##// END OF EJS Templates
Fixes to input splitting to reduce the occurrences of spurious attribute...
fperez -
Show More
@@ -1,3084 +1,3085 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 2104 2007-02-20 10:25:51Z fperez $"""
4 $Id: Magic.py 2122 2007-03-01 02:27:11Z fperez $"""
5
5
6 #*****************************************************************************
6 #*****************************************************************************
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
8 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
8 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
9 #
9 #
10 # Distributed under the terms of the BSD License. The full license is in
10 # Distributed under the terms of the BSD License. The full license is in
11 # the file COPYING, distributed as part of this software.
11 # the file COPYING, distributed as part of this software.
12 #*****************************************************************************
12 #*****************************************************************************
13
13
14 #****************************************************************************
14 #****************************************************************************
15 # Modules and globals
15 # Modules and globals
16
16
17 from IPython import Release
17 from IPython import Release
18 __author__ = '%s <%s>\n%s <%s>' % \
18 __author__ = '%s <%s>\n%s <%s>' % \
19 ( Release.authors['Janko'] + Release.authors['Fernando'] )
19 ( Release.authors['Janko'] + Release.authors['Fernando'] )
20 __license__ = Release.license
20 __license__ = Release.license
21
21
22 # Python standard modules
22 # Python standard modules
23 import __builtin__
23 import __builtin__
24 import bdb
24 import bdb
25 import inspect
25 import inspect
26 import os
26 import os
27 import pdb
27 import pdb
28 import pydoc
28 import pydoc
29 import sys
29 import sys
30 import re
30 import re
31 import tempfile
31 import tempfile
32 import time
32 import time
33 import cPickle as pickle
33 import cPickle as pickle
34 import textwrap
34 import textwrap
35 from cStringIO import StringIO
35 from cStringIO import StringIO
36 from getopt import getopt,GetoptError
36 from getopt import getopt,GetoptError
37 from pprint import pprint, pformat
37 from pprint import pprint, pformat
38
38
39 # cProfile was added in Python2.5
39 # cProfile was added in Python2.5
40 try:
40 try:
41 import cProfile as profile
41 import cProfile as profile
42 import pstats
42 import pstats
43 except ImportError:
43 except ImportError:
44 # profile isn't bundled by default in Debian for license reasons
44 # profile isn't bundled by default in Debian for license reasons
45 try:
45 try:
46 import profile,pstats
46 import profile,pstats
47 except ImportError:
47 except ImportError:
48 profile = pstats = None
48 profile = pstats = None
49
49
50 # Homebrewed
50 # Homebrewed
51 import IPython
51 import IPython
52 from IPython import Debugger, OInspect, wildcard
52 from IPython import Debugger, OInspect, wildcard
53 from IPython.FakeModule import FakeModule
53 from IPython.FakeModule import FakeModule
54 from IPython.Itpl import Itpl, itpl, printpl,itplns
54 from IPython.Itpl import Itpl, itpl, printpl,itplns
55 from IPython.PyColorize import Parser
55 from IPython.PyColorize import Parser
56 from IPython.ipstruct import Struct
56 from IPython.ipstruct import Struct
57 from IPython.macro import Macro
57 from IPython.macro import Macro
58 from IPython.genutils import *
58 from IPython.genutils import *
59 from IPython import platutils
59 from IPython import platutils
60
60
61 #***************************************************************************
61 #***************************************************************************
62 # Utility functions
62 # Utility functions
63 def on_off(tag):
63 def on_off(tag):
64 """Return an ON/OFF string for a 1/0 input. Simple utility function."""
64 """Return an ON/OFF string for a 1/0 input. Simple utility function."""
65 return ['OFF','ON'][tag]
65 return ['OFF','ON'][tag]
66
66
67 class Bunch: pass
67 class Bunch: pass
68
68
69 #***************************************************************************
69 #***************************************************************************
70 # Main class implementing Magic functionality
70 # Main class implementing Magic functionality
71 class Magic:
71 class Magic:
72 """Magic functions for InteractiveShell.
72 """Magic functions for InteractiveShell.
73
73
74 Shell functions which can be reached as %function_name. All magic
74 Shell functions which can be reached as %function_name. All magic
75 functions should accept a string, which they can parse for their own
75 functions should accept a string, which they can parse for their own
76 needs. This can make some functions easier to type, eg `%cd ../`
76 needs. This can make some functions easier to type, eg `%cd ../`
77 vs. `%cd("../")`
77 vs. `%cd("../")`
78
78
79 ALL definitions MUST begin with the prefix magic_. The user won't need it
79 ALL definitions MUST begin with the prefix magic_. The user won't need it
80 at the command line, but it is is needed in the definition. """
80 at the command line, but it is is needed in the definition. """
81
81
82 # class globals
82 # class globals
83 auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.',
83 auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.',
84 'Automagic is ON, % prefix NOT needed for magic functions.']
84 'Automagic is ON, % prefix NOT needed for magic functions.']
85
85
86 #......................................................................
86 #......................................................................
87 # some utility functions
87 # some utility functions
88
88
89 def __init__(self,shell):
89 def __init__(self,shell):
90
90
91 self.options_table = {}
91 self.options_table = {}
92 if profile is None:
92 if profile is None:
93 self.magic_prun = self.profile_missing_notice
93 self.magic_prun = self.profile_missing_notice
94 self.shell = shell
94 self.shell = shell
95
95
96 # namespace for holding state we may need
96 # namespace for holding state we may need
97 self._magic_state = Bunch()
97 self._magic_state = Bunch()
98
98
99 def profile_missing_notice(self, *args, **kwargs):
99 def profile_missing_notice(self, *args, **kwargs):
100 error("""\
100 error("""\
101 The profile module could not be found. If you are a Debian user,
101 The profile module could not be found. If you are a Debian user,
102 it has been removed from the standard Debian package because of its non-free
102 it has been removed from the standard Debian package because of its non-free
103 license. To use profiling, please install"python2.3-profiler" from non-free.""")
103 license. To use profiling, please install"python2.3-profiler" from non-free.""")
104
104
105 def default_option(self,fn,optstr):
105 def default_option(self,fn,optstr):
106 """Make an entry in the options_table for fn, with value optstr"""
106 """Make an entry in the options_table for fn, with value optstr"""
107
107
108 if fn not in self.lsmagic():
108 if fn not in self.lsmagic():
109 error("%s is not a magic function" % fn)
109 error("%s is not a magic function" % fn)
110 self.options_table[fn] = optstr
110 self.options_table[fn] = optstr
111
111
112 def lsmagic(self):
112 def lsmagic(self):
113 """Return a list of currently available magic functions.
113 """Return a list of currently available magic functions.
114
114
115 Gives a list of the bare names after mangling (['ls','cd', ...], not
115 Gives a list of the bare names after mangling (['ls','cd', ...], not
116 ['magic_ls','magic_cd',...]"""
116 ['magic_ls','magic_cd',...]"""
117
117
118 # FIXME. This needs a cleanup, in the way the magics list is built.
118 # FIXME. This needs a cleanup, in the way the magics list is built.
119
119
120 # magics in class definition
120 # magics in class definition
121 class_magic = lambda fn: fn.startswith('magic_') and \
121 class_magic = lambda fn: fn.startswith('magic_') and \
122 callable(Magic.__dict__[fn])
122 callable(Magic.__dict__[fn])
123 # in instance namespace (run-time user additions)
123 # in instance namespace (run-time user additions)
124 inst_magic = lambda fn: fn.startswith('magic_') and \
124 inst_magic = lambda fn: fn.startswith('magic_') and \
125 callable(self.__dict__[fn])
125 callable(self.__dict__[fn])
126 # and bound magics by user (so they can access self):
126 # and bound magics by user (so they can access self):
127 inst_bound_magic = lambda fn: fn.startswith('magic_') and \
127 inst_bound_magic = lambda fn: fn.startswith('magic_') and \
128 callable(self.__class__.__dict__[fn])
128 callable(self.__class__.__dict__[fn])
129 magics = filter(class_magic,Magic.__dict__.keys()) + \
129 magics = filter(class_magic,Magic.__dict__.keys()) + \
130 filter(inst_magic,self.__dict__.keys()) + \
130 filter(inst_magic,self.__dict__.keys()) + \
131 filter(inst_bound_magic,self.__class__.__dict__.keys())
131 filter(inst_bound_magic,self.__class__.__dict__.keys())
132 out = []
132 out = []
133 for fn in magics:
133 for fn in magics:
134 out.append(fn.replace('magic_','',1))
134 out.append(fn.replace('magic_','',1))
135 out.sort()
135 out.sort()
136 return out
136 return out
137
137
138 def extract_input_slices(self,slices,raw=False):
138 def extract_input_slices(self,slices,raw=False):
139 """Return as a string a set of input history slices.
139 """Return as a string a set of input history slices.
140
140
141 Inputs:
141 Inputs:
142
142
143 - slices: the set of slices is given as a list of strings (like
143 - slices: the set of slices is given as a list of strings (like
144 ['1','4:8','9'], since this function is for use by magic functions
144 ['1','4:8','9'], since this function is for use by magic functions
145 which get their arguments as strings.
145 which get their arguments as strings.
146
146
147 Optional inputs:
147 Optional inputs:
148
148
149 - raw(False): by default, the processed input is used. If this is
149 - raw(False): by default, the processed input is used. If this is
150 true, the raw input history is used instead.
150 true, the raw input history is used instead.
151
151
152 Note that slices can be called with two notations:
152 Note that slices can be called with two notations:
153
153
154 N:M -> standard python form, means including items N...(M-1).
154 N:M -> standard python form, means including items N...(M-1).
155
155
156 N-M -> include items N..M (closed endpoint)."""
156 N-M -> include items N..M (closed endpoint)."""
157
157
158 if raw:
158 if raw:
159 hist = self.shell.input_hist_raw
159 hist = self.shell.input_hist_raw
160 else:
160 else:
161 hist = self.shell.input_hist
161 hist = self.shell.input_hist
162
162
163 cmds = []
163 cmds = []
164 for chunk in slices:
164 for chunk in slices:
165 if ':' in chunk:
165 if ':' in chunk:
166 ini,fin = map(int,chunk.split(':'))
166 ini,fin = map(int,chunk.split(':'))
167 elif '-' in chunk:
167 elif '-' in chunk:
168 ini,fin = map(int,chunk.split('-'))
168 ini,fin = map(int,chunk.split('-'))
169 fin += 1
169 fin += 1
170 else:
170 else:
171 ini = int(chunk)
171 ini = int(chunk)
172 fin = ini+1
172 fin = ini+1
173 cmds.append(hist[ini:fin])
173 cmds.append(hist[ini:fin])
174 return cmds
174 return cmds
175
175
176 def _ofind(self, oname, namespaces=None):
176 def _ofind(self, oname, namespaces=None):
177 """Find an object in the available namespaces.
177 """Find an object in the available namespaces.
178
178
179 self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic
179 self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic
180
180
181 Has special code to detect magic functions.
181 Has special code to detect magic functions.
182 """
182 """
183
183
184 oname = oname.strip()
184 oname = oname.strip()
185
185
186 alias_ns = None
186 alias_ns = None
187 if namespaces is None:
187 if namespaces is None:
188 # Namespaces to search in:
188 # Namespaces to search in:
189 # Put them in a list. The order is important so that we
189 # Put them in a list. The order is important so that we
190 # find things in the same order that Python finds them.
190 # find things in the same order that Python finds them.
191 namespaces = [ ('Interactive', self.shell.user_ns),
191 namespaces = [ ('Interactive', self.shell.user_ns),
192 ('IPython internal', self.shell.internal_ns),
192 ('IPython internal', self.shell.internal_ns),
193 ('Python builtin', __builtin__.__dict__),
193 ('Python builtin', __builtin__.__dict__),
194 ('Alias', self.shell.alias_table),
194 ('Alias', self.shell.alias_table),
195 ]
195 ]
196 alias_ns = self.shell.alias_table
196 alias_ns = self.shell.alias_table
197
197
198 # initialize results to 'null'
198 # initialize results to 'null'
199 found = 0; obj = None; ospace = None; ds = None;
199 found = 0; obj = None; ospace = None; ds = None;
200 ismagic = 0; isalias = 0; parent = None
200 ismagic = 0; isalias = 0; parent = None
201
201
202 # Look for the given name by splitting it in parts. If the head is
202 # Look for the given name by splitting it in parts. If the head is
203 # found, then we look for all the remaining parts as members, and only
203 # found, then we look for all the remaining parts as members, and only
204 # declare success if we can find them all.
204 # declare success if we can find them all.
205 oname_parts = oname.split('.')
205 oname_parts = oname.split('.')
206 oname_head, oname_rest = oname_parts[0],oname_parts[1:]
206 oname_head, oname_rest = oname_parts[0],oname_parts[1:]
207 for nsname,ns in namespaces:
207 for nsname,ns in namespaces:
208 try:
208 try:
209 obj = ns[oname_head]
209 obj = ns[oname_head]
210 except KeyError:
210 except KeyError:
211 continue
211 continue
212 else:
212 else:
213 #print 'oname_rest:', oname_rest # dbg
213 for part in oname_rest:
214 for part in oname_rest:
214 try:
215 try:
215 parent = obj
216 parent = obj
216 obj = getattr(obj,part)
217 obj = getattr(obj,part)
217 except:
218 except:
218 # Blanket except b/c some badly implemented objects
219 # Blanket except b/c some badly implemented objects
219 # allow __getattr__ to raise exceptions other than
220 # allow __getattr__ to raise exceptions other than
220 # AttributeError, which then crashes IPython.
221 # AttributeError, which then crashes IPython.
221 break
222 break
222 else:
223 else:
223 # 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
224 found = 1
225 found = 1
225 ospace = nsname
226 ospace = nsname
226 if ns == alias_ns:
227 if ns == alias_ns:
227 isalias = 1
228 isalias = 1
228 break # namespace loop
229 break # namespace loop
229
230
230 # Try to see if it's magic
231 # Try to see if it's magic
231 if not found:
232 if not found:
232 if oname.startswith(self.shell.ESC_MAGIC):
233 if oname.startswith(self.shell.ESC_MAGIC):
233 oname = oname[1:]
234 oname = oname[1:]
234 obj = getattr(self,'magic_'+oname,None)
235 obj = getattr(self,'magic_'+oname,None)
235 if obj is not None:
236 if obj is not None:
236 found = 1
237 found = 1
237 ospace = 'IPython internal'
238 ospace = 'IPython internal'
238 ismagic = 1
239 ismagic = 1
239
240
240 # Last try: special-case some literals like '', [], {}, etc:
241 # Last try: special-case some literals like '', [], {}, etc:
241 if not found and oname_head in ["''",'""','[]','{}','()']:
242 if not found and oname_head in ["''",'""','[]','{}','()']:
242 obj = eval(oname_head)
243 obj = eval(oname_head)
243 found = 1
244 found = 1
244 ospace = 'Interactive'
245 ospace = 'Interactive'
245
246
246 return {'found':found, 'obj':obj, 'namespace':ospace,
247 return {'found':found, 'obj':obj, 'namespace':ospace,
247 'ismagic':ismagic, 'isalias':isalias, 'parent':parent}
248 'ismagic':ismagic, 'isalias':isalias, 'parent':parent}
248
249
249 def arg_err(self,func):
250 def arg_err(self,func):
250 """Print docstring if incorrect arguments were passed"""
251 """Print docstring if incorrect arguments were passed"""
251 print 'Error in arguments:'
252 print 'Error in arguments:'
252 print OInspect.getdoc(func)
253 print OInspect.getdoc(func)
253
254
254 def format_latex(self,strng):
255 def format_latex(self,strng):
255 """Format a string for latex inclusion."""
256 """Format a string for latex inclusion."""
256
257
257 # Characters that need to be escaped for latex:
258 # Characters that need to be escaped for latex:
258 escape_re = re.compile(r'(%|_|\$|#|&)',re.MULTILINE)
259 escape_re = re.compile(r'(%|_|\$|#|&)',re.MULTILINE)
259 # Magic command names as headers:
260 # Magic command names as headers:
260 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
261 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
261 re.MULTILINE)
262 re.MULTILINE)
262 # Magic commands
263 # Magic commands
263 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,
264 re.MULTILINE)
265 re.MULTILINE)
265 # Paragraph continue
266 # Paragraph continue
266 par_re = re.compile(r'\\$',re.MULTILINE)
267 par_re = re.compile(r'\\$',re.MULTILINE)
267
268
268 # The "\n" symbol
269 # The "\n" symbol
269 newline_re = re.compile(r'\\n')
270 newline_re = re.compile(r'\\n')
270
271
271 # Now build the string for output:
272 # Now build the string for output:
272 #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)
273 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}}:',
274 strng)
275 strng)
275 strng = cmd_re.sub(r'\\texttt{\g<cmd>}',strng)
276 strng = cmd_re.sub(r'\\texttt{\g<cmd>}',strng)
276 strng = par_re.sub(r'\\\\',strng)
277 strng = par_re.sub(r'\\\\',strng)
277 strng = escape_re.sub(r'\\\1',strng)
278 strng = escape_re.sub(r'\\\1',strng)
278 strng = newline_re.sub(r'\\textbackslash{}n',strng)
279 strng = newline_re.sub(r'\\textbackslash{}n',strng)
279 return strng
280 return strng
280
281
281 def format_screen(self,strng):
282 def format_screen(self,strng):
282 """Format a string for screen printing.
283 """Format a string for screen printing.
283
284
284 This removes some latex-type format codes."""
285 This removes some latex-type format codes."""
285 # Paragraph continue
286 # Paragraph continue
286 par_re = re.compile(r'\\$',re.MULTILINE)
287 par_re = re.compile(r'\\$',re.MULTILINE)
287 strng = par_re.sub('',strng)
288 strng = par_re.sub('',strng)
288 return strng
289 return strng
289
290
290 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
291 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
291 """Parse options passed to an argument string.
292 """Parse options passed to an argument string.
292
293
293 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
294 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
295 as a string.
296 as a string.
296
297
297 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.
298 This allows us to easily expand variables, glob files, quote
299 This allows us to easily expand variables, glob files, quote
299 arguments, etc.
300 arguments, etc.
300
301
301 Options:
302 Options:
302 -mode: default 'string'. If given as 'list', the argument string is
303 -mode: default 'string'. If given as 'list', the argument string is
303 returned as a list (split on whitespace) instead of a string.
304 returned as a list (split on whitespace) instead of a string.
304
305
305 -list_all: put all option values in lists. Normally only options
306 -list_all: put all option values in lists. Normally only options
306 appearing more than once are put in a list.
307 appearing more than once are put in a list.
307
308
308 -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,
309 as per the conventions outlined in the shlex module from the
310 as per the conventions outlined in the shlex module from the
310 standard library."""
311 standard library."""
311
312
312 # inject default options at the beginning of the input line
313 # inject default options at the beginning of the input line
313 caller = sys._getframe(1).f_code.co_name.replace('magic_','')
314 caller = sys._getframe(1).f_code.co_name.replace('magic_','')
314 arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str)
315 arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str)
315
316
316 mode = kw.get('mode','string')
317 mode = kw.get('mode','string')
317 if mode not in ['string','list']:
318 if mode not in ['string','list']:
318 raise ValueError,'incorrect mode given: %s' % mode
319 raise ValueError,'incorrect mode given: %s' % mode
319 # Get options
320 # Get options
320 list_all = kw.get('list_all',0)
321 list_all = kw.get('list_all',0)
321 posix = kw.get('posix',True)
322 posix = kw.get('posix',True)
322
323
323 # 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:
324 odict = {} # Dictionary with options
325 odict = {} # Dictionary with options
325 args = arg_str.split()
326 args = arg_str.split()
326 if len(args) >= 1:
327 if len(args) >= 1:
327 # 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
328 # need to look for options
329 # need to look for options
329 argv = arg_split(arg_str,posix)
330 argv = arg_split(arg_str,posix)
330 # Do regular option processing
331 # Do regular option processing
331 try:
332 try:
332 opts,args = getopt(argv,opt_str,*long_opts)
333 opts,args = getopt(argv,opt_str,*long_opts)
333 except GetoptError,e:
334 except GetoptError,e:
334 raise GetoptError('%s ( allowed: "%s" %s)' % (e.msg,opt_str,
335 raise GetoptError('%s ( allowed: "%s" %s)' % (e.msg,opt_str,
335 " ".join(long_opts)))
336 " ".join(long_opts)))
336 for o,a in opts:
337 for o,a in opts:
337 if o.startswith('--'):
338 if o.startswith('--'):
338 o = o[2:]
339 o = o[2:]
339 else:
340 else:
340 o = o[1:]
341 o = o[1:]
341 try:
342 try:
342 odict[o].append(a)
343 odict[o].append(a)
343 except AttributeError:
344 except AttributeError:
344 odict[o] = [odict[o],a]
345 odict[o] = [odict[o],a]
345 except KeyError:
346 except KeyError:
346 if list_all:
347 if list_all:
347 odict[o] = [a]
348 odict[o] = [a]
348 else:
349 else:
349 odict[o] = a
350 odict[o] = a
350
351
351 # Prepare opts,args for return
352 # Prepare opts,args for return
352 opts = Struct(odict)
353 opts = Struct(odict)
353 if mode == 'string':
354 if mode == 'string':
354 args = ' '.join(args)
355 args = ' '.join(args)
355
356
356 return opts,args
357 return opts,args
357
358
358 #......................................................................
359 #......................................................................
359 # And now the actual magic functions
360 # And now the actual magic functions
360
361
361 # Functions for IPython shell work (vars,funcs, config, etc)
362 # Functions for IPython shell work (vars,funcs, config, etc)
362 def magic_lsmagic(self, parameter_s = ''):
363 def magic_lsmagic(self, parameter_s = ''):
363 """List currently available magic functions."""
364 """List currently available magic functions."""
364 mesc = self.shell.ESC_MAGIC
365 mesc = self.shell.ESC_MAGIC
365 print 'Available magic functions:\n'+mesc+\
366 print 'Available magic functions:\n'+mesc+\
366 (' '+mesc).join(self.lsmagic())
367 (' '+mesc).join(self.lsmagic())
367 print '\n' + Magic.auto_status[self.shell.rc.automagic]
368 print '\n' + Magic.auto_status[self.shell.rc.automagic]
368 return None
369 return None
369
370
370 def magic_magic(self, parameter_s = ''):
371 def magic_magic(self, parameter_s = ''):
371 """Print information about the magic function system."""
372 """Print information about the magic function system."""
372
373
373 mode = ''
374 mode = ''
374 try:
375 try:
375 if parameter_s.split()[0] == '-latex':
376 if parameter_s.split()[0] == '-latex':
376 mode = 'latex'
377 mode = 'latex'
377 if parameter_s.split()[0] == '-brief':
378 if parameter_s.split()[0] == '-brief':
378 mode = 'brief'
379 mode = 'brief'
379 except:
380 except:
380 pass
381 pass
381
382
382 magic_docs = []
383 magic_docs = []
383 for fname in self.lsmagic():
384 for fname in self.lsmagic():
384 mname = 'magic_' + fname
385 mname = 'magic_' + fname
385 for space in (Magic,self,self.__class__):
386 for space in (Magic,self,self.__class__):
386 try:
387 try:
387 fn = space.__dict__[mname]
388 fn = space.__dict__[mname]
388 except KeyError:
389 except KeyError:
389 pass
390 pass
390 else:
391 else:
391 break
392 break
392 if mode == 'brief':
393 if mode == 'brief':
393 # only first line
394 # only first line
394 fndoc = fn.__doc__.split('\n',1)[0]
395 fndoc = fn.__doc__.split('\n',1)[0]
395 else:
396 else:
396 fndoc = fn.__doc__
397 fndoc = fn.__doc__
397
398
398 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,
399 fname,fndoc))
400 fname,fndoc))
400 magic_docs = ''.join(magic_docs)
401 magic_docs = ''.join(magic_docs)
401
402
402 if mode == 'latex':
403 if mode == 'latex':
403 print self.format_latex(magic_docs)
404 print self.format_latex(magic_docs)
404 return
405 return
405 else:
406 else:
406 magic_docs = self.format_screen(magic_docs)
407 magic_docs = self.format_screen(magic_docs)
407 if mode == 'brief':
408 if mode == 'brief':
408 return magic_docs
409 return magic_docs
409
410
410 outmsg = """
411 outmsg = """
411 IPython's 'magic' functions
412 IPython's 'magic' functions
412 ===========================
413 ===========================
413
414
414 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
415 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
416 features. All these functions are prefixed with a % character, but parameters
417 features. All these functions are prefixed with a % character, but parameters
417 are given without parentheses or quotes.
418 are given without parentheses or quotes.
418
419
419 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
420 %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,
421 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.
422
423
423 Example: typing '%cd mydir' (without the quotes) changes you working directory
424 Example: typing '%cd mydir' (without the quotes) changes you working directory
424 to 'mydir', if it exists.
425 to 'mydir', if it exists.
425
426
426 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
427 ipythonrc and example-magic.py files for details (in your ipython
428 ipythonrc and example-magic.py files for details (in your ipython
428 configuration directory, typically $HOME/.ipython/).
429 configuration directory, typically $HOME/.ipython/).
429
430
430 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
431 ipythonrc file, placing a line like:
432 ipythonrc file, placing a line like:
432
433
433 execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
434 execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
434
435
435 will define %pf as a new name for %profile.
436 will define %pf as a new name for %profile.
436
437
437 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
438 automatically adds to the builtin namespace. Type 'ipmagic?' for details.
439 automatically adds to the builtin namespace. Type 'ipmagic?' for details.
439
440
440 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
441 of any of them, type %magic_name?, e.g. '%cd?'.
442 of any of them, type %magic_name?, e.g. '%cd?'.
442
443
443 Currently the magic system has the following functions:\n"""
444 Currently the magic system has the following functions:\n"""
444
445
445 mesc = self.shell.ESC_MAGIC
446 mesc = self.shell.ESC_MAGIC
446 outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):"
447 outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):"
447 "\n\n%s%s\n\n%s" % (outmsg,
448 "\n\n%s%s\n\n%s" % (outmsg,
448 magic_docs,mesc,mesc,
449 magic_docs,mesc,mesc,
449 (' '+mesc).join(self.lsmagic()),
450 (' '+mesc).join(self.lsmagic()),
450 Magic.auto_status[self.shell.rc.automagic] ) )
451 Magic.auto_status[self.shell.rc.automagic] ) )
451
452
452 page(outmsg,screen_lines=self.shell.rc.screen_length)
453 page(outmsg,screen_lines=self.shell.rc.screen_length)
453
454
454 def magic_automagic(self, parameter_s = ''):
455 def magic_automagic(self, parameter_s = ''):
455 """Make magic functions callable without having to type the initial %.
456 """Make magic functions callable without having to type the initial %.
456
457
457 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
458 %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
459 use any of (case insensitive):
460 use any of (case insensitive):
460
461
461 - on,1,True: to activate
462 - on,1,True: to activate
462
463
463 - off,0,False: to deactivate.
464 - off,0,False: to deactivate.
464
465
465 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
466 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
467 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
468 delete the variable (del var), the previously shadowed magic function
469 delete the variable (del var), the previously shadowed magic function
469 becomes visible to automagic again."""
470 becomes visible to automagic again."""
470
471
471 rc = self.shell.rc
472 rc = self.shell.rc
472 arg = parameter_s.lower()
473 arg = parameter_s.lower()
473 if parameter_s in ('on','1','true'):
474 if parameter_s in ('on','1','true'):
474 rc.automagic = True
475 rc.automagic = True
475 elif parameter_s in ('off','0','false'):
476 elif parameter_s in ('off','0','false'):
476 rc.automagic = False
477 rc.automagic = False
477 else:
478 else:
478 rc.automagic = not rc.automagic
479 rc.automagic = not rc.automagic
479 print '\n' + Magic.auto_status[rc.automagic]
480 print '\n' + Magic.auto_status[rc.automagic]
480
481
481 def magic_autocall(self, parameter_s = ''):
482 def magic_autocall(self, parameter_s = ''):
482 """Make functions callable without having to type parentheses.
483 """Make functions callable without having to type parentheses.
483
484
484 Usage:
485 Usage:
485
486
486 %autocall [mode]
487 %autocall [mode]
487
488
488 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
489 value is toggled on and off (remembering the previous state)."""
490 value is toggled on and off (remembering the previous state)."""
490
491
491 rc = self.shell.rc
492 rc = self.shell.rc
492
493
493 if parameter_s:
494 if parameter_s:
494 arg = int(parameter_s)
495 arg = int(parameter_s)
495 else:
496 else:
496 arg = 'toggle'
497 arg = 'toggle'
497
498
498 if not arg in (0,1,2,'toggle'):
499 if not arg in (0,1,2,'toggle'):
499 error('Valid modes: (0->Off, 1->Smart, 2->Full')
500 error('Valid modes: (0->Off, 1->Smart, 2->Full')
500 return
501 return
501
502
502 if arg in (0,1,2):
503 if arg in (0,1,2):
503 rc.autocall = arg
504 rc.autocall = arg
504 else: # toggle
505 else: # toggle
505 if rc.autocall:
506 if rc.autocall:
506 self._magic_state.autocall_save = rc.autocall
507 self._magic_state.autocall_save = rc.autocall
507 rc.autocall = 0
508 rc.autocall = 0
508 else:
509 else:
509 try:
510 try:
510 rc.autocall = self._magic_state.autocall_save
511 rc.autocall = self._magic_state.autocall_save
511 except AttributeError:
512 except AttributeError:
512 rc.autocall = self._magic_state.autocall_save = 1
513 rc.autocall = self._magic_state.autocall_save = 1
513
514
514 print "Automatic calling is:",['OFF','Smart','Full'][rc.autocall]
515 print "Automatic calling is:",['OFF','Smart','Full'][rc.autocall]
515
516
516 def magic_autoindent(self, parameter_s = ''):
517 def magic_autoindent(self, parameter_s = ''):
517 """Toggle autoindent on/off (if available)."""
518 """Toggle autoindent on/off (if available)."""
518
519
519 self.shell.set_autoindent()
520 self.shell.set_autoindent()
520 print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent]
521 print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent]
521
522
522 def magic_system_verbose(self, parameter_s = ''):
523 def magic_system_verbose(self, parameter_s = ''):
523 """Set verbose printing of system calls.
524 """Set verbose printing of system calls.
524
525
525 If called without an argument, act as a toggle"""
526 If called without an argument, act as a toggle"""
526
527
527 if parameter_s:
528 if parameter_s:
528 val = bool(eval(parameter_s))
529 val = bool(eval(parameter_s))
529 else:
530 else:
530 val = None
531 val = None
531
532
532 self.shell.rc_set_toggle('system_verbose',val)
533 self.shell.rc_set_toggle('system_verbose',val)
533 print "System verbose printing is:",\
534 print "System verbose printing is:",\
534 ['OFF','ON'][self.shell.rc.system_verbose]
535 ['OFF','ON'][self.shell.rc.system_verbose]
535
536
536 def magic_history(self, parameter_s = ''):
537 def magic_history(self, parameter_s = ''):
537 """Print input history (_i<n> variables), with most recent last.
538 """Print input history (_i<n> variables), with most recent last.
538
539
539 %history -> print at most 40 inputs (some may be multi-line)\\
540 %history -> print at most 40 inputs (some may be multi-line)\\
540 %history n -> print at most n inputs\\
541 %history n -> print at most n inputs\\
541 %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)\\
542
543
543 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
544 automatically generated variable _i<n>. Multi-line statements are
545 automatically generated variable _i<n>. Multi-line statements are
545 printed starting at a new line for easy copy/paste.
546 printed starting at a new line for easy copy/paste.
546
547
547
548
548 Options:
549 Options:
549
550
550 -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
551 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
552 editor.
553 editor.
553
554
554 This feature is only available if numbered prompts are in use.
555 This feature is only available if numbered prompts are in use.
555
556
556 -r: print the 'raw' history. IPython filters your input and
557 -r: print the 'raw' history. IPython filters your input and
557 converts it all into valid Python source before executing it (things
558 converts it all into valid Python source before executing it (things
558 like magics or aliases are turned into function calls, for
559 like magics or aliases are turned into function calls, for
559 example). With this option, you'll see the unfiltered history
560 example). With this option, you'll see the unfiltered history
560 instead of the filtered version: '%cd /' will be seen as '%cd /'
561 instead of the filtered version: '%cd /' will be seen as '%cd /'
561 instead of '_ip.magic("%cd /")'.
562 instead of '_ip.magic("%cd /")'.
562 """
563 """
563
564
564 shell = self.shell
565 shell = self.shell
565 if not shell.outputcache.do_full_cache:
566 if not shell.outputcache.do_full_cache:
566 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.'
567 return
568 return
568 opts,args = self.parse_options(parameter_s,'nr',mode='list')
569 opts,args = self.parse_options(parameter_s,'nr',mode='list')
569
570
570 if opts.has_key('r'):
571 if opts.has_key('r'):
571 input_hist = shell.input_hist_raw
572 input_hist = shell.input_hist_raw
572 else:
573 else:
573 input_hist = shell.input_hist
574 input_hist = shell.input_hist
574
575
575 default_length = 40
576 default_length = 40
576 if len(args) == 0:
577 if len(args) == 0:
577 final = len(input_hist)
578 final = len(input_hist)
578 init = max(1,final-default_length)
579 init = max(1,final-default_length)
579 elif len(args) == 1:
580 elif len(args) == 1:
580 final = len(input_hist)
581 final = len(input_hist)
581 init = max(1,final-int(args[0]))
582 init = max(1,final-int(args[0]))
582 elif len(args) == 2:
583 elif len(args) == 2:
583 init,final = map(int,args)
584 init,final = map(int,args)
584 else:
585 else:
585 warn('%hist takes 0, 1 or 2 arguments separated by spaces.')
586 warn('%hist takes 0, 1 or 2 arguments separated by spaces.')
586 print self.magic_hist.__doc__
587 print self.magic_hist.__doc__
587 return
588 return
588 width = len(str(final))
589 width = len(str(final))
589 line_sep = ['','\n']
590 line_sep = ['','\n']
590 print_nums = not opts.has_key('n')
591 print_nums = not opts.has_key('n')
591 for in_num in range(init,final):
592 for in_num in range(init,final):
592 inline = input_hist[in_num]
593 inline = input_hist[in_num]
593 multiline = int(inline.count('\n') > 1)
594 multiline = int(inline.count('\n') > 1)
594 if print_nums:
595 if print_nums:
595 print '%s:%s' % (str(in_num).ljust(width),line_sep[multiline]),
596 print '%s:%s' % (str(in_num).ljust(width),line_sep[multiline]),
596 print inline,
597 print inline,
597
598
598 def magic_hist(self, parameter_s=''):
599 def magic_hist(self, parameter_s=''):
599 """Alternate name for %history."""
600 """Alternate name for %history."""
600 return self.magic_history(parameter_s)
601 return self.magic_history(parameter_s)
601
602
602 def magic_p(self, parameter_s=''):
603 def magic_p(self, parameter_s=''):
603 """Just a short alias for Python's 'print'."""
604 """Just a short alias for Python's 'print'."""
604 exec 'print ' + parameter_s in self.shell.user_ns
605 exec 'print ' + parameter_s in self.shell.user_ns
605
606
606 def magic_r(self, parameter_s=''):
607 def magic_r(self, parameter_s=''):
607 """Repeat previous input.
608 """Repeat previous input.
608
609
609 If given an argument, repeats the previous command which starts with
610 If given an argument, repeats the previous command which starts with
610 the same string, otherwise it just repeats the previous input.
611 the same string, otherwise it just repeats the previous input.
611
612
612 Shell escaped commands (with ! as first character) are not recognized
613 Shell escaped commands (with ! as first character) are not recognized
613 by this system, only pure python code and magic commands.
614 by this system, only pure python code and magic commands.
614 """
615 """
615
616
616 start = parameter_s.strip()
617 start = parameter_s.strip()
617 esc_magic = self.shell.ESC_MAGIC
618 esc_magic = self.shell.ESC_MAGIC
618 # Identify magic commands even if automagic is on (which means
619 # Identify magic commands even if automagic is on (which means
619 # 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).
620 if self.shell.rc.automagic:
621 if self.shell.rc.automagic:
621 start_magic = esc_magic+start
622 start_magic = esc_magic+start
622 else:
623 else:
623 start_magic = start
624 start_magic = start
624 # Look through the input history in reverse
625 # Look through the input history in reverse
625 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):
626 input = self.shell.input_hist[n]
627 input = self.shell.input_hist[n]
627 # skip plain 'r' lines so we don't recurse to infinity
628 # skip plain 'r' lines so we don't recurse to infinity
628 if input != '_ip.magic("r")\n' and \
629 if input != '_ip.magic("r")\n' and \
629 (input.startswith(start) or input.startswith(start_magic)):
630 (input.startswith(start) or input.startswith(start_magic)):
630 #print 'match',`input` # dbg
631 #print 'match',`input` # dbg
631 print 'Executing:',input,
632 print 'Executing:',input,
632 self.shell.runlines(input)
633 self.shell.runlines(input)
633 return
634 return
634 print 'No previous input matching `%s` found.' % start
635 print 'No previous input matching `%s` found.' % start
635
636
636 def magic_page(self, parameter_s=''):
637 def magic_page(self, parameter_s=''):
637 """Pretty print the object and display it through a pager.
638 """Pretty print the object and display it through a pager.
638
639
639 %page [options] OBJECT
640 %page [options] OBJECT
640
641
641 If no object is given, use _ (last output).
642 If no object is given, use _ (last output).
642
643
643 Options:
644 Options:
644
645
645 -r: page str(object), don't pretty-print it."""
646 -r: page str(object), don't pretty-print it."""
646
647
647 # After a function contributed by Olivier Aubert, slightly modified.
648 # After a function contributed by Olivier Aubert, slightly modified.
648
649
649 # Process options/args
650 # Process options/args
650 opts,args = self.parse_options(parameter_s,'r')
651 opts,args = self.parse_options(parameter_s,'r')
651 raw = 'r' in opts
652 raw = 'r' in opts
652
653
653 oname = args and args or '_'
654 oname = args and args or '_'
654 info = self._ofind(oname)
655 info = self._ofind(oname)
655 if info['found']:
656 if info['found']:
656 txt = (raw and str or pformat)( info['obj'] )
657 txt = (raw and str or pformat)( info['obj'] )
657 page(txt)
658 page(txt)
658 else:
659 else:
659 print 'Object `%s` not found' % oname
660 print 'Object `%s` not found' % oname
660
661
661 def magic_profile(self, parameter_s=''):
662 def magic_profile(self, parameter_s=''):
662 """Print your currently active IPyhton profile."""
663 """Print your currently active IPyhton profile."""
663 if self.shell.rc.profile:
664 if self.shell.rc.profile:
664 printpl('Current IPython profile: $self.shell.rc.profile.')
665 printpl('Current IPython profile: $self.shell.rc.profile.')
665 else:
666 else:
666 print 'No profile active.'
667 print 'No profile active.'
667
668
668 def _inspect(self,meth,oname,namespaces=None,**kw):
669 def _inspect(self,meth,oname,namespaces=None,**kw):
669 """Generic interface to the inspector system.
670 """Generic interface to the inspector system.
670
671
671 This function is meant to be called by pdef, pdoc & friends."""
672 This function is meant to be called by pdef, pdoc & friends."""
672
673
673 oname = oname.strip()
674 oname = oname.strip()
674 info = Struct(self._ofind(oname, namespaces))
675 info = Struct(self._ofind(oname, namespaces))
675
676
676 if info.found:
677 if info.found:
677 # Get the docstring of the class property if it exists.
678 # Get the docstring of the class property if it exists.
678 path = oname.split('.')
679 path = oname.split('.')
679 root = '.'.join(path[:-1])
680 root = '.'.join(path[:-1])
680 if info.parent is not None:
681 if info.parent is not None:
681 try:
682 try:
682 target = getattr(info.parent, '__class__')
683 target = getattr(info.parent, '__class__')
683 # The object belongs to a class instance.
684 # The object belongs to a class instance.
684 try:
685 try:
685 target = getattr(target, path[-1])
686 target = getattr(target, path[-1])
686 # The class defines the object.
687 # The class defines the object.
687 if isinstance(target, property):
688 if isinstance(target, property):
688 oname = root + '.__class__.' + path[-1]
689 oname = root + '.__class__.' + path[-1]
689 info = Struct(self._ofind(oname))
690 info = Struct(self._ofind(oname))
690 except AttributeError: pass
691 except AttributeError: pass
691 except AttributeError: pass
692 except AttributeError: pass
692
693
693 pmethod = getattr(self.shell.inspector,meth)
694 pmethod = getattr(self.shell.inspector,meth)
694 formatter = info.ismagic and self.format_screen or None
695 formatter = info.ismagic and self.format_screen or None
695 if meth == 'pdoc':
696 if meth == 'pdoc':
696 pmethod(info.obj,oname,formatter)
697 pmethod(info.obj,oname,formatter)
697 elif meth == 'pinfo':
698 elif meth == 'pinfo':
698 pmethod(info.obj,oname,formatter,info,**kw)
699 pmethod(info.obj,oname,formatter,info,**kw)
699 else:
700 else:
700 pmethod(info.obj,oname)
701 pmethod(info.obj,oname)
701 else:
702 else:
702 print 'Object `%s` not found.' % oname
703 print 'Object `%s` not found.' % oname
703 return 'not found' # so callers can take other action
704 return 'not found' # so callers can take other action
704
705
705 def magic_pdef(self, parameter_s='', namespaces=None):
706 def magic_pdef(self, parameter_s='', namespaces=None):
706 """Print the definition header for any callable object.
707 """Print the definition header for any callable object.
707
708
708 If the object is a class, print the constructor information."""
709 If the object is a class, print the constructor information."""
709 self._inspect('pdef',parameter_s, namespaces)
710 self._inspect('pdef',parameter_s, namespaces)
710
711
711 def magic_pdoc(self, parameter_s='', namespaces=None):
712 def magic_pdoc(self, parameter_s='', namespaces=None):
712 """Print the docstring for an object.
713 """Print the docstring for an object.
713
714
714 If the given object is a class, it will print both the class and the
715 If the given object is a class, it will print both the class and the
715 constructor docstrings."""
716 constructor docstrings."""
716 self._inspect('pdoc',parameter_s, namespaces)
717 self._inspect('pdoc',parameter_s, namespaces)
717
718
718 def magic_psource(self, parameter_s='', namespaces=None):
719 def magic_psource(self, parameter_s='', namespaces=None):
719 """Print (or run through pager) the source code for an object."""
720 """Print (or run through pager) the source code for an object."""
720 self._inspect('psource',parameter_s, namespaces)
721 self._inspect('psource',parameter_s, namespaces)
721
722
722 def magic_pfile(self, parameter_s=''):
723 def magic_pfile(self, parameter_s=''):
723 """Print (or run through pager) the file where an object is defined.
724 """Print (or run through pager) the file where an object is defined.
724
725
725 The file opens at the line where the object definition begins. IPython
726 The file opens at the line where the object definition begins. IPython
726 will honor the environment variable PAGER if set, and otherwise will
727 will honor the environment variable PAGER if set, and otherwise will
727 do its best to print the file in a convenient form.
728 do its best to print the file in a convenient form.
728
729
729 If the given argument is not an object currently defined, IPython will
730 If the given argument is not an object currently defined, IPython will
730 try to interpret it as a filename (automatically adding a .py extension
731 try to interpret it as a filename (automatically adding a .py extension
731 if needed). You can thus use %pfile as a syntax highlighting code
732 if needed). You can thus use %pfile as a syntax highlighting code
732 viewer."""
733 viewer."""
733
734
734 # first interpret argument as an object name
735 # first interpret argument as an object name
735 out = self._inspect('pfile',parameter_s)
736 out = self._inspect('pfile',parameter_s)
736 # if not, try the input as a filename
737 # if not, try the input as a filename
737 if out == 'not found':
738 if out == 'not found':
738 try:
739 try:
739 filename = get_py_filename(parameter_s)
740 filename = get_py_filename(parameter_s)
740 except IOError,msg:
741 except IOError,msg:
741 print msg
742 print msg
742 return
743 return
743 page(self.shell.inspector.format(file(filename).read()))
744 page(self.shell.inspector.format(file(filename).read()))
744
745
745 def magic_pinfo(self, parameter_s='', namespaces=None):
746 def magic_pinfo(self, parameter_s='', namespaces=None):
746 """Provide detailed information about an object.
747 """Provide detailed information about an object.
747
748
748 '%pinfo object' is just a synonym for object? or ?object."""
749 '%pinfo object' is just a synonym for object? or ?object."""
749
750
750 #print 'pinfo par: <%s>' % parameter_s # dbg
751 #print 'pinfo par: <%s>' % parameter_s # dbg
751
752
752 # detail_level: 0 -> obj? , 1 -> obj??
753 # detail_level: 0 -> obj? , 1 -> obj??
753 detail_level = 0
754 detail_level = 0
754 # We need to detect if we got called as 'pinfo pinfo foo', which can
755 # We need to detect if we got called as 'pinfo pinfo foo', which can
755 # happen if the user types 'pinfo foo?' at the cmd line.
756 # happen if the user types 'pinfo foo?' at the cmd line.
756 pinfo,qmark1,oname,qmark2 = \
757 pinfo,qmark1,oname,qmark2 = \
757 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
758 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
758 if pinfo or qmark1 or qmark2:
759 if pinfo or qmark1 or qmark2:
759 detail_level = 1
760 detail_level = 1
760 if "*" in oname:
761 if "*" in oname:
761 self.magic_psearch(oname)
762 self.magic_psearch(oname)
762 else:
763 else:
763 self._inspect('pinfo', oname, detail_level=detail_level,
764 self._inspect('pinfo', oname, detail_level=detail_level,
764 namespaces=namespaces)
765 namespaces=namespaces)
765
766
766 def magic_psearch(self, parameter_s=''):
767 def magic_psearch(self, parameter_s=''):
767 """Search for object in namespaces by wildcard.
768 """Search for object in namespaces by wildcard.
768
769
769 %psearch [options] PATTERN [OBJECT TYPE]
770 %psearch [options] PATTERN [OBJECT TYPE]
770
771
771 Note: ? can be used as a synonym for %psearch, at the beginning or at
772 Note: ? can be used as a synonym for %psearch, at the beginning or at
772 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
773 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
773 rest of the command line must be unchanged (options come first), so
774 rest of the command line must be unchanged (options come first), so
774 for example the following forms are equivalent
775 for example the following forms are equivalent
775
776
776 %psearch -i a* function
777 %psearch -i a* function
777 -i a* function?
778 -i a* function?
778 ?-i a* function
779 ?-i a* function
779
780
780 Arguments:
781 Arguments:
781
782
782 PATTERN
783 PATTERN
783
784
784 where PATTERN is a string containing * as a wildcard similar to its
785 where PATTERN is a string containing * as a wildcard similar to its
785 use in a shell. The pattern is matched in all namespaces on the
786 use in a shell. The pattern is matched in all namespaces on the
786 search path. By default objects starting with a single _ are not
787 search path. By default objects starting with a single _ are not
787 matched, many IPython generated objects have a single
788 matched, many IPython generated objects have a single
788 underscore. The default is case insensitive matching. Matching is
789 underscore. The default is case insensitive matching. Matching is
789 also done on the attributes of objects and not only on the objects
790 also done on the attributes of objects and not only on the objects
790 in a module.
791 in a module.
791
792
792 [OBJECT TYPE]
793 [OBJECT TYPE]
793
794
794 Is the name of a python type from the types module. The name is
795 Is the name of a python type from the types module. The name is
795 given in lowercase without the ending type, ex. StringType is
796 given in lowercase without the ending type, ex. StringType is
796 written string. By adding a type here only objects matching the
797 written string. By adding a type here only objects matching the
797 given type are matched. Using all here makes the pattern match all
798 given type are matched. Using all here makes the pattern match all
798 types (this is the default).
799 types (this is the default).
799
800
800 Options:
801 Options:
801
802
802 -a: makes the pattern match even objects whose names start with a
803 -a: makes the pattern match even objects whose names start with a
803 single underscore. These names are normally ommitted from the
804 single underscore. These names are normally ommitted from the
804 search.
805 search.
805
806
806 -i/-c: make the pattern case insensitive/sensitive. If neither of
807 -i/-c: make the pattern case insensitive/sensitive. If neither of
807 these options is given, the default is read from your ipythonrc
808 these options is given, the default is read from your ipythonrc
808 file. The option name which sets this value is
809 file. The option name which sets this value is
809 'wildcards_case_sensitive'. If this option is not specified in your
810 'wildcards_case_sensitive'. If this option is not specified in your
810 ipythonrc file, IPython's internal default is to do a case sensitive
811 ipythonrc file, IPython's internal default is to do a case sensitive
811 search.
812 search.
812
813
813 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
814 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
814 specifiy can be searched in any of the following namespaces:
815 specifiy can be searched in any of the following namespaces:
815 'builtin', 'user', 'user_global','internal', 'alias', where
816 'builtin', 'user', 'user_global','internal', 'alias', where
816 'builtin' and 'user' are the search defaults. Note that you should
817 'builtin' and 'user' are the search defaults. Note that you should
817 not use quotes when specifying namespaces.
818 not use quotes when specifying namespaces.
818
819
819 'Builtin' contains the python module builtin, 'user' contains all
820 'Builtin' contains the python module builtin, 'user' contains all
820 user data, 'alias' only contain the shell aliases and no python
821 user data, 'alias' only contain the shell aliases and no python
821 objects, 'internal' contains objects used by IPython. The
822 objects, 'internal' contains objects used by IPython. The
822 'user_global' namespace is only used by embedded IPython instances,
823 'user_global' namespace is only used by embedded IPython instances,
823 and it contains module-level globals. You can add namespaces to the
824 and it contains module-level globals. You can add namespaces to the
824 search with -s or exclude them with -e (these options can be given
825 search with -s or exclude them with -e (these options can be given
825 more than once).
826 more than once).
826
827
827 Examples:
828 Examples:
828
829
829 %psearch a* -> objects beginning with an a
830 %psearch a* -> objects beginning with an a
830 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
831 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
831 %psearch a* function -> all functions beginning with an a
832 %psearch a* function -> all functions beginning with an a
832 %psearch re.e* -> objects beginning with an e in module re
833 %psearch re.e* -> objects beginning with an e in module re
833 %psearch r*.e* -> objects that start with e in modules starting in r
834 %psearch r*.e* -> objects that start with e in modules starting in r
834 %psearch r*.* string -> all strings in modules beginning with r
835 %psearch r*.* string -> all strings in modules beginning with r
835
836
836 Case sensitve search:
837 Case sensitve search:
837
838
838 %psearch -c a* list all object beginning with lower case a
839 %psearch -c a* list all object beginning with lower case a
839
840
840 Show objects beginning with a single _:
841 Show objects beginning with a single _:
841
842
842 %psearch -a _* list objects beginning with a single underscore"""
843 %psearch -a _* list objects beginning with a single underscore"""
843
844
844 # default namespaces to be searched
845 # default namespaces to be searched
845 def_search = ['user','builtin']
846 def_search = ['user','builtin']
846
847
847 # Process options/args
848 # Process options/args
848 opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
849 opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
849 opt = opts.get
850 opt = opts.get
850 shell = self.shell
851 shell = self.shell
851 psearch = shell.inspector.psearch
852 psearch = shell.inspector.psearch
852
853
853 # select case options
854 # select case options
854 if opts.has_key('i'):
855 if opts.has_key('i'):
855 ignore_case = True
856 ignore_case = True
856 elif opts.has_key('c'):
857 elif opts.has_key('c'):
857 ignore_case = False
858 ignore_case = False
858 else:
859 else:
859 ignore_case = not shell.rc.wildcards_case_sensitive
860 ignore_case = not shell.rc.wildcards_case_sensitive
860
861
861 # Build list of namespaces to search from user options
862 # Build list of namespaces to search from user options
862 def_search.extend(opt('s',[]))
863 def_search.extend(opt('s',[]))
863 ns_exclude = ns_exclude=opt('e',[])
864 ns_exclude = ns_exclude=opt('e',[])
864 ns_search = [nm for nm in def_search if nm not in ns_exclude]
865 ns_search = [nm for nm in def_search if nm not in ns_exclude]
865
866
866 # Call the actual search
867 # Call the actual search
867 try:
868 try:
868 psearch(args,shell.ns_table,ns_search,
869 psearch(args,shell.ns_table,ns_search,
869 show_all=opt('a'),ignore_case=ignore_case)
870 show_all=opt('a'),ignore_case=ignore_case)
870 except:
871 except:
871 shell.showtraceback()
872 shell.showtraceback()
872
873
873 def magic_who_ls(self, parameter_s=''):
874 def magic_who_ls(self, parameter_s=''):
874 """Return a sorted list of all interactive variables.
875 """Return a sorted list of all interactive variables.
875
876
876 If arguments are given, only variables of types matching these
877 If arguments are given, only variables of types matching these
877 arguments are returned."""
878 arguments are returned."""
878
879
879 user_ns = self.shell.user_ns
880 user_ns = self.shell.user_ns
880 internal_ns = self.shell.internal_ns
881 internal_ns = self.shell.internal_ns
881 user_config_ns = self.shell.user_config_ns
882 user_config_ns = self.shell.user_config_ns
882 out = []
883 out = []
883 typelist = parameter_s.split()
884 typelist = parameter_s.split()
884
885
885 for i in user_ns:
886 for i in user_ns:
886 if not (i.startswith('_') or i.startswith('_i')) \
887 if not (i.startswith('_') or i.startswith('_i')) \
887 and not (i in internal_ns or i in user_config_ns):
888 and not (i in internal_ns or i in user_config_ns):
888 if typelist:
889 if typelist:
889 if type(user_ns[i]).__name__ in typelist:
890 if type(user_ns[i]).__name__ in typelist:
890 out.append(i)
891 out.append(i)
891 else:
892 else:
892 out.append(i)
893 out.append(i)
893 out.sort()
894 out.sort()
894 return out
895 return out
895
896
896 def magic_who(self, parameter_s=''):
897 def magic_who(self, parameter_s=''):
897 """Print all interactive variables, with some minimal formatting.
898 """Print all interactive variables, with some minimal formatting.
898
899
899 If any arguments are given, only variables whose type matches one of
900 If any arguments are given, only variables whose type matches one of
900 these are printed. For example:
901 these are printed. For example:
901
902
902 %who function str
903 %who function str
903
904
904 will only list functions and strings, excluding all other types of
905 will only list functions and strings, excluding all other types of
905 variables. To find the proper type names, simply use type(var) at a
906 variables. To find the proper type names, simply use type(var) at a
906 command line to see how python prints type names. For example:
907 command line to see how python prints type names. For example:
907
908
908 In [1]: type('hello')\\
909 In [1]: type('hello')\\
909 Out[1]: <type 'str'>
910 Out[1]: <type 'str'>
910
911
911 indicates that the type name for strings is 'str'.
912 indicates that the type name for strings is 'str'.
912
913
913 %who always excludes executed names loaded through your configuration
914 %who always excludes executed names loaded through your configuration
914 file and things which are internal to IPython.
915 file and things which are internal to IPython.
915
916
916 This is deliberate, as typically you may load many modules and the
917 This is deliberate, as typically you may load many modules and the
917 purpose of %who is to show you only what you've manually defined."""
918 purpose of %who is to show you only what you've manually defined."""
918
919
919 varlist = self.magic_who_ls(parameter_s)
920 varlist = self.magic_who_ls(parameter_s)
920 if not varlist:
921 if not varlist:
921 print 'Interactive namespace is empty.'
922 print 'Interactive namespace is empty.'
922 return
923 return
923
924
924 # if we have variables, move on...
925 # if we have variables, move on...
925
926
926 # stupid flushing problem: when prompts have no separators, stdout is
927 # stupid flushing problem: when prompts have no separators, stdout is
927 # getting lost. I'm starting to think this is a python bug. I'm having
928 # getting lost. I'm starting to think this is a python bug. I'm having
928 # to force a flush with a print because even a sys.stdout.flush
929 # to force a flush with a print because even a sys.stdout.flush
929 # doesn't seem to do anything!
930 # doesn't seem to do anything!
930
931
931 count = 0
932 count = 0
932 for i in varlist:
933 for i in varlist:
933 print i+'\t',
934 print i+'\t',
934 count += 1
935 count += 1
935 if count > 8:
936 if count > 8:
936 count = 0
937 count = 0
937 print
938 print
938 sys.stdout.flush() # FIXME. Why the hell isn't this flushing???
939 sys.stdout.flush() # FIXME. Why the hell isn't this flushing???
939
940
940 print # well, this does force a flush at the expense of an extra \n
941 print # well, this does force a flush at the expense of an extra \n
941
942
942 def magic_whos(self, parameter_s=''):
943 def magic_whos(self, parameter_s=''):
943 """Like %who, but gives some extra information about each variable.
944 """Like %who, but gives some extra information about each variable.
944
945
945 The same type filtering of %who can be applied here.
946 The same type filtering of %who can be applied here.
946
947
947 For all variables, the type is printed. Additionally it prints:
948 For all variables, the type is printed. Additionally it prints:
948
949
949 - For {},[],(): their length.
950 - For {},[],(): their length.
950
951
951 - For Numeric arrays, a summary with shape, number of elements,
952 - For Numeric arrays, a summary with shape, number of elements,
952 typecode and size in memory.
953 typecode and size in memory.
953
954
954 - Everything else: a string representation, snipping their middle if
955 - Everything else: a string representation, snipping their middle if
955 too long."""
956 too long."""
956
957
957 varnames = self.magic_who_ls(parameter_s)
958 varnames = self.magic_who_ls(parameter_s)
958 if not varnames:
959 if not varnames:
959 print 'Interactive namespace is empty.'
960 print 'Interactive namespace is empty.'
960 return
961 return
961
962
962 # if we have variables, move on...
963 # if we have variables, move on...
963
964
964 # for these types, show len() instead of data:
965 # for these types, show len() instead of data:
965 seq_types = [types.DictType,types.ListType,types.TupleType]
966 seq_types = [types.DictType,types.ListType,types.TupleType]
966
967
967 # for Numeric arrays, display summary info
968 # for Numeric arrays, display summary info
968 try:
969 try:
969 import Numeric
970 import Numeric
970 except ImportError:
971 except ImportError:
971 array_type = None
972 array_type = None
972 else:
973 else:
973 array_type = Numeric.ArrayType.__name__
974 array_type = Numeric.ArrayType.__name__
974
975
975 # Find all variable names and types so we can figure out column sizes
976 # Find all variable names and types so we can figure out column sizes
976
977
977 def get_vars(i):
978 def get_vars(i):
978 return self.shell.user_ns[i]
979 return self.shell.user_ns[i]
979
980
980 # some types are well known and can be shorter
981 # some types are well known and can be shorter
981 abbrevs = {'IPython.macro.Macro' : 'Macro'}
982 abbrevs = {'IPython.macro.Macro' : 'Macro'}
982 def type_name(v):
983 def type_name(v):
983 tn = type(v).__name__
984 tn = type(v).__name__
984 return abbrevs.get(tn,tn)
985 return abbrevs.get(tn,tn)
985
986
986 varlist = map(get_vars,varnames)
987 varlist = map(get_vars,varnames)
987
988
988 typelist = []
989 typelist = []
989 for vv in varlist:
990 for vv in varlist:
990 tt = type_name(vv)
991 tt = type_name(vv)
991
992
992 if tt=='instance':
993 if tt=='instance':
993 typelist.append( abbrevs.get(str(vv.__class__),str(vv.__class__)))
994 typelist.append( abbrevs.get(str(vv.__class__),str(vv.__class__)))
994 else:
995 else:
995 typelist.append(tt)
996 typelist.append(tt)
996
997
997 # column labels and # of spaces as separator
998 # column labels and # of spaces as separator
998 varlabel = 'Variable'
999 varlabel = 'Variable'
999 typelabel = 'Type'
1000 typelabel = 'Type'
1000 datalabel = 'Data/Info'
1001 datalabel = 'Data/Info'
1001 colsep = 3
1002 colsep = 3
1002 # variable format strings
1003 # variable format strings
1003 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
1004 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
1004 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
1005 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
1005 aformat = "%s: %s elems, type `%s`, %s bytes"
1006 aformat = "%s: %s elems, type `%s`, %s bytes"
1006 # find the size of the columns to format the output nicely
1007 # find the size of the columns to format the output nicely
1007 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
1008 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
1008 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
1009 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
1009 # table header
1010 # table header
1010 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
1011 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
1011 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
1012 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
1012 # and the table itself
1013 # and the table itself
1013 kb = 1024
1014 kb = 1024
1014 Mb = 1048576 # kb**2
1015 Mb = 1048576 # kb**2
1015 for vname,var,vtype in zip(varnames,varlist,typelist):
1016 for vname,var,vtype in zip(varnames,varlist,typelist):
1016 print itpl(vformat),
1017 print itpl(vformat),
1017 if vtype in seq_types:
1018 if vtype in seq_types:
1018 print len(var)
1019 print len(var)
1019 elif vtype==array_type:
1020 elif vtype==array_type:
1020 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
1021 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
1021 vsize = Numeric.size(var)
1022 vsize = Numeric.size(var)
1022 vbytes = vsize*var.itemsize()
1023 vbytes = vsize*var.itemsize()
1023 if vbytes < 100000:
1024 if vbytes < 100000:
1024 print aformat % (vshape,vsize,var.typecode(),vbytes)
1025 print aformat % (vshape,vsize,var.typecode(),vbytes)
1025 else:
1026 else:
1026 print aformat % (vshape,vsize,var.typecode(),vbytes),
1027 print aformat % (vshape,vsize,var.typecode(),vbytes),
1027 if vbytes < Mb:
1028 if vbytes < Mb:
1028 print '(%s kb)' % (vbytes/kb,)
1029 print '(%s kb)' % (vbytes/kb,)
1029 else:
1030 else:
1030 print '(%s Mb)' % (vbytes/Mb,)
1031 print '(%s Mb)' % (vbytes/Mb,)
1031 else:
1032 else:
1032 vstr = str(var).replace('\n','\\n')
1033 vstr = str(var).replace('\n','\\n')
1033 if len(vstr) < 50:
1034 if len(vstr) < 50:
1034 print vstr
1035 print vstr
1035 else:
1036 else:
1036 printpl(vfmt_short)
1037 printpl(vfmt_short)
1037
1038
1038 def magic_reset(self, parameter_s=''):
1039 def magic_reset(self, parameter_s=''):
1039 """Resets the namespace by removing all names defined by the user.
1040 """Resets the namespace by removing all names defined by the user.
1040
1041
1041 Input/Output history are left around in case you need them."""
1042 Input/Output history are left around in case you need them."""
1042
1043
1043 ans = self.shell.ask_yes_no(
1044 ans = self.shell.ask_yes_no(
1044 "Once deleted, variables cannot be recovered. Proceed (y/[n])? ")
1045 "Once deleted, variables cannot be recovered. Proceed (y/[n])? ")
1045 if not ans:
1046 if not ans:
1046 print 'Nothing done.'
1047 print 'Nothing done.'
1047 return
1048 return
1048 user_ns = self.shell.user_ns
1049 user_ns = self.shell.user_ns
1049 for i in self.magic_who_ls():
1050 for i in self.magic_who_ls():
1050 del(user_ns[i])
1051 del(user_ns[i])
1051
1052
1052 def magic_logstart(self,parameter_s=''):
1053 def magic_logstart(self,parameter_s=''):
1053 """Start logging anywhere in a session.
1054 """Start logging anywhere in a session.
1054
1055
1055 %logstart [-o|-r|-t] [log_name [log_mode]]
1056 %logstart [-o|-r|-t] [log_name [log_mode]]
1056
1057
1057 If no name is given, it defaults to a file named 'ipython_log.py' in your
1058 If no name is given, it defaults to a file named 'ipython_log.py' in your
1058 current directory, in 'rotate' mode (see below).
1059 current directory, in 'rotate' mode (see below).
1059
1060
1060 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
1061 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
1061 history up to that point and then continues logging.
1062 history up to that point and then continues logging.
1062
1063
1063 %logstart takes a second optional parameter: logging mode. This can be one
1064 %logstart takes a second optional parameter: logging mode. This can be one
1064 of (note that the modes are given unquoted):\\
1065 of (note that the modes are given unquoted):\\
1065 append: well, that says it.\\
1066 append: well, that says it.\\
1066 backup: rename (if exists) to name~ and start name.\\
1067 backup: rename (if exists) to name~ and start name.\\
1067 global: single logfile in your home dir, appended to.\\
1068 global: single logfile in your home dir, appended to.\\
1068 over : overwrite existing log.\\
1069 over : overwrite existing log.\\
1069 rotate: create rotating logs name.1~, name.2~, etc.
1070 rotate: create rotating logs name.1~, name.2~, etc.
1070
1071
1071 Options:
1072 Options:
1072
1073
1073 -o: log also IPython's output. In this mode, all commands which
1074 -o: log also IPython's output. In this mode, all commands which
1074 generate an Out[NN] prompt are recorded to the logfile, right after
1075 generate an Out[NN] prompt are recorded to the logfile, right after
1075 their corresponding input line. The output lines are always
1076 their corresponding input line. The output lines are always
1076 prepended with a '#[Out]# ' marker, so that the log remains valid
1077 prepended with a '#[Out]# ' marker, so that the log remains valid
1077 Python code.
1078 Python code.
1078
1079
1079 Since this marker is always the same, filtering only the output from
1080 Since this marker is always the same, filtering only the output from
1080 a log is very easy, using for example a simple awk call:
1081 a log is very easy, using for example a simple awk call:
1081
1082
1082 awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py
1083 awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py
1083
1084
1084 -r: log 'raw' input. Normally, IPython's logs contain the processed
1085 -r: log 'raw' input. Normally, IPython's logs contain the processed
1085 input, so that user lines are logged in their final form, converted
1086 input, so that user lines are logged in their final form, converted
1086 into valid Python. For example, %Exit is logged as
1087 into valid Python. For example, %Exit is logged as
1087 '_ip.magic("Exit"). If the -r flag is given, all input is logged
1088 '_ip.magic("Exit"). If the -r flag is given, all input is logged
1088 exactly as typed, with no transformations applied.
1089 exactly as typed, with no transformations applied.
1089
1090
1090 -t: put timestamps before each input line logged (these are put in
1091 -t: put timestamps before each input line logged (these are put in
1091 comments)."""
1092 comments)."""
1092
1093
1093 opts,par = self.parse_options(parameter_s,'ort')
1094 opts,par = self.parse_options(parameter_s,'ort')
1094 log_output = 'o' in opts
1095 log_output = 'o' in opts
1095 log_raw_input = 'r' in opts
1096 log_raw_input = 'r' in opts
1096 timestamp = 't' in opts
1097 timestamp = 't' in opts
1097
1098
1098 rc = self.shell.rc
1099 rc = self.shell.rc
1099 logger = self.shell.logger
1100 logger = self.shell.logger
1100
1101
1101 # if no args are given, the defaults set in the logger constructor by
1102 # if no args are given, the defaults set in the logger constructor by
1102 # ipytohn remain valid
1103 # ipytohn remain valid
1103 if par:
1104 if par:
1104 try:
1105 try:
1105 logfname,logmode = par.split()
1106 logfname,logmode = par.split()
1106 except:
1107 except:
1107 logfname = par
1108 logfname = par
1108 logmode = 'backup'
1109 logmode = 'backup'
1109 else:
1110 else:
1110 logfname = logger.logfname
1111 logfname = logger.logfname
1111 logmode = logger.logmode
1112 logmode = logger.logmode
1112 # put logfname into rc struct as if it had been called on the command
1113 # put logfname into rc struct as if it had been called on the command
1113 # line, so it ends up saved in the log header Save it in case we need
1114 # line, so it ends up saved in the log header Save it in case we need
1114 # to restore it...
1115 # to restore it...
1115 old_logfile = rc.opts.get('logfile','')
1116 old_logfile = rc.opts.get('logfile','')
1116 if logfname:
1117 if logfname:
1117 logfname = os.path.expanduser(logfname)
1118 logfname = os.path.expanduser(logfname)
1118 rc.opts.logfile = logfname
1119 rc.opts.logfile = logfname
1119 loghead = self.shell.loghead_tpl % (rc.opts,rc.args)
1120 loghead = self.shell.loghead_tpl % (rc.opts,rc.args)
1120 try:
1121 try:
1121 started = logger.logstart(logfname,loghead,logmode,
1122 started = logger.logstart(logfname,loghead,logmode,
1122 log_output,timestamp,log_raw_input)
1123 log_output,timestamp,log_raw_input)
1123 except:
1124 except:
1124 rc.opts.logfile = old_logfile
1125 rc.opts.logfile = old_logfile
1125 warn("Couldn't start log: %s" % sys.exc_info()[1])
1126 warn("Couldn't start log: %s" % sys.exc_info()[1])
1126 else:
1127 else:
1127 # log input history up to this point, optionally interleaving
1128 # log input history up to this point, optionally interleaving
1128 # output if requested
1129 # output if requested
1129
1130
1130 if timestamp:
1131 if timestamp:
1131 # disable timestamping for the previous history, since we've
1132 # disable timestamping for the previous history, since we've
1132 # lost those already (no time machine here).
1133 # lost those already (no time machine here).
1133 logger.timestamp = False
1134 logger.timestamp = False
1134
1135
1135 if log_raw_input:
1136 if log_raw_input:
1136 input_hist = self.shell.input_hist_raw
1137 input_hist = self.shell.input_hist_raw
1137 else:
1138 else:
1138 input_hist = self.shell.input_hist
1139 input_hist = self.shell.input_hist
1139
1140
1140 if log_output:
1141 if log_output:
1141 log_write = logger.log_write
1142 log_write = logger.log_write
1142 output_hist = self.shell.output_hist
1143 output_hist = self.shell.output_hist
1143 for n in range(1,len(input_hist)-1):
1144 for n in range(1,len(input_hist)-1):
1144 log_write(input_hist[n].rstrip())
1145 log_write(input_hist[n].rstrip())
1145 if n in output_hist:
1146 if n in output_hist:
1146 log_write(repr(output_hist[n]),'output')
1147 log_write(repr(output_hist[n]),'output')
1147 else:
1148 else:
1148 logger.log_write(input_hist[1:])
1149 logger.log_write(input_hist[1:])
1149 if timestamp:
1150 if timestamp:
1150 # re-enable timestamping
1151 # re-enable timestamping
1151 logger.timestamp = True
1152 logger.timestamp = True
1152
1153
1153 print ('Activating auto-logging. '
1154 print ('Activating auto-logging. '
1154 'Current session state plus future input saved.')
1155 'Current session state plus future input saved.')
1155 logger.logstate()
1156 logger.logstate()
1156
1157
1157 def magic_logoff(self,parameter_s=''):
1158 def magic_logoff(self,parameter_s=''):
1158 """Temporarily stop logging.
1159 """Temporarily stop logging.
1159
1160
1160 You must have previously started logging."""
1161 You must have previously started logging."""
1161 self.shell.logger.switch_log(0)
1162 self.shell.logger.switch_log(0)
1162
1163
1163 def magic_logon(self,parameter_s=''):
1164 def magic_logon(self,parameter_s=''):
1164 """Restart logging.
1165 """Restart logging.
1165
1166
1166 This function is for restarting logging which you've temporarily
1167 This function is for restarting logging which you've temporarily
1167 stopped with %logoff. For starting logging for the first time, you
1168 stopped with %logoff. For starting logging for the first time, you
1168 must use the %logstart function, which allows you to specify an
1169 must use the %logstart function, which allows you to specify an
1169 optional log filename."""
1170 optional log filename."""
1170
1171
1171 self.shell.logger.switch_log(1)
1172 self.shell.logger.switch_log(1)
1172
1173
1173 def magic_logstate(self,parameter_s=''):
1174 def magic_logstate(self,parameter_s=''):
1174 """Print the status of the logging system."""
1175 """Print the status of the logging system."""
1175
1176
1176 self.shell.logger.logstate()
1177 self.shell.logger.logstate()
1177
1178
1178 def magic_pdb(self, parameter_s=''):
1179 def magic_pdb(self, parameter_s=''):
1179 """Control the automatic calling of the pdb interactive debugger.
1180 """Control the automatic calling of the pdb interactive debugger.
1180
1181
1181 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1182 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1182 argument it works as a toggle.
1183 argument it works as a toggle.
1183
1184
1184 When an exception is triggered, IPython can optionally call the
1185 When an exception is triggered, IPython can optionally call the
1185 interactive pdb debugger after the traceback printout. %pdb toggles
1186 interactive pdb debugger after the traceback printout. %pdb toggles
1186 this feature on and off.
1187 this feature on and off.
1187
1188
1188 The initial state of this feature is set in your ipythonrc
1189 The initial state of this feature is set in your ipythonrc
1189 configuration file (the variable is called 'pdb').
1190 configuration file (the variable is called 'pdb').
1190
1191
1191 If you want to just activate the debugger AFTER an exception has fired,
1192 If you want to just activate the debugger AFTER an exception has fired,
1192 without having to type '%pdb on' and rerunning your code, you can use
1193 without having to type '%pdb on' and rerunning your code, you can use
1193 the %debug magic."""
1194 the %debug magic."""
1194
1195
1195 par = parameter_s.strip().lower()
1196 par = parameter_s.strip().lower()
1196
1197
1197 if par:
1198 if par:
1198 try:
1199 try:
1199 new_pdb = {'off':0,'0':0,'on':1,'1':1}[par]
1200 new_pdb = {'off':0,'0':0,'on':1,'1':1}[par]
1200 except KeyError:
1201 except KeyError:
1201 print ('Incorrect argument. Use on/1, off/0, '
1202 print ('Incorrect argument. Use on/1, off/0, '
1202 'or nothing for a toggle.')
1203 'or nothing for a toggle.')
1203 return
1204 return
1204 else:
1205 else:
1205 # toggle
1206 # toggle
1206 new_pdb = not self.shell.call_pdb
1207 new_pdb = not self.shell.call_pdb
1207
1208
1208 # set on the shell
1209 # set on the shell
1209 self.shell.call_pdb = new_pdb
1210 self.shell.call_pdb = new_pdb
1210 print 'Automatic pdb calling has been turned',on_off(new_pdb)
1211 print 'Automatic pdb calling has been turned',on_off(new_pdb)
1211
1212
1212 def magic_debug(self, parameter_s=''):
1213 def magic_debug(self, parameter_s=''):
1213 """Activate the interactive debugger in post-mortem mode.
1214 """Activate the interactive debugger in post-mortem mode.
1214
1215
1215 If an exception has just occurred, this lets you inspect its stack
1216 If an exception has just occurred, this lets you inspect its stack
1216 frames interactively. Note that this will always work only on the last
1217 frames interactively. Note that this will always work only on the last
1217 traceback that occurred, so you must call this quickly after an
1218 traceback that occurred, so you must call this quickly after an
1218 exception that you wish to inspect has fired, because if another one
1219 exception that you wish to inspect has fired, because if another one
1219 occurs, it clobbers the previous one.
1220 occurs, it clobbers the previous one.
1220
1221
1221 If you want IPython to automatically do this on every exception, see
1222 If you want IPython to automatically do this on every exception, see
1222 the %pdb magic for more details.
1223 the %pdb magic for more details.
1223 """
1224 """
1224
1225
1225 self.shell.debugger(force=True)
1226 self.shell.debugger(force=True)
1226
1227
1227 def magic_prun(self, parameter_s ='',user_mode=1,
1228 def magic_prun(self, parameter_s ='',user_mode=1,
1228 opts=None,arg_lst=None,prog_ns=None):
1229 opts=None,arg_lst=None,prog_ns=None):
1229
1230
1230 """Run a statement through the python code profiler.
1231 """Run a statement through the python code profiler.
1231
1232
1232 Usage:\\
1233 Usage:\\
1233 %prun [options] statement
1234 %prun [options] statement
1234
1235
1235 The given statement (which doesn't require quote marks) is run via the
1236 The given statement (which doesn't require quote marks) is run via the
1236 python profiler in a manner similar to the profile.run() function.
1237 python profiler in a manner similar to the profile.run() function.
1237 Namespaces are internally managed to work correctly; profile.run
1238 Namespaces are internally managed to work correctly; profile.run
1238 cannot be used in IPython because it makes certain assumptions about
1239 cannot be used in IPython because it makes certain assumptions about
1239 namespaces which do not hold under IPython.
1240 namespaces which do not hold under IPython.
1240
1241
1241 Options:
1242 Options:
1242
1243
1243 -l <limit>: you can place restrictions on what or how much of the
1244 -l <limit>: you can place restrictions on what or how much of the
1244 profile gets printed. The limit value can be:
1245 profile gets printed. The limit value can be:
1245
1246
1246 * A string: only information for function names containing this string
1247 * A string: only information for function names containing this string
1247 is printed.
1248 is printed.
1248
1249
1249 * An integer: only these many lines are printed.
1250 * An integer: only these many lines are printed.
1250
1251
1251 * A float (between 0 and 1): this fraction of the report is printed
1252 * A float (between 0 and 1): this fraction of the report is printed
1252 (for example, use a limit of 0.4 to see the topmost 40% only).
1253 (for example, use a limit of 0.4 to see the topmost 40% only).
1253
1254
1254 You can combine several limits with repeated use of the option. For
1255 You can combine several limits with repeated use of the option. For
1255 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1256 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1256 information about class constructors.
1257 information about class constructors.
1257
1258
1258 -r: return the pstats.Stats object generated by the profiling. This
1259 -r: return the pstats.Stats object generated by the profiling. This
1259 object has all the information about the profile in it, and you can
1260 object has all the information about the profile in it, and you can
1260 later use it for further analysis or in other functions.
1261 later use it for further analysis or in other functions.
1261
1262
1262 -s <key>: sort profile by given key. You can provide more than one key
1263 -s <key>: sort profile by given key. You can provide more than one key
1263 by using the option several times: '-s key1 -s key2 -s key3...'. The
1264 by using the option several times: '-s key1 -s key2 -s key3...'. The
1264 default sorting key is 'time'.
1265 default sorting key is 'time'.
1265
1266
1266 The following is copied verbatim from the profile documentation
1267 The following is copied verbatim from the profile documentation
1267 referenced below:
1268 referenced below:
1268
1269
1269 When more than one key is provided, additional keys are used as
1270 When more than one key is provided, additional keys are used as
1270 secondary criteria when the there is equality in all keys selected
1271 secondary criteria when the there is equality in all keys selected
1271 before them.
1272 before them.
1272
1273
1273 Abbreviations can be used for any key names, as long as the
1274 Abbreviations can be used for any key names, as long as the
1274 abbreviation is unambiguous. The following are the keys currently
1275 abbreviation is unambiguous. The following are the keys currently
1275 defined:
1276 defined:
1276
1277
1277 Valid Arg Meaning\\
1278 Valid Arg Meaning\\
1278 "calls" call count\\
1279 "calls" call count\\
1279 "cumulative" cumulative time\\
1280 "cumulative" cumulative time\\
1280 "file" file name\\
1281 "file" file name\\
1281 "module" file name\\
1282 "module" file name\\
1282 "pcalls" primitive call count\\
1283 "pcalls" primitive call count\\
1283 "line" line number\\
1284 "line" line number\\
1284 "name" function name\\
1285 "name" function name\\
1285 "nfl" name/file/line\\
1286 "nfl" name/file/line\\
1286 "stdname" standard name\\
1287 "stdname" standard name\\
1287 "time" internal time
1288 "time" internal time
1288
1289
1289 Note that all sorts on statistics are in descending order (placing
1290 Note that all sorts on statistics are in descending order (placing
1290 most time consuming items first), where as name, file, and line number
1291 most time consuming items first), where as name, file, and line number
1291 searches are in ascending order (i.e., alphabetical). The subtle
1292 searches are in ascending order (i.e., alphabetical). The subtle
1292 distinction between "nfl" and "stdname" is that the standard name is a
1293 distinction between "nfl" and "stdname" is that the standard name is a
1293 sort of the name as printed, which means that the embedded line
1294 sort of the name as printed, which means that the embedded line
1294 numbers get compared in an odd way. For example, lines 3, 20, and 40
1295 numbers get compared in an odd way. For example, lines 3, 20, and 40
1295 would (if the file names were the same) appear in the string order
1296 would (if the file names were the same) appear in the string order
1296 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1297 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1297 line numbers. In fact, sort_stats("nfl") is the same as
1298 line numbers. In fact, sort_stats("nfl") is the same as
1298 sort_stats("name", "file", "line").
1299 sort_stats("name", "file", "line").
1299
1300
1300 -T <filename>: save profile results as shown on screen to a text
1301 -T <filename>: save profile results as shown on screen to a text
1301 file. The profile is still shown on screen.
1302 file. The profile is still shown on screen.
1302
1303
1303 -D <filename>: save (via dump_stats) profile statistics to given
1304 -D <filename>: save (via dump_stats) profile statistics to given
1304 filename. This data is in a format understod by the pstats module, and
1305 filename. This data is in a format understod by the pstats module, and
1305 is generated by a call to the dump_stats() method of profile
1306 is generated by a call to the dump_stats() method of profile
1306 objects. The profile is still shown on screen.
1307 objects. The profile is still shown on screen.
1307
1308
1308 If you want to run complete programs under the profiler's control, use
1309 If you want to run complete programs under the profiler's control, use
1309 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1310 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1310 contains profiler specific options as described here.
1311 contains profiler specific options as described here.
1311
1312
1312 You can read the complete documentation for the profile module with:\\
1313 You can read the complete documentation for the profile module with:\\
1313 In [1]: import profile; profile.help() """
1314 In [1]: import profile; profile.help() """
1314
1315
1315 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1316 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1316 # protect user quote marks
1317 # protect user quote marks
1317 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1318 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1318
1319
1319 if user_mode: # regular user call
1320 if user_mode: # regular user call
1320 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1321 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1321 list_all=1)
1322 list_all=1)
1322 namespace = self.shell.user_ns
1323 namespace = self.shell.user_ns
1323 else: # called to run a program by %run -p
1324 else: # called to run a program by %run -p
1324 try:
1325 try:
1325 filename = get_py_filename(arg_lst[0])
1326 filename = get_py_filename(arg_lst[0])
1326 except IOError,msg:
1327 except IOError,msg:
1327 error(msg)
1328 error(msg)
1328 return
1329 return
1329
1330
1330 arg_str = 'execfile(filename,prog_ns)'
1331 arg_str = 'execfile(filename,prog_ns)'
1331 namespace = locals()
1332 namespace = locals()
1332
1333
1333 opts.merge(opts_def)
1334 opts.merge(opts_def)
1334
1335
1335 prof = profile.Profile()
1336 prof = profile.Profile()
1336 try:
1337 try:
1337 prof = prof.runctx(arg_str,namespace,namespace)
1338 prof = prof.runctx(arg_str,namespace,namespace)
1338 sys_exit = ''
1339 sys_exit = ''
1339 except SystemExit:
1340 except SystemExit:
1340 sys_exit = """*** SystemExit exception caught in code being profiled."""
1341 sys_exit = """*** SystemExit exception caught in code being profiled."""
1341
1342
1342 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1343 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1343
1344
1344 lims = opts.l
1345 lims = opts.l
1345 if lims:
1346 if lims:
1346 lims = [] # rebuild lims with ints/floats/strings
1347 lims = [] # rebuild lims with ints/floats/strings
1347 for lim in opts.l:
1348 for lim in opts.l:
1348 try:
1349 try:
1349 lims.append(int(lim))
1350 lims.append(int(lim))
1350 except ValueError:
1351 except ValueError:
1351 try:
1352 try:
1352 lims.append(float(lim))
1353 lims.append(float(lim))
1353 except ValueError:
1354 except ValueError:
1354 lims.append(lim)
1355 lims.append(lim)
1355
1356
1356 # trap output
1357 # trap output
1357 sys_stdout = sys.stdout
1358 sys_stdout = sys.stdout
1358 stdout_trap = StringIO()
1359 stdout_trap = StringIO()
1359 try:
1360 try:
1360 sys.stdout = stdout_trap
1361 sys.stdout = stdout_trap
1361 stats.print_stats(*lims)
1362 stats.print_stats(*lims)
1362 finally:
1363 finally:
1363 sys.stdout = sys_stdout
1364 sys.stdout = sys_stdout
1364 output = stdout_trap.getvalue()
1365 output = stdout_trap.getvalue()
1365 output = output.rstrip()
1366 output = output.rstrip()
1366
1367
1367 page(output,screen_lines=self.shell.rc.screen_length)
1368 page(output,screen_lines=self.shell.rc.screen_length)
1368 print sys_exit,
1369 print sys_exit,
1369
1370
1370 dump_file = opts.D[0]
1371 dump_file = opts.D[0]
1371 text_file = opts.T[0]
1372 text_file = opts.T[0]
1372 if dump_file:
1373 if dump_file:
1373 prof.dump_stats(dump_file)
1374 prof.dump_stats(dump_file)
1374 print '\n*** Profile stats marshalled to file',\
1375 print '\n*** Profile stats marshalled to file',\
1375 `dump_file`+'.',sys_exit
1376 `dump_file`+'.',sys_exit
1376 if text_file:
1377 if text_file:
1377 file(text_file,'w').write(output)
1378 file(text_file,'w').write(output)
1378 print '\n*** Profile printout saved to text file',\
1379 print '\n*** Profile printout saved to text file',\
1379 `text_file`+'.',sys_exit
1380 `text_file`+'.',sys_exit
1380
1381
1381 if opts.has_key('r'):
1382 if opts.has_key('r'):
1382 return stats
1383 return stats
1383 else:
1384 else:
1384 return None
1385 return None
1385
1386
1386 def magic_run(self, parameter_s ='',runner=None):
1387 def magic_run(self, parameter_s ='',runner=None):
1387 """Run the named file inside IPython as a program.
1388 """Run the named file inside IPython as a program.
1388
1389
1389 Usage:\\
1390 Usage:\\
1390 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1391 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1391
1392
1392 Parameters after the filename are passed as command-line arguments to
1393 Parameters after the filename are passed as command-line arguments to
1393 the program (put in sys.argv). Then, control returns to IPython's
1394 the program (put in sys.argv). Then, control returns to IPython's
1394 prompt.
1395 prompt.
1395
1396
1396 This is similar to running at a system prompt:\\
1397 This is similar to running at a system prompt:\\
1397 $ python file args\\
1398 $ python file args\\
1398 but with the advantage of giving you IPython's tracebacks, and of
1399 but with the advantage of giving you IPython's tracebacks, and of
1399 loading all variables into your interactive namespace for further use
1400 loading all variables into your interactive namespace for further use
1400 (unless -p is used, see below).
1401 (unless -p is used, see below).
1401
1402
1402 The file is executed in a namespace initially consisting only of
1403 The file is executed in a namespace initially consisting only of
1403 __name__=='__main__' and sys.argv constructed as indicated. It thus
1404 __name__=='__main__' and sys.argv constructed as indicated. It thus
1404 sees its environment as if it were being run as a stand-alone
1405 sees its environment as if it were being run as a stand-alone
1405 program. But after execution, the IPython interactive namespace gets
1406 program. But after execution, the IPython interactive namespace gets
1406 updated with all variables defined in the program (except for __name__
1407 updated with all variables defined in the program (except for __name__
1407 and sys.argv). This allows for very convenient loading of code for
1408 and sys.argv). This allows for very convenient loading of code for
1408 interactive work, while giving each program a 'clean sheet' to run in.
1409 interactive work, while giving each program a 'clean sheet' to run in.
1409
1410
1410 Options:
1411 Options:
1411
1412
1412 -n: __name__ is NOT set to '__main__', but to the running file's name
1413 -n: __name__ is NOT set to '__main__', but to the running file's name
1413 without extension (as python does under import). This allows running
1414 without extension (as python does under import). This allows running
1414 scripts and reloading the definitions in them without calling code
1415 scripts and reloading the definitions in them without calling code
1415 protected by an ' if __name__ == "__main__" ' clause.
1416 protected by an ' if __name__ == "__main__" ' clause.
1416
1417
1417 -i: run the file in IPython's namespace instead of an empty one. This
1418 -i: run the file in IPython's namespace instead of an empty one. This
1418 is useful if you are experimenting with code written in a text editor
1419 is useful if you are experimenting with code written in a text editor
1419 which depends on variables defined interactively.
1420 which depends on variables defined interactively.
1420
1421
1421 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1422 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1422 being run. This is particularly useful if IPython is being used to
1423 being run. This is particularly useful if IPython is being used to
1423 run unittests, which always exit with a sys.exit() call. In such
1424 run unittests, which always exit with a sys.exit() call. In such
1424 cases you are interested in the output of the test results, not in
1425 cases you are interested in the output of the test results, not in
1425 seeing a traceback of the unittest module.
1426 seeing a traceback of the unittest module.
1426
1427
1427 -t: print timing information at the end of the run. IPython will give
1428 -t: print timing information at the end of the run. IPython will give
1428 you an estimated CPU time consumption for your script, which under
1429 you an estimated CPU time consumption for your script, which under
1429 Unix uses the resource module to avoid the wraparound problems of
1430 Unix uses the resource module to avoid the wraparound problems of
1430 time.clock(). Under Unix, an estimate of time spent on system tasks
1431 time.clock(). Under Unix, an estimate of time spent on system tasks
1431 is also given (for Windows platforms this is reported as 0.0).
1432 is also given (for Windows platforms this is reported as 0.0).
1432
1433
1433 If -t is given, an additional -N<N> option can be given, where <N>
1434 If -t is given, an additional -N<N> option can be given, where <N>
1434 must be an integer indicating how many times you want the script to
1435 must be an integer indicating how many times you want the script to
1435 run. The final timing report will include total and per run results.
1436 run. The final timing report will include total and per run results.
1436
1437
1437 For example (testing the script uniq_stable.py):
1438 For example (testing the script uniq_stable.py):
1438
1439
1439 In [1]: run -t uniq_stable
1440 In [1]: run -t uniq_stable
1440
1441
1441 IPython CPU timings (estimated):\\
1442 IPython CPU timings (estimated):\\
1442 User : 0.19597 s.\\
1443 User : 0.19597 s.\\
1443 System: 0.0 s.\\
1444 System: 0.0 s.\\
1444
1445
1445 In [2]: run -t -N5 uniq_stable
1446 In [2]: run -t -N5 uniq_stable
1446
1447
1447 IPython CPU timings (estimated):\\
1448 IPython CPU timings (estimated):\\
1448 Total runs performed: 5\\
1449 Total runs performed: 5\\
1449 Times : Total Per run\\
1450 Times : Total Per run\\
1450 User : 0.910862 s, 0.1821724 s.\\
1451 User : 0.910862 s, 0.1821724 s.\\
1451 System: 0.0 s, 0.0 s.
1452 System: 0.0 s, 0.0 s.
1452
1453
1453 -d: run your program under the control of pdb, the Python debugger.
1454 -d: run your program under the control of pdb, the Python debugger.
1454 This allows you to execute your program step by step, watch variables,
1455 This allows you to execute your program step by step, watch variables,
1455 etc. Internally, what IPython does is similar to calling:
1456 etc. Internally, what IPython does is similar to calling:
1456
1457
1457 pdb.run('execfile("YOURFILENAME")')
1458 pdb.run('execfile("YOURFILENAME")')
1458
1459
1459 with a breakpoint set on line 1 of your file. You can change the line
1460 with a breakpoint set on line 1 of your file. You can change the line
1460 number for this automatic breakpoint to be <N> by using the -bN option
1461 number for this automatic breakpoint to be <N> by using the -bN option
1461 (where N must be an integer). For example:
1462 (where N must be an integer). For example:
1462
1463
1463 %run -d -b40 myscript
1464 %run -d -b40 myscript
1464
1465
1465 will set the first breakpoint at line 40 in myscript.py. Note that
1466 will set the first breakpoint at line 40 in myscript.py. Note that
1466 the first breakpoint must be set on a line which actually does
1467 the first breakpoint must be set on a line which actually does
1467 something (not a comment or docstring) for it to stop execution.
1468 something (not a comment or docstring) for it to stop execution.
1468
1469
1469 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1470 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1470 first enter 'c' (without qoutes) to start execution up to the first
1471 first enter 'c' (without qoutes) to start execution up to the first
1471 breakpoint.
1472 breakpoint.
1472
1473
1473 Entering 'help' gives information about the use of the debugger. You
1474 Entering 'help' gives information about the use of the debugger. You
1474 can easily see pdb's full documentation with "import pdb;pdb.help()"
1475 can easily see pdb's full documentation with "import pdb;pdb.help()"
1475 at a prompt.
1476 at a prompt.
1476
1477
1477 -p: run program under the control of the Python profiler module (which
1478 -p: run program under the control of the Python profiler module (which
1478 prints a detailed report of execution times, function calls, etc).
1479 prints a detailed report of execution times, function calls, etc).
1479
1480
1480 You can pass other options after -p which affect the behavior of the
1481 You can pass other options after -p which affect the behavior of the
1481 profiler itself. See the docs for %prun for details.
1482 profiler itself. See the docs for %prun for details.
1482
1483
1483 In this mode, the program's variables do NOT propagate back to the
1484 In this mode, the program's variables do NOT propagate back to the
1484 IPython interactive namespace (because they remain in the namespace
1485 IPython interactive namespace (because they remain in the namespace
1485 where the profiler executes them).
1486 where the profiler executes them).
1486
1487
1487 Internally this triggers a call to %prun, see its documentation for
1488 Internally this triggers a call to %prun, see its documentation for
1488 details on the options available specifically for profiling.
1489 details on the options available specifically for profiling.
1489
1490
1490 There is one special usage for which the text above doesn't apply:
1491 There is one special usage for which the text above doesn't apply:
1491 if the filename ends with .ipy, the file is run as ipython script,
1492 if the filename ends with .ipy, the file is run as ipython script,
1492 just as if the commands were written on IPython prompt.
1493 just as if the commands were written on IPython prompt.
1493 """
1494 """
1494
1495
1495 # get arguments and set sys.argv for program to be run.
1496 # get arguments and set sys.argv for program to be run.
1496 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1497 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1497 mode='list',list_all=1)
1498 mode='list',list_all=1)
1498
1499
1499 try:
1500 try:
1500 filename = get_py_filename(arg_lst[0])
1501 filename = get_py_filename(arg_lst[0])
1501 except IndexError:
1502 except IndexError:
1502 warn('you must provide at least a filename.')
1503 warn('you must provide at least a filename.')
1503 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1504 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1504 return
1505 return
1505 except IOError,msg:
1506 except IOError,msg:
1506 error(msg)
1507 error(msg)
1507 return
1508 return
1508
1509
1509 if filename.lower().endswith('.ipy'):
1510 if filename.lower().endswith('.ipy'):
1510 self.api.runlines(open(filename).read())
1511 self.api.runlines(open(filename).read())
1511 return
1512 return
1512
1513
1513 # Control the response to exit() calls made by the script being run
1514 # Control the response to exit() calls made by the script being run
1514 exit_ignore = opts.has_key('e')
1515 exit_ignore = opts.has_key('e')
1515
1516
1516 # Make sure that the running script gets a proper sys.argv as if it
1517 # Make sure that the running script gets a proper sys.argv as if it
1517 # were run from a system shell.
1518 # were run from a system shell.
1518 save_argv = sys.argv # save it for later restoring
1519 save_argv = sys.argv # save it for later restoring
1519 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1520 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1520
1521
1521 if opts.has_key('i'):
1522 if opts.has_key('i'):
1522 prog_ns = self.shell.user_ns
1523 prog_ns = self.shell.user_ns
1523 __name__save = self.shell.user_ns['__name__']
1524 __name__save = self.shell.user_ns['__name__']
1524 prog_ns['__name__'] = '__main__'
1525 prog_ns['__name__'] = '__main__'
1525 else:
1526 else:
1526 if opts.has_key('n'):
1527 if opts.has_key('n'):
1527 name = os.path.splitext(os.path.basename(filename))[0]
1528 name = os.path.splitext(os.path.basename(filename))[0]
1528 else:
1529 else:
1529 name = '__main__'
1530 name = '__main__'
1530 prog_ns = {'__name__':name}
1531 prog_ns = {'__name__':name}
1531
1532
1532 # Since '%run foo' emulates 'python foo.py' at the cmd line, we must
1533 # Since '%run foo' emulates 'python foo.py' at the cmd line, we must
1533 # set the __file__ global in the script's namespace
1534 # set the __file__ global in the script's namespace
1534 prog_ns['__file__'] = filename
1535 prog_ns['__file__'] = filename
1535
1536
1536 # pickle fix. See iplib for an explanation. But we need to make sure
1537 # pickle fix. See iplib for an explanation. But we need to make sure
1537 # that, if we overwrite __main__, we replace it at the end
1538 # that, if we overwrite __main__, we replace it at the end
1538 if prog_ns['__name__'] == '__main__':
1539 if prog_ns['__name__'] == '__main__':
1539 restore_main = sys.modules['__main__']
1540 restore_main = sys.modules['__main__']
1540 else:
1541 else:
1541 restore_main = False
1542 restore_main = False
1542
1543
1543 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1544 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1544
1545
1545 stats = None
1546 stats = None
1546 try:
1547 try:
1547 if self.shell.has_readline:
1548 if self.shell.has_readline:
1548 self.shell.savehist()
1549 self.shell.savehist()
1549
1550
1550 if opts.has_key('p'):
1551 if opts.has_key('p'):
1551 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1552 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1552 else:
1553 else:
1553 if opts.has_key('d'):
1554 if opts.has_key('d'):
1554 deb = Debugger.Pdb(self.shell.rc.colors)
1555 deb = Debugger.Pdb(self.shell.rc.colors)
1555 # reset Breakpoint state, which is moronically kept
1556 # reset Breakpoint state, which is moronically kept
1556 # in a class
1557 # in a class
1557 bdb.Breakpoint.next = 1
1558 bdb.Breakpoint.next = 1
1558 bdb.Breakpoint.bplist = {}
1559 bdb.Breakpoint.bplist = {}
1559 bdb.Breakpoint.bpbynumber = [None]
1560 bdb.Breakpoint.bpbynumber = [None]
1560 # Set an initial breakpoint to stop execution
1561 # Set an initial breakpoint to stop execution
1561 maxtries = 10
1562 maxtries = 10
1562 bp = int(opts.get('b',[1])[0])
1563 bp = int(opts.get('b',[1])[0])
1563 checkline = deb.checkline(filename,bp)
1564 checkline = deb.checkline(filename,bp)
1564 if not checkline:
1565 if not checkline:
1565 for bp in range(bp+1,bp+maxtries+1):
1566 for bp in range(bp+1,bp+maxtries+1):
1566 if deb.checkline(filename,bp):
1567 if deb.checkline(filename,bp):
1567 break
1568 break
1568 else:
1569 else:
1569 msg = ("\nI failed to find a valid line to set "
1570 msg = ("\nI failed to find a valid line to set "
1570 "a breakpoint\n"
1571 "a breakpoint\n"
1571 "after trying up to line: %s.\n"
1572 "after trying up to line: %s.\n"
1572 "Please set a valid breakpoint manually "
1573 "Please set a valid breakpoint manually "
1573 "with the -b option." % bp)
1574 "with the -b option." % bp)
1574 error(msg)
1575 error(msg)
1575 return
1576 return
1576 # if we find a good linenumber, set the breakpoint
1577 # if we find a good linenumber, set the breakpoint
1577 deb.do_break('%s:%s' % (filename,bp))
1578 deb.do_break('%s:%s' % (filename,bp))
1578 # Start file run
1579 # Start file run
1579 print "NOTE: Enter 'c' at the",
1580 print "NOTE: Enter 'c' at the",
1580 print "%s prompt to start your script." % deb.prompt
1581 print "%s prompt to start your script." % deb.prompt
1581 try:
1582 try:
1582 deb.run('execfile("%s")' % filename,prog_ns)
1583 deb.run('execfile("%s")' % filename,prog_ns)
1583
1584
1584 except:
1585 except:
1585 etype, value, tb = sys.exc_info()
1586 etype, value, tb = sys.exc_info()
1586 # Skip three frames in the traceback: the %run one,
1587 # Skip three frames in the traceback: the %run one,
1587 # one inside bdb.py, and the command-line typed by the
1588 # one inside bdb.py, and the command-line typed by the
1588 # user (run by exec in pdb itself).
1589 # user (run by exec in pdb itself).
1589 self.shell.InteractiveTB(etype,value,tb,tb_offset=3)
1590 self.shell.InteractiveTB(etype,value,tb,tb_offset=3)
1590 else:
1591 else:
1591 if runner is None:
1592 if runner is None:
1592 runner = self.shell.safe_execfile
1593 runner = self.shell.safe_execfile
1593 if opts.has_key('t'):
1594 if opts.has_key('t'):
1594 try:
1595 try:
1595 nruns = int(opts['N'][0])
1596 nruns = int(opts['N'][0])
1596 if nruns < 1:
1597 if nruns < 1:
1597 error('Number of runs must be >=1')
1598 error('Number of runs must be >=1')
1598 return
1599 return
1599 except (KeyError):
1600 except (KeyError):
1600 nruns = 1
1601 nruns = 1
1601 if nruns == 1:
1602 if nruns == 1:
1602 t0 = clock2()
1603 t0 = clock2()
1603 runner(filename,prog_ns,prog_ns,
1604 runner(filename,prog_ns,prog_ns,
1604 exit_ignore=exit_ignore)
1605 exit_ignore=exit_ignore)
1605 t1 = clock2()
1606 t1 = clock2()
1606 t_usr = t1[0]-t0[0]
1607 t_usr = t1[0]-t0[0]
1607 t_sys = t1[1]-t1[1]
1608 t_sys = t1[1]-t1[1]
1608 print "\nIPython CPU timings (estimated):"
1609 print "\nIPython CPU timings (estimated):"
1609 print " User : %10s s." % t_usr
1610 print " User : %10s s." % t_usr
1610 print " System: %10s s." % t_sys
1611 print " System: %10s s." % t_sys
1611 else:
1612 else:
1612 runs = range(nruns)
1613 runs = range(nruns)
1613 t0 = clock2()
1614 t0 = clock2()
1614 for nr in runs:
1615 for nr in runs:
1615 runner(filename,prog_ns,prog_ns,
1616 runner(filename,prog_ns,prog_ns,
1616 exit_ignore=exit_ignore)
1617 exit_ignore=exit_ignore)
1617 t1 = clock2()
1618 t1 = clock2()
1618 t_usr = t1[0]-t0[0]
1619 t_usr = t1[0]-t0[0]
1619 t_sys = t1[1]-t1[1]
1620 t_sys = t1[1]-t1[1]
1620 print "\nIPython CPU timings (estimated):"
1621 print "\nIPython CPU timings (estimated):"
1621 print "Total runs performed:",nruns
1622 print "Total runs performed:",nruns
1622 print " Times : %10s %10s" % ('Total','Per run')
1623 print " Times : %10s %10s" % ('Total','Per run')
1623 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1624 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1624 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1625 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1625
1626
1626 else:
1627 else:
1627 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1628 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1628 if opts.has_key('i'):
1629 if opts.has_key('i'):
1629 self.shell.user_ns['__name__'] = __name__save
1630 self.shell.user_ns['__name__'] = __name__save
1630 else:
1631 else:
1631 # update IPython interactive namespace
1632 # update IPython interactive namespace
1632 del prog_ns['__name__']
1633 del prog_ns['__name__']
1633 self.shell.user_ns.update(prog_ns)
1634 self.shell.user_ns.update(prog_ns)
1634 finally:
1635 finally:
1635 sys.argv = save_argv
1636 sys.argv = save_argv
1636 if restore_main:
1637 if restore_main:
1637 sys.modules['__main__'] = restore_main
1638 sys.modules['__main__'] = restore_main
1638 if self.shell.has_readline:
1639 if self.shell.has_readline:
1639 self.shell.readline.read_history_file(self.shell.histfile)
1640 self.shell.readline.read_history_file(self.shell.histfile)
1640
1641
1641 return stats
1642 return stats
1642
1643
1643 def magic_runlog(self, parameter_s =''):
1644 def magic_runlog(self, parameter_s =''):
1644 """Run files as logs.
1645 """Run files as logs.
1645
1646
1646 Usage:\\
1647 Usage:\\
1647 %runlog file1 file2 ...
1648 %runlog file1 file2 ...
1648
1649
1649 Run the named files (treating them as log files) in sequence inside
1650 Run the named files (treating them as log files) in sequence inside
1650 the interpreter, and return to the prompt. This is much slower than
1651 the interpreter, and return to the prompt. This is much slower than
1651 %run because each line is executed in a try/except block, but it
1652 %run because each line is executed in a try/except block, but it
1652 allows running files with syntax errors in them.
1653 allows running files with syntax errors in them.
1653
1654
1654 Normally IPython will guess when a file is one of its own logfiles, so
1655 Normally IPython will guess when a file is one of its own logfiles, so
1655 you can typically use %run even for logs. This shorthand allows you to
1656 you can typically use %run even for logs. This shorthand allows you to
1656 force any file to be treated as a log file."""
1657 force any file to be treated as a log file."""
1657
1658
1658 for f in parameter_s.split():
1659 for f in parameter_s.split():
1659 self.shell.safe_execfile(f,self.shell.user_ns,
1660 self.shell.safe_execfile(f,self.shell.user_ns,
1660 self.shell.user_ns,islog=1)
1661 self.shell.user_ns,islog=1)
1661
1662
1662 def magic_timeit(self, parameter_s =''):
1663 def magic_timeit(self, parameter_s =''):
1663 """Time execution of a Python statement or expression
1664 """Time execution of a Python statement or expression
1664
1665
1665 Usage:\\
1666 Usage:\\
1666 %timeit [-n<N> -r<R> [-t|-c]] statement
1667 %timeit [-n<N> -r<R> [-t|-c]] statement
1667
1668
1668 Time execution of a Python statement or expression using the timeit
1669 Time execution of a Python statement or expression using the timeit
1669 module.
1670 module.
1670
1671
1671 Options:
1672 Options:
1672 -n<N>: execute the given statement <N> times in a loop. If this value
1673 -n<N>: execute the given statement <N> times in a loop. If this value
1673 is not given, a fitting value is chosen.
1674 is not given, a fitting value is chosen.
1674
1675
1675 -r<R>: repeat the loop iteration <R> times and take the best result.
1676 -r<R>: repeat the loop iteration <R> times and take the best result.
1676 Default: 3
1677 Default: 3
1677
1678
1678 -t: use time.time to measure the time, which is the default on Unix.
1679 -t: use time.time to measure the time, which is the default on Unix.
1679 This function measures wall time.
1680 This function measures wall time.
1680
1681
1681 -c: use time.clock to measure the time, which is the default on
1682 -c: use time.clock to measure the time, which is the default on
1682 Windows and measures wall time. On Unix, resource.getrusage is used
1683 Windows and measures wall time. On Unix, resource.getrusage is used
1683 instead and returns the CPU user time.
1684 instead and returns the CPU user time.
1684
1685
1685 -p<P>: use a precision of <P> digits to display the timing result.
1686 -p<P>: use a precision of <P> digits to display the timing result.
1686 Default: 3
1687 Default: 3
1687
1688
1688
1689
1689 Examples:\\
1690 Examples:\\
1690 In [1]: %timeit pass
1691 In [1]: %timeit pass
1691 10000000 loops, best of 3: 53.3 ns per loop
1692 10000000 loops, best of 3: 53.3 ns per loop
1692
1693
1693 In [2]: u = None
1694 In [2]: u = None
1694
1695
1695 In [3]: %timeit u is None
1696 In [3]: %timeit u is None
1696 10000000 loops, best of 3: 184 ns per loop
1697 10000000 loops, best of 3: 184 ns per loop
1697
1698
1698 In [4]: %timeit -r 4 u == None
1699 In [4]: %timeit -r 4 u == None
1699 1000000 loops, best of 4: 242 ns per loop
1700 1000000 loops, best of 4: 242 ns per loop
1700
1701
1701 In [5]: import time
1702 In [5]: import time
1702
1703
1703 In [6]: %timeit -n1 time.sleep(2)
1704 In [6]: %timeit -n1 time.sleep(2)
1704 1 loops, best of 3: 2 s per loop
1705 1 loops, best of 3: 2 s per loop
1705
1706
1706
1707
1707 The times reported by %timeit will be slightly higher than those
1708 The times reported by %timeit will be slightly higher than those
1708 reported by the timeit.py script when variables are accessed. This is
1709 reported by the timeit.py script when variables are accessed. This is
1709 due to the fact that %timeit executes the statement in the namespace
1710 due to the fact that %timeit executes the statement in the namespace
1710 of the shell, compared with timeit.py, which uses a single setup
1711 of the shell, compared with timeit.py, which uses a single setup
1711 statement to import function or create variables. Generally, the bias
1712 statement to import function or create variables. Generally, the bias
1712 does not matter as long as results from timeit.py are not mixed with
1713 does not matter as long as results from timeit.py are not mixed with
1713 those from %timeit."""
1714 those from %timeit."""
1714
1715
1715 import timeit
1716 import timeit
1716 import math
1717 import math
1717
1718
1718 units = ["s", "ms", "\xc2\xb5s", "ns"]
1719 units = ["s", "ms", "\xc2\xb5s", "ns"]
1719 scaling = [1, 1e3, 1e6, 1e9]
1720 scaling = [1, 1e3, 1e6, 1e9]
1720
1721
1721 opts, stmt = self.parse_options(parameter_s,'n:r:tcp:',
1722 opts, stmt = self.parse_options(parameter_s,'n:r:tcp:',
1722 posix=False)
1723 posix=False)
1723 if stmt == "":
1724 if stmt == "":
1724 return
1725 return
1725 timefunc = timeit.default_timer
1726 timefunc = timeit.default_timer
1726 number = int(getattr(opts, "n", 0))
1727 number = int(getattr(opts, "n", 0))
1727 repeat = int(getattr(opts, "r", timeit.default_repeat))
1728 repeat = int(getattr(opts, "r", timeit.default_repeat))
1728 precision = int(getattr(opts, "p", 3))
1729 precision = int(getattr(opts, "p", 3))
1729 if hasattr(opts, "t"):
1730 if hasattr(opts, "t"):
1730 timefunc = time.time
1731 timefunc = time.time
1731 if hasattr(opts, "c"):
1732 if hasattr(opts, "c"):
1732 timefunc = clock
1733 timefunc = clock
1733
1734
1734 timer = timeit.Timer(timer=timefunc)
1735 timer = timeit.Timer(timer=timefunc)
1735 # this code has tight coupling to the inner workings of timeit.Timer,
1736 # this code has tight coupling to the inner workings of timeit.Timer,
1736 # but is there a better way to achieve that the code stmt has access
1737 # but is there a better way to achieve that the code stmt has access
1737 # to the shell namespace?
1738 # to the shell namespace?
1738
1739
1739 src = timeit.template % {'stmt': timeit.reindent(stmt, 8),
1740 src = timeit.template % {'stmt': timeit.reindent(stmt, 8),
1740 'setup': "pass"}
1741 'setup': "pass"}
1741 code = compile(src, "<magic-timeit>", "exec")
1742 code = compile(src, "<magic-timeit>", "exec")
1742 ns = {}
1743 ns = {}
1743 exec code in self.shell.user_ns, ns
1744 exec code in self.shell.user_ns, ns
1744 timer.inner = ns["inner"]
1745 timer.inner = ns["inner"]
1745
1746
1746 if number == 0:
1747 if number == 0:
1747 # determine number so that 0.2 <= total time < 2.0
1748 # determine number so that 0.2 <= total time < 2.0
1748 number = 1
1749 number = 1
1749 for i in range(1, 10):
1750 for i in range(1, 10):
1750 number *= 10
1751 number *= 10
1751 if timer.timeit(number) >= 0.2:
1752 if timer.timeit(number) >= 0.2:
1752 break
1753 break
1753
1754
1754 best = min(timer.repeat(repeat, number)) / number
1755 best = min(timer.repeat(repeat, number)) / number
1755
1756
1756 if best > 0.0:
1757 if best > 0.0:
1757 order = min(-int(math.floor(math.log10(best)) // 3), 3)
1758 order = min(-int(math.floor(math.log10(best)) // 3), 3)
1758 else:
1759 else:
1759 order = 3
1760 order = 3
1760 print "%d loops, best of %d: %.*g %s per loop" % (number, repeat,
1761 print "%d loops, best of %d: %.*g %s per loop" % (number, repeat,
1761 precision,
1762 precision,
1762 best * scaling[order],
1763 best * scaling[order],
1763 units[order])
1764 units[order])
1764
1765
1765 def magic_time(self,parameter_s = ''):
1766 def magic_time(self,parameter_s = ''):
1766 """Time execution of a Python statement or expression.
1767 """Time execution of a Python statement or expression.
1767
1768
1768 The CPU and wall clock times are printed, and the value of the
1769 The CPU and wall clock times are printed, and the value of the
1769 expression (if any) is returned. Note that under Win32, system time
1770 expression (if any) is returned. Note that under Win32, system time
1770 is always reported as 0, since it can not be measured.
1771 is always reported as 0, since it can not be measured.
1771
1772
1772 This function provides very basic timing functionality. In Python
1773 This function provides very basic timing functionality. In Python
1773 2.3, the timeit module offers more control and sophistication, so this
1774 2.3, the timeit module offers more control and sophistication, so this
1774 could be rewritten to use it (patches welcome).
1775 could be rewritten to use it (patches welcome).
1775
1776
1776 Some examples:
1777 Some examples:
1777
1778
1778 In [1]: time 2**128
1779 In [1]: time 2**128
1779 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1780 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1780 Wall time: 0.00
1781 Wall time: 0.00
1781 Out[1]: 340282366920938463463374607431768211456L
1782 Out[1]: 340282366920938463463374607431768211456L
1782
1783
1783 In [2]: n = 1000000
1784 In [2]: n = 1000000
1784
1785
1785 In [3]: time sum(range(n))
1786 In [3]: time sum(range(n))
1786 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1787 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1787 Wall time: 1.37
1788 Wall time: 1.37
1788 Out[3]: 499999500000L
1789 Out[3]: 499999500000L
1789
1790
1790 In [4]: time print 'hello world'
1791 In [4]: time print 'hello world'
1791 hello world
1792 hello world
1792 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1793 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1793 Wall time: 0.00
1794 Wall time: 0.00
1794 """
1795 """
1795
1796
1796 # fail immediately if the given expression can't be compiled
1797 # fail immediately if the given expression can't be compiled
1797 try:
1798 try:
1798 mode = 'eval'
1799 mode = 'eval'
1799 code = compile(parameter_s,'<timed eval>',mode)
1800 code = compile(parameter_s,'<timed eval>',mode)
1800 except SyntaxError:
1801 except SyntaxError:
1801 mode = 'exec'
1802 mode = 'exec'
1802 code = compile(parameter_s,'<timed exec>',mode)
1803 code = compile(parameter_s,'<timed exec>',mode)
1803 # skew measurement as little as possible
1804 # skew measurement as little as possible
1804 glob = self.shell.user_ns
1805 glob = self.shell.user_ns
1805 clk = clock2
1806 clk = clock2
1806 wtime = time.time
1807 wtime = time.time
1807 # time execution
1808 # time execution
1808 wall_st = wtime()
1809 wall_st = wtime()
1809 if mode=='eval':
1810 if mode=='eval':
1810 st = clk()
1811 st = clk()
1811 out = eval(code,glob)
1812 out = eval(code,glob)
1812 end = clk()
1813 end = clk()
1813 else:
1814 else:
1814 st = clk()
1815 st = clk()
1815 exec code in glob
1816 exec code in glob
1816 end = clk()
1817 end = clk()
1817 out = None
1818 out = None
1818 wall_end = wtime()
1819 wall_end = wtime()
1819 # Compute actual times and report
1820 # Compute actual times and report
1820 wall_time = wall_end-wall_st
1821 wall_time = wall_end-wall_st
1821 cpu_user = end[0]-st[0]
1822 cpu_user = end[0]-st[0]
1822 cpu_sys = end[1]-st[1]
1823 cpu_sys = end[1]-st[1]
1823 cpu_tot = cpu_user+cpu_sys
1824 cpu_tot = cpu_user+cpu_sys
1824 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1825 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1825 (cpu_user,cpu_sys,cpu_tot)
1826 (cpu_user,cpu_sys,cpu_tot)
1826 print "Wall time: %.2f" % wall_time
1827 print "Wall time: %.2f" % wall_time
1827 return out
1828 return out
1828
1829
1829 def magic_macro(self,parameter_s = ''):
1830 def magic_macro(self,parameter_s = ''):
1830 """Define a set of input lines as a macro for future re-execution.
1831 """Define a set of input lines as a macro for future re-execution.
1831
1832
1832 Usage:\\
1833 Usage:\\
1833 %macro [options] name n1-n2 n3-n4 ... n5 .. n6 ...
1834 %macro [options] name n1-n2 n3-n4 ... n5 .. n6 ...
1834
1835
1835 Options:
1836 Options:
1836
1837
1837 -r: use 'raw' input. By default, the 'processed' history is used,
1838 -r: use 'raw' input. By default, the 'processed' history is used,
1838 so that magics are loaded in their transformed version to valid
1839 so that magics are loaded in their transformed version to valid
1839 Python. If this option is given, the raw input as typed as the
1840 Python. If this option is given, the raw input as typed as the
1840 command line is used instead.
1841 command line is used instead.
1841
1842
1842 This will define a global variable called `name` which is a string
1843 This will define a global variable called `name` which is a string
1843 made of joining the slices and lines you specify (n1,n2,... numbers
1844 made of joining the slices and lines you specify (n1,n2,... numbers
1844 above) from your input history into a single string. This variable
1845 above) from your input history into a single string. This variable
1845 acts like an automatic function which re-executes those lines as if
1846 acts like an automatic function which re-executes those lines as if
1846 you had typed them. You just type 'name' at the prompt and the code
1847 you had typed them. You just type 'name' at the prompt and the code
1847 executes.
1848 executes.
1848
1849
1849 The notation for indicating number ranges is: n1-n2 means 'use line
1850 The notation for indicating number ranges is: n1-n2 means 'use line
1850 numbers n1,...n2' (the endpoint is included). That is, '5-7' means
1851 numbers n1,...n2' (the endpoint is included). That is, '5-7' means
1851 using the lines numbered 5,6 and 7.
1852 using the lines numbered 5,6 and 7.
1852
1853
1853 Note: as a 'hidden' feature, you can also use traditional python slice
1854 Note: as a 'hidden' feature, you can also use traditional python slice
1854 notation, where N:M means numbers N through M-1.
1855 notation, where N:M means numbers N through M-1.
1855
1856
1856 For example, if your history contains (%hist prints it):
1857 For example, if your history contains (%hist prints it):
1857
1858
1858 44: x=1\\
1859 44: x=1\\
1859 45: y=3\\
1860 45: y=3\\
1860 46: z=x+y\\
1861 46: z=x+y\\
1861 47: print x\\
1862 47: print x\\
1862 48: a=5\\
1863 48: a=5\\
1863 49: print 'x',x,'y',y\\
1864 49: print 'x',x,'y',y\\
1864
1865
1865 you can create a macro with lines 44 through 47 (included) and line 49
1866 you can create a macro with lines 44 through 47 (included) and line 49
1866 called my_macro with:
1867 called my_macro with:
1867
1868
1868 In [51]: %macro my_macro 44-47 49
1869 In [51]: %macro my_macro 44-47 49
1869
1870
1870 Now, typing `my_macro` (without quotes) will re-execute all this code
1871 Now, typing `my_macro` (without quotes) will re-execute all this code
1871 in one pass.
1872 in one pass.
1872
1873
1873 You don't need to give the line-numbers in order, and any given line
1874 You don't need to give the line-numbers in order, and any given line
1874 number can appear multiple times. You can assemble macros with any
1875 number can appear multiple times. You can assemble macros with any
1875 lines from your input history in any order.
1876 lines from your input history in any order.
1876
1877
1877 The macro is a simple object which holds its value in an attribute,
1878 The macro is a simple object which holds its value in an attribute,
1878 but IPython's display system checks for macros and executes them as
1879 but IPython's display system checks for macros and executes them as
1879 code instead of printing them when you type their name.
1880 code instead of printing them when you type their name.
1880
1881
1881 You can view a macro's contents by explicitly printing it with:
1882 You can view a macro's contents by explicitly printing it with:
1882
1883
1883 'print macro_name'.
1884 'print macro_name'.
1884
1885
1885 For one-off cases which DON'T contain magic function calls in them you
1886 For one-off cases which DON'T contain magic function calls in them you
1886 can obtain similar results by explicitly executing slices from your
1887 can obtain similar results by explicitly executing slices from your
1887 input history with:
1888 input history with:
1888
1889
1889 In [60]: exec In[44:48]+In[49]"""
1890 In [60]: exec In[44:48]+In[49]"""
1890
1891
1891 opts,args = self.parse_options(parameter_s,'r',mode='list')
1892 opts,args = self.parse_options(parameter_s,'r',mode='list')
1892 name,ranges = args[0], args[1:]
1893 name,ranges = args[0], args[1:]
1893 #print 'rng',ranges # dbg
1894 #print 'rng',ranges # dbg
1894 lines = self.extract_input_slices(ranges,opts.has_key('r'))
1895 lines = self.extract_input_slices(ranges,opts.has_key('r'))
1895 macro = Macro(lines)
1896 macro = Macro(lines)
1896 self.shell.user_ns.update({name:macro})
1897 self.shell.user_ns.update({name:macro})
1897 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1898 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1898 print 'Macro contents:'
1899 print 'Macro contents:'
1899 print macro,
1900 print macro,
1900
1901
1901 def magic_save(self,parameter_s = ''):
1902 def magic_save(self,parameter_s = ''):
1902 """Save a set of lines to a given filename.
1903 """Save a set of lines to a given filename.
1903
1904
1904 Usage:\\
1905 Usage:\\
1905 %save [options] filename n1-n2 n3-n4 ... n5 .. n6 ...
1906 %save [options] filename n1-n2 n3-n4 ... n5 .. n6 ...
1906
1907
1907 Options:
1908 Options:
1908
1909
1909 -r: use 'raw' input. By default, the 'processed' history is used,
1910 -r: use 'raw' input. By default, the 'processed' history is used,
1910 so that magics are loaded in their transformed version to valid
1911 so that magics are loaded in their transformed version to valid
1911 Python. If this option is given, the raw input as typed as the
1912 Python. If this option is given, the raw input as typed as the
1912 command line is used instead.
1913 command line is used instead.
1913
1914
1914 This function uses the same syntax as %macro for line extraction, but
1915 This function uses the same syntax as %macro for line extraction, but
1915 instead of creating a macro it saves the resulting string to the
1916 instead of creating a macro it saves the resulting string to the
1916 filename you specify.
1917 filename you specify.
1917
1918
1918 It adds a '.py' extension to the file if you don't do so yourself, and
1919 It adds a '.py' extension to the file if you don't do so yourself, and
1919 it asks for confirmation before overwriting existing files."""
1920 it asks for confirmation before overwriting existing files."""
1920
1921
1921 opts,args = self.parse_options(parameter_s,'r',mode='list')
1922 opts,args = self.parse_options(parameter_s,'r',mode='list')
1922 fname,ranges = args[0], args[1:]
1923 fname,ranges = args[0], args[1:]
1923 if not fname.endswith('.py'):
1924 if not fname.endswith('.py'):
1924 fname += '.py'
1925 fname += '.py'
1925 if os.path.isfile(fname):
1926 if os.path.isfile(fname):
1926 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1927 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1927 if ans.lower() not in ['y','yes']:
1928 if ans.lower() not in ['y','yes']:
1928 print 'Operation cancelled.'
1929 print 'Operation cancelled.'
1929 return
1930 return
1930 cmds = ''.join(self.extract_input_slices(ranges,opts.has_key('r')))
1931 cmds = ''.join(self.extract_input_slices(ranges,opts.has_key('r')))
1931 f = file(fname,'w')
1932 f = file(fname,'w')
1932 f.write(cmds)
1933 f.write(cmds)
1933 f.close()
1934 f.close()
1934 print 'The following commands were written to file `%s`:' % fname
1935 print 'The following commands were written to file `%s`:' % fname
1935 print cmds
1936 print cmds
1936
1937
1937 def _edit_macro(self,mname,macro):
1938 def _edit_macro(self,mname,macro):
1938 """open an editor with the macro data in a file"""
1939 """open an editor with the macro data in a file"""
1939 filename = self.shell.mktempfile(macro.value)
1940 filename = self.shell.mktempfile(macro.value)
1940 self.shell.hooks.editor(filename)
1941 self.shell.hooks.editor(filename)
1941
1942
1942 # and make a new macro object, to replace the old one
1943 # and make a new macro object, to replace the old one
1943 mfile = open(filename)
1944 mfile = open(filename)
1944 mvalue = mfile.read()
1945 mvalue = mfile.read()
1945 mfile.close()
1946 mfile.close()
1946 self.shell.user_ns[mname] = Macro(mvalue)
1947 self.shell.user_ns[mname] = Macro(mvalue)
1947
1948
1948 def magic_ed(self,parameter_s=''):
1949 def magic_ed(self,parameter_s=''):
1949 """Alias to %edit."""
1950 """Alias to %edit."""
1950 return self.magic_edit(parameter_s)
1951 return self.magic_edit(parameter_s)
1951
1952
1952 def magic_edit(self,parameter_s='',last_call=['','']):
1953 def magic_edit(self,parameter_s='',last_call=['','']):
1953 """Bring up an editor and execute the resulting code.
1954 """Bring up an editor and execute the resulting code.
1954
1955
1955 Usage:
1956 Usage:
1956 %edit [options] [args]
1957 %edit [options] [args]
1957
1958
1958 %edit runs IPython's editor hook. The default version of this hook is
1959 %edit runs IPython's editor hook. The default version of this hook is
1959 set to call the __IPYTHON__.rc.editor command. This is read from your
1960 set to call the __IPYTHON__.rc.editor command. This is read from your
1960 environment variable $EDITOR. If this isn't found, it will default to
1961 environment variable $EDITOR. If this isn't found, it will default to
1961 vi under Linux/Unix and to notepad under Windows. See the end of this
1962 vi under Linux/Unix and to notepad under Windows. See the end of this
1962 docstring for how to change the editor hook.
1963 docstring for how to change the editor hook.
1963
1964
1964 You can also set the value of this editor via the command line option
1965 You can also set the value of this editor via the command line option
1965 '-editor' or in your ipythonrc file. This is useful if you wish to use
1966 '-editor' or in your ipythonrc file. This is useful if you wish to use
1966 specifically for IPython an editor different from your typical default
1967 specifically for IPython an editor different from your typical default
1967 (and for Windows users who typically don't set environment variables).
1968 (and for Windows users who typically don't set environment variables).
1968
1969
1969 This command allows you to conveniently edit multi-line code right in
1970 This command allows you to conveniently edit multi-line code right in
1970 your IPython session.
1971 your IPython session.
1971
1972
1972 If called without arguments, %edit opens up an empty editor with a
1973 If called without arguments, %edit opens up an empty editor with a
1973 temporary file and will execute the contents of this file when you
1974 temporary file and will execute the contents of this file when you
1974 close it (don't forget to save it!).
1975 close it (don't forget to save it!).
1975
1976
1976
1977
1977 Options:
1978 Options:
1978
1979
1979 -n <number>: open the editor at a specified line number. By default,
1980 -n <number>: open the editor at a specified line number. By default,
1980 the IPython editor hook uses the unix syntax 'editor +N filename', but
1981 the IPython editor hook uses the unix syntax 'editor +N filename', but
1981 you can configure this by providing your own modified hook if your
1982 you can configure this by providing your own modified hook if your
1982 favorite editor supports line-number specifications with a different
1983 favorite editor supports line-number specifications with a different
1983 syntax.
1984 syntax.
1984
1985
1985 -p: this will call the editor with the same data as the previous time
1986 -p: this will call the editor with the same data as the previous time
1986 it was used, regardless of how long ago (in your current session) it
1987 it was used, regardless of how long ago (in your current session) it
1987 was.
1988 was.
1988
1989
1989 -r: use 'raw' input. This option only applies to input taken from the
1990 -r: use 'raw' input. This option only applies to input taken from the
1990 user's history. By default, the 'processed' history is used, so that
1991 user's history. By default, the 'processed' history is used, so that
1991 magics are loaded in their transformed version to valid Python. If
1992 magics are loaded in their transformed version to valid Python. If
1992 this option is given, the raw input as typed as the command line is
1993 this option is given, the raw input as typed as the command line is
1993 used instead. When you exit the editor, it will be executed by
1994 used instead. When you exit the editor, it will be executed by
1994 IPython's own processor.
1995 IPython's own processor.
1995
1996
1996 -x: do not execute the edited code immediately upon exit. This is
1997 -x: do not execute the edited code immediately upon exit. This is
1997 mainly useful if you are editing programs which need to be called with
1998 mainly useful if you are editing programs which need to be called with
1998 command line arguments, which you can then do using %run.
1999 command line arguments, which you can then do using %run.
1999
2000
2000
2001
2001 Arguments:
2002 Arguments:
2002
2003
2003 If arguments are given, the following possibilites exist:
2004 If arguments are given, the following possibilites exist:
2004
2005
2005 - The arguments are numbers or pairs of colon-separated numbers (like
2006 - The arguments are numbers or pairs of colon-separated numbers (like
2006 1 4:8 9). These are interpreted as lines of previous input to be
2007 1 4:8 9). These are interpreted as lines of previous input to be
2007 loaded into the editor. The syntax is the same of the %macro command.
2008 loaded into the editor. The syntax is the same of the %macro command.
2008
2009
2009 - If the argument doesn't start with a number, it is evaluated as a
2010 - If the argument doesn't start with a number, it is evaluated as a
2010 variable and its contents loaded into the editor. You can thus edit
2011 variable and its contents loaded into the editor. You can thus edit
2011 any string which contains python code (including the result of
2012 any string which contains python code (including the result of
2012 previous edits).
2013 previous edits).
2013
2014
2014 - If the argument is the name of an object (other than a string),
2015 - If the argument is the name of an object (other than a string),
2015 IPython will try to locate the file where it was defined and open the
2016 IPython will try to locate the file where it was defined and open the
2016 editor at the point where it is defined. You can use `%edit function`
2017 editor at the point where it is defined. You can use `%edit function`
2017 to load an editor exactly at the point where 'function' is defined,
2018 to load an editor exactly at the point where 'function' is defined,
2018 edit it and have the file be executed automatically.
2019 edit it and have the file be executed automatically.
2019
2020
2020 If the object is a macro (see %macro for details), this opens up your
2021 If the object is a macro (see %macro for details), this opens up your
2021 specified editor with a temporary file containing the macro's data.
2022 specified editor with a temporary file containing the macro's data.
2022 Upon exit, the macro is reloaded with the contents of the file.
2023 Upon exit, the macro is reloaded with the contents of the file.
2023
2024
2024 Note: opening at an exact line is only supported under Unix, and some
2025 Note: opening at an exact line is only supported under Unix, and some
2025 editors (like kedit and gedit up to Gnome 2.8) do not understand the
2026 editors (like kedit and gedit up to Gnome 2.8) do not understand the
2026 '+NUMBER' parameter necessary for this feature. Good editors like
2027 '+NUMBER' parameter necessary for this feature. Good editors like
2027 (X)Emacs, vi, jed, pico and joe all do.
2028 (X)Emacs, vi, jed, pico and joe all do.
2028
2029
2029 - If the argument is not found as a variable, IPython will look for a
2030 - If the argument is not found as a variable, IPython will look for a
2030 file with that name (adding .py if necessary) and load it into the
2031 file with that name (adding .py if necessary) and load it into the
2031 editor. It will execute its contents with execfile() when you exit,
2032 editor. It will execute its contents with execfile() when you exit,
2032 loading any code in the file into your interactive namespace.
2033 loading any code in the file into your interactive namespace.
2033
2034
2034 After executing your code, %edit will return as output the code you
2035 After executing your code, %edit will return as output the code you
2035 typed in the editor (except when it was an existing file). This way
2036 typed in the editor (except when it was an existing file). This way
2036 you can reload the code in further invocations of %edit as a variable,
2037 you can reload the code in further invocations of %edit as a variable,
2037 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
2038 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
2038 the output.
2039 the output.
2039
2040
2040 Note that %edit is also available through the alias %ed.
2041 Note that %edit is also available through the alias %ed.
2041
2042
2042 This is an example of creating a simple function inside the editor and
2043 This is an example of creating a simple function inside the editor and
2043 then modifying it. First, start up the editor:
2044 then modifying it. First, start up the editor:
2044
2045
2045 In [1]: ed\\
2046 In [1]: ed\\
2046 Editing... done. Executing edited code...\\
2047 Editing... done. Executing edited code...\\
2047 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
2048 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
2048
2049
2049 We can then call the function foo():
2050 We can then call the function foo():
2050
2051
2051 In [2]: foo()\\
2052 In [2]: foo()\\
2052 foo() was defined in an editing session
2053 foo() was defined in an editing session
2053
2054
2054 Now we edit foo. IPython automatically loads the editor with the
2055 Now we edit foo. IPython automatically loads the editor with the
2055 (temporary) file where foo() was previously defined:
2056 (temporary) file where foo() was previously defined:
2056
2057
2057 In [3]: ed foo\\
2058 In [3]: ed foo\\
2058 Editing... done. Executing edited code...
2059 Editing... done. Executing edited code...
2059
2060
2060 And if we call foo() again we get the modified version:
2061 And if we call foo() again we get the modified version:
2061
2062
2062 In [4]: foo()\\
2063 In [4]: foo()\\
2063 foo() has now been changed!
2064 foo() has now been changed!
2064
2065
2065 Here is an example of how to edit a code snippet successive
2066 Here is an example of how to edit a code snippet successive
2066 times. First we call the editor:
2067 times. First we call the editor:
2067
2068
2068 In [8]: ed\\
2069 In [8]: ed\\
2069 Editing... done. Executing edited code...\\
2070 Editing... done. Executing edited code...\\
2070 hello\\
2071 hello\\
2071 Out[8]: "print 'hello'\\n"
2072 Out[8]: "print 'hello'\\n"
2072
2073
2073 Now we call it again with the previous output (stored in _):
2074 Now we call it again with the previous output (stored in _):
2074
2075
2075 In [9]: ed _\\
2076 In [9]: ed _\\
2076 Editing... done. Executing edited code...\\
2077 Editing... done. Executing edited code...\\
2077 hello world\\
2078 hello world\\
2078 Out[9]: "print 'hello world'\\n"
2079 Out[9]: "print 'hello world'\\n"
2079
2080
2080 Now we call it with the output #8 (stored in _8, also as Out[8]):
2081 Now we call it with the output #8 (stored in _8, also as Out[8]):
2081
2082
2082 In [10]: ed _8\\
2083 In [10]: ed _8\\
2083 Editing... done. Executing edited code...\\
2084 Editing... done. Executing edited code...\\
2084 hello again\\
2085 hello again\\
2085 Out[10]: "print 'hello again'\\n"
2086 Out[10]: "print 'hello again'\\n"
2086
2087
2087
2088
2088 Changing the default editor hook:
2089 Changing the default editor hook:
2089
2090
2090 If you wish to write your own editor hook, you can put it in a
2091 If you wish to write your own editor hook, you can put it in a
2091 configuration file which you load at startup time. The default hook
2092 configuration file which you load at startup time. The default hook
2092 is defined in the IPython.hooks module, and you can use that as a
2093 is defined in the IPython.hooks module, and you can use that as a
2093 starting example for further modifications. That file also has
2094 starting example for further modifications. That file also has
2094 general instructions on how to set a new hook for use once you've
2095 general instructions on how to set a new hook for use once you've
2095 defined it."""
2096 defined it."""
2096
2097
2097 # FIXME: This function has become a convoluted mess. It needs a
2098 # FIXME: This function has become a convoluted mess. It needs a
2098 # ground-up rewrite with clean, simple logic.
2099 # ground-up rewrite with clean, simple logic.
2099
2100
2100 def make_filename(arg):
2101 def make_filename(arg):
2101 "Make a filename from the given args"
2102 "Make a filename from the given args"
2102 try:
2103 try:
2103 filename = get_py_filename(arg)
2104 filename = get_py_filename(arg)
2104 except IOError:
2105 except IOError:
2105 if args.endswith('.py'):
2106 if args.endswith('.py'):
2106 filename = arg
2107 filename = arg
2107 else:
2108 else:
2108 filename = None
2109 filename = None
2109 return filename
2110 return filename
2110
2111
2111 # custom exceptions
2112 # custom exceptions
2112 class DataIsObject(Exception): pass
2113 class DataIsObject(Exception): pass
2113
2114
2114 opts,args = self.parse_options(parameter_s,'prxn:')
2115 opts,args = self.parse_options(parameter_s,'prxn:')
2115 # Set a few locals from the options for convenience:
2116 # Set a few locals from the options for convenience:
2116 opts_p = opts.has_key('p')
2117 opts_p = opts.has_key('p')
2117 opts_r = opts.has_key('r')
2118 opts_r = opts.has_key('r')
2118
2119
2119 # Default line number value
2120 # Default line number value
2120 lineno = opts.get('n',None)
2121 lineno = opts.get('n',None)
2121
2122
2122 if opts_p:
2123 if opts_p:
2123 args = '_%s' % last_call[0]
2124 args = '_%s' % last_call[0]
2124 if not self.shell.user_ns.has_key(args):
2125 if not self.shell.user_ns.has_key(args):
2125 args = last_call[1]
2126 args = last_call[1]
2126
2127
2127 # use last_call to remember the state of the previous call, but don't
2128 # use last_call to remember the state of the previous call, but don't
2128 # let it be clobbered by successive '-p' calls.
2129 # let it be clobbered by successive '-p' calls.
2129 try:
2130 try:
2130 last_call[0] = self.shell.outputcache.prompt_count
2131 last_call[0] = self.shell.outputcache.prompt_count
2131 if not opts_p:
2132 if not opts_p:
2132 last_call[1] = parameter_s
2133 last_call[1] = parameter_s
2133 except:
2134 except:
2134 pass
2135 pass
2135
2136
2136 # by default this is done with temp files, except when the given
2137 # by default this is done with temp files, except when the given
2137 # arg is a filename
2138 # arg is a filename
2138 use_temp = 1
2139 use_temp = 1
2139
2140
2140 if re.match(r'\d',args):
2141 if re.match(r'\d',args):
2141 # Mode where user specifies ranges of lines, like in %macro.
2142 # Mode where user specifies ranges of lines, like in %macro.
2142 # This means that you can't edit files whose names begin with
2143 # This means that you can't edit files whose names begin with
2143 # numbers this way. Tough.
2144 # numbers this way. Tough.
2144 ranges = args.split()
2145 ranges = args.split()
2145 data = ''.join(self.extract_input_slices(ranges,opts_r))
2146 data = ''.join(self.extract_input_slices(ranges,opts_r))
2146 elif args.endswith('.py'):
2147 elif args.endswith('.py'):
2147 filename = make_filename(args)
2148 filename = make_filename(args)
2148 data = ''
2149 data = ''
2149 use_temp = 0
2150 use_temp = 0
2150 elif args:
2151 elif args:
2151 try:
2152 try:
2152 # Load the parameter given as a variable. If not a string,
2153 # Load the parameter given as a variable. If not a string,
2153 # process it as an object instead (below)
2154 # process it as an object instead (below)
2154
2155
2155 #print '*** args',args,'type',type(args) # dbg
2156 #print '*** args',args,'type',type(args) # dbg
2156 data = eval(args,self.shell.user_ns)
2157 data = eval(args,self.shell.user_ns)
2157 if not type(data) in StringTypes:
2158 if not type(data) in StringTypes:
2158 raise DataIsObject
2159 raise DataIsObject
2159
2160
2160 except (NameError,SyntaxError):
2161 except (NameError,SyntaxError):
2161 # given argument is not a variable, try as a filename
2162 # given argument is not a variable, try as a filename
2162 filename = make_filename(args)
2163 filename = make_filename(args)
2163 if filename is None:
2164 if filename is None:
2164 warn("Argument given (%s) can't be found as a variable "
2165 warn("Argument given (%s) can't be found as a variable "
2165 "or as a filename." % args)
2166 "or as a filename." % args)
2166 return
2167 return
2167
2168
2168 data = ''
2169 data = ''
2169 use_temp = 0
2170 use_temp = 0
2170 except DataIsObject:
2171 except DataIsObject:
2171
2172
2172 # macros have a special edit function
2173 # macros have a special edit function
2173 if isinstance(data,Macro):
2174 if isinstance(data,Macro):
2174 self._edit_macro(args,data)
2175 self._edit_macro(args,data)
2175 return
2176 return
2176
2177
2177 # For objects, try to edit the file where they are defined
2178 # For objects, try to edit the file where they are defined
2178 try:
2179 try:
2179 filename = inspect.getabsfile(data)
2180 filename = inspect.getabsfile(data)
2180 datafile = 1
2181 datafile = 1
2181 except TypeError:
2182 except TypeError:
2182 filename = make_filename(args)
2183 filename = make_filename(args)
2183 datafile = 1
2184 datafile = 1
2184 warn('Could not find file where `%s` is defined.\n'
2185 warn('Could not find file where `%s` is defined.\n'
2185 'Opening a file named `%s`' % (args,filename))
2186 'Opening a file named `%s`' % (args,filename))
2186 # Now, make sure we can actually read the source (if it was in
2187 # Now, make sure we can actually read the source (if it was in
2187 # a temp file it's gone by now).
2188 # a temp file it's gone by now).
2188 if datafile:
2189 if datafile:
2189 try:
2190 try:
2190 if lineno is None:
2191 if lineno is None:
2191 lineno = inspect.getsourcelines(data)[1]
2192 lineno = inspect.getsourcelines(data)[1]
2192 except IOError:
2193 except IOError:
2193 filename = make_filename(args)
2194 filename = make_filename(args)
2194 if filename is None:
2195 if filename is None:
2195 warn('The file `%s` where `%s` was defined cannot '
2196 warn('The file `%s` where `%s` was defined cannot '
2196 'be read.' % (filename,data))
2197 'be read.' % (filename,data))
2197 return
2198 return
2198 use_temp = 0
2199 use_temp = 0
2199 else:
2200 else:
2200 data = ''
2201 data = ''
2201
2202
2202 if use_temp:
2203 if use_temp:
2203 filename = self.shell.mktempfile(data)
2204 filename = self.shell.mktempfile(data)
2204 print 'IPython will make a temporary file named:',filename
2205 print 'IPython will make a temporary file named:',filename
2205
2206
2206 # do actual editing here
2207 # do actual editing here
2207 print 'Editing...',
2208 print 'Editing...',
2208 sys.stdout.flush()
2209 sys.stdout.flush()
2209 self.shell.hooks.editor(filename,lineno)
2210 self.shell.hooks.editor(filename,lineno)
2210 if opts.has_key('x'): # -x prevents actual execution
2211 if opts.has_key('x'): # -x prevents actual execution
2211 print
2212 print
2212 else:
2213 else:
2213 print 'done. Executing edited code...'
2214 print 'done. Executing edited code...'
2214 if opts_r:
2215 if opts_r:
2215 self.shell.runlines(file_read(filename))
2216 self.shell.runlines(file_read(filename))
2216 else:
2217 else:
2217 self.shell.safe_execfile(filename,self.shell.user_ns)
2218 self.shell.safe_execfile(filename,self.shell.user_ns)
2218 if use_temp:
2219 if use_temp:
2219 try:
2220 try:
2220 return open(filename).read()
2221 return open(filename).read()
2221 except IOError,msg:
2222 except IOError,msg:
2222 if msg.filename == filename:
2223 if msg.filename == filename:
2223 warn('File not found. Did you forget to save?')
2224 warn('File not found. Did you forget to save?')
2224 return
2225 return
2225 else:
2226 else:
2226 self.shell.showtraceback()
2227 self.shell.showtraceback()
2227
2228
2228 def magic_xmode(self,parameter_s = ''):
2229 def magic_xmode(self,parameter_s = ''):
2229 """Switch modes for the exception handlers.
2230 """Switch modes for the exception handlers.
2230
2231
2231 Valid modes: Plain, Context and Verbose.
2232 Valid modes: Plain, Context and Verbose.
2232
2233
2233 If called without arguments, acts as a toggle."""
2234 If called without arguments, acts as a toggle."""
2234
2235
2235 def xmode_switch_err(name):
2236 def xmode_switch_err(name):
2236 warn('Error changing %s exception modes.\n%s' %
2237 warn('Error changing %s exception modes.\n%s' %
2237 (name,sys.exc_info()[1]))
2238 (name,sys.exc_info()[1]))
2238
2239
2239 shell = self.shell
2240 shell = self.shell
2240 new_mode = parameter_s.strip().capitalize()
2241 new_mode = parameter_s.strip().capitalize()
2241 try:
2242 try:
2242 shell.InteractiveTB.set_mode(mode=new_mode)
2243 shell.InteractiveTB.set_mode(mode=new_mode)
2243 print 'Exception reporting mode:',shell.InteractiveTB.mode
2244 print 'Exception reporting mode:',shell.InteractiveTB.mode
2244 except:
2245 except:
2245 xmode_switch_err('user')
2246 xmode_switch_err('user')
2246
2247
2247 # threaded shells use a special handler in sys.excepthook
2248 # threaded shells use a special handler in sys.excepthook
2248 if shell.isthreaded:
2249 if shell.isthreaded:
2249 try:
2250 try:
2250 shell.sys_excepthook.set_mode(mode=new_mode)
2251 shell.sys_excepthook.set_mode(mode=new_mode)
2251 except:
2252 except:
2252 xmode_switch_err('threaded')
2253 xmode_switch_err('threaded')
2253
2254
2254 def magic_colors(self,parameter_s = ''):
2255 def magic_colors(self,parameter_s = ''):
2255 """Switch color scheme for prompts, info system and exception handlers.
2256 """Switch color scheme for prompts, info system and exception handlers.
2256
2257
2257 Currently implemented schemes: NoColor, Linux, LightBG.
2258 Currently implemented schemes: NoColor, Linux, LightBG.
2258
2259
2259 Color scheme names are not case-sensitive."""
2260 Color scheme names are not case-sensitive."""
2260
2261
2261 def color_switch_err(name):
2262 def color_switch_err(name):
2262 warn('Error changing %s color schemes.\n%s' %
2263 warn('Error changing %s color schemes.\n%s' %
2263 (name,sys.exc_info()[1]))
2264 (name,sys.exc_info()[1]))
2264
2265
2265
2266
2266 new_scheme = parameter_s.strip()
2267 new_scheme = parameter_s.strip()
2267 if not new_scheme:
2268 if not new_scheme:
2268 print 'You must specify a color scheme.'
2269 print 'You must specify a color scheme.'
2269 return
2270 return
2270 import IPython.rlineimpl as readline
2271 import IPython.rlineimpl as readline
2271 if not readline.have_readline:
2272 if not readline.have_readline:
2272 msg = """\
2273 msg = """\
2273 Proper color support under MS Windows requires the pyreadline library.
2274 Proper color support under MS Windows requires the pyreadline library.
2274 You can find it at:
2275 You can find it at:
2275 http://ipython.scipy.org/moin/PyReadline/Intro
2276 http://ipython.scipy.org/moin/PyReadline/Intro
2276 Gary's readline needs the ctypes module, from:
2277 Gary's readline needs the ctypes module, from:
2277 http://starship.python.net/crew/theller/ctypes
2278 http://starship.python.net/crew/theller/ctypes
2278 (Note that ctypes is already part of Python versions 2.5 and newer).
2279 (Note that ctypes is already part of Python versions 2.5 and newer).
2279
2280
2280 Defaulting color scheme to 'NoColor'"""
2281 Defaulting color scheme to 'NoColor'"""
2281 new_scheme = 'NoColor'
2282 new_scheme = 'NoColor'
2282 warn(msg)
2283 warn(msg)
2283 # local shortcut
2284 # local shortcut
2284 shell = self.shell
2285 shell = self.shell
2285
2286
2286 # Set prompt colors
2287 # Set prompt colors
2287 try:
2288 try:
2288 shell.outputcache.set_colors(new_scheme)
2289 shell.outputcache.set_colors(new_scheme)
2289 except:
2290 except:
2290 color_switch_err('prompt')
2291 color_switch_err('prompt')
2291 else:
2292 else:
2292 shell.rc.colors = \
2293 shell.rc.colors = \
2293 shell.outputcache.color_table.active_scheme_name
2294 shell.outputcache.color_table.active_scheme_name
2294 # Set exception colors
2295 # Set exception colors
2295 try:
2296 try:
2296 shell.InteractiveTB.set_colors(scheme = new_scheme)
2297 shell.InteractiveTB.set_colors(scheme = new_scheme)
2297 shell.SyntaxTB.set_colors(scheme = new_scheme)
2298 shell.SyntaxTB.set_colors(scheme = new_scheme)
2298 except:
2299 except:
2299 color_switch_err('exception')
2300 color_switch_err('exception')
2300
2301
2301 # threaded shells use a verbose traceback in sys.excepthook
2302 # threaded shells use a verbose traceback in sys.excepthook
2302 if shell.isthreaded:
2303 if shell.isthreaded:
2303 try:
2304 try:
2304 shell.sys_excepthook.set_colors(scheme=new_scheme)
2305 shell.sys_excepthook.set_colors(scheme=new_scheme)
2305 except:
2306 except:
2306 color_switch_err('system exception handler')
2307 color_switch_err('system exception handler')
2307
2308
2308 # Set info (for 'object?') colors
2309 # Set info (for 'object?') colors
2309 if shell.rc.color_info:
2310 if shell.rc.color_info:
2310 try:
2311 try:
2311 shell.inspector.set_active_scheme(new_scheme)
2312 shell.inspector.set_active_scheme(new_scheme)
2312 except:
2313 except:
2313 color_switch_err('object inspector')
2314 color_switch_err('object inspector')
2314 else:
2315 else:
2315 shell.inspector.set_active_scheme('NoColor')
2316 shell.inspector.set_active_scheme('NoColor')
2316
2317
2317 def magic_color_info(self,parameter_s = ''):
2318 def magic_color_info(self,parameter_s = ''):
2318 """Toggle color_info.
2319 """Toggle color_info.
2319
2320
2320 The color_info configuration parameter controls whether colors are
2321 The color_info configuration parameter controls whether colors are
2321 used for displaying object details (by things like %psource, %pfile or
2322 used for displaying object details (by things like %psource, %pfile or
2322 the '?' system). This function toggles this value with each call.
2323 the '?' system). This function toggles this value with each call.
2323
2324
2324 Note that unless you have a fairly recent pager (less works better
2325 Note that unless you have a fairly recent pager (less works better
2325 than more) in your system, using colored object information displays
2326 than more) in your system, using colored object information displays
2326 will not work properly. Test it and see."""
2327 will not work properly. Test it and see."""
2327
2328
2328 self.shell.rc.color_info = 1 - self.shell.rc.color_info
2329 self.shell.rc.color_info = 1 - self.shell.rc.color_info
2329 self.magic_colors(self.shell.rc.colors)
2330 self.magic_colors(self.shell.rc.colors)
2330 print 'Object introspection functions have now coloring:',
2331 print 'Object introspection functions have now coloring:',
2331 print ['OFF','ON'][self.shell.rc.color_info]
2332 print ['OFF','ON'][self.shell.rc.color_info]
2332
2333
2333 def magic_Pprint(self, parameter_s=''):
2334 def magic_Pprint(self, parameter_s=''):
2334 """Toggle pretty printing on/off."""
2335 """Toggle pretty printing on/off."""
2335
2336
2336 self.shell.rc.pprint = 1 - self.shell.rc.pprint
2337 self.shell.rc.pprint = 1 - self.shell.rc.pprint
2337 print 'Pretty printing has been turned', \
2338 print 'Pretty printing has been turned', \
2338 ['OFF','ON'][self.shell.rc.pprint]
2339 ['OFF','ON'][self.shell.rc.pprint]
2339
2340
2340 def magic_exit(self, parameter_s=''):
2341 def magic_exit(self, parameter_s=''):
2341 """Exit IPython, confirming if configured to do so.
2342 """Exit IPython, confirming if configured to do so.
2342
2343
2343 You can configure whether IPython asks for confirmation upon exit by
2344 You can configure whether IPython asks for confirmation upon exit by
2344 setting the confirm_exit flag in the ipythonrc file."""
2345 setting the confirm_exit flag in the ipythonrc file."""
2345
2346
2346 self.shell.exit()
2347 self.shell.exit()
2347
2348
2348 def magic_quit(self, parameter_s=''):
2349 def magic_quit(self, parameter_s=''):
2349 """Exit IPython, confirming if configured to do so (like %exit)"""
2350 """Exit IPython, confirming if configured to do so (like %exit)"""
2350
2351
2351 self.shell.exit()
2352 self.shell.exit()
2352
2353
2353 def magic_Exit(self, parameter_s=''):
2354 def magic_Exit(self, parameter_s=''):
2354 """Exit IPython without confirmation."""
2355 """Exit IPython without confirmation."""
2355
2356
2356 self.shell.exit_now = True
2357 self.shell.exit_now = True
2357
2358
2358 def magic_Quit(self, parameter_s=''):
2359 def magic_Quit(self, parameter_s=''):
2359 """Exit IPython without confirmation (like %Exit)."""
2360 """Exit IPython without confirmation (like %Exit)."""
2360
2361
2361 self.shell.exit_now = True
2362 self.shell.exit_now = True
2362
2363
2363 #......................................................................
2364 #......................................................................
2364 # Functions to implement unix shell-type things
2365 # Functions to implement unix shell-type things
2365
2366
2366 def magic_alias(self, parameter_s = ''):
2367 def magic_alias(self, parameter_s = ''):
2367 """Define an alias for a system command.
2368 """Define an alias for a system command.
2368
2369
2369 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2370 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2370
2371
2371 Then, typing 'alias_name params' will execute the system command 'cmd
2372 Then, typing 'alias_name params' will execute the system command 'cmd
2372 params' (from your underlying operating system).
2373 params' (from your underlying operating system).
2373
2374
2374 Aliases have lower precedence than magic functions and Python normal
2375 Aliases have lower precedence than magic functions and Python normal
2375 variables, so if 'foo' is both a Python variable and an alias, the
2376 variables, so if 'foo' is both a Python variable and an alias, the
2376 alias can not be executed until 'del foo' removes the Python variable.
2377 alias can not be executed until 'del foo' removes the Python variable.
2377
2378
2378 You can use the %l specifier in an alias definition to represent the
2379 You can use the %l specifier in an alias definition to represent the
2379 whole line when the alias is called. For example:
2380 whole line when the alias is called. For example:
2380
2381
2381 In [2]: alias all echo "Input in brackets: <%l>"\\
2382 In [2]: alias all echo "Input in brackets: <%l>"\\
2382 In [3]: all hello world\\
2383 In [3]: all hello world\\
2383 Input in brackets: <hello world>
2384 Input in brackets: <hello world>
2384
2385
2385 You can also define aliases with parameters using %s specifiers (one
2386 You can also define aliases with parameters using %s specifiers (one
2386 per parameter):
2387 per parameter):
2387
2388
2388 In [1]: alias parts echo first %s second %s\\
2389 In [1]: alias parts echo first %s second %s\\
2389 In [2]: %parts A B\\
2390 In [2]: %parts A B\\
2390 first A second B\\
2391 first A second B\\
2391 In [3]: %parts A\\
2392 In [3]: %parts A\\
2392 Incorrect number of arguments: 2 expected.\\
2393 Incorrect number of arguments: 2 expected.\\
2393 parts is an alias to: 'echo first %s second %s'
2394 parts is an alias to: 'echo first %s second %s'
2394
2395
2395 Note that %l and %s are mutually exclusive. You can only use one or
2396 Note that %l and %s are mutually exclusive. You can only use one or
2396 the other in your aliases.
2397 the other in your aliases.
2397
2398
2398 Aliases expand Python variables just like system calls using ! or !!
2399 Aliases expand Python variables just like system calls using ! or !!
2399 do: all expressions prefixed with '$' get expanded. For details of
2400 do: all expressions prefixed with '$' get expanded. For details of
2400 the semantic rules, see PEP-215:
2401 the semantic rules, see PEP-215:
2401 http://www.python.org/peps/pep-0215.html. This is the library used by
2402 http://www.python.org/peps/pep-0215.html. This is the library used by
2402 IPython for variable expansion. If you want to access a true shell
2403 IPython for variable expansion. If you want to access a true shell
2403 variable, an extra $ is necessary to prevent its expansion by IPython:
2404 variable, an extra $ is necessary to prevent its expansion by IPython:
2404
2405
2405 In [6]: alias show echo\\
2406 In [6]: alias show echo\\
2406 In [7]: PATH='A Python string'\\
2407 In [7]: PATH='A Python string'\\
2407 In [8]: show $PATH\\
2408 In [8]: show $PATH\\
2408 A Python string\\
2409 A Python string\\
2409 In [9]: show $$PATH\\
2410 In [9]: show $$PATH\\
2410 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2411 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2411
2412
2412 You can use the alias facility to acess all of $PATH. See the %rehash
2413 You can use the alias facility to acess all of $PATH. See the %rehash
2413 and %rehashx functions, which automatically create aliases for the
2414 and %rehashx functions, which automatically create aliases for the
2414 contents of your $PATH.
2415 contents of your $PATH.
2415
2416
2416 If called with no parameters, %alias prints the current alias table."""
2417 If called with no parameters, %alias prints the current alias table."""
2417
2418
2418 par = parameter_s.strip()
2419 par = parameter_s.strip()
2419 if not par:
2420 if not par:
2420 stored = self.db.get('stored_aliases', {} )
2421 stored = self.db.get('stored_aliases', {} )
2421 atab = self.shell.alias_table
2422 atab = self.shell.alias_table
2422 aliases = atab.keys()
2423 aliases = atab.keys()
2423 aliases.sort()
2424 aliases.sort()
2424 res = []
2425 res = []
2425 showlast = []
2426 showlast = []
2426 for alias in aliases:
2427 for alias in aliases:
2427 tgt = atab[alias][1]
2428 tgt = atab[alias][1]
2428 # 'interesting' aliases
2429 # 'interesting' aliases
2429 if (alias in stored or
2430 if (alias in stored or
2430 alias != os.path.splitext(tgt)[0] or
2431 alias != os.path.splitext(tgt)[0] or
2431 ' ' in tgt):
2432 ' ' in tgt):
2432 showlast.append((alias, tgt))
2433 showlast.append((alias, tgt))
2433 else:
2434 else:
2434 res.append((alias, tgt ))
2435 res.append((alias, tgt ))
2435
2436
2436 # show most interesting aliases last
2437 # show most interesting aliases last
2437 res.extend(showlast)
2438 res.extend(showlast)
2438 print "Total number of aliases:",len(aliases)
2439 print "Total number of aliases:",len(aliases)
2439 return res
2440 return res
2440 try:
2441 try:
2441 alias,cmd = par.split(None,1)
2442 alias,cmd = par.split(None,1)
2442 except:
2443 except:
2443 print OInspect.getdoc(self.magic_alias)
2444 print OInspect.getdoc(self.magic_alias)
2444 else:
2445 else:
2445 nargs = cmd.count('%s')
2446 nargs = cmd.count('%s')
2446 if nargs>0 and cmd.find('%l')>=0:
2447 if nargs>0 and cmd.find('%l')>=0:
2447 error('The %s and %l specifiers are mutually exclusive '
2448 error('The %s and %l specifiers are mutually exclusive '
2448 'in alias definitions.')
2449 'in alias definitions.')
2449 else: # all looks OK
2450 else: # all looks OK
2450 self.shell.alias_table[alias] = (nargs,cmd)
2451 self.shell.alias_table[alias] = (nargs,cmd)
2451 self.shell.alias_table_validate(verbose=0)
2452 self.shell.alias_table_validate(verbose=0)
2452 # end magic_alias
2453 # end magic_alias
2453
2454
2454 def magic_unalias(self, parameter_s = ''):
2455 def magic_unalias(self, parameter_s = ''):
2455 """Remove an alias"""
2456 """Remove an alias"""
2456
2457
2457 aname = parameter_s.strip()
2458 aname = parameter_s.strip()
2458 if aname in self.shell.alias_table:
2459 if aname in self.shell.alias_table:
2459 del self.shell.alias_table[aname]
2460 del self.shell.alias_table[aname]
2460 stored = self.db.get('stored_aliases', {} )
2461 stored = self.db.get('stored_aliases', {} )
2461 if aname in stored:
2462 if aname in stored:
2462 print "Removing %stored alias",aname
2463 print "Removing %stored alias",aname
2463 del stored[aname]
2464 del stored[aname]
2464 self.db['stored_aliases'] = stored
2465 self.db['stored_aliases'] = stored
2465
2466
2466 def magic_rehash(self, parameter_s = ''):
2467 def magic_rehash(self, parameter_s = ''):
2467 """Update the alias table with all entries in $PATH.
2468 """Update the alias table with all entries in $PATH.
2468
2469
2469 This version does no checks on execute permissions or whether the
2470 This version does no checks on execute permissions or whether the
2470 contents of $PATH are truly files (instead of directories or something
2471 contents of $PATH are truly files (instead of directories or something
2471 else). For such a safer (but slower) version, use %rehashx."""
2472 else). For such a safer (but slower) version, use %rehashx."""
2472
2473
2473 # This function (and rehashx) manipulate the alias_table directly
2474 # This function (and rehashx) manipulate the alias_table directly
2474 # rather than calling magic_alias, for speed reasons. A rehash on a
2475 # rather than calling magic_alias, for speed reasons. A rehash on a
2475 # typical Linux box involves several thousand entries, so efficiency
2476 # typical Linux box involves several thousand entries, so efficiency
2476 # here is a top concern.
2477 # here is a top concern.
2477
2478
2478 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2479 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2479 alias_table = self.shell.alias_table
2480 alias_table = self.shell.alias_table
2480 for pdir in path:
2481 for pdir in path:
2481 for ff in os.listdir(pdir):
2482 for ff in os.listdir(pdir):
2482 # each entry in the alias table must be (N,name), where
2483 # each entry in the alias table must be (N,name), where
2483 # N is the number of positional arguments of the alias.
2484 # N is the number of positional arguments of the alias.
2484 alias_table[ff] = (0,ff)
2485 alias_table[ff] = (0,ff)
2485 # Make sure the alias table doesn't contain keywords or builtins
2486 # Make sure the alias table doesn't contain keywords or builtins
2486 self.shell.alias_table_validate()
2487 self.shell.alias_table_validate()
2487 # Call again init_auto_alias() so we get 'rm -i' and other modified
2488 # Call again init_auto_alias() so we get 'rm -i' and other modified
2488 # aliases since %rehash will probably clobber them
2489 # aliases since %rehash will probably clobber them
2489 self.shell.init_auto_alias()
2490 self.shell.init_auto_alias()
2490
2491
2491 def magic_rehashx(self, parameter_s = ''):
2492 def magic_rehashx(self, parameter_s = ''):
2492 """Update the alias table with all executable files in $PATH.
2493 """Update the alias table with all executable files in $PATH.
2493
2494
2494 This version explicitly checks that every entry in $PATH is a file
2495 This version explicitly checks that every entry in $PATH is a file
2495 with execute access (os.X_OK), so it is much slower than %rehash.
2496 with execute access (os.X_OK), so it is much slower than %rehash.
2496
2497
2497 Under Windows, it checks executability as a match agains a
2498 Under Windows, it checks executability as a match agains a
2498 '|'-separated string of extensions, stored in the IPython config
2499 '|'-separated string of extensions, stored in the IPython config
2499 variable win_exec_ext. This defaults to 'exe|com|bat'. """
2500 variable win_exec_ext. This defaults to 'exe|com|bat'. """
2500
2501
2501 path = [os.path.abspath(os.path.expanduser(p)) for p in
2502 path = [os.path.abspath(os.path.expanduser(p)) for p in
2502 os.environ['PATH'].split(os.pathsep)]
2503 os.environ['PATH'].split(os.pathsep)]
2503 path = filter(os.path.isdir,path)
2504 path = filter(os.path.isdir,path)
2504
2505
2505 alias_table = self.shell.alias_table
2506 alias_table = self.shell.alias_table
2506 syscmdlist = []
2507 syscmdlist = []
2507 if os.name == 'posix':
2508 if os.name == 'posix':
2508 isexec = lambda fname:os.path.isfile(fname) and \
2509 isexec = lambda fname:os.path.isfile(fname) and \
2509 os.access(fname,os.X_OK)
2510 os.access(fname,os.X_OK)
2510 else:
2511 else:
2511
2512
2512 try:
2513 try:
2513 winext = os.environ['pathext'].replace(';','|').replace('.','')
2514 winext = os.environ['pathext'].replace(';','|').replace('.','')
2514 except KeyError:
2515 except KeyError:
2515 winext = 'exe|com|bat|py'
2516 winext = 'exe|com|bat|py'
2516 if 'py' not in winext:
2517 if 'py' not in winext:
2517 winext += '|py'
2518 winext += '|py'
2518 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2519 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2519 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2520 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2520 savedir = os.getcwd()
2521 savedir = os.getcwd()
2521 try:
2522 try:
2522 # write the whole loop for posix/Windows so we don't have an if in
2523 # write the whole loop for posix/Windows so we don't have an if in
2523 # the innermost part
2524 # the innermost part
2524 if os.name == 'posix':
2525 if os.name == 'posix':
2525 for pdir in path:
2526 for pdir in path:
2526 os.chdir(pdir)
2527 os.chdir(pdir)
2527 for ff in os.listdir(pdir):
2528 for ff in os.listdir(pdir):
2528 if isexec(ff) and ff not in self.shell.no_alias:
2529 if isexec(ff) and ff not in self.shell.no_alias:
2529 # each entry in the alias table must be (N,name),
2530 # each entry in the alias table must be (N,name),
2530 # where N is the number of positional arguments of the
2531 # where N is the number of positional arguments of the
2531 # alias.
2532 # alias.
2532 alias_table[ff] = (0,ff)
2533 alias_table[ff] = (0,ff)
2533 syscmdlist.append(ff)
2534 syscmdlist.append(ff)
2534 else:
2535 else:
2535 for pdir in path:
2536 for pdir in path:
2536 os.chdir(pdir)
2537 os.chdir(pdir)
2537 for ff in os.listdir(pdir):
2538 for ff in os.listdir(pdir):
2538 base, ext = os.path.splitext(ff)
2539 base, ext = os.path.splitext(ff)
2539 if isexec(ff) and base not in self.shell.no_alias:
2540 if isexec(ff) and base not in self.shell.no_alias:
2540 if ext.lower() == '.exe':
2541 if ext.lower() == '.exe':
2541 ff = base
2542 ff = base
2542 alias_table[base] = (0,ff)
2543 alias_table[base] = (0,ff)
2543 syscmdlist.append(ff)
2544 syscmdlist.append(ff)
2544 # Make sure the alias table doesn't contain keywords or builtins
2545 # Make sure the alias table doesn't contain keywords or builtins
2545 self.shell.alias_table_validate()
2546 self.shell.alias_table_validate()
2546 # Call again init_auto_alias() so we get 'rm -i' and other
2547 # Call again init_auto_alias() so we get 'rm -i' and other
2547 # modified aliases since %rehashx will probably clobber them
2548 # modified aliases since %rehashx will probably clobber them
2548 self.shell.init_auto_alias()
2549 self.shell.init_auto_alias()
2549 db = self.getapi().db
2550 db = self.getapi().db
2550 db['syscmdlist'] = syscmdlist
2551 db['syscmdlist'] = syscmdlist
2551 finally:
2552 finally:
2552 os.chdir(savedir)
2553 os.chdir(savedir)
2553
2554
2554 def magic_pwd(self, parameter_s = ''):
2555 def magic_pwd(self, parameter_s = ''):
2555 """Return the current working directory path."""
2556 """Return the current working directory path."""
2556 return os.getcwd()
2557 return os.getcwd()
2557
2558
2558 def magic_cd(self, parameter_s=''):
2559 def magic_cd(self, parameter_s=''):
2559 """Change the current working directory.
2560 """Change the current working directory.
2560
2561
2561 This command automatically maintains an internal list of directories
2562 This command automatically maintains an internal list of directories
2562 you visit during your IPython session, in the variable _dh. The
2563 you visit during your IPython session, in the variable _dh. The
2563 command %dhist shows this history nicely formatted. You can also
2564 command %dhist shows this history nicely formatted. You can also
2564 do 'cd -<tab>' to see directory history conveniently.
2565 do 'cd -<tab>' to see directory history conveniently.
2565
2566
2566 Usage:
2567 Usage:
2567
2568
2568 cd 'dir': changes to directory 'dir'.
2569 cd 'dir': changes to directory 'dir'.
2569
2570
2570 cd -: changes to the last visited directory.
2571 cd -: changes to the last visited directory.
2571
2572
2572 cd -<n>: changes to the n-th directory in the directory history.
2573 cd -<n>: changes to the n-th directory in the directory history.
2573
2574
2574 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2575 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2575 (note: cd <bookmark_name> is enough if there is no
2576 (note: cd <bookmark_name> is enough if there is no
2576 directory <bookmark_name>, but a bookmark with the name exists.)
2577 directory <bookmark_name>, but a bookmark with the name exists.)
2577 'cd -b <tab>' allows you to tab-complete bookmark names.
2578 'cd -b <tab>' allows you to tab-complete bookmark names.
2578
2579
2579 Options:
2580 Options:
2580
2581
2581 -q: quiet. Do not print the working directory after the cd command is
2582 -q: quiet. Do not print the working directory after the cd command is
2582 executed. By default IPython's cd command does print this directory,
2583 executed. By default IPython's cd command does print this directory,
2583 since the default prompts do not display path information.
2584 since the default prompts do not display path information.
2584
2585
2585 Note that !cd doesn't work for this purpose because the shell where
2586 Note that !cd doesn't work for this purpose because the shell where
2586 !command runs is immediately discarded after executing 'command'."""
2587 !command runs is immediately discarded after executing 'command'."""
2587
2588
2588 parameter_s = parameter_s.strip()
2589 parameter_s = parameter_s.strip()
2589 #bkms = self.shell.persist.get("bookmarks",{})
2590 #bkms = self.shell.persist.get("bookmarks",{})
2590
2591
2591 numcd = re.match(r'(-)(\d+)$',parameter_s)
2592 numcd = re.match(r'(-)(\d+)$',parameter_s)
2592 # jump in directory history by number
2593 # jump in directory history by number
2593 if numcd:
2594 if numcd:
2594 nn = int(numcd.group(2))
2595 nn = int(numcd.group(2))
2595 try:
2596 try:
2596 ps = self.shell.user_ns['_dh'][nn]
2597 ps = self.shell.user_ns['_dh'][nn]
2597 except IndexError:
2598 except IndexError:
2598 print 'The requested directory does not exist in history.'
2599 print 'The requested directory does not exist in history.'
2599 return
2600 return
2600 else:
2601 else:
2601 opts = {}
2602 opts = {}
2602 else:
2603 else:
2603 #turn all non-space-escaping backslashes to slashes,
2604 #turn all non-space-escaping backslashes to slashes,
2604 # for c:\windows\directory\names\
2605 # for c:\windows\directory\names\
2605 parameter_s = re.sub(r'\\(?! )','/', parameter_s)
2606 parameter_s = re.sub(r'\\(?! )','/', parameter_s)
2606 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2607 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2607 # jump to previous
2608 # jump to previous
2608 if ps == '-':
2609 if ps == '-':
2609 try:
2610 try:
2610 ps = self.shell.user_ns['_dh'][-2]
2611 ps = self.shell.user_ns['_dh'][-2]
2611 except IndexError:
2612 except IndexError:
2612 print 'No previous directory to change to.'
2613 print 'No previous directory to change to.'
2613 return
2614 return
2614 # jump to bookmark if needed
2615 # jump to bookmark if needed
2615 else:
2616 else:
2616 if not os.path.isdir(ps) or opts.has_key('b'):
2617 if not os.path.isdir(ps) or opts.has_key('b'):
2617 bkms = self.db.get('bookmarks', {})
2618 bkms = self.db.get('bookmarks', {})
2618
2619
2619 if bkms.has_key(ps):
2620 if bkms.has_key(ps):
2620 target = bkms[ps]
2621 target = bkms[ps]
2621 print '(bookmark:%s) -> %s' % (ps,target)
2622 print '(bookmark:%s) -> %s' % (ps,target)
2622 ps = target
2623 ps = target
2623 else:
2624 else:
2624 if opts.has_key('b'):
2625 if opts.has_key('b'):
2625 error("Bookmark '%s' not found. "
2626 error("Bookmark '%s' not found. "
2626 "Use '%%bookmark -l' to see your bookmarks." % ps)
2627 "Use '%%bookmark -l' to see your bookmarks." % ps)
2627 return
2628 return
2628
2629
2629 # at this point ps should point to the target dir
2630 # at this point ps should point to the target dir
2630 if ps:
2631 if ps:
2631 try:
2632 try:
2632 os.chdir(os.path.expanduser(ps))
2633 os.chdir(os.path.expanduser(ps))
2633 if self.shell.rc.term_title:
2634 if self.shell.rc.term_title:
2634 #print 'set term title:',self.shell.rc.term_title # dbg
2635 #print 'set term title:',self.shell.rc.term_title # dbg
2635 ttitle = ("IPy:" + (
2636 ttitle = ("IPy:" + (
2636 os.getcwd() == '/' and '/' or \
2637 os.getcwd() == '/' and '/' or \
2637 os.path.basename(os.getcwd())))
2638 os.path.basename(os.getcwd())))
2638 platutils.set_term_title(ttitle)
2639 platutils.set_term_title(ttitle)
2639 except OSError:
2640 except OSError:
2640 print sys.exc_info()[1]
2641 print sys.exc_info()[1]
2641 else:
2642 else:
2642 self.shell.user_ns['_dh'].append(os.getcwd())
2643 self.shell.user_ns['_dh'].append(os.getcwd())
2643 else:
2644 else:
2644 os.chdir(self.shell.home_dir)
2645 os.chdir(self.shell.home_dir)
2645 if self.shell.rc.term_title:
2646 if self.shell.rc.term_title:
2646 platutils.set_term_title("IPy:~")
2647 platutils.set_term_title("IPy:~")
2647 self.shell.user_ns['_dh'].append(os.getcwd())
2648 self.shell.user_ns['_dh'].append(os.getcwd())
2648 if not 'q' in opts:
2649 if not 'q' in opts:
2649 print self.shell.user_ns['_dh'][-1]
2650 print self.shell.user_ns['_dh'][-1]
2650
2651
2651 def magic_dhist(self, parameter_s=''):
2652 def magic_dhist(self, parameter_s=''):
2652 """Print your history of visited directories.
2653 """Print your history of visited directories.
2653
2654
2654 %dhist -> print full history\\
2655 %dhist -> print full history\\
2655 %dhist n -> print last n entries only\\
2656 %dhist n -> print last n entries only\\
2656 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2657 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2657
2658
2658 This history is automatically maintained by the %cd command, and
2659 This history is automatically maintained by the %cd command, and
2659 always available as the global list variable _dh. You can use %cd -<n>
2660 always available as the global list variable _dh. You can use %cd -<n>
2660 to go to directory number <n>."""
2661 to go to directory number <n>."""
2661
2662
2662 dh = self.shell.user_ns['_dh']
2663 dh = self.shell.user_ns['_dh']
2663 if parameter_s:
2664 if parameter_s:
2664 try:
2665 try:
2665 args = map(int,parameter_s.split())
2666 args = map(int,parameter_s.split())
2666 except:
2667 except:
2667 self.arg_err(Magic.magic_dhist)
2668 self.arg_err(Magic.magic_dhist)
2668 return
2669 return
2669 if len(args) == 1:
2670 if len(args) == 1:
2670 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2671 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2671 elif len(args) == 2:
2672 elif len(args) == 2:
2672 ini,fin = args
2673 ini,fin = args
2673 else:
2674 else:
2674 self.arg_err(Magic.magic_dhist)
2675 self.arg_err(Magic.magic_dhist)
2675 return
2676 return
2676 else:
2677 else:
2677 ini,fin = 0,len(dh)
2678 ini,fin = 0,len(dh)
2678 nlprint(dh,
2679 nlprint(dh,
2679 header = 'Directory history (kept in _dh)',
2680 header = 'Directory history (kept in _dh)',
2680 start=ini,stop=fin)
2681 start=ini,stop=fin)
2681
2682
2682 def magic_env(self, parameter_s=''):
2683 def magic_env(self, parameter_s=''):
2683 """List environment variables."""
2684 """List environment variables."""
2684
2685
2685 return os.environ.data
2686 return os.environ.data
2686
2687
2687 def magic_pushd(self, parameter_s=''):
2688 def magic_pushd(self, parameter_s=''):
2688 """Place the current dir on stack and change directory.
2689 """Place the current dir on stack and change directory.
2689
2690
2690 Usage:\\
2691 Usage:\\
2691 %pushd ['dirname']
2692 %pushd ['dirname']
2692
2693
2693 %pushd with no arguments does a %pushd to your home directory.
2694 %pushd with no arguments does a %pushd to your home directory.
2694 """
2695 """
2695 if parameter_s == '': parameter_s = '~'
2696 if parameter_s == '': parameter_s = '~'
2696 dir_s = self.shell.dir_stack
2697 dir_s = self.shell.dir_stack
2697 if len(dir_s)>0 and os.path.expanduser(parameter_s) != \
2698 if len(dir_s)>0 and os.path.expanduser(parameter_s) != \
2698 os.path.expanduser(self.shell.dir_stack[0]):
2699 os.path.expanduser(self.shell.dir_stack[0]):
2699 try:
2700 try:
2700 self.magic_cd(parameter_s)
2701 self.magic_cd(parameter_s)
2701 dir_s.insert(0,os.getcwd().replace(self.home_dir,'~'))
2702 dir_s.insert(0,os.getcwd().replace(self.home_dir,'~'))
2702 self.magic_dirs()
2703 self.magic_dirs()
2703 except:
2704 except:
2704 print 'Invalid directory'
2705 print 'Invalid directory'
2705 else:
2706 else:
2706 print 'You are already there!'
2707 print 'You are already there!'
2707
2708
2708 def magic_popd(self, parameter_s=''):
2709 def magic_popd(self, parameter_s=''):
2709 """Change to directory popped off the top of the stack.
2710 """Change to directory popped off the top of the stack.
2710 """
2711 """
2711 if len (self.shell.dir_stack) > 1:
2712 if len (self.shell.dir_stack) > 1:
2712 self.shell.dir_stack.pop(0)
2713 self.shell.dir_stack.pop(0)
2713 self.magic_cd(self.shell.dir_stack[0])
2714 self.magic_cd(self.shell.dir_stack[0])
2714 print self.shell.dir_stack[0]
2715 print self.shell.dir_stack[0]
2715 else:
2716 else:
2716 print "You can't remove the starting directory from the stack:",\
2717 print "You can't remove the starting directory from the stack:",\
2717 self.shell.dir_stack
2718 self.shell.dir_stack
2718
2719
2719 def magic_dirs(self, parameter_s=''):
2720 def magic_dirs(self, parameter_s=''):
2720 """Return the current directory stack."""
2721 """Return the current directory stack."""
2721
2722
2722 return self.shell.dir_stack[:]
2723 return self.shell.dir_stack[:]
2723
2724
2724 def magic_sc(self, parameter_s=''):
2725 def magic_sc(self, parameter_s=''):
2725 """Shell capture - execute a shell command and capture its output.
2726 """Shell capture - execute a shell command and capture its output.
2726
2727
2727 DEPRECATED. Suboptimal, retained for backwards compatibility.
2728 DEPRECATED. Suboptimal, retained for backwards compatibility.
2728
2729
2729 You should use the form 'var = !command' instead. Example:
2730 You should use the form 'var = !command' instead. Example:
2730
2731
2731 "%sc -l myfiles = ls ~" should now be written as
2732 "%sc -l myfiles = ls ~" should now be written as
2732
2733
2733 "myfiles = !ls ~"
2734 "myfiles = !ls ~"
2734
2735
2735 myfiles.s, myfiles.l and myfiles.n still apply as documented
2736 myfiles.s, myfiles.l and myfiles.n still apply as documented
2736 below.
2737 below.
2737
2738
2738 --
2739 --
2739 %sc [options] varname=command
2740 %sc [options] varname=command
2740
2741
2741 IPython will run the given command using commands.getoutput(), and
2742 IPython will run the given command using commands.getoutput(), and
2742 will then update the user's interactive namespace with a variable
2743 will then update the user's interactive namespace with a variable
2743 called varname, containing the value of the call. Your command can
2744 called varname, containing the value of the call. Your command can
2744 contain shell wildcards, pipes, etc.
2745 contain shell wildcards, pipes, etc.
2745
2746
2746 The '=' sign in the syntax is mandatory, and the variable name you
2747 The '=' sign in the syntax is mandatory, and the variable name you
2747 supply must follow Python's standard conventions for valid names.
2748 supply must follow Python's standard conventions for valid names.
2748
2749
2749 (A special format without variable name exists for internal use)
2750 (A special format without variable name exists for internal use)
2750
2751
2751 Options:
2752 Options:
2752
2753
2753 -l: list output. Split the output on newlines into a list before
2754 -l: list output. Split the output on newlines into a list before
2754 assigning it to the given variable. By default the output is stored
2755 assigning it to the given variable. By default the output is stored
2755 as a single string.
2756 as a single string.
2756
2757
2757 -v: verbose. Print the contents of the variable.
2758 -v: verbose. Print the contents of the variable.
2758
2759
2759 In most cases you should not need to split as a list, because the
2760 In most cases you should not need to split as a list, because the
2760 returned value is a special type of string which can automatically
2761 returned value is a special type of string which can automatically
2761 provide its contents either as a list (split on newlines) or as a
2762 provide its contents either as a list (split on newlines) or as a
2762 space-separated string. These are convenient, respectively, either
2763 space-separated string. These are convenient, respectively, either
2763 for sequential processing or to be passed to a shell command.
2764 for sequential processing or to be passed to a shell command.
2764
2765
2765 For example:
2766 For example:
2766
2767
2767 # Capture into variable a
2768 # Capture into variable a
2768 In [9]: sc a=ls *py
2769 In [9]: sc a=ls *py
2769
2770
2770 # a is a string with embedded newlines
2771 # a is a string with embedded newlines
2771 In [10]: a
2772 In [10]: a
2772 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2773 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2773
2774
2774 # which can be seen as a list:
2775 # which can be seen as a list:
2775 In [11]: a.l
2776 In [11]: a.l
2776 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2777 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2777
2778
2778 # or as a whitespace-separated string:
2779 # or as a whitespace-separated string:
2779 In [12]: a.s
2780 In [12]: a.s
2780 Out[12]: 'setup.py win32_manual_post_install.py'
2781 Out[12]: 'setup.py win32_manual_post_install.py'
2781
2782
2782 # a.s is useful to pass as a single command line:
2783 # a.s is useful to pass as a single command line:
2783 In [13]: !wc -l $a.s
2784 In [13]: !wc -l $a.s
2784 146 setup.py
2785 146 setup.py
2785 130 win32_manual_post_install.py
2786 130 win32_manual_post_install.py
2786 276 total
2787 276 total
2787
2788
2788 # while the list form is useful to loop over:
2789 # while the list form is useful to loop over:
2789 In [14]: for f in a.l:
2790 In [14]: for f in a.l:
2790 ....: !wc -l $f
2791 ....: !wc -l $f
2791 ....:
2792 ....:
2792 146 setup.py
2793 146 setup.py
2793 130 win32_manual_post_install.py
2794 130 win32_manual_post_install.py
2794
2795
2795 Similiarly, the lists returned by the -l option are also special, in
2796 Similiarly, the lists returned by the -l option are also special, in
2796 the sense that you can equally invoke the .s attribute on them to
2797 the sense that you can equally invoke the .s attribute on them to
2797 automatically get a whitespace-separated string from their contents:
2798 automatically get a whitespace-separated string from their contents:
2798
2799
2799 In [1]: sc -l b=ls *py
2800 In [1]: sc -l b=ls *py
2800
2801
2801 In [2]: b
2802 In [2]: b
2802 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2803 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2803
2804
2804 In [3]: b.s
2805 In [3]: b.s
2805 Out[3]: 'setup.py win32_manual_post_install.py'
2806 Out[3]: 'setup.py win32_manual_post_install.py'
2806
2807
2807 In summary, both the lists and strings used for ouptut capture have
2808 In summary, both the lists and strings used for ouptut capture have
2808 the following special attributes:
2809 the following special attributes:
2809
2810
2810 .l (or .list) : value as list.
2811 .l (or .list) : value as list.
2811 .n (or .nlstr): value as newline-separated string.
2812 .n (or .nlstr): value as newline-separated string.
2812 .s (or .spstr): value as space-separated string.
2813 .s (or .spstr): value as space-separated string.
2813 """
2814 """
2814
2815
2815 opts,args = self.parse_options(parameter_s,'lv')
2816 opts,args = self.parse_options(parameter_s,'lv')
2816 # Try to get a variable name and command to run
2817 # Try to get a variable name and command to run
2817 try:
2818 try:
2818 # the variable name must be obtained from the parse_options
2819 # the variable name must be obtained from the parse_options
2819 # output, which uses shlex.split to strip options out.
2820 # output, which uses shlex.split to strip options out.
2820 var,_ = args.split('=',1)
2821 var,_ = args.split('=',1)
2821 var = var.strip()
2822 var = var.strip()
2822 # But the the command has to be extracted from the original input
2823 # But the the command has to be extracted from the original input
2823 # parameter_s, not on what parse_options returns, to avoid the
2824 # parameter_s, not on what parse_options returns, to avoid the
2824 # quote stripping which shlex.split performs on it.
2825 # quote stripping which shlex.split performs on it.
2825 _,cmd = parameter_s.split('=',1)
2826 _,cmd = parameter_s.split('=',1)
2826 except ValueError:
2827 except ValueError:
2827 var,cmd = '',''
2828 var,cmd = '',''
2828 # If all looks ok, proceed
2829 # If all looks ok, proceed
2829 out,err = self.shell.getoutputerror(cmd)
2830 out,err = self.shell.getoutputerror(cmd)
2830 if err:
2831 if err:
2831 print >> Term.cerr,err
2832 print >> Term.cerr,err
2832 if opts.has_key('l'):
2833 if opts.has_key('l'):
2833 out = SList(out.split('\n'))
2834 out = SList(out.split('\n'))
2834 else:
2835 else:
2835 out = LSString(out)
2836 out = LSString(out)
2836 if opts.has_key('v'):
2837 if opts.has_key('v'):
2837 print '%s ==\n%s' % (var,pformat(out))
2838 print '%s ==\n%s' % (var,pformat(out))
2838 if var:
2839 if var:
2839 self.shell.user_ns.update({var:out})
2840 self.shell.user_ns.update({var:out})
2840 else:
2841 else:
2841 return out
2842 return out
2842
2843
2843 def magic_sx(self, parameter_s=''):
2844 def magic_sx(self, parameter_s=''):
2844 """Shell execute - run a shell command and capture its output.
2845 """Shell execute - run a shell command and capture its output.
2845
2846
2846 %sx command
2847 %sx command
2847
2848
2848 IPython will run the given command using commands.getoutput(), and
2849 IPython will run the given command using commands.getoutput(), and
2849 return the result formatted as a list (split on '\\n'). Since the
2850 return the result formatted as a list (split on '\\n'). Since the
2850 output is _returned_, it will be stored in ipython's regular output
2851 output is _returned_, it will be stored in ipython's regular output
2851 cache Out[N] and in the '_N' automatic variables.
2852 cache Out[N] and in the '_N' automatic variables.
2852
2853
2853 Notes:
2854 Notes:
2854
2855
2855 1) If an input line begins with '!!', then %sx is automatically
2856 1) If an input line begins with '!!', then %sx is automatically
2856 invoked. That is, while:
2857 invoked. That is, while:
2857 !ls
2858 !ls
2858 causes ipython to simply issue system('ls'), typing
2859 causes ipython to simply issue system('ls'), typing
2859 !!ls
2860 !!ls
2860 is a shorthand equivalent to:
2861 is a shorthand equivalent to:
2861 %sx ls
2862 %sx ls
2862
2863
2863 2) %sx differs from %sc in that %sx automatically splits into a list,
2864 2) %sx differs from %sc in that %sx automatically splits into a list,
2864 like '%sc -l'. The reason for this is to make it as easy as possible
2865 like '%sc -l'. The reason for this is to make it as easy as possible
2865 to process line-oriented shell output via further python commands.
2866 to process line-oriented shell output via further python commands.
2866 %sc is meant to provide much finer control, but requires more
2867 %sc is meant to provide much finer control, but requires more
2867 typing.
2868 typing.
2868
2869
2869 3) Just like %sc -l, this is a list with special attributes:
2870 3) Just like %sc -l, this is a list with special attributes:
2870
2871
2871 .l (or .list) : value as list.
2872 .l (or .list) : value as list.
2872 .n (or .nlstr): value as newline-separated string.
2873 .n (or .nlstr): value as newline-separated string.
2873 .s (or .spstr): value as whitespace-separated string.
2874 .s (or .spstr): value as whitespace-separated string.
2874
2875
2875 This is very useful when trying to use such lists as arguments to
2876 This is very useful when trying to use such lists as arguments to
2876 system commands."""
2877 system commands."""
2877
2878
2878 if parameter_s:
2879 if parameter_s:
2879 out,err = self.shell.getoutputerror(parameter_s)
2880 out,err = self.shell.getoutputerror(parameter_s)
2880 if err:
2881 if err:
2881 print >> Term.cerr,err
2882 print >> Term.cerr,err
2882 return SList(out.split('\n'))
2883 return SList(out.split('\n'))
2883
2884
2884 def magic_bg(self, parameter_s=''):
2885 def magic_bg(self, parameter_s=''):
2885 """Run a job in the background, in a separate thread.
2886 """Run a job in the background, in a separate thread.
2886
2887
2887 For example,
2888 For example,
2888
2889
2889 %bg myfunc(x,y,z=1)
2890 %bg myfunc(x,y,z=1)
2890
2891
2891 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2892 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2892 execution starts, a message will be printed indicating the job
2893 execution starts, a message will be printed indicating the job
2893 number. If your job number is 5, you can use
2894 number. If your job number is 5, you can use
2894
2895
2895 myvar = jobs.result(5) or myvar = jobs[5].result
2896 myvar = jobs.result(5) or myvar = jobs[5].result
2896
2897
2897 to assign this result to variable 'myvar'.
2898 to assign this result to variable 'myvar'.
2898
2899
2899 IPython has a job manager, accessible via the 'jobs' object. You can
2900 IPython has a job manager, accessible via the 'jobs' object. You can
2900 type jobs? to get more information about it, and use jobs.<TAB> to see
2901 type jobs? to get more information about it, and use jobs.<TAB> to see
2901 its attributes. All attributes not starting with an underscore are
2902 its attributes. All attributes not starting with an underscore are
2902 meant for public use.
2903 meant for public use.
2903
2904
2904 In particular, look at the jobs.new() method, which is used to create
2905 In particular, look at the jobs.new() method, which is used to create
2905 new jobs. This magic %bg function is just a convenience wrapper
2906 new jobs. This magic %bg function is just a convenience wrapper
2906 around jobs.new(), for expression-based jobs. If you want to create a
2907 around jobs.new(), for expression-based jobs. If you want to create a
2907 new job with an explicit function object and arguments, you must call
2908 new job with an explicit function object and arguments, you must call
2908 jobs.new() directly.
2909 jobs.new() directly.
2909
2910
2910 The jobs.new docstring also describes in detail several important
2911 The jobs.new docstring also describes in detail several important
2911 caveats associated with a thread-based model for background job
2912 caveats associated with a thread-based model for background job
2912 execution. Type jobs.new? for details.
2913 execution. Type jobs.new? for details.
2913
2914
2914 You can check the status of all jobs with jobs.status().
2915 You can check the status of all jobs with jobs.status().
2915
2916
2916 The jobs variable is set by IPython into the Python builtin namespace.
2917 The jobs variable is set by IPython into the Python builtin namespace.
2917 If you ever declare a variable named 'jobs', you will shadow this
2918 If you ever declare a variable named 'jobs', you will shadow this
2918 name. You can either delete your global jobs variable to regain
2919 name. You can either delete your global jobs variable to regain
2919 access to the job manager, or make a new name and assign it manually
2920 access to the job manager, or make a new name and assign it manually
2920 to the manager (stored in IPython's namespace). For example, to
2921 to the manager (stored in IPython's namespace). For example, to
2921 assign the job manager to the Jobs name, use:
2922 assign the job manager to the Jobs name, use:
2922
2923
2923 Jobs = __builtins__.jobs"""
2924 Jobs = __builtins__.jobs"""
2924
2925
2925 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2926 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2926
2927
2927
2928
2928 def magic_bookmark(self, parameter_s=''):
2929 def magic_bookmark(self, parameter_s=''):
2929 """Manage IPython's bookmark system.
2930 """Manage IPython's bookmark system.
2930
2931
2931 %bookmark <name> - set bookmark to current dir
2932 %bookmark <name> - set bookmark to current dir
2932 %bookmark <name> <dir> - set bookmark to <dir>
2933 %bookmark <name> <dir> - set bookmark to <dir>
2933 %bookmark -l - list all bookmarks
2934 %bookmark -l - list all bookmarks
2934 %bookmark -d <name> - remove bookmark
2935 %bookmark -d <name> - remove bookmark
2935 %bookmark -r - remove all bookmarks
2936 %bookmark -r - remove all bookmarks
2936
2937
2937 You can later on access a bookmarked folder with:
2938 You can later on access a bookmarked folder with:
2938 %cd -b <name>
2939 %cd -b <name>
2939 or simply '%cd <name>' if there is no directory called <name> AND
2940 or simply '%cd <name>' if there is no directory called <name> AND
2940 there is such a bookmark defined.
2941 there is such a bookmark defined.
2941
2942
2942 Your bookmarks persist through IPython sessions, but they are
2943 Your bookmarks persist through IPython sessions, but they are
2943 associated with each profile."""
2944 associated with each profile."""
2944
2945
2945 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2946 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2946 if len(args) > 2:
2947 if len(args) > 2:
2947 error('You can only give at most two arguments')
2948 error('You can only give at most two arguments')
2948 return
2949 return
2949
2950
2950 bkms = self.db.get('bookmarks',{})
2951 bkms = self.db.get('bookmarks',{})
2951
2952
2952 if opts.has_key('d'):
2953 if opts.has_key('d'):
2953 try:
2954 try:
2954 todel = args[0]
2955 todel = args[0]
2955 except IndexError:
2956 except IndexError:
2956 error('You must provide a bookmark to delete')
2957 error('You must provide a bookmark to delete')
2957 else:
2958 else:
2958 try:
2959 try:
2959 del bkms[todel]
2960 del bkms[todel]
2960 except:
2961 except:
2961 error("Can't delete bookmark '%s'" % todel)
2962 error("Can't delete bookmark '%s'" % todel)
2962 elif opts.has_key('r'):
2963 elif opts.has_key('r'):
2963 bkms = {}
2964 bkms = {}
2964 elif opts.has_key('l'):
2965 elif opts.has_key('l'):
2965 bks = bkms.keys()
2966 bks = bkms.keys()
2966 bks.sort()
2967 bks.sort()
2967 if bks:
2968 if bks:
2968 size = max(map(len,bks))
2969 size = max(map(len,bks))
2969 else:
2970 else:
2970 size = 0
2971 size = 0
2971 fmt = '%-'+str(size)+'s -> %s'
2972 fmt = '%-'+str(size)+'s -> %s'
2972 print 'Current bookmarks:'
2973 print 'Current bookmarks:'
2973 for bk in bks:
2974 for bk in bks:
2974 print fmt % (bk,bkms[bk])
2975 print fmt % (bk,bkms[bk])
2975 else:
2976 else:
2976 if not args:
2977 if not args:
2977 error("You must specify the bookmark name")
2978 error("You must specify the bookmark name")
2978 elif len(args)==1:
2979 elif len(args)==1:
2979 bkms[args[0]] = os.getcwd()
2980 bkms[args[0]] = os.getcwd()
2980 elif len(args)==2:
2981 elif len(args)==2:
2981 bkms[args[0]] = args[1]
2982 bkms[args[0]] = args[1]
2982 self.db['bookmarks'] = bkms
2983 self.db['bookmarks'] = bkms
2983
2984
2984 def magic_pycat(self, parameter_s=''):
2985 def magic_pycat(self, parameter_s=''):
2985 """Show a syntax-highlighted file through a pager.
2986 """Show a syntax-highlighted file through a pager.
2986
2987
2987 This magic is similar to the cat utility, but it will assume the file
2988 This magic is similar to the cat utility, but it will assume the file
2988 to be Python source and will show it with syntax highlighting. """
2989 to be Python source and will show it with syntax highlighting. """
2989
2990
2990 try:
2991 try:
2991 filename = get_py_filename(parameter_s)
2992 filename = get_py_filename(parameter_s)
2992 cont = file_read(filename)
2993 cont = file_read(filename)
2993 except IOError:
2994 except IOError:
2994 try:
2995 try:
2995 cont = eval(parameter_s,self.user_ns)
2996 cont = eval(parameter_s,self.user_ns)
2996 except NameError:
2997 except NameError:
2997 cont = None
2998 cont = None
2998 if cont is None:
2999 if cont is None:
2999 print "Error: no such file or variable"
3000 print "Error: no such file or variable"
3000 return
3001 return
3001
3002
3002 page(self.shell.pycolorize(cont),
3003 page(self.shell.pycolorize(cont),
3003 screen_lines=self.shell.rc.screen_length)
3004 screen_lines=self.shell.rc.screen_length)
3004
3005
3005 def magic_cpaste(self, parameter_s=''):
3006 def magic_cpaste(self, parameter_s=''):
3006 """Allows you to paste & execute a pre-formatted code block from clipboard
3007 """Allows you to paste & execute a pre-formatted code block from clipboard
3007
3008
3008 You must terminate the block with '--' (two minus-signs) alone on the
3009 You must terminate the block with '--' (two minus-signs) alone on the
3009 line. You can also provide your own sentinel with '%paste -s %%' ('%%'
3010 line. You can also provide your own sentinel with '%paste -s %%' ('%%'
3010 is the new sentinel for this operation)
3011 is the new sentinel for this operation)
3011
3012
3012 The block is dedented prior to execution to enable execution of
3013 The block is dedented prior to execution to enable execution of
3013 method definitions. '>' characters at the beginning of a line is
3014 method definitions. '>' characters at the beginning of a line is
3014 ignored, to allow pasting directly from e-mails. The executed block
3015 ignored, to allow pasting directly from e-mails. The executed block
3015 is also assigned to variable named 'pasted_block' for later editing
3016 is also assigned to variable named 'pasted_block' for later editing
3016 with '%edit pasted_block'.
3017 with '%edit pasted_block'.
3017
3018
3018 You can also pass a variable name as an argument, e.g. '%cpaste foo'.
3019 You can also pass a variable name as an argument, e.g. '%cpaste foo'.
3019 This assigns the pasted block to variable 'foo' as string, without
3020 This assigns the pasted block to variable 'foo' as string, without
3020 dedenting or executing it.
3021 dedenting or executing it.
3021
3022
3022 Do not be alarmed by garbled output on Windows (it's a readline bug).
3023 Do not be alarmed by garbled output on Windows (it's a readline bug).
3023 Just press enter and type -- (and press enter again) and the block
3024 Just press enter and type -- (and press enter again) and the block
3024 will be what was just pasted.
3025 will be what was just pasted.
3025
3026
3026 IPython statements (magics, shell escapes) are not supported (yet).
3027 IPython statements (magics, shell escapes) are not supported (yet).
3027 """
3028 """
3028 opts,args = self.parse_options(parameter_s,'s:',mode='string')
3029 opts,args = self.parse_options(parameter_s,'s:',mode='string')
3029 par = args.strip()
3030 par = args.strip()
3030 sentinel = opts.get('s','--')
3031 sentinel = opts.get('s','--')
3031
3032
3032 from IPython import iplib
3033 from IPython import iplib
3033 lines = []
3034 lines = []
3034 print "Pasting code; enter '%s' alone on the line to stop." % sentinel
3035 print "Pasting code; enter '%s' alone on the line to stop." % sentinel
3035 while 1:
3036 while 1:
3036 l = iplib.raw_input_original(':')
3037 l = iplib.raw_input_original(':')
3037 if l ==sentinel:
3038 if l ==sentinel:
3038 break
3039 break
3039 lines.append(l.lstrip('>'))
3040 lines.append(l.lstrip('>'))
3040 block = "\n".join(lines) + '\n'
3041 block = "\n".join(lines) + '\n'
3041 #print "block:\n",block
3042 #print "block:\n",block
3042 if not par:
3043 if not par:
3043 b = textwrap.dedent(block)
3044 b = textwrap.dedent(block)
3044 exec b in self.user_ns
3045 exec b in self.user_ns
3045 self.user_ns['pasted_block'] = b
3046 self.user_ns['pasted_block'] = b
3046 else:
3047 else:
3047 self.user_ns[par] = block
3048 self.user_ns[par] = block
3048 print "Block assigned to '%s'" % par
3049 print "Block assigned to '%s'" % par
3049
3050
3050 def magic_quickref(self,arg):
3051 def magic_quickref(self,arg):
3051 """ Show a quick reference sheet """
3052 """ Show a quick reference sheet """
3052 import IPython.usage
3053 import IPython.usage
3053 qr = IPython.usage.quick_reference + self.magic_magic('-brief')
3054 qr = IPython.usage.quick_reference + self.magic_magic('-brief')
3054
3055
3055 page(qr)
3056 page(qr)
3056
3057
3057 def magic_upgrade(self,arg):
3058 def magic_upgrade(self,arg):
3058 """ Upgrade your IPython installation
3059 """ Upgrade your IPython installation
3059
3060
3060 This will copy the config files that don't yet exist in your
3061 This will copy the config files that don't yet exist in your
3061 ipython dir from the system config dir. Use this after upgrading
3062 ipython dir from the system config dir. Use this after upgrading
3062 IPython if you don't wish to delete your .ipython dir.
3063 IPython if you don't wish to delete your .ipython dir.
3063
3064
3064 Call with -nolegacy to get rid of ipythonrc* files (recommended for
3065 Call with -nolegacy to get rid of ipythonrc* files (recommended for
3065 new users)
3066 new users)
3066
3067
3067 """
3068 """
3068 ip = self.getapi()
3069 ip = self.getapi()
3069 ipinstallation = path(IPython.__file__).dirname()
3070 ipinstallation = path(IPython.__file__).dirname()
3070 upgrade_script = '%s "%s"' % (sys.executable,ipinstallation / 'upgrade_dir.py')
3071 upgrade_script = '%s "%s"' % (sys.executable,ipinstallation / 'upgrade_dir.py')
3071 src_config = ipinstallation / 'UserConfig'
3072 src_config = ipinstallation / 'UserConfig'
3072 userdir = path(ip.options.ipythondir)
3073 userdir = path(ip.options.ipythondir)
3073 cmd = '%s "%s" "%s"' % (upgrade_script, src_config, userdir)
3074 cmd = '%s "%s" "%s"' % (upgrade_script, src_config, userdir)
3074 print ">",cmd
3075 print ">",cmd
3075 shell(cmd)
3076 shell(cmd)
3076 if arg == '-nolegacy':
3077 if arg == '-nolegacy':
3077 legacy = userdir.files('ipythonrc*')
3078 legacy = userdir.files('ipythonrc*')
3078 print "Nuking legacy files:",legacy
3079 print "Nuking legacy files:",legacy
3079
3080
3080 [p.remove() for p in legacy]
3081 [p.remove() for p in legacy]
3081 suffix = (sys.platform == 'win32' and '.ini' or '')
3082 suffix = (sys.platform == 'win32' and '.ini' or '')
3082 (userdir / ('ipythonrc' + suffix)).write_text('# Empty, see ipy_user_conf.py\n')
3083 (userdir / ('ipythonrc' + suffix)).write_text('# Empty, see ipy_user_conf.py\n')
3083
3084
3084 # end Magic
3085 # end Magic
@@ -1,2542 +1,2548 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 2014 2007-01-05 10:36:58Z fperez $
9 $Id: iplib.py 2122 2007-03-01 02:27:11Z fperez $
10 """
10 """
11
11
12 #*****************************************************************************
12 #*****************************************************************************
13 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
13 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
14 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
14 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
15 #
15 #
16 # Distributed under the terms of the BSD License. The full license is in
16 # Distributed under the terms of the BSD License. The full license is in
17 # the file COPYING, distributed as part of this software.
17 # the file COPYING, distributed as part of this software.
18 #
18 #
19 # Note: this code originally subclassed code.InteractiveConsole from the
19 # Note: this code originally subclassed code.InteractiveConsole from the
20 # Python standard library. Over time, all of that class has been copied
20 # Python standard library. Over time, all of that class has been copied
21 # verbatim here for modifications which could not be accomplished by
21 # verbatim here for modifications which could not be accomplished by
22 # subclassing. At this point, there are no dependencies at all on the code
22 # subclassing. At this point, there are no dependencies at all on the code
23 # module anymore (it is not even imported). The Python License (sec. 2)
23 # module anymore (it is not even imported). The Python License (sec. 2)
24 # allows for this, but it's always nice to acknowledge credit where credit is
24 # allows for this, but it's always nice to acknowledge credit where credit is
25 # due.
25 # due.
26 #*****************************************************************************
26 #*****************************************************************************
27
27
28 #****************************************************************************
28 #****************************************************************************
29 # Modules and globals
29 # Modules and globals
30
30
31 from IPython import Release
31 from IPython import Release
32 __author__ = '%s <%s>\n%s <%s>' % \
32 __author__ = '%s <%s>\n%s <%s>' % \
33 ( Release.authors['Janko'] + Release.authors['Fernando'] )
33 ( Release.authors['Janko'] + Release.authors['Fernando'] )
34 __license__ = Release.license
34 __license__ = Release.license
35 __version__ = Release.version
35 __version__ = Release.version
36
36
37 # Python standard modules
37 # Python standard modules
38 import __main__
38 import __main__
39 import __builtin__
39 import __builtin__
40 import StringIO
40 import StringIO
41 import bdb
41 import bdb
42 import cPickle as pickle
42 import cPickle as pickle
43 import codeop
43 import codeop
44 import exceptions
44 import exceptions
45 import glob
45 import glob
46 import inspect
46 import inspect
47 import keyword
47 import keyword
48 import new
48 import new
49 import os
49 import os
50 import pydoc
50 import pydoc
51 import re
51 import re
52 import shutil
52 import shutil
53 import string
53 import string
54 import sys
54 import sys
55 import tempfile
55 import tempfile
56 import traceback
56 import traceback
57 import types
57 import types
58 import pickleshare
58 import pickleshare
59 from sets import Set
59 from sets import Set
60 from pprint import pprint, pformat
60 from pprint import pprint, pformat
61
61
62 # IPython's own modules
62 # IPython's own modules
63 import IPython
63 import IPython
64 from IPython import OInspect,PyColorize,ultraTB
64 from IPython import OInspect,PyColorize,ultraTB
65 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
65 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
66 from IPython.FakeModule import FakeModule
66 from IPython.FakeModule import FakeModule
67 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
67 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
68 from IPython.Logger import Logger
68 from IPython.Logger import Logger
69 from IPython.Magic import Magic
69 from IPython.Magic import Magic
70 from IPython.Prompts import CachedOutput
70 from IPython.Prompts import CachedOutput
71 from IPython.ipstruct import Struct
71 from IPython.ipstruct import Struct
72 from IPython.background_jobs import BackgroundJobManager
72 from IPython.background_jobs import BackgroundJobManager
73 from IPython.usage import cmd_line_usage,interactive_usage
73 from IPython.usage import cmd_line_usage,interactive_usage
74 from IPython.genutils import *
74 from IPython.genutils import *
75 from IPython.strdispatch import StrDispatch
75 from IPython.strdispatch import StrDispatch
76 import IPython.ipapi
76 import IPython.ipapi
77
77
78 # Globals
78 # Globals
79
79
80 # store the builtin raw_input globally, and use this always, in case user code
80 # store the builtin raw_input globally, and use this always, in case user code
81 # overwrites it (like wx.py.PyShell does)
81 # overwrites it (like wx.py.PyShell does)
82 raw_input_original = raw_input
82 raw_input_original = raw_input
83
83
84 # compiled regexps for autoindent management
84 # compiled regexps for autoindent management
85 dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass')
85 dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass')
86
86
87
87
88 #****************************************************************************
88 #****************************************************************************
89 # Some utility function definitions
89 # Some utility function definitions
90
90
91 ini_spaces_re = re.compile(r'^(\s+)')
91 ini_spaces_re = re.compile(r'^(\s+)')
92
92
93 def num_ini_spaces(strng):
93 def num_ini_spaces(strng):
94 """Return the number of initial spaces in a string"""
94 """Return the number of initial spaces in a string"""
95
95
96 ini_spaces = ini_spaces_re.match(strng)
96 ini_spaces = ini_spaces_re.match(strng)
97 if ini_spaces:
97 if ini_spaces:
98 return ini_spaces.end()
98 return ini_spaces.end()
99 else:
99 else:
100 return 0
100 return 0
101
101
102 def softspace(file, newvalue):
102 def softspace(file, newvalue):
103 """Copied from code.py, to remove the dependency"""
103 """Copied from code.py, to remove the dependency"""
104
104
105 oldvalue = 0
105 oldvalue = 0
106 try:
106 try:
107 oldvalue = file.softspace
107 oldvalue = file.softspace
108 except AttributeError:
108 except AttributeError:
109 pass
109 pass
110 try:
110 try:
111 file.softspace = newvalue
111 file.softspace = newvalue
112 except (AttributeError, TypeError):
112 except (AttributeError, TypeError):
113 # "attribute-less object" or "read-only attributes"
113 # "attribute-less object" or "read-only attributes"
114 pass
114 pass
115 return oldvalue
115 return oldvalue
116
116
117
117
118 #****************************************************************************
118 #****************************************************************************
119 # Local use exceptions
119 # Local use exceptions
120 class SpaceInInput(exceptions.Exception): pass
120 class SpaceInInput(exceptions.Exception): pass
121
121
122
122
123 #****************************************************************************
123 #****************************************************************************
124 # Local use classes
124 # Local use classes
125 class Bunch: pass
125 class Bunch: pass
126
126
127 class Undefined: pass
127 class Undefined: pass
128
128
129 class Quitter(object):
129 class Quitter(object):
130 """Simple class to handle exit, similar to Python 2.5's.
130 """Simple class to handle exit, similar to Python 2.5's.
131
131
132 It handles exiting in an ipython-safe manner, which the one in Python 2.5
132 It handles exiting in an ipython-safe manner, which the one in Python 2.5
133 doesn't do (obviously, since it doesn't know about ipython)."""
133 doesn't do (obviously, since it doesn't know about ipython)."""
134
134
135 def __init__(self,shell,name):
135 def __init__(self,shell,name):
136 self.shell = shell
136 self.shell = shell
137 self.name = name
137 self.name = name
138
138
139 def __repr__(self):
139 def __repr__(self):
140 return 'Type %s() to exit.' % self.name
140 return 'Type %s() to exit.' % self.name
141 __str__ = __repr__
141 __str__ = __repr__
142
142
143 def __call__(self):
143 def __call__(self):
144 self.shell.exit()
144 self.shell.exit()
145
145
146 class InputList(list):
146 class InputList(list):
147 """Class to store user input.
147 """Class to store user input.
148
148
149 It's basically a list, but slices return a string instead of a list, thus
149 It's basically a list, but slices return a string instead of a list, thus
150 allowing things like (assuming 'In' is an instance):
150 allowing things like (assuming 'In' is an instance):
151
151
152 exec In[4:7]
152 exec In[4:7]
153
153
154 or
154 or
155
155
156 exec In[5:9] + In[14] + In[21:25]"""
156 exec In[5:9] + In[14] + In[21:25]"""
157
157
158 def __getslice__(self,i,j):
158 def __getslice__(self,i,j):
159 return ''.join(list.__getslice__(self,i,j))
159 return ''.join(list.__getslice__(self,i,j))
160
160
161 class SyntaxTB(ultraTB.ListTB):
161 class SyntaxTB(ultraTB.ListTB):
162 """Extension which holds some state: the last exception value"""
162 """Extension which holds some state: the last exception value"""
163
163
164 def __init__(self,color_scheme = 'NoColor'):
164 def __init__(self,color_scheme = 'NoColor'):
165 ultraTB.ListTB.__init__(self,color_scheme)
165 ultraTB.ListTB.__init__(self,color_scheme)
166 self.last_syntax_error = None
166 self.last_syntax_error = None
167
167
168 def __call__(self, etype, value, elist):
168 def __call__(self, etype, value, elist):
169 self.last_syntax_error = value
169 self.last_syntax_error = value
170 ultraTB.ListTB.__call__(self,etype,value,elist)
170 ultraTB.ListTB.__call__(self,etype,value,elist)
171
171
172 def clear_err_state(self):
172 def clear_err_state(self):
173 """Return the current error state and clear it"""
173 """Return the current error state and clear it"""
174 e = self.last_syntax_error
174 e = self.last_syntax_error
175 self.last_syntax_error = None
175 self.last_syntax_error = None
176 return e
176 return e
177
177
178 #****************************************************************************
178 #****************************************************************************
179 # Main IPython class
179 # Main IPython class
180
180
181 # FIXME: the Magic class is a mixin for now, and will unfortunately remain so
181 # FIXME: the Magic class is a mixin for now, and will unfortunately remain so
182 # until a full rewrite is made. I've cleaned all cross-class uses of
182 # until a full rewrite is made. I've cleaned all cross-class uses of
183 # attributes and methods, but too much user code out there relies on the
183 # attributes and methods, but too much user code out there relies on the
184 # equlity %foo == __IP.magic_foo, so I can't actually remove the mixin usage.
184 # equlity %foo == __IP.magic_foo, so I can't actually remove the mixin usage.
185 #
185 #
186 # But at least now, all the pieces have been separated and we could, in
186 # But at least now, all the pieces have been separated and we could, in
187 # principle, stop using the mixin. This will ease the transition to the
187 # principle, stop using the mixin. This will ease the transition to the
188 # chainsaw branch.
188 # chainsaw branch.
189
189
190 # For reference, the following is the list of 'self.foo' uses in the Magic
190 # For reference, the following is the list of 'self.foo' uses in the Magic
191 # class as of 2005-12-28. These are names we CAN'T use in the main ipython
191 # class as of 2005-12-28. These are names we CAN'T use in the main ipython
192 # class, to prevent clashes.
192 # class, to prevent clashes.
193
193
194 # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind',
194 # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind',
195 # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic',
195 # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic',
196 # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell',
196 # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell',
197 # 'self.value']
197 # 'self.value']
198
198
199 class InteractiveShell(object,Magic):
199 class InteractiveShell(object,Magic):
200 """An enhanced console for Python."""
200 """An enhanced console for Python."""
201
201
202 # class attribute to indicate whether the class supports threads or not.
202 # class attribute to indicate whether the class supports threads or not.
203 # Subclasses with thread support should override this as needed.
203 # Subclasses with thread support should override this as needed.
204 isthreaded = False
204 isthreaded = False
205
205
206 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
206 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
207 user_ns = None,user_global_ns=None,banner2='',
207 user_ns = None,user_global_ns=None,banner2='',
208 custom_exceptions=((),None),embedded=False):
208 custom_exceptions=((),None),embedded=False):
209
209
210 # log system
210 # log system
211 self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate')
211 self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate')
212
212
213 # some minimal strict typechecks. For some core data structures, I
213 # some minimal strict typechecks. For some core data structures, I
214 # want actual basic python types, not just anything that looks like
214 # want actual basic python types, not just anything that looks like
215 # one. This is especially true for namespaces.
215 # one. This is especially true for namespaces.
216 for ns in (user_ns,user_global_ns):
216 for ns in (user_ns,user_global_ns):
217 if ns is not None and type(ns) != types.DictType:
217 if ns is not None and type(ns) != types.DictType:
218 raise TypeError,'namespace must be a dictionary'
218 raise TypeError,'namespace must be a dictionary'
219
219
220 # Job manager (for jobs run as background threads)
220 # Job manager (for jobs run as background threads)
221 self.jobs = BackgroundJobManager()
221 self.jobs = BackgroundJobManager()
222
222
223 # Store the actual shell's name
223 # Store the actual shell's name
224 self.name = name
224 self.name = name
225
225
226 # We need to know whether the instance is meant for embedding, since
226 # We need to know whether the instance is meant for embedding, since
227 # global/local namespaces need to be handled differently in that case
227 # global/local namespaces need to be handled differently in that case
228 self.embedded = embedded
228 self.embedded = embedded
229
229
230 # command compiler
230 # command compiler
231 self.compile = codeop.CommandCompiler()
231 self.compile = codeop.CommandCompiler()
232
232
233 # User input buffer
233 # User input buffer
234 self.buffer = []
234 self.buffer = []
235
235
236 # Default name given in compilation of code
236 # Default name given in compilation of code
237 self.filename = '<ipython console>'
237 self.filename = '<ipython console>'
238
238
239 # Install our own quitter instead of the builtins. For python2.3-2.4,
239 # Install our own quitter instead of the builtins. For python2.3-2.4,
240 # this brings in behavior like 2.5, and for 2.5 it's identical.
240 # this brings in behavior like 2.5, and for 2.5 it's identical.
241 __builtin__.exit = Quitter(self,'exit')
241 __builtin__.exit = Quitter(self,'exit')
242 __builtin__.quit = Quitter(self,'quit')
242 __builtin__.quit = Quitter(self,'quit')
243
243
244 # Make an empty namespace, which extension writers can rely on both
244 # Make an empty namespace, which extension writers can rely on both
245 # existing and NEVER being used by ipython itself. This gives them a
245 # existing and NEVER being used by ipython itself. This gives them a
246 # convenient location for storing additional information and state
246 # convenient location for storing additional information and state
247 # their extensions may require, without fear of collisions with other
247 # their extensions may require, without fear of collisions with other
248 # ipython names that may develop later.
248 # ipython names that may develop later.
249 self.meta = Struct()
249 self.meta = Struct()
250
250
251 # Create the namespace where the user will operate. user_ns is
251 # Create the namespace where the user will operate. user_ns is
252 # normally the only one used, and it is passed to the exec calls as
252 # normally the only one used, and it is passed to the exec calls as
253 # the locals argument. But we do carry a user_global_ns namespace
253 # the locals argument. But we do carry a user_global_ns namespace
254 # given as the exec 'globals' argument, This is useful in embedding
254 # given as the exec 'globals' argument, This is useful in embedding
255 # situations where the ipython shell opens in a context where the
255 # situations where the ipython shell opens in a context where the
256 # distinction between locals and globals is meaningful.
256 # distinction between locals and globals is meaningful.
257
257
258 # FIXME. For some strange reason, __builtins__ is showing up at user
258 # FIXME. For some strange reason, __builtins__ is showing up at user
259 # level as a dict instead of a module. This is a manual fix, but I
259 # level as a dict instead of a module. This is a manual fix, but I
260 # should really track down where the problem is coming from. Alex
260 # should really track down where the problem is coming from. Alex
261 # Schmolck reported this problem first.
261 # Schmolck reported this problem first.
262
262
263 # A useful post by Alex Martelli on this topic:
263 # A useful post by Alex Martelli on this topic:
264 # Re: inconsistent value from __builtins__
264 # Re: inconsistent value from __builtins__
265 # Von: Alex Martelli <aleaxit@yahoo.com>
265 # Von: Alex Martelli <aleaxit@yahoo.com>
266 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
266 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
267 # Gruppen: comp.lang.python
267 # Gruppen: comp.lang.python
268
268
269 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
269 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
270 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
270 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
271 # > <type 'dict'>
271 # > <type 'dict'>
272 # > >>> print type(__builtins__)
272 # > >>> print type(__builtins__)
273 # > <type 'module'>
273 # > <type 'module'>
274 # > Is this difference in return value intentional?
274 # > Is this difference in return value intentional?
275
275
276 # Well, it's documented that '__builtins__' can be either a dictionary
276 # Well, it's documented that '__builtins__' can be either a dictionary
277 # or a module, and it's been that way for a long time. Whether it's
277 # or a module, and it's been that way for a long time. Whether it's
278 # intentional (or sensible), I don't know. In any case, the idea is
278 # intentional (or sensible), I don't know. In any case, the idea is
279 # that if you need to access the built-in namespace directly, you
279 # that if you need to access the built-in namespace directly, you
280 # should start with "import __builtin__" (note, no 's') which will
280 # should start with "import __builtin__" (note, no 's') which will
281 # definitely give you a module. Yeah, it's somewhat confusing:-(.
281 # definitely give you a module. Yeah, it's somewhat confusing:-(.
282
282
283 # These routines return properly built dicts as needed by the rest of
283 # These routines return properly built dicts as needed by the rest of
284 # the code, and can also be used by extension writers to generate
284 # the code, and can also be used by extension writers to generate
285 # properly initialized namespaces.
285 # properly initialized namespaces.
286 user_ns = IPython.ipapi.make_user_ns(user_ns)
286 user_ns = IPython.ipapi.make_user_ns(user_ns)
287 user_global_ns = IPython.ipapi.make_user_global_ns(user_global_ns)
287 user_global_ns = IPython.ipapi.make_user_global_ns(user_global_ns)
288
288
289 # Assign namespaces
289 # Assign namespaces
290 # This is the namespace where all normal user variables live
290 # This is the namespace where all normal user variables live
291 self.user_ns = user_ns
291 self.user_ns = user_ns
292 # Embedded instances require a separate namespace for globals.
292 # Embedded instances require a separate namespace for globals.
293 # Normally this one is unused by non-embedded instances.
293 # Normally this one is unused by non-embedded instances.
294 self.user_global_ns = user_global_ns
294 self.user_global_ns = user_global_ns
295 # A namespace to keep track of internal data structures to prevent
295 # A namespace to keep track of internal data structures to prevent
296 # them from cluttering user-visible stuff. Will be updated later
296 # them from cluttering user-visible stuff. Will be updated later
297 self.internal_ns = {}
297 self.internal_ns = {}
298
298
299 # Namespace of system aliases. Each entry in the alias
299 # Namespace of system aliases. Each entry in the alias
300 # table must be a 2-tuple of the form (N,name), where N is the number
300 # table must be a 2-tuple of the form (N,name), where N is the number
301 # of positional arguments of the alias.
301 # of positional arguments of the alias.
302 self.alias_table = {}
302 self.alias_table = {}
303
303
304 # A table holding all the namespaces IPython deals with, so that
304 # A table holding all the namespaces IPython deals with, so that
305 # introspection facilities can search easily.
305 # introspection facilities can search easily.
306 self.ns_table = {'user':user_ns,
306 self.ns_table = {'user':user_ns,
307 'user_global':user_global_ns,
307 'user_global':user_global_ns,
308 'alias':self.alias_table,
308 'alias':self.alias_table,
309 'internal':self.internal_ns,
309 'internal':self.internal_ns,
310 'builtin':__builtin__.__dict__
310 'builtin':__builtin__.__dict__
311 }
311 }
312
312
313 # The user namespace MUST have a pointer to the shell itself.
313 # The user namespace MUST have a pointer to the shell itself.
314 self.user_ns[name] = self
314 self.user_ns[name] = self
315
315
316 # We need to insert into sys.modules something that looks like a
316 # We need to insert into sys.modules something that looks like a
317 # module but which accesses the IPython namespace, for shelve and
317 # module but which accesses the IPython namespace, for shelve and
318 # pickle to work interactively. Normally they rely on getting
318 # pickle to work interactively. Normally they rely on getting
319 # everything out of __main__, but for embedding purposes each IPython
319 # everything out of __main__, but for embedding purposes each IPython
320 # instance has its own private namespace, so we can't go shoving
320 # instance has its own private namespace, so we can't go shoving
321 # everything into __main__.
321 # everything into __main__.
322
322
323 # note, however, that we should only do this for non-embedded
323 # note, however, that we should only do this for non-embedded
324 # ipythons, which really mimic the __main__.__dict__ with their own
324 # ipythons, which really mimic the __main__.__dict__ with their own
325 # namespace. Embedded instances, on the other hand, should not do
325 # namespace. Embedded instances, on the other hand, should not do
326 # this because they need to manage the user local/global namespaces
326 # this because they need to manage the user local/global namespaces
327 # only, but they live within a 'normal' __main__ (meaning, they
327 # only, but they live within a 'normal' __main__ (meaning, they
328 # shouldn't overtake the execution environment of the script they're
328 # shouldn't overtake the execution environment of the script they're
329 # embedded in).
329 # embedded in).
330
330
331 if not embedded:
331 if not embedded:
332 try:
332 try:
333 main_name = self.user_ns['__name__']
333 main_name = self.user_ns['__name__']
334 except KeyError:
334 except KeyError:
335 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
335 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
336 else:
336 else:
337 #print "pickle hack in place" # dbg
337 #print "pickle hack in place" # dbg
338 #print 'main_name:',main_name # dbg
338 #print 'main_name:',main_name # dbg
339 sys.modules[main_name] = FakeModule(self.user_ns)
339 sys.modules[main_name] = FakeModule(self.user_ns)
340
340
341 # List of input with multi-line handling.
341 # List of input with multi-line handling.
342 # Fill its zero entry, user counter starts at 1
342 # Fill its zero entry, user counter starts at 1
343 self.input_hist = InputList(['\n'])
343 self.input_hist = InputList(['\n'])
344 # This one will hold the 'raw' input history, without any
344 # This one will hold the 'raw' input history, without any
345 # pre-processing. This will allow users to retrieve the input just as
345 # pre-processing. This will allow users to retrieve the input just as
346 # it was exactly typed in by the user, with %hist -r.
346 # it was exactly typed in by the user, with %hist -r.
347 self.input_hist_raw = InputList(['\n'])
347 self.input_hist_raw = InputList(['\n'])
348
348
349 # list of visited directories
349 # list of visited directories
350 try:
350 try:
351 self.dir_hist = [os.getcwd()]
351 self.dir_hist = [os.getcwd()]
352 except IOError, e:
352 except IOError, e:
353 self.dir_hist = []
353 self.dir_hist = []
354
354
355 # dict of output history
355 # dict of output history
356 self.output_hist = {}
356 self.output_hist = {}
357
357
358 # dict of things NOT to alias (keywords, builtins and some magics)
358 # dict of things NOT to alias (keywords, builtins and some magics)
359 no_alias = {}
359 no_alias = {}
360 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
360 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
361 for key in keyword.kwlist + no_alias_magics:
361 for key in keyword.kwlist + no_alias_magics:
362 no_alias[key] = 1
362 no_alias[key] = 1
363 no_alias.update(__builtin__.__dict__)
363 no_alias.update(__builtin__.__dict__)
364 self.no_alias = no_alias
364 self.no_alias = no_alias
365
365
366 # make global variables for user access to these
366 # make global variables for user access to these
367 self.user_ns['_ih'] = self.input_hist
367 self.user_ns['_ih'] = self.input_hist
368 self.user_ns['_oh'] = self.output_hist
368 self.user_ns['_oh'] = self.output_hist
369 self.user_ns['_dh'] = self.dir_hist
369 self.user_ns['_dh'] = self.dir_hist
370
370
371 # user aliases to input and output histories
371 # user aliases to input and output histories
372 self.user_ns['In'] = self.input_hist
372 self.user_ns['In'] = self.input_hist
373 self.user_ns['Out'] = self.output_hist
373 self.user_ns['Out'] = self.output_hist
374
374
375 # Object variable to store code object waiting execution. This is
375 # Object variable to store code object waiting execution. This is
376 # used mainly by the multithreaded shells, but it can come in handy in
376 # used mainly by the multithreaded shells, but it can come in handy in
377 # other situations. No need to use a Queue here, since it's a single
377 # other situations. No need to use a Queue here, since it's a single
378 # item which gets cleared once run.
378 # item which gets cleared once run.
379 self.code_to_run = None
379 self.code_to_run = None
380
380
381 # escapes for automatic behavior on the command line
381 # escapes for automatic behavior on the command line
382 self.ESC_SHELL = '!'
382 self.ESC_SHELL = '!'
383 self.ESC_HELP = '?'
383 self.ESC_HELP = '?'
384 self.ESC_MAGIC = '%'
384 self.ESC_MAGIC = '%'
385 self.ESC_QUOTE = ','
385 self.ESC_QUOTE = ','
386 self.ESC_QUOTE2 = ';'
386 self.ESC_QUOTE2 = ';'
387 self.ESC_PAREN = '/'
387 self.ESC_PAREN = '/'
388
388
389 # And their associated handlers
389 # And their associated handlers
390 self.esc_handlers = {self.ESC_PAREN : self.handle_auto,
390 self.esc_handlers = {self.ESC_PAREN : self.handle_auto,
391 self.ESC_QUOTE : self.handle_auto,
391 self.ESC_QUOTE : self.handle_auto,
392 self.ESC_QUOTE2 : self.handle_auto,
392 self.ESC_QUOTE2 : self.handle_auto,
393 self.ESC_MAGIC : self.handle_magic,
393 self.ESC_MAGIC : self.handle_magic,
394 self.ESC_HELP : self.handle_help,
394 self.ESC_HELP : self.handle_help,
395 self.ESC_SHELL : self.handle_shell_escape,
395 self.ESC_SHELL : self.handle_shell_escape,
396 }
396 }
397
397
398 # class initializations
398 # class initializations
399 Magic.__init__(self,self)
399 Magic.__init__(self,self)
400
400
401 # Python source parser/formatter for syntax highlighting
401 # Python source parser/formatter for syntax highlighting
402 pyformat = PyColorize.Parser().format
402 pyformat = PyColorize.Parser().format
403 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
403 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
404
404
405 # hooks holds pointers used for user-side customizations
405 # hooks holds pointers used for user-side customizations
406 self.hooks = Struct()
406 self.hooks = Struct()
407
407
408 self.strdispatchers = {}
408 self.strdispatchers = {}
409
409
410 # Set all default hooks, defined in the IPython.hooks module.
410 # Set all default hooks, defined in the IPython.hooks module.
411 hooks = IPython.hooks
411 hooks = IPython.hooks
412 for hook_name in hooks.__all__:
412 for hook_name in hooks.__all__:
413 # default hooks have priority 100, i.e. low; user hooks should have 0-100 priority
413 # default hooks have priority 100, i.e. low; user hooks should have 0-100 priority
414 self.set_hook(hook_name,getattr(hooks,hook_name), 100)
414 self.set_hook(hook_name,getattr(hooks,hook_name), 100)
415 #print "bound hook",hook_name
415 #print "bound hook",hook_name
416
416
417 # Flag to mark unconditional exit
417 # Flag to mark unconditional exit
418 self.exit_now = False
418 self.exit_now = False
419
419
420 self.usage_min = """\
420 self.usage_min = """\
421 An enhanced console for Python.
421 An enhanced console for Python.
422 Some of its features are:
422 Some of its features are:
423 - Readline support if the readline library is present.
423 - Readline support if the readline library is present.
424 - Tab completion in the local namespace.
424 - Tab completion in the local namespace.
425 - Logging of input, see command-line options.
425 - Logging of input, see command-line options.
426 - System shell escape via ! , eg !ls.
426 - System shell escape via ! , eg !ls.
427 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
427 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
428 - Keeps track of locally defined variables via %who, %whos.
428 - Keeps track of locally defined variables via %who, %whos.
429 - Show object information with a ? eg ?x or x? (use ?? for more info).
429 - Show object information with a ? eg ?x or x? (use ?? for more info).
430 """
430 """
431 if usage: self.usage = usage
431 if usage: self.usage = usage
432 else: self.usage = self.usage_min
432 else: self.usage = self.usage_min
433
433
434 # Storage
434 # Storage
435 self.rc = rc # This will hold all configuration information
435 self.rc = rc # This will hold all configuration information
436 self.pager = 'less'
436 self.pager = 'less'
437 # temporary files used for various purposes. Deleted at exit.
437 # temporary files used for various purposes. Deleted at exit.
438 self.tempfiles = []
438 self.tempfiles = []
439
439
440 # Keep track of readline usage (later set by init_readline)
440 # Keep track of readline usage (later set by init_readline)
441 self.has_readline = False
441 self.has_readline = False
442
442
443 # template for logfile headers. It gets resolved at runtime by the
443 # template for logfile headers. It gets resolved at runtime by the
444 # logstart method.
444 # logstart method.
445 self.loghead_tpl = \
445 self.loghead_tpl = \
446 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
446 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
447 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
447 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
448 #log# opts = %s
448 #log# opts = %s
449 #log# args = %s
449 #log# args = %s
450 #log# It is safe to make manual edits below here.
450 #log# It is safe to make manual edits below here.
451 #log#-----------------------------------------------------------------------
451 #log#-----------------------------------------------------------------------
452 """
452 """
453 # for pushd/popd management
453 # for pushd/popd management
454 try:
454 try:
455 self.home_dir = get_home_dir()
455 self.home_dir = get_home_dir()
456 except HomeDirError,msg:
456 except HomeDirError,msg:
457 fatal(msg)
457 fatal(msg)
458
458
459 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
459 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
460
460
461 # Functions to call the underlying shell.
461 # Functions to call the underlying shell.
462
462
463 # The first is similar to os.system, but it doesn't return a value,
463 # The first is similar to os.system, but it doesn't return a value,
464 # and it allows interpolation of variables in the user's namespace.
464 # and it allows interpolation of variables in the user's namespace.
465 self.system = lambda cmd: \
465 self.system = lambda cmd: \
466 shell(self.var_expand(cmd,depth=2),
466 shell(self.var_expand(cmd,depth=2),
467 header=self.rc.system_header,
467 header=self.rc.system_header,
468 verbose=self.rc.system_verbose)
468 verbose=self.rc.system_verbose)
469
469
470 # These are for getoutput and getoutputerror:
470 # These are for getoutput and getoutputerror:
471 self.getoutput = lambda cmd: \
471 self.getoutput = lambda cmd: \
472 getoutput(self.var_expand(cmd,depth=2),
472 getoutput(self.var_expand(cmd,depth=2),
473 header=self.rc.system_header,
473 header=self.rc.system_header,
474 verbose=self.rc.system_verbose)
474 verbose=self.rc.system_verbose)
475
475
476 self.getoutputerror = lambda cmd: \
476 self.getoutputerror = lambda cmd: \
477 getoutputerror(self.var_expand(cmd,depth=2),
477 getoutputerror(self.var_expand(cmd,depth=2),
478 header=self.rc.system_header,
478 header=self.rc.system_header,
479 verbose=self.rc.system_verbose)
479 verbose=self.rc.system_verbose)
480
480
481 # RegExp for splitting line contents into pre-char//first
481 # RegExp for splitting line contents into pre-char//first
482 # word-method//rest. For clarity, each group in on one line.
482 # word-method//rest. For clarity, each group in on one line.
483
483
484 # WARNING: update the regexp if the above escapes are changed, as they
484 # WARNING: update the regexp if the above escapes are changed, as they
485 # are hardwired in.
485 # are hardwired in.
486
486
487 # Don't get carried away with trying to make the autocalling catch too
487 # Don't get carried away with trying to make the autocalling catch too
488 # much: it's better to be conservative rather than to trigger hidden
488 # much: it's better to be conservative rather than to trigger hidden
489 # evals() somewhere and end up causing side effects.
489 # evals() somewhere and end up causing side effects.
490
490
491 self.line_split = re.compile(r'^([\s*,;/])'
491 self.line_split = re.compile(r'^([\s*,;/])'
492 r'([\?\w\.]+\w*\s*)'
492 r'([\?\w\.]+\w*\s*)'
493 r'(\(?.*$)')
493 r'(\(?.*$)')
494
494
495 # A simpler regexp used as a fallback if the above doesn't work. This
496 # one is more conservative in how it partitions the input. This code
497 # can probably be cleaned up to do everything with just one regexp, but
498 # I'm afraid of breaking something; do it once the unit tests are in
499 # place.
500 self.line_split_fallback = re.compile(r'^(\s*)'
501 r'([\w\.]*)'
502 r'(.*)')
503
495 # Original re, keep around for a while in case changes break something
504 # Original re, keep around for a while in case changes break something
496 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
505 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
497 # r'(\s*[\?\w\.]+\w*\s*)'
506 # r'(\s*[\?\w\.]+\w*\s*)'
498 # r'(\(?.*$)')
507 # r'(\(?.*$)')
499
508
500 # RegExp to identify potential function names
509 # RegExp to identify potential function names
501 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
510 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
502
511
503 # RegExp to exclude strings with this start from autocalling. In
512 # RegExp to exclude strings with this start from autocalling. In
504 # particular, all binary operators should be excluded, so that if foo
513 # particular, all binary operators should be excluded, so that if foo
505 # is callable, foo OP bar doesn't become foo(OP bar), which is
514 # is callable, foo OP bar doesn't become foo(OP bar), which is
506 # invalid. The characters '!=()' don't need to be checked for, as the
515 # invalid. The characters '!=()' don't need to be checked for, as the
507 # _prefilter routine explicitely does so, to catch direct calls and
516 # _prefilter routine explicitely does so, to catch direct calls and
508 # rebindings of existing names.
517 # rebindings of existing names.
509
518
510 # Warning: the '-' HAS TO BE AT THE END of the first group, otherwise
519 # Warning: the '-' HAS TO BE AT THE END of the first group, otherwise
511 # it affects the rest of the group in square brackets.
520 # it affects the rest of the group in square brackets.
512 self.re_exclude_auto = re.compile(r'^[<>,&^\|\*/\+-]'
521 self.re_exclude_auto = re.compile(r'^[<>,&^\|\*/\+-]'
513 '|^is |^not |^in |^and |^or ')
522 '|^is |^not |^in |^and |^or ')
514
523
515 # try to catch also methods for stuff in lists/tuples/dicts: off
524 # try to catch also methods for stuff in lists/tuples/dicts: off
516 # (experimental). For this to work, the line_split regexp would need
525 # (experimental). For this to work, the line_split regexp would need
517 # to be modified so it wouldn't break things at '['. That line is
526 # to be modified so it wouldn't break things at '['. That line is
518 # nasty enough that I shouldn't change it until I can test it _well_.
527 # nasty enough that I shouldn't change it until I can test it _well_.
519 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
528 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
520
529
521 # keep track of where we started running (mainly for crash post-mortem)
530 # keep track of where we started running (mainly for crash post-mortem)
522 self.starting_dir = os.getcwd()
531 self.starting_dir = os.getcwd()
523
532
524 # Various switches which can be set
533 # Various switches which can be set
525 self.CACHELENGTH = 5000 # this is cheap, it's just text
534 self.CACHELENGTH = 5000 # this is cheap, it's just text
526 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
535 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
527 self.banner2 = banner2
536 self.banner2 = banner2
528
537
529 # TraceBack handlers:
538 # TraceBack handlers:
530
539
531 # Syntax error handler.
540 # Syntax error handler.
532 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
541 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
533
542
534 # The interactive one is initialized with an offset, meaning we always
543 # The interactive one is initialized with an offset, meaning we always
535 # want to remove the topmost item in the traceback, which is our own
544 # want to remove the topmost item in the traceback, which is our own
536 # internal code. Valid modes: ['Plain','Context','Verbose']
545 # internal code. Valid modes: ['Plain','Context','Verbose']
537 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
546 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
538 color_scheme='NoColor',
547 color_scheme='NoColor',
539 tb_offset = 1)
548 tb_offset = 1)
540
549
541 # IPython itself shouldn't crash. This will produce a detailed
550 # IPython itself shouldn't crash. This will produce a detailed
542 # post-mortem if it does. But we only install the crash handler for
551 # post-mortem if it does. But we only install the crash handler for
543 # non-threaded shells, the threaded ones use a normal verbose reporter
552 # non-threaded shells, the threaded ones use a normal verbose reporter
544 # and lose the crash handler. This is because exceptions in the main
553 # and lose the crash handler. This is because exceptions in the main
545 # thread (such as in GUI code) propagate directly to sys.excepthook,
554 # thread (such as in GUI code) propagate directly to sys.excepthook,
546 # and there's no point in printing crash dumps for every user exception.
555 # and there's no point in printing crash dumps for every user exception.
547 if self.isthreaded:
556 if self.isthreaded:
548 ipCrashHandler = ultraTB.FormattedTB()
557 ipCrashHandler = ultraTB.FormattedTB()
549 else:
558 else:
550 from IPython import CrashHandler
559 from IPython import CrashHandler
551 ipCrashHandler = CrashHandler.IPythonCrashHandler(self)
560 ipCrashHandler = CrashHandler.IPythonCrashHandler(self)
552 self.set_crash_handler(ipCrashHandler)
561 self.set_crash_handler(ipCrashHandler)
553
562
554 # and add any custom exception handlers the user may have specified
563 # and add any custom exception handlers the user may have specified
555 self.set_custom_exc(*custom_exceptions)
564 self.set_custom_exc(*custom_exceptions)
556
565
557 # indentation management
566 # indentation management
558 self.autoindent = False
567 self.autoindent = False
559 self.indent_current_nsp = 0
568 self.indent_current_nsp = 0
560
569
561 # Make some aliases automatically
570 # Make some aliases automatically
562 # Prepare list of shell aliases to auto-define
571 # Prepare list of shell aliases to auto-define
563 if os.name == 'posix':
572 if os.name == 'posix':
564 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
573 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
565 'mv mv -i','rm rm -i','cp cp -i',
574 'mv mv -i','rm rm -i','cp cp -i',
566 'cat cat','less less','clear clear',
575 'cat cat','less less','clear clear',
567 # a better ls
576 # a better ls
568 'ls ls -F',
577 'ls ls -F',
569 # long ls
578 # long ls
570 'll ls -lF')
579 'll ls -lF')
571 # Extra ls aliases with color, which need special treatment on BSD
580 # Extra ls aliases with color, which need special treatment on BSD
572 # variants
581 # variants
573 ls_extra = ( # color ls
582 ls_extra = ( # color ls
574 'lc ls -F -o --color',
583 'lc ls -F -o --color',
575 # ls normal files only
584 # ls normal files only
576 'lf ls -F -o --color %l | grep ^-',
585 'lf ls -F -o --color %l | grep ^-',
577 # ls symbolic links
586 # ls symbolic links
578 'lk ls -F -o --color %l | grep ^l',
587 'lk ls -F -o --color %l | grep ^l',
579 # directories or links to directories,
588 # directories or links to directories,
580 'ldir ls -F -o --color %l | grep /$',
589 'ldir ls -F -o --color %l | grep /$',
581 # things which are executable
590 # things which are executable
582 'lx ls -F -o --color %l | grep ^-..x',
591 'lx ls -F -o --color %l | grep ^-..x',
583 )
592 )
584 # The BSDs don't ship GNU ls, so they don't understand the
593 # The BSDs don't ship GNU ls, so they don't understand the
585 # --color switch out of the box
594 # --color switch out of the box
586 if 'bsd' in sys.platform:
595 if 'bsd' in sys.platform:
587 ls_extra = ( # ls normal files only
596 ls_extra = ( # ls normal files only
588 'lf ls -lF | grep ^-',
597 'lf ls -lF | grep ^-',
589 # ls symbolic links
598 # ls symbolic links
590 'lk ls -lF | grep ^l',
599 'lk ls -lF | grep ^l',
591 # directories or links to directories,
600 # directories or links to directories,
592 'ldir ls -lF | grep /$',
601 'ldir ls -lF | grep /$',
593 # things which are executable
602 # things which are executable
594 'lx ls -lF | grep ^-..x',
603 'lx ls -lF | grep ^-..x',
595 )
604 )
596 auto_alias = auto_alias + ls_extra
605 auto_alias = auto_alias + ls_extra
597 elif os.name in ['nt','dos']:
606 elif os.name in ['nt','dos']:
598 auto_alias = ('dir dir /on', 'ls dir /on',
607 auto_alias = ('dir dir /on', 'ls dir /on',
599 'ddir dir /ad /on', 'ldir dir /ad /on',
608 'ddir dir /ad /on', 'ldir dir /ad /on',
600 'mkdir mkdir','rmdir rmdir','echo echo',
609 'mkdir mkdir','rmdir rmdir','echo echo',
601 'ren ren','cls cls','copy copy')
610 'ren ren','cls cls','copy copy')
602 else:
611 else:
603 auto_alias = ()
612 auto_alias = ()
604 self.auto_alias = [s.split(None,1) for s in auto_alias]
613 self.auto_alias = [s.split(None,1) for s in auto_alias]
605 # Call the actual (public) initializer
614 # Call the actual (public) initializer
606 self.init_auto_alias()
615 self.init_auto_alias()
607
616
608 # Produce a public API instance
617 # Produce a public API instance
609 self.api = IPython.ipapi.IPApi(self)
618 self.api = IPython.ipapi.IPApi(self)
610
619
611 # track which builtins we add, so we can clean up later
620 # track which builtins we add, so we can clean up later
612 self.builtins_added = {}
621 self.builtins_added = {}
613 # This method will add the necessary builtins for operation, but
622 # This method will add the necessary builtins for operation, but
614 # tracking what it did via the builtins_added dict.
623 # tracking what it did via the builtins_added dict.
615 self.add_builtins()
624 self.add_builtins()
616
625
617 # end __init__
626 # end __init__
618
627
619 def var_expand(self,cmd,depth=0):
628 def var_expand(self,cmd,depth=0):
620 """Expand python variables in a string.
629 """Expand python variables in a string.
621
630
622 The depth argument indicates how many frames above the caller should
631 The depth argument indicates how many frames above the caller should
623 be walked to look for the local namespace where to expand variables.
632 be walked to look for the local namespace where to expand variables.
624
633
625 The global namespace for expansion is always the user's interactive
634 The global namespace for expansion is always the user's interactive
626 namespace.
635 namespace.
627 """
636 """
628
637
629 return str(ItplNS(cmd.replace('#','\#'),
638 return str(ItplNS(cmd.replace('#','\#'),
630 self.user_ns, # globals
639 self.user_ns, # globals
631 # Skip our own frame in searching for locals:
640 # Skip our own frame in searching for locals:
632 sys._getframe(depth+1).f_locals # locals
641 sys._getframe(depth+1).f_locals # locals
633 ))
642 ))
634
643
635 def pre_config_initialization(self):
644 def pre_config_initialization(self):
636 """Pre-configuration init method
645 """Pre-configuration init method
637
646
638 This is called before the configuration files are processed to
647 This is called before the configuration files are processed to
639 prepare the services the config files might need.
648 prepare the services the config files might need.
640
649
641 self.rc already has reasonable default values at this point.
650 self.rc already has reasonable default values at this point.
642 """
651 """
643 rc = self.rc
652 rc = self.rc
644
653
645 self.db = pickleshare.PickleShareDB(rc.ipythondir + "/db")
654 self.db = pickleshare.PickleShareDB(rc.ipythondir + "/db")
646
655
647 def post_config_initialization(self):
656 def post_config_initialization(self):
648 """Post configuration init method
657 """Post configuration init method
649
658
650 This is called after the configuration files have been processed to
659 This is called after the configuration files have been processed to
651 'finalize' the initialization."""
660 'finalize' the initialization."""
652
661
653 rc = self.rc
662 rc = self.rc
654
663
655 # Object inspector
664 # Object inspector
656 self.inspector = OInspect.Inspector(OInspect.InspectColors,
665 self.inspector = OInspect.Inspector(OInspect.InspectColors,
657 PyColorize.ANSICodeColors,
666 PyColorize.ANSICodeColors,
658 'NoColor',
667 'NoColor',
659 rc.object_info_string_level)
668 rc.object_info_string_level)
660
669
661 # Load readline proper
670 # Load readline proper
662 if rc.readline:
671 if rc.readline:
663 self.init_readline()
672 self.init_readline()
664
673
665 # local shortcut, this is used a LOT
674 # local shortcut, this is used a LOT
666 self.log = self.logger.log
675 self.log = self.logger.log
667
676
668 # Initialize cache, set in/out prompts and printing system
677 # Initialize cache, set in/out prompts and printing system
669 self.outputcache = CachedOutput(self,
678 self.outputcache = CachedOutput(self,
670 rc.cache_size,
679 rc.cache_size,
671 rc.pprint,
680 rc.pprint,
672 input_sep = rc.separate_in,
681 input_sep = rc.separate_in,
673 output_sep = rc.separate_out,
682 output_sep = rc.separate_out,
674 output_sep2 = rc.separate_out2,
683 output_sep2 = rc.separate_out2,
675 ps1 = rc.prompt_in1,
684 ps1 = rc.prompt_in1,
676 ps2 = rc.prompt_in2,
685 ps2 = rc.prompt_in2,
677 ps_out = rc.prompt_out,
686 ps_out = rc.prompt_out,
678 pad_left = rc.prompts_pad_left)
687 pad_left = rc.prompts_pad_left)
679
688
680 # user may have over-ridden the default print hook:
689 # user may have over-ridden the default print hook:
681 try:
690 try:
682 self.outputcache.__class__.display = self.hooks.display
691 self.outputcache.__class__.display = self.hooks.display
683 except AttributeError:
692 except AttributeError:
684 pass
693 pass
685
694
686 # I don't like assigning globally to sys, because it means when
695 # I don't like assigning globally to sys, because it means when
687 # embedding instances, each embedded instance overrides the previous
696 # embedding instances, each embedded instance overrides the previous
688 # choice. But sys.displayhook seems to be called internally by exec,
697 # choice. But sys.displayhook seems to be called internally by exec,
689 # so I don't see a way around it. We first save the original and then
698 # so I don't see a way around it. We first save the original and then
690 # overwrite it.
699 # overwrite it.
691 self.sys_displayhook = sys.displayhook
700 self.sys_displayhook = sys.displayhook
692 sys.displayhook = self.outputcache
701 sys.displayhook = self.outputcache
693
702
694 # Set user colors (don't do it in the constructor above so that it
703 # Set user colors (don't do it in the constructor above so that it
695 # doesn't crash if colors option is invalid)
704 # doesn't crash if colors option is invalid)
696 self.magic_colors(rc.colors)
705 self.magic_colors(rc.colors)
697
706
698 # Set calling of pdb on exceptions
707 # Set calling of pdb on exceptions
699 self.call_pdb = rc.pdb
708 self.call_pdb = rc.pdb
700
709
701 # Load user aliases
710 # Load user aliases
702 for alias in rc.alias:
711 for alias in rc.alias:
703 self.magic_alias(alias)
712 self.magic_alias(alias)
704 self.hooks.late_startup_hook()
713 self.hooks.late_startup_hook()
705
714
706 batchrun = False
715 batchrun = False
707 for batchfile in [path(arg) for arg in self.rc.args
716 for batchfile in [path(arg) for arg in self.rc.args
708 if arg.lower().endswith('.ipy')]:
717 if arg.lower().endswith('.ipy')]:
709 if not batchfile.isfile():
718 if not batchfile.isfile():
710 print "No such batch file:", batchfile
719 print "No such batch file:", batchfile
711 continue
720 continue
712 self.api.runlines(batchfile.text())
721 self.api.runlines(batchfile.text())
713 batchrun = True
722 batchrun = True
714 if batchrun:
723 if batchrun:
715 self.exit_now = True
724 self.exit_now = True
716
725
717 def add_builtins(self):
726 def add_builtins(self):
718 """Store ipython references into the builtin namespace.
727 """Store ipython references into the builtin namespace.
719
728
720 Some parts of ipython operate via builtins injected here, which hold a
729 Some parts of ipython operate via builtins injected here, which hold a
721 reference to IPython itself."""
730 reference to IPython itself."""
722
731
723 # TODO: deprecate all except _ip; 'jobs' should be installed
732 # TODO: deprecate all except _ip; 'jobs' should be installed
724 # by an extension and the rest are under _ip, ipalias is redundant
733 # by an extension and the rest are under _ip, ipalias is redundant
725 builtins_new = dict(__IPYTHON__ = self,
734 builtins_new = dict(__IPYTHON__ = self,
726 ip_set_hook = self.set_hook,
735 ip_set_hook = self.set_hook,
727 jobs = self.jobs,
736 jobs = self.jobs,
728 ipmagic = wrap_deprecated(self.ipmagic,'_ip.magic()'),
737 ipmagic = wrap_deprecated(self.ipmagic,'_ip.magic()'),
729 ipalias = wrap_deprecated(self.ipalias),
738 ipalias = wrap_deprecated(self.ipalias),
730 ipsystem = wrap_deprecated(self.ipsystem,'_ip.system()'),
739 ipsystem = wrap_deprecated(self.ipsystem,'_ip.system()'),
731 _ip = self.api
740 _ip = self.api
732 )
741 )
733 for biname,bival in builtins_new.items():
742 for biname,bival in builtins_new.items():
734 try:
743 try:
735 # store the orignal value so we can restore it
744 # store the orignal value so we can restore it
736 self.builtins_added[biname] = __builtin__.__dict__[biname]
745 self.builtins_added[biname] = __builtin__.__dict__[biname]
737 except KeyError:
746 except KeyError:
738 # or mark that it wasn't defined, and we'll just delete it at
747 # or mark that it wasn't defined, and we'll just delete it at
739 # cleanup
748 # cleanup
740 self.builtins_added[biname] = Undefined
749 self.builtins_added[biname] = Undefined
741 __builtin__.__dict__[biname] = bival
750 __builtin__.__dict__[biname] = bival
742
751
743 # Keep in the builtins a flag for when IPython is active. We set it
752 # Keep in the builtins a flag for when IPython is active. We set it
744 # with setdefault so that multiple nested IPythons don't clobber one
753 # with setdefault so that multiple nested IPythons don't clobber one
745 # another. Each will increase its value by one upon being activated,
754 # another. Each will increase its value by one upon being activated,
746 # which also gives us a way to determine the nesting level.
755 # which also gives us a way to determine the nesting level.
747 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
756 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
748
757
749 def clean_builtins(self):
758 def clean_builtins(self):
750 """Remove any builtins which might have been added by add_builtins, or
759 """Remove any builtins which might have been added by add_builtins, or
751 restore overwritten ones to their previous values."""
760 restore overwritten ones to their previous values."""
752 for biname,bival in self.builtins_added.items():
761 for biname,bival in self.builtins_added.items():
753 if bival is Undefined:
762 if bival is Undefined:
754 del __builtin__.__dict__[biname]
763 del __builtin__.__dict__[biname]
755 else:
764 else:
756 __builtin__.__dict__[biname] = bival
765 __builtin__.__dict__[biname] = bival
757 self.builtins_added.clear()
766 self.builtins_added.clear()
758
767
759 def set_hook(self,name,hook, priority = 50, str_key = None, re_key = None):
768 def set_hook(self,name,hook, priority = 50, str_key = None, re_key = None):
760 """set_hook(name,hook) -> sets an internal IPython hook.
769 """set_hook(name,hook) -> sets an internal IPython hook.
761
770
762 IPython exposes some of its internal API as user-modifiable hooks. By
771 IPython exposes some of its internal API as user-modifiable hooks. By
763 adding your function to one of these hooks, you can modify IPython's
772 adding your function to one of these hooks, you can modify IPython's
764 behavior to call at runtime your own routines."""
773 behavior to call at runtime your own routines."""
765
774
766 # At some point in the future, this should validate the hook before it
775 # At some point in the future, this should validate the hook before it
767 # accepts it. Probably at least check that the hook takes the number
776 # accepts it. Probably at least check that the hook takes the number
768 # of args it's supposed to.
777 # of args it's supposed to.
769
778
770 f = new.instancemethod(hook,self,self.__class__)
779 f = new.instancemethod(hook,self,self.__class__)
771
780
772 # check if the hook is for strdispatcher first
781 # check if the hook is for strdispatcher first
773 if str_key is not None:
782 if str_key is not None:
774 sdp = self.strdispatchers.get(name, StrDispatch())
783 sdp = self.strdispatchers.get(name, StrDispatch())
775 sdp.add_s(str_key, f, priority )
784 sdp.add_s(str_key, f, priority )
776 self.strdispatchers[name] = sdp
785 self.strdispatchers[name] = sdp
777 return
786 return
778 if re_key is not None:
787 if re_key is not None:
779 sdp = self.strdispatchers.get(name, StrDispatch())
788 sdp = self.strdispatchers.get(name, StrDispatch())
780 sdp.add_re(re.compile(re_key), f, priority )
789 sdp.add_re(re.compile(re_key), f, priority )
781 self.strdispatchers[name] = sdp
790 self.strdispatchers[name] = sdp
782 return
791 return
783
792
784 dp = getattr(self.hooks, name, None)
793 dp = getattr(self.hooks, name, None)
785 if name not in IPython.hooks.__all__:
794 if name not in IPython.hooks.__all__:
786 print "Warning! Hook '%s' is not one of %s" % (name, IPython.hooks.__all__ )
795 print "Warning! Hook '%s' is not one of %s" % (name, IPython.hooks.__all__ )
787 if not dp:
796 if not dp:
788 dp = IPython.hooks.CommandChainDispatcher()
797 dp = IPython.hooks.CommandChainDispatcher()
789
798
790 try:
799 try:
791 dp.add(f,priority)
800 dp.add(f,priority)
792 except AttributeError:
801 except AttributeError:
793 # it was not commandchain, plain old func - replace
802 # it was not commandchain, plain old func - replace
794 dp = f
803 dp = f
795
804
796 setattr(self.hooks,name, dp)
805 setattr(self.hooks,name, dp)
797
806
798
807
799 #setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
808 #setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
800
809
801 def set_crash_handler(self,crashHandler):
810 def set_crash_handler(self,crashHandler):
802 """Set the IPython crash handler.
811 """Set the IPython crash handler.
803
812
804 This must be a callable with a signature suitable for use as
813 This must be a callable with a signature suitable for use as
805 sys.excepthook."""
814 sys.excepthook."""
806
815
807 # Install the given crash handler as the Python exception hook
816 # Install the given crash handler as the Python exception hook
808 sys.excepthook = crashHandler
817 sys.excepthook = crashHandler
809
818
810 # The instance will store a pointer to this, so that runtime code
819 # The instance will store a pointer to this, so that runtime code
811 # (such as magics) can access it. This is because during the
820 # (such as magics) can access it. This is because during the
812 # read-eval loop, it gets temporarily overwritten (to deal with GUI
821 # read-eval loop, it gets temporarily overwritten (to deal with GUI
813 # frameworks).
822 # frameworks).
814 self.sys_excepthook = sys.excepthook
823 self.sys_excepthook = sys.excepthook
815
824
816
825
817 def set_custom_exc(self,exc_tuple,handler):
826 def set_custom_exc(self,exc_tuple,handler):
818 """set_custom_exc(exc_tuple,handler)
827 """set_custom_exc(exc_tuple,handler)
819
828
820 Set a custom exception handler, which will be called if any of the
829 Set a custom exception handler, which will be called if any of the
821 exceptions in exc_tuple occur in the mainloop (specifically, in the
830 exceptions in exc_tuple occur in the mainloop (specifically, in the
822 runcode() method.
831 runcode() method.
823
832
824 Inputs:
833 Inputs:
825
834
826 - exc_tuple: a *tuple* of valid exceptions to call the defined
835 - exc_tuple: a *tuple* of valid exceptions to call the defined
827 handler for. It is very important that you use a tuple, and NOT A
836 handler for. It is very important that you use a tuple, and NOT A
828 LIST here, because of the way Python's except statement works. If
837 LIST here, because of the way Python's except statement works. If
829 you only want to trap a single exception, use a singleton tuple:
838 you only want to trap a single exception, use a singleton tuple:
830
839
831 exc_tuple == (MyCustomException,)
840 exc_tuple == (MyCustomException,)
832
841
833 - handler: this must be defined as a function with the following
842 - handler: this must be defined as a function with the following
834 basic interface: def my_handler(self,etype,value,tb).
843 basic interface: def my_handler(self,etype,value,tb).
835
844
836 This will be made into an instance method (via new.instancemethod)
845 This will be made into an instance method (via new.instancemethod)
837 of IPython itself, and it will be called if any of the exceptions
846 of IPython itself, and it will be called if any of the exceptions
838 listed in the exc_tuple are caught. If the handler is None, an
847 listed in the exc_tuple are caught. If the handler is None, an
839 internal basic one is used, which just prints basic info.
848 internal basic one is used, which just prints basic info.
840
849
841 WARNING: by putting in your own exception handler into IPython's main
850 WARNING: by putting in your own exception handler into IPython's main
842 execution loop, you run a very good chance of nasty crashes. This
851 execution loop, you run a very good chance of nasty crashes. This
843 facility should only be used if you really know what you are doing."""
852 facility should only be used if you really know what you are doing."""
844
853
845 assert type(exc_tuple)==type(()) , \
854 assert type(exc_tuple)==type(()) , \
846 "The custom exceptions must be given AS A TUPLE."
855 "The custom exceptions must be given AS A TUPLE."
847
856
848 def dummy_handler(self,etype,value,tb):
857 def dummy_handler(self,etype,value,tb):
849 print '*** Simple custom exception handler ***'
858 print '*** Simple custom exception handler ***'
850 print 'Exception type :',etype
859 print 'Exception type :',etype
851 print 'Exception value:',value
860 print 'Exception value:',value
852 print 'Traceback :',tb
861 print 'Traceback :',tb
853 print 'Source code :','\n'.join(self.buffer)
862 print 'Source code :','\n'.join(self.buffer)
854
863
855 if handler is None: handler = dummy_handler
864 if handler is None: handler = dummy_handler
856
865
857 self.CustomTB = new.instancemethod(handler,self,self.__class__)
866 self.CustomTB = new.instancemethod(handler,self,self.__class__)
858 self.custom_exceptions = exc_tuple
867 self.custom_exceptions = exc_tuple
859
868
860 def set_custom_completer(self,completer,pos=0):
869 def set_custom_completer(self,completer,pos=0):
861 """set_custom_completer(completer,pos=0)
870 """set_custom_completer(completer,pos=0)
862
871
863 Adds a new custom completer function.
872 Adds a new custom completer function.
864
873
865 The position argument (defaults to 0) is the index in the completers
874 The position argument (defaults to 0) is the index in the completers
866 list where you want the completer to be inserted."""
875 list where you want the completer to be inserted."""
867
876
868 newcomp = new.instancemethod(completer,self.Completer,
877 newcomp = new.instancemethod(completer,self.Completer,
869 self.Completer.__class__)
878 self.Completer.__class__)
870 self.Completer.matchers.insert(pos,newcomp)
879 self.Completer.matchers.insert(pos,newcomp)
871
880
872 def _get_call_pdb(self):
881 def _get_call_pdb(self):
873 return self._call_pdb
882 return self._call_pdb
874
883
875 def _set_call_pdb(self,val):
884 def _set_call_pdb(self,val):
876
885
877 if val not in (0,1,False,True):
886 if val not in (0,1,False,True):
878 raise ValueError,'new call_pdb value must be boolean'
887 raise ValueError,'new call_pdb value must be boolean'
879
888
880 # store value in instance
889 # store value in instance
881 self._call_pdb = val
890 self._call_pdb = val
882
891
883 # notify the actual exception handlers
892 # notify the actual exception handlers
884 self.InteractiveTB.call_pdb = val
893 self.InteractiveTB.call_pdb = val
885 if self.isthreaded:
894 if self.isthreaded:
886 try:
895 try:
887 self.sys_excepthook.call_pdb = val
896 self.sys_excepthook.call_pdb = val
888 except:
897 except:
889 warn('Failed to activate pdb for threaded exception handler')
898 warn('Failed to activate pdb for threaded exception handler')
890
899
891 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
900 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
892 'Control auto-activation of pdb at exceptions')
901 'Control auto-activation of pdb at exceptions')
893
902
894
903
895 # These special functions get installed in the builtin namespace, to
904 # These special functions get installed in the builtin namespace, to
896 # provide programmatic (pure python) access to magics, aliases and system
905 # provide programmatic (pure python) access to magics, aliases and system
897 # calls. This is important for logging, user scripting, and more.
906 # calls. This is important for logging, user scripting, and more.
898
907
899 # We are basically exposing, via normal python functions, the three
908 # We are basically exposing, via normal python functions, the three
900 # mechanisms in which ipython offers special call modes (magics for
909 # mechanisms in which ipython offers special call modes (magics for
901 # internal control, aliases for direct system access via pre-selected
910 # internal control, aliases for direct system access via pre-selected
902 # names, and !cmd for calling arbitrary system commands).
911 # names, and !cmd for calling arbitrary system commands).
903
912
904 def ipmagic(self,arg_s):
913 def ipmagic(self,arg_s):
905 """Call a magic function by name.
914 """Call a magic function by name.
906
915
907 Input: a string containing the name of the magic function to call and any
916 Input: a string containing the name of the magic function to call and any
908 additional arguments to be passed to the magic.
917 additional arguments to be passed to the magic.
909
918
910 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
919 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
911 prompt:
920 prompt:
912
921
913 In[1]: %name -opt foo bar
922 In[1]: %name -opt foo bar
914
923
915 To call a magic without arguments, simply use ipmagic('name').
924 To call a magic without arguments, simply use ipmagic('name').
916
925
917 This provides a proper Python function to call IPython's magics in any
926 This provides a proper Python function to call IPython's magics in any
918 valid Python code you can type at the interpreter, including loops and
927 valid Python code you can type at the interpreter, including loops and
919 compound statements. It is added by IPython to the Python builtin
928 compound statements. It is added by IPython to the Python builtin
920 namespace upon initialization."""
929 namespace upon initialization."""
921
930
922 args = arg_s.split(' ',1)
931 args = arg_s.split(' ',1)
923 magic_name = args[0]
932 magic_name = args[0]
924 magic_name = magic_name.lstrip(self.ESC_MAGIC)
933 magic_name = magic_name.lstrip(self.ESC_MAGIC)
925
934
926 try:
935 try:
927 magic_args = args[1]
936 magic_args = args[1]
928 except IndexError:
937 except IndexError:
929 magic_args = ''
938 magic_args = ''
930 fn = getattr(self,'magic_'+magic_name,None)
939 fn = getattr(self,'magic_'+magic_name,None)
931 if fn is None:
940 if fn is None:
932 error("Magic function `%s` not found." % magic_name)
941 error("Magic function `%s` not found." % magic_name)
933 else:
942 else:
934 magic_args = self.var_expand(magic_args,1)
943 magic_args = self.var_expand(magic_args,1)
935 return fn(magic_args)
944 return fn(magic_args)
936
945
937 def ipalias(self,arg_s):
946 def ipalias(self,arg_s):
938 """Call an alias by name.
947 """Call an alias by name.
939
948
940 Input: a string containing the name of the alias to call and any
949 Input: a string containing the name of the alias to call and any
941 additional arguments to be passed to the magic.
950 additional arguments to be passed to the magic.
942
951
943 ipalias('name -opt foo bar') is equivalent to typing at the ipython
952 ipalias('name -opt foo bar') is equivalent to typing at the ipython
944 prompt:
953 prompt:
945
954
946 In[1]: name -opt foo bar
955 In[1]: name -opt foo bar
947
956
948 To call an alias without arguments, simply use ipalias('name').
957 To call an alias without arguments, simply use ipalias('name').
949
958
950 This provides a proper Python function to call IPython's aliases in any
959 This provides a proper Python function to call IPython's aliases in any
951 valid Python code you can type at the interpreter, including loops and
960 valid Python code you can type at the interpreter, including loops and
952 compound statements. It is added by IPython to the Python builtin
961 compound statements. It is added by IPython to the Python builtin
953 namespace upon initialization."""
962 namespace upon initialization."""
954
963
955 args = arg_s.split(' ',1)
964 args = arg_s.split(' ',1)
956 alias_name = args[0]
965 alias_name = args[0]
957 try:
966 try:
958 alias_args = args[1]
967 alias_args = args[1]
959 except IndexError:
968 except IndexError:
960 alias_args = ''
969 alias_args = ''
961 if alias_name in self.alias_table:
970 if alias_name in self.alias_table:
962 self.call_alias(alias_name,alias_args)
971 self.call_alias(alias_name,alias_args)
963 else:
972 else:
964 error("Alias `%s` not found." % alias_name)
973 error("Alias `%s` not found." % alias_name)
965
974
966 def ipsystem(self,arg_s):
975 def ipsystem(self,arg_s):
967 """Make a system call, using IPython."""
976 """Make a system call, using IPython."""
968
977
969 self.system(arg_s)
978 self.system(arg_s)
970
979
971 def complete(self,text):
980 def complete(self,text):
972 """Return a sorted list of all possible completions on text.
981 """Return a sorted list of all possible completions on text.
973
982
974 Inputs:
983 Inputs:
975
984
976 - text: a string of text to be completed on.
985 - text: a string of text to be completed on.
977
986
978 This is a wrapper around the completion mechanism, similar to what
987 This is a wrapper around the completion mechanism, similar to what
979 readline does at the command line when the TAB key is hit. By
988 readline does at the command line when the TAB key is hit. By
980 exposing it as a method, it can be used by other non-readline
989 exposing it as a method, it can be used by other non-readline
981 environments (such as GUIs) for text completion.
990 environments (such as GUIs) for text completion.
982
991
983 Simple usage example:
992 Simple usage example:
984
993
985 In [1]: x = 'hello'
994 In [1]: x = 'hello'
986
995
987 In [2]: __IP.complete('x.l')
996 In [2]: __IP.complete('x.l')
988 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
997 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
989
998
990 complete = self.Completer.complete
999 complete = self.Completer.complete
991 state = 0
1000 state = 0
992 # use a dict so we get unique keys, since ipyhton's multiple
1001 # use a dict so we get unique keys, since ipyhton's multiple
993 # completers can return duplicates.
1002 # completers can return duplicates.
994 comps = {}
1003 comps = {}
995 while True:
1004 while True:
996 newcomp = complete(text,state)
1005 newcomp = complete(text,state)
997 if newcomp is None:
1006 if newcomp is None:
998 break
1007 break
999 comps[newcomp] = 1
1008 comps[newcomp] = 1
1000 state += 1
1009 state += 1
1001 outcomps = comps.keys()
1010 outcomps = comps.keys()
1002 outcomps.sort()
1011 outcomps.sort()
1003 return outcomps
1012 return outcomps
1004
1013
1005 def set_completer_frame(self, frame=None):
1014 def set_completer_frame(self, frame=None):
1006 if frame:
1015 if frame:
1007 self.Completer.namespace = frame.f_locals
1016 self.Completer.namespace = frame.f_locals
1008 self.Completer.global_namespace = frame.f_globals
1017 self.Completer.global_namespace = frame.f_globals
1009 else:
1018 else:
1010 self.Completer.namespace = self.user_ns
1019 self.Completer.namespace = self.user_ns
1011 self.Completer.global_namespace = self.user_global_ns
1020 self.Completer.global_namespace = self.user_global_ns
1012
1021
1013 def init_auto_alias(self):
1022 def init_auto_alias(self):
1014 """Define some aliases automatically.
1023 """Define some aliases automatically.
1015
1024
1016 These are ALL parameter-less aliases"""
1025 These are ALL parameter-less aliases"""
1017
1026
1018 for alias,cmd in self.auto_alias:
1027 for alias,cmd in self.auto_alias:
1019 self.alias_table[alias] = (0,cmd)
1028 self.alias_table[alias] = (0,cmd)
1020
1029
1021 def alias_table_validate(self,verbose=0):
1030 def alias_table_validate(self,verbose=0):
1022 """Update information about the alias table.
1031 """Update information about the alias table.
1023
1032
1024 In particular, make sure no Python keywords/builtins are in it."""
1033 In particular, make sure no Python keywords/builtins are in it."""
1025
1034
1026 no_alias = self.no_alias
1035 no_alias = self.no_alias
1027 for k in self.alias_table.keys():
1036 for k in self.alias_table.keys():
1028 if k in no_alias:
1037 if k in no_alias:
1029 del self.alias_table[k]
1038 del self.alias_table[k]
1030 if verbose:
1039 if verbose:
1031 print ("Deleting alias <%s>, it's a Python "
1040 print ("Deleting alias <%s>, it's a Python "
1032 "keyword or builtin." % k)
1041 "keyword or builtin." % k)
1033
1042
1034 def set_autoindent(self,value=None):
1043 def set_autoindent(self,value=None):
1035 """Set the autoindent flag, checking for readline support.
1044 """Set the autoindent flag, checking for readline support.
1036
1045
1037 If called with no arguments, it acts as a toggle."""
1046 If called with no arguments, it acts as a toggle."""
1038
1047
1039 if not self.has_readline:
1048 if not self.has_readline:
1040 if os.name == 'posix':
1049 if os.name == 'posix':
1041 warn("The auto-indent feature requires the readline library")
1050 warn("The auto-indent feature requires the readline library")
1042 self.autoindent = 0
1051 self.autoindent = 0
1043 return
1052 return
1044 if value is None:
1053 if value is None:
1045 self.autoindent = not self.autoindent
1054 self.autoindent = not self.autoindent
1046 else:
1055 else:
1047 self.autoindent = value
1056 self.autoindent = value
1048
1057
1049 def rc_set_toggle(self,rc_field,value=None):
1058 def rc_set_toggle(self,rc_field,value=None):
1050 """Set or toggle a field in IPython's rc config. structure.
1059 """Set or toggle a field in IPython's rc config. structure.
1051
1060
1052 If called with no arguments, it acts as a toggle.
1061 If called with no arguments, it acts as a toggle.
1053
1062
1054 If called with a non-existent field, the resulting AttributeError
1063 If called with a non-existent field, the resulting AttributeError
1055 exception will propagate out."""
1064 exception will propagate out."""
1056
1065
1057 rc_val = getattr(self.rc,rc_field)
1066 rc_val = getattr(self.rc,rc_field)
1058 if value is None:
1067 if value is None:
1059 value = not rc_val
1068 value = not rc_val
1060 setattr(self.rc,rc_field,value)
1069 setattr(self.rc,rc_field,value)
1061
1070
1062 def user_setup(self,ipythondir,rc_suffix,mode='install'):
1071 def user_setup(self,ipythondir,rc_suffix,mode='install'):
1063 """Install the user configuration directory.
1072 """Install the user configuration directory.
1064
1073
1065 Can be called when running for the first time or to upgrade the user's
1074 Can be called when running for the first time or to upgrade the user's
1066 .ipython/ directory with the mode parameter. Valid modes are 'install'
1075 .ipython/ directory with the mode parameter. Valid modes are 'install'
1067 and 'upgrade'."""
1076 and 'upgrade'."""
1068
1077
1069 def wait():
1078 def wait():
1070 try:
1079 try:
1071 raw_input("Please press <RETURN> to start IPython.")
1080 raw_input("Please press <RETURN> to start IPython.")
1072 except EOFError:
1081 except EOFError:
1073 print >> Term.cout
1082 print >> Term.cout
1074 print '*'*70
1083 print '*'*70
1075
1084
1076 cwd = os.getcwd() # remember where we started
1085 cwd = os.getcwd() # remember where we started
1077 glb = glob.glob
1086 glb = glob.glob
1078 print '*'*70
1087 print '*'*70
1079 if mode == 'install':
1088 if mode == 'install':
1080 print \
1089 print \
1081 """Welcome to IPython. I will try to create a personal configuration directory
1090 """Welcome to IPython. I will try to create a personal configuration directory
1082 where you can customize many aspects of IPython's functionality in:\n"""
1091 where you can customize many aspects of IPython's functionality in:\n"""
1083 else:
1092 else:
1084 print 'I am going to upgrade your configuration in:'
1093 print 'I am going to upgrade your configuration in:'
1085
1094
1086 print ipythondir
1095 print ipythondir
1087
1096
1088 rcdirend = os.path.join('IPython','UserConfig')
1097 rcdirend = os.path.join('IPython','UserConfig')
1089 cfg = lambda d: os.path.join(d,rcdirend)
1098 cfg = lambda d: os.path.join(d,rcdirend)
1090 try:
1099 try:
1091 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
1100 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
1092 except IOError:
1101 except IOError:
1093 warning = """
1102 warning = """
1094 Installation error. IPython's directory was not found.
1103 Installation error. IPython's directory was not found.
1095
1104
1096 Check the following:
1105 Check the following:
1097
1106
1098 The ipython/IPython directory should be in a directory belonging to your
1107 The ipython/IPython directory should be in a directory belonging to your
1099 PYTHONPATH environment variable (that is, it should be in a directory
1108 PYTHONPATH environment variable (that is, it should be in a directory
1100 belonging to sys.path). You can copy it explicitly there or just link to it.
1109 belonging to sys.path). You can copy it explicitly there or just link to it.
1101
1110
1102 IPython will proceed with builtin defaults.
1111 IPython will proceed with builtin defaults.
1103 """
1112 """
1104 warn(warning)
1113 warn(warning)
1105 wait()
1114 wait()
1106 return
1115 return
1107
1116
1108 if mode == 'install':
1117 if mode == 'install':
1109 try:
1118 try:
1110 shutil.copytree(rcdir,ipythondir)
1119 shutil.copytree(rcdir,ipythondir)
1111 os.chdir(ipythondir)
1120 os.chdir(ipythondir)
1112 rc_files = glb("ipythonrc*")
1121 rc_files = glb("ipythonrc*")
1113 for rc_file in rc_files:
1122 for rc_file in rc_files:
1114 os.rename(rc_file,rc_file+rc_suffix)
1123 os.rename(rc_file,rc_file+rc_suffix)
1115 except:
1124 except:
1116 warning = """
1125 warning = """
1117
1126
1118 There was a problem with the installation:
1127 There was a problem with the installation:
1119 %s
1128 %s
1120 Try to correct it or contact the developers if you think it's a bug.
1129 Try to correct it or contact the developers if you think it's a bug.
1121 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1130 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1122 warn(warning)
1131 warn(warning)
1123 wait()
1132 wait()
1124 return
1133 return
1125
1134
1126 elif mode == 'upgrade':
1135 elif mode == 'upgrade':
1127 try:
1136 try:
1128 os.chdir(ipythondir)
1137 os.chdir(ipythondir)
1129 except:
1138 except:
1130 print """
1139 print """
1131 Can not upgrade: changing to directory %s failed. Details:
1140 Can not upgrade: changing to directory %s failed. Details:
1132 %s
1141 %s
1133 """ % (ipythondir,sys.exc_info()[1])
1142 """ % (ipythondir,sys.exc_info()[1])
1134 wait()
1143 wait()
1135 return
1144 return
1136 else:
1145 else:
1137 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1146 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1138 for new_full_path in sources:
1147 for new_full_path in sources:
1139 new_filename = os.path.basename(new_full_path)
1148 new_filename = os.path.basename(new_full_path)
1140 if new_filename.startswith('ipythonrc'):
1149 if new_filename.startswith('ipythonrc'):
1141 new_filename = new_filename + rc_suffix
1150 new_filename = new_filename + rc_suffix
1142 # The config directory should only contain files, skip any
1151 # The config directory should only contain files, skip any
1143 # directories which may be there (like CVS)
1152 # directories which may be there (like CVS)
1144 if os.path.isdir(new_full_path):
1153 if os.path.isdir(new_full_path):
1145 continue
1154 continue
1146 if os.path.exists(new_filename):
1155 if os.path.exists(new_filename):
1147 old_file = new_filename+'.old'
1156 old_file = new_filename+'.old'
1148 if os.path.exists(old_file):
1157 if os.path.exists(old_file):
1149 os.remove(old_file)
1158 os.remove(old_file)
1150 os.rename(new_filename,old_file)
1159 os.rename(new_filename,old_file)
1151 shutil.copy(new_full_path,new_filename)
1160 shutil.copy(new_full_path,new_filename)
1152 else:
1161 else:
1153 raise ValueError,'unrecognized mode for install:',`mode`
1162 raise ValueError,'unrecognized mode for install:',`mode`
1154
1163
1155 # Fix line-endings to those native to each platform in the config
1164 # Fix line-endings to those native to each platform in the config
1156 # directory.
1165 # directory.
1157 try:
1166 try:
1158 os.chdir(ipythondir)
1167 os.chdir(ipythondir)
1159 except:
1168 except:
1160 print """
1169 print """
1161 Problem: changing to directory %s failed.
1170 Problem: changing to directory %s failed.
1162 Details:
1171 Details:
1163 %s
1172 %s
1164
1173
1165 Some configuration files may have incorrect line endings. This should not
1174 Some configuration files may have incorrect line endings. This should not
1166 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1175 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1167 wait()
1176 wait()
1168 else:
1177 else:
1169 for fname in glb('ipythonrc*'):
1178 for fname in glb('ipythonrc*'):
1170 try:
1179 try:
1171 native_line_ends(fname,backup=0)
1180 native_line_ends(fname,backup=0)
1172 except IOError:
1181 except IOError:
1173 pass
1182 pass
1174
1183
1175 if mode == 'install':
1184 if mode == 'install':
1176 print """
1185 print """
1177 Successful installation!
1186 Successful installation!
1178
1187
1179 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1188 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1180 IPython manual (there are both HTML and PDF versions supplied with the
1189 IPython manual (there are both HTML and PDF versions supplied with the
1181 distribution) to make sure that your system environment is properly configured
1190 distribution) to make sure that your system environment is properly configured
1182 to take advantage of IPython's features.
1191 to take advantage of IPython's features.
1183
1192
1184 Important note: the configuration system has changed! The old system is
1193 Important note: the configuration system has changed! The old system is
1185 still in place, but its setting may be partly overridden by the settings in
1194 still in place, but its setting may be partly overridden by the settings in
1186 "~/.ipython/ipy_user_conf.py" config file. Please take a look at the file
1195 "~/.ipython/ipy_user_conf.py" config file. Please take a look at the file
1187 if some of the new settings bother you.
1196 if some of the new settings bother you.
1188
1197
1189 """
1198 """
1190 else:
1199 else:
1191 print """
1200 print """
1192 Successful upgrade!
1201 Successful upgrade!
1193
1202
1194 All files in your directory:
1203 All files in your directory:
1195 %(ipythondir)s
1204 %(ipythondir)s
1196 which would have been overwritten by the upgrade were backed up with a .old
1205 which would have been overwritten by the upgrade were backed up with a .old
1197 extension. If you had made particular customizations in those files you may
1206 extension. If you had made particular customizations in those files you may
1198 want to merge them back into the new files.""" % locals()
1207 want to merge them back into the new files.""" % locals()
1199 wait()
1208 wait()
1200 os.chdir(cwd)
1209 os.chdir(cwd)
1201 # end user_setup()
1210 # end user_setup()
1202
1211
1203 def atexit_operations(self):
1212 def atexit_operations(self):
1204 """This will be executed at the time of exit.
1213 """This will be executed at the time of exit.
1205
1214
1206 Saving of persistent data should be performed here. """
1215 Saving of persistent data should be performed here. """
1207
1216
1208 #print '*** IPython exit cleanup ***' # dbg
1217 #print '*** IPython exit cleanup ***' # dbg
1209 # input history
1218 # input history
1210 self.savehist()
1219 self.savehist()
1211
1220
1212 # Cleanup all tempfiles left around
1221 # Cleanup all tempfiles left around
1213 for tfile in self.tempfiles:
1222 for tfile in self.tempfiles:
1214 try:
1223 try:
1215 os.unlink(tfile)
1224 os.unlink(tfile)
1216 except OSError:
1225 except OSError:
1217 pass
1226 pass
1218
1227
1219 # save the "persistent data" catch-all dictionary
1228 # save the "persistent data" catch-all dictionary
1220 self.hooks.shutdown_hook()
1229 self.hooks.shutdown_hook()
1221
1230
1222 def savehist(self):
1231 def savehist(self):
1223 """Save input history to a file (via readline library)."""
1232 """Save input history to a file (via readline library)."""
1224 try:
1233 try:
1225 self.readline.write_history_file(self.histfile)
1234 self.readline.write_history_file(self.histfile)
1226 except:
1235 except:
1227 print 'Unable to save IPython command history to file: ' + \
1236 print 'Unable to save IPython command history to file: ' + \
1228 `self.histfile`
1237 `self.histfile`
1229
1238
1230 def history_saving_wrapper(self, func):
1239 def history_saving_wrapper(self, func):
1231 """ Wrap func for readline history saving
1240 """ Wrap func for readline history saving
1232
1241
1233 Convert func into callable that saves & restores
1242 Convert func into callable that saves & restores
1234 history around the call """
1243 history around the call """
1235
1244
1236 if not self.has_readline:
1245 if not self.has_readline:
1237 return func
1246 return func
1238
1247
1239 def wrapper():
1248 def wrapper():
1240 self.savehist()
1249 self.savehist()
1241 try:
1250 try:
1242 func()
1251 func()
1243 finally:
1252 finally:
1244 readline.read_history_file(self.histfile)
1253 readline.read_history_file(self.histfile)
1245 return wrapper
1254 return wrapper
1246
1255
1247
1256
1248 def pre_readline(self):
1257 def pre_readline(self):
1249 """readline hook to be used at the start of each line.
1258 """readline hook to be used at the start of each line.
1250
1259
1251 Currently it handles auto-indent only."""
1260 Currently it handles auto-indent only."""
1252
1261
1253 #debugx('self.indent_current_nsp','pre_readline:')
1262 #debugx('self.indent_current_nsp','pre_readline:')
1254 self.readline.insert_text(self.indent_current_str())
1263 self.readline.insert_text(self.indent_current_str())
1255
1264
1256 def init_readline(self):
1265 def init_readline(self):
1257 """Command history completion/saving/reloading."""
1266 """Command history completion/saving/reloading."""
1258
1267
1259 import IPython.rlineimpl as readline
1268 import IPython.rlineimpl as readline
1260 if not readline.have_readline:
1269 if not readline.have_readline:
1261 self.has_readline = 0
1270 self.has_readline = 0
1262 self.readline = None
1271 self.readline = None
1263 # no point in bugging windows users with this every time:
1272 # no point in bugging windows users with this every time:
1264 warn('Readline services not available on this platform.')
1273 warn('Readline services not available on this platform.')
1265 else:
1274 else:
1266 sys.modules['readline'] = readline
1275 sys.modules['readline'] = readline
1267 import atexit
1276 import atexit
1268 from IPython.completer import IPCompleter
1277 from IPython.completer import IPCompleter
1269 self.Completer = IPCompleter(self,
1278 self.Completer = IPCompleter(self,
1270 self.user_ns,
1279 self.user_ns,
1271 self.user_global_ns,
1280 self.user_global_ns,
1272 self.rc.readline_omit__names,
1281 self.rc.readline_omit__names,
1273 self.alias_table)
1282 self.alias_table)
1274 sdisp = self.strdispatchers.get('complete_command', StrDispatch())
1283 sdisp = self.strdispatchers.get('complete_command', StrDispatch())
1275 self.strdispatchers['complete_command'] = sdisp
1284 self.strdispatchers['complete_command'] = sdisp
1276 self.Completer.custom_completers = sdisp
1285 self.Completer.custom_completers = sdisp
1277 # Platform-specific configuration
1286 # Platform-specific configuration
1278 if os.name == 'nt':
1287 if os.name == 'nt':
1279 self.readline_startup_hook = readline.set_pre_input_hook
1288 self.readline_startup_hook = readline.set_pre_input_hook
1280 else:
1289 else:
1281 self.readline_startup_hook = readline.set_startup_hook
1290 self.readline_startup_hook = readline.set_startup_hook
1282
1291
1283 # Load user's initrc file (readline config)
1292 # Load user's initrc file (readline config)
1284 inputrc_name = os.environ.get('INPUTRC')
1293 inputrc_name = os.environ.get('INPUTRC')
1285 if inputrc_name is None:
1294 if inputrc_name is None:
1286 home_dir = get_home_dir()
1295 home_dir = get_home_dir()
1287 if home_dir is not None:
1296 if home_dir is not None:
1288 inputrc_name = os.path.join(home_dir,'.inputrc')
1297 inputrc_name = os.path.join(home_dir,'.inputrc')
1289 if os.path.isfile(inputrc_name):
1298 if os.path.isfile(inputrc_name):
1290 try:
1299 try:
1291 readline.read_init_file(inputrc_name)
1300 readline.read_init_file(inputrc_name)
1292 except:
1301 except:
1293 warn('Problems reading readline initialization file <%s>'
1302 warn('Problems reading readline initialization file <%s>'
1294 % inputrc_name)
1303 % inputrc_name)
1295
1304
1296 self.has_readline = 1
1305 self.has_readline = 1
1297 self.readline = readline
1306 self.readline = readline
1298 # save this in sys so embedded copies can restore it properly
1307 # save this in sys so embedded copies can restore it properly
1299 sys.ipcompleter = self.Completer.complete
1308 sys.ipcompleter = self.Completer.complete
1300 readline.set_completer(self.Completer.complete)
1309 readline.set_completer(self.Completer.complete)
1301
1310
1302 # Configure readline according to user's prefs
1311 # Configure readline according to user's prefs
1303 for rlcommand in self.rc.readline_parse_and_bind:
1312 for rlcommand in self.rc.readline_parse_and_bind:
1304 readline.parse_and_bind(rlcommand)
1313 readline.parse_and_bind(rlcommand)
1305
1314
1306 # remove some chars from the delimiters list
1315 # remove some chars from the delimiters list
1307 delims = readline.get_completer_delims()
1316 delims = readline.get_completer_delims()
1308 delims = delims.translate(string._idmap,
1317 delims = delims.translate(string._idmap,
1309 self.rc.readline_remove_delims)
1318 self.rc.readline_remove_delims)
1310 readline.set_completer_delims(delims)
1319 readline.set_completer_delims(delims)
1311 # otherwise we end up with a monster history after a while:
1320 # otherwise we end up with a monster history after a while:
1312 readline.set_history_length(1000)
1321 readline.set_history_length(1000)
1313 try:
1322 try:
1314 #print '*** Reading readline history' # dbg
1323 #print '*** Reading readline history' # dbg
1315 readline.read_history_file(self.histfile)
1324 readline.read_history_file(self.histfile)
1316 except IOError:
1325 except IOError:
1317 pass # It doesn't exist yet.
1326 pass # It doesn't exist yet.
1318
1327
1319 atexit.register(self.atexit_operations)
1328 atexit.register(self.atexit_operations)
1320 del atexit
1329 del atexit
1321
1330
1322 # Configure auto-indent for all platforms
1331 # Configure auto-indent for all platforms
1323 self.set_autoindent(self.rc.autoindent)
1332 self.set_autoindent(self.rc.autoindent)
1324
1333
1325 def ask_yes_no(self,prompt,default=True):
1334 def ask_yes_no(self,prompt,default=True):
1326 if self.rc.quiet:
1335 if self.rc.quiet:
1327 return True
1336 return True
1328 return ask_yes_no(prompt,default)
1337 return ask_yes_no(prompt,default)
1329
1338
1330 def _should_recompile(self,e):
1339 def _should_recompile(self,e):
1331 """Utility routine for edit_syntax_error"""
1340 """Utility routine for edit_syntax_error"""
1332
1341
1333 if e.filename in ('<ipython console>','<input>','<string>',
1342 if e.filename in ('<ipython console>','<input>','<string>',
1334 '<console>','<BackgroundJob compilation>',
1343 '<console>','<BackgroundJob compilation>',
1335 None):
1344 None):
1336
1345
1337 return False
1346 return False
1338 try:
1347 try:
1339 if (self.rc.autoedit_syntax and
1348 if (self.rc.autoedit_syntax and
1340 not self.ask_yes_no('Return to editor to correct syntax error? '
1349 not self.ask_yes_no('Return to editor to correct syntax error? '
1341 '[Y/n] ','y')):
1350 '[Y/n] ','y')):
1342 return False
1351 return False
1343 except EOFError:
1352 except EOFError:
1344 return False
1353 return False
1345
1354
1346 def int0(x):
1355 def int0(x):
1347 try:
1356 try:
1348 return int(x)
1357 return int(x)
1349 except TypeError:
1358 except TypeError:
1350 return 0
1359 return 0
1351 # always pass integer line and offset values to editor hook
1360 # always pass integer line and offset values to editor hook
1352 self.hooks.fix_error_editor(e.filename,
1361 self.hooks.fix_error_editor(e.filename,
1353 int0(e.lineno),int0(e.offset),e.msg)
1362 int0(e.lineno),int0(e.offset),e.msg)
1354 return True
1363 return True
1355
1364
1356 def edit_syntax_error(self):
1365 def edit_syntax_error(self):
1357 """The bottom half of the syntax error handler called in the main loop.
1366 """The bottom half of the syntax error handler called in the main loop.
1358
1367
1359 Loop until syntax error is fixed or user cancels.
1368 Loop until syntax error is fixed or user cancels.
1360 """
1369 """
1361
1370
1362 while self.SyntaxTB.last_syntax_error:
1371 while self.SyntaxTB.last_syntax_error:
1363 # copy and clear last_syntax_error
1372 # copy and clear last_syntax_error
1364 err = self.SyntaxTB.clear_err_state()
1373 err = self.SyntaxTB.clear_err_state()
1365 if not self._should_recompile(err):
1374 if not self._should_recompile(err):
1366 return
1375 return
1367 try:
1376 try:
1368 # may set last_syntax_error again if a SyntaxError is raised
1377 # may set last_syntax_error again if a SyntaxError is raised
1369 self.safe_execfile(err.filename,self.user_ns)
1378 self.safe_execfile(err.filename,self.user_ns)
1370 except:
1379 except:
1371 self.showtraceback()
1380 self.showtraceback()
1372 else:
1381 else:
1373 try:
1382 try:
1374 f = file(err.filename)
1383 f = file(err.filename)
1375 try:
1384 try:
1376 sys.displayhook(f.read())
1385 sys.displayhook(f.read())
1377 finally:
1386 finally:
1378 f.close()
1387 f.close()
1379 except:
1388 except:
1380 self.showtraceback()
1389 self.showtraceback()
1381
1390
1382 def showsyntaxerror(self, filename=None):
1391 def showsyntaxerror(self, filename=None):
1383 """Display the syntax error that just occurred.
1392 """Display the syntax error that just occurred.
1384
1393
1385 This doesn't display a stack trace because there isn't one.
1394 This doesn't display a stack trace because there isn't one.
1386
1395
1387 If a filename is given, it is stuffed in the exception instead
1396 If a filename is given, it is stuffed in the exception instead
1388 of what was there before (because Python's parser always uses
1397 of what was there before (because Python's parser always uses
1389 "<string>" when reading from a string).
1398 "<string>" when reading from a string).
1390 """
1399 """
1391 etype, value, last_traceback = sys.exc_info()
1400 etype, value, last_traceback = sys.exc_info()
1392
1401
1393 # See note about these variables in showtraceback() below
1402 # See note about these variables in showtraceback() below
1394 sys.last_type = etype
1403 sys.last_type = etype
1395 sys.last_value = value
1404 sys.last_value = value
1396 sys.last_traceback = last_traceback
1405 sys.last_traceback = last_traceback
1397
1406
1398 if filename and etype is SyntaxError:
1407 if filename and etype is SyntaxError:
1399 # Work hard to stuff the correct filename in the exception
1408 # Work hard to stuff the correct filename in the exception
1400 try:
1409 try:
1401 msg, (dummy_filename, lineno, offset, line) = value
1410 msg, (dummy_filename, lineno, offset, line) = value
1402 except:
1411 except:
1403 # Not the format we expect; leave it alone
1412 # Not the format we expect; leave it alone
1404 pass
1413 pass
1405 else:
1414 else:
1406 # Stuff in the right filename
1415 # Stuff in the right filename
1407 try:
1416 try:
1408 # Assume SyntaxError is a class exception
1417 # Assume SyntaxError is a class exception
1409 value = SyntaxError(msg, (filename, lineno, offset, line))
1418 value = SyntaxError(msg, (filename, lineno, offset, line))
1410 except:
1419 except:
1411 # If that failed, assume SyntaxError is a string
1420 # If that failed, assume SyntaxError is a string
1412 value = msg, (filename, lineno, offset, line)
1421 value = msg, (filename, lineno, offset, line)
1413 self.SyntaxTB(etype,value,[])
1422 self.SyntaxTB(etype,value,[])
1414
1423
1415 def debugger(self,force=False):
1424 def debugger(self,force=False):
1416 """Call the pydb/pdb debugger.
1425 """Call the pydb/pdb debugger.
1417
1426
1418 Keywords:
1427 Keywords:
1419
1428
1420 - force(False): by default, this routine checks the instance call_pdb
1429 - force(False): by default, this routine checks the instance call_pdb
1421 flag and does not actually invoke the debugger if the flag is false.
1430 flag and does not actually invoke the debugger if the flag is false.
1422 The 'force' option forces the debugger to activate even if the flag
1431 The 'force' option forces the debugger to activate even if the flag
1423 is false.
1432 is false.
1424 """
1433 """
1425
1434
1426 if not (force or self.call_pdb):
1435 if not (force or self.call_pdb):
1427 return
1436 return
1428
1437
1429 if not hasattr(sys,'last_traceback'):
1438 if not hasattr(sys,'last_traceback'):
1430 error('No traceback has been produced, nothing to debug.')
1439 error('No traceback has been produced, nothing to debug.')
1431 return
1440 return
1432
1441
1433 have_pydb = False
1442 have_pydb = False
1434 # use pydb if available
1443 # use pydb if available
1435 try:
1444 try:
1436 from pydb import pm
1445 from pydb import pm
1437 have_pydb = True
1446 have_pydb = True
1438 except ImportError:
1447 except ImportError:
1439 pass
1448 pass
1440 if not have_pydb:
1449 if not have_pydb:
1441 # fallback to our internal debugger
1450 # fallback to our internal debugger
1442 pm = lambda : self.InteractiveTB.debugger(force=True)
1451 pm = lambda : self.InteractiveTB.debugger(force=True)
1443 self.history_saving_wrapper(pm)()
1452 self.history_saving_wrapper(pm)()
1444
1453
1445 def showtraceback(self,exc_tuple = None,filename=None,tb_offset=None):
1454 def showtraceback(self,exc_tuple = None,filename=None,tb_offset=None):
1446 """Display the exception that just occurred.
1455 """Display the exception that just occurred.
1447
1456
1448 If nothing is known about the exception, this is the method which
1457 If nothing is known about the exception, this is the method which
1449 should be used throughout the code for presenting user tracebacks,
1458 should be used throughout the code for presenting user tracebacks,
1450 rather than directly invoking the InteractiveTB object.
1459 rather than directly invoking the InteractiveTB object.
1451
1460
1452 A specific showsyntaxerror() also exists, but this method can take
1461 A specific showsyntaxerror() also exists, but this method can take
1453 care of calling it if needed, so unless you are explicitly catching a
1462 care of calling it if needed, so unless you are explicitly catching a
1454 SyntaxError exception, don't try to analyze the stack manually and
1463 SyntaxError exception, don't try to analyze the stack manually and
1455 simply call this method."""
1464 simply call this method."""
1456
1465
1457 # Though this won't be called by syntax errors in the input line,
1466 # Though this won't be called by syntax errors in the input line,
1458 # there may be SyntaxError cases whith imported code.
1467 # there may be SyntaxError cases whith imported code.
1459 if exc_tuple is None:
1468 if exc_tuple is None:
1460 etype, value, tb = sys.exc_info()
1469 etype, value, tb = sys.exc_info()
1461 else:
1470 else:
1462 etype, value, tb = exc_tuple
1471 etype, value, tb = exc_tuple
1463
1472
1464 if etype is SyntaxError:
1473 if etype is SyntaxError:
1465 self.showsyntaxerror(filename)
1474 self.showsyntaxerror(filename)
1466 else:
1475 else:
1467 # WARNING: these variables are somewhat deprecated and not
1476 # WARNING: these variables are somewhat deprecated and not
1468 # necessarily safe to use in a threaded environment, but tools
1477 # necessarily safe to use in a threaded environment, but tools
1469 # like pdb depend on their existence, so let's set them. If we
1478 # like pdb depend on their existence, so let's set them. If we
1470 # find problems in the field, we'll need to revisit their use.
1479 # find problems in the field, we'll need to revisit their use.
1471 sys.last_type = etype
1480 sys.last_type = etype
1472 sys.last_value = value
1481 sys.last_value = value
1473 sys.last_traceback = tb
1482 sys.last_traceback = tb
1474
1483
1475 if etype in self.custom_exceptions:
1484 if etype in self.custom_exceptions:
1476 self.CustomTB(etype,value,tb)
1485 self.CustomTB(etype,value,tb)
1477 else:
1486 else:
1478 self.InteractiveTB(etype,value,tb,tb_offset=tb_offset)
1487 self.InteractiveTB(etype,value,tb,tb_offset=tb_offset)
1479 if self.InteractiveTB.call_pdb and self.has_readline:
1488 if self.InteractiveTB.call_pdb and self.has_readline:
1480 # pdb mucks up readline, fix it back
1489 # pdb mucks up readline, fix it back
1481 self.readline.set_completer(self.Completer.complete)
1490 self.readline.set_completer(self.Completer.complete)
1482
1491
1483 def mainloop(self,banner=None):
1492 def mainloop(self,banner=None):
1484 """Creates the local namespace and starts the mainloop.
1493 """Creates the local namespace and starts the mainloop.
1485
1494
1486 If an optional banner argument is given, it will override the
1495 If an optional banner argument is given, it will override the
1487 internally created default banner."""
1496 internally created default banner."""
1488
1497
1489 if self.rc.c: # Emulate Python's -c option
1498 if self.rc.c: # Emulate Python's -c option
1490 self.exec_init_cmd()
1499 self.exec_init_cmd()
1491 if banner is None:
1500 if banner is None:
1492 if not self.rc.banner:
1501 if not self.rc.banner:
1493 banner = ''
1502 banner = ''
1494 # banner is string? Use it directly!
1503 # banner is string? Use it directly!
1495 elif isinstance(self.rc.banner,basestring):
1504 elif isinstance(self.rc.banner,basestring):
1496 banner = self.rc.banner
1505 banner = self.rc.banner
1497 else:
1506 else:
1498 banner = self.BANNER+self.banner2
1507 banner = self.BANNER+self.banner2
1499
1508
1500 self.interact(banner)
1509 self.interact(banner)
1501
1510
1502 def exec_init_cmd(self):
1511 def exec_init_cmd(self):
1503 """Execute a command given at the command line.
1512 """Execute a command given at the command line.
1504
1513
1505 This emulates Python's -c option."""
1514 This emulates Python's -c option."""
1506
1515
1507 #sys.argv = ['-c']
1516 #sys.argv = ['-c']
1508 self.push(self.rc.c)
1517 self.push(self.rc.c)
1509
1518
1510 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1519 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1511 """Embeds IPython into a running python program.
1520 """Embeds IPython into a running python program.
1512
1521
1513 Input:
1522 Input:
1514
1523
1515 - header: An optional header message can be specified.
1524 - header: An optional header message can be specified.
1516
1525
1517 - local_ns, global_ns: working namespaces. If given as None, the
1526 - local_ns, global_ns: working namespaces. If given as None, the
1518 IPython-initialized one is updated with __main__.__dict__, so that
1527 IPython-initialized one is updated with __main__.__dict__, so that
1519 program variables become visible but user-specific configuration
1528 program variables become visible but user-specific configuration
1520 remains possible.
1529 remains possible.
1521
1530
1522 - stack_depth: specifies how many levels in the stack to go to
1531 - stack_depth: specifies how many levels in the stack to go to
1523 looking for namespaces (when local_ns and global_ns are None). This
1532 looking for namespaces (when local_ns and global_ns are None). This
1524 allows an intermediate caller to make sure that this function gets
1533 allows an intermediate caller to make sure that this function gets
1525 the namespace from the intended level in the stack. By default (0)
1534 the namespace from the intended level in the stack. By default (0)
1526 it will get its locals and globals from the immediate caller.
1535 it will get its locals and globals from the immediate caller.
1527
1536
1528 Warning: it's possible to use this in a program which is being run by
1537 Warning: it's possible to use this in a program which is being run by
1529 IPython itself (via %run), but some funny things will happen (a few
1538 IPython itself (via %run), but some funny things will happen (a few
1530 globals get overwritten). In the future this will be cleaned up, as
1539 globals get overwritten). In the future this will be cleaned up, as
1531 there is no fundamental reason why it can't work perfectly."""
1540 there is no fundamental reason why it can't work perfectly."""
1532
1541
1533 # Get locals and globals from caller
1542 # Get locals and globals from caller
1534 if local_ns is None or global_ns is None:
1543 if local_ns is None or global_ns is None:
1535 call_frame = sys._getframe(stack_depth).f_back
1544 call_frame = sys._getframe(stack_depth).f_back
1536
1545
1537 if local_ns is None:
1546 if local_ns is None:
1538 local_ns = call_frame.f_locals
1547 local_ns = call_frame.f_locals
1539 if global_ns is None:
1548 if global_ns is None:
1540 global_ns = call_frame.f_globals
1549 global_ns = call_frame.f_globals
1541
1550
1542 # Update namespaces and fire up interpreter
1551 # Update namespaces and fire up interpreter
1543
1552
1544 # The global one is easy, we can just throw it in
1553 # The global one is easy, we can just throw it in
1545 self.user_global_ns = global_ns
1554 self.user_global_ns = global_ns
1546
1555
1547 # but the user/local one is tricky: ipython needs it to store internal
1556 # but the user/local one is tricky: ipython needs it to store internal
1548 # data, but we also need the locals. We'll copy locals in the user
1557 # data, but we also need the locals. We'll copy locals in the user
1549 # one, but will track what got copied so we can delete them at exit.
1558 # one, but will track what got copied so we can delete them at exit.
1550 # This is so that a later embedded call doesn't see locals from a
1559 # This is so that a later embedded call doesn't see locals from a
1551 # previous call (which most likely existed in a separate scope).
1560 # previous call (which most likely existed in a separate scope).
1552 local_varnames = local_ns.keys()
1561 local_varnames = local_ns.keys()
1553 self.user_ns.update(local_ns)
1562 self.user_ns.update(local_ns)
1554
1563
1555 # Patch for global embedding to make sure that things don't overwrite
1564 # Patch for global embedding to make sure that things don't overwrite
1556 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1565 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1557 # FIXME. Test this a bit more carefully (the if.. is new)
1566 # FIXME. Test this a bit more carefully (the if.. is new)
1558 if local_ns is None and global_ns is None:
1567 if local_ns is None and global_ns is None:
1559 self.user_global_ns.update(__main__.__dict__)
1568 self.user_global_ns.update(__main__.__dict__)
1560
1569
1561 # make sure the tab-completer has the correct frame information, so it
1570 # make sure the tab-completer has the correct frame information, so it
1562 # actually completes using the frame's locals/globals
1571 # actually completes using the frame's locals/globals
1563 self.set_completer_frame()
1572 self.set_completer_frame()
1564
1573
1565 # before activating the interactive mode, we need to make sure that
1574 # before activating the interactive mode, we need to make sure that
1566 # all names in the builtin namespace needed by ipython point to
1575 # all names in the builtin namespace needed by ipython point to
1567 # ourselves, and not to other instances.
1576 # ourselves, and not to other instances.
1568 self.add_builtins()
1577 self.add_builtins()
1569
1578
1570 self.interact(header)
1579 self.interact(header)
1571
1580
1572 # now, purge out the user namespace from anything we might have added
1581 # now, purge out the user namespace from anything we might have added
1573 # from the caller's local namespace
1582 # from the caller's local namespace
1574 delvar = self.user_ns.pop
1583 delvar = self.user_ns.pop
1575 for var in local_varnames:
1584 for var in local_varnames:
1576 delvar(var,None)
1585 delvar(var,None)
1577 # and clean builtins we may have overridden
1586 # and clean builtins we may have overridden
1578 self.clean_builtins()
1587 self.clean_builtins()
1579
1588
1580 def interact(self, banner=None):
1589 def interact(self, banner=None):
1581 """Closely emulate the interactive Python console.
1590 """Closely emulate the interactive Python console.
1582
1591
1583 The optional banner argument specify the banner to print
1592 The optional banner argument specify the banner to print
1584 before the first interaction; by default it prints a banner
1593 before the first interaction; by default it prints a banner
1585 similar to the one printed by the real Python interpreter,
1594 similar to the one printed by the real Python interpreter,
1586 followed by the current class name in parentheses (so as not
1595 followed by the current class name in parentheses (so as not
1587 to confuse this with the real interpreter -- since it's so
1596 to confuse this with the real interpreter -- since it's so
1588 close!).
1597 close!).
1589
1598
1590 """
1599 """
1591
1600
1592 if self.exit_now:
1601 if self.exit_now:
1593 # batch run -> do not interact
1602 # batch run -> do not interact
1594 return
1603 return
1595 cprt = 'Type "copyright", "credits" or "license" for more information.'
1604 cprt = 'Type "copyright", "credits" or "license" for more information.'
1596 if banner is None:
1605 if banner is None:
1597 self.write("Python %s on %s\n%s\n(%s)\n" %
1606 self.write("Python %s on %s\n%s\n(%s)\n" %
1598 (sys.version, sys.platform, cprt,
1607 (sys.version, sys.platform, cprt,
1599 self.__class__.__name__))
1608 self.__class__.__name__))
1600 else:
1609 else:
1601 self.write(banner)
1610 self.write(banner)
1602
1611
1603 more = 0
1612 more = 0
1604
1613
1605 # Mark activity in the builtins
1614 # Mark activity in the builtins
1606 __builtin__.__dict__['__IPYTHON__active'] += 1
1615 __builtin__.__dict__['__IPYTHON__active'] += 1
1607
1616
1608 # exit_now is set by a call to %Exit or %Quit
1617 # exit_now is set by a call to %Exit or %Quit
1609 while not self.exit_now:
1618 while not self.exit_now:
1610 if more:
1619 if more:
1611 prompt = self.hooks.generate_prompt(True)
1620 prompt = self.hooks.generate_prompt(True)
1612 if self.autoindent:
1621 if self.autoindent:
1613 self.readline_startup_hook(self.pre_readline)
1622 self.readline_startup_hook(self.pre_readline)
1614 else:
1623 else:
1615 prompt = self.hooks.generate_prompt(False)
1624 prompt = self.hooks.generate_prompt(False)
1616 try:
1625 try:
1617 line = self.raw_input(prompt,more)
1626 line = self.raw_input(prompt,more)
1618 if self.exit_now:
1627 if self.exit_now:
1619 # quick exit on sys.std[in|out] close
1628 # quick exit on sys.std[in|out] close
1620 break
1629 break
1621 if self.autoindent:
1630 if self.autoindent:
1622 self.readline_startup_hook(None)
1631 self.readline_startup_hook(None)
1623 except KeyboardInterrupt:
1632 except KeyboardInterrupt:
1624 self.write('\nKeyboardInterrupt\n')
1633 self.write('\nKeyboardInterrupt\n')
1625 self.resetbuffer()
1634 self.resetbuffer()
1626 # keep cache in sync with the prompt counter:
1635 # keep cache in sync with the prompt counter:
1627 self.outputcache.prompt_count -= 1
1636 self.outputcache.prompt_count -= 1
1628
1637
1629 if self.autoindent:
1638 if self.autoindent:
1630 self.indent_current_nsp = 0
1639 self.indent_current_nsp = 0
1631 more = 0
1640 more = 0
1632 except EOFError:
1641 except EOFError:
1633 if self.autoindent:
1642 if self.autoindent:
1634 self.readline_startup_hook(None)
1643 self.readline_startup_hook(None)
1635 self.write('\n')
1644 self.write('\n')
1636 self.exit()
1645 self.exit()
1637 except bdb.BdbQuit:
1646 except bdb.BdbQuit:
1638 warn('The Python debugger has exited with a BdbQuit exception.\n'
1647 warn('The Python debugger has exited with a BdbQuit exception.\n'
1639 'Because of how pdb handles the stack, it is impossible\n'
1648 'Because of how pdb handles the stack, it is impossible\n'
1640 'for IPython to properly format this particular exception.\n'
1649 'for IPython to properly format this particular exception.\n'
1641 'IPython will resume normal operation.')
1650 'IPython will resume normal operation.')
1642 except:
1651 except:
1643 # exceptions here are VERY RARE, but they can be triggered
1652 # exceptions here are VERY RARE, but they can be triggered
1644 # asynchronously by signal handlers, for example.
1653 # asynchronously by signal handlers, for example.
1645 self.showtraceback()
1654 self.showtraceback()
1646 else:
1655 else:
1647 more = self.push(line)
1656 more = self.push(line)
1648 if (self.SyntaxTB.last_syntax_error and
1657 if (self.SyntaxTB.last_syntax_error and
1649 self.rc.autoedit_syntax):
1658 self.rc.autoedit_syntax):
1650 self.edit_syntax_error()
1659 self.edit_syntax_error()
1651
1660
1652 # We are off again...
1661 # We are off again...
1653 __builtin__.__dict__['__IPYTHON__active'] -= 1
1662 __builtin__.__dict__['__IPYTHON__active'] -= 1
1654
1663
1655 def excepthook(self, etype, value, tb):
1664 def excepthook(self, etype, value, tb):
1656 """One more defense for GUI apps that call sys.excepthook.
1665 """One more defense for GUI apps that call sys.excepthook.
1657
1666
1658 GUI frameworks like wxPython trap exceptions and call
1667 GUI frameworks like wxPython trap exceptions and call
1659 sys.excepthook themselves. I guess this is a feature that
1668 sys.excepthook themselves. I guess this is a feature that
1660 enables them to keep running after exceptions that would
1669 enables them to keep running after exceptions that would
1661 otherwise kill their mainloop. This is a bother for IPython
1670 otherwise kill their mainloop. This is a bother for IPython
1662 which excepts to catch all of the program exceptions with a try:
1671 which excepts to catch all of the program exceptions with a try:
1663 except: statement.
1672 except: statement.
1664
1673
1665 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1674 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1666 any app directly invokes sys.excepthook, it will look to the user like
1675 any app directly invokes sys.excepthook, it will look to the user like
1667 IPython crashed. In order to work around this, we can disable the
1676 IPython crashed. In order to work around this, we can disable the
1668 CrashHandler and replace it with this excepthook instead, which prints a
1677 CrashHandler and replace it with this excepthook instead, which prints a
1669 regular traceback using our InteractiveTB. In this fashion, apps which
1678 regular traceback using our InteractiveTB. In this fashion, apps which
1670 call sys.excepthook will generate a regular-looking exception from
1679 call sys.excepthook will generate a regular-looking exception from
1671 IPython, and the CrashHandler will only be triggered by real IPython
1680 IPython, and the CrashHandler will only be triggered by real IPython
1672 crashes.
1681 crashes.
1673
1682
1674 This hook should be used sparingly, only in places which are not likely
1683 This hook should be used sparingly, only in places which are not likely
1675 to be true IPython errors.
1684 to be true IPython errors.
1676 """
1685 """
1677 self.showtraceback((etype,value,tb),tb_offset=0)
1686 self.showtraceback((etype,value,tb),tb_offset=0)
1678
1687
1679 def expand_aliases(self,fn,rest):
1688 def expand_aliases(self,fn,rest):
1680 """ Expand multiple levels of aliases:
1689 """ Expand multiple levels of aliases:
1681
1690
1682 if:
1691 if:
1683
1692
1684 alias foo bar /tmp
1693 alias foo bar /tmp
1685 alias baz foo
1694 alias baz foo
1686
1695
1687 then:
1696 then:
1688
1697
1689 baz huhhahhei -> bar /tmp huhhahhei
1698 baz huhhahhei -> bar /tmp huhhahhei
1690
1699
1691 """
1700 """
1692 line = fn + " " + rest
1701 line = fn + " " + rest
1693
1702
1694 done = Set()
1703 done = Set()
1695 while 1:
1704 while 1:
1696 pre,fn,rest = self.split_user_input(line)
1705 pre,fn,rest = self.split_user_input(line)
1697 if fn in self.alias_table:
1706 if fn in self.alias_table:
1698 if fn in done:
1707 if fn in done:
1699 warn("Cyclic alias definition, repeated '%s'" % fn)
1708 warn("Cyclic alias definition, repeated '%s'" % fn)
1700 return ""
1709 return ""
1701 done.add(fn)
1710 done.add(fn)
1702
1711
1703 l2 = self.transform_alias(fn,rest)
1712 l2 = self.transform_alias(fn,rest)
1704 # dir -> dir
1713 # dir -> dir
1705 # print "alias",line, "->",l2 #dbg
1714 # print "alias",line, "->",l2 #dbg
1706 if l2 == line:
1715 if l2 == line:
1707 break
1716 break
1708 # ls -> ls -F should not recurse forever
1717 # ls -> ls -F should not recurse forever
1709 if l2.split(None,1)[0] == line.split(None,1)[0]:
1718 if l2.split(None,1)[0] == line.split(None,1)[0]:
1710 line = l2
1719 line = l2
1711 break
1720 break
1712
1721
1713 line=l2
1722 line=l2
1714
1723
1715
1724
1716 # print "al expand to",line #dbg
1725 # print "al expand to",line #dbg
1717 else:
1726 else:
1718 break
1727 break
1719
1728
1720 return line
1729 return line
1721
1730
1722 def transform_alias(self, alias,rest=''):
1731 def transform_alias(self, alias,rest=''):
1723 """ Transform alias to system command string.
1732 """ Transform alias to system command string.
1724 """
1733 """
1725 nargs,cmd = self.alias_table[alias]
1734 nargs,cmd = self.alias_table[alias]
1726 if ' ' in cmd and os.path.isfile(cmd):
1735 if ' ' in cmd and os.path.isfile(cmd):
1727 cmd = '"%s"' % cmd
1736 cmd = '"%s"' % cmd
1728
1737
1729 # Expand the %l special to be the user's input line
1738 # Expand the %l special to be the user's input line
1730 if cmd.find('%l') >= 0:
1739 if cmd.find('%l') >= 0:
1731 cmd = cmd.replace('%l',rest)
1740 cmd = cmd.replace('%l',rest)
1732 rest = ''
1741 rest = ''
1733 if nargs==0:
1742 if nargs==0:
1734 # Simple, argument-less aliases
1743 # Simple, argument-less aliases
1735 cmd = '%s %s' % (cmd,rest)
1744 cmd = '%s %s' % (cmd,rest)
1736 else:
1745 else:
1737 # Handle aliases with positional arguments
1746 # Handle aliases with positional arguments
1738 args = rest.split(None,nargs)
1747 args = rest.split(None,nargs)
1739 if len(args)< nargs:
1748 if len(args)< nargs:
1740 error('Alias <%s> requires %s arguments, %s given.' %
1749 error('Alias <%s> requires %s arguments, %s given.' %
1741 (alias,nargs,len(args)))
1750 (alias,nargs,len(args)))
1742 return None
1751 return None
1743 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1752 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1744 # Now call the macro, evaluating in the user's namespace
1753 # Now call the macro, evaluating in the user's namespace
1745 #print 'new command: <%r>' % cmd # dbg
1754 #print 'new command: <%r>' % cmd # dbg
1746 return cmd
1755 return cmd
1747
1756
1748 def call_alias(self,alias,rest=''):
1757 def call_alias(self,alias,rest=''):
1749 """Call an alias given its name and the rest of the line.
1758 """Call an alias given its name and the rest of the line.
1750
1759
1751 This is only used to provide backwards compatibility for users of
1760 This is only used to provide backwards compatibility for users of
1752 ipalias(), use of which is not recommended for anymore."""
1761 ipalias(), use of which is not recommended for anymore."""
1753
1762
1754 # Now call the macro, evaluating in the user's namespace
1763 # Now call the macro, evaluating in the user's namespace
1755 cmd = self.transform_alias(alias, rest)
1764 cmd = self.transform_alias(alias, rest)
1756 try:
1765 try:
1757 self.system(cmd)
1766 self.system(cmd)
1758 except:
1767 except:
1759 self.showtraceback()
1768 self.showtraceback()
1760
1769
1761 def indent_current_str(self):
1770 def indent_current_str(self):
1762 """return the current level of indentation as a string"""
1771 """return the current level of indentation as a string"""
1763 return self.indent_current_nsp * ' '
1772 return self.indent_current_nsp * ' '
1764
1773
1765 def autoindent_update(self,line):
1774 def autoindent_update(self,line):
1766 """Keep track of the indent level."""
1775 """Keep track of the indent level."""
1767
1776
1768 #debugx('line')
1777 #debugx('line')
1769 #debugx('self.indent_current_nsp')
1778 #debugx('self.indent_current_nsp')
1770 if self.autoindent:
1779 if self.autoindent:
1771 if line:
1780 if line:
1772 inisp = num_ini_spaces(line)
1781 inisp = num_ini_spaces(line)
1773 if inisp < self.indent_current_nsp:
1782 if inisp < self.indent_current_nsp:
1774 self.indent_current_nsp = inisp
1783 self.indent_current_nsp = inisp
1775
1784
1776 if line[-1] == ':':
1785 if line[-1] == ':':
1777 self.indent_current_nsp += 4
1786 self.indent_current_nsp += 4
1778 elif dedent_re.match(line):
1787 elif dedent_re.match(line):
1779 self.indent_current_nsp -= 4
1788 self.indent_current_nsp -= 4
1780 else:
1789 else:
1781 self.indent_current_nsp = 0
1790 self.indent_current_nsp = 0
1782
1791
1783 def runlines(self,lines):
1792 def runlines(self,lines):
1784 """Run a string of one or more lines of source.
1793 """Run a string of one or more lines of source.
1785
1794
1786 This method is capable of running a string containing multiple source
1795 This method is capable of running a string containing multiple source
1787 lines, as if they had been entered at the IPython prompt. Since it
1796 lines, as if they had been entered at the IPython prompt. Since it
1788 exposes IPython's processing machinery, the given strings can contain
1797 exposes IPython's processing machinery, the given strings can contain
1789 magic calls (%magic), special shell access (!cmd), etc."""
1798 magic calls (%magic), special shell access (!cmd), etc."""
1790
1799
1791 # We must start with a clean buffer, in case this is run from an
1800 # We must start with a clean buffer, in case this is run from an
1792 # interactive IPython session (via a magic, for example).
1801 # interactive IPython session (via a magic, for example).
1793 self.resetbuffer()
1802 self.resetbuffer()
1794 lines = lines.split('\n')
1803 lines = lines.split('\n')
1795 more = 0
1804 more = 0
1796 for line in lines:
1805 for line in lines:
1797 # skip blank lines so we don't mess up the prompt counter, but do
1806 # skip blank lines so we don't mess up the prompt counter, but do
1798 # NOT skip even a blank line if we are in a code block (more is
1807 # NOT skip even a blank line if we are in a code block (more is
1799 # true)
1808 # true)
1800 if line or more:
1809 if line or more:
1801 more = self.push(self.prefilter(line,more))
1810 more = self.push(self.prefilter(line,more))
1802 # IPython's runsource returns None if there was an error
1811 # IPython's runsource returns None if there was an error
1803 # compiling the code. This allows us to stop processing right
1812 # compiling the code. This allows us to stop processing right
1804 # away, so the user gets the error message at the right place.
1813 # away, so the user gets the error message at the right place.
1805 if more is None:
1814 if more is None:
1806 break
1815 break
1807 # final newline in case the input didn't have it, so that the code
1816 # final newline in case the input didn't have it, so that the code
1808 # actually does get executed
1817 # actually does get executed
1809 if more:
1818 if more:
1810 self.push('\n')
1819 self.push('\n')
1811
1820
1812 def runsource(self, source, filename='<input>', symbol='single'):
1821 def runsource(self, source, filename='<input>', symbol='single'):
1813 """Compile and run some source in the interpreter.
1822 """Compile and run some source in the interpreter.
1814
1823
1815 Arguments are as for compile_command().
1824 Arguments are as for compile_command().
1816
1825
1817 One several things can happen:
1826 One several things can happen:
1818
1827
1819 1) The input is incorrect; compile_command() raised an
1828 1) The input is incorrect; compile_command() raised an
1820 exception (SyntaxError or OverflowError). A syntax traceback
1829 exception (SyntaxError or OverflowError). A syntax traceback
1821 will be printed by calling the showsyntaxerror() method.
1830 will be printed by calling the showsyntaxerror() method.
1822
1831
1823 2) The input is incomplete, and more input is required;
1832 2) The input is incomplete, and more input is required;
1824 compile_command() returned None. Nothing happens.
1833 compile_command() returned None. Nothing happens.
1825
1834
1826 3) The input is complete; compile_command() returned a code
1835 3) The input is complete; compile_command() returned a code
1827 object. The code is executed by calling self.runcode() (which
1836 object. The code is executed by calling self.runcode() (which
1828 also handles run-time exceptions, except for SystemExit).
1837 also handles run-time exceptions, except for SystemExit).
1829
1838
1830 The return value is:
1839 The return value is:
1831
1840
1832 - True in case 2
1841 - True in case 2
1833
1842
1834 - False in the other cases, unless an exception is raised, where
1843 - False in the other cases, unless an exception is raised, where
1835 None is returned instead. This can be used by external callers to
1844 None is returned instead. This can be used by external callers to
1836 know whether to continue feeding input or not.
1845 know whether to continue feeding input or not.
1837
1846
1838 The return value can be used to decide whether to use sys.ps1 or
1847 The return value can be used to decide whether to use sys.ps1 or
1839 sys.ps2 to prompt the next line."""
1848 sys.ps2 to prompt the next line."""
1840
1849
1841 # if the source code has leading blanks, add 'if 1:\n' to it
1850 # if the source code has leading blanks, add 'if 1:\n' to it
1842 # this allows execution of indented pasted code. It is tempting
1851 # this allows execution of indented pasted code. It is tempting
1843 # to add '\n' at the end of source to run commands like ' a=1'
1852 # to add '\n' at the end of source to run commands like ' a=1'
1844 # directly, but this fails for more complicated scenarios
1853 # directly, but this fails for more complicated scenarios
1845 if source[:1] in [' ', '\t']:
1854 if source[:1] in [' ', '\t']:
1846 source = 'if 1:\n%s' % source
1855 source = 'if 1:\n%s' % source
1847
1856
1848 try:
1857 try:
1849 code = self.compile(source,filename,symbol)
1858 code = self.compile(source,filename,symbol)
1850 except (OverflowError, SyntaxError, ValueError):
1859 except (OverflowError, SyntaxError, ValueError):
1851 # Case 1
1860 # Case 1
1852 self.showsyntaxerror(filename)
1861 self.showsyntaxerror(filename)
1853 return None
1862 return None
1854
1863
1855 if code is None:
1864 if code is None:
1856 # Case 2
1865 # Case 2
1857 return True
1866 return True
1858
1867
1859 # Case 3
1868 # Case 3
1860 # We store the code object so that threaded shells and
1869 # We store the code object so that threaded shells and
1861 # custom exception handlers can access all this info if needed.
1870 # custom exception handlers can access all this info if needed.
1862 # The source corresponding to this can be obtained from the
1871 # The source corresponding to this can be obtained from the
1863 # buffer attribute as '\n'.join(self.buffer).
1872 # buffer attribute as '\n'.join(self.buffer).
1864 self.code_to_run = code
1873 self.code_to_run = code
1865 # now actually execute the code object
1874 # now actually execute the code object
1866 if self.runcode(code) == 0:
1875 if self.runcode(code) == 0:
1867 return False
1876 return False
1868 else:
1877 else:
1869 return None
1878 return None
1870
1879
1871 def runcode(self,code_obj):
1880 def runcode(self,code_obj):
1872 """Execute a code object.
1881 """Execute a code object.
1873
1882
1874 When an exception occurs, self.showtraceback() is called to display a
1883 When an exception occurs, self.showtraceback() is called to display a
1875 traceback.
1884 traceback.
1876
1885
1877 Return value: a flag indicating whether the code to be run completed
1886 Return value: a flag indicating whether the code to be run completed
1878 successfully:
1887 successfully:
1879
1888
1880 - 0: successful execution.
1889 - 0: successful execution.
1881 - 1: an error occurred.
1890 - 1: an error occurred.
1882 """
1891 """
1883
1892
1884 # Set our own excepthook in case the user code tries to call it
1893 # Set our own excepthook in case the user code tries to call it
1885 # directly, so that the IPython crash handler doesn't get triggered
1894 # directly, so that the IPython crash handler doesn't get triggered
1886 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1895 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1887
1896
1888 # we save the original sys.excepthook in the instance, in case config
1897 # we save the original sys.excepthook in the instance, in case config
1889 # code (such as magics) needs access to it.
1898 # code (such as magics) needs access to it.
1890 self.sys_excepthook = old_excepthook
1899 self.sys_excepthook = old_excepthook
1891 outflag = 1 # happens in more places, so it's easier as default
1900 outflag = 1 # happens in more places, so it's easier as default
1892 try:
1901 try:
1893 try:
1902 try:
1894 # Embedded instances require separate global/local namespaces
1903 # Embedded instances require separate global/local namespaces
1895 # so they can see both the surrounding (local) namespace and
1904 # so they can see both the surrounding (local) namespace and
1896 # the module-level globals when called inside another function.
1905 # the module-level globals when called inside another function.
1897 if self.embedded:
1906 if self.embedded:
1898 exec code_obj in self.user_global_ns, self.user_ns
1907 exec code_obj in self.user_global_ns, self.user_ns
1899 # Normal (non-embedded) instances should only have a single
1908 # Normal (non-embedded) instances should only have a single
1900 # namespace for user code execution, otherwise functions won't
1909 # namespace for user code execution, otherwise functions won't
1901 # see interactive top-level globals.
1910 # see interactive top-level globals.
1902 else:
1911 else:
1903 exec code_obj in self.user_ns
1912 exec code_obj in self.user_ns
1904 finally:
1913 finally:
1905 # Reset our crash handler in place
1914 # Reset our crash handler in place
1906 sys.excepthook = old_excepthook
1915 sys.excepthook = old_excepthook
1907 except SystemExit:
1916 except SystemExit:
1908 self.resetbuffer()
1917 self.resetbuffer()
1909 self.showtraceback()
1918 self.showtraceback()
1910 warn("Type %exit or %quit to exit IPython "
1919 warn("Type %exit or %quit to exit IPython "
1911 "(%Exit or %Quit do so unconditionally).",level=1)
1920 "(%Exit or %Quit do so unconditionally).",level=1)
1912 except self.custom_exceptions:
1921 except self.custom_exceptions:
1913 etype,value,tb = sys.exc_info()
1922 etype,value,tb = sys.exc_info()
1914 self.CustomTB(etype,value,tb)
1923 self.CustomTB(etype,value,tb)
1915 except:
1924 except:
1916 self.showtraceback()
1925 self.showtraceback()
1917 else:
1926 else:
1918 outflag = 0
1927 outflag = 0
1919 if softspace(sys.stdout, 0):
1928 if softspace(sys.stdout, 0):
1920 print
1929 print
1921 # Flush out code object which has been run (and source)
1930 # Flush out code object which has been run (and source)
1922 self.code_to_run = None
1931 self.code_to_run = None
1923 return outflag
1932 return outflag
1924
1933
1925 def push(self, line):
1934 def push(self, line):
1926 """Push a line to the interpreter.
1935 """Push a line to the interpreter.
1927
1936
1928 The line should not have a trailing newline; it may have
1937 The line should not have a trailing newline; it may have
1929 internal newlines. The line is appended to a buffer and the
1938 internal newlines. The line is appended to a buffer and the
1930 interpreter's runsource() method is called with the
1939 interpreter's runsource() method is called with the
1931 concatenated contents of the buffer as source. If this
1940 concatenated contents of the buffer as source. If this
1932 indicates that the command was executed or invalid, the buffer
1941 indicates that the command was executed or invalid, the buffer
1933 is reset; otherwise, the command is incomplete, and the buffer
1942 is reset; otherwise, the command is incomplete, and the buffer
1934 is left as it was after the line was appended. The return
1943 is left as it was after the line was appended. The return
1935 value is 1 if more input is required, 0 if the line was dealt
1944 value is 1 if more input is required, 0 if the line was dealt
1936 with in some way (this is the same as runsource()).
1945 with in some way (this is the same as runsource()).
1937 """
1946 """
1938
1947
1939 # autoindent management should be done here, and not in the
1948 # autoindent management should be done here, and not in the
1940 # interactive loop, since that one is only seen by keyboard input. We
1949 # interactive loop, since that one is only seen by keyboard input. We
1941 # need this done correctly even for code run via runlines (which uses
1950 # need this done correctly even for code run via runlines (which uses
1942 # push).
1951 # push).
1943
1952
1944 #print 'push line: <%s>' % line # dbg
1953 #print 'push line: <%s>' % line # dbg
1945 for subline in line.splitlines():
1954 for subline in line.splitlines():
1946 self.autoindent_update(subline)
1955 self.autoindent_update(subline)
1947 self.buffer.append(line)
1956 self.buffer.append(line)
1948 more = self.runsource('\n'.join(self.buffer), self.filename)
1957 more = self.runsource('\n'.join(self.buffer), self.filename)
1949 if not more:
1958 if not more:
1950 self.resetbuffer()
1959 self.resetbuffer()
1951 return more
1960 return more
1952
1961
1953 def resetbuffer(self):
1962 def resetbuffer(self):
1954 """Reset the input buffer."""
1963 """Reset the input buffer."""
1955 self.buffer[:] = []
1964 self.buffer[:] = []
1956
1965
1957 def raw_input(self,prompt='',continue_prompt=False):
1966 def raw_input(self,prompt='',continue_prompt=False):
1958 """Write a prompt and read a line.
1967 """Write a prompt and read a line.
1959
1968
1960 The returned line does not include the trailing newline.
1969 The returned line does not include the trailing newline.
1961 When the user enters the EOF key sequence, EOFError is raised.
1970 When the user enters the EOF key sequence, EOFError is raised.
1962
1971
1963 Optional inputs:
1972 Optional inputs:
1964
1973
1965 - prompt(''): a string to be printed to prompt the user.
1974 - prompt(''): a string to be printed to prompt the user.
1966
1975
1967 - continue_prompt(False): whether this line is the first one or a
1976 - continue_prompt(False): whether this line is the first one or a
1968 continuation in a sequence of inputs.
1977 continuation in a sequence of inputs.
1969 """
1978 """
1970
1979
1971 try:
1980 try:
1972 line = raw_input_original(prompt)
1981 line = raw_input_original(prompt)
1973 except ValueError:
1982 except ValueError:
1974 warn("\n********\nYou or a %run:ed script called sys.stdin.close() or sys.stdout.close()!\nExiting IPython!")
1983 warn("\n********\nYou or a %run:ed script called sys.stdin.close() or sys.stdout.close()!\nExiting IPython!")
1975 self.exit_now = True
1984 self.exit_now = True
1976 return ""
1985 return ""
1977
1986
1978
1987
1979 # Try to be reasonably smart about not re-indenting pasted input more
1988 # Try to be reasonably smart about not re-indenting pasted input more
1980 # than necessary. We do this by trimming out the auto-indent initial
1989 # than necessary. We do this by trimming out the auto-indent initial
1981 # spaces, if the user's actual input started itself with whitespace.
1990 # spaces, if the user's actual input started itself with whitespace.
1982 #debugx('self.buffer[-1]')
1991 #debugx('self.buffer[-1]')
1983
1992
1984 if self.autoindent:
1993 if self.autoindent:
1985 if num_ini_spaces(line) > self.indent_current_nsp:
1994 if num_ini_spaces(line) > self.indent_current_nsp:
1986 line = line[self.indent_current_nsp:]
1995 line = line[self.indent_current_nsp:]
1987 self.indent_current_nsp = 0
1996 self.indent_current_nsp = 0
1988
1997
1989 # store the unfiltered input before the user has any chance to modify
1998 # store the unfiltered input before the user has any chance to modify
1990 # it.
1999 # it.
1991 if line.strip():
2000 if line.strip():
1992 if continue_prompt:
2001 if continue_prompt:
1993 self.input_hist_raw[-1] += '%s\n' % line
2002 self.input_hist_raw[-1] += '%s\n' % line
1994 if self.has_readline: # and some config option is set?
2003 if self.has_readline: # and some config option is set?
1995 try:
2004 try:
1996 histlen = self.readline.get_current_history_length()
2005 histlen = self.readline.get_current_history_length()
1997 newhist = self.input_hist_raw[-1].rstrip()
2006 newhist = self.input_hist_raw[-1].rstrip()
1998 self.readline.remove_history_item(histlen-1)
2007 self.readline.remove_history_item(histlen-1)
1999 self.readline.replace_history_item(histlen-2,newhist)
2008 self.readline.replace_history_item(histlen-2,newhist)
2000 except AttributeError:
2009 except AttributeError:
2001 pass # re{move,place}_history_item are new in 2.4.
2010 pass # re{move,place}_history_item are new in 2.4.
2002 else:
2011 else:
2003 self.input_hist_raw.append('%s\n' % line)
2012 self.input_hist_raw.append('%s\n' % line)
2004
2013
2005 try:
2014 try:
2006 lineout = self.prefilter(line,continue_prompt)
2015 lineout = self.prefilter(line,continue_prompt)
2007 except:
2016 except:
2008 # blanket except, in case a user-defined prefilter crashes, so it
2017 # blanket except, in case a user-defined prefilter crashes, so it
2009 # can't take all of ipython with it.
2018 # can't take all of ipython with it.
2010 self.showtraceback()
2019 self.showtraceback()
2011 return ''
2020 return ''
2012 else:
2021 else:
2013 return lineout
2022 return lineout
2014
2023
2015 def split_user_input(self,line):
2024 def split_user_input(self,line):
2016 """Split user input into pre-char, function part and rest."""
2025 """Split user input into pre-char, function part and rest."""
2017
2026
2018 lsplit = self.line_split.match(line)
2027 lsplit = self.line_split.match(line)
2019 if lsplit is None: # no regexp match returns None
2028 if lsplit is None: # no regexp match returns None
2020 try:
2029 lsplit = self.line_split_fallback.match(line)
2021 iFun,theRest = line.split(None,1)
2022 except ValueError:
2023 iFun,theRest = line,''
2024 pre = re.match('^(\s*)(.*)',line).groups()[0]
2025 else:
2026 pre,iFun,theRest = lsplit.groups()
2027
2030
2031 #pre,iFun,theRest = lsplit.groups() # dbg
2028 #print 'line:<%s>' % line # dbg
2032 #print 'line:<%s>' % line # dbg
2029 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
2033 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
2030 return pre,iFun.strip(),theRest
2034 #return pre,iFun.strip(),theRest # dbg
2035
2036 return lsplit.groups()
2031
2037
2032 def _prefilter(self, line, continue_prompt):
2038 def _prefilter(self, line, continue_prompt):
2033 """Calls different preprocessors, depending on the form of line."""
2039 """Calls different preprocessors, depending on the form of line."""
2034
2040
2035 # All handlers *must* return a value, even if it's blank ('').
2041 # All handlers *must* return a value, even if it's blank ('').
2036
2042
2037 # Lines are NOT logged here. Handlers should process the line as
2043 # Lines are NOT logged here. Handlers should process the line as
2038 # needed, update the cache AND log it (so that the input cache array
2044 # needed, update the cache AND log it (so that the input cache array
2039 # stays synced).
2045 # stays synced).
2040
2046
2041 # This function is _very_ delicate, and since it's also the one which
2047 # This function is _very_ delicate, and since it's also the one which
2042 # determines IPython's response to user input, it must be as efficient
2048 # determines IPython's response to user input, it must be as efficient
2043 # as possible. For this reason it has _many_ returns in it, trying
2049 # as possible. For this reason it has _many_ returns in it, trying
2044 # always to exit as quickly as it can figure out what it needs to do.
2050 # always to exit as quickly as it can figure out what it needs to do.
2045
2051
2046 # This function is the main responsible for maintaining IPython's
2052 # This function is the main responsible for maintaining IPython's
2047 # behavior respectful of Python's semantics. So be _very_ careful if
2053 # behavior respectful of Python's semantics. So be _very_ careful if
2048 # making changes to anything here.
2054 # making changes to anything here.
2049
2055
2050 #.....................................................................
2056 #.....................................................................
2051 # Code begins
2057 # Code begins
2052
2058
2053 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
2059 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
2054
2060
2055 # save the line away in case we crash, so the post-mortem handler can
2061 # save the line away in case we crash, so the post-mortem handler can
2056 # record it
2062 # record it
2057 self._last_input_line = line
2063 self._last_input_line = line
2058
2064
2059 #print '***line: <%s>' % line # dbg
2065 #print '***line: <%s>' % line # dbg
2060
2066
2061 # the input history needs to track even empty lines
2067 # the input history needs to track even empty lines
2062 stripped = line.strip()
2068 stripped = line.strip()
2063
2069
2064 if not stripped:
2070 if not stripped:
2065 if not continue_prompt:
2071 if not continue_prompt:
2066 self.outputcache.prompt_count -= 1
2072 self.outputcache.prompt_count -= 1
2067 return self.handle_normal(line,continue_prompt)
2073 return self.handle_normal(line,continue_prompt)
2068 #return self.handle_normal('',continue_prompt)
2074 #return self.handle_normal('',continue_prompt)
2069
2075
2070 # print '***cont',continue_prompt # dbg
2076 # print '***cont',continue_prompt # dbg
2071 # special handlers are only allowed for single line statements
2077 # special handlers are only allowed for single line statements
2072 if continue_prompt and not self.rc.multi_line_specials:
2078 if continue_prompt and not self.rc.multi_line_specials:
2073 return self.handle_normal(line,continue_prompt)
2079 return self.handle_normal(line,continue_prompt)
2074
2080
2075
2081
2076 # For the rest, we need the structure of the input
2082 # For the rest, we need the structure of the input
2077 pre,iFun,theRest = self.split_user_input(line)
2083 pre,iFun,theRest = self.split_user_input(line)
2078
2084
2079 # See whether any pre-existing handler can take care of it
2085 # See whether any pre-existing handler can take care of it
2080
2086
2081 rewritten = self.hooks.input_prefilter(stripped)
2087 rewritten = self.hooks.input_prefilter(stripped)
2082 if rewritten != stripped: # ok, some prefilter did something
2088 if rewritten != stripped: # ok, some prefilter did something
2083 rewritten = pre + rewritten # add indentation
2089 rewritten = pre + rewritten # add indentation
2084 return self.handle_normal(rewritten)
2090 return self.handle_normal(rewritten)
2085
2091
2086 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2092 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2087
2093
2088 # First check for explicit escapes in the last/first character
2094 # First check for explicit escapes in the last/first character
2089 handler = None
2095 handler = None
2090 if line[-1] == self.ESC_HELP:
2096 if line[-1] == self.ESC_HELP:
2091 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
2097 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
2092 if handler is None:
2098 if handler is None:
2093 # look at the first character of iFun, NOT of line, so we skip
2099 # look at the first character of iFun, NOT of line, so we skip
2094 # leading whitespace in multiline input
2100 # leading whitespace in multiline input
2095 handler = self.esc_handlers.get(iFun[0:1])
2101 handler = self.esc_handlers.get(iFun[0:1])
2096 if handler is not None:
2102 if handler is not None:
2097 return handler(line,continue_prompt,pre,iFun,theRest)
2103 return handler(line,continue_prompt,pre,iFun,theRest)
2098 # Emacs ipython-mode tags certain input lines
2104 # Emacs ipython-mode tags certain input lines
2099 if line.endswith('# PYTHON-MODE'):
2105 if line.endswith('# PYTHON-MODE'):
2100 return self.handle_emacs(line,continue_prompt)
2106 return self.handle_emacs(line,continue_prompt)
2101
2107
2102 # Next, check if we can automatically execute this thing
2108 # Next, check if we can automatically execute this thing
2103
2109
2104 # Allow ! in multi-line statements if multi_line_specials is on:
2110 # Allow ! in multi-line statements if multi_line_specials is on:
2105 if continue_prompt and self.rc.multi_line_specials and \
2111 if continue_prompt and self.rc.multi_line_specials and \
2106 iFun.startswith(self.ESC_SHELL):
2112 iFun.startswith(self.ESC_SHELL):
2107 return self.handle_shell_escape(line,continue_prompt,
2113 return self.handle_shell_escape(line,continue_prompt,
2108 pre=pre,iFun=iFun,
2114 pre=pre,iFun=iFun,
2109 theRest=theRest)
2115 theRest=theRest)
2110
2116
2111 # Let's try to find if the input line is a magic fn
2117 # Let's try to find if the input line is a magic fn
2112 oinfo = None
2118 oinfo = None
2113 if hasattr(self,'magic_'+iFun):
2119 if hasattr(self,'magic_'+iFun):
2114 # WARNING: _ofind uses getattr(), so it can consume generators and
2120 # WARNING: _ofind uses getattr(), so it can consume generators and
2115 # cause other side effects.
2121 # cause other side effects.
2116 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
2122 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
2117 if oinfo['ismagic']:
2123 if oinfo['ismagic']:
2118 # Be careful not to call magics when a variable assignment is
2124 # Be careful not to call magics when a variable assignment is
2119 # being made (ls='hi', for example)
2125 # being made (ls='hi', for example)
2120 if self.rc.automagic and \
2126 if self.rc.automagic and \
2121 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
2127 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
2122 (self.rc.multi_line_specials or not continue_prompt):
2128 (self.rc.multi_line_specials or not continue_prompt):
2123 return self.handle_magic(line,continue_prompt,
2129 return self.handle_magic(line,continue_prompt,
2124 pre,iFun,theRest)
2130 pre,iFun,theRest)
2125 else:
2131 else:
2126 return self.handle_normal(line,continue_prompt)
2132 return self.handle_normal(line,continue_prompt)
2127
2133
2128 # If the rest of the line begins with an (in)equality, assginment or
2134 # If the rest of the line begins with an (in)equality, assginment or
2129 # function call, we should not call _ofind but simply execute it.
2135 # function call, we should not call _ofind but simply execute it.
2130 # This avoids spurious geattr() accesses on objects upon assignment.
2136 # This avoids spurious geattr() accesses on objects upon assignment.
2131 #
2137 #
2132 # It also allows users to assign to either alias or magic names true
2138 # It also allows users to assign to either alias or magic names true
2133 # python variables (the magic/alias systems always take second seat to
2139 # python variables (the magic/alias systems always take second seat to
2134 # true python code).
2140 # true python code).
2135 if theRest and theRest[0] in '!=()':
2141 if theRest and theRest[0] in '!=()':
2136 return self.handle_normal(line,continue_prompt)
2142 return self.handle_normal(line,continue_prompt)
2137
2143
2138 if oinfo is None:
2144 if oinfo is None:
2139 # let's try to ensure that _oinfo is ONLY called when autocall is
2145 # let's try to ensure that _oinfo is ONLY called when autocall is
2140 # on. Since it has inevitable potential side effects, at least
2146 # on. Since it has inevitable potential side effects, at least
2141 # having autocall off should be a guarantee to the user that no
2147 # having autocall off should be a guarantee to the user that no
2142 # weird things will happen.
2148 # weird things will happen.
2143
2149
2144 if self.rc.autocall:
2150 if self.rc.autocall:
2145 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
2151 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
2146 else:
2152 else:
2147 # in this case, all that's left is either an alias or
2153 # in this case, all that's left is either an alias or
2148 # processing the line normally.
2154 # processing the line normally.
2149 if iFun in self.alias_table:
2155 if iFun in self.alias_table:
2150 # if autocall is off, by not running _ofind we won't know
2156 # if autocall is off, by not running _ofind we won't know
2151 # whether the given name may also exist in one of the
2157 # whether the given name may also exist in one of the
2152 # user's namespace. At this point, it's best to do a
2158 # user's namespace. At this point, it's best to do a
2153 # quick check just to be sure that we don't let aliases
2159 # quick check just to be sure that we don't let aliases
2154 # shadow variables.
2160 # shadow variables.
2155 head = iFun.split('.',1)[0]
2161 head = iFun.split('.',1)[0]
2156 if head in self.user_ns or head in self.internal_ns \
2162 if head in self.user_ns or head in self.internal_ns \
2157 or head in __builtin__.__dict__:
2163 or head in __builtin__.__dict__:
2158 return self.handle_normal(line,continue_prompt)
2164 return self.handle_normal(line,continue_prompt)
2159 else:
2165 else:
2160 return self.handle_alias(line,continue_prompt,
2166 return self.handle_alias(line,continue_prompt,
2161 pre,iFun,theRest)
2167 pre,iFun,theRest)
2162
2168
2163 else:
2169 else:
2164 return self.handle_normal(line,continue_prompt)
2170 return self.handle_normal(line,continue_prompt)
2165
2171
2166 if not oinfo['found']:
2172 if not oinfo['found']:
2167 return self.handle_normal(line,continue_prompt)
2173 return self.handle_normal(line,continue_prompt)
2168 else:
2174 else:
2169 #print 'pre<%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2175 #print 'pre<%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2170 if oinfo['isalias']:
2176 if oinfo['isalias']:
2171 return self.handle_alias(line,continue_prompt,
2177 return self.handle_alias(line,continue_prompt,
2172 pre,iFun,theRest)
2178 pre,iFun,theRest)
2173
2179
2174 if (self.rc.autocall
2180 if (self.rc.autocall
2175 and
2181 and
2176 (
2182 (
2177 #only consider exclusion re if not "," or ";" autoquoting
2183 #only consider exclusion re if not "," or ";" autoquoting
2178 (pre == self.ESC_QUOTE or pre == self.ESC_QUOTE2
2184 (pre == self.ESC_QUOTE or pre == self.ESC_QUOTE2
2179 or pre == self.ESC_PAREN) or
2185 or pre == self.ESC_PAREN) or
2180 (not self.re_exclude_auto.match(theRest)))
2186 (not self.re_exclude_auto.match(theRest)))
2181 and
2187 and
2182 self.re_fun_name.match(iFun) and
2188 self.re_fun_name.match(iFun) and
2183 callable(oinfo['obj'])) :
2189 callable(oinfo['obj'])) :
2184 #print 'going auto' # dbg
2190 #print 'going auto' # dbg
2185 return self.handle_auto(line,continue_prompt,
2191 return self.handle_auto(line,continue_prompt,
2186 pre,iFun,theRest,oinfo['obj'])
2192 pre,iFun,theRest,oinfo['obj'])
2187 else:
2193 else:
2188 #print 'was callable?', callable(oinfo['obj']) # dbg
2194 #print 'was callable?', callable(oinfo['obj']) # dbg
2189 return self.handle_normal(line,continue_prompt)
2195 return self.handle_normal(line,continue_prompt)
2190
2196
2191 # If we get here, we have a normal Python line. Log and return.
2197 # If we get here, we have a normal Python line. Log and return.
2192 return self.handle_normal(line,continue_prompt)
2198 return self.handle_normal(line,continue_prompt)
2193
2199
2194 def _prefilter_dumb(self, line, continue_prompt):
2200 def _prefilter_dumb(self, line, continue_prompt):
2195 """simple prefilter function, for debugging"""
2201 """simple prefilter function, for debugging"""
2196 return self.handle_normal(line,continue_prompt)
2202 return self.handle_normal(line,continue_prompt)
2197
2203
2198
2204
2199 def multiline_prefilter(self, line, continue_prompt):
2205 def multiline_prefilter(self, line, continue_prompt):
2200 """ Run _prefilter for each line of input
2206 """ Run _prefilter for each line of input
2201
2207
2202 Covers cases where there are multiple lines in the user entry,
2208 Covers cases where there are multiple lines in the user entry,
2203 which is the case when the user goes back to a multiline history
2209 which is the case when the user goes back to a multiline history
2204 entry and presses enter.
2210 entry and presses enter.
2205
2211
2206 """
2212 """
2207 out = []
2213 out = []
2208 for l in line.rstrip('\n').split('\n'):
2214 for l in line.rstrip('\n').split('\n'):
2209 out.append(self._prefilter(l, continue_prompt))
2215 out.append(self._prefilter(l, continue_prompt))
2210 return '\n'.join(out)
2216 return '\n'.join(out)
2211
2217
2212 # Set the default prefilter() function (this can be user-overridden)
2218 # Set the default prefilter() function (this can be user-overridden)
2213 prefilter = multiline_prefilter
2219 prefilter = multiline_prefilter
2214
2220
2215 def handle_normal(self,line,continue_prompt=None,
2221 def handle_normal(self,line,continue_prompt=None,
2216 pre=None,iFun=None,theRest=None):
2222 pre=None,iFun=None,theRest=None):
2217 """Handle normal input lines. Use as a template for handlers."""
2223 """Handle normal input lines. Use as a template for handlers."""
2218
2224
2219 # With autoindent on, we need some way to exit the input loop, and I
2225 # With autoindent on, we need some way to exit the input loop, and I
2220 # don't want to force the user to have to backspace all the way to
2226 # don't want to force the user to have to backspace all the way to
2221 # clear the line. The rule will be in this case, that either two
2227 # clear the line. The rule will be in this case, that either two
2222 # lines of pure whitespace in a row, or a line of pure whitespace but
2228 # lines of pure whitespace in a row, or a line of pure whitespace but
2223 # of a size different to the indent level, will exit the input loop.
2229 # of a size different to the indent level, will exit the input loop.
2224
2230
2225 if (continue_prompt and self.autoindent and line.isspace() and
2231 if (continue_prompt and self.autoindent and line.isspace() and
2226 (0 < abs(len(line) - self.indent_current_nsp) <= 2 or
2232 (0 < abs(len(line) - self.indent_current_nsp) <= 2 or
2227 (self.buffer[-1]).isspace() )):
2233 (self.buffer[-1]).isspace() )):
2228 line = ''
2234 line = ''
2229
2235
2230 self.log(line,line,continue_prompt)
2236 self.log(line,line,continue_prompt)
2231 return line
2237 return line
2232
2238
2233 def handle_alias(self,line,continue_prompt=None,
2239 def handle_alias(self,line,continue_prompt=None,
2234 pre=None,iFun=None,theRest=None):
2240 pre=None,iFun=None,theRest=None):
2235 """Handle alias input lines. """
2241 """Handle alias input lines. """
2236
2242
2237 # pre is needed, because it carries the leading whitespace. Otherwise
2243 # pre is needed, because it carries the leading whitespace. Otherwise
2238 # aliases won't work in indented sections.
2244 # aliases won't work in indented sections.
2239 transformed = self.expand_aliases(iFun, theRest)
2245 transformed = self.expand_aliases(iFun, theRest)
2240 line_out = '%s_ip.system(%s)' % (pre, make_quoted_expr( transformed ))
2246 line_out = '%s_ip.system(%s)' % (pre, make_quoted_expr( transformed ))
2241 self.log(line,line_out,continue_prompt)
2247 self.log(line,line_out,continue_prompt)
2242 #print 'line out:',line_out # dbg
2248 #print 'line out:',line_out # dbg
2243 return line_out
2249 return line_out
2244
2250
2245 def handle_shell_escape(self, line, continue_prompt=None,
2251 def handle_shell_escape(self, line, continue_prompt=None,
2246 pre=None,iFun=None,theRest=None):
2252 pre=None,iFun=None,theRest=None):
2247 """Execute the line in a shell, empty return value"""
2253 """Execute the line in a shell, empty return value"""
2248
2254
2249 #print 'line in :', `line` # dbg
2255 #print 'line in :', `line` # dbg
2250 # Example of a special handler. Others follow a similar pattern.
2256 # Example of a special handler. Others follow a similar pattern.
2251 if line.lstrip().startswith('!!'):
2257 if line.lstrip().startswith('!!'):
2252 # rewrite iFun/theRest to properly hold the call to %sx and
2258 # rewrite iFun/theRest to properly hold the call to %sx and
2253 # the actual command to be executed, so handle_magic can work
2259 # the actual command to be executed, so handle_magic can work
2254 # correctly
2260 # correctly
2255 theRest = '%s %s' % (iFun[2:],theRest)
2261 theRest = '%s %s' % (iFun[2:],theRest)
2256 iFun = 'sx'
2262 iFun = 'sx'
2257 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,
2263 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,
2258 line.lstrip()[2:]),
2264 line.lstrip()[2:]),
2259 continue_prompt,pre,iFun,theRest)
2265 continue_prompt,pre,iFun,theRest)
2260 else:
2266 else:
2261 cmd=line.lstrip().lstrip('!')
2267 cmd=line.lstrip().lstrip('!')
2262 line_out = '%s_ip.system(%s)' % (pre,make_quoted_expr(cmd))
2268 line_out = '%s_ip.system(%s)' % (pre,make_quoted_expr(cmd))
2263 # update cache/log and return
2269 # update cache/log and return
2264 self.log(line,line_out,continue_prompt)
2270 self.log(line,line_out,continue_prompt)
2265 return line_out
2271 return line_out
2266
2272
2267 def handle_magic(self, line, continue_prompt=None,
2273 def handle_magic(self, line, continue_prompt=None,
2268 pre=None,iFun=None,theRest=None):
2274 pre=None,iFun=None,theRest=None):
2269 """Execute magic functions."""
2275 """Execute magic functions."""
2270
2276
2271
2277
2272 cmd = '%s_ip.magic(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
2278 cmd = '%s_ip.magic(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
2273 self.log(line,cmd,continue_prompt)
2279 self.log(line,cmd,continue_prompt)
2274 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
2280 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
2275 return cmd
2281 return cmd
2276
2282
2277 def handle_auto(self, line, continue_prompt=None,
2283 def handle_auto(self, line, continue_prompt=None,
2278 pre=None,iFun=None,theRest=None,obj=None):
2284 pre=None,iFun=None,theRest=None,obj=None):
2279 """Hande lines which can be auto-executed, quoting if requested."""
2285 """Hande lines which can be auto-executed, quoting if requested."""
2280
2286
2281 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2287 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2282
2288
2283 # This should only be active for single-line input!
2289 # This should only be active for single-line input!
2284 if continue_prompt:
2290 if continue_prompt:
2285 self.log(line,line,continue_prompt)
2291 self.log(line,line,continue_prompt)
2286 return line
2292 return line
2287
2293
2288 auto_rewrite = True
2294 auto_rewrite = True
2289
2295
2290 if pre == self.ESC_QUOTE:
2296 if pre == self.ESC_QUOTE:
2291 # Auto-quote splitting on whitespace
2297 # Auto-quote splitting on whitespace
2292 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
2298 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
2293 elif pre == self.ESC_QUOTE2:
2299 elif pre == self.ESC_QUOTE2:
2294 # Auto-quote whole string
2300 # Auto-quote whole string
2295 newcmd = '%s("%s")' % (iFun,theRest)
2301 newcmd = '%s("%s")' % (iFun,theRest)
2296 elif pre == self.ESC_PAREN:
2302 elif pre == self.ESC_PAREN:
2297 newcmd = '%s(%s)' % (iFun,",".join(theRest.split()))
2303 newcmd = '%s(%s)' % (iFun,",".join(theRest.split()))
2298 else:
2304 else:
2299 # Auto-paren.
2305 # Auto-paren.
2300 # We only apply it to argument-less calls if the autocall
2306 # We only apply it to argument-less calls if the autocall
2301 # parameter is set to 2. We only need to check that autocall is <
2307 # parameter is set to 2. We only need to check that autocall is <
2302 # 2, since this function isn't called unless it's at least 1.
2308 # 2, since this function isn't called unless it's at least 1.
2303 if not theRest and (self.rc.autocall < 2):
2309 if not theRest and (self.rc.autocall < 2):
2304 newcmd = '%s %s' % (iFun,theRest)
2310 newcmd = '%s %s' % (iFun,theRest)
2305 auto_rewrite = False
2311 auto_rewrite = False
2306 else:
2312 else:
2307 if theRest.startswith('['):
2313 if theRest.startswith('['):
2308 if hasattr(obj,'__getitem__'):
2314 if hasattr(obj,'__getitem__'):
2309 # Don't autocall in this case: item access for an object
2315 # Don't autocall in this case: item access for an object
2310 # which is BOTH callable and implements __getitem__.
2316 # which is BOTH callable and implements __getitem__.
2311 newcmd = '%s %s' % (iFun,theRest)
2317 newcmd = '%s %s' % (iFun,theRest)
2312 auto_rewrite = False
2318 auto_rewrite = False
2313 else:
2319 else:
2314 # if the object doesn't support [] access, go ahead and
2320 # if the object doesn't support [] access, go ahead and
2315 # autocall
2321 # autocall
2316 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
2322 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
2317 elif theRest.endswith(';'):
2323 elif theRest.endswith(';'):
2318 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
2324 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
2319 else:
2325 else:
2320 newcmd = '%s(%s)' % (iFun.rstrip(), theRest)
2326 newcmd = '%s(%s)' % (iFun.rstrip(), theRest)
2321
2327
2322 if auto_rewrite:
2328 if auto_rewrite:
2323 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
2329 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
2324 # log what is now valid Python, not the actual user input (without the
2330 # log what is now valid Python, not the actual user input (without the
2325 # final newline)
2331 # final newline)
2326 self.log(line,newcmd,continue_prompt)
2332 self.log(line,newcmd,continue_prompt)
2327 return newcmd
2333 return newcmd
2328
2334
2329 def handle_help(self, line, continue_prompt=None,
2335 def handle_help(self, line, continue_prompt=None,
2330 pre=None,iFun=None,theRest=None):
2336 pre=None,iFun=None,theRest=None):
2331 """Try to get some help for the object.
2337 """Try to get some help for the object.
2332
2338
2333 obj? or ?obj -> basic information.
2339 obj? or ?obj -> basic information.
2334 obj?? or ??obj -> more details.
2340 obj?? or ??obj -> more details.
2335 """
2341 """
2336
2342
2337 # We need to make sure that we don't process lines which would be
2343 # We need to make sure that we don't process lines which would be
2338 # otherwise valid python, such as "x=1 # what?"
2344 # otherwise valid python, such as "x=1 # what?"
2339 try:
2345 try:
2340 codeop.compile_command(line)
2346 codeop.compile_command(line)
2341 except SyntaxError:
2347 except SyntaxError:
2342 # We should only handle as help stuff which is NOT valid syntax
2348 # We should only handle as help stuff which is NOT valid syntax
2343 if line[0]==self.ESC_HELP:
2349 if line[0]==self.ESC_HELP:
2344 line = line[1:]
2350 line = line[1:]
2345 elif line[-1]==self.ESC_HELP:
2351 elif line[-1]==self.ESC_HELP:
2346 line = line[:-1]
2352 line = line[:-1]
2347 self.log(line,'#?'+line,continue_prompt)
2353 self.log(line,'#?'+line,continue_prompt)
2348 if line:
2354 if line:
2349 self.magic_pinfo(line)
2355 self.magic_pinfo(line)
2350 else:
2356 else:
2351 page(self.usage,screen_lines=self.rc.screen_length)
2357 page(self.usage,screen_lines=self.rc.screen_length)
2352 return '' # Empty string is needed here!
2358 return '' # Empty string is needed here!
2353 except:
2359 except:
2354 # Pass any other exceptions through to the normal handler
2360 # Pass any other exceptions through to the normal handler
2355 return self.handle_normal(line,continue_prompt)
2361 return self.handle_normal(line,continue_prompt)
2356 else:
2362 else:
2357 # If the code compiles ok, we should handle it normally
2363 # If the code compiles ok, we should handle it normally
2358 return self.handle_normal(line,continue_prompt)
2364 return self.handle_normal(line,continue_prompt)
2359
2365
2360 def getapi(self):
2366 def getapi(self):
2361 """ Get an IPApi object for this shell instance
2367 """ Get an IPApi object for this shell instance
2362
2368
2363 Getting an IPApi object is always preferable to accessing the shell
2369 Getting an IPApi object is always preferable to accessing the shell
2364 directly, but this holds true especially for extensions.
2370 directly, but this holds true especially for extensions.
2365
2371
2366 It should always be possible to implement an extension with IPApi
2372 It should always be possible to implement an extension with IPApi
2367 alone. If not, contact maintainer to request an addition.
2373 alone. If not, contact maintainer to request an addition.
2368
2374
2369 """
2375 """
2370 return self.api
2376 return self.api
2371
2377
2372 def handle_emacs(self,line,continue_prompt=None,
2378 def handle_emacs(self,line,continue_prompt=None,
2373 pre=None,iFun=None,theRest=None):
2379 pre=None,iFun=None,theRest=None):
2374 """Handle input lines marked by python-mode."""
2380 """Handle input lines marked by python-mode."""
2375
2381
2376 # Currently, nothing is done. Later more functionality can be added
2382 # Currently, nothing is done. Later more functionality can be added
2377 # here if needed.
2383 # here if needed.
2378
2384
2379 # The input cache shouldn't be updated
2385 # The input cache shouldn't be updated
2380
2386
2381 return line
2387 return line
2382
2388
2383 def mktempfile(self,data=None):
2389 def mktempfile(self,data=None):
2384 """Make a new tempfile and return its filename.
2390 """Make a new tempfile and return its filename.
2385
2391
2386 This makes a call to tempfile.mktemp, but it registers the created
2392 This makes a call to tempfile.mktemp, but it registers the created
2387 filename internally so ipython cleans it up at exit time.
2393 filename internally so ipython cleans it up at exit time.
2388
2394
2389 Optional inputs:
2395 Optional inputs:
2390
2396
2391 - data(None): if data is given, it gets written out to the temp file
2397 - data(None): if data is given, it gets written out to the temp file
2392 immediately, and the file is closed again."""
2398 immediately, and the file is closed again."""
2393
2399
2394 filename = tempfile.mktemp('.py','ipython_edit_')
2400 filename = tempfile.mktemp('.py','ipython_edit_')
2395 self.tempfiles.append(filename)
2401 self.tempfiles.append(filename)
2396
2402
2397 if data:
2403 if data:
2398 tmp_file = open(filename,'w')
2404 tmp_file = open(filename,'w')
2399 tmp_file.write(data)
2405 tmp_file.write(data)
2400 tmp_file.close()
2406 tmp_file.close()
2401 return filename
2407 return filename
2402
2408
2403 def write(self,data):
2409 def write(self,data):
2404 """Write a string to the default output"""
2410 """Write a string to the default output"""
2405 Term.cout.write(data)
2411 Term.cout.write(data)
2406
2412
2407 def write_err(self,data):
2413 def write_err(self,data):
2408 """Write a string to the default error output"""
2414 """Write a string to the default error output"""
2409 Term.cerr.write(data)
2415 Term.cerr.write(data)
2410
2416
2411 def exit(self):
2417 def exit(self):
2412 """Handle interactive exit.
2418 """Handle interactive exit.
2413
2419
2414 This method sets the exit_now attribute."""
2420 This method sets the exit_now attribute."""
2415
2421
2416 if self.rc.confirm_exit:
2422 if self.rc.confirm_exit:
2417 if self.ask_yes_no('Do you really want to exit ([y]/n)?','y'):
2423 if self.ask_yes_no('Do you really want to exit ([y]/n)?','y'):
2418 self.exit_now = True
2424 self.exit_now = True
2419 else:
2425 else:
2420 self.exit_now = True
2426 self.exit_now = True
2421
2427
2422 def safe_execfile(self,fname,*where,**kw):
2428 def safe_execfile(self,fname,*where,**kw):
2423 """A safe version of the builtin execfile().
2429 """A safe version of the builtin execfile().
2424
2430
2425 This version will never throw an exception, and knows how to handle
2431 This version will never throw an exception, and knows how to handle
2426 ipython logs as well."""
2432 ipython logs as well."""
2427
2433
2428 def syspath_cleanup():
2434 def syspath_cleanup():
2429 """Internal cleanup routine for sys.path."""
2435 """Internal cleanup routine for sys.path."""
2430 if add_dname:
2436 if add_dname:
2431 try:
2437 try:
2432 sys.path.remove(dname)
2438 sys.path.remove(dname)
2433 except ValueError:
2439 except ValueError:
2434 # For some reason the user has already removed it, ignore.
2440 # For some reason the user has already removed it, ignore.
2435 pass
2441 pass
2436
2442
2437 fname = os.path.expanduser(fname)
2443 fname = os.path.expanduser(fname)
2438
2444
2439 # Find things also in current directory. This is needed to mimic the
2445 # Find things also in current directory. This is needed to mimic the
2440 # behavior of running a script from the system command line, where
2446 # behavior of running a script from the system command line, where
2441 # Python inserts the script's directory into sys.path
2447 # Python inserts the script's directory into sys.path
2442 dname = os.path.dirname(os.path.abspath(fname))
2448 dname = os.path.dirname(os.path.abspath(fname))
2443 add_dname = False
2449 add_dname = False
2444 if dname not in sys.path:
2450 if dname not in sys.path:
2445 sys.path.insert(0,dname)
2451 sys.path.insert(0,dname)
2446 add_dname = True
2452 add_dname = True
2447
2453
2448 try:
2454 try:
2449 xfile = open(fname)
2455 xfile = open(fname)
2450 except:
2456 except:
2451 print >> Term.cerr, \
2457 print >> Term.cerr, \
2452 'Could not open file <%s> for safe execution.' % fname
2458 'Could not open file <%s> for safe execution.' % fname
2453 syspath_cleanup()
2459 syspath_cleanup()
2454 return None
2460 return None
2455
2461
2456 kw.setdefault('islog',0)
2462 kw.setdefault('islog',0)
2457 kw.setdefault('quiet',1)
2463 kw.setdefault('quiet',1)
2458 kw.setdefault('exit_ignore',0)
2464 kw.setdefault('exit_ignore',0)
2459 first = xfile.readline()
2465 first = xfile.readline()
2460 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
2466 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
2461 xfile.close()
2467 xfile.close()
2462 # line by line execution
2468 # line by line execution
2463 if first.startswith(loghead) or kw['islog']:
2469 if first.startswith(loghead) or kw['islog']:
2464 print 'Loading log file <%s> one line at a time...' % fname
2470 print 'Loading log file <%s> one line at a time...' % fname
2465 if kw['quiet']:
2471 if kw['quiet']:
2466 stdout_save = sys.stdout
2472 stdout_save = sys.stdout
2467 sys.stdout = StringIO.StringIO()
2473 sys.stdout = StringIO.StringIO()
2468 try:
2474 try:
2469 globs,locs = where[0:2]
2475 globs,locs = where[0:2]
2470 except:
2476 except:
2471 try:
2477 try:
2472 globs = locs = where[0]
2478 globs = locs = where[0]
2473 except:
2479 except:
2474 globs = locs = globals()
2480 globs = locs = globals()
2475 badblocks = []
2481 badblocks = []
2476
2482
2477 # we also need to identify indented blocks of code when replaying
2483 # we also need to identify indented blocks of code when replaying
2478 # logs and put them together before passing them to an exec
2484 # logs and put them together before passing them to an exec
2479 # statement. This takes a bit of regexp and look-ahead work in the
2485 # statement. This takes a bit of regexp and look-ahead work in the
2480 # file. It's easiest if we swallow the whole thing in memory
2486 # file. It's easiest if we swallow the whole thing in memory
2481 # first, and manually walk through the lines list moving the
2487 # first, and manually walk through the lines list moving the
2482 # counter ourselves.
2488 # counter ourselves.
2483 indent_re = re.compile('\s+\S')
2489 indent_re = re.compile('\s+\S')
2484 xfile = open(fname)
2490 xfile = open(fname)
2485 filelines = xfile.readlines()
2491 filelines = xfile.readlines()
2486 xfile.close()
2492 xfile.close()
2487 nlines = len(filelines)
2493 nlines = len(filelines)
2488 lnum = 0
2494 lnum = 0
2489 while lnum < nlines:
2495 while lnum < nlines:
2490 line = filelines[lnum]
2496 line = filelines[lnum]
2491 lnum += 1
2497 lnum += 1
2492 # don't re-insert logger status info into cache
2498 # don't re-insert logger status info into cache
2493 if line.startswith('#log#'):
2499 if line.startswith('#log#'):
2494 continue
2500 continue
2495 else:
2501 else:
2496 # build a block of code (maybe a single line) for execution
2502 # build a block of code (maybe a single line) for execution
2497 block = line
2503 block = line
2498 try:
2504 try:
2499 next = filelines[lnum] # lnum has already incremented
2505 next = filelines[lnum] # lnum has already incremented
2500 except:
2506 except:
2501 next = None
2507 next = None
2502 while next and indent_re.match(next):
2508 while next and indent_re.match(next):
2503 block += next
2509 block += next
2504 lnum += 1
2510 lnum += 1
2505 try:
2511 try:
2506 next = filelines[lnum]
2512 next = filelines[lnum]
2507 except:
2513 except:
2508 next = None
2514 next = None
2509 # now execute the block of one or more lines
2515 # now execute the block of one or more lines
2510 try:
2516 try:
2511 exec block in globs,locs
2517 exec block in globs,locs
2512 except SystemExit:
2518 except SystemExit:
2513 pass
2519 pass
2514 except:
2520 except:
2515 badblocks.append(block.rstrip())
2521 badblocks.append(block.rstrip())
2516 if kw['quiet']: # restore stdout
2522 if kw['quiet']: # restore stdout
2517 sys.stdout.close()
2523 sys.stdout.close()
2518 sys.stdout = stdout_save
2524 sys.stdout = stdout_save
2519 print 'Finished replaying log file <%s>' % fname
2525 print 'Finished replaying log file <%s>' % fname
2520 if badblocks:
2526 if badblocks:
2521 print >> sys.stderr, ('\nThe following lines/blocks in file '
2527 print >> sys.stderr, ('\nThe following lines/blocks in file '
2522 '<%s> reported errors:' % fname)
2528 '<%s> reported errors:' % fname)
2523
2529
2524 for badline in badblocks:
2530 for badline in badblocks:
2525 print >> sys.stderr, badline
2531 print >> sys.stderr, badline
2526 else: # regular file execution
2532 else: # regular file execution
2527 try:
2533 try:
2528 execfile(fname,*where)
2534 execfile(fname,*where)
2529 except SyntaxError:
2535 except SyntaxError:
2530 self.showsyntaxerror()
2536 self.showsyntaxerror()
2531 warn('Failure executing file: <%s>' % fname)
2537 warn('Failure executing file: <%s>' % fname)
2532 except SystemExit,status:
2538 except SystemExit,status:
2533 if not kw['exit_ignore']:
2539 if not kw['exit_ignore']:
2534 self.showtraceback()
2540 self.showtraceback()
2535 warn('Failure executing file: <%s>' % fname)
2541 warn('Failure executing file: <%s>' % fname)
2536 except:
2542 except:
2537 self.showtraceback()
2543 self.showtraceback()
2538 warn('Failure executing file: <%s>' % fname)
2544 warn('Failure executing file: <%s>' % fname)
2539
2545
2540 syspath_cleanup()
2546 syspath_cleanup()
2541
2547
2542 #************************* end of file <iplib.py> *****************************
2548 #************************* end of file <iplib.py> *****************************
@@ -1,6251 +1,6257 b''
1 2007-02-28 Fernando Perez <Fernando.Perez@colorado.edu>
2
3 * IPython/iplib.py (split_user_input): fix input splitting so we
4 don't attempt attribute accesses on things that can't possibly be
5 valid Python attributes. After a bug report by Alex Schmolck.
6
1 2007-02-27 Fernando Perez <Fernando.Perez@colorado.edu>
7 2007-02-27 Fernando Perez <Fernando.Perez@colorado.edu>
2
8
3 * IPython/Shell.py (IPShellGTK.mainloop): update threads calls to
9 * IPython/Shell.py (IPShellGTK.mainloop): update threads calls to
4 avoid a DeprecationWarning from GTK.
10 avoid a DeprecationWarning from GTK.
5
11
6 2007-02-22 Fernando Perez <Fernando.Perez@colorado.edu>
12 2007-02-22 Fernando Perez <Fernando.Perez@colorado.edu>
7
13
8 * IPython/genutils.py (clock): I modified clock() to return total
14 * IPython/genutils.py (clock): I modified clock() to return total
9 time, user+system. This is a more commonly needed metric. I also
15 time, user+system. This is a more commonly needed metric. I also
10 introduced the new clocku/clocks to get only user/system time if
16 introduced the new clocku/clocks to get only user/system time if
11 one wants those instead.
17 one wants those instead.
12
18
13 ***WARNING: API CHANGE*** clock() used to return only user time,
19 ***WARNING: API CHANGE*** clock() used to return only user time,
14 so if you want exactly the same results as before, use clocku
20 so if you want exactly the same results as before, use clocku
15 instead.
21 instead.
16
22
17 2007-02-22 Ville Vainio <vivainio@gmail.com>
23 2007-02-22 Ville Vainio <vivainio@gmail.com>
18
24
19 * IPython/Extensions/ipy_p4.py: Extension for improved
25 * IPython/Extensions/ipy_p4.py: Extension for improved
20 p4 (perforce version control system) experience.
26 p4 (perforce version control system) experience.
21 Adds %p4 magic with p4 command completion and
27 Adds %p4 magic with p4 command completion and
22 automatic -G argument (marshall output as python dict)
28 automatic -G argument (marshall output as python dict)
23
29
24 2007-02-19 Fernando Perez <Fernando.Perez@colorado.edu>
30 2007-02-19 Fernando Perez <Fernando.Perez@colorado.edu>
25
31
26 * IPython/demo.py (Demo.re_stop): make dashes optional in demo
32 * IPython/demo.py (Demo.re_stop): make dashes optional in demo
27 stop marks.
33 stop marks.
28 (ClearingMixin): a simple mixin to easily make a Demo class clear
34 (ClearingMixin): a simple mixin to easily make a Demo class clear
29 the screen in between blocks and have empty marquees. The
35 the screen in between blocks and have empty marquees. The
30 ClearDemo and ClearIPDemo classes that use it are included.
36 ClearDemo and ClearIPDemo classes that use it are included.
31
37
32 2007-02-18 Fernando Perez <Fernando.Perez@colorado.edu>
38 2007-02-18 Fernando Perez <Fernando.Perez@colorado.edu>
33
39
34 * IPython/irunner.py (pexpect_monkeypatch): patch pexpect to
40 * IPython/irunner.py (pexpect_monkeypatch): patch pexpect to
35 protect against exceptions at Python shutdown time. Patch
41 protect against exceptions at Python shutdown time. Patch
36 sumbmitted to upstream.
42 sumbmitted to upstream.
37
43
38 2007-02-14 Walter Doerwald <walter@livinglogic.de>
44 2007-02-14 Walter Doerwald <walter@livinglogic.de>
39
45
40 * IPython/Extensions/ibrowse.py: If entering the first object level
46 * IPython/Extensions/ibrowse.py: If entering the first object level
41 (i.e. the object for which the browser has been started) fails,
47 (i.e. the object for which the browser has been started) fails,
42 now the error is raised directly (aborting the browser) instead of
48 now the error is raised directly (aborting the browser) instead of
43 running into an empty levels list later.
49 running into an empty levels list later.
44
50
45 2007-02-03 Walter Doerwald <walter@livinglogic.de>
51 2007-02-03 Walter Doerwald <walter@livinglogic.de>
46
52
47 * IPython/Extensions/ipipe.py: Add an xrepr implementation
53 * IPython/Extensions/ipipe.py: Add an xrepr implementation
48 for the noitem object.
54 for the noitem object.
49
55
50 2007-01-31 Fernando Perez <Fernando.Perez@colorado.edu>
56 2007-01-31 Fernando Perez <Fernando.Perez@colorado.edu>
51
57
52 * IPython/completer.py (Completer.attr_matches): Fix small
58 * IPython/completer.py (Completer.attr_matches): Fix small
53 tab-completion bug with Enthought Traits objects with units.
59 tab-completion bug with Enthought Traits objects with units.
54 Thanks to a bug report by Tom Denniston
60 Thanks to a bug report by Tom Denniston
55 <tom.denniston-AT-alum.dartmouth.org>.
61 <tom.denniston-AT-alum.dartmouth.org>.
56
62
57 2007-01-27 Fernando Perez <Fernando.Perez@colorado.edu>
63 2007-01-27 Fernando Perez <Fernando.Perez@colorado.edu>
58
64
59 * IPython/Extensions/ipy_stock_completers.py (runlistpy): fix a
65 * IPython/Extensions/ipy_stock_completers.py (runlistpy): fix a
60 bug where only .ipy or .py would be completed. Once the first
66 bug where only .ipy or .py would be completed. Once the first
61 argument to %run has been given, all completions are valid because
67 argument to %run has been given, all completions are valid because
62 they are the arguments to the script, which may well be non-python
68 they are the arguments to the script, which may well be non-python
63 filenames.
69 filenames.
64
70
65 * IPython/irunner.py (InteractiveRunner.run_source): major updates
71 * IPython/irunner.py (InteractiveRunner.run_source): major updates
66 to irunner to allow it to correctly support real doctesting of
72 to irunner to allow it to correctly support real doctesting of
67 out-of-process ipython code.
73 out-of-process ipython code.
68
74
69 * IPython/Magic.py (magic_cd): Make the setting of the terminal
75 * IPython/Magic.py (magic_cd): Make the setting of the terminal
70 title an option (-noterm_title) because it completely breaks
76 title an option (-noterm_title) because it completely breaks
71 doctesting.
77 doctesting.
72
78
73 * IPython/demo.py: fix IPythonDemo class that was not actually working.
79 * IPython/demo.py: fix IPythonDemo class that was not actually working.
74
80
75 2007-01-24 Fernando Perez <Fernando.Perez@colorado.edu>
81 2007-01-24 Fernando Perez <Fernando.Perez@colorado.edu>
76
82
77 * IPython/irunner.py (main): fix small bug where extensions were
83 * IPython/irunner.py (main): fix small bug where extensions were
78 not being correctly recognized.
84 not being correctly recognized.
79
85
80 2007-01-23 Walter Doerwald <walter@livinglogic.de>
86 2007-01-23 Walter Doerwald <walter@livinglogic.de>
81
87
82 * IPython/Extensions/ipipe.py (xiter): Make sure that iterating
88 * IPython/Extensions/ipipe.py (xiter): Make sure that iterating
83 a string containing a single line yields the string itself as the
89 a string containing a single line yields the string itself as the
84 only item.
90 only item.
85
91
86 * IPython/Extensions/ibrowse.py (ibrowse): Avoid entering an
92 * IPython/Extensions/ibrowse.py (ibrowse): Avoid entering an
87 object if it's the same as the one on the last level (This avoids
93 object if it's the same as the one on the last level (This avoids
88 infinite recursion for one line strings).
94 infinite recursion for one line strings).
89
95
90 2007-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
96 2007-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
91
97
92 * IPython/ultraTB.py (AutoFormattedTB.__call__): properly flush
98 * IPython/ultraTB.py (AutoFormattedTB.__call__): properly flush
93 all output streams before printing tracebacks. This ensures that
99 all output streams before printing tracebacks. This ensures that
94 user output doesn't end up interleaved with traceback output.
100 user output doesn't end up interleaved with traceback output.
95
101
96 2007-01-10 Ville Vainio <vivainio@gmail.com>
102 2007-01-10 Ville Vainio <vivainio@gmail.com>
97
103
98 * Extensions/envpersist.py: Turbocharged %env that remembers
104 * Extensions/envpersist.py: Turbocharged %env that remembers
99 env vars across sessions; e.g. "%env PATH+=;/opt/scripts" or
105 env vars across sessions; e.g. "%env PATH+=;/opt/scripts" or
100 "%env VISUAL=jed".
106 "%env VISUAL=jed".
101
107
102 2007-01-05 Fernando Perez <Fernando.Perez@colorado.edu>
108 2007-01-05 Fernando Perez <Fernando.Perez@colorado.edu>
103
109
104 * IPython/iplib.py (showtraceback): ensure that we correctly call
110 * IPython/iplib.py (showtraceback): ensure that we correctly call
105 custom handlers in all cases (some with pdb were slipping through,
111 custom handlers in all cases (some with pdb were slipping through,
106 but I'm not exactly sure why).
112 but I'm not exactly sure why).
107
113
108 * IPython/Debugger.py (Tracer.__init__): added new class to
114 * IPython/Debugger.py (Tracer.__init__): added new class to
109 support set_trace-like usage of IPython's enhanced debugger.
115 support set_trace-like usage of IPython's enhanced debugger.
110
116
111 2006-12-24 Ville Vainio <vivainio@gmail.com>
117 2006-12-24 Ville Vainio <vivainio@gmail.com>
112
118
113 * ipmaker.py: more informative message when ipy_user_conf
119 * ipmaker.py: more informative message when ipy_user_conf
114 import fails (suggest running %upgrade).
120 import fails (suggest running %upgrade).
115
121
116 * tools/run_ipy_in_profiler.py: Utility to see where
122 * tools/run_ipy_in_profiler.py: Utility to see where
117 the time during IPython startup is spent.
123 the time during IPython startup is spent.
118
124
119 2006-12-20 Ville Vainio <vivainio@gmail.com>
125 2006-12-20 Ville Vainio <vivainio@gmail.com>
120
126
121 * 0.7.3 is out - merge all from 0.7.3 branch to trunk
127 * 0.7.3 is out - merge all from 0.7.3 branch to trunk
122
128
123 * ipapi.py: Add new ipapi method, expand_alias.
129 * ipapi.py: Add new ipapi method, expand_alias.
124
130
125 * Release.py: Bump up version to 0.7.4.svn
131 * Release.py: Bump up version to 0.7.4.svn
126
132
127 2006-12-17 Ville Vainio <vivainio@gmail.com>
133 2006-12-17 Ville Vainio <vivainio@gmail.com>
128
134
129 * Extensions/jobctrl.py: Fixed &cmd arg arg...
135 * Extensions/jobctrl.py: Fixed &cmd arg arg...
130 to work properly on posix too
136 to work properly on posix too
131
137
132 * Release.py: Update revnum (version is still just 0.7.3).
138 * Release.py: Update revnum (version is still just 0.7.3).
133
139
134 2006-12-15 Ville Vainio <vivainio@gmail.com>
140 2006-12-15 Ville Vainio <vivainio@gmail.com>
135
141
136 * scripts/ipython_win_post_install: create ipython.py in
142 * scripts/ipython_win_post_install: create ipython.py in
137 prefix + "/scripts".
143 prefix + "/scripts".
138
144
139 * Release.py: Update version to 0.7.3.
145 * Release.py: Update version to 0.7.3.
140
146
141 2006-12-14 Ville Vainio <vivainio@gmail.com>
147 2006-12-14 Ville Vainio <vivainio@gmail.com>
142
148
143 * scripts/ipython_win_post_install: Overwrite old shortcuts
149 * scripts/ipython_win_post_install: Overwrite old shortcuts
144 if they already exist
150 if they already exist
145
151
146 * Release.py: release 0.7.3rc2
152 * Release.py: release 0.7.3rc2
147
153
148 2006-12-13 Ville Vainio <vivainio@gmail.com>
154 2006-12-13 Ville Vainio <vivainio@gmail.com>
149
155
150 * Branch and update Release.py for 0.7.3rc1
156 * Branch and update Release.py for 0.7.3rc1
151
157
152 2006-12-13 Fernando Perez <Fernando.Perez@colorado.edu>
158 2006-12-13 Fernando Perez <Fernando.Perez@colorado.edu>
153
159
154 * IPython/Shell.py (IPShellWX): update for current WX naming
160 * IPython/Shell.py (IPShellWX): update for current WX naming
155 conventions, to avoid a deprecation warning with current WX
161 conventions, to avoid a deprecation warning with current WX
156 versions. Thanks to a report by Danny Shevitz.
162 versions. Thanks to a report by Danny Shevitz.
157
163
158 2006-12-12 Ville Vainio <vivainio@gmail.com>
164 2006-12-12 Ville Vainio <vivainio@gmail.com>
159
165
160 * ipmaker.py: apply david cournapeau's patch to make
166 * ipmaker.py: apply david cournapeau's patch to make
161 import_some work properly even when ipythonrc does
167 import_some work properly even when ipythonrc does
162 import_some on empty list (it was an old bug!).
168 import_some on empty list (it was an old bug!).
163
169
164 * UserConfig/ipy_user_conf.py, UserConfig/ipythonrc:
170 * UserConfig/ipy_user_conf.py, UserConfig/ipythonrc:
165 Add deprecation note to ipythonrc and a url to wiki
171 Add deprecation note to ipythonrc and a url to wiki
166 in ipy_user_conf.py
172 in ipy_user_conf.py
167
173
168
174
169 * Magic.py (%run): %run myscript.ipy now runs myscript.ipy
175 * Magic.py (%run): %run myscript.ipy now runs myscript.ipy
170 as if it was typed on IPython command prompt, i.e.
176 as if it was typed on IPython command prompt, i.e.
171 as IPython script.
177 as IPython script.
172
178
173 * example-magic.py, magic_grepl.py: remove outdated examples
179 * example-magic.py, magic_grepl.py: remove outdated examples
174
180
175 2006-12-11 Fernando Perez <Fernando.Perez@colorado.edu>
181 2006-12-11 Fernando Perez <Fernando.Perez@colorado.edu>
176
182
177 * IPython/iplib.py (debugger): prevent a nasty traceback if %debug
183 * IPython/iplib.py (debugger): prevent a nasty traceback if %debug
178 is called before any exception has occurred.
184 is called before any exception has occurred.
179
185
180 2006-12-08 Ville Vainio <vivainio@gmail.com>
186 2006-12-08 Ville Vainio <vivainio@gmail.com>
181
187
182 * Extensions/ipy_stock_completers.py: fix cd completer
188 * Extensions/ipy_stock_completers.py: fix cd completer
183 to translate /'s to \'s again.
189 to translate /'s to \'s again.
184
190
185 * completer.py: prevent traceback on file completions w/
191 * completer.py: prevent traceback on file completions w/
186 backslash.
192 backslash.
187
193
188 * Release.py: Update release number to 0.7.3b3 for release
194 * Release.py: Update release number to 0.7.3b3 for release
189
195
190 2006-12-07 Ville Vainio <vivainio@gmail.com>
196 2006-12-07 Ville Vainio <vivainio@gmail.com>
191
197
192 * Extensions/ipy_signals.py: Ignore ctrl+C in IPython process
198 * Extensions/ipy_signals.py: Ignore ctrl+C in IPython process
193 while executing external code. Provides more shell-like behaviour
199 while executing external code. Provides more shell-like behaviour
194 and overall better response to ctrl + C / ctrl + break.
200 and overall better response to ctrl + C / ctrl + break.
195
201
196 * tools/make_tarball.py: new script to create tarball straight from svn
202 * tools/make_tarball.py: new script to create tarball straight from svn
197 (setup.py sdist doesn't work on win32).
203 (setup.py sdist doesn't work on win32).
198
204
199 * Extensions/ipy_stock_completers.py: fix cd completer to give up
205 * Extensions/ipy_stock_completers.py: fix cd completer to give up
200 on dirnames with spaces and use the default completer instead.
206 on dirnames with spaces and use the default completer instead.
201
207
202 * Revision.py: Change version to 0.7.3b2 for release.
208 * Revision.py: Change version to 0.7.3b2 for release.
203
209
204 2006-12-05 Ville Vainio <vivainio@gmail.com>
210 2006-12-05 Ville Vainio <vivainio@gmail.com>
205
211
206 * Magic.py, iplib.py, completer.py: Apply R. Bernstein's
212 * Magic.py, iplib.py, completer.py: Apply R. Bernstein's
207 pydb patch 4 (rm debug printing, py 2.5 checking)
213 pydb patch 4 (rm debug printing, py 2.5 checking)
208
214
209 2006-11-30 Walter Doerwald <walter@livinglogic.de>
215 2006-11-30 Walter Doerwald <walter@livinglogic.de>
210 * IPython/Extensions/ibrowse.py: Add two new commands to ibrowse:
216 * IPython/Extensions/ibrowse.py: Add two new commands to ibrowse:
211 "refresh" (mapped to "r") refreshes the screen by restarting the iterator.
217 "refresh" (mapped to "r") refreshes the screen by restarting the iterator.
212 "refreshfind" (mapped to "R") does the same but tries to go back to the same
218 "refreshfind" (mapped to "R") does the same but tries to go back to the same
213 object the cursor was on before the refresh. The command "markrange" is
219 object the cursor was on before the refresh. The command "markrange" is
214 mapped to "%" now.
220 mapped to "%" now.
215 * IPython/Extensions/ibrowse.py: Make igrpentry and ipwdentry comparable.
221 * IPython/Extensions/ibrowse.py: Make igrpentry and ipwdentry comparable.
216
222
217 2006-11-29 Fernando Perez <Fernando.Perez@colorado.edu>
223 2006-11-29 Fernando Perez <Fernando.Perez@colorado.edu>
218
224
219 * IPython/Magic.py (magic_debug): new %debug magic to activate the
225 * IPython/Magic.py (magic_debug): new %debug magic to activate the
220 interactive debugger on the last traceback, without having to call
226 interactive debugger on the last traceback, without having to call
221 %pdb and rerun your code. Made minor changes in various modules,
227 %pdb and rerun your code. Made minor changes in various modules,
222 should automatically recognize pydb if available.
228 should automatically recognize pydb if available.
223
229
224 2006-11-28 Ville Vainio <vivainio@gmail.com>
230 2006-11-28 Ville Vainio <vivainio@gmail.com>
225
231
226 * completer.py: If the text start with !, show file completions
232 * completer.py: If the text start with !, show file completions
227 properly. This helps when trying to complete command name
233 properly. This helps when trying to complete command name
228 for shell escapes.
234 for shell escapes.
229
235
230 2006-11-27 Ville Vainio <vivainio@gmail.com>
236 2006-11-27 Ville Vainio <vivainio@gmail.com>
231
237
232 * ipy_stock_completers.py: bzr completer submitted by Stefan van
238 * ipy_stock_completers.py: bzr completer submitted by Stefan van
233 der Walt. Clean up svn and hg completers by using a common
239 der Walt. Clean up svn and hg completers by using a common
234 vcs_completer.
240 vcs_completer.
235
241
236 2006-11-26 Ville Vainio <vivainio@gmail.com>
242 2006-11-26 Ville Vainio <vivainio@gmail.com>
237
243
238 * Remove ipconfig and %config; you should use _ip.options structure
244 * Remove ipconfig and %config; you should use _ip.options structure
239 directly instead!
245 directly instead!
240
246
241 * genutils.py: add wrap_deprecated function for deprecating callables
247 * genutils.py: add wrap_deprecated function for deprecating callables
242
248
243 * iplib.py: deprecate ipmagic, ipsystem, ipalias. Use _ip.magic and
249 * iplib.py: deprecate ipmagic, ipsystem, ipalias. Use _ip.magic and
244 _ip.system instead. ipalias is redundant.
250 _ip.system instead. ipalias is redundant.
245
251
246 * Magic.py: %rehashdir no longer aliases 'cmdname' to 'cmdname.exe' on
252 * Magic.py: %rehashdir no longer aliases 'cmdname' to 'cmdname.exe' on
247 win32, but just 'cmdname'. Other extensions (non-'exe') are still made
253 win32, but just 'cmdname'. Other extensions (non-'exe') are still made
248 explicit.
254 explicit.
249
255
250 * ipy_stock_completers.py: 'hg' (mercurial VCS) now has a custom
256 * ipy_stock_completers.py: 'hg' (mercurial VCS) now has a custom
251 completer. Try it by entering 'hg ' and pressing tab.
257 completer. Try it by entering 'hg ' and pressing tab.
252
258
253 * macro.py: Give Macro a useful __repr__ method
259 * macro.py: Give Macro a useful __repr__ method
254
260
255 * Magic.py: %whos abbreviates the typename of Macro for brevity.
261 * Magic.py: %whos abbreviates the typename of Macro for brevity.
256
262
257 2006-11-24 Walter Doerwald <walter@livinglogic.de>
263 2006-11-24 Walter Doerwald <walter@livinglogic.de>
258 * IPython/Extensions/astyle.py: Do a relative import of ipipe, so that
264 * IPython/Extensions/astyle.py: Do a relative import of ipipe, so that
259 we don't get a duplicate ipipe module, where registration of the xrepr
265 we don't get a duplicate ipipe module, where registration of the xrepr
260 implementation for Text is useless.
266 implementation for Text is useless.
261
267
262 * IPython/Extensions/ipipe.py: Fix __xrepr__() implementation for ils.
268 * IPython/Extensions/ipipe.py: Fix __xrepr__() implementation for ils.
263
269
264 * IPython/Extensions/ibrowse.py: Fix keymapping for the enter command.
270 * IPython/Extensions/ibrowse.py: Fix keymapping for the enter command.
265
271
266 2006-11-24 Ville Vainio <vivainio@gmail.com>
272 2006-11-24 Ville Vainio <vivainio@gmail.com>
267
273
268 * Magic.py, manual_base.lyx: Kirill Smelkov patch:
274 * Magic.py, manual_base.lyx: Kirill Smelkov patch:
269 try to use "cProfile" instead of the slower pure python
275 try to use "cProfile" instead of the slower pure python
270 "profile"
276 "profile"
271
277
272 2006-11-23 Ville Vainio <vivainio@gmail.com>
278 2006-11-23 Ville Vainio <vivainio@gmail.com>
273
279
274 * manual_base.lyx: Kirill Smelkov patch: Fix wrong
280 * manual_base.lyx: Kirill Smelkov patch: Fix wrong
275 Qt+IPython+Designer link in documentation.
281 Qt+IPython+Designer link in documentation.
276
282
277 * Extensions/ipy_pydb.py: R. Bernstein's patch for passing
283 * Extensions/ipy_pydb.py: R. Bernstein's patch for passing
278 correct Pdb object to %pydb.
284 correct Pdb object to %pydb.
279
285
280
286
281 2006-11-22 Walter Doerwald <walter@livinglogic.de>
287 2006-11-22 Walter Doerwald <walter@livinglogic.de>
282 * IPython/Extensions/astyle.py: Text needs it's own implemenation of the
288 * IPython/Extensions/astyle.py: Text needs it's own implemenation of the
283 generic xrepr(), otherwise the list implementation would kick in.
289 generic xrepr(), otherwise the list implementation would kick in.
284
290
285 2006-11-21 Ville Vainio <vivainio@gmail.com>
291 2006-11-21 Ville Vainio <vivainio@gmail.com>
286
292
287 * upgrade_dir.py: Now actually overwrites a nonmodified user file
293 * upgrade_dir.py: Now actually overwrites a nonmodified user file
288 with one from UserConfig.
294 with one from UserConfig.
289
295
290 * ipy_profile_sh.py: Add dummy "depth" to var_expand lambda,
296 * ipy_profile_sh.py: Add dummy "depth" to var_expand lambda,
291 it was missing which broke the sh profile.
297 it was missing which broke the sh profile.
292
298
293 * completer.py: file completer now uses explicit '/' instead
299 * completer.py: file completer now uses explicit '/' instead
294 of os.path.join, expansion of 'foo' was broken on win32
300 of os.path.join, expansion of 'foo' was broken on win32
295 if there was one directory with name 'foobar'.
301 if there was one directory with name 'foobar'.
296
302
297 * A bunch of patches from Kirill Smelkov:
303 * A bunch of patches from Kirill Smelkov:
298
304
299 * [patch 9/9] doc: point bug-tracker URL to IPythons trac-tickets.
305 * [patch 9/9] doc: point bug-tracker URL to IPythons trac-tickets.
300
306
301 * [patch 7/9] Implement %page -r (page in raw mode) -
307 * [patch 7/9] Implement %page -r (page in raw mode) -
302
308
303 * [patch 5/9] ScientificPython webpage has moved
309 * [patch 5/9] ScientificPython webpage has moved
304
310
305 * [patch 4/9] The manual mentions %ds, should be %dhist
311 * [patch 4/9] The manual mentions %ds, should be %dhist
306
312
307 * [patch 3/9] Kill old bits from %prun doc.
313 * [patch 3/9] Kill old bits from %prun doc.
308
314
309 * [patch 1/9] Fix typos here and there.
315 * [patch 1/9] Fix typos here and there.
310
316
311 2006-11-08 Ville Vainio <vivainio@gmail.com>
317 2006-11-08 Ville Vainio <vivainio@gmail.com>
312
318
313 * completer.py (attr_matches): catch all exceptions raised
319 * completer.py (attr_matches): catch all exceptions raised
314 by eval of expr with dots.
320 by eval of expr with dots.
315
321
316 2006-11-07 Fernando Perez <Fernando.Perez@colorado.edu>
322 2006-11-07 Fernando Perez <Fernando.Perez@colorado.edu>
317
323
318 * IPython/iplib.py (runsource): Prepend an 'if 1:' to the user
324 * IPython/iplib.py (runsource): Prepend an 'if 1:' to the user
319 input if it starts with whitespace. This allows you to paste
325 input if it starts with whitespace. This allows you to paste
320 indented input from any editor without manually having to type in
326 indented input from any editor without manually having to type in
321 the 'if 1:', which is convenient when working interactively.
327 the 'if 1:', which is convenient when working interactively.
322 Slightly modifed version of a patch by Bo Peng
328 Slightly modifed version of a patch by Bo Peng
323 <bpeng-AT-rice.edu>.
329 <bpeng-AT-rice.edu>.
324
330
325 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
331 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
326
332
327 * IPython/irunner.py (main): modified irunner so it automatically
333 * IPython/irunner.py (main): modified irunner so it automatically
328 recognizes the right runner to use based on the extension (.py for
334 recognizes the right runner to use based on the extension (.py for
329 python, .ipy for ipython and .sage for sage).
335 python, .ipy for ipython and .sage for sage).
330
336
331 * IPython/iplib.py (InteractiveShell.ipconfig): new builtin, also
337 * IPython/iplib.py (InteractiveShell.ipconfig): new builtin, also
332 visible in ipapi as ip.config(), to programatically control the
338 visible in ipapi as ip.config(), to programatically control the
333 internal rc object. There's an accompanying %config magic for
339 internal rc object. There's an accompanying %config magic for
334 interactive use, which has been enhanced to match the
340 interactive use, which has been enhanced to match the
335 funtionality in ipconfig.
341 funtionality in ipconfig.
336
342
337 * IPython/Magic.py (magic_system_verbose): Change %system_verbose
343 * IPython/Magic.py (magic_system_verbose): Change %system_verbose
338 so it's not just a toggle, it now takes an argument. Add support
344 so it's not just a toggle, it now takes an argument. Add support
339 for a customizable header when making system calls, as the new
345 for a customizable header when making system calls, as the new
340 system_header variable in the ipythonrc file.
346 system_header variable in the ipythonrc file.
341
347
342 2006-11-03 Walter Doerwald <walter@livinglogic.de>
348 2006-11-03 Walter Doerwald <walter@livinglogic.de>
343
349
344 * IPython/Extensions/ipipe.py: xrepr(), xiter() and xattrs() are now
350 * IPython/Extensions/ipipe.py: xrepr(), xiter() and xattrs() are now
345 generic functions (using Philip J. Eby's simplegeneric package).
351 generic functions (using Philip J. Eby's simplegeneric package).
346 This makes it possible to customize the display of third-party classes
352 This makes it possible to customize the display of third-party classes
347 without having to monkeypatch them. xiter() no longer supports a mode
353 without having to monkeypatch them. xiter() no longer supports a mode
348 argument and the XMode class has been removed. The same functionality can
354 argument and the XMode class has been removed. The same functionality can
349 be implemented via IterAttributeDescriptor and IterMethodDescriptor.
355 be implemented via IterAttributeDescriptor and IterMethodDescriptor.
350 One consequence of the switch to generic functions is that xrepr() and
356 One consequence of the switch to generic functions is that xrepr() and
351 xattrs() implementation must define the default value for the mode
357 xattrs() implementation must define the default value for the mode
352 argument themselves and xattrs() implementations must return real
358 argument themselves and xattrs() implementations must return real
353 descriptors.
359 descriptors.
354
360
355 * IPython/external: This new subpackage will contain all third-party
361 * IPython/external: This new subpackage will contain all third-party
356 packages that are bundled with IPython. (The first one is simplegeneric).
362 packages that are bundled with IPython. (The first one is simplegeneric).
357
363
358 * IPython/Extensions/ipipe.py (ifile/ils): Readd output of the parent
364 * IPython/Extensions/ipipe.py (ifile/ils): Readd output of the parent
359 directory which as been dropped in r1703.
365 directory which as been dropped in r1703.
360
366
361 * IPython/Extensions/ipipe.py (iless): Fixed.
367 * IPython/Extensions/ipipe.py (iless): Fixed.
362
368
363 * IPython/Extensions/ibrowse: Fixed sorting under Python 2.3.
369 * IPython/Extensions/ibrowse: Fixed sorting under Python 2.3.
364
370
365 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
371 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
366
372
367 * IPython/iplib.py (InteractiveShell.var_expand): fix stack
373 * IPython/iplib.py (InteractiveShell.var_expand): fix stack
368 handling in variable expansion so that shells and magics recognize
374 handling in variable expansion so that shells and magics recognize
369 function local scopes correctly. Bug reported by Brian.
375 function local scopes correctly. Bug reported by Brian.
370
376
371 * scripts/ipython: remove the very first entry in sys.path which
377 * scripts/ipython: remove the very first entry in sys.path which
372 Python auto-inserts for scripts, so that sys.path under IPython is
378 Python auto-inserts for scripts, so that sys.path under IPython is
373 as similar as possible to that under plain Python.
379 as similar as possible to that under plain Python.
374
380
375 * IPython/completer.py (IPCompleter.file_matches): Fix
381 * IPython/completer.py (IPCompleter.file_matches): Fix
376 tab-completion so that quotes are not closed unless the completion
382 tab-completion so that quotes are not closed unless the completion
377 is unambiguous. After a request by Stefan. Minor cleanups in
383 is unambiguous. After a request by Stefan. Minor cleanups in
378 ipy_stock_completers.
384 ipy_stock_completers.
379
385
380 2006-11-02 Ville Vainio <vivainio@gmail.com>
386 2006-11-02 Ville Vainio <vivainio@gmail.com>
381
387
382 * ipy_stock_completers.py: Add %run and %cd completers.
388 * ipy_stock_completers.py: Add %run and %cd completers.
383
389
384 * completer.py: Try running custom completer for both
390 * completer.py: Try running custom completer for both
385 "foo" and "%foo" if the command is just "foo". Ignore case
391 "foo" and "%foo" if the command is just "foo". Ignore case
386 when filtering possible completions.
392 when filtering possible completions.
387
393
388 * UserConfig/ipy_user_conf.py: install stock completers as default
394 * UserConfig/ipy_user_conf.py: install stock completers as default
389
395
390 * iplib.py (history_saving_wrapper), debugger(), ipy_pydb.py:
396 * iplib.py (history_saving_wrapper), debugger(), ipy_pydb.py:
391 simplified readline history save / restore through a wrapper
397 simplified readline history save / restore through a wrapper
392 function
398 function
393
399
394
400
395 2006-10-31 Ville Vainio <vivainio@gmail.com>
401 2006-10-31 Ville Vainio <vivainio@gmail.com>
396
402
397 * strdispatch.py, completer.py, ipy_stock_completers.py:
403 * strdispatch.py, completer.py, ipy_stock_completers.py:
398 Allow str_key ("command") in completer hooks. Implement
404 Allow str_key ("command") in completer hooks. Implement
399 trivial completer for 'import' (stdlib modules only). Rename
405 trivial completer for 'import' (stdlib modules only). Rename
400 ipy_linux_package_managers.py to ipy_stock_completers.py.
406 ipy_linux_package_managers.py to ipy_stock_completers.py.
401 SVN completer.
407 SVN completer.
402
408
403 * Extensions/ledit.py: %magic line editor for easily and
409 * Extensions/ledit.py: %magic line editor for easily and
404 incrementally manipulating lists of strings. The magic command
410 incrementally manipulating lists of strings. The magic command
405 name is %led.
411 name is %led.
406
412
407 2006-10-30 Ville Vainio <vivainio@gmail.com>
413 2006-10-30 Ville Vainio <vivainio@gmail.com>
408
414
409 * Debugger.py, iplib.py (debugger()): Add last set of Rocky
415 * Debugger.py, iplib.py (debugger()): Add last set of Rocky
410 Bernsteins's patches for pydb integration.
416 Bernsteins's patches for pydb integration.
411 http://bashdb.sourceforge.net/pydb/
417 http://bashdb.sourceforge.net/pydb/
412
418
413 * strdispatch.py, iplib.py, completer.py, IPython/__init__.py,
419 * strdispatch.py, iplib.py, completer.py, IPython/__init__.py,
414 Extensions/ipy_linux_package_managers.py, hooks.py: Implement
420 Extensions/ipy_linux_package_managers.py, hooks.py: Implement
415 custom completer hook to allow the users to implement their own
421 custom completer hook to allow the users to implement their own
416 completers. See ipy_linux_package_managers.py for example. The
422 completers. See ipy_linux_package_managers.py for example. The
417 hook name is 'complete_command'.
423 hook name is 'complete_command'.
418
424
419 2006-10-28 Fernando Perez <Fernando.Perez@colorado.edu>
425 2006-10-28 Fernando Perez <Fernando.Perez@colorado.edu>
420
426
421 * IPython/UserConfig/ipythonrc-scipy: minor cleanups to remove old
427 * IPython/UserConfig/ipythonrc-scipy: minor cleanups to remove old
422 Numeric leftovers.
428 Numeric leftovers.
423
429
424 * ipython.el (py-execute-region): apply Stefan's patch to fix
430 * ipython.el (py-execute-region): apply Stefan's patch to fix
425 garbled results if the python shell hasn't been previously started.
431 garbled results if the python shell hasn't been previously started.
426
432
427 * IPython/genutils.py (arg_split): moved to genutils, since it's a
433 * IPython/genutils.py (arg_split): moved to genutils, since it's a
428 pretty generic function and useful for other things.
434 pretty generic function and useful for other things.
429
435
430 * IPython/OInspect.py (getsource): Add customizable source
436 * IPython/OInspect.py (getsource): Add customizable source
431 extractor. After a request/patch form W. Stein (SAGE).
437 extractor. After a request/patch form W. Stein (SAGE).
432
438
433 * IPython/irunner.py (InteractiveRunner.run_source): reset tty
439 * IPython/irunner.py (InteractiveRunner.run_source): reset tty
434 window size to a more reasonable value from what pexpect does,
440 window size to a more reasonable value from what pexpect does,
435 since their choice causes wrapping bugs with long input lines.
441 since their choice causes wrapping bugs with long input lines.
436
442
437 2006-10-28 Ville Vainio <vivainio@gmail.com>
443 2006-10-28 Ville Vainio <vivainio@gmail.com>
438
444
439 * Magic.py (%run): Save and restore the readline history from
445 * Magic.py (%run): Save and restore the readline history from
440 file around %run commands to prevent side effects from
446 file around %run commands to prevent side effects from
441 %runned programs that might use readline (e.g. pydb).
447 %runned programs that might use readline (e.g. pydb).
442
448
443 * extensions/ipy_pydb.py: Adds %pydb magic when imported, for
449 * extensions/ipy_pydb.py: Adds %pydb magic when imported, for
444 invoking the pydb enhanced debugger.
450 invoking the pydb enhanced debugger.
445
451
446 2006-10-23 Walter Doerwald <walter@livinglogic.de>
452 2006-10-23 Walter Doerwald <walter@livinglogic.de>
447
453
448 * IPython/Extensions/ipipe.py (ifile): Remove all methods that
454 * IPython/Extensions/ipipe.py (ifile): Remove all methods that
449 call the base class method and propagate the return value to
455 call the base class method and propagate the return value to
450 ifile. This is now done by path itself.
456 ifile. This is now done by path itself.
451
457
452 2006-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
458 2006-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
453
459
454 * IPython/ipapi.py (IPApi.__init__): Added new entry to public
460 * IPython/ipapi.py (IPApi.__init__): Added new entry to public
455 api: set_crash_handler(), to expose the ability to change the
461 api: set_crash_handler(), to expose the ability to change the
456 internal crash handler.
462 internal crash handler.
457
463
458 * IPython/CrashHandler.py (CrashHandler.__init__): abstract out
464 * IPython/CrashHandler.py (CrashHandler.__init__): abstract out
459 the various parameters of the crash handler so that apps using
465 the various parameters of the crash handler so that apps using
460 IPython as their engine can customize crash handling. Ipmlemented
466 IPython as their engine can customize crash handling. Ipmlemented
461 at the request of SAGE.
467 at the request of SAGE.
462
468
463 2006-10-14 Ville Vainio <vivainio@gmail.com>
469 2006-10-14 Ville Vainio <vivainio@gmail.com>
464
470
465 * Magic.py, ipython.el: applied first "safe" part of Rocky
471 * Magic.py, ipython.el: applied first "safe" part of Rocky
466 Bernstein's patch set for pydb integration.
472 Bernstein's patch set for pydb integration.
467
473
468 * Magic.py (%unalias, %alias): %store'd aliases can now be
474 * Magic.py (%unalias, %alias): %store'd aliases can now be
469 removed with '%unalias'. %alias w/o args now shows most
475 removed with '%unalias'. %alias w/o args now shows most
470 interesting (stored / manually defined) aliases last
476 interesting (stored / manually defined) aliases last
471 where they catch the eye w/o scrolling.
477 where they catch the eye w/o scrolling.
472
478
473 * Magic.py (%rehashx), ext_rehashdir.py: files with
479 * Magic.py (%rehashx), ext_rehashdir.py: files with
474 'py' extension are always considered executable, even
480 'py' extension are always considered executable, even
475 when not in PATHEXT environment variable.
481 when not in PATHEXT environment variable.
476
482
477 2006-10-12 Ville Vainio <vivainio@gmail.com>
483 2006-10-12 Ville Vainio <vivainio@gmail.com>
478
484
479 * jobctrl.py: Add new "jobctrl" extension for spawning background
485 * jobctrl.py: Add new "jobctrl" extension for spawning background
480 processes with "&find /". 'import jobctrl' to try it out. Requires
486 processes with "&find /". 'import jobctrl' to try it out. Requires
481 'subprocess' module, standard in python 2.4+.
487 'subprocess' module, standard in python 2.4+.
482
488
483 * iplib.py (expand_aliases, handle_alias): Aliases expand transitively,
489 * iplib.py (expand_aliases, handle_alias): Aliases expand transitively,
484 so if foo -> bar and bar -> baz, then foo -> baz.
490 so if foo -> bar and bar -> baz, then foo -> baz.
485
491
486 2006-10-09 Fernando Perez <Fernando.Perez@colorado.edu>
492 2006-10-09 Fernando Perez <Fernando.Perez@colorado.edu>
487
493
488 * IPython/Magic.py (Magic.parse_options): add a new posix option
494 * IPython/Magic.py (Magic.parse_options): add a new posix option
489 to allow parsing of input args in magics that doesn't strip quotes
495 to allow parsing of input args in magics that doesn't strip quotes
490 (if posix=False). This also closes %timeit bug reported by
496 (if posix=False). This also closes %timeit bug reported by
491 Stefan.
497 Stefan.
492
498
493 2006-10-03 Ville Vainio <vivainio@gmail.com>
499 2006-10-03 Ville Vainio <vivainio@gmail.com>
494
500
495 * iplib.py (raw_input, interact): Return ValueError catching for
501 * iplib.py (raw_input, interact): Return ValueError catching for
496 raw_input. Fixes infinite loop for sys.stdin.close() or
502 raw_input. Fixes infinite loop for sys.stdin.close() or
497 sys.stdout.close().
503 sys.stdout.close().
498
504
499 2006-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
505 2006-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
500
506
501 * IPython/irunner.py (InteractiveRunner.run_source): small fixes
507 * IPython/irunner.py (InteractiveRunner.run_source): small fixes
502 to help in handling doctests. irunner is now pretty useful for
508 to help in handling doctests. irunner is now pretty useful for
503 running standalone scripts and simulate a full interactive session
509 running standalone scripts and simulate a full interactive session
504 in a format that can be then pasted as a doctest.
510 in a format that can be then pasted as a doctest.
505
511
506 * IPython/iplib.py (InteractiveShell.__init__): Install exit/quit
512 * IPython/iplib.py (InteractiveShell.__init__): Install exit/quit
507 on top of the default (useless) ones. This also fixes the nasty
513 on top of the default (useless) ones. This also fixes the nasty
508 way in which 2.5's Quitter() exits (reverted [1785]).
514 way in which 2.5's Quitter() exits (reverted [1785]).
509
515
510 * IPython/Debugger.py (Pdb.__init__): Fix ipdb to work with python
516 * IPython/Debugger.py (Pdb.__init__): Fix ipdb to work with python
511 2.5.
517 2.5.
512
518
513 * IPython/ultraTB.py (TBTools.set_colors): Make sure that ipdb
519 * IPython/ultraTB.py (TBTools.set_colors): Make sure that ipdb
514 color scheme is updated as well when color scheme is changed
520 color scheme is updated as well when color scheme is changed
515 interactively.
521 interactively.
516
522
517 2006-09-27 Ville Vainio <vivainio@gmail.com>
523 2006-09-27 Ville Vainio <vivainio@gmail.com>
518
524
519 * iplib.py (raw_input): python 2.5 closes stdin on quit -> avoid
525 * iplib.py (raw_input): python 2.5 closes stdin on quit -> avoid
520 infinite loop and just exit. It's a hack, but will do for a while.
526 infinite loop and just exit. It's a hack, but will do for a while.
521
527
522 2006-08-25 Walter Doerwald <walter@livinglogic.de>
528 2006-08-25 Walter Doerwald <walter@livinglogic.de>
523
529
524 * IPython/Extensions/ipipe.py (ils): Add arguments dirs and files to
530 * IPython/Extensions/ipipe.py (ils): Add arguments dirs and files to
525 the constructor, this makes it possible to get a list of only directories
531 the constructor, this makes it possible to get a list of only directories
526 or only files.
532 or only files.
527
533
528 2006-08-12 Ville Vainio <vivainio@gmail.com>
534 2006-08-12 Ville Vainio <vivainio@gmail.com>
529
535
530 * Fakemodule.py, OInspect.py: Reverted 2006-08-11 mods,
536 * Fakemodule.py, OInspect.py: Reverted 2006-08-11 mods,
531 they broke unittest
537 they broke unittest
532
538
533 2006-08-11 Ville Vainio <vivainio@gmail.com>
539 2006-08-11 Ville Vainio <vivainio@gmail.com>
534
540
535 * Fakemodule.py, OInspect.py: remove 2006-08-09 monkepatch
541 * Fakemodule.py, OInspect.py: remove 2006-08-09 monkepatch
536 by resolving issue properly, i.e. by inheriting FakeModule
542 by resolving issue properly, i.e. by inheriting FakeModule
537 from types.ModuleType. Pickling ipython interactive data
543 from types.ModuleType. Pickling ipython interactive data
538 should still work as usual (testing appreciated).
544 should still work as usual (testing appreciated).
539
545
540 2006-08-09 Fernando Perez <Fernando.Perez@colorado.edu>
546 2006-08-09 Fernando Perez <Fernando.Perez@colorado.edu>
541
547
542 * IPython/OInspect.py: monkeypatch inspect from the stdlib if
548 * IPython/OInspect.py: monkeypatch inspect from the stdlib if
543 running under python 2.3 with code from 2.4 to fix a bug with
549 running under python 2.3 with code from 2.4 to fix a bug with
544 help(). Reported by the Debian maintainers, Norbert Tretkowski
550 help(). Reported by the Debian maintainers, Norbert Tretkowski
545 <norbert-AT-tretkowski.de> and Alexandre Fayolle
551 <norbert-AT-tretkowski.de> and Alexandre Fayolle
546 <afayolle-AT-debian.org>.
552 <afayolle-AT-debian.org>.
547
553
548 2006-08-04 Walter Doerwald <walter@livinglogic.de>
554 2006-08-04 Walter Doerwald <walter@livinglogic.de>
549
555
550 * IPython/Extensions/ibrowse.py: Fixed the help message in the footer
556 * IPython/Extensions/ibrowse.py: Fixed the help message in the footer
551 (which was displaying "quit" twice).
557 (which was displaying "quit" twice).
552
558
553 2006-07-28 Walter Doerwald <walter@livinglogic.de>
559 2006-07-28 Walter Doerwald <walter@livinglogic.de>
554
560
555 * IPython/Extensions/ipipe.py: Fix isort.__iter__() (was still using
561 * IPython/Extensions/ipipe.py: Fix isort.__iter__() (was still using
556 the mode argument).
562 the mode argument).
557
563
558 2006-07-27 Walter Doerwald <walter@livinglogic.de>
564 2006-07-27 Walter Doerwald <walter@livinglogic.de>
559
565
560 * IPython/Extensions/ipipe.py: Fix getglobals() if we're
566 * IPython/Extensions/ipipe.py: Fix getglobals() if we're
561 not running under IPython.
567 not running under IPython.
562
568
563 * IPython/Extensions/ipipe.py: Rename XAttr to AttributeDetail
569 * IPython/Extensions/ipipe.py: Rename XAttr to AttributeDetail
564 and make it iterable (iterating over the attribute itself). Add two new
570 and make it iterable (iterating over the attribute itself). Add two new
565 magic strings for __xattrs__(): If the string starts with "-", the attribute
571 magic strings for __xattrs__(): If the string starts with "-", the attribute
566 will not be displayed in ibrowse's detail view (but it can still be
572 will not be displayed in ibrowse's detail view (but it can still be
567 iterated over). This makes it possible to add attributes that are large
573 iterated over). This makes it possible to add attributes that are large
568 lists or generator methods to the detail view. Replace magic attribute names
574 lists or generator methods to the detail view. Replace magic attribute names
569 and _attrname() and _getattr() with "descriptors": For each type of magic
575 and _attrname() and _getattr() with "descriptors": For each type of magic
570 attribute name there's a subclass of Descriptor: None -> SelfDescriptor();
576 attribute name there's a subclass of Descriptor: None -> SelfDescriptor();
571 "foo" -> AttributeDescriptor("foo"); "foo()" -> MethodDescriptor("foo");
577 "foo" -> AttributeDescriptor("foo"); "foo()" -> MethodDescriptor("foo");
572 "-foo" -> IterAttributeDescriptor("foo"); "-foo()" -> IterMethodDescriptor("foo");
578 "-foo" -> IterAttributeDescriptor("foo"); "-foo()" -> IterMethodDescriptor("foo");
573 foo() -> FunctionDescriptor(foo). Magic strings returned from __xattrs__()
579 foo() -> FunctionDescriptor(foo). Magic strings returned from __xattrs__()
574 are still supported.
580 are still supported.
575
581
576 * IPython/Extensions/ibrowse.py: If fetching the next row from the input
582 * IPython/Extensions/ibrowse.py: If fetching the next row from the input
577 fails in ibrowse.fetch(), the exception object is added as the last item
583 fails in ibrowse.fetch(), the exception object is added as the last item
578 and item fetching is canceled. This prevents ibrowse from aborting if e.g.
584 and item fetching is canceled. This prevents ibrowse from aborting if e.g.
579 a generator throws an exception midway through execution.
585 a generator throws an exception midway through execution.
580
586
581 * IPython/Extensions/ipipe.py: Turn ifile's properties mimetype and
587 * IPython/Extensions/ipipe.py: Turn ifile's properties mimetype and
582 encoding into methods.
588 encoding into methods.
583
589
584 2006-07-26 Ville Vainio <vivainio@gmail.com>
590 2006-07-26 Ville Vainio <vivainio@gmail.com>
585
591
586 * iplib.py: history now stores multiline input as single
592 * iplib.py: history now stores multiline input as single
587 history entries. Patch by Jorgen Cederlof.
593 history entries. Patch by Jorgen Cederlof.
588
594
589 2006-07-18 Walter Doerwald <walter@livinglogic.de>
595 2006-07-18 Walter Doerwald <walter@livinglogic.de>
590
596
591 * IPython/Extensions/ibrowse.py: Make cursor visible over
597 * IPython/Extensions/ibrowse.py: Make cursor visible over
592 non existing attributes.
598 non existing attributes.
593
599
594 2006-07-14 Walter Doerwald <walter@livinglogic.de>
600 2006-07-14 Walter Doerwald <walter@livinglogic.de>
595
601
596 * IPython/Extensions/ipipe.py (ix): Use os.popen4() so that the
602 * IPython/Extensions/ipipe.py (ix): Use os.popen4() so that the
597 error output of the running command doesn't mess up the screen.
603 error output of the running command doesn't mess up the screen.
598
604
599 2006-07-13 Walter Doerwald <walter@livinglogic.de>
605 2006-07-13 Walter Doerwald <walter@livinglogic.de>
600
606
601 * IPython/Extensions/ipipe.py (isort): Make isort usable without
607 * IPython/Extensions/ipipe.py (isort): Make isort usable without
602 argument. This sorts the items themselves.
608 argument. This sorts the items themselves.
603
609
604 2006-07-12 Walter Doerwald <walter@livinglogic.de>
610 2006-07-12 Walter Doerwald <walter@livinglogic.de>
605
611
606 * IPython/Extensions/ipipe.py (eval, ifilter, isort, ieval):
612 * IPython/Extensions/ipipe.py (eval, ifilter, isort, ieval):
607 Compile expression strings into code objects. This should speed
613 Compile expression strings into code objects. This should speed
608 up ifilter and friends somewhat.
614 up ifilter and friends somewhat.
609
615
610 2006-07-08 Ville Vainio <vivainio@gmail.com>
616 2006-07-08 Ville Vainio <vivainio@gmail.com>
611
617
612 * Magic.py: %cpaste now strips > from the beginning of lines
618 * Magic.py: %cpaste now strips > from the beginning of lines
613 to ease pasting quoted code from emails. Contributed by
619 to ease pasting quoted code from emails. Contributed by
614 Stefan van der Walt.
620 Stefan van der Walt.
615
621
616 2006-06-29 Ville Vainio <vivainio@gmail.com>
622 2006-06-29 Ville Vainio <vivainio@gmail.com>
617
623
618 * ipmaker.py, Shell.py: qt4agg matplotlib backend support for pylab
624 * ipmaker.py, Shell.py: qt4agg matplotlib backend support for pylab
619 mode, patch contributed by Darren Dale. NEEDS TESTING!
625 mode, patch contributed by Darren Dale. NEEDS TESTING!
620
626
621 2006-06-28 Walter Doerwald <walter@livinglogic.de>
627 2006-06-28 Walter Doerwald <walter@livinglogic.de>
622
628
623 * IPython/Extensions/ibrowse.py: Give the ibrowse cursor row
629 * IPython/Extensions/ibrowse.py: Give the ibrowse cursor row
624 a blue background. Fix fetching new display rows when the browser
630 a blue background. Fix fetching new display rows when the browser
625 scrolls more than a screenful (e.g. by using the goto command).
631 scrolls more than a screenful (e.g. by using the goto command).
626
632
627 2006-06-27 Ville Vainio <vivainio@gmail.com>
633 2006-06-27 Ville Vainio <vivainio@gmail.com>
628
634
629 * Magic.py (_inspect, _ofind) Apply David Huard's
635 * Magic.py (_inspect, _ofind) Apply David Huard's
630 patch for displaying the correct docstring for 'property'
636 patch for displaying the correct docstring for 'property'
631 attributes.
637 attributes.
632
638
633 2006-06-23 Walter Doerwald <walter@livinglogic.de>
639 2006-06-23 Walter Doerwald <walter@livinglogic.de>
634
640
635 * IPython/Extensions/ibrowse.py: Put the documentation of the keyboard
641 * IPython/Extensions/ibrowse.py: Put the documentation of the keyboard
636 commands into the methods implementing them.
642 commands into the methods implementing them.
637
643
638 2006-06-22 Fernando Perez <Fernando.Perez@colorado.edu>
644 2006-06-22 Fernando Perez <Fernando.Perez@colorado.edu>
639
645
640 * ipython.el (ipython-indentation-hook): cleanup patch, submitted
646 * ipython.el (ipython-indentation-hook): cleanup patch, submitted
641 by Kov Chai <tchaikov-AT-gmail.com>. He notes that the original
647 by Kov Chai <tchaikov-AT-gmail.com>. He notes that the original
642 autoindent support was authored by Jin Liu.
648 autoindent support was authored by Jin Liu.
643
649
644 2006-06-22 Walter Doerwald <walter@livinglogic.de>
650 2006-06-22 Walter Doerwald <walter@livinglogic.de>
645
651
646 * IPython/Extensions/ibrowse.py: Replace the plain dictionaries used
652 * IPython/Extensions/ibrowse.py: Replace the plain dictionaries used
647 for keymaps with a custom class that simplifies handling.
653 for keymaps with a custom class that simplifies handling.
648
654
649 2006-06-19 Walter Doerwald <walter@livinglogic.de>
655 2006-06-19 Walter Doerwald <walter@livinglogic.de>
650
656
651 * IPython/Extensions/ibrowse.py: ibrowse now properly handles terminal
657 * IPython/Extensions/ibrowse.py: ibrowse now properly handles terminal
652 resizing. This requires Python 2.5 to work.
658 resizing. This requires Python 2.5 to work.
653
659
654 2006-06-16 Walter Doerwald <walter@livinglogic.de>
660 2006-06-16 Walter Doerwald <walter@livinglogic.de>
655
661
656 * IPython/Extensions/ibrowse.py: Add two new commands to
662 * IPython/Extensions/ibrowse.py: Add two new commands to
657 ibrowse: "hideattr" (mapped to "h") hides the attribute under
663 ibrowse: "hideattr" (mapped to "h") hides the attribute under
658 the cursor. "unhiderattrs" (mapped to "H") reveals all hidden
664 the cursor. "unhiderattrs" (mapped to "H") reveals all hidden
659 attributes again. Remapped the help command to "?". Display
665 attributes again. Remapped the help command to "?". Display
660 keycodes in the range 0x01-0x1F as CTRL-xx. Add CTRL-a and CTRL-e
666 keycodes in the range 0x01-0x1F as CTRL-xx. Add CTRL-a and CTRL-e
661 as keys for the "home" and "end" commands. Add three new commands
667 as keys for the "home" and "end" commands. Add three new commands
662 to the input mode for "find" and friends: "delend" (CTRL-K)
668 to the input mode for "find" and friends: "delend" (CTRL-K)
663 deletes to the end of line. "incsearchup" searches upwards in the
669 deletes to the end of line. "incsearchup" searches upwards in the
664 command history for an input that starts with the text before the cursor.
670 command history for an input that starts with the text before the cursor.
665 "incsearchdown" does the same downwards. Removed a bogus mapping of
671 "incsearchdown" does the same downwards. Removed a bogus mapping of
666 the x key to "delete".
672 the x key to "delete".
667
673
668 2006-06-15 Ville Vainio <vivainio@gmail.com>
674 2006-06-15 Ville Vainio <vivainio@gmail.com>
669
675
670 * iplib.py, hooks.py: Added new generate_prompt hook that can be
676 * iplib.py, hooks.py: Added new generate_prompt hook that can be
671 used to create prompts dynamically, instead of the "old" way of
677 used to create prompts dynamically, instead of the "old" way of
672 assigning "magic" strings to prompt_in1 and prompt_in2. The old
678 assigning "magic" strings to prompt_in1 and prompt_in2. The old
673 way still works (it's invoked by the default hook), of course.
679 way still works (it's invoked by the default hook), of course.
674
680
675 * Prompts.py: added generate_output_prompt hook for altering output
681 * Prompts.py: added generate_output_prompt hook for altering output
676 prompt
682 prompt
677
683
678 * Release.py: Changed version string to 0.7.3.svn.
684 * Release.py: Changed version string to 0.7.3.svn.
679
685
680 2006-06-15 Walter Doerwald <walter@livinglogic.de>
686 2006-06-15 Walter Doerwald <walter@livinglogic.de>
681
687
682 * IPython/Extensions/ibrowse.py: Change _BrowserLevel.moveto() so that
688 * IPython/Extensions/ibrowse.py: Change _BrowserLevel.moveto() so that
683 the call to fetch() always tries to fetch enough data for at least one
689 the call to fetch() always tries to fetch enough data for at least one
684 full screen. This makes it possible to simply call moveto(0,0,True) in
690 full screen. This makes it possible to simply call moveto(0,0,True) in
685 the constructor. Fix typos and removed the obsolete goto attribute.
691 the constructor. Fix typos and removed the obsolete goto attribute.
686
692
687 2006-06-12 Ville Vainio <vivainio@gmail.com>
693 2006-06-12 Ville Vainio <vivainio@gmail.com>
688
694
689 * ipy_profile_sh.py: applied Krisha Mohan Gundu's patch for
695 * ipy_profile_sh.py: applied Krisha Mohan Gundu's patch for
690 allowing $variable interpolation within multiline statements,
696 allowing $variable interpolation within multiline statements,
691 though so far only with "sh" profile for a testing period.
697 though so far only with "sh" profile for a testing period.
692 The patch also enables splitting long commands with \ but it
698 The patch also enables splitting long commands with \ but it
693 doesn't work properly yet.
699 doesn't work properly yet.
694
700
695 2006-06-12 Walter Doerwald <walter@livinglogic.de>
701 2006-06-12 Walter Doerwald <walter@livinglogic.de>
696
702
697 * IPython/Extensions/ibrowse.py (_dodisplay): Display the length of the
703 * IPython/Extensions/ibrowse.py (_dodisplay): Display the length of the
698 input history and the position of the cursor in the input history for
704 input history and the position of the cursor in the input history for
699 the find, findbackwards and goto command.
705 the find, findbackwards and goto command.
700
706
701 2006-06-10 Walter Doerwald <walter@livinglogic.de>
707 2006-06-10 Walter Doerwald <walter@livinglogic.de>
702
708
703 * IPython/Extensions/ibrowse.py: Add a class _CommandInput that
709 * IPython/Extensions/ibrowse.py: Add a class _CommandInput that
704 implements the basic functionality of browser commands that require
710 implements the basic functionality of browser commands that require
705 input. Reimplement the goto, find and findbackwards commands as
711 input. Reimplement the goto, find and findbackwards commands as
706 subclasses of _CommandInput. Add an input history and keymaps to those
712 subclasses of _CommandInput. Add an input history and keymaps to those
707 commands. Add "\r" as a keyboard shortcut for the enterdefault and
713 commands. Add "\r" as a keyboard shortcut for the enterdefault and
708 execute commands.
714 execute commands.
709
715
710 2006-06-07 Ville Vainio <vivainio@gmail.com>
716 2006-06-07 Ville Vainio <vivainio@gmail.com>
711
717
712 * iplib.py: ipython mybatch.ipy exits ipython immediately after
718 * iplib.py: ipython mybatch.ipy exits ipython immediately after
713 running the batch files instead of leaving the session open.
719 running the batch files instead of leaving the session open.
714
720
715 2006-06-07 Fernando Perez <Fernando.Perez@colorado.edu>
721 2006-06-07 Fernando Perez <Fernando.Perez@colorado.edu>
716
722
717 * IPython/iplib.py (InteractiveShell.__init__): update BSD fix, as
723 * IPython/iplib.py (InteractiveShell.__init__): update BSD fix, as
718 the original fix was incomplete. Patch submitted by W. Maier.
724 the original fix was incomplete. Patch submitted by W. Maier.
719
725
720 2006-06-07 Ville Vainio <vivainio@gmail.com>
726 2006-06-07 Ville Vainio <vivainio@gmail.com>
721
727
722 * iplib.py,Magic.py, ipmaker.py (magic_rehashx):
728 * iplib.py,Magic.py, ipmaker.py (magic_rehashx):
723 Confirmation prompts can be supressed by 'quiet' option.
729 Confirmation prompts can be supressed by 'quiet' option.
724 _ip.options.quiet = 1 means "assume yes for all yes/no queries".
730 _ip.options.quiet = 1 means "assume yes for all yes/no queries".
725
731
726 2006-06-06 *** Released version 0.7.2
732 2006-06-06 *** Released version 0.7.2
727
733
728 2006-06-06 Fernando Perez <Fernando.Perez@colorado.edu>
734 2006-06-06 Fernando Perez <Fernando.Perez@colorado.edu>
729
735
730 * IPython/Release.py (version): Made 0.7.2 final for release.
736 * IPython/Release.py (version): Made 0.7.2 final for release.
731 Repo tagged and release cut.
737 Repo tagged and release cut.
732
738
733 2006-06-05 Ville Vainio <vivainio@gmail.com>
739 2006-06-05 Ville Vainio <vivainio@gmail.com>
734
740
735 * Magic.py (magic_rehashx): Honor no_alias list earlier in
741 * Magic.py (magic_rehashx): Honor no_alias list earlier in
736 %rehashx, to avoid clobbering builtins in ipy_profile_sh.py
742 %rehashx, to avoid clobbering builtins in ipy_profile_sh.py
737
743
738 * upgrade_dir.py: try import 'path' module a bit harder
744 * upgrade_dir.py: try import 'path' module a bit harder
739 (for %upgrade)
745 (for %upgrade)
740
746
741 2006-06-03 Fernando Perez <Fernando.Perez@colorado.edu>
747 2006-06-03 Fernando Perez <Fernando.Perez@colorado.edu>
742
748
743 * IPython/genutils.py (ask_yes_no): treat EOF as a default answer
749 * IPython/genutils.py (ask_yes_no): treat EOF as a default answer
744 instead of looping 20 times.
750 instead of looping 20 times.
745
751
746 * IPython/ipmaker.py (make_IPython): honor -ipythondir flag
752 * IPython/ipmaker.py (make_IPython): honor -ipythondir flag
747 correctly at initialization time. Bug reported by Krishna Mohan
753 correctly at initialization time. Bug reported by Krishna Mohan
748 Gundu <gkmohan-AT-gmail.com> on the user list.
754 Gundu <gkmohan-AT-gmail.com> on the user list.
749
755
750 * IPython/Release.py (version): Mark 0.7.2 version to start
756 * IPython/Release.py (version): Mark 0.7.2 version to start
751 testing for release on 06/06.
757 testing for release on 06/06.
752
758
753 2006-05-31 Fernando Perez <Fernando.Perez@colorado.edu>
759 2006-05-31 Fernando Perez <Fernando.Perez@colorado.edu>
754
760
755 * scripts/irunner: thin script interface so users don't have to
761 * scripts/irunner: thin script interface so users don't have to
756 find the module and call it as an executable, since modules rarely
762 find the module and call it as an executable, since modules rarely
757 live in people's PATH.
763 live in people's PATH.
758
764
759 * IPython/irunner.py (InteractiveRunner.__init__): added
765 * IPython/irunner.py (InteractiveRunner.__init__): added
760 delaybeforesend attribute to control delays with newer versions of
766 delaybeforesend attribute to control delays with newer versions of
761 pexpect. Thanks to detailed help from pexpect's author, Noah
767 pexpect. Thanks to detailed help from pexpect's author, Noah
762 Spurrier <noah-AT-noah.org>. Noted how to use the SAGE runner
768 Spurrier <noah-AT-noah.org>. Noted how to use the SAGE runner
763 correctly (it works in NoColor mode).
769 correctly (it works in NoColor mode).
764
770
765 * IPython/iplib.py (handle_normal): fix nasty crash reported on
771 * IPython/iplib.py (handle_normal): fix nasty crash reported on
766 SAGE list, from improper log() calls.
772 SAGE list, from improper log() calls.
767
773
768 2006-05-31 Ville Vainio <vivainio@gmail.com>
774 2006-05-31 Ville Vainio <vivainio@gmail.com>
769
775
770 * upgrade_dir.py, Magic.py (magic_upgrade): call upgrade_dir
776 * upgrade_dir.py, Magic.py (magic_upgrade): call upgrade_dir
771 with args in parens to work correctly with dirs that have spaces.
777 with args in parens to work correctly with dirs that have spaces.
772
778
773 2006-05-30 Fernando Perez <Fernando.Perez@colorado.edu>
779 2006-05-30 Fernando Perez <Fernando.Perez@colorado.edu>
774
780
775 * IPython/Logger.py (Logger.logstart): add option to log raw input
781 * IPython/Logger.py (Logger.logstart): add option to log raw input
776 instead of the processed one. A -r flag was added to the
782 instead of the processed one. A -r flag was added to the
777 %logstart magic used for controlling logging.
783 %logstart magic used for controlling logging.
778
784
779 2006-05-29 Fernando Perez <Fernando.Perez@colorado.edu>
785 2006-05-29 Fernando Perez <Fernando.Perez@colorado.edu>
780
786
781 * IPython/iplib.py (InteractiveShell.__init__): add check for the
787 * IPython/iplib.py (InteractiveShell.__init__): add check for the
782 *BSDs to omit --color from all 'ls' aliases, since *BSD ls doesn't
788 *BSDs to omit --color from all 'ls' aliases, since *BSD ls doesn't
783 recognize the option. After a bug report by Will Maier. This
789 recognize the option. After a bug report by Will Maier. This
784 closes #64 (will do it after confirmation from W. Maier).
790 closes #64 (will do it after confirmation from W. Maier).
785
791
786 * IPython/irunner.py: New module to run scripts as if manually
792 * IPython/irunner.py: New module to run scripts as if manually
787 typed into an interactive environment, based on pexpect. After a
793 typed into an interactive environment, based on pexpect. After a
788 submission by Ken Schutte <kschutte-AT-csail.mit.edu> on the
794 submission by Ken Schutte <kschutte-AT-csail.mit.edu> on the
789 ipython-user list. Simple unittests in the tests/ directory.
795 ipython-user list. Simple unittests in the tests/ directory.
790
796
791 * tools/release: add Will Maier, OpenBSD port maintainer, to
797 * tools/release: add Will Maier, OpenBSD port maintainer, to
792 recepients list. We are now officially part of the OpenBSD ports:
798 recepients list. We are now officially part of the OpenBSD ports:
793 http://www.openbsd.org/ports.html ! Many thanks to Will for the
799 http://www.openbsd.org/ports.html ! Many thanks to Will for the
794 work.
800 work.
795
801
796 2006-05-26 Fernando Perez <Fernando.Perez@colorado.edu>
802 2006-05-26 Fernando Perez <Fernando.Perez@colorado.edu>
797
803
798 * IPython/ipmaker.py (make_IPython): modify sys.argv fix (below)
804 * IPython/ipmaker.py (make_IPython): modify sys.argv fix (below)
799 so that it doesn't break tkinter apps.
805 so that it doesn't break tkinter apps.
800
806
801 * IPython/iplib.py (_prefilter): fix bug where aliases would
807 * IPython/iplib.py (_prefilter): fix bug where aliases would
802 shadow variables when autocall was fully off. Reported by SAGE
808 shadow variables when autocall was fully off. Reported by SAGE
803 author William Stein.
809 author William Stein.
804
810
805 * IPython/OInspect.py (Inspector.__init__): add a flag to control
811 * IPython/OInspect.py (Inspector.__init__): add a flag to control
806 at what detail level strings are computed when foo? is requested.
812 at what detail level strings are computed when foo? is requested.
807 This allows users to ask for example that the string form of an
813 This allows users to ask for example that the string form of an
808 object is only computed when foo?? is called, or even never, by
814 object is only computed when foo?? is called, or even never, by
809 setting the object_info_string_level >= 2 in the configuration
815 setting the object_info_string_level >= 2 in the configuration
810 file. This new option has been added and documented. After a
816 file. This new option has been added and documented. After a
811 request by SAGE to be able to control the printing of very large
817 request by SAGE to be able to control the printing of very large
812 objects more easily.
818 objects more easily.
813
819
814 2006-05-25 Fernando Perez <Fernando.Perez@colorado.edu>
820 2006-05-25 Fernando Perez <Fernando.Perez@colorado.edu>
815
821
816 * IPython/ipmaker.py (make_IPython): remove the ipython call path
822 * IPython/ipmaker.py (make_IPython): remove the ipython call path
817 from sys.argv, to be 100% consistent with how Python itself works
823 from sys.argv, to be 100% consistent with how Python itself works
818 (as seen for example with python -i file.py). After a bug report
824 (as seen for example with python -i file.py). After a bug report
819 by Jeffrey Collins.
825 by Jeffrey Collins.
820
826
821 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix
827 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix
822 nasty bug which was preventing custom namespaces with -pylab,
828 nasty bug which was preventing custom namespaces with -pylab,
823 reported by M. Foord. Minor cleanup, remove old matplotlib.matlab
829 reported by M. Foord. Minor cleanup, remove old matplotlib.matlab
824 compatibility (long gone from mpl).
830 compatibility (long gone from mpl).
825
831
826 * IPython/ipapi.py (make_session): name change: create->make. We
832 * IPython/ipapi.py (make_session): name change: create->make. We
827 use make in other places (ipmaker,...), it's shorter and easier to
833 use make in other places (ipmaker,...), it's shorter and easier to
828 type and say, etc. I'm trying to clean things before 0.7.2 so
834 type and say, etc. I'm trying to clean things before 0.7.2 so
829 that I can keep things stable wrt to ipapi in the chainsaw branch.
835 that I can keep things stable wrt to ipapi in the chainsaw branch.
830
836
831 * ipython.el: fix the py-pdbtrack-input-prompt variable so that
837 * ipython.el: fix the py-pdbtrack-input-prompt variable so that
832 python-mode recognizes our debugger mode. Add support for
838 python-mode recognizes our debugger mode. Add support for
833 autoindent inside (X)emacs. After a patch sent in by Jin Liu
839 autoindent inside (X)emacs. After a patch sent in by Jin Liu
834 <m.liu.jin-AT-gmail.com> originally written by
840 <m.liu.jin-AT-gmail.com> originally written by
835 doxgen-AT-newsmth.net (with minor modifications for xemacs
841 doxgen-AT-newsmth.net (with minor modifications for xemacs
836 compatibility)
842 compatibility)
837
843
838 * IPython/Debugger.py (Pdb.format_stack_entry): fix formatting of
844 * IPython/Debugger.py (Pdb.format_stack_entry): fix formatting of
839 tracebacks when walking the stack so that the stack tracking system
845 tracebacks when walking the stack so that the stack tracking system
840 in emacs' python-mode can identify the frames correctly.
846 in emacs' python-mode can identify the frames correctly.
841
847
842 * IPython/ipmaker.py (make_IPython): make the internal (and
848 * IPython/ipmaker.py (make_IPython): make the internal (and
843 default config) autoedit_syntax value false by default. Too many
849 default config) autoedit_syntax value false by default. Too many
844 users have complained to me (both on and off-list) about problems
850 users have complained to me (both on and off-list) about problems
845 with this option being on by default, so I'm making it default to
851 with this option being on by default, so I'm making it default to
846 off. It can still be enabled by anyone via the usual mechanisms.
852 off. It can still be enabled by anyone via the usual mechanisms.
847
853
848 * IPython/completer.py (Completer.attr_matches): add support for
854 * IPython/completer.py (Completer.attr_matches): add support for
849 PyCrust-style _getAttributeNames magic method. Patch contributed
855 PyCrust-style _getAttributeNames magic method. Patch contributed
850 by <mscott-AT-goldenspud.com>. Closes #50.
856 by <mscott-AT-goldenspud.com>. Closes #50.
851
857
852 * IPython/iplib.py (InteractiveShell.__init__): remove the
858 * IPython/iplib.py (InteractiveShell.__init__): remove the
853 deletion of exit/quit from __builtin__, which can break
859 deletion of exit/quit from __builtin__, which can break
854 third-party tools like the Zope debugging console. The
860 third-party tools like the Zope debugging console. The
855 %exit/%quit magics remain. In general, it's probably a good idea
861 %exit/%quit magics remain. In general, it's probably a good idea
856 not to delete anything from __builtin__, since we never know what
862 not to delete anything from __builtin__, since we never know what
857 that will break. In any case, python now (for 2.5) will support
863 that will break. In any case, python now (for 2.5) will support
858 'real' exit/quit, so this issue is moot. Closes #55.
864 'real' exit/quit, so this issue is moot. Closes #55.
859
865
860 * IPython/genutils.py (with_obj): rename the 'with' function to
866 * IPython/genutils.py (with_obj): rename the 'with' function to
861 'withobj' to avoid incompatibilities with Python 2.5, where 'with'
867 'withobj' to avoid incompatibilities with Python 2.5, where 'with'
862 becomes a language keyword. Closes #53.
868 becomes a language keyword. Closes #53.
863
869
864 * IPython/FakeModule.py (FakeModule.__init__): add a proper
870 * IPython/FakeModule.py (FakeModule.__init__): add a proper
865 __file__ attribute to this so it fools more things into thinking
871 __file__ attribute to this so it fools more things into thinking
866 it is a real module. Closes #59.
872 it is a real module. Closes #59.
867
873
868 * IPython/Magic.py (magic_edit): add -n option to open the editor
874 * IPython/Magic.py (magic_edit): add -n option to open the editor
869 at a specific line number. After a patch by Stefan van der Walt.
875 at a specific line number. After a patch by Stefan van der Walt.
870
876
871 2006-05-23 Fernando Perez <Fernando.Perez@colorado.edu>
877 2006-05-23 Fernando Perez <Fernando.Perez@colorado.edu>
872
878
873 * IPython/iplib.py (edit_syntax_error): fix crash when for some
879 * IPython/iplib.py (edit_syntax_error): fix crash when for some
874 reason the file could not be opened. After automatic crash
880 reason the file could not be opened. After automatic crash
875 reports sent by James Graham <jgraham-AT-ast.cam.ac.uk> and
881 reports sent by James Graham <jgraham-AT-ast.cam.ac.uk> and
876 Charles Dolan <charlespatrickdolan-AT-yahoo.com>.
882 Charles Dolan <charlespatrickdolan-AT-yahoo.com>.
877 (_should_recompile): Don't fire editor if using %bg, since there
883 (_should_recompile): Don't fire editor if using %bg, since there
878 is no file in the first place. From the same report as above.
884 is no file in the first place. From the same report as above.
879 (raw_input): protect against faulty third-party prefilters. After
885 (raw_input): protect against faulty third-party prefilters. After
880 an automatic crash report sent by Dirk Laurie <dirk-AT-sun.ac.za>
886 an automatic crash report sent by Dirk Laurie <dirk-AT-sun.ac.za>
881 while running under SAGE.
887 while running under SAGE.
882
888
883 2006-05-23 Ville Vainio <vivainio@gmail.com>
889 2006-05-23 Ville Vainio <vivainio@gmail.com>
884
890
885 * ipapi.py: Stripped down ip.to_user_ns() to work only as
891 * ipapi.py: Stripped down ip.to_user_ns() to work only as
886 ip.to_user_ns("x1 y1"), which exposes vars x1 and y1. ipapi.get()
892 ip.to_user_ns("x1 y1"), which exposes vars x1 and y1. ipapi.get()
887 now returns None (again), unless dummy is specifically allowed by
893 now returns None (again), unless dummy is specifically allowed by
888 ipapi.get(allow_dummy=True).
894 ipapi.get(allow_dummy=True).
889
895
890 2006-05-18 Fernando Perez <Fernando.Perez@colorado.edu>
896 2006-05-18 Fernando Perez <Fernando.Perez@colorado.edu>
891
897
892 * IPython: remove all 2.2-compatibility objects and hacks from
898 * IPython: remove all 2.2-compatibility objects and hacks from
893 everywhere, since we only support 2.3 at this point. Docs
899 everywhere, since we only support 2.3 at this point. Docs
894 updated.
900 updated.
895
901
896 * IPython/ipapi.py (IPApi.__init__): Cleanup of all getters.
902 * IPython/ipapi.py (IPApi.__init__): Cleanup of all getters.
897 Anything requiring extra validation can be turned into a Python
903 Anything requiring extra validation can be turned into a Python
898 property in the future. I used a property for the db one b/c
904 property in the future. I used a property for the db one b/c
899 there was a nasty circularity problem with the initialization
905 there was a nasty circularity problem with the initialization
900 order, which right now I don't have time to clean up.
906 order, which right now I don't have time to clean up.
901
907
902 * IPython/Shell.py (MTInteractiveShell.runcode): Fix, I think,
908 * IPython/Shell.py (MTInteractiveShell.runcode): Fix, I think,
903 another locking bug reported by Jorgen. I'm not 100% sure though,
909 another locking bug reported by Jorgen. I'm not 100% sure though,
904 so more testing is needed...
910 so more testing is needed...
905
911
906 2006-05-17 Fernando Perez <Fernando.Perez@colorado.edu>
912 2006-05-17 Fernando Perez <Fernando.Perez@colorado.edu>
907
913
908 * IPython/ipapi.py (IPApi.to_user_ns): New function to inject
914 * IPython/ipapi.py (IPApi.to_user_ns): New function to inject
909 local variables from any routine in user code (typically executed
915 local variables from any routine in user code (typically executed
910 with %run) directly into the interactive namespace. Very useful
916 with %run) directly into the interactive namespace. Very useful
911 when doing complex debugging.
917 when doing complex debugging.
912 (IPythonNotRunning): Changed the default None object to a dummy
918 (IPythonNotRunning): Changed the default None object to a dummy
913 whose attributes can be queried as well as called without
919 whose attributes can be queried as well as called without
914 exploding, to ease writing code which works transparently both in
920 exploding, to ease writing code which works transparently both in
915 and out of ipython and uses some of this API.
921 and out of ipython and uses some of this API.
916
922
917 2006-05-16 Fernando Perez <Fernando.Perez@colorado.edu>
923 2006-05-16 Fernando Perez <Fernando.Perez@colorado.edu>
918
924
919 * IPython/hooks.py (result_display): Fix the fact that our display
925 * IPython/hooks.py (result_display): Fix the fact that our display
920 hook was using str() instead of repr(), as the default python
926 hook was using str() instead of repr(), as the default python
921 console does. This had gone unnoticed b/c it only happened if
927 console does. This had gone unnoticed b/c it only happened if
922 %Pprint was off, but the inconsistency was there.
928 %Pprint was off, but the inconsistency was there.
923
929
924 2006-05-15 Ville Vainio <vivainio@gmail.com>
930 2006-05-15 Ville Vainio <vivainio@gmail.com>
925
931
926 * Oinspect.py: Only show docstring for nonexisting/binary files
932 * Oinspect.py: Only show docstring for nonexisting/binary files
927 when doing object??, closing ticket #62
933 when doing object??, closing ticket #62
928
934
929 2006-05-13 Fernando Perez <Fernando.Perez@colorado.edu>
935 2006-05-13 Fernando Perez <Fernando.Perez@colorado.edu>
930
936
931 * IPython/Shell.py (MTInteractiveShell.runsource): Fix threading
937 * IPython/Shell.py (MTInteractiveShell.runsource): Fix threading
932 bug, closes http://www.scipy.net/roundup/ipython/issue55. A lock
938 bug, closes http://www.scipy.net/roundup/ipython/issue55. A lock
933 was being released in a routine which hadn't checked if it had
939 was being released in a routine which hadn't checked if it had
934 been the one to acquire it.
940 been the one to acquire it.
935
941
936 2006-05-07 Fernando Perez <Fernando.Perez@colorado.edu>
942 2006-05-07 Fernando Perez <Fernando.Perez@colorado.edu>
937
943
938 * IPython/Release.py (version): put out 0.7.2.rc1 for testing.
944 * IPython/Release.py (version): put out 0.7.2.rc1 for testing.
939
945
940 2006-04-11 Ville Vainio <vivainio@gmail.com>
946 2006-04-11 Ville Vainio <vivainio@gmail.com>
941
947
942 * iplib.py, ipmaker.py: .ipy extension now means "ipython batch file"
948 * iplib.py, ipmaker.py: .ipy extension now means "ipython batch file"
943 in command line. E.g. "ipython test.ipy" runs test.ipy with ipython
949 in command line. E.g. "ipython test.ipy" runs test.ipy with ipython
944 prefilters, allowing stuff like magics and aliases in the file.
950 prefilters, allowing stuff like magics and aliases in the file.
945
951
946 * Prompts.py, Extensions/clearcmd.py, ipy_system_conf.py: %clear magic
952 * Prompts.py, Extensions/clearcmd.py, ipy_system_conf.py: %clear magic
947 added. Supported now are "%clear in" and "%clear out" (clear input and
953 added. Supported now are "%clear in" and "%clear out" (clear input and
948 output history, respectively). Also fixed CachedOutput.flush to
954 output history, respectively). Also fixed CachedOutput.flush to
949 properly flush the output cache.
955 properly flush the output cache.
950
956
951 * Extensions/pspersistence.py: Fix %store to avoid "%store obj.attr"
957 * Extensions/pspersistence.py: Fix %store to avoid "%store obj.attr"
952 half-success (and fail explicitly).
958 half-success (and fail explicitly).
953
959
954 2006-03-28 Ville Vainio <vivainio@gmail.com>
960 2006-03-28 Ville Vainio <vivainio@gmail.com>
955
961
956 * iplib.py: Fix quoting of aliases so that only argless ones
962 * iplib.py: Fix quoting of aliases so that only argless ones
957 are quoted
963 are quoted
958
964
959 2006-03-28 Ville Vainio <vivainio@gmail.com>
965 2006-03-28 Ville Vainio <vivainio@gmail.com>
960
966
961 * iplib.py: Quote aliases with spaces in the name.
967 * iplib.py: Quote aliases with spaces in the name.
962 "c:\program files\blah\bin" is now legal alias target.
968 "c:\program files\blah\bin" is now legal alias target.
963
969
964 * ext_rehashdir.py: Space no longer allowed as arg
970 * ext_rehashdir.py: Space no longer allowed as arg
965 separator, since space is legal in path names.
971 separator, since space is legal in path names.
966
972
967 2006-03-16 Ville Vainio <vivainio@gmail.com>
973 2006-03-16 Ville Vainio <vivainio@gmail.com>
968
974
969 * upgrade_dir.py: Take path.py from Extensions, correcting
975 * upgrade_dir.py: Take path.py from Extensions, correcting
970 %upgrade magic
976 %upgrade magic
971
977
972 * ipmaker.py: Suggest using %upgrade if ipy_user_conf.py isn't found.
978 * ipmaker.py: Suggest using %upgrade if ipy_user_conf.py isn't found.
973
979
974 * hooks.py: Only enclose editor binary in quotes if legal and
980 * hooks.py: Only enclose editor binary in quotes if legal and
975 necessary (space in the name, and is an existing file). Fixes a bug
981 necessary (space in the name, and is an existing file). Fixes a bug
976 reported by Zachary Pincus.
982 reported by Zachary Pincus.
977
983
978 2006-03-13 Fernando Perez <Fernando.Perez@colorado.edu>
984 2006-03-13 Fernando Perez <Fernando.Perez@colorado.edu>
979
985
980 * Manual: thanks to a tip on proper color handling for Emacs, by
986 * Manual: thanks to a tip on proper color handling for Emacs, by
981 Eric J Haywiser <ejh1-AT-MIT.EDU>.
987 Eric J Haywiser <ejh1-AT-MIT.EDU>.
982
988
983 * ipython.el: close http://www.scipy.net/roundup/ipython/issue57
989 * ipython.el: close http://www.scipy.net/roundup/ipython/issue57
984 by applying the provided patch. Thanks to Liu Jin
990 by applying the provided patch. Thanks to Liu Jin
985 <m.liu.jin-AT-gmail.com> for the contribution. No problems under
991 <m.liu.jin-AT-gmail.com> for the contribution. No problems under
986 XEmacs/Linux, I'm trusting the submitter that it actually helps
992 XEmacs/Linux, I'm trusting the submitter that it actually helps
987 under win32/GNU Emacs. Will revisit if any problems are reported.
993 under win32/GNU Emacs. Will revisit if any problems are reported.
988
994
989 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
995 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
990
996
991 * IPython/Gnuplot2.py (_FileClass): update for current Gnuplot.py
997 * IPython/Gnuplot2.py (_FileClass): update for current Gnuplot.py
992 from SVN, thanks to a patch by Ryan Woodard <rywo@bas.ac.uk>.
998 from SVN, thanks to a patch by Ryan Woodard <rywo@bas.ac.uk>.
993
999
994 2006-03-12 Ville Vainio <vivainio@gmail.com>
1000 2006-03-12 Ville Vainio <vivainio@gmail.com>
995
1001
996 * Magic.py (magic_timeit): Added %timeit magic, contributed by
1002 * Magic.py (magic_timeit): Added %timeit magic, contributed by
997 Torsten Marek.
1003 Torsten Marek.
998
1004
999 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
1005 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
1000
1006
1001 * IPython/Magic.py (magic_macro): fix so that the n1-n2 syntax for
1007 * IPython/Magic.py (magic_macro): fix so that the n1-n2 syntax for
1002 line ranges works again.
1008 line ranges works again.
1003
1009
1004 2006-03-11 Fernando Perez <Fernando.Perez@colorado.edu>
1010 2006-03-11 Fernando Perez <Fernando.Perez@colorado.edu>
1005
1011
1006 * IPython/iplib.py (showtraceback): add back sys.last_traceback
1012 * IPython/iplib.py (showtraceback): add back sys.last_traceback
1007 and friends, after a discussion with Zach Pincus on ipython-user.
1013 and friends, after a discussion with Zach Pincus on ipython-user.
1008 I'm not 100% sure, but after thinking about it quite a bit, it may
1014 I'm not 100% sure, but after thinking about it quite a bit, it may
1009 be OK. Testing with the multithreaded shells didn't reveal any
1015 be OK. Testing with the multithreaded shells didn't reveal any
1010 problems, but let's keep an eye out.
1016 problems, but let's keep an eye out.
1011
1017
1012 In the process, I fixed a few things which were calling
1018 In the process, I fixed a few things which were calling
1013 self.InteractiveTB() directly (like safe_execfile), which is a
1019 self.InteractiveTB() directly (like safe_execfile), which is a
1014 mistake: ALL exception reporting should be done by calling
1020 mistake: ALL exception reporting should be done by calling
1015 self.showtraceback(), which handles state and tab-completion and
1021 self.showtraceback(), which handles state and tab-completion and
1016 more.
1022 more.
1017
1023
1018 2006-03-01 Ville Vainio <vivainio@gmail.com>
1024 2006-03-01 Ville Vainio <vivainio@gmail.com>
1019
1025
1020 * Extensions/ipipe.py: Added Walter Doerwald's "ipipe" module.
1026 * Extensions/ipipe.py: Added Walter Doerwald's "ipipe" module.
1021 To use, do "from ipipe import *".
1027 To use, do "from ipipe import *".
1022
1028
1023 2006-02-24 Ville Vainio <vivainio@gmail.com>
1029 2006-02-24 Ville Vainio <vivainio@gmail.com>
1024
1030
1025 * Magic.py, upgrade_dir.py: %upgrade magic added. Does things more
1031 * Magic.py, upgrade_dir.py: %upgrade magic added. Does things more
1026 "cleanly" and safely than the older upgrade mechanism.
1032 "cleanly" and safely than the older upgrade mechanism.
1027
1033
1028 2006-02-21 Ville Vainio <vivainio@gmail.com>
1034 2006-02-21 Ville Vainio <vivainio@gmail.com>
1029
1035
1030 * Magic.py: %save works again.
1036 * Magic.py: %save works again.
1031
1037
1032 2006-02-15 Ville Vainio <vivainio@gmail.com>
1038 2006-02-15 Ville Vainio <vivainio@gmail.com>
1033
1039
1034 * Magic.py: %Pprint works again
1040 * Magic.py: %Pprint works again
1035
1041
1036 * Extensions/ipy_sane_defaults.py: Provide everything provided
1042 * Extensions/ipy_sane_defaults.py: Provide everything provided
1037 in default ipythonrc, to make it possible to have a completely empty
1043 in default ipythonrc, to make it possible to have a completely empty
1038 ipythonrc (and thus completely rc-file free configuration)
1044 ipythonrc (and thus completely rc-file free configuration)
1039
1045
1040 2006-02-11 Fernando Perez <Fernando.Perez@colorado.edu>
1046 2006-02-11 Fernando Perez <Fernando.Perez@colorado.edu>
1041
1047
1042 * IPython/hooks.py (editor): quote the call to the editor command,
1048 * IPython/hooks.py (editor): quote the call to the editor command,
1043 to allow commands with spaces in them. Problem noted by watching
1049 to allow commands with spaces in them. Problem noted by watching
1044 Ian Oswald's video about textpad under win32 at
1050 Ian Oswald's video about textpad under win32 at
1045 http://showmedo.com/videoListPage?listKey=PythonIPythonSeries
1051 http://showmedo.com/videoListPage?listKey=PythonIPythonSeries
1046
1052
1047 * IPython/UserConfig/ipythonrc: Replace @ signs with % when
1053 * IPython/UserConfig/ipythonrc: Replace @ signs with % when
1048 describing magics (we haven't used @ for a loong time).
1054 describing magics (we haven't used @ for a loong time).
1049
1055
1050 * IPython/ultraTB.py (VerboseTB.text.text_repr): Added patch
1056 * IPython/ultraTB.py (VerboseTB.text.text_repr): Added patch
1051 contributed by marienz to close
1057 contributed by marienz to close
1052 http://www.scipy.net/roundup/ipython/issue53.
1058 http://www.scipy.net/roundup/ipython/issue53.
1053
1059
1054 2006-02-10 Ville Vainio <vivainio@gmail.com>
1060 2006-02-10 Ville Vainio <vivainio@gmail.com>
1055
1061
1056 * genutils.py: getoutput now works in win32 too
1062 * genutils.py: getoutput now works in win32 too
1057
1063
1058 * completer.py: alias and magic completion only invoked
1064 * completer.py: alias and magic completion only invoked
1059 at the first "item" in the line, to avoid "cd %store"
1065 at the first "item" in the line, to avoid "cd %store"
1060 nonsense.
1066 nonsense.
1061
1067
1062 2006-02-09 Ville Vainio <vivainio@gmail.com>
1068 2006-02-09 Ville Vainio <vivainio@gmail.com>
1063
1069
1064 * test/*: Added a unit testing framework (finally).
1070 * test/*: Added a unit testing framework (finally).
1065 '%run runtests.py' to run test_*.
1071 '%run runtests.py' to run test_*.
1066
1072
1067 * ipapi.py: Exposed runlines and set_custom_exc
1073 * ipapi.py: Exposed runlines and set_custom_exc
1068
1074
1069 2006-02-07 Ville Vainio <vivainio@gmail.com>
1075 2006-02-07 Ville Vainio <vivainio@gmail.com>
1070
1076
1071 * iplib.py: don't split "f 1 2" to "f(1,2)" in autocall,
1077 * iplib.py: don't split "f 1 2" to "f(1,2)" in autocall,
1072 instead use "f(1 2)" as before.
1078 instead use "f(1 2)" as before.
1073
1079
1074 2006-02-05 Fernando Perez <Fernando.Perez@colorado.edu>
1080 2006-02-05 Fernando Perez <Fernando.Perez@colorado.edu>
1075
1081
1076 * IPython/demo.py (IPythonDemo): Add new classes to the demo
1082 * IPython/demo.py (IPythonDemo): Add new classes to the demo
1077 facilities, for demos processed by the IPython input filter
1083 facilities, for demos processed by the IPython input filter
1078 (IPythonDemo), and for running a script one-line-at-a-time as a
1084 (IPythonDemo), and for running a script one-line-at-a-time as a
1079 demo, both for pure Python (LineDemo) and for IPython-processed
1085 demo, both for pure Python (LineDemo) and for IPython-processed
1080 input (IPythonLineDemo). After a request by Dave Kohel, from the
1086 input (IPythonLineDemo). After a request by Dave Kohel, from the
1081 SAGE team.
1087 SAGE team.
1082 (Demo.edit): added an edit() method to the demo objects, to edit
1088 (Demo.edit): added an edit() method to the demo objects, to edit
1083 the in-memory copy of the last executed block.
1089 the in-memory copy of the last executed block.
1084
1090
1085 * IPython/Magic.py (magic_edit): add '-r' option for 'raw'
1091 * IPython/Magic.py (magic_edit): add '-r' option for 'raw'
1086 processing to %edit, %macro and %save. These commands can now be
1092 processing to %edit, %macro and %save. These commands can now be
1087 invoked on the unprocessed input as it was typed by the user
1093 invoked on the unprocessed input as it was typed by the user
1088 (without any prefilters applied). After requests by the SAGE team
1094 (without any prefilters applied). After requests by the SAGE team
1089 at SAGE days 2006: http://modular.ucsd.edu/sage/days1/schedule.html.
1095 at SAGE days 2006: http://modular.ucsd.edu/sage/days1/schedule.html.
1090
1096
1091 2006-02-01 Ville Vainio <vivainio@gmail.com>
1097 2006-02-01 Ville Vainio <vivainio@gmail.com>
1092
1098
1093 * setup.py, eggsetup.py: easy_install ipython==dev works
1099 * setup.py, eggsetup.py: easy_install ipython==dev works
1094 correctly now (on Linux)
1100 correctly now (on Linux)
1095
1101
1096 * ipy_user_conf,ipmaker: user config changes, removed spurious
1102 * ipy_user_conf,ipmaker: user config changes, removed spurious
1097 warnings
1103 warnings
1098
1104
1099 * iplib: if rc.banner is string, use it as is.
1105 * iplib: if rc.banner is string, use it as is.
1100
1106
1101 * Magic: %pycat accepts a string argument and pages it's contents.
1107 * Magic: %pycat accepts a string argument and pages it's contents.
1102
1108
1103
1109
1104 2006-01-30 Ville Vainio <vivainio@gmail.com>
1110 2006-01-30 Ville Vainio <vivainio@gmail.com>
1105
1111
1106 * pickleshare,pspersistence,ipapi,Magic: persistence overhaul.
1112 * pickleshare,pspersistence,ipapi,Magic: persistence overhaul.
1107 Now %store and bookmarks work through PickleShare, meaning that
1113 Now %store and bookmarks work through PickleShare, meaning that
1108 concurrent access is possible and all ipython sessions see the
1114 concurrent access is possible and all ipython sessions see the
1109 same database situation all the time, instead of snapshot of
1115 same database situation all the time, instead of snapshot of
1110 the situation when the session was started. Hence, %bookmark
1116 the situation when the session was started. Hence, %bookmark
1111 results are immediately accessible from othes sessions. The database
1117 results are immediately accessible from othes sessions. The database
1112 is also available for use by user extensions. See:
1118 is also available for use by user extensions. See:
1113 http://www.python.org/pypi/pickleshare
1119 http://www.python.org/pypi/pickleshare
1114
1120
1115 * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'.
1121 * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'.
1116
1122
1117 * aliases can now be %store'd
1123 * aliases can now be %store'd
1118
1124
1119 * path.py moved to Extensions so that pickleshare does not need
1125 * path.py moved to Extensions so that pickleshare does not need
1120 IPython-specific import. Extensions added to pythonpath right
1126 IPython-specific import. Extensions added to pythonpath right
1121 at __init__.
1127 at __init__.
1122
1128
1123 * iplib.py: ipalias deprecated/redundant; aliases are converted and
1129 * iplib.py: ipalias deprecated/redundant; aliases are converted and
1124 called with _ip.system and the pre-transformed command string.
1130 called with _ip.system and the pre-transformed command string.
1125
1131
1126 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu>
1132 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu>
1127
1133
1128 * IPython/iplib.py (interact): Fix that we were not catching
1134 * IPython/iplib.py (interact): Fix that we were not catching
1129 KeyboardInterrupt exceptions properly. I'm not quite sure why the
1135 KeyboardInterrupt exceptions properly. I'm not quite sure why the
1130 logic here had to change, but it's fixed now.
1136 logic here had to change, but it's fixed now.
1131
1137
1132 2006-01-29 Ville Vainio <vivainio@gmail.com>
1138 2006-01-29 Ville Vainio <vivainio@gmail.com>
1133
1139
1134 * iplib.py: Try to import pyreadline on Windows.
1140 * iplib.py: Try to import pyreadline on Windows.
1135
1141
1136 2006-01-27 Ville Vainio <vivainio@gmail.com>
1142 2006-01-27 Ville Vainio <vivainio@gmail.com>
1137
1143
1138 * iplib.py: Expose ipapi as _ip in builtin namespace.
1144 * iplib.py: Expose ipapi as _ip in builtin namespace.
1139 Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system)
1145 Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system)
1140 and ip_set_hook (-> _ip.set_hook) redundant. % and !
1146 and ip_set_hook (-> _ip.set_hook) redundant. % and !
1141 syntax now produce _ip.* variant of the commands.
1147 syntax now produce _ip.* variant of the commands.
1142
1148
1143 * "_ip.options().autoedit_syntax = 2" automatically throws
1149 * "_ip.options().autoedit_syntax = 2" automatically throws
1144 user to editor for syntax error correction without prompting.
1150 user to editor for syntax error correction without prompting.
1145
1151
1146 2006-01-27 Ville Vainio <vivainio@gmail.com>
1152 2006-01-27 Ville Vainio <vivainio@gmail.com>
1147
1153
1148 * ipmaker.py: Give "realistic" sys.argv for scripts (without
1154 * ipmaker.py: Give "realistic" sys.argv for scripts (without
1149 'ipython' at argv[0]) executed through command line.
1155 'ipython' at argv[0]) executed through command line.
1150 NOTE: this DEPRECATES calling ipython with multiple scripts
1156 NOTE: this DEPRECATES calling ipython with multiple scripts
1151 ("ipython a.py b.py c.py")
1157 ("ipython a.py b.py c.py")
1152
1158
1153 * iplib.py, hooks.py: Added configurable input prefilter,
1159 * iplib.py, hooks.py: Added configurable input prefilter,
1154 named 'input_prefilter'. See ext_rescapture.py for example
1160 named 'input_prefilter'. See ext_rescapture.py for example
1155 usage.
1161 usage.
1156
1162
1157 * ext_rescapture.py, Magic.py: Better system command output capture
1163 * ext_rescapture.py, Magic.py: Better system command output capture
1158 through 'var = !ls' (deprecates user-visible %sc). Same notation
1164 through 'var = !ls' (deprecates user-visible %sc). Same notation
1159 applies for magics, 'var = %alias' assigns alias list to var.
1165 applies for magics, 'var = %alias' assigns alias list to var.
1160
1166
1161 * ipapi.py: added meta() for accessing extension-usable data store.
1167 * ipapi.py: added meta() for accessing extension-usable data store.
1162
1168
1163 * iplib.py: added InteractiveShell.getapi(). New magics should be
1169 * iplib.py: added InteractiveShell.getapi(). New magics should be
1164 written doing self.getapi() instead of using the shell directly.
1170 written doing self.getapi() instead of using the shell directly.
1165
1171
1166 * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and
1172 * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and
1167 %store foo >> ~/myfoo.txt to store variables to files (in clean
1173 %store foo >> ~/myfoo.txt to store variables to files (in clean
1168 textual form, not a restorable pickle).
1174 textual form, not a restorable pickle).
1169
1175
1170 * ipmaker.py: now import ipy_profile_PROFILENAME automatically
1176 * ipmaker.py: now import ipy_profile_PROFILENAME automatically
1171
1177
1172 * usage.py, Magic.py: added %quickref
1178 * usage.py, Magic.py: added %quickref
1173
1179
1174 * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2).
1180 * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2).
1175
1181
1176 * GetoptErrors when invoking magics etc. with wrong args
1182 * GetoptErrors when invoking magics etc. with wrong args
1177 are now more helpful:
1183 are now more helpful:
1178 GetoptError: option -l not recognized (allowed: "qb" )
1184 GetoptError: option -l not recognized (allowed: "qb" )
1179
1185
1180 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu>
1186 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu>
1181
1187
1182 * IPython/demo.py (Demo.show): Flush stdout after each block, so
1188 * IPython/demo.py (Demo.show): Flush stdout after each block, so
1183 computationally intensive blocks don't appear to stall the demo.
1189 computationally intensive blocks don't appear to stall the demo.
1184
1190
1185 2006-01-24 Ville Vainio <vivainio@gmail.com>
1191 2006-01-24 Ville Vainio <vivainio@gmail.com>
1186
1192
1187 * iplib.py, hooks.py: 'result_display' hook can return a non-None
1193 * iplib.py, hooks.py: 'result_display' hook can return a non-None
1188 value to manipulate resulting history entry.
1194 value to manipulate resulting history entry.
1189
1195
1190 * ipapi.py: Moved TryNext here from hooks.py. Moved functions
1196 * ipapi.py: Moved TryNext here from hooks.py. Moved functions
1191 to instance methods of IPApi class, to make extending an embedded
1197 to instance methods of IPApi class, to make extending an embedded
1192 IPython feasible. See ext_rehashdir.py for example usage.
1198 IPython feasible. See ext_rehashdir.py for example usage.
1193
1199
1194 * Merged 1071-1076 from branches/0.7.1
1200 * Merged 1071-1076 from branches/0.7.1
1195
1201
1196
1202
1197 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu>
1203 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu>
1198
1204
1199 * tools/release (daystamp): Fix build tools to use the new
1205 * tools/release (daystamp): Fix build tools to use the new
1200 eggsetup.py script to build lightweight eggs.
1206 eggsetup.py script to build lightweight eggs.
1201
1207
1202 * Applied changesets 1062 and 1064 before 0.7.1 release.
1208 * Applied changesets 1062 and 1064 before 0.7.1 release.
1203
1209
1204 * IPython/Magic.py (magic_history): Add '-r' option to %hist, to
1210 * IPython/Magic.py (magic_history): Add '-r' option to %hist, to
1205 see the raw input history (without conversions like %ls ->
1211 see the raw input history (without conversions like %ls ->
1206 ipmagic("ls")). After a request from W. Stein, SAGE
1212 ipmagic("ls")). After a request from W. Stein, SAGE
1207 (http://modular.ucsd.edu/sage) developer. This information is
1213 (http://modular.ucsd.edu/sage) developer. This information is
1208 stored in the input_hist_raw attribute of the IPython instance, so
1214 stored in the input_hist_raw attribute of the IPython instance, so
1209 developers can access it if needed (it's an InputList instance).
1215 developers can access it if needed (it's an InputList instance).
1210
1216
1211 * Versionstring = 0.7.2.svn
1217 * Versionstring = 0.7.2.svn
1212
1218
1213 * eggsetup.py: A separate script for constructing eggs, creates
1219 * eggsetup.py: A separate script for constructing eggs, creates
1214 proper launch scripts even on Windows (an .exe file in
1220 proper launch scripts even on Windows (an .exe file in
1215 \python24\scripts).
1221 \python24\scripts).
1216
1222
1217 * ipapi.py: launch_new_instance, launch entry point needed for the
1223 * ipapi.py: launch_new_instance, launch entry point needed for the
1218 egg.
1224 egg.
1219
1225
1220 2006-01-23 Ville Vainio <vivainio@gmail.com>
1226 2006-01-23 Ville Vainio <vivainio@gmail.com>
1221
1227
1222 * Added %cpaste magic for pasting python code
1228 * Added %cpaste magic for pasting python code
1223
1229
1224 2006-01-22 Ville Vainio <vivainio@gmail.com>
1230 2006-01-22 Ville Vainio <vivainio@gmail.com>
1225
1231
1226 * Merge from branches/0.7.1 into trunk, revs 1052-1057
1232 * Merge from branches/0.7.1 into trunk, revs 1052-1057
1227
1233
1228 * Versionstring = 0.7.2.svn
1234 * Versionstring = 0.7.2.svn
1229
1235
1230 * eggsetup.py: A separate script for constructing eggs, creates
1236 * eggsetup.py: A separate script for constructing eggs, creates
1231 proper launch scripts even on Windows (an .exe file in
1237 proper launch scripts even on Windows (an .exe file in
1232 \python24\scripts).
1238 \python24\scripts).
1233
1239
1234 * ipapi.py: launch_new_instance, launch entry point needed for the
1240 * ipapi.py: launch_new_instance, launch entry point needed for the
1235 egg.
1241 egg.
1236
1242
1237 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
1243 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
1238
1244
1239 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
1245 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
1240 %pfile foo would print the file for foo even if it was a binary.
1246 %pfile foo would print the file for foo even if it was a binary.
1241 Now, extensions '.so' and '.dll' are skipped.
1247 Now, extensions '.so' and '.dll' are skipped.
1242
1248
1243 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
1249 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
1244 bug, where macros would fail in all threaded modes. I'm not 100%
1250 bug, where macros would fail in all threaded modes. I'm not 100%
1245 sure, so I'm going to put out an rc instead of making a release
1251 sure, so I'm going to put out an rc instead of making a release
1246 today, and wait for feedback for at least a few days.
1252 today, and wait for feedback for at least a few days.
1247
1253
1248 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
1254 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
1249 it...) the handling of pasting external code with autoindent on.
1255 it...) the handling of pasting external code with autoindent on.
1250 To get out of a multiline input, the rule will appear for most
1256 To get out of a multiline input, the rule will appear for most
1251 users unchanged: two blank lines or change the indent level
1257 users unchanged: two blank lines or change the indent level
1252 proposed by IPython. But there is a twist now: you can
1258 proposed by IPython. But there is a twist now: you can
1253 add/subtract only *one or two spaces*. If you add/subtract three
1259 add/subtract only *one or two spaces*. If you add/subtract three
1254 or more (unless you completely delete the line), IPython will
1260 or more (unless you completely delete the line), IPython will
1255 accept that line, and you'll need to enter a second one of pure
1261 accept that line, and you'll need to enter a second one of pure
1256 whitespace. I know it sounds complicated, but I can't find a
1262 whitespace. I know it sounds complicated, but I can't find a
1257 different solution that covers all the cases, with the right
1263 different solution that covers all the cases, with the right
1258 heuristics. Hopefully in actual use, nobody will really notice
1264 heuristics. Hopefully in actual use, nobody will really notice
1259 all these strange rules and things will 'just work'.
1265 all these strange rules and things will 'just work'.
1260
1266
1261 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
1267 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
1262
1268
1263 * IPython/iplib.py (interact): catch exceptions which can be
1269 * IPython/iplib.py (interact): catch exceptions which can be
1264 triggered asynchronously by signal handlers. Thanks to an
1270 triggered asynchronously by signal handlers. Thanks to an
1265 automatic crash report, submitted by Colin Kingsley
1271 automatic crash report, submitted by Colin Kingsley
1266 <tercel-AT-gentoo.org>.
1272 <tercel-AT-gentoo.org>.
1267
1273
1268 2006-01-20 Ville Vainio <vivainio@gmail.com>
1274 2006-01-20 Ville Vainio <vivainio@gmail.com>
1269
1275
1270 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
1276 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
1271 (%rehashdir, very useful, try it out) of how to extend ipython
1277 (%rehashdir, very useful, try it out) of how to extend ipython
1272 with new magics. Also added Extensions dir to pythonpath to make
1278 with new magics. Also added Extensions dir to pythonpath to make
1273 importing extensions easy.
1279 importing extensions easy.
1274
1280
1275 * %store now complains when trying to store interactively declared
1281 * %store now complains when trying to store interactively declared
1276 classes / instances of those classes.
1282 classes / instances of those classes.
1277
1283
1278 * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py,
1284 * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py,
1279 ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported
1285 ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported
1280 if they exist, and ipy_user_conf.py with some defaults is created for
1286 if they exist, and ipy_user_conf.py with some defaults is created for
1281 the user.
1287 the user.
1282
1288
1283 * Startup rehashing done by the config file, not InterpreterExec.
1289 * Startup rehashing done by the config file, not InterpreterExec.
1284 This means system commands are available even without selecting the
1290 This means system commands are available even without selecting the
1285 pysh profile. It's the sensible default after all.
1291 pysh profile. It's the sensible default after all.
1286
1292
1287 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
1293 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
1288
1294
1289 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
1295 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
1290 multiline code with autoindent on working. But I am really not
1296 multiline code with autoindent on working. But I am really not
1291 sure, so this needs more testing. Will commit a debug-enabled
1297 sure, so this needs more testing. Will commit a debug-enabled
1292 version for now, while I test it some more, so that Ville and
1298 version for now, while I test it some more, so that Ville and
1293 others may also catch any problems. Also made
1299 others may also catch any problems. Also made
1294 self.indent_current_str() a method, to ensure that there's no
1300 self.indent_current_str() a method, to ensure that there's no
1295 chance of the indent space count and the corresponding string
1301 chance of the indent space count and the corresponding string
1296 falling out of sync. All code needing the string should just call
1302 falling out of sync. All code needing the string should just call
1297 the method.
1303 the method.
1298
1304
1299 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
1305 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
1300
1306
1301 * IPython/Magic.py (magic_edit): fix check for when users don't
1307 * IPython/Magic.py (magic_edit): fix check for when users don't
1302 save their output files, the try/except was in the wrong section.
1308 save their output files, the try/except was in the wrong section.
1303
1309
1304 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
1310 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
1305
1311
1306 * IPython/Magic.py (magic_run): fix __file__ global missing from
1312 * IPython/Magic.py (magic_run): fix __file__ global missing from
1307 script's namespace when executed via %run. After a report by
1313 script's namespace when executed via %run. After a report by
1308 Vivian.
1314 Vivian.
1309
1315
1310 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
1316 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
1311 when using python 2.4. The parent constructor changed in 2.4, and
1317 when using python 2.4. The parent constructor changed in 2.4, and
1312 we need to track it directly (we can't call it, as it messes up
1318 we need to track it directly (we can't call it, as it messes up
1313 readline and tab-completion inside our pdb would stop working).
1319 readline and tab-completion inside our pdb would stop working).
1314 After a bug report by R. Bernstein <rocky-AT-panix.com>.
1320 After a bug report by R. Bernstein <rocky-AT-panix.com>.
1315
1321
1316 2006-01-16 Ville Vainio <vivainio@gmail.com>
1322 2006-01-16 Ville Vainio <vivainio@gmail.com>
1317
1323
1318 * Ipython/magic.py: Reverted back to old %edit functionality
1324 * Ipython/magic.py: Reverted back to old %edit functionality
1319 that returns file contents on exit.
1325 that returns file contents on exit.
1320
1326
1321 * IPython/path.py: Added Jason Orendorff's "path" module to
1327 * IPython/path.py: Added Jason Orendorff's "path" module to
1322 IPython tree, http://www.jorendorff.com/articles/python/path/.
1328 IPython tree, http://www.jorendorff.com/articles/python/path/.
1323 You can get path objects conveniently through %sc, and !!, e.g.:
1329 You can get path objects conveniently through %sc, and !!, e.g.:
1324 sc files=ls
1330 sc files=ls
1325 for p in files.paths: # or files.p
1331 for p in files.paths: # or files.p
1326 print p,p.mtime
1332 print p,p.mtime
1327
1333
1328 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
1334 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
1329 now work again without considering the exclusion regexp -
1335 now work again without considering the exclusion regexp -
1330 hence, things like ',foo my/path' turn to 'foo("my/path")'
1336 hence, things like ',foo my/path' turn to 'foo("my/path")'
1331 instead of syntax error.
1337 instead of syntax error.
1332
1338
1333
1339
1334 2006-01-14 Ville Vainio <vivainio@gmail.com>
1340 2006-01-14 Ville Vainio <vivainio@gmail.com>
1335
1341
1336 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
1342 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
1337 ipapi decorators for python 2.4 users, options() provides access to rc
1343 ipapi decorators for python 2.4 users, options() provides access to rc
1338 data.
1344 data.
1339
1345
1340 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
1346 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
1341 as path separators (even on Linux ;-). Space character after
1347 as path separators (even on Linux ;-). Space character after
1342 backslash (as yielded by tab completer) is still space;
1348 backslash (as yielded by tab completer) is still space;
1343 "%cd long\ name" works as expected.
1349 "%cd long\ name" works as expected.
1344
1350
1345 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
1351 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
1346 as "chain of command", with priority. API stays the same,
1352 as "chain of command", with priority. API stays the same,
1347 TryNext exception raised by a hook function signals that
1353 TryNext exception raised by a hook function signals that
1348 current hook failed and next hook should try handling it, as
1354 current hook failed and next hook should try handling it, as
1349 suggested by Walter DΓΆrwald <walter@livinglogic.de>. Walter also
1355 suggested by Walter DΓΆrwald <walter@livinglogic.de>. Walter also
1350 requested configurable display hook, which is now implemented.
1356 requested configurable display hook, which is now implemented.
1351
1357
1352 2006-01-13 Ville Vainio <vivainio@gmail.com>
1358 2006-01-13 Ville Vainio <vivainio@gmail.com>
1353
1359
1354 * IPython/platutils*.py: platform specific utility functions,
1360 * IPython/platutils*.py: platform specific utility functions,
1355 so far only set_term_title is implemented (change terminal
1361 so far only set_term_title is implemented (change terminal
1356 label in windowing systems). %cd now changes the title to
1362 label in windowing systems). %cd now changes the title to
1357 current dir.
1363 current dir.
1358
1364
1359 * IPython/Release.py: Added myself to "authors" list,
1365 * IPython/Release.py: Added myself to "authors" list,
1360 had to create new files.
1366 had to create new files.
1361
1367
1362 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
1368 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
1363 shell escape; not a known bug but had potential to be one in the
1369 shell escape; not a known bug but had potential to be one in the
1364 future.
1370 future.
1365
1371
1366 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
1372 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
1367 extension API for IPython! See the module for usage example. Fix
1373 extension API for IPython! See the module for usage example. Fix
1368 OInspect for docstring-less magic functions.
1374 OInspect for docstring-less magic functions.
1369
1375
1370
1376
1371 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
1377 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
1372
1378
1373 * IPython/iplib.py (raw_input): temporarily deactivate all
1379 * IPython/iplib.py (raw_input): temporarily deactivate all
1374 attempts at allowing pasting of code with autoindent on. It
1380 attempts at allowing pasting of code with autoindent on. It
1375 introduced bugs (reported by Prabhu) and I can't seem to find a
1381 introduced bugs (reported by Prabhu) and I can't seem to find a
1376 robust combination which works in all cases. Will have to revisit
1382 robust combination which works in all cases. Will have to revisit
1377 later.
1383 later.
1378
1384
1379 * IPython/genutils.py: remove isspace() function. We've dropped
1385 * IPython/genutils.py: remove isspace() function. We've dropped
1380 2.2 compatibility, so it's OK to use the string method.
1386 2.2 compatibility, so it's OK to use the string method.
1381
1387
1382 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
1388 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
1383
1389
1384 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
1390 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
1385 matching what NOT to autocall on, to include all python binary
1391 matching what NOT to autocall on, to include all python binary
1386 operators (including things like 'and', 'or', 'is' and 'in').
1392 operators (including things like 'and', 'or', 'is' and 'in').
1387 Prompted by a bug report on 'foo & bar', but I realized we had
1393 Prompted by a bug report on 'foo & bar', but I realized we had
1388 many more potential bug cases with other operators. The regexp is
1394 many more potential bug cases with other operators. The regexp is
1389 self.re_exclude_auto, it's fairly commented.
1395 self.re_exclude_auto, it's fairly commented.
1390
1396
1391 2006-01-12 Ville Vainio <vivainio@gmail.com>
1397 2006-01-12 Ville Vainio <vivainio@gmail.com>
1392
1398
1393 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
1399 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
1394 Prettified and hardened string/backslash quoting with ipsystem(),
1400 Prettified and hardened string/backslash quoting with ipsystem(),
1395 ipalias() and ipmagic(). Now even \ characters are passed to
1401 ipalias() and ipmagic(). Now even \ characters are passed to
1396 %magics, !shell escapes and aliases exactly as they are in the
1402 %magics, !shell escapes and aliases exactly as they are in the
1397 ipython command line. Should improve backslash experience,
1403 ipython command line. Should improve backslash experience,
1398 particularly in Windows (path delimiter for some commands that
1404 particularly in Windows (path delimiter for some commands that
1399 won't understand '/'), but Unix benefits as well (regexps). %cd
1405 won't understand '/'), but Unix benefits as well (regexps). %cd
1400 magic still doesn't support backslash path delimiters, though. Also
1406 magic still doesn't support backslash path delimiters, though. Also
1401 deleted all pretense of supporting multiline command strings in
1407 deleted all pretense of supporting multiline command strings in
1402 !system or %magic commands. Thanks to Jerry McRae for suggestions.
1408 !system or %magic commands. Thanks to Jerry McRae for suggestions.
1403
1409
1404 * doc/build_doc_instructions.txt added. Documentation on how to
1410 * doc/build_doc_instructions.txt added. Documentation on how to
1405 use doc/update_manual.py, added yesterday. Both files contributed
1411 use doc/update_manual.py, added yesterday. Both files contributed
1406 by JΓΆrgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
1412 by JΓΆrgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
1407 doc/*.sh for deprecation at a later date.
1413 doc/*.sh for deprecation at a later date.
1408
1414
1409 * /ipython.py Added ipython.py to root directory for
1415 * /ipython.py Added ipython.py to root directory for
1410 zero-installation (tar xzvf ipython.tgz; cd ipython; python
1416 zero-installation (tar xzvf ipython.tgz; cd ipython; python
1411 ipython.py) and development convenience (no need to keep doing
1417 ipython.py) and development convenience (no need to keep doing
1412 "setup.py install" between changes).
1418 "setup.py install" between changes).
1413
1419
1414 * Made ! and !! shell escapes work (again) in multiline expressions:
1420 * Made ! and !! shell escapes work (again) in multiline expressions:
1415 if 1:
1421 if 1:
1416 !ls
1422 !ls
1417 !!ls
1423 !!ls
1418
1424
1419 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
1425 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
1420
1426
1421 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
1427 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
1422 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
1428 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
1423 module in case-insensitive installation. Was causing crashes
1429 module in case-insensitive installation. Was causing crashes
1424 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
1430 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
1425
1431
1426 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
1432 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
1427 <marienz-AT-gentoo.org>, closes
1433 <marienz-AT-gentoo.org>, closes
1428 http://www.scipy.net/roundup/ipython/issue51.
1434 http://www.scipy.net/roundup/ipython/issue51.
1429
1435
1430 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
1436 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
1431
1437
1432 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the
1438 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the
1433 problem of excessive CPU usage under *nix and keyboard lag under
1439 problem of excessive CPU usage under *nix and keyboard lag under
1434 win32.
1440 win32.
1435
1441
1436 2006-01-10 *** Released version 0.7.0
1442 2006-01-10 *** Released version 0.7.0
1437
1443
1438 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
1444 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
1439
1445
1440 * IPython/Release.py (revision): tag version number to 0.7.0,
1446 * IPython/Release.py (revision): tag version number to 0.7.0,
1441 ready for release.
1447 ready for release.
1442
1448
1443 * IPython/Magic.py (magic_edit): Add print statement to %edit so
1449 * IPython/Magic.py (magic_edit): Add print statement to %edit so
1444 it informs the user of the name of the temp. file used. This can
1450 it informs the user of the name of the temp. file used. This can
1445 help if you decide later to reuse that same file, so you know
1451 help if you decide later to reuse that same file, so you know
1446 where to copy the info from.
1452 where to copy the info from.
1447
1453
1448 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
1454 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
1449
1455
1450 * setup_bdist_egg.py: little script to build an egg. Added
1456 * setup_bdist_egg.py: little script to build an egg. Added
1451 support in the release tools as well.
1457 support in the release tools as well.
1452
1458
1453 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
1459 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
1454
1460
1455 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
1461 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
1456 version selection (new -wxversion command line and ipythonrc
1462 version selection (new -wxversion command line and ipythonrc
1457 parameter). Patch contributed by Arnd Baecker
1463 parameter). Patch contributed by Arnd Baecker
1458 <arnd.baecker-AT-web.de>.
1464 <arnd.baecker-AT-web.de>.
1459
1465
1460 * IPython/iplib.py (embed_mainloop): fix tab-completion in
1466 * IPython/iplib.py (embed_mainloop): fix tab-completion in
1461 embedded instances, for variables defined at the interactive
1467 embedded instances, for variables defined at the interactive
1462 prompt of the embedded ipython. Reported by Arnd.
1468 prompt of the embedded ipython. Reported by Arnd.
1463
1469
1464 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
1470 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
1465 it can be used as a (stateful) toggle, or with a direct parameter.
1471 it can be used as a (stateful) toggle, or with a direct parameter.
1466
1472
1467 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
1473 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
1468 could be triggered in certain cases and cause the traceback
1474 could be triggered in certain cases and cause the traceback
1469 printer not to work.
1475 printer not to work.
1470
1476
1471 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
1477 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
1472
1478
1473 * IPython/iplib.py (_should_recompile): Small fix, closes
1479 * IPython/iplib.py (_should_recompile): Small fix, closes
1474 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
1480 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
1475
1481
1476 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
1482 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
1477
1483
1478 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
1484 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
1479 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
1485 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
1480 Moad for help with tracking it down.
1486 Moad for help with tracking it down.
1481
1487
1482 * IPython/iplib.py (handle_auto): fix autocall handling for
1488 * IPython/iplib.py (handle_auto): fix autocall handling for
1483 objects which support BOTH __getitem__ and __call__ (so that f [x]
1489 objects which support BOTH __getitem__ and __call__ (so that f [x]
1484 is left alone, instead of becoming f([x]) automatically).
1490 is left alone, instead of becoming f([x]) automatically).
1485
1491
1486 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
1492 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
1487 Ville's patch.
1493 Ville's patch.
1488
1494
1489 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
1495 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
1490
1496
1491 * IPython/iplib.py (handle_auto): changed autocall semantics to
1497 * IPython/iplib.py (handle_auto): changed autocall semantics to
1492 include 'smart' mode, where the autocall transformation is NOT
1498 include 'smart' mode, where the autocall transformation is NOT
1493 applied if there are no arguments on the line. This allows you to
1499 applied if there are no arguments on the line. This allows you to
1494 just type 'foo' if foo is a callable to see its internal form,
1500 just type 'foo' if foo is a callable to see its internal form,
1495 instead of having it called with no arguments (typically a
1501 instead of having it called with no arguments (typically a
1496 mistake). The old 'full' autocall still exists: for that, you
1502 mistake). The old 'full' autocall still exists: for that, you
1497 need to set the 'autocall' parameter to 2 in your ipythonrc file.
1503 need to set the 'autocall' parameter to 2 in your ipythonrc file.
1498
1504
1499 * IPython/completer.py (Completer.attr_matches): add
1505 * IPython/completer.py (Completer.attr_matches): add
1500 tab-completion support for Enthoughts' traits. After a report by
1506 tab-completion support for Enthoughts' traits. After a report by
1501 Arnd and a patch by Prabhu.
1507 Arnd and a patch by Prabhu.
1502
1508
1503 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
1509 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
1504
1510
1505 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
1511 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
1506 Schmolck's patch to fix inspect.getinnerframes().
1512 Schmolck's patch to fix inspect.getinnerframes().
1507
1513
1508 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
1514 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
1509 for embedded instances, regarding handling of namespaces and items
1515 for embedded instances, regarding handling of namespaces and items
1510 added to the __builtin__ one. Multiple embedded instances and
1516 added to the __builtin__ one. Multiple embedded instances and
1511 recursive embeddings should work better now (though I'm not sure
1517 recursive embeddings should work better now (though I'm not sure
1512 I've got all the corner cases fixed, that code is a bit of a brain
1518 I've got all the corner cases fixed, that code is a bit of a brain
1513 twister).
1519 twister).
1514
1520
1515 * IPython/Magic.py (magic_edit): added support to edit in-memory
1521 * IPython/Magic.py (magic_edit): added support to edit in-memory
1516 macros (automatically creates the necessary temp files). %edit
1522 macros (automatically creates the necessary temp files). %edit
1517 also doesn't return the file contents anymore, it's just noise.
1523 also doesn't return the file contents anymore, it's just noise.
1518
1524
1519 * IPython/completer.py (Completer.attr_matches): revert change to
1525 * IPython/completer.py (Completer.attr_matches): revert change to
1520 complete only on attributes listed in __all__. I realized it
1526 complete only on attributes listed in __all__. I realized it
1521 cripples the tab-completion system as a tool for exploring the
1527 cripples the tab-completion system as a tool for exploring the
1522 internals of unknown libraries (it renders any non-__all__
1528 internals of unknown libraries (it renders any non-__all__
1523 attribute off-limits). I got bit by this when trying to see
1529 attribute off-limits). I got bit by this when trying to see
1524 something inside the dis module.
1530 something inside the dis module.
1525
1531
1526 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
1532 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
1527
1533
1528 * IPython/iplib.py (InteractiveShell.__init__): add .meta
1534 * IPython/iplib.py (InteractiveShell.__init__): add .meta
1529 namespace for users and extension writers to hold data in. This
1535 namespace for users and extension writers to hold data in. This
1530 follows the discussion in
1536 follows the discussion in
1531 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
1537 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
1532
1538
1533 * IPython/completer.py (IPCompleter.complete): small patch to help
1539 * IPython/completer.py (IPCompleter.complete): small patch to help
1534 tab-completion under Emacs, after a suggestion by John Barnard
1540 tab-completion under Emacs, after a suggestion by John Barnard
1535 <barnarj-AT-ccf.org>.
1541 <barnarj-AT-ccf.org>.
1536
1542
1537 * IPython/Magic.py (Magic.extract_input_slices): added support for
1543 * IPython/Magic.py (Magic.extract_input_slices): added support for
1538 the slice notation in magics to use N-M to represent numbers N...M
1544 the slice notation in magics to use N-M to represent numbers N...M
1539 (closed endpoints). This is used by %macro and %save.
1545 (closed endpoints). This is used by %macro and %save.
1540
1546
1541 * IPython/completer.py (Completer.attr_matches): for modules which
1547 * IPython/completer.py (Completer.attr_matches): for modules which
1542 define __all__, complete only on those. After a patch by Jeffrey
1548 define __all__, complete only on those. After a patch by Jeffrey
1543 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
1549 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
1544 speed up this routine.
1550 speed up this routine.
1545
1551
1546 * IPython/Logger.py (Logger.log): fix a history handling bug. I
1552 * IPython/Logger.py (Logger.log): fix a history handling bug. I
1547 don't know if this is the end of it, but the behavior now is
1553 don't know if this is the end of it, but the behavior now is
1548 certainly much more correct. Note that coupled with macros,
1554 certainly much more correct. Note that coupled with macros,
1549 slightly surprising (at first) behavior may occur: a macro will in
1555 slightly surprising (at first) behavior may occur: a macro will in
1550 general expand to multiple lines of input, so upon exiting, the
1556 general expand to multiple lines of input, so upon exiting, the
1551 in/out counters will both be bumped by the corresponding amount
1557 in/out counters will both be bumped by the corresponding amount
1552 (as if the macro's contents had been typed interactively). Typing
1558 (as if the macro's contents had been typed interactively). Typing
1553 %hist will reveal the intermediate (silently processed) lines.
1559 %hist will reveal the intermediate (silently processed) lines.
1554
1560
1555 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
1561 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
1556 pickle to fail (%run was overwriting __main__ and not restoring
1562 pickle to fail (%run was overwriting __main__ and not restoring
1557 it, but pickle relies on __main__ to operate).
1563 it, but pickle relies on __main__ to operate).
1558
1564
1559 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
1565 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
1560 using properties, but forgot to make the main InteractiveShell
1566 using properties, but forgot to make the main InteractiveShell
1561 class a new-style class. Properties fail silently, and
1567 class a new-style class. Properties fail silently, and
1562 mysteriously, with old-style class (getters work, but
1568 mysteriously, with old-style class (getters work, but
1563 setters don't do anything).
1569 setters don't do anything).
1564
1570
1565 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
1571 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
1566
1572
1567 * IPython/Magic.py (magic_history): fix history reporting bug (I
1573 * IPython/Magic.py (magic_history): fix history reporting bug (I
1568 know some nasties are still there, I just can't seem to find a
1574 know some nasties are still there, I just can't seem to find a
1569 reproducible test case to track them down; the input history is
1575 reproducible test case to track them down; the input history is
1570 falling out of sync...)
1576 falling out of sync...)
1571
1577
1572 * IPython/iplib.py (handle_shell_escape): fix bug where both
1578 * IPython/iplib.py (handle_shell_escape): fix bug where both
1573 aliases and system accesses where broken for indented code (such
1579 aliases and system accesses where broken for indented code (such
1574 as loops).
1580 as loops).
1575
1581
1576 * IPython/genutils.py (shell): fix small but critical bug for
1582 * IPython/genutils.py (shell): fix small but critical bug for
1577 win32 system access.
1583 win32 system access.
1578
1584
1579 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
1585 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
1580
1586
1581 * IPython/iplib.py (showtraceback): remove use of the
1587 * IPython/iplib.py (showtraceback): remove use of the
1582 sys.last_{type/value/traceback} structures, which are non
1588 sys.last_{type/value/traceback} structures, which are non
1583 thread-safe.
1589 thread-safe.
1584 (_prefilter): change control flow to ensure that we NEVER
1590 (_prefilter): change control flow to ensure that we NEVER
1585 introspect objects when autocall is off. This will guarantee that
1591 introspect objects when autocall is off. This will guarantee that
1586 having an input line of the form 'x.y', where access to attribute
1592 having an input line of the form 'x.y', where access to attribute
1587 'y' has side effects, doesn't trigger the side effect TWICE. It
1593 'y' has side effects, doesn't trigger the side effect TWICE. It
1588 is important to note that, with autocall on, these side effects
1594 is important to note that, with autocall on, these side effects
1589 can still happen.
1595 can still happen.
1590 (ipsystem): new builtin, to complete the ip{magic/alias/system}
1596 (ipsystem): new builtin, to complete the ip{magic/alias/system}
1591 trio. IPython offers these three kinds of special calls which are
1597 trio. IPython offers these three kinds of special calls which are
1592 not python code, and it's a good thing to have their call method
1598 not python code, and it's a good thing to have their call method
1593 be accessible as pure python functions (not just special syntax at
1599 be accessible as pure python functions (not just special syntax at
1594 the command line). It gives us a better internal implementation
1600 the command line). It gives us a better internal implementation
1595 structure, as well as exposing these for user scripting more
1601 structure, as well as exposing these for user scripting more
1596 cleanly.
1602 cleanly.
1597
1603
1598 * IPython/macro.py (Macro.__init__): moved macros to a standalone
1604 * IPython/macro.py (Macro.__init__): moved macros to a standalone
1599 file. Now that they'll be more likely to be used with the
1605 file. Now that they'll be more likely to be used with the
1600 persistance system (%store), I want to make sure their module path
1606 persistance system (%store), I want to make sure their module path
1601 doesn't change in the future, so that we don't break things for
1607 doesn't change in the future, so that we don't break things for
1602 users' persisted data.
1608 users' persisted data.
1603
1609
1604 * IPython/iplib.py (autoindent_update): move indentation
1610 * IPython/iplib.py (autoindent_update): move indentation
1605 management into the _text_ processing loop, not the keyboard
1611 management into the _text_ processing loop, not the keyboard
1606 interactive one. This is necessary to correctly process non-typed
1612 interactive one. This is necessary to correctly process non-typed
1607 multiline input (such as macros).
1613 multiline input (such as macros).
1608
1614
1609 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
1615 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
1610 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
1616 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
1611 which was producing problems in the resulting manual.
1617 which was producing problems in the resulting manual.
1612 (magic_whos): improve reporting of instances (show their class,
1618 (magic_whos): improve reporting of instances (show their class,
1613 instead of simply printing 'instance' which isn't terribly
1619 instead of simply printing 'instance' which isn't terribly
1614 informative).
1620 informative).
1615
1621
1616 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
1622 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
1617 (minor mods) to support network shares under win32.
1623 (minor mods) to support network shares under win32.
1618
1624
1619 * IPython/winconsole.py (get_console_size): add new winconsole
1625 * IPython/winconsole.py (get_console_size): add new winconsole
1620 module and fixes to page_dumb() to improve its behavior under
1626 module and fixes to page_dumb() to improve its behavior under
1621 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
1627 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
1622
1628
1623 * IPython/Magic.py (Macro): simplified Macro class to just
1629 * IPython/Magic.py (Macro): simplified Macro class to just
1624 subclass list. We've had only 2.2 compatibility for a very long
1630 subclass list. We've had only 2.2 compatibility for a very long
1625 time, yet I was still avoiding subclassing the builtin types. No
1631 time, yet I was still avoiding subclassing the builtin types. No
1626 more (I'm also starting to use properties, though I won't shift to
1632 more (I'm also starting to use properties, though I won't shift to
1627 2.3-specific features quite yet).
1633 2.3-specific features quite yet).
1628 (magic_store): added Ville's patch for lightweight variable
1634 (magic_store): added Ville's patch for lightweight variable
1629 persistence, after a request on the user list by Matt Wilkie
1635 persistence, after a request on the user list by Matt Wilkie
1630 <maphew-AT-gmail.com>. The new %store magic's docstring has full
1636 <maphew-AT-gmail.com>. The new %store magic's docstring has full
1631 details.
1637 details.
1632
1638
1633 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1639 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1634 changed the default logfile name from 'ipython.log' to
1640 changed the default logfile name from 'ipython.log' to
1635 'ipython_log.py'. These logs are real python files, and now that
1641 'ipython_log.py'. These logs are real python files, and now that
1636 we have much better multiline support, people are more likely to
1642 we have much better multiline support, people are more likely to
1637 want to use them as such. Might as well name them correctly.
1643 want to use them as such. Might as well name them correctly.
1638
1644
1639 * IPython/Magic.py: substantial cleanup. While we can't stop
1645 * IPython/Magic.py: substantial cleanup. While we can't stop
1640 using magics as mixins, due to the existing customizations 'out
1646 using magics as mixins, due to the existing customizations 'out
1641 there' which rely on the mixin naming conventions, at least I
1647 there' which rely on the mixin naming conventions, at least I
1642 cleaned out all cross-class name usage. So once we are OK with
1648 cleaned out all cross-class name usage. So once we are OK with
1643 breaking compatibility, the two systems can be separated.
1649 breaking compatibility, the two systems can be separated.
1644
1650
1645 * IPython/Logger.py: major cleanup. This one is NOT a mixin
1651 * IPython/Logger.py: major cleanup. This one is NOT a mixin
1646 anymore, and the class is a fair bit less hideous as well. New
1652 anymore, and the class is a fair bit less hideous as well. New
1647 features were also introduced: timestamping of input, and logging
1653 features were also introduced: timestamping of input, and logging
1648 of output results. These are user-visible with the -t and -o
1654 of output results. These are user-visible with the -t and -o
1649 options to %logstart. Closes
1655 options to %logstart. Closes
1650 http://www.scipy.net/roundup/ipython/issue11 and a request by
1656 http://www.scipy.net/roundup/ipython/issue11 and a request by
1651 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
1657 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
1652
1658
1653 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
1659 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
1654
1660
1655 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
1661 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
1656 better handle backslashes in paths. See the thread 'More Windows
1662 better handle backslashes in paths. See the thread 'More Windows
1657 questions part 2 - \/ characters revisited' on the iypthon user
1663 questions part 2 - \/ characters revisited' on the iypthon user
1658 list:
1664 list:
1659 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
1665 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
1660
1666
1661 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
1667 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
1662
1668
1663 (InteractiveShell.__init__): change threaded shells to not use the
1669 (InteractiveShell.__init__): change threaded shells to not use the
1664 ipython crash handler. This was causing more problems than not,
1670 ipython crash handler. This was causing more problems than not,
1665 as exceptions in the main thread (GUI code, typically) would
1671 as exceptions in the main thread (GUI code, typically) would
1666 always show up as a 'crash', when they really weren't.
1672 always show up as a 'crash', when they really weren't.
1667
1673
1668 The colors and exception mode commands (%colors/%xmode) have been
1674 The colors and exception mode commands (%colors/%xmode) have been
1669 synchronized to also take this into account, so users can get
1675 synchronized to also take this into account, so users can get
1670 verbose exceptions for their threaded code as well. I also added
1676 verbose exceptions for their threaded code as well. I also added
1671 support for activating pdb inside this exception handler as well,
1677 support for activating pdb inside this exception handler as well,
1672 so now GUI authors can use IPython's enhanced pdb at runtime.
1678 so now GUI authors can use IPython's enhanced pdb at runtime.
1673
1679
1674 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
1680 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
1675 true by default, and add it to the shipped ipythonrc file. Since
1681 true by default, and add it to the shipped ipythonrc file. Since
1676 this asks the user before proceeding, I think it's OK to make it
1682 this asks the user before proceeding, I think it's OK to make it
1677 true by default.
1683 true by default.
1678
1684
1679 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
1685 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
1680 of the previous special-casing of input in the eval loop. I think
1686 of the previous special-casing of input in the eval loop. I think
1681 this is cleaner, as they really are commands and shouldn't have
1687 this is cleaner, as they really are commands and shouldn't have
1682 a special role in the middle of the core code.
1688 a special role in the middle of the core code.
1683
1689
1684 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
1690 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
1685
1691
1686 * IPython/iplib.py (edit_syntax_error): added support for
1692 * IPython/iplib.py (edit_syntax_error): added support for
1687 automatically reopening the editor if the file had a syntax error
1693 automatically reopening the editor if the file had a syntax error
1688 in it. Thanks to scottt who provided the patch at:
1694 in it. Thanks to scottt who provided the patch at:
1689 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
1695 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
1690 version committed).
1696 version committed).
1691
1697
1692 * IPython/iplib.py (handle_normal): add suport for multi-line
1698 * IPython/iplib.py (handle_normal): add suport for multi-line
1693 input with emtpy lines. This fixes
1699 input with emtpy lines. This fixes
1694 http://www.scipy.net/roundup/ipython/issue43 and a similar
1700 http://www.scipy.net/roundup/ipython/issue43 and a similar
1695 discussion on the user list.
1701 discussion on the user list.
1696
1702
1697 WARNING: a behavior change is necessarily introduced to support
1703 WARNING: a behavior change is necessarily introduced to support
1698 blank lines: now a single blank line with whitespace does NOT
1704 blank lines: now a single blank line with whitespace does NOT
1699 break the input loop, which means that when autoindent is on, by
1705 break the input loop, which means that when autoindent is on, by
1700 default hitting return on the next (indented) line does NOT exit.
1706 default hitting return on the next (indented) line does NOT exit.
1701
1707
1702 Instead, to exit a multiline input you can either have:
1708 Instead, to exit a multiline input you can either have:
1703
1709
1704 - TWO whitespace lines (just hit return again), or
1710 - TWO whitespace lines (just hit return again), or
1705 - a single whitespace line of a different length than provided
1711 - a single whitespace line of a different length than provided
1706 by the autoindent (add or remove a space).
1712 by the autoindent (add or remove a space).
1707
1713
1708 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
1714 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
1709 module to better organize all readline-related functionality.
1715 module to better organize all readline-related functionality.
1710 I've deleted FlexCompleter and put all completion clases here.
1716 I've deleted FlexCompleter and put all completion clases here.
1711
1717
1712 * IPython/iplib.py (raw_input): improve indentation management.
1718 * IPython/iplib.py (raw_input): improve indentation management.
1713 It is now possible to paste indented code with autoindent on, and
1719 It is now possible to paste indented code with autoindent on, and
1714 the code is interpreted correctly (though it still looks bad on
1720 the code is interpreted correctly (though it still looks bad on
1715 screen, due to the line-oriented nature of ipython).
1721 screen, due to the line-oriented nature of ipython).
1716 (MagicCompleter.complete): change behavior so that a TAB key on an
1722 (MagicCompleter.complete): change behavior so that a TAB key on an
1717 otherwise empty line actually inserts a tab, instead of completing
1723 otherwise empty line actually inserts a tab, instead of completing
1718 on the entire global namespace. This makes it easier to use the
1724 on the entire global namespace. This makes it easier to use the
1719 TAB key for indentation. After a request by Hans Meine
1725 TAB key for indentation. After a request by Hans Meine
1720 <hans_meine-AT-gmx.net>
1726 <hans_meine-AT-gmx.net>
1721 (_prefilter): add support so that typing plain 'exit' or 'quit'
1727 (_prefilter): add support so that typing plain 'exit' or 'quit'
1722 does a sensible thing. Originally I tried to deviate as little as
1728 does a sensible thing. Originally I tried to deviate as little as
1723 possible from the default python behavior, but even that one may
1729 possible from the default python behavior, but even that one may
1724 change in this direction (thread on python-dev to that effect).
1730 change in this direction (thread on python-dev to that effect).
1725 Regardless, ipython should do the right thing even if CPython's
1731 Regardless, ipython should do the right thing even if CPython's
1726 '>>>' prompt doesn't.
1732 '>>>' prompt doesn't.
1727 (InteractiveShell): removed subclassing code.InteractiveConsole
1733 (InteractiveShell): removed subclassing code.InteractiveConsole
1728 class. By now we'd overridden just about all of its methods: I've
1734 class. By now we'd overridden just about all of its methods: I've
1729 copied the remaining two over, and now ipython is a standalone
1735 copied the remaining two over, and now ipython is a standalone
1730 class. This will provide a clearer picture for the chainsaw
1736 class. This will provide a clearer picture for the chainsaw
1731 branch refactoring.
1737 branch refactoring.
1732
1738
1733 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
1739 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
1734
1740
1735 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
1741 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
1736 failures for objects which break when dir() is called on them.
1742 failures for objects which break when dir() is called on them.
1737
1743
1738 * IPython/FlexCompleter.py (Completer.__init__): Added support for
1744 * IPython/FlexCompleter.py (Completer.__init__): Added support for
1739 distinct local and global namespaces in the completer API. This
1745 distinct local and global namespaces in the completer API. This
1740 change allows us to properly handle completion with distinct
1746 change allows us to properly handle completion with distinct
1741 scopes, including in embedded instances (this had never really
1747 scopes, including in embedded instances (this had never really
1742 worked correctly).
1748 worked correctly).
1743
1749
1744 Note: this introduces a change in the constructor for
1750 Note: this introduces a change in the constructor for
1745 MagicCompleter, as a new global_namespace parameter is now the
1751 MagicCompleter, as a new global_namespace parameter is now the
1746 second argument (the others were bumped one position).
1752 second argument (the others were bumped one position).
1747
1753
1748 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
1754 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
1749
1755
1750 * IPython/iplib.py (embed_mainloop): fix tab-completion in
1756 * IPython/iplib.py (embed_mainloop): fix tab-completion in
1751 embedded instances (which can be done now thanks to Vivian's
1757 embedded instances (which can be done now thanks to Vivian's
1752 frame-handling fixes for pdb).
1758 frame-handling fixes for pdb).
1753 (InteractiveShell.__init__): Fix namespace handling problem in
1759 (InteractiveShell.__init__): Fix namespace handling problem in
1754 embedded instances. We were overwriting __main__ unconditionally,
1760 embedded instances. We were overwriting __main__ unconditionally,
1755 and this should only be done for 'full' (non-embedded) IPython;
1761 and this should only be done for 'full' (non-embedded) IPython;
1756 embedded instances must respect the caller's __main__. Thanks to
1762 embedded instances must respect the caller's __main__. Thanks to
1757 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
1763 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
1758
1764
1759 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
1765 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
1760
1766
1761 * setup.py: added download_url to setup(). This registers the
1767 * setup.py: added download_url to setup(). This registers the
1762 download address at PyPI, which is not only useful to humans
1768 download address at PyPI, which is not only useful to humans
1763 browsing the site, but is also picked up by setuptools (the Eggs
1769 browsing the site, but is also picked up by setuptools (the Eggs
1764 machinery). Thanks to Ville and R. Kern for the info/discussion
1770 machinery). Thanks to Ville and R. Kern for the info/discussion
1765 on this.
1771 on this.
1766
1772
1767 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
1773 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
1768
1774
1769 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
1775 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
1770 This brings a lot of nice functionality to the pdb mode, which now
1776 This brings a lot of nice functionality to the pdb mode, which now
1771 has tab-completion, syntax highlighting, and better stack handling
1777 has tab-completion, syntax highlighting, and better stack handling
1772 than before. Many thanks to Vivian De Smedt
1778 than before. Many thanks to Vivian De Smedt
1773 <vivian-AT-vdesmedt.com> for the original patches.
1779 <vivian-AT-vdesmedt.com> for the original patches.
1774
1780
1775 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
1781 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
1776
1782
1777 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
1783 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
1778 sequence to consistently accept the banner argument. The
1784 sequence to consistently accept the banner argument. The
1779 inconsistency was tripping SAGE, thanks to Gary Zablackis
1785 inconsistency was tripping SAGE, thanks to Gary Zablackis
1780 <gzabl-AT-yahoo.com> for the report.
1786 <gzabl-AT-yahoo.com> for the report.
1781
1787
1782 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
1788 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
1783
1789
1784 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1790 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1785 Fix bug where a naked 'alias' call in the ipythonrc file would
1791 Fix bug where a naked 'alias' call in the ipythonrc file would
1786 cause a crash. Bug reported by Jorgen Stenarson.
1792 cause a crash. Bug reported by Jorgen Stenarson.
1787
1793
1788 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
1794 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
1789
1795
1790 * IPython/ipmaker.py (make_IPython): cleanups which should improve
1796 * IPython/ipmaker.py (make_IPython): cleanups which should improve
1791 startup time.
1797 startup time.
1792
1798
1793 * IPython/iplib.py (runcode): my globals 'fix' for embedded
1799 * IPython/iplib.py (runcode): my globals 'fix' for embedded
1794 instances had introduced a bug with globals in normal code. Now
1800 instances had introduced a bug with globals in normal code. Now
1795 it's working in all cases.
1801 it's working in all cases.
1796
1802
1797 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
1803 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
1798 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
1804 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
1799 has been introduced to set the default case sensitivity of the
1805 has been introduced to set the default case sensitivity of the
1800 searches. Users can still select either mode at runtime on a
1806 searches. Users can still select either mode at runtime on a
1801 per-search basis.
1807 per-search basis.
1802
1808
1803 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
1809 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
1804
1810
1805 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
1811 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
1806 attributes in wildcard searches for subclasses. Modified version
1812 attributes in wildcard searches for subclasses. Modified version
1807 of a patch by Jorgen.
1813 of a patch by Jorgen.
1808
1814
1809 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
1815 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
1810
1816
1811 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
1817 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
1812 embedded instances. I added a user_global_ns attribute to the
1818 embedded instances. I added a user_global_ns attribute to the
1813 InteractiveShell class to handle this.
1819 InteractiveShell class to handle this.
1814
1820
1815 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
1821 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
1816
1822
1817 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
1823 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
1818 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
1824 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
1819 (reported under win32, but may happen also in other platforms).
1825 (reported under win32, but may happen also in other platforms).
1820 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
1826 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
1821
1827
1822 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
1828 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
1823
1829
1824 * IPython/Magic.py (magic_psearch): new support for wildcard
1830 * IPython/Magic.py (magic_psearch): new support for wildcard
1825 patterns. Now, typing ?a*b will list all names which begin with a
1831 patterns. Now, typing ?a*b will list all names which begin with a
1826 and end in b, for example. The %psearch magic has full
1832 and end in b, for example. The %psearch magic has full
1827 docstrings. Many thanks to JΓΆrgen Stenarson
1833 docstrings. Many thanks to JΓΆrgen Stenarson
1828 <jorgen.stenarson-AT-bostream.nu>, author of the patches
1834 <jorgen.stenarson-AT-bostream.nu>, author of the patches
1829 implementing this functionality.
1835 implementing this functionality.
1830
1836
1831 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1837 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1832
1838
1833 * Manual: fixed long-standing annoyance of double-dashes (as in
1839 * Manual: fixed long-standing annoyance of double-dashes (as in
1834 --prefix=~, for example) being stripped in the HTML version. This
1840 --prefix=~, for example) being stripped in the HTML version. This
1835 is a latex2html bug, but a workaround was provided. Many thanks
1841 is a latex2html bug, but a workaround was provided. Many thanks
1836 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
1842 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
1837 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
1843 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
1838 rolling. This seemingly small issue had tripped a number of users
1844 rolling. This seemingly small issue had tripped a number of users
1839 when first installing, so I'm glad to see it gone.
1845 when first installing, so I'm glad to see it gone.
1840
1846
1841 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1847 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1842
1848
1843 * IPython/Extensions/numeric_formats.py: fix missing import,
1849 * IPython/Extensions/numeric_formats.py: fix missing import,
1844 reported by Stephen Walton.
1850 reported by Stephen Walton.
1845
1851
1846 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
1852 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
1847
1853
1848 * IPython/demo.py: finish demo module, fully documented now.
1854 * IPython/demo.py: finish demo module, fully documented now.
1849
1855
1850 * IPython/genutils.py (file_read): simple little utility to read a
1856 * IPython/genutils.py (file_read): simple little utility to read a
1851 file and ensure it's closed afterwards.
1857 file and ensure it's closed afterwards.
1852
1858
1853 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
1859 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
1854
1860
1855 * IPython/demo.py (Demo.__init__): added support for individually
1861 * IPython/demo.py (Demo.__init__): added support for individually
1856 tagging blocks for automatic execution.
1862 tagging blocks for automatic execution.
1857
1863
1858 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
1864 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
1859 syntax-highlighted python sources, requested by John.
1865 syntax-highlighted python sources, requested by John.
1860
1866
1861 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
1867 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
1862
1868
1863 * IPython/demo.py (Demo.again): fix bug where again() blocks after
1869 * IPython/demo.py (Demo.again): fix bug where again() blocks after
1864 finishing.
1870 finishing.
1865
1871
1866 * IPython/genutils.py (shlex_split): moved from Magic to here,
1872 * IPython/genutils.py (shlex_split): moved from Magic to here,
1867 where all 2.2 compatibility stuff lives. I needed it for demo.py.
1873 where all 2.2 compatibility stuff lives. I needed it for demo.py.
1868
1874
1869 * IPython/demo.py (Demo.__init__): added support for silent
1875 * IPython/demo.py (Demo.__init__): added support for silent
1870 blocks, improved marks as regexps, docstrings written.
1876 blocks, improved marks as regexps, docstrings written.
1871 (Demo.__init__): better docstring, added support for sys.argv.
1877 (Demo.__init__): better docstring, added support for sys.argv.
1872
1878
1873 * IPython/genutils.py (marquee): little utility used by the demo
1879 * IPython/genutils.py (marquee): little utility used by the demo
1874 code, handy in general.
1880 code, handy in general.
1875
1881
1876 * IPython/demo.py (Demo.__init__): new class for interactive
1882 * IPython/demo.py (Demo.__init__): new class for interactive
1877 demos. Not documented yet, I just wrote it in a hurry for
1883 demos. Not documented yet, I just wrote it in a hurry for
1878 scipy'05. Will docstring later.
1884 scipy'05. Will docstring later.
1879
1885
1880 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
1886 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
1881
1887
1882 * IPython/Shell.py (sigint_handler): Drastic simplification which
1888 * IPython/Shell.py (sigint_handler): Drastic simplification which
1883 also seems to make Ctrl-C work correctly across threads! This is
1889 also seems to make Ctrl-C work correctly across threads! This is
1884 so simple, that I can't beleive I'd missed it before. Needs more
1890 so simple, that I can't beleive I'd missed it before. Needs more
1885 testing, though.
1891 testing, though.
1886 (KBINT): Never mind, revert changes. I'm sure I'd tried something
1892 (KBINT): Never mind, revert changes. I'm sure I'd tried something
1887 like this before...
1893 like this before...
1888
1894
1889 * IPython/genutils.py (get_home_dir): add protection against
1895 * IPython/genutils.py (get_home_dir): add protection against
1890 non-dirs in win32 registry.
1896 non-dirs in win32 registry.
1891
1897
1892 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
1898 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
1893 bug where dict was mutated while iterating (pysh crash).
1899 bug where dict was mutated while iterating (pysh crash).
1894
1900
1895 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
1901 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
1896
1902
1897 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
1903 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
1898 spurious newlines added by this routine. After a report by
1904 spurious newlines added by this routine. After a report by
1899 F. Mantegazza.
1905 F. Mantegazza.
1900
1906
1901 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
1907 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
1902
1908
1903 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
1909 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
1904 calls. These were a leftover from the GTK 1.x days, and can cause
1910 calls. These were a leftover from the GTK 1.x days, and can cause
1905 problems in certain cases (after a report by John Hunter).
1911 problems in certain cases (after a report by John Hunter).
1906
1912
1907 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
1913 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
1908 os.getcwd() fails at init time. Thanks to patch from David Remahl
1914 os.getcwd() fails at init time. Thanks to patch from David Remahl
1909 <chmod007-AT-mac.com>.
1915 <chmod007-AT-mac.com>.
1910 (InteractiveShell.__init__): prevent certain special magics from
1916 (InteractiveShell.__init__): prevent certain special magics from
1911 being shadowed by aliases. Closes
1917 being shadowed by aliases. Closes
1912 http://www.scipy.net/roundup/ipython/issue41.
1918 http://www.scipy.net/roundup/ipython/issue41.
1913
1919
1914 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
1920 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
1915
1921
1916 * IPython/iplib.py (InteractiveShell.complete): Added new
1922 * IPython/iplib.py (InteractiveShell.complete): Added new
1917 top-level completion method to expose the completion mechanism
1923 top-level completion method to expose the completion mechanism
1918 beyond readline-based environments.
1924 beyond readline-based environments.
1919
1925
1920 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
1926 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
1921
1927
1922 * tools/ipsvnc (svnversion): fix svnversion capture.
1928 * tools/ipsvnc (svnversion): fix svnversion capture.
1923
1929
1924 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
1930 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
1925 attribute to self, which was missing. Before, it was set by a
1931 attribute to self, which was missing. Before, it was set by a
1926 routine which in certain cases wasn't being called, so the
1932 routine which in certain cases wasn't being called, so the
1927 instance could end up missing the attribute. This caused a crash.
1933 instance could end up missing the attribute. This caused a crash.
1928 Closes http://www.scipy.net/roundup/ipython/issue40.
1934 Closes http://www.scipy.net/roundup/ipython/issue40.
1929
1935
1930 2005-08-16 Fernando Perez <fperez@colorado.edu>
1936 2005-08-16 Fernando Perez <fperez@colorado.edu>
1931
1937
1932 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
1938 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
1933 contains non-string attribute. Closes
1939 contains non-string attribute. Closes
1934 http://www.scipy.net/roundup/ipython/issue38.
1940 http://www.scipy.net/roundup/ipython/issue38.
1935
1941
1936 2005-08-14 Fernando Perez <fperez@colorado.edu>
1942 2005-08-14 Fernando Perez <fperez@colorado.edu>
1937
1943
1938 * tools/ipsvnc: Minor improvements, to add changeset info.
1944 * tools/ipsvnc: Minor improvements, to add changeset info.
1939
1945
1940 2005-08-12 Fernando Perez <fperez@colorado.edu>
1946 2005-08-12 Fernando Perez <fperez@colorado.edu>
1941
1947
1942 * IPython/iplib.py (runsource): remove self.code_to_run_src
1948 * IPython/iplib.py (runsource): remove self.code_to_run_src
1943 attribute. I realized this is nothing more than
1949 attribute. I realized this is nothing more than
1944 '\n'.join(self.buffer), and having the same data in two different
1950 '\n'.join(self.buffer), and having the same data in two different
1945 places is just asking for synchronization bugs. This may impact
1951 places is just asking for synchronization bugs. This may impact
1946 people who have custom exception handlers, so I need to warn
1952 people who have custom exception handlers, so I need to warn
1947 ipython-dev about it (F. Mantegazza may use them).
1953 ipython-dev about it (F. Mantegazza may use them).
1948
1954
1949 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
1955 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
1950
1956
1951 * IPython/genutils.py: fix 2.2 compatibility (generators)
1957 * IPython/genutils.py: fix 2.2 compatibility (generators)
1952
1958
1953 2005-07-18 Fernando Perez <fperez@colorado.edu>
1959 2005-07-18 Fernando Perez <fperez@colorado.edu>
1954
1960
1955 * IPython/genutils.py (get_home_dir): fix to help users with
1961 * IPython/genutils.py (get_home_dir): fix to help users with
1956 invalid $HOME under win32.
1962 invalid $HOME under win32.
1957
1963
1958 2005-07-17 Fernando Perez <fperez@colorado.edu>
1964 2005-07-17 Fernando Perez <fperez@colorado.edu>
1959
1965
1960 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
1966 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
1961 some old hacks and clean up a bit other routines; code should be
1967 some old hacks and clean up a bit other routines; code should be
1962 simpler and a bit faster.
1968 simpler and a bit faster.
1963
1969
1964 * IPython/iplib.py (interact): removed some last-resort attempts
1970 * IPython/iplib.py (interact): removed some last-resort attempts
1965 to survive broken stdout/stderr. That code was only making it
1971 to survive broken stdout/stderr. That code was only making it
1966 harder to abstract out the i/o (necessary for gui integration),
1972 harder to abstract out the i/o (necessary for gui integration),
1967 and the crashes it could prevent were extremely rare in practice
1973 and the crashes it could prevent were extremely rare in practice
1968 (besides being fully user-induced in a pretty violent manner).
1974 (besides being fully user-induced in a pretty violent manner).
1969
1975
1970 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
1976 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
1971 Nothing major yet, but the code is simpler to read; this should
1977 Nothing major yet, but the code is simpler to read; this should
1972 make it easier to do more serious modifications in the future.
1978 make it easier to do more serious modifications in the future.
1973
1979
1974 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
1980 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
1975 which broke in .15 (thanks to a report by Ville).
1981 which broke in .15 (thanks to a report by Ville).
1976
1982
1977 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
1983 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
1978 be quite correct, I know next to nothing about unicode). This
1984 be quite correct, I know next to nothing about unicode). This
1979 will allow unicode strings to be used in prompts, amongst other
1985 will allow unicode strings to be used in prompts, amongst other
1980 cases. It also will prevent ipython from crashing when unicode
1986 cases. It also will prevent ipython from crashing when unicode
1981 shows up unexpectedly in many places. If ascii encoding fails, we
1987 shows up unexpectedly in many places. If ascii encoding fails, we
1982 assume utf_8. Currently the encoding is not a user-visible
1988 assume utf_8. Currently the encoding is not a user-visible
1983 setting, though it could be made so if there is demand for it.
1989 setting, though it could be made so if there is demand for it.
1984
1990
1985 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
1991 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
1986
1992
1987 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
1993 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
1988
1994
1989 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
1995 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
1990
1996
1991 * IPython/genutils.py: Add 2.2 compatibility here, so all other
1997 * IPython/genutils.py: Add 2.2 compatibility here, so all other
1992 code can work transparently for 2.2/2.3.
1998 code can work transparently for 2.2/2.3.
1993
1999
1994 2005-07-16 Fernando Perez <fperez@colorado.edu>
2000 2005-07-16 Fernando Perez <fperez@colorado.edu>
1995
2001
1996 * IPython/ultraTB.py (ExceptionColors): Make a global variable
2002 * IPython/ultraTB.py (ExceptionColors): Make a global variable
1997 out of the color scheme table used for coloring exception
2003 out of the color scheme table used for coloring exception
1998 tracebacks. This allows user code to add new schemes at runtime.
2004 tracebacks. This allows user code to add new schemes at runtime.
1999 This is a minimally modified version of the patch at
2005 This is a minimally modified version of the patch at
2000 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
2006 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
2001 for the contribution.
2007 for the contribution.
2002
2008
2003 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
2009 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
2004 slightly modified version of the patch in
2010 slightly modified version of the patch in
2005 http://www.scipy.net/roundup/ipython/issue34, which also allows me
2011 http://www.scipy.net/roundup/ipython/issue34, which also allows me
2006 to remove the previous try/except solution (which was costlier).
2012 to remove the previous try/except solution (which was costlier).
2007 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
2013 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
2008
2014
2009 2005-06-08 Fernando Perez <fperez@colorado.edu>
2015 2005-06-08 Fernando Perez <fperez@colorado.edu>
2010
2016
2011 * IPython/iplib.py (write/write_err): Add methods to abstract all
2017 * IPython/iplib.py (write/write_err): Add methods to abstract all
2012 I/O a bit more.
2018 I/O a bit more.
2013
2019
2014 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
2020 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
2015 warning, reported by Aric Hagberg, fix by JD Hunter.
2021 warning, reported by Aric Hagberg, fix by JD Hunter.
2016
2022
2017 2005-06-02 *** Released version 0.6.15
2023 2005-06-02 *** Released version 0.6.15
2018
2024
2019 2005-06-01 Fernando Perez <fperez@colorado.edu>
2025 2005-06-01 Fernando Perez <fperez@colorado.edu>
2020
2026
2021 * IPython/iplib.py (MagicCompleter.file_matches): Fix
2027 * IPython/iplib.py (MagicCompleter.file_matches): Fix
2022 tab-completion of filenames within open-quoted strings. Note that
2028 tab-completion of filenames within open-quoted strings. Note that
2023 this requires that in ~/.ipython/ipythonrc, users change the
2029 this requires that in ~/.ipython/ipythonrc, users change the
2024 readline delimiters configuration to read:
2030 readline delimiters configuration to read:
2025
2031
2026 readline_remove_delims -/~
2032 readline_remove_delims -/~
2027
2033
2028
2034
2029 2005-05-31 *** Released version 0.6.14
2035 2005-05-31 *** Released version 0.6.14
2030
2036
2031 2005-05-29 Fernando Perez <fperez@colorado.edu>
2037 2005-05-29 Fernando Perez <fperez@colorado.edu>
2032
2038
2033 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
2039 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
2034 with files not on the filesystem. Reported by Eliyahu Sandler
2040 with files not on the filesystem. Reported by Eliyahu Sandler
2035 <eli@gondolin.net>
2041 <eli@gondolin.net>
2036
2042
2037 2005-05-22 Fernando Perez <fperez@colorado.edu>
2043 2005-05-22 Fernando Perez <fperez@colorado.edu>
2038
2044
2039 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
2045 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
2040 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
2046 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
2041
2047
2042 2005-05-19 Fernando Perez <fperez@colorado.edu>
2048 2005-05-19 Fernando Perez <fperez@colorado.edu>
2043
2049
2044 * IPython/iplib.py (safe_execfile): close a file which could be
2050 * IPython/iplib.py (safe_execfile): close a file which could be
2045 left open (causing problems in win32, which locks open files).
2051 left open (causing problems in win32, which locks open files).
2046 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
2052 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
2047
2053
2048 2005-05-18 Fernando Perez <fperez@colorado.edu>
2054 2005-05-18 Fernando Perez <fperez@colorado.edu>
2049
2055
2050 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
2056 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
2051 keyword arguments correctly to safe_execfile().
2057 keyword arguments correctly to safe_execfile().
2052
2058
2053 2005-05-13 Fernando Perez <fperez@colorado.edu>
2059 2005-05-13 Fernando Perez <fperez@colorado.edu>
2054
2060
2055 * ipython.1: Added info about Qt to manpage, and threads warning
2061 * ipython.1: Added info about Qt to manpage, and threads warning
2056 to usage page (invoked with --help).
2062 to usage page (invoked with --help).
2057
2063
2058 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
2064 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
2059 new matcher (it goes at the end of the priority list) to do
2065 new matcher (it goes at the end of the priority list) to do
2060 tab-completion on named function arguments. Submitted by George
2066 tab-completion on named function arguments. Submitted by George
2061 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
2067 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
2062 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
2068 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
2063 for more details.
2069 for more details.
2064
2070
2065 * IPython/Magic.py (magic_run): Added new -e flag to ignore
2071 * IPython/Magic.py (magic_run): Added new -e flag to ignore
2066 SystemExit exceptions in the script being run. Thanks to a report
2072 SystemExit exceptions in the script being run. Thanks to a report
2067 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
2073 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
2068 producing very annoying behavior when running unit tests.
2074 producing very annoying behavior when running unit tests.
2069
2075
2070 2005-05-12 Fernando Perez <fperez@colorado.edu>
2076 2005-05-12 Fernando Perez <fperez@colorado.edu>
2071
2077
2072 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
2078 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
2073 which I'd broken (again) due to a changed regexp. In the process,
2079 which I'd broken (again) due to a changed regexp. In the process,
2074 added ';' as an escape to auto-quote the whole line without
2080 added ';' as an escape to auto-quote the whole line without
2075 splitting its arguments. Thanks to a report by Jerry McRae
2081 splitting its arguments. Thanks to a report by Jerry McRae
2076 <qrs0xyc02-AT-sneakemail.com>.
2082 <qrs0xyc02-AT-sneakemail.com>.
2077
2083
2078 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
2084 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
2079 possible crashes caused by a TokenError. Reported by Ed Schofield
2085 possible crashes caused by a TokenError. Reported by Ed Schofield
2080 <schofield-AT-ftw.at>.
2086 <schofield-AT-ftw.at>.
2081
2087
2082 2005-05-06 Fernando Perez <fperez@colorado.edu>
2088 2005-05-06 Fernando Perez <fperez@colorado.edu>
2083
2089
2084 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
2090 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
2085
2091
2086 2005-04-29 Fernando Perez <fperez@colorado.edu>
2092 2005-04-29 Fernando Perez <fperez@colorado.edu>
2087
2093
2088 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
2094 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
2089 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
2095 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
2090 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
2096 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
2091 which provides support for Qt interactive usage (similar to the
2097 which provides support for Qt interactive usage (similar to the
2092 existing one for WX and GTK). This had been often requested.
2098 existing one for WX and GTK). This had been often requested.
2093
2099
2094 2005-04-14 *** Released version 0.6.13
2100 2005-04-14 *** Released version 0.6.13
2095
2101
2096 2005-04-08 Fernando Perez <fperez@colorado.edu>
2102 2005-04-08 Fernando Perez <fperez@colorado.edu>
2097
2103
2098 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
2104 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
2099 from _ofind, which gets called on almost every input line. Now,
2105 from _ofind, which gets called on almost every input line. Now,
2100 we only try to get docstrings if they are actually going to be
2106 we only try to get docstrings if they are actually going to be
2101 used (the overhead of fetching unnecessary docstrings can be
2107 used (the overhead of fetching unnecessary docstrings can be
2102 noticeable for certain objects, such as Pyro proxies).
2108 noticeable for certain objects, such as Pyro proxies).
2103
2109
2104 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
2110 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
2105 for completers. For some reason I had been passing them the state
2111 for completers. For some reason I had been passing them the state
2106 variable, which completers never actually need, and was in
2112 variable, which completers never actually need, and was in
2107 conflict with the rlcompleter API. Custom completers ONLY need to
2113 conflict with the rlcompleter API. Custom completers ONLY need to
2108 take the text parameter.
2114 take the text parameter.
2109
2115
2110 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
2116 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
2111 work correctly in pysh. I've also moved all the logic which used
2117 work correctly in pysh. I've also moved all the logic which used
2112 to be in pysh.py here, which will prevent problems with future
2118 to be in pysh.py here, which will prevent problems with future
2113 upgrades. However, this time I must warn users to update their
2119 upgrades. However, this time I must warn users to update their
2114 pysh profile to include the line
2120 pysh profile to include the line
2115
2121
2116 import_all IPython.Extensions.InterpreterExec
2122 import_all IPython.Extensions.InterpreterExec
2117
2123
2118 because otherwise things won't work for them. They MUST also
2124 because otherwise things won't work for them. They MUST also
2119 delete pysh.py and the line
2125 delete pysh.py and the line
2120
2126
2121 execfile pysh.py
2127 execfile pysh.py
2122
2128
2123 from their ipythonrc-pysh.
2129 from their ipythonrc-pysh.
2124
2130
2125 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
2131 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
2126 robust in the face of objects whose dir() returns non-strings
2132 robust in the face of objects whose dir() returns non-strings
2127 (which it shouldn't, but some broken libs like ITK do). Thanks to
2133 (which it shouldn't, but some broken libs like ITK do). Thanks to
2128 a patch by John Hunter (implemented differently, though). Also
2134 a patch by John Hunter (implemented differently, though). Also
2129 minor improvements by using .extend instead of + on lists.
2135 minor improvements by using .extend instead of + on lists.
2130
2136
2131 * pysh.py:
2137 * pysh.py:
2132
2138
2133 2005-04-06 Fernando Perez <fperez@colorado.edu>
2139 2005-04-06 Fernando Perez <fperez@colorado.edu>
2134
2140
2135 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
2141 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
2136 by default, so that all users benefit from it. Those who don't
2142 by default, so that all users benefit from it. Those who don't
2137 want it can still turn it off.
2143 want it can still turn it off.
2138
2144
2139 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
2145 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
2140 config file, I'd forgotten about this, so users were getting it
2146 config file, I'd forgotten about this, so users were getting it
2141 off by default.
2147 off by default.
2142
2148
2143 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
2149 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
2144 consistency. Now magics can be called in multiline statements,
2150 consistency. Now magics can be called in multiline statements,
2145 and python variables can be expanded in magic calls via $var.
2151 and python variables can be expanded in magic calls via $var.
2146 This makes the magic system behave just like aliases or !system
2152 This makes the magic system behave just like aliases or !system
2147 calls.
2153 calls.
2148
2154
2149 2005-03-28 Fernando Perez <fperez@colorado.edu>
2155 2005-03-28 Fernando Perez <fperez@colorado.edu>
2150
2156
2151 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
2157 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
2152 expensive string additions for building command. Add support for
2158 expensive string additions for building command. Add support for
2153 trailing ';' when autocall is used.
2159 trailing ';' when autocall is used.
2154
2160
2155 2005-03-26 Fernando Perez <fperez@colorado.edu>
2161 2005-03-26 Fernando Perez <fperez@colorado.edu>
2156
2162
2157 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
2163 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
2158 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
2164 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
2159 ipython.el robust against prompts with any number of spaces
2165 ipython.el robust against prompts with any number of spaces
2160 (including 0) after the ':' character.
2166 (including 0) after the ':' character.
2161
2167
2162 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
2168 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
2163 continuation prompt, which misled users to think the line was
2169 continuation prompt, which misled users to think the line was
2164 already indented. Closes debian Bug#300847, reported to me by
2170 already indented. Closes debian Bug#300847, reported to me by
2165 Norbert Tretkowski <tretkowski-AT-inittab.de>.
2171 Norbert Tretkowski <tretkowski-AT-inittab.de>.
2166
2172
2167 2005-03-23 Fernando Perez <fperez@colorado.edu>
2173 2005-03-23 Fernando Perez <fperez@colorado.edu>
2168
2174
2169 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
2175 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
2170 properly aligned if they have embedded newlines.
2176 properly aligned if they have embedded newlines.
2171
2177
2172 * IPython/iplib.py (runlines): Add a public method to expose
2178 * IPython/iplib.py (runlines): Add a public method to expose
2173 IPython's code execution machinery, so that users can run strings
2179 IPython's code execution machinery, so that users can run strings
2174 as if they had been typed at the prompt interactively.
2180 as if they had been typed at the prompt interactively.
2175 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
2181 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
2176 methods which can call the system shell, but with python variable
2182 methods which can call the system shell, but with python variable
2177 expansion. The three such methods are: __IPYTHON__.system,
2183 expansion. The three such methods are: __IPYTHON__.system,
2178 .getoutput and .getoutputerror. These need to be documented in a
2184 .getoutput and .getoutputerror. These need to be documented in a
2179 'public API' section (to be written) of the manual.
2185 'public API' section (to be written) of the manual.
2180
2186
2181 2005-03-20 Fernando Perez <fperez@colorado.edu>
2187 2005-03-20 Fernando Perez <fperez@colorado.edu>
2182
2188
2183 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
2189 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
2184 for custom exception handling. This is quite powerful, and it
2190 for custom exception handling. This is quite powerful, and it
2185 allows for user-installable exception handlers which can trap
2191 allows for user-installable exception handlers which can trap
2186 custom exceptions at runtime and treat them separately from
2192 custom exceptions at runtime and treat them separately from
2187 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
2193 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
2188 Mantegazza <mantegazza-AT-ill.fr>.
2194 Mantegazza <mantegazza-AT-ill.fr>.
2189 (InteractiveShell.set_custom_completer): public API function to
2195 (InteractiveShell.set_custom_completer): public API function to
2190 add new completers at runtime.
2196 add new completers at runtime.
2191
2197
2192 2005-03-19 Fernando Perez <fperez@colorado.edu>
2198 2005-03-19 Fernando Perez <fperez@colorado.edu>
2193
2199
2194 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
2200 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
2195 allow objects which provide their docstrings via non-standard
2201 allow objects which provide their docstrings via non-standard
2196 mechanisms (like Pyro proxies) to still be inspected by ipython's
2202 mechanisms (like Pyro proxies) to still be inspected by ipython's
2197 ? system.
2203 ? system.
2198
2204
2199 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
2205 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
2200 automatic capture system. I tried quite hard to make it work
2206 automatic capture system. I tried quite hard to make it work
2201 reliably, and simply failed. I tried many combinations with the
2207 reliably, and simply failed. I tried many combinations with the
2202 subprocess module, but eventually nothing worked in all needed
2208 subprocess module, but eventually nothing worked in all needed
2203 cases (not blocking stdin for the child, duplicating stdout
2209 cases (not blocking stdin for the child, duplicating stdout
2204 without blocking, etc). The new %sc/%sx still do capture to these
2210 without blocking, etc). The new %sc/%sx still do capture to these
2205 magical list/string objects which make shell use much more
2211 magical list/string objects which make shell use much more
2206 conveninent, so not all is lost.
2212 conveninent, so not all is lost.
2207
2213
2208 XXX - FIX MANUAL for the change above!
2214 XXX - FIX MANUAL for the change above!
2209
2215
2210 (runsource): I copied code.py's runsource() into ipython to modify
2216 (runsource): I copied code.py's runsource() into ipython to modify
2211 it a bit. Now the code object and source to be executed are
2217 it a bit. Now the code object and source to be executed are
2212 stored in ipython. This makes this info accessible to third-party
2218 stored in ipython. This makes this info accessible to third-party
2213 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
2219 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
2214 Mantegazza <mantegazza-AT-ill.fr>.
2220 Mantegazza <mantegazza-AT-ill.fr>.
2215
2221
2216 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
2222 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
2217 history-search via readline (like C-p/C-n). I'd wanted this for a
2223 history-search via readline (like C-p/C-n). I'd wanted this for a
2218 long time, but only recently found out how to do it. For users
2224 long time, but only recently found out how to do it. For users
2219 who already have their ipythonrc files made and want this, just
2225 who already have their ipythonrc files made and want this, just
2220 add:
2226 add:
2221
2227
2222 readline_parse_and_bind "\e[A": history-search-backward
2228 readline_parse_and_bind "\e[A": history-search-backward
2223 readline_parse_and_bind "\e[B": history-search-forward
2229 readline_parse_and_bind "\e[B": history-search-forward
2224
2230
2225 2005-03-18 Fernando Perez <fperez@colorado.edu>
2231 2005-03-18 Fernando Perez <fperez@colorado.edu>
2226
2232
2227 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
2233 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
2228 LSString and SList classes which allow transparent conversions
2234 LSString and SList classes which allow transparent conversions
2229 between list mode and whitespace-separated string.
2235 between list mode and whitespace-separated string.
2230 (magic_r): Fix recursion problem in %r.
2236 (magic_r): Fix recursion problem in %r.
2231
2237
2232 * IPython/genutils.py (LSString): New class to be used for
2238 * IPython/genutils.py (LSString): New class to be used for
2233 automatic storage of the results of all alias/system calls in _o
2239 automatic storage of the results of all alias/system calls in _o
2234 and _e (stdout/err). These provide a .l/.list attribute which
2240 and _e (stdout/err). These provide a .l/.list attribute which
2235 does automatic splitting on newlines. This means that for most
2241 does automatic splitting on newlines. This means that for most
2236 uses, you'll never need to do capturing of output with %sc/%sx
2242 uses, you'll never need to do capturing of output with %sc/%sx
2237 anymore, since ipython keeps this always done for you. Note that
2243 anymore, since ipython keeps this always done for you. Note that
2238 only the LAST results are stored, the _o/e variables are
2244 only the LAST results are stored, the _o/e variables are
2239 overwritten on each call. If you need to save their contents
2245 overwritten on each call. If you need to save their contents
2240 further, simply bind them to any other name.
2246 further, simply bind them to any other name.
2241
2247
2242 2005-03-17 Fernando Perez <fperez@colorado.edu>
2248 2005-03-17 Fernando Perez <fperez@colorado.edu>
2243
2249
2244 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
2250 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
2245 prompt namespace handling.
2251 prompt namespace handling.
2246
2252
2247 2005-03-16 Fernando Perez <fperez@colorado.edu>
2253 2005-03-16 Fernando Perez <fperez@colorado.edu>
2248
2254
2249 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
2255 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
2250 classic prompts to be '>>> ' (final space was missing, and it
2256 classic prompts to be '>>> ' (final space was missing, and it
2251 trips the emacs python mode).
2257 trips the emacs python mode).
2252 (BasePrompt.__str__): Added safe support for dynamic prompt
2258 (BasePrompt.__str__): Added safe support for dynamic prompt
2253 strings. Now you can set your prompt string to be '$x', and the
2259 strings. Now you can set your prompt string to be '$x', and the
2254 value of x will be printed from your interactive namespace. The
2260 value of x will be printed from your interactive namespace. The
2255 interpolation syntax includes the full Itpl support, so
2261 interpolation syntax includes the full Itpl support, so
2256 ${foo()+x+bar()} is a valid prompt string now, and the function
2262 ${foo()+x+bar()} is a valid prompt string now, and the function
2257 calls will be made at runtime.
2263 calls will be made at runtime.
2258
2264
2259 2005-03-15 Fernando Perez <fperez@colorado.edu>
2265 2005-03-15 Fernando Perez <fperez@colorado.edu>
2260
2266
2261 * IPython/Magic.py (magic_history): renamed %hist to %history, to
2267 * IPython/Magic.py (magic_history): renamed %hist to %history, to
2262 avoid name clashes in pylab. %hist still works, it just forwards
2268 avoid name clashes in pylab. %hist still works, it just forwards
2263 the call to %history.
2269 the call to %history.
2264
2270
2265 2005-03-02 *** Released version 0.6.12
2271 2005-03-02 *** Released version 0.6.12
2266
2272
2267 2005-03-02 Fernando Perez <fperez@colorado.edu>
2273 2005-03-02 Fernando Perez <fperez@colorado.edu>
2268
2274
2269 * IPython/iplib.py (handle_magic): log magic calls properly as
2275 * IPython/iplib.py (handle_magic): log magic calls properly as
2270 ipmagic() function calls.
2276 ipmagic() function calls.
2271
2277
2272 * IPython/Magic.py (magic_time): Improved %time to support
2278 * IPython/Magic.py (magic_time): Improved %time to support
2273 statements and provide wall-clock as well as CPU time.
2279 statements and provide wall-clock as well as CPU time.
2274
2280
2275 2005-02-27 Fernando Perez <fperez@colorado.edu>
2281 2005-02-27 Fernando Perez <fperez@colorado.edu>
2276
2282
2277 * IPython/hooks.py: New hooks module, to expose user-modifiable
2283 * IPython/hooks.py: New hooks module, to expose user-modifiable
2278 IPython functionality in a clean manner. For now only the editor
2284 IPython functionality in a clean manner. For now only the editor
2279 hook is actually written, and other thigns which I intend to turn
2285 hook is actually written, and other thigns which I intend to turn
2280 into proper hooks aren't yet there. The display and prefilter
2286 into proper hooks aren't yet there. The display and prefilter
2281 stuff, for example, should be hooks. But at least now the
2287 stuff, for example, should be hooks. But at least now the
2282 framework is in place, and the rest can be moved here with more
2288 framework is in place, and the rest can be moved here with more
2283 time later. IPython had had a .hooks variable for a long time for
2289 time later. IPython had had a .hooks variable for a long time for
2284 this purpose, but I'd never actually used it for anything.
2290 this purpose, but I'd never actually used it for anything.
2285
2291
2286 2005-02-26 Fernando Perez <fperez@colorado.edu>
2292 2005-02-26 Fernando Perez <fperez@colorado.edu>
2287
2293
2288 * IPython/ipmaker.py (make_IPython): make the default ipython
2294 * IPython/ipmaker.py (make_IPython): make the default ipython
2289 directory be called _ipython under win32, to follow more the
2295 directory be called _ipython under win32, to follow more the
2290 naming peculiarities of that platform (where buggy software like
2296 naming peculiarities of that platform (where buggy software like
2291 Visual Sourcesafe breaks with .named directories). Reported by
2297 Visual Sourcesafe breaks with .named directories). Reported by
2292 Ville Vainio.
2298 Ville Vainio.
2293
2299
2294 2005-02-23 Fernando Perez <fperez@colorado.edu>
2300 2005-02-23 Fernando Perez <fperez@colorado.edu>
2295
2301
2296 * IPython/iplib.py (InteractiveShell.__init__): removed a few
2302 * IPython/iplib.py (InteractiveShell.__init__): removed a few
2297 auto_aliases for win32 which were causing problems. Users can
2303 auto_aliases for win32 which were causing problems. Users can
2298 define the ones they personally like.
2304 define the ones they personally like.
2299
2305
2300 2005-02-21 Fernando Perez <fperez@colorado.edu>
2306 2005-02-21 Fernando Perez <fperez@colorado.edu>
2301
2307
2302 * IPython/Magic.py (magic_time): new magic to time execution of
2308 * IPython/Magic.py (magic_time): new magic to time execution of
2303 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
2309 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
2304
2310
2305 2005-02-19 Fernando Perez <fperez@colorado.edu>
2311 2005-02-19 Fernando Perez <fperez@colorado.edu>
2306
2312
2307 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
2313 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
2308 into keys (for prompts, for example).
2314 into keys (for prompts, for example).
2309
2315
2310 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
2316 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
2311 prompts in case users want them. This introduces a small behavior
2317 prompts in case users want them. This introduces a small behavior
2312 change: ipython does not automatically add a space to all prompts
2318 change: ipython does not automatically add a space to all prompts
2313 anymore. To get the old prompts with a space, users should add it
2319 anymore. To get the old prompts with a space, users should add it
2314 manually to their ipythonrc file, so for example prompt_in1 should
2320 manually to their ipythonrc file, so for example prompt_in1 should
2315 now read 'In [\#]: ' instead of 'In [\#]:'.
2321 now read 'In [\#]: ' instead of 'In [\#]:'.
2316 (BasePrompt.__init__): New option prompts_pad_left (only in rc
2322 (BasePrompt.__init__): New option prompts_pad_left (only in rc
2317 file) to control left-padding of secondary prompts.
2323 file) to control left-padding of secondary prompts.
2318
2324
2319 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
2325 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
2320 the profiler can't be imported. Fix for Debian, which removed
2326 the profiler can't be imported. Fix for Debian, which removed
2321 profile.py because of License issues. I applied a slightly
2327 profile.py because of License issues. I applied a slightly
2322 modified version of the original Debian patch at
2328 modified version of the original Debian patch at
2323 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
2329 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
2324
2330
2325 2005-02-17 Fernando Perez <fperez@colorado.edu>
2331 2005-02-17 Fernando Perez <fperez@colorado.edu>
2326
2332
2327 * IPython/genutils.py (native_line_ends): Fix bug which would
2333 * IPython/genutils.py (native_line_ends): Fix bug which would
2328 cause improper line-ends under win32 b/c I was not opening files
2334 cause improper line-ends under win32 b/c I was not opening files
2329 in binary mode. Bug report and fix thanks to Ville.
2335 in binary mode. Bug report and fix thanks to Ville.
2330
2336
2331 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
2337 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
2332 trying to catch spurious foo[1] autocalls. My fix actually broke
2338 trying to catch spurious foo[1] autocalls. My fix actually broke
2333 ',/' autoquote/call with explicit escape (bad regexp).
2339 ',/' autoquote/call with explicit escape (bad regexp).
2334
2340
2335 2005-02-15 *** Released version 0.6.11
2341 2005-02-15 *** Released version 0.6.11
2336
2342
2337 2005-02-14 Fernando Perez <fperez@colorado.edu>
2343 2005-02-14 Fernando Perez <fperez@colorado.edu>
2338
2344
2339 * IPython/background_jobs.py: New background job management
2345 * IPython/background_jobs.py: New background job management
2340 subsystem. This is implemented via a new set of classes, and
2346 subsystem. This is implemented via a new set of classes, and
2341 IPython now provides a builtin 'jobs' object for background job
2347 IPython now provides a builtin 'jobs' object for background job
2342 execution. A convenience %bg magic serves as a lightweight
2348 execution. A convenience %bg magic serves as a lightweight
2343 frontend for starting the more common type of calls. This was
2349 frontend for starting the more common type of calls. This was
2344 inspired by discussions with B. Granger and the BackgroundCommand
2350 inspired by discussions with B. Granger and the BackgroundCommand
2345 class described in the book Python Scripting for Computational
2351 class described in the book Python Scripting for Computational
2346 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
2352 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
2347 (although ultimately no code from this text was used, as IPython's
2353 (although ultimately no code from this text was used, as IPython's
2348 system is a separate implementation).
2354 system is a separate implementation).
2349
2355
2350 * IPython/iplib.py (MagicCompleter.python_matches): add new option
2356 * IPython/iplib.py (MagicCompleter.python_matches): add new option
2351 to control the completion of single/double underscore names
2357 to control the completion of single/double underscore names
2352 separately. As documented in the example ipytonrc file, the
2358 separately. As documented in the example ipytonrc file, the
2353 readline_omit__names variable can now be set to 2, to omit even
2359 readline_omit__names variable can now be set to 2, to omit even
2354 single underscore names. Thanks to a patch by Brian Wong
2360 single underscore names. Thanks to a patch by Brian Wong
2355 <BrianWong-AT-AirgoNetworks.Com>.
2361 <BrianWong-AT-AirgoNetworks.Com>.
2356 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
2362 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
2357 be autocalled as foo([1]) if foo were callable. A problem for
2363 be autocalled as foo([1]) if foo were callable. A problem for
2358 things which are both callable and implement __getitem__.
2364 things which are both callable and implement __getitem__.
2359 (init_readline): Fix autoindentation for win32. Thanks to a patch
2365 (init_readline): Fix autoindentation for win32. Thanks to a patch
2360 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
2366 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
2361
2367
2362 2005-02-12 Fernando Perez <fperez@colorado.edu>
2368 2005-02-12 Fernando Perez <fperez@colorado.edu>
2363
2369
2364 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
2370 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
2365 which I had written long ago to sort out user error messages which
2371 which I had written long ago to sort out user error messages which
2366 may occur during startup. This seemed like a good idea initially,
2372 may occur during startup. This seemed like a good idea initially,
2367 but it has proven a disaster in retrospect. I don't want to
2373 but it has proven a disaster in retrospect. I don't want to
2368 change much code for now, so my fix is to set the internal 'debug'
2374 change much code for now, so my fix is to set the internal 'debug'
2369 flag to true everywhere, whose only job was precisely to control
2375 flag to true everywhere, whose only job was precisely to control
2370 this subsystem. This closes issue 28 (as well as avoiding all
2376 this subsystem. This closes issue 28 (as well as avoiding all
2371 sorts of strange hangups which occur from time to time).
2377 sorts of strange hangups which occur from time to time).
2372
2378
2373 2005-02-07 Fernando Perez <fperez@colorado.edu>
2379 2005-02-07 Fernando Perez <fperez@colorado.edu>
2374
2380
2375 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
2381 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
2376 previous call produced a syntax error.
2382 previous call produced a syntax error.
2377
2383
2378 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
2384 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
2379 classes without constructor.
2385 classes without constructor.
2380
2386
2381 2005-02-06 Fernando Perez <fperez@colorado.edu>
2387 2005-02-06 Fernando Perez <fperez@colorado.edu>
2382
2388
2383 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
2389 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
2384 completions with the results of each matcher, so we return results
2390 completions with the results of each matcher, so we return results
2385 to the user from all namespaces. This breaks with ipython
2391 to the user from all namespaces. This breaks with ipython
2386 tradition, but I think it's a nicer behavior. Now you get all
2392 tradition, but I think it's a nicer behavior. Now you get all
2387 possible completions listed, from all possible namespaces (python,
2393 possible completions listed, from all possible namespaces (python,
2388 filesystem, magics...) After a request by John Hunter
2394 filesystem, magics...) After a request by John Hunter
2389 <jdhunter-AT-nitace.bsd.uchicago.edu>.
2395 <jdhunter-AT-nitace.bsd.uchicago.edu>.
2390
2396
2391 2005-02-05 Fernando Perez <fperez@colorado.edu>
2397 2005-02-05 Fernando Perez <fperez@colorado.edu>
2392
2398
2393 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
2399 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
2394 the call had quote characters in it (the quotes were stripped).
2400 the call had quote characters in it (the quotes were stripped).
2395
2401
2396 2005-01-31 Fernando Perez <fperez@colorado.edu>
2402 2005-01-31 Fernando Perez <fperez@colorado.edu>
2397
2403
2398 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
2404 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
2399 Itpl.itpl() to make the code more robust against psyco
2405 Itpl.itpl() to make the code more robust against psyco
2400 optimizations.
2406 optimizations.
2401
2407
2402 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
2408 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
2403 of causing an exception. Quicker, cleaner.
2409 of causing an exception. Quicker, cleaner.
2404
2410
2405 2005-01-28 Fernando Perez <fperez@colorado.edu>
2411 2005-01-28 Fernando Perez <fperez@colorado.edu>
2406
2412
2407 * scripts/ipython_win_post_install.py (install): hardcode
2413 * scripts/ipython_win_post_install.py (install): hardcode
2408 sys.prefix+'python.exe' as the executable path. It turns out that
2414 sys.prefix+'python.exe' as the executable path. It turns out that
2409 during the post-installation run, sys.executable resolves to the
2415 during the post-installation run, sys.executable resolves to the
2410 name of the binary installer! I should report this as a distutils
2416 name of the binary installer! I should report this as a distutils
2411 bug, I think. I updated the .10 release with this tiny fix, to
2417 bug, I think. I updated the .10 release with this tiny fix, to
2412 avoid annoying the lists further.
2418 avoid annoying the lists further.
2413
2419
2414 2005-01-27 *** Released version 0.6.10
2420 2005-01-27 *** Released version 0.6.10
2415
2421
2416 2005-01-27 Fernando Perez <fperez@colorado.edu>
2422 2005-01-27 Fernando Perez <fperez@colorado.edu>
2417
2423
2418 * IPython/numutils.py (norm): Added 'inf' as optional name for
2424 * IPython/numutils.py (norm): Added 'inf' as optional name for
2419 L-infinity norm, included references to mathworld.com for vector
2425 L-infinity norm, included references to mathworld.com for vector
2420 norm definitions.
2426 norm definitions.
2421 (amin/amax): added amin/amax for array min/max. Similar to what
2427 (amin/amax): added amin/amax for array min/max. Similar to what
2422 pylab ships with after the recent reorganization of names.
2428 pylab ships with after the recent reorganization of names.
2423 (spike/spike_odd): removed deprecated spike/spike_odd functions.
2429 (spike/spike_odd): removed deprecated spike/spike_odd functions.
2424
2430
2425 * ipython.el: committed Alex's recent fixes and improvements.
2431 * ipython.el: committed Alex's recent fixes and improvements.
2426 Tested with python-mode from CVS, and it looks excellent. Since
2432 Tested with python-mode from CVS, and it looks excellent. Since
2427 python-mode hasn't released anything in a while, I'm temporarily
2433 python-mode hasn't released anything in a while, I'm temporarily
2428 putting a copy of today's CVS (v 4.70) of python-mode in:
2434 putting a copy of today's CVS (v 4.70) of python-mode in:
2429 http://ipython.scipy.org/tmp/python-mode.el
2435 http://ipython.scipy.org/tmp/python-mode.el
2430
2436
2431 * scripts/ipython_win_post_install.py (install): Win32 fix to use
2437 * scripts/ipython_win_post_install.py (install): Win32 fix to use
2432 sys.executable for the executable name, instead of assuming it's
2438 sys.executable for the executable name, instead of assuming it's
2433 called 'python.exe' (the post-installer would have produced broken
2439 called 'python.exe' (the post-installer would have produced broken
2434 setups on systems with a differently named python binary).
2440 setups on systems with a differently named python binary).
2435
2441
2436 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
2442 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
2437 references to os.linesep, to make the code more
2443 references to os.linesep, to make the code more
2438 platform-independent. This is also part of the win32 coloring
2444 platform-independent. This is also part of the win32 coloring
2439 fixes.
2445 fixes.
2440
2446
2441 * IPython/genutils.py (page_dumb): Remove attempts to chop long
2447 * IPython/genutils.py (page_dumb): Remove attempts to chop long
2442 lines, which actually cause coloring bugs because the length of
2448 lines, which actually cause coloring bugs because the length of
2443 the line is very difficult to correctly compute with embedded
2449 the line is very difficult to correctly compute with embedded
2444 escapes. This was the source of all the coloring problems under
2450 escapes. This was the source of all the coloring problems under
2445 Win32. I think that _finally_, Win32 users have a properly
2451 Win32. I think that _finally_, Win32 users have a properly
2446 working ipython in all respects. This would never have happened
2452 working ipython in all respects. This would never have happened
2447 if not for Gary Bishop and Viktor Ransmayr's great help and work.
2453 if not for Gary Bishop and Viktor Ransmayr's great help and work.
2448
2454
2449 2005-01-26 *** Released version 0.6.9
2455 2005-01-26 *** Released version 0.6.9
2450
2456
2451 2005-01-25 Fernando Perez <fperez@colorado.edu>
2457 2005-01-25 Fernando Perez <fperez@colorado.edu>
2452
2458
2453 * setup.py: finally, we have a true Windows installer, thanks to
2459 * setup.py: finally, we have a true Windows installer, thanks to
2454 the excellent work of Viktor Ransmayr
2460 the excellent work of Viktor Ransmayr
2455 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
2461 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
2456 Windows users. The setup routine is quite a bit cleaner thanks to
2462 Windows users. The setup routine is quite a bit cleaner thanks to
2457 this, and the post-install script uses the proper functions to
2463 this, and the post-install script uses the proper functions to
2458 allow a clean de-installation using the standard Windows Control
2464 allow a clean de-installation using the standard Windows Control
2459 Panel.
2465 Panel.
2460
2466
2461 * IPython/genutils.py (get_home_dir): changed to use the $HOME
2467 * IPython/genutils.py (get_home_dir): changed to use the $HOME
2462 environment variable under all OSes (including win32) if
2468 environment variable under all OSes (including win32) if
2463 available. This will give consistency to win32 users who have set
2469 available. This will give consistency to win32 users who have set
2464 this variable for any reason. If os.environ['HOME'] fails, the
2470 this variable for any reason. If os.environ['HOME'] fails, the
2465 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
2471 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
2466
2472
2467 2005-01-24 Fernando Perez <fperez@colorado.edu>
2473 2005-01-24 Fernando Perez <fperez@colorado.edu>
2468
2474
2469 * IPython/numutils.py (empty_like): add empty_like(), similar to
2475 * IPython/numutils.py (empty_like): add empty_like(), similar to
2470 zeros_like() but taking advantage of the new empty() Numeric routine.
2476 zeros_like() but taking advantage of the new empty() Numeric routine.
2471
2477
2472 2005-01-23 *** Released version 0.6.8
2478 2005-01-23 *** Released version 0.6.8
2473
2479
2474 2005-01-22 Fernando Perez <fperez@colorado.edu>
2480 2005-01-22 Fernando Perez <fperez@colorado.edu>
2475
2481
2476 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
2482 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
2477 automatic show() calls. After discussing things with JDH, it
2483 automatic show() calls. After discussing things with JDH, it
2478 turns out there are too many corner cases where this can go wrong.
2484 turns out there are too many corner cases where this can go wrong.
2479 It's best not to try to be 'too smart', and simply have ipython
2485 It's best not to try to be 'too smart', and simply have ipython
2480 reproduce as much as possible the default behavior of a normal
2486 reproduce as much as possible the default behavior of a normal
2481 python shell.
2487 python shell.
2482
2488
2483 * IPython/iplib.py (InteractiveShell.__init__): Modified the
2489 * IPython/iplib.py (InteractiveShell.__init__): Modified the
2484 line-splitting regexp and _prefilter() to avoid calling getattr()
2490 line-splitting regexp and _prefilter() to avoid calling getattr()
2485 on assignments. This closes
2491 on assignments. This closes
2486 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
2492 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
2487 readline uses getattr(), so a simple <TAB> keypress is still
2493 readline uses getattr(), so a simple <TAB> keypress is still
2488 enough to trigger getattr() calls on an object.
2494 enough to trigger getattr() calls on an object.
2489
2495
2490 2005-01-21 Fernando Perez <fperez@colorado.edu>
2496 2005-01-21 Fernando Perez <fperez@colorado.edu>
2491
2497
2492 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
2498 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
2493 docstring under pylab so it doesn't mask the original.
2499 docstring under pylab so it doesn't mask the original.
2494
2500
2495 2005-01-21 *** Released version 0.6.7
2501 2005-01-21 *** Released version 0.6.7
2496
2502
2497 2005-01-21 Fernando Perez <fperez@colorado.edu>
2503 2005-01-21 Fernando Perez <fperez@colorado.edu>
2498
2504
2499 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
2505 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
2500 signal handling for win32 users in multithreaded mode.
2506 signal handling for win32 users in multithreaded mode.
2501
2507
2502 2005-01-17 Fernando Perez <fperez@colorado.edu>
2508 2005-01-17 Fernando Perez <fperez@colorado.edu>
2503
2509
2504 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
2510 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
2505 instances with no __init__. After a crash report by Norbert Nemec
2511 instances with no __init__. After a crash report by Norbert Nemec
2506 <Norbert-AT-nemec-online.de>.
2512 <Norbert-AT-nemec-online.de>.
2507
2513
2508 2005-01-14 Fernando Perez <fperez@colorado.edu>
2514 2005-01-14 Fernando Perez <fperez@colorado.edu>
2509
2515
2510 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
2516 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
2511 names for verbose exceptions, when multiple dotted names and the
2517 names for verbose exceptions, when multiple dotted names and the
2512 'parent' object were present on the same line.
2518 'parent' object were present on the same line.
2513
2519
2514 2005-01-11 Fernando Perez <fperez@colorado.edu>
2520 2005-01-11 Fernando Perez <fperez@colorado.edu>
2515
2521
2516 * IPython/genutils.py (flag_calls): new utility to trap and flag
2522 * IPython/genutils.py (flag_calls): new utility to trap and flag
2517 calls in functions. I need it to clean up matplotlib support.
2523 calls in functions. I need it to clean up matplotlib support.
2518 Also removed some deprecated code in genutils.
2524 Also removed some deprecated code in genutils.
2519
2525
2520 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
2526 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
2521 that matplotlib scripts called with %run, which don't call show()
2527 that matplotlib scripts called with %run, which don't call show()
2522 themselves, still have their plotting windows open.
2528 themselves, still have their plotting windows open.
2523
2529
2524 2005-01-05 Fernando Perez <fperez@colorado.edu>
2530 2005-01-05 Fernando Perez <fperez@colorado.edu>
2525
2531
2526 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
2532 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
2527 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
2533 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
2528
2534
2529 2004-12-19 Fernando Perez <fperez@colorado.edu>
2535 2004-12-19 Fernando Perez <fperez@colorado.edu>
2530
2536
2531 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
2537 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
2532 parent_runcode, which was an eyesore. The same result can be
2538 parent_runcode, which was an eyesore. The same result can be
2533 obtained with Python's regular superclass mechanisms.
2539 obtained with Python's regular superclass mechanisms.
2534
2540
2535 2004-12-17 Fernando Perez <fperez@colorado.edu>
2541 2004-12-17 Fernando Perez <fperez@colorado.edu>
2536
2542
2537 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
2543 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
2538 reported by Prabhu.
2544 reported by Prabhu.
2539 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
2545 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
2540 sys.stderr) instead of explicitly calling sys.stderr. This helps
2546 sys.stderr) instead of explicitly calling sys.stderr. This helps
2541 maintain our I/O abstractions clean, for future GUI embeddings.
2547 maintain our I/O abstractions clean, for future GUI embeddings.
2542
2548
2543 * IPython/genutils.py (info): added new utility for sys.stderr
2549 * IPython/genutils.py (info): added new utility for sys.stderr
2544 unified info message handling (thin wrapper around warn()).
2550 unified info message handling (thin wrapper around warn()).
2545
2551
2546 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
2552 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
2547 composite (dotted) names on verbose exceptions.
2553 composite (dotted) names on verbose exceptions.
2548 (VerboseTB.nullrepr): harden against another kind of errors which
2554 (VerboseTB.nullrepr): harden against another kind of errors which
2549 Python's inspect module can trigger, and which were crashing
2555 Python's inspect module can trigger, and which were crashing
2550 IPython. Thanks to a report by Marco Lombardi
2556 IPython. Thanks to a report by Marco Lombardi
2551 <mlombard-AT-ma010192.hq.eso.org>.
2557 <mlombard-AT-ma010192.hq.eso.org>.
2552
2558
2553 2004-12-13 *** Released version 0.6.6
2559 2004-12-13 *** Released version 0.6.6
2554
2560
2555 2004-12-12 Fernando Perez <fperez@colorado.edu>
2561 2004-12-12 Fernando Perez <fperez@colorado.edu>
2556
2562
2557 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
2563 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
2558 generated by pygtk upon initialization if it was built without
2564 generated by pygtk upon initialization if it was built without
2559 threads (for matplotlib users). After a crash reported by
2565 threads (for matplotlib users). After a crash reported by
2560 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
2566 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
2561
2567
2562 * IPython/ipmaker.py (make_IPython): fix small bug in the
2568 * IPython/ipmaker.py (make_IPython): fix small bug in the
2563 import_some parameter for multiple imports.
2569 import_some parameter for multiple imports.
2564
2570
2565 * IPython/iplib.py (ipmagic): simplified the interface of
2571 * IPython/iplib.py (ipmagic): simplified the interface of
2566 ipmagic() to take a single string argument, just as it would be
2572 ipmagic() to take a single string argument, just as it would be
2567 typed at the IPython cmd line.
2573 typed at the IPython cmd line.
2568 (ipalias): Added new ipalias() with an interface identical to
2574 (ipalias): Added new ipalias() with an interface identical to
2569 ipmagic(). This completes exposing a pure python interface to the
2575 ipmagic(). This completes exposing a pure python interface to the
2570 alias and magic system, which can be used in loops or more complex
2576 alias and magic system, which can be used in loops or more complex
2571 code where IPython's automatic line mangling is not active.
2577 code where IPython's automatic line mangling is not active.
2572
2578
2573 * IPython/genutils.py (timing): changed interface of timing to
2579 * IPython/genutils.py (timing): changed interface of timing to
2574 simply run code once, which is the most common case. timings()
2580 simply run code once, which is the most common case. timings()
2575 remains unchanged, for the cases where you want multiple runs.
2581 remains unchanged, for the cases where you want multiple runs.
2576
2582
2577 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
2583 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
2578 bug where Python2.2 crashes with exec'ing code which does not end
2584 bug where Python2.2 crashes with exec'ing code which does not end
2579 in a single newline. Python 2.3 is OK, so I hadn't noticed this
2585 in a single newline. Python 2.3 is OK, so I hadn't noticed this
2580 before.
2586 before.
2581
2587
2582 2004-12-10 Fernando Perez <fperez@colorado.edu>
2588 2004-12-10 Fernando Perez <fperez@colorado.edu>
2583
2589
2584 * IPython/Magic.py (Magic.magic_prun): changed name of option from
2590 * IPython/Magic.py (Magic.magic_prun): changed name of option from
2585 -t to -T, to accomodate the new -t flag in %run (the %run and
2591 -t to -T, to accomodate the new -t flag in %run (the %run and
2586 %prun options are kind of intermixed, and it's not easy to change
2592 %prun options are kind of intermixed, and it's not easy to change
2587 this with the limitations of python's getopt).
2593 this with the limitations of python's getopt).
2588
2594
2589 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
2595 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
2590 the execution of scripts. It's not as fine-tuned as timeit.py,
2596 the execution of scripts. It's not as fine-tuned as timeit.py,
2591 but it works from inside ipython (and under 2.2, which lacks
2597 but it works from inside ipython (and under 2.2, which lacks
2592 timeit.py). Optionally a number of runs > 1 can be given for
2598 timeit.py). Optionally a number of runs > 1 can be given for
2593 timing very short-running code.
2599 timing very short-running code.
2594
2600
2595 * IPython/genutils.py (uniq_stable): new routine which returns a
2601 * IPython/genutils.py (uniq_stable): new routine which returns a
2596 list of unique elements in any iterable, but in stable order of
2602 list of unique elements in any iterable, but in stable order of
2597 appearance. I needed this for the ultraTB fixes, and it's a handy
2603 appearance. I needed this for the ultraTB fixes, and it's a handy
2598 utility.
2604 utility.
2599
2605
2600 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
2606 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
2601 dotted names in Verbose exceptions. This had been broken since
2607 dotted names in Verbose exceptions. This had been broken since
2602 the very start, now x.y will properly be printed in a Verbose
2608 the very start, now x.y will properly be printed in a Verbose
2603 traceback, instead of x being shown and y appearing always as an
2609 traceback, instead of x being shown and y appearing always as an
2604 'undefined global'. Getting this to work was a bit tricky,
2610 'undefined global'. Getting this to work was a bit tricky,
2605 because by default python tokenizers are stateless. Saved by
2611 because by default python tokenizers are stateless. Saved by
2606 python's ability to easily add a bit of state to an arbitrary
2612 python's ability to easily add a bit of state to an arbitrary
2607 function (without needing to build a full-blown callable object).
2613 function (without needing to build a full-blown callable object).
2608
2614
2609 Also big cleanup of this code, which had horrendous runtime
2615 Also big cleanup of this code, which had horrendous runtime
2610 lookups of zillions of attributes for colorization. Moved all
2616 lookups of zillions of attributes for colorization. Moved all
2611 this code into a few templates, which make it cleaner and quicker.
2617 this code into a few templates, which make it cleaner and quicker.
2612
2618
2613 Printout quality was also improved for Verbose exceptions: one
2619 Printout quality was also improved for Verbose exceptions: one
2614 variable per line, and memory addresses are printed (this can be
2620 variable per line, and memory addresses are printed (this can be
2615 quite handy in nasty debugging situations, which is what Verbose
2621 quite handy in nasty debugging situations, which is what Verbose
2616 is for).
2622 is for).
2617
2623
2618 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
2624 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
2619 the command line as scripts to be loaded by embedded instances.
2625 the command line as scripts to be loaded by embedded instances.
2620 Doing so has the potential for an infinite recursion if there are
2626 Doing so has the potential for an infinite recursion if there are
2621 exceptions thrown in the process. This fixes a strange crash
2627 exceptions thrown in the process. This fixes a strange crash
2622 reported by Philippe MULLER <muller-AT-irit.fr>.
2628 reported by Philippe MULLER <muller-AT-irit.fr>.
2623
2629
2624 2004-12-09 Fernando Perez <fperez@colorado.edu>
2630 2004-12-09 Fernando Perez <fperez@colorado.edu>
2625
2631
2626 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
2632 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
2627 to reflect new names in matplotlib, which now expose the
2633 to reflect new names in matplotlib, which now expose the
2628 matlab-compatible interface via a pylab module instead of the
2634 matlab-compatible interface via a pylab module instead of the
2629 'matlab' name. The new code is backwards compatible, so users of
2635 'matlab' name. The new code is backwards compatible, so users of
2630 all matplotlib versions are OK. Patch by J. Hunter.
2636 all matplotlib versions are OK. Patch by J. Hunter.
2631
2637
2632 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
2638 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
2633 of __init__ docstrings for instances (class docstrings are already
2639 of __init__ docstrings for instances (class docstrings are already
2634 automatically printed). Instances with customized docstrings
2640 automatically printed). Instances with customized docstrings
2635 (indep. of the class) are also recognized and all 3 separate
2641 (indep. of the class) are also recognized and all 3 separate
2636 docstrings are printed (instance, class, constructor). After some
2642 docstrings are printed (instance, class, constructor). After some
2637 comments/suggestions by J. Hunter.
2643 comments/suggestions by J. Hunter.
2638
2644
2639 2004-12-05 Fernando Perez <fperez@colorado.edu>
2645 2004-12-05 Fernando Perez <fperez@colorado.edu>
2640
2646
2641 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
2647 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
2642 warnings when tab-completion fails and triggers an exception.
2648 warnings when tab-completion fails and triggers an exception.
2643
2649
2644 2004-12-03 Fernando Perez <fperez@colorado.edu>
2650 2004-12-03 Fernando Perez <fperez@colorado.edu>
2645
2651
2646 * IPython/Magic.py (magic_prun): Fix bug where an exception would
2652 * IPython/Magic.py (magic_prun): Fix bug where an exception would
2647 be triggered when using 'run -p'. An incorrect option flag was
2653 be triggered when using 'run -p'. An incorrect option flag was
2648 being set ('d' instead of 'D').
2654 being set ('d' instead of 'D').
2649 (manpage): fix missing escaped \- sign.
2655 (manpage): fix missing escaped \- sign.
2650
2656
2651 2004-11-30 *** Released version 0.6.5
2657 2004-11-30 *** Released version 0.6.5
2652
2658
2653 2004-11-30 Fernando Perez <fperez@colorado.edu>
2659 2004-11-30 Fernando Perez <fperez@colorado.edu>
2654
2660
2655 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
2661 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
2656 setting with -d option.
2662 setting with -d option.
2657
2663
2658 * setup.py (docfiles): Fix problem where the doc glob I was using
2664 * setup.py (docfiles): Fix problem where the doc glob I was using
2659 was COMPLETELY BROKEN. It was giving the right files by pure
2665 was COMPLETELY BROKEN. It was giving the right files by pure
2660 accident, but failed once I tried to include ipython.el. Note:
2666 accident, but failed once I tried to include ipython.el. Note:
2661 glob() does NOT allow you to do exclusion on multiple endings!
2667 glob() does NOT allow you to do exclusion on multiple endings!
2662
2668
2663 2004-11-29 Fernando Perez <fperez@colorado.edu>
2669 2004-11-29 Fernando Perez <fperez@colorado.edu>
2664
2670
2665 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
2671 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
2666 the manpage as the source. Better formatting & consistency.
2672 the manpage as the source. Better formatting & consistency.
2667
2673
2668 * IPython/Magic.py (magic_run): Added new -d option, to run
2674 * IPython/Magic.py (magic_run): Added new -d option, to run
2669 scripts under the control of the python pdb debugger. Note that
2675 scripts under the control of the python pdb debugger. Note that
2670 this required changing the %prun option -d to -D, to avoid a clash
2676 this required changing the %prun option -d to -D, to avoid a clash
2671 (since %run must pass options to %prun, and getopt is too dumb to
2677 (since %run must pass options to %prun, and getopt is too dumb to
2672 handle options with string values with embedded spaces). Thanks
2678 handle options with string values with embedded spaces). Thanks
2673 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
2679 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
2674 (magic_who_ls): added type matching to %who and %whos, so that one
2680 (magic_who_ls): added type matching to %who and %whos, so that one
2675 can filter their output to only include variables of certain
2681 can filter their output to only include variables of certain
2676 types. Another suggestion by Matthew.
2682 types. Another suggestion by Matthew.
2677 (magic_whos): Added memory summaries in kb and Mb for arrays.
2683 (magic_whos): Added memory summaries in kb and Mb for arrays.
2678 (magic_who): Improve formatting (break lines every 9 vars).
2684 (magic_who): Improve formatting (break lines every 9 vars).
2679
2685
2680 2004-11-28 Fernando Perez <fperez@colorado.edu>
2686 2004-11-28 Fernando Perez <fperez@colorado.edu>
2681
2687
2682 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
2688 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
2683 cache when empty lines were present.
2689 cache when empty lines were present.
2684
2690
2685 2004-11-24 Fernando Perez <fperez@colorado.edu>
2691 2004-11-24 Fernando Perez <fperez@colorado.edu>
2686
2692
2687 * IPython/usage.py (__doc__): document the re-activated threading
2693 * IPython/usage.py (__doc__): document the re-activated threading
2688 options for WX and GTK.
2694 options for WX and GTK.
2689
2695
2690 2004-11-23 Fernando Perez <fperez@colorado.edu>
2696 2004-11-23 Fernando Perez <fperez@colorado.edu>
2691
2697
2692 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
2698 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
2693 the -wthread and -gthread options, along with a new -tk one to try
2699 the -wthread and -gthread options, along with a new -tk one to try
2694 and coordinate Tk threading with wx/gtk. The tk support is very
2700 and coordinate Tk threading with wx/gtk. The tk support is very
2695 platform dependent, since it seems to require Tcl and Tk to be
2701 platform dependent, since it seems to require Tcl and Tk to be
2696 built with threads (Fedora1/2 appears NOT to have it, but in
2702 built with threads (Fedora1/2 appears NOT to have it, but in
2697 Prabhu's Debian boxes it works OK). But even with some Tk
2703 Prabhu's Debian boxes it works OK). But even with some Tk
2698 limitations, this is a great improvement.
2704 limitations, this is a great improvement.
2699
2705
2700 * IPython/Prompts.py (prompt_specials_color): Added \t for time
2706 * IPython/Prompts.py (prompt_specials_color): Added \t for time
2701 info in user prompts. Patch by Prabhu.
2707 info in user prompts. Patch by Prabhu.
2702
2708
2703 2004-11-18 Fernando Perez <fperez@colorado.edu>
2709 2004-11-18 Fernando Perez <fperez@colorado.edu>
2704
2710
2705 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
2711 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
2706 EOFErrors and bail, to avoid infinite loops if a non-terminating
2712 EOFErrors and bail, to avoid infinite loops if a non-terminating
2707 file is fed into ipython. Patch submitted in issue 19 by user,
2713 file is fed into ipython. Patch submitted in issue 19 by user,
2708 many thanks.
2714 many thanks.
2709
2715
2710 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
2716 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
2711 autoquote/parens in continuation prompts, which can cause lots of
2717 autoquote/parens in continuation prompts, which can cause lots of
2712 problems. Closes roundup issue 20.
2718 problems. Closes roundup issue 20.
2713
2719
2714 2004-11-17 Fernando Perez <fperez@colorado.edu>
2720 2004-11-17 Fernando Perez <fperez@colorado.edu>
2715
2721
2716 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
2722 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
2717 reported as debian bug #280505. I'm not sure my local changelog
2723 reported as debian bug #280505. I'm not sure my local changelog
2718 entry has the proper debian format (Jack?).
2724 entry has the proper debian format (Jack?).
2719
2725
2720 2004-11-08 *** Released version 0.6.4
2726 2004-11-08 *** Released version 0.6.4
2721
2727
2722 2004-11-08 Fernando Perez <fperez@colorado.edu>
2728 2004-11-08 Fernando Perez <fperez@colorado.edu>
2723
2729
2724 * IPython/iplib.py (init_readline): Fix exit message for Windows
2730 * IPython/iplib.py (init_readline): Fix exit message for Windows
2725 when readline is active. Thanks to a report by Eric Jones
2731 when readline is active. Thanks to a report by Eric Jones
2726 <eric-AT-enthought.com>.
2732 <eric-AT-enthought.com>.
2727
2733
2728 2004-11-07 Fernando Perez <fperez@colorado.edu>
2734 2004-11-07 Fernando Perez <fperez@colorado.edu>
2729
2735
2730 * IPython/genutils.py (page): Add a trap for OSError exceptions,
2736 * IPython/genutils.py (page): Add a trap for OSError exceptions,
2731 sometimes seen by win2k/cygwin users.
2737 sometimes seen by win2k/cygwin users.
2732
2738
2733 2004-11-06 Fernando Perez <fperez@colorado.edu>
2739 2004-11-06 Fernando Perez <fperez@colorado.edu>
2734
2740
2735 * IPython/iplib.py (interact): Change the handling of %Exit from
2741 * IPython/iplib.py (interact): Change the handling of %Exit from
2736 trying to propagate a SystemExit to an internal ipython flag.
2742 trying to propagate a SystemExit to an internal ipython flag.
2737 This is less elegant than using Python's exception mechanism, but
2743 This is less elegant than using Python's exception mechanism, but
2738 I can't get that to work reliably with threads, so under -pylab
2744 I can't get that to work reliably with threads, so under -pylab
2739 %Exit was hanging IPython. Cross-thread exception handling is
2745 %Exit was hanging IPython. Cross-thread exception handling is
2740 really a bitch. Thaks to a bug report by Stephen Walton
2746 really a bitch. Thaks to a bug report by Stephen Walton
2741 <stephen.walton-AT-csun.edu>.
2747 <stephen.walton-AT-csun.edu>.
2742
2748
2743 2004-11-04 Fernando Perez <fperez@colorado.edu>
2749 2004-11-04 Fernando Perez <fperez@colorado.edu>
2744
2750
2745 * IPython/iplib.py (raw_input_original): store a pointer to the
2751 * IPython/iplib.py (raw_input_original): store a pointer to the
2746 true raw_input to harden against code which can modify it
2752 true raw_input to harden against code which can modify it
2747 (wx.py.PyShell does this and would otherwise crash ipython).
2753 (wx.py.PyShell does this and would otherwise crash ipython).
2748 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
2754 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
2749
2755
2750 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
2756 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
2751 Ctrl-C problem, which does not mess up the input line.
2757 Ctrl-C problem, which does not mess up the input line.
2752
2758
2753 2004-11-03 Fernando Perez <fperez@colorado.edu>
2759 2004-11-03 Fernando Perez <fperez@colorado.edu>
2754
2760
2755 * IPython/Release.py: Changed licensing to BSD, in all files.
2761 * IPython/Release.py: Changed licensing to BSD, in all files.
2756 (name): lowercase name for tarball/RPM release.
2762 (name): lowercase name for tarball/RPM release.
2757
2763
2758 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
2764 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
2759 use throughout ipython.
2765 use throughout ipython.
2760
2766
2761 * IPython/Magic.py (Magic._ofind): Switch to using the new
2767 * IPython/Magic.py (Magic._ofind): Switch to using the new
2762 OInspect.getdoc() function.
2768 OInspect.getdoc() function.
2763
2769
2764 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
2770 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
2765 of the line currently being canceled via Ctrl-C. It's extremely
2771 of the line currently being canceled via Ctrl-C. It's extremely
2766 ugly, but I don't know how to do it better (the problem is one of
2772 ugly, but I don't know how to do it better (the problem is one of
2767 handling cross-thread exceptions).
2773 handling cross-thread exceptions).
2768
2774
2769 2004-10-28 Fernando Perez <fperez@colorado.edu>
2775 2004-10-28 Fernando Perez <fperez@colorado.edu>
2770
2776
2771 * IPython/Shell.py (signal_handler): add signal handlers to trap
2777 * IPython/Shell.py (signal_handler): add signal handlers to trap
2772 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
2778 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
2773 report by Francesc Alted.
2779 report by Francesc Alted.
2774
2780
2775 2004-10-21 Fernando Perez <fperez@colorado.edu>
2781 2004-10-21 Fernando Perez <fperez@colorado.edu>
2776
2782
2777 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
2783 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
2778 to % for pysh syntax extensions.
2784 to % for pysh syntax extensions.
2779
2785
2780 2004-10-09 Fernando Perez <fperez@colorado.edu>
2786 2004-10-09 Fernando Perez <fperez@colorado.edu>
2781
2787
2782 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
2788 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
2783 arrays to print a more useful summary, without calling str(arr).
2789 arrays to print a more useful summary, without calling str(arr).
2784 This avoids the problem of extremely lengthy computations which
2790 This avoids the problem of extremely lengthy computations which
2785 occur if arr is large, and appear to the user as a system lockup
2791 occur if arr is large, and appear to the user as a system lockup
2786 with 100% cpu activity. After a suggestion by Kristian Sandberg
2792 with 100% cpu activity. After a suggestion by Kristian Sandberg
2787 <Kristian.Sandberg@colorado.edu>.
2793 <Kristian.Sandberg@colorado.edu>.
2788 (Magic.__init__): fix bug in global magic escapes not being
2794 (Magic.__init__): fix bug in global magic escapes not being
2789 correctly set.
2795 correctly set.
2790
2796
2791 2004-10-08 Fernando Perez <fperez@colorado.edu>
2797 2004-10-08 Fernando Perez <fperez@colorado.edu>
2792
2798
2793 * IPython/Magic.py (__license__): change to absolute imports of
2799 * IPython/Magic.py (__license__): change to absolute imports of
2794 ipython's own internal packages, to start adapting to the absolute
2800 ipython's own internal packages, to start adapting to the absolute
2795 import requirement of PEP-328.
2801 import requirement of PEP-328.
2796
2802
2797 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
2803 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
2798 files, and standardize author/license marks through the Release
2804 files, and standardize author/license marks through the Release
2799 module instead of having per/file stuff (except for files with
2805 module instead of having per/file stuff (except for files with
2800 particular licenses, like the MIT/PSF-licensed codes).
2806 particular licenses, like the MIT/PSF-licensed codes).
2801
2807
2802 * IPython/Debugger.py: remove dead code for python 2.1
2808 * IPython/Debugger.py: remove dead code for python 2.1
2803
2809
2804 2004-10-04 Fernando Perez <fperez@colorado.edu>
2810 2004-10-04 Fernando Perez <fperez@colorado.edu>
2805
2811
2806 * IPython/iplib.py (ipmagic): New function for accessing magics
2812 * IPython/iplib.py (ipmagic): New function for accessing magics
2807 via a normal python function call.
2813 via a normal python function call.
2808
2814
2809 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
2815 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
2810 from '@' to '%', to accomodate the new @decorator syntax of python
2816 from '@' to '%', to accomodate the new @decorator syntax of python
2811 2.4.
2817 2.4.
2812
2818
2813 2004-09-29 Fernando Perez <fperez@colorado.edu>
2819 2004-09-29 Fernando Perez <fperez@colorado.edu>
2814
2820
2815 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
2821 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
2816 matplotlib.use to prevent running scripts which try to switch
2822 matplotlib.use to prevent running scripts which try to switch
2817 interactive backends from within ipython. This will just crash
2823 interactive backends from within ipython. This will just crash
2818 the python interpreter, so we can't allow it (but a detailed error
2824 the python interpreter, so we can't allow it (but a detailed error
2819 is given to the user).
2825 is given to the user).
2820
2826
2821 2004-09-28 Fernando Perez <fperez@colorado.edu>
2827 2004-09-28 Fernando Perez <fperez@colorado.edu>
2822
2828
2823 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
2829 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
2824 matplotlib-related fixes so that using @run with non-matplotlib
2830 matplotlib-related fixes so that using @run with non-matplotlib
2825 scripts doesn't pop up spurious plot windows. This requires
2831 scripts doesn't pop up spurious plot windows. This requires
2826 matplotlib >= 0.63, where I had to make some changes as well.
2832 matplotlib >= 0.63, where I had to make some changes as well.
2827
2833
2828 * IPython/ipmaker.py (make_IPython): update version requirement to
2834 * IPython/ipmaker.py (make_IPython): update version requirement to
2829 python 2.2.
2835 python 2.2.
2830
2836
2831 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
2837 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
2832 banner arg for embedded customization.
2838 banner arg for embedded customization.
2833
2839
2834 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
2840 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
2835 explicit uses of __IP as the IPython's instance name. Now things
2841 explicit uses of __IP as the IPython's instance name. Now things
2836 are properly handled via the shell.name value. The actual code
2842 are properly handled via the shell.name value. The actual code
2837 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
2843 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
2838 is much better than before. I'll clean things completely when the
2844 is much better than before. I'll clean things completely when the
2839 magic stuff gets a real overhaul.
2845 magic stuff gets a real overhaul.
2840
2846
2841 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
2847 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
2842 minor changes to debian dir.
2848 minor changes to debian dir.
2843
2849
2844 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
2850 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
2845 pointer to the shell itself in the interactive namespace even when
2851 pointer to the shell itself in the interactive namespace even when
2846 a user-supplied dict is provided. This is needed for embedding
2852 a user-supplied dict is provided. This is needed for embedding
2847 purposes (found by tests with Michel Sanner).
2853 purposes (found by tests with Michel Sanner).
2848
2854
2849 2004-09-27 Fernando Perez <fperez@colorado.edu>
2855 2004-09-27 Fernando Perez <fperez@colorado.edu>
2850
2856
2851 * IPython/UserConfig/ipythonrc: remove []{} from
2857 * IPython/UserConfig/ipythonrc: remove []{} from
2852 readline_remove_delims, so that things like [modname.<TAB> do
2858 readline_remove_delims, so that things like [modname.<TAB> do
2853 proper completion. This disables [].TAB, but that's a less common
2859 proper completion. This disables [].TAB, but that's a less common
2854 case than module names in list comprehensions, for example.
2860 case than module names in list comprehensions, for example.
2855 Thanks to a report by Andrea Riciputi.
2861 Thanks to a report by Andrea Riciputi.
2856
2862
2857 2004-09-09 Fernando Perez <fperez@colorado.edu>
2863 2004-09-09 Fernando Perez <fperez@colorado.edu>
2858
2864
2859 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
2865 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
2860 blocking problems in win32 and osx. Fix by John.
2866 blocking problems in win32 and osx. Fix by John.
2861
2867
2862 2004-09-08 Fernando Perez <fperez@colorado.edu>
2868 2004-09-08 Fernando Perez <fperez@colorado.edu>
2863
2869
2864 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
2870 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
2865 for Win32 and OSX. Fix by John Hunter.
2871 for Win32 and OSX. Fix by John Hunter.
2866
2872
2867 2004-08-30 *** Released version 0.6.3
2873 2004-08-30 *** Released version 0.6.3
2868
2874
2869 2004-08-30 Fernando Perez <fperez@colorado.edu>
2875 2004-08-30 Fernando Perez <fperez@colorado.edu>
2870
2876
2871 * setup.py (isfile): Add manpages to list of dependent files to be
2877 * setup.py (isfile): Add manpages to list of dependent files to be
2872 updated.
2878 updated.
2873
2879
2874 2004-08-27 Fernando Perez <fperez@colorado.edu>
2880 2004-08-27 Fernando Perez <fperez@colorado.edu>
2875
2881
2876 * IPython/Shell.py (start): I've disabled -wthread and -gthread
2882 * IPython/Shell.py (start): I've disabled -wthread and -gthread
2877 for now. They don't really work with standalone WX/GTK code
2883 for now. They don't really work with standalone WX/GTK code
2878 (though matplotlib IS working fine with both of those backends).
2884 (though matplotlib IS working fine with both of those backends).
2879 This will neeed much more testing. I disabled most things with
2885 This will neeed much more testing. I disabled most things with
2880 comments, so turning it back on later should be pretty easy.
2886 comments, so turning it back on later should be pretty easy.
2881
2887
2882 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
2888 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
2883 autocalling of expressions like r'foo', by modifying the line
2889 autocalling of expressions like r'foo', by modifying the line
2884 split regexp. Closes
2890 split regexp. Closes
2885 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
2891 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
2886 Riley <ipythonbugs-AT-sabi.net>.
2892 Riley <ipythonbugs-AT-sabi.net>.
2887 (InteractiveShell.mainloop): honor --nobanner with banner
2893 (InteractiveShell.mainloop): honor --nobanner with banner
2888 extensions.
2894 extensions.
2889
2895
2890 * IPython/Shell.py: Significant refactoring of all classes, so
2896 * IPython/Shell.py: Significant refactoring of all classes, so
2891 that we can really support ALL matplotlib backends and threading
2897 that we can really support ALL matplotlib backends and threading
2892 models (John spotted a bug with Tk which required this). Now we
2898 models (John spotted a bug with Tk which required this). Now we
2893 should support single-threaded, WX-threads and GTK-threads, both
2899 should support single-threaded, WX-threads and GTK-threads, both
2894 for generic code and for matplotlib.
2900 for generic code and for matplotlib.
2895
2901
2896 * IPython/ipmaker.py (__call__): Changed -mpthread option to
2902 * IPython/ipmaker.py (__call__): Changed -mpthread option to
2897 -pylab, to simplify things for users. Will also remove the pylab
2903 -pylab, to simplify things for users. Will also remove the pylab
2898 profile, since now all of matplotlib configuration is directly
2904 profile, since now all of matplotlib configuration is directly
2899 handled here. This also reduces startup time.
2905 handled here. This also reduces startup time.
2900
2906
2901 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
2907 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
2902 shell wasn't being correctly called. Also in IPShellWX.
2908 shell wasn't being correctly called. Also in IPShellWX.
2903
2909
2904 * IPython/iplib.py (InteractiveShell.__init__): Added option to
2910 * IPython/iplib.py (InteractiveShell.__init__): Added option to
2905 fine-tune banner.
2911 fine-tune banner.
2906
2912
2907 * IPython/numutils.py (spike): Deprecate these spike functions,
2913 * IPython/numutils.py (spike): Deprecate these spike functions,
2908 delete (long deprecated) gnuplot_exec handler.
2914 delete (long deprecated) gnuplot_exec handler.
2909
2915
2910 2004-08-26 Fernando Perez <fperez@colorado.edu>
2916 2004-08-26 Fernando Perez <fperez@colorado.edu>
2911
2917
2912 * ipython.1: Update for threading options, plus some others which
2918 * ipython.1: Update for threading options, plus some others which
2913 were missing.
2919 were missing.
2914
2920
2915 * IPython/ipmaker.py (__call__): Added -wthread option for
2921 * IPython/ipmaker.py (__call__): Added -wthread option for
2916 wxpython thread handling. Make sure threading options are only
2922 wxpython thread handling. Make sure threading options are only
2917 valid at the command line.
2923 valid at the command line.
2918
2924
2919 * scripts/ipython: moved shell selection into a factory function
2925 * scripts/ipython: moved shell selection into a factory function
2920 in Shell.py, to keep the starter script to a minimum.
2926 in Shell.py, to keep the starter script to a minimum.
2921
2927
2922 2004-08-25 Fernando Perez <fperez@colorado.edu>
2928 2004-08-25 Fernando Perez <fperez@colorado.edu>
2923
2929
2924 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
2930 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
2925 John. Along with some recent changes he made to matplotlib, the
2931 John. Along with some recent changes he made to matplotlib, the
2926 next versions of both systems should work very well together.
2932 next versions of both systems should work very well together.
2927
2933
2928 2004-08-24 Fernando Perez <fperez@colorado.edu>
2934 2004-08-24 Fernando Perez <fperez@colorado.edu>
2929
2935
2930 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
2936 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
2931 tried to switch the profiling to using hotshot, but I'm getting
2937 tried to switch the profiling to using hotshot, but I'm getting
2932 strange errors from prof.runctx() there. I may be misreading the
2938 strange errors from prof.runctx() there. I may be misreading the
2933 docs, but it looks weird. For now the profiling code will
2939 docs, but it looks weird. For now the profiling code will
2934 continue to use the standard profiler.
2940 continue to use the standard profiler.
2935
2941
2936 2004-08-23 Fernando Perez <fperez@colorado.edu>
2942 2004-08-23 Fernando Perez <fperez@colorado.edu>
2937
2943
2938 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
2944 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
2939 threaded shell, by John Hunter. It's not quite ready yet, but
2945 threaded shell, by John Hunter. It's not quite ready yet, but
2940 close.
2946 close.
2941
2947
2942 2004-08-22 Fernando Perez <fperez@colorado.edu>
2948 2004-08-22 Fernando Perez <fperez@colorado.edu>
2943
2949
2944 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
2950 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
2945 in Magic and ultraTB.
2951 in Magic and ultraTB.
2946
2952
2947 * ipython.1: document threading options in manpage.
2953 * ipython.1: document threading options in manpage.
2948
2954
2949 * scripts/ipython: Changed name of -thread option to -gthread,
2955 * scripts/ipython: Changed name of -thread option to -gthread,
2950 since this is GTK specific. I want to leave the door open for a
2956 since this is GTK specific. I want to leave the door open for a
2951 -wthread option for WX, which will most likely be necessary. This
2957 -wthread option for WX, which will most likely be necessary. This
2952 change affects usage and ipmaker as well.
2958 change affects usage and ipmaker as well.
2953
2959
2954 * IPython/Shell.py (matplotlib_shell): Add a factory function to
2960 * IPython/Shell.py (matplotlib_shell): Add a factory function to
2955 handle the matplotlib shell issues. Code by John Hunter
2961 handle the matplotlib shell issues. Code by John Hunter
2956 <jdhunter-AT-nitace.bsd.uchicago.edu>.
2962 <jdhunter-AT-nitace.bsd.uchicago.edu>.
2957 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
2963 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
2958 broken (and disabled for end users) for now, but it puts the
2964 broken (and disabled for end users) for now, but it puts the
2959 infrastructure in place.
2965 infrastructure in place.
2960
2966
2961 2004-08-21 Fernando Perez <fperez@colorado.edu>
2967 2004-08-21 Fernando Perez <fperez@colorado.edu>
2962
2968
2963 * ipythonrc-pylab: Add matplotlib support.
2969 * ipythonrc-pylab: Add matplotlib support.
2964
2970
2965 * matplotlib_config.py: new files for matplotlib support, part of
2971 * matplotlib_config.py: new files for matplotlib support, part of
2966 the pylab profile.
2972 the pylab profile.
2967
2973
2968 * IPython/usage.py (__doc__): documented the threading options.
2974 * IPython/usage.py (__doc__): documented the threading options.
2969
2975
2970 2004-08-20 Fernando Perez <fperez@colorado.edu>
2976 2004-08-20 Fernando Perez <fperez@colorado.edu>
2971
2977
2972 * ipython: Modified the main calling routine to handle the -thread
2978 * ipython: Modified the main calling routine to handle the -thread
2973 and -mpthread options. This needs to be done as a top-level hack,
2979 and -mpthread options. This needs to be done as a top-level hack,
2974 because it determines which class to instantiate for IPython
2980 because it determines which class to instantiate for IPython
2975 itself.
2981 itself.
2976
2982
2977 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
2983 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
2978 classes to support multithreaded GTK operation without blocking,
2984 classes to support multithreaded GTK operation without blocking,
2979 and matplotlib with all backends. This is a lot of still very
2985 and matplotlib with all backends. This is a lot of still very
2980 experimental code, and threads are tricky. So it may still have a
2986 experimental code, and threads are tricky. So it may still have a
2981 few rough edges... This code owes a lot to
2987 few rough edges... This code owes a lot to
2982 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
2988 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
2983 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
2989 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
2984 to John Hunter for all the matplotlib work.
2990 to John Hunter for all the matplotlib work.
2985
2991
2986 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
2992 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
2987 options for gtk thread and matplotlib support.
2993 options for gtk thread and matplotlib support.
2988
2994
2989 2004-08-16 Fernando Perez <fperez@colorado.edu>
2995 2004-08-16 Fernando Perez <fperez@colorado.edu>
2990
2996
2991 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
2997 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
2992 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
2998 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
2993 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
2999 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
2994
3000
2995 2004-08-11 Fernando Perez <fperez@colorado.edu>
3001 2004-08-11 Fernando Perez <fperez@colorado.edu>
2996
3002
2997 * setup.py (isfile): Fix build so documentation gets updated for
3003 * setup.py (isfile): Fix build so documentation gets updated for
2998 rpms (it was only done for .tgz builds).
3004 rpms (it was only done for .tgz builds).
2999
3005
3000 2004-08-10 Fernando Perez <fperez@colorado.edu>
3006 2004-08-10 Fernando Perez <fperez@colorado.edu>
3001
3007
3002 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
3008 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
3003
3009
3004 * iplib.py : Silence syntax error exceptions in tab-completion.
3010 * iplib.py : Silence syntax error exceptions in tab-completion.
3005
3011
3006 2004-08-05 Fernando Perez <fperez@colorado.edu>
3012 2004-08-05 Fernando Perez <fperez@colorado.edu>
3007
3013
3008 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
3014 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
3009 'color off' mark for continuation prompts. This was causing long
3015 'color off' mark for continuation prompts. This was causing long
3010 continuation lines to mis-wrap.
3016 continuation lines to mis-wrap.
3011
3017
3012 2004-08-01 Fernando Perez <fperez@colorado.edu>
3018 2004-08-01 Fernando Perez <fperez@colorado.edu>
3013
3019
3014 * IPython/ipmaker.py (make_IPython): Allow the shell class used
3020 * IPython/ipmaker.py (make_IPython): Allow the shell class used
3015 for building ipython to be a parameter. All this is necessary
3021 for building ipython to be a parameter. All this is necessary
3016 right now to have a multithreaded version, but this insane
3022 right now to have a multithreaded version, but this insane
3017 non-design will be cleaned up soon. For now, it's a hack that
3023 non-design will be cleaned up soon. For now, it's a hack that
3018 works.
3024 works.
3019
3025
3020 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
3026 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
3021 args in various places. No bugs so far, but it's a dangerous
3027 args in various places. No bugs so far, but it's a dangerous
3022 practice.
3028 practice.
3023
3029
3024 2004-07-31 Fernando Perez <fperez@colorado.edu>
3030 2004-07-31 Fernando Perez <fperez@colorado.edu>
3025
3031
3026 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
3032 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
3027 fix completion of files with dots in their names under most
3033 fix completion of files with dots in their names under most
3028 profiles (pysh was OK because the completion order is different).
3034 profiles (pysh was OK because the completion order is different).
3029
3035
3030 2004-07-27 Fernando Perez <fperez@colorado.edu>
3036 2004-07-27 Fernando Perez <fperez@colorado.edu>
3031
3037
3032 * IPython/iplib.py (InteractiveShell.__init__): build dict of
3038 * IPython/iplib.py (InteractiveShell.__init__): build dict of
3033 keywords manually, b/c the one in keyword.py was removed in python
3039 keywords manually, b/c the one in keyword.py was removed in python
3034 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
3040 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
3035 This is NOT a bug under python 2.3 and earlier.
3041 This is NOT a bug under python 2.3 and earlier.
3036
3042
3037 2004-07-26 Fernando Perez <fperez@colorado.edu>
3043 2004-07-26 Fernando Perez <fperez@colorado.edu>
3038
3044
3039 * IPython/ultraTB.py (VerboseTB.text): Add another
3045 * IPython/ultraTB.py (VerboseTB.text): Add another
3040 linecache.checkcache() call to try to prevent inspect.py from
3046 linecache.checkcache() call to try to prevent inspect.py from
3041 crashing under python 2.3. I think this fixes
3047 crashing under python 2.3. I think this fixes
3042 http://www.scipy.net/roundup/ipython/issue17.
3048 http://www.scipy.net/roundup/ipython/issue17.
3043
3049
3044 2004-07-26 *** Released version 0.6.2
3050 2004-07-26 *** Released version 0.6.2
3045
3051
3046 2004-07-26 Fernando Perez <fperez@colorado.edu>
3052 2004-07-26 Fernando Perez <fperez@colorado.edu>
3047
3053
3048 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
3054 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
3049 fail for any number.
3055 fail for any number.
3050 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
3056 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
3051 empty bookmarks.
3057 empty bookmarks.
3052
3058
3053 2004-07-26 *** Released version 0.6.1
3059 2004-07-26 *** Released version 0.6.1
3054
3060
3055 2004-07-26 Fernando Perez <fperez@colorado.edu>
3061 2004-07-26 Fernando Perez <fperez@colorado.edu>
3056
3062
3057 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
3063 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
3058
3064
3059 * IPython/iplib.py (protect_filename): Applied Ville's patch for
3065 * IPython/iplib.py (protect_filename): Applied Ville's patch for
3060 escaping '()[]{}' in filenames.
3066 escaping '()[]{}' in filenames.
3061
3067
3062 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
3068 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
3063 Python 2.2 users who lack a proper shlex.split.
3069 Python 2.2 users who lack a proper shlex.split.
3064
3070
3065 2004-07-19 Fernando Perez <fperez@colorado.edu>
3071 2004-07-19 Fernando Perez <fperez@colorado.edu>
3066
3072
3067 * IPython/iplib.py (InteractiveShell.init_readline): Add support
3073 * IPython/iplib.py (InteractiveShell.init_readline): Add support
3068 for reading readline's init file. I follow the normal chain:
3074 for reading readline's init file. I follow the normal chain:
3069 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
3075 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
3070 report by Mike Heeter. This closes
3076 report by Mike Heeter. This closes
3071 http://www.scipy.net/roundup/ipython/issue16.
3077 http://www.scipy.net/roundup/ipython/issue16.
3072
3078
3073 2004-07-18 Fernando Perez <fperez@colorado.edu>
3079 2004-07-18 Fernando Perez <fperez@colorado.edu>
3074
3080
3075 * IPython/iplib.py (__init__): Add better handling of '\' under
3081 * IPython/iplib.py (__init__): Add better handling of '\' under
3076 Win32 for filenames. After a patch by Ville.
3082 Win32 for filenames. After a patch by Ville.
3077
3083
3078 2004-07-17 Fernando Perez <fperez@colorado.edu>
3084 2004-07-17 Fernando Perez <fperez@colorado.edu>
3079
3085
3080 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
3086 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
3081 autocalling would be triggered for 'foo is bar' if foo is
3087 autocalling would be triggered for 'foo is bar' if foo is
3082 callable. I also cleaned up the autocall detection code to use a
3088 callable. I also cleaned up the autocall detection code to use a
3083 regexp, which is faster. Bug reported by Alexander Schmolck.
3089 regexp, which is faster. Bug reported by Alexander Schmolck.
3084
3090
3085 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
3091 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
3086 '?' in them would confuse the help system. Reported by Alex
3092 '?' in them would confuse the help system. Reported by Alex
3087 Schmolck.
3093 Schmolck.
3088
3094
3089 2004-07-16 Fernando Perez <fperez@colorado.edu>
3095 2004-07-16 Fernando Perez <fperez@colorado.edu>
3090
3096
3091 * IPython/GnuplotInteractive.py (__all__): added plot2.
3097 * IPython/GnuplotInteractive.py (__all__): added plot2.
3092
3098
3093 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
3099 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
3094 plotting dictionaries, lists or tuples of 1d arrays.
3100 plotting dictionaries, lists or tuples of 1d arrays.
3095
3101
3096 * IPython/Magic.py (Magic.magic_hist): small clenaups and
3102 * IPython/Magic.py (Magic.magic_hist): small clenaups and
3097 optimizations.
3103 optimizations.
3098
3104
3099 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
3105 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
3100 the information which was there from Janko's original IPP code:
3106 the information which was there from Janko's original IPP code:
3101
3107
3102 03.05.99 20:53 porto.ifm.uni-kiel.de
3108 03.05.99 20:53 porto.ifm.uni-kiel.de
3103 --Started changelog.
3109 --Started changelog.
3104 --make clear do what it say it does
3110 --make clear do what it say it does
3105 --added pretty output of lines from inputcache
3111 --added pretty output of lines from inputcache
3106 --Made Logger a mixin class, simplifies handling of switches
3112 --Made Logger a mixin class, simplifies handling of switches
3107 --Added own completer class. .string<TAB> expands to last history
3113 --Added own completer class. .string<TAB> expands to last history
3108 line which starts with string. The new expansion is also present
3114 line which starts with string. The new expansion is also present
3109 with Ctrl-r from the readline library. But this shows, who this
3115 with Ctrl-r from the readline library. But this shows, who this
3110 can be done for other cases.
3116 can be done for other cases.
3111 --Added convention that all shell functions should accept a
3117 --Added convention that all shell functions should accept a
3112 parameter_string This opens the door for different behaviour for
3118 parameter_string This opens the door for different behaviour for
3113 each function. @cd is a good example of this.
3119 each function. @cd is a good example of this.
3114
3120
3115 04.05.99 12:12 porto.ifm.uni-kiel.de
3121 04.05.99 12:12 porto.ifm.uni-kiel.de
3116 --added logfile rotation
3122 --added logfile rotation
3117 --added new mainloop method which freezes first the namespace
3123 --added new mainloop method which freezes first the namespace
3118
3124
3119 07.05.99 21:24 porto.ifm.uni-kiel.de
3125 07.05.99 21:24 porto.ifm.uni-kiel.de
3120 --added the docreader classes. Now there is a help system.
3126 --added the docreader classes. Now there is a help system.
3121 -This is only a first try. Currently it's not easy to put new
3127 -This is only a first try. Currently it's not easy to put new
3122 stuff in the indices. But this is the way to go. Info would be
3128 stuff in the indices. But this is the way to go. Info would be
3123 better, but HTML is every where and not everybody has an info
3129 better, but HTML is every where and not everybody has an info
3124 system installed and it's not so easy to change html-docs to info.
3130 system installed and it's not so easy to change html-docs to info.
3125 --added global logfile option
3131 --added global logfile option
3126 --there is now a hook for object inspection method pinfo needs to
3132 --there is now a hook for object inspection method pinfo needs to
3127 be provided for this. Can be reached by two '??'.
3133 be provided for this. Can be reached by two '??'.
3128
3134
3129 08.05.99 20:51 porto.ifm.uni-kiel.de
3135 08.05.99 20:51 porto.ifm.uni-kiel.de
3130 --added a README
3136 --added a README
3131 --bug in rc file. Something has changed so functions in the rc
3137 --bug in rc file. Something has changed so functions in the rc
3132 file need to reference the shell and not self. Not clear if it's a
3138 file need to reference the shell and not self. Not clear if it's a
3133 bug or feature.
3139 bug or feature.
3134 --changed rc file for new behavior
3140 --changed rc file for new behavior
3135
3141
3136 2004-07-15 Fernando Perez <fperez@colorado.edu>
3142 2004-07-15 Fernando Perez <fperez@colorado.edu>
3137
3143
3138 * IPython/Logger.py (Logger.log): fixed recent bug where the input
3144 * IPython/Logger.py (Logger.log): fixed recent bug where the input
3139 cache was falling out of sync in bizarre manners when multi-line
3145 cache was falling out of sync in bizarre manners when multi-line
3140 input was present. Minor optimizations and cleanup.
3146 input was present. Minor optimizations and cleanup.
3141
3147
3142 (Logger): Remove old Changelog info for cleanup. This is the
3148 (Logger): Remove old Changelog info for cleanup. This is the
3143 information which was there from Janko's original code:
3149 information which was there from Janko's original code:
3144
3150
3145 Changes to Logger: - made the default log filename a parameter
3151 Changes to Logger: - made the default log filename a parameter
3146
3152
3147 - put a check for lines beginning with !@? in log(). Needed
3153 - put a check for lines beginning with !@? in log(). Needed
3148 (even if the handlers properly log their lines) for mid-session
3154 (even if the handlers properly log their lines) for mid-session
3149 logging activation to work properly. Without this, lines logged
3155 logging activation to work properly. Without this, lines logged
3150 in mid session, which get read from the cache, would end up
3156 in mid session, which get read from the cache, would end up
3151 'bare' (with !@? in the open) in the log. Now they are caught
3157 'bare' (with !@? in the open) in the log. Now they are caught
3152 and prepended with a #.
3158 and prepended with a #.
3153
3159
3154 * IPython/iplib.py (InteractiveShell.init_readline): added check
3160 * IPython/iplib.py (InteractiveShell.init_readline): added check
3155 in case MagicCompleter fails to be defined, so we don't crash.
3161 in case MagicCompleter fails to be defined, so we don't crash.
3156
3162
3157 2004-07-13 Fernando Perez <fperez@colorado.edu>
3163 2004-07-13 Fernando Perez <fperez@colorado.edu>
3158
3164
3159 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
3165 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
3160 of EPS if the requested filename ends in '.eps'.
3166 of EPS if the requested filename ends in '.eps'.
3161
3167
3162 2004-07-04 Fernando Perez <fperez@colorado.edu>
3168 2004-07-04 Fernando Perez <fperez@colorado.edu>
3163
3169
3164 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
3170 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
3165 escaping of quotes when calling the shell.
3171 escaping of quotes when calling the shell.
3166
3172
3167 2004-07-02 Fernando Perez <fperez@colorado.edu>
3173 2004-07-02 Fernando Perez <fperez@colorado.edu>
3168
3174
3169 * IPython/Prompts.py (CachedOutput.update): Fix problem with
3175 * IPython/Prompts.py (CachedOutput.update): Fix problem with
3170 gettext not working because we were clobbering '_'. Fixes
3176 gettext not working because we were clobbering '_'. Fixes
3171 http://www.scipy.net/roundup/ipython/issue6.
3177 http://www.scipy.net/roundup/ipython/issue6.
3172
3178
3173 2004-07-01 Fernando Perez <fperez@colorado.edu>
3179 2004-07-01 Fernando Perez <fperez@colorado.edu>
3174
3180
3175 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
3181 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
3176 into @cd. Patch by Ville.
3182 into @cd. Patch by Ville.
3177
3183
3178 * IPython/iplib.py (InteractiveShell.post_config_initialization):
3184 * IPython/iplib.py (InteractiveShell.post_config_initialization):
3179 new function to store things after ipmaker runs. Patch by Ville.
3185 new function to store things after ipmaker runs. Patch by Ville.
3180 Eventually this will go away once ipmaker is removed and the class
3186 Eventually this will go away once ipmaker is removed and the class
3181 gets cleaned up, but for now it's ok. Key functionality here is
3187 gets cleaned up, but for now it's ok. Key functionality here is
3182 the addition of the persistent storage mechanism, a dict for
3188 the addition of the persistent storage mechanism, a dict for
3183 keeping data across sessions (for now just bookmarks, but more can
3189 keeping data across sessions (for now just bookmarks, but more can
3184 be implemented later).
3190 be implemented later).
3185
3191
3186 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
3192 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
3187 persistent across sections. Patch by Ville, I modified it
3193 persistent across sections. Patch by Ville, I modified it
3188 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
3194 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
3189 added a '-l' option to list all bookmarks.
3195 added a '-l' option to list all bookmarks.
3190
3196
3191 * IPython/iplib.py (InteractiveShell.atexit_operations): new
3197 * IPython/iplib.py (InteractiveShell.atexit_operations): new
3192 center for cleanup. Registered with atexit.register(). I moved
3198 center for cleanup. Registered with atexit.register(). I moved
3193 here the old exit_cleanup(). After a patch by Ville.
3199 here the old exit_cleanup(). After a patch by Ville.
3194
3200
3195 * IPython/Magic.py (get_py_filename): added '~' to the accepted
3201 * IPython/Magic.py (get_py_filename): added '~' to the accepted
3196 characters in the hacked shlex_split for python 2.2.
3202 characters in the hacked shlex_split for python 2.2.
3197
3203
3198 * IPython/iplib.py (file_matches): more fixes to filenames with
3204 * IPython/iplib.py (file_matches): more fixes to filenames with
3199 whitespace in them. It's not perfect, but limitations in python's
3205 whitespace in them. It's not perfect, but limitations in python's
3200 readline make it impossible to go further.
3206 readline make it impossible to go further.
3201
3207
3202 2004-06-29 Fernando Perez <fperez@colorado.edu>
3208 2004-06-29 Fernando Perez <fperez@colorado.edu>
3203
3209
3204 * IPython/iplib.py (file_matches): escape whitespace correctly in
3210 * IPython/iplib.py (file_matches): escape whitespace correctly in
3205 filename completions. Bug reported by Ville.
3211 filename completions. Bug reported by Ville.
3206
3212
3207 2004-06-28 Fernando Perez <fperez@colorado.edu>
3213 2004-06-28 Fernando Perez <fperez@colorado.edu>
3208
3214
3209 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
3215 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
3210 the history file will be called 'history-PROFNAME' (or just
3216 the history file will be called 'history-PROFNAME' (or just
3211 'history' if no profile is loaded). I was getting annoyed at
3217 'history' if no profile is loaded). I was getting annoyed at
3212 getting my Numerical work history clobbered by pysh sessions.
3218 getting my Numerical work history clobbered by pysh sessions.
3213
3219
3214 * IPython/iplib.py (InteractiveShell.__init__): Internal
3220 * IPython/iplib.py (InteractiveShell.__init__): Internal
3215 getoutputerror() function so that we can honor the system_verbose
3221 getoutputerror() function so that we can honor the system_verbose
3216 flag for _all_ system calls. I also added escaping of #
3222 flag for _all_ system calls. I also added escaping of #
3217 characters here to avoid confusing Itpl.
3223 characters here to avoid confusing Itpl.
3218
3224
3219 * IPython/Magic.py (shlex_split): removed call to shell in
3225 * IPython/Magic.py (shlex_split): removed call to shell in
3220 parse_options and replaced it with shlex.split(). The annoying
3226 parse_options and replaced it with shlex.split(). The annoying
3221 part was that in Python 2.2, shlex.split() doesn't exist, so I had
3227 part was that in Python 2.2, shlex.split() doesn't exist, so I had
3222 to backport it from 2.3, with several frail hacks (the shlex
3228 to backport it from 2.3, with several frail hacks (the shlex
3223 module is rather limited in 2.2). Thanks to a suggestion by Ville
3229 module is rather limited in 2.2). Thanks to a suggestion by Ville
3224 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
3230 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
3225 problem.
3231 problem.
3226
3232
3227 (Magic.magic_system_verbose): new toggle to print the actual
3233 (Magic.magic_system_verbose): new toggle to print the actual
3228 system calls made by ipython. Mainly for debugging purposes.
3234 system calls made by ipython. Mainly for debugging purposes.
3229
3235
3230 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
3236 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
3231 doesn't support persistence. Reported (and fix suggested) by
3237 doesn't support persistence. Reported (and fix suggested) by
3232 Travis Caldwell <travis_caldwell2000@yahoo.com>.
3238 Travis Caldwell <travis_caldwell2000@yahoo.com>.
3233
3239
3234 2004-06-26 Fernando Perez <fperez@colorado.edu>
3240 2004-06-26 Fernando Perez <fperez@colorado.edu>
3235
3241
3236 * IPython/Logger.py (Logger.log): fix to handle correctly empty
3242 * IPython/Logger.py (Logger.log): fix to handle correctly empty
3237 continue prompts.
3243 continue prompts.
3238
3244
3239 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
3245 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
3240 function (basically a big docstring) and a few more things here to
3246 function (basically a big docstring) and a few more things here to
3241 speedup startup. pysh.py is now very lightweight. We want because
3247 speedup startup. pysh.py is now very lightweight. We want because
3242 it gets execfile'd, while InterpreterExec gets imported, so
3248 it gets execfile'd, while InterpreterExec gets imported, so
3243 byte-compilation saves time.
3249 byte-compilation saves time.
3244
3250
3245 2004-06-25 Fernando Perez <fperez@colorado.edu>
3251 2004-06-25 Fernando Perez <fperez@colorado.edu>
3246
3252
3247 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
3253 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
3248 -NUM', which was recently broken.
3254 -NUM', which was recently broken.
3249
3255
3250 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
3256 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
3251 in multi-line input (but not !!, which doesn't make sense there).
3257 in multi-line input (but not !!, which doesn't make sense there).
3252
3258
3253 * IPython/UserConfig/ipythonrc: made autoindent on by default.
3259 * IPython/UserConfig/ipythonrc: made autoindent on by default.
3254 It's just too useful, and people can turn it off in the less
3260 It's just too useful, and people can turn it off in the less
3255 common cases where it's a problem.
3261 common cases where it's a problem.
3256
3262
3257 2004-06-24 Fernando Perez <fperez@colorado.edu>
3263 2004-06-24 Fernando Perez <fperez@colorado.edu>
3258
3264
3259 * IPython/iplib.py (InteractiveShell._prefilter): big change -
3265 * IPython/iplib.py (InteractiveShell._prefilter): big change -
3260 special syntaxes (like alias calling) is now allied in multi-line
3266 special syntaxes (like alias calling) is now allied in multi-line
3261 input. This is still _very_ experimental, but it's necessary for
3267 input. This is still _very_ experimental, but it's necessary for
3262 efficient shell usage combining python looping syntax with system
3268 efficient shell usage combining python looping syntax with system
3263 calls. For now it's restricted to aliases, I don't think it
3269 calls. For now it's restricted to aliases, I don't think it
3264 really even makes sense to have this for magics.
3270 really even makes sense to have this for magics.
3265
3271
3266 2004-06-23 Fernando Perez <fperez@colorado.edu>
3272 2004-06-23 Fernando Perez <fperez@colorado.edu>
3267
3273
3268 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
3274 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
3269 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
3275 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
3270
3276
3271 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
3277 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
3272 extensions under Windows (after code sent by Gary Bishop). The
3278 extensions under Windows (after code sent by Gary Bishop). The
3273 extensions considered 'executable' are stored in IPython's rc
3279 extensions considered 'executable' are stored in IPython's rc
3274 structure as win_exec_ext.
3280 structure as win_exec_ext.
3275
3281
3276 * IPython/genutils.py (shell): new function, like system() but
3282 * IPython/genutils.py (shell): new function, like system() but
3277 without return value. Very useful for interactive shell work.
3283 without return value. Very useful for interactive shell work.
3278
3284
3279 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
3285 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
3280 delete aliases.
3286 delete aliases.
3281
3287
3282 * IPython/iplib.py (InteractiveShell.alias_table_update): make
3288 * IPython/iplib.py (InteractiveShell.alias_table_update): make
3283 sure that the alias table doesn't contain python keywords.
3289 sure that the alias table doesn't contain python keywords.
3284
3290
3285 2004-06-21 Fernando Perez <fperez@colorado.edu>
3291 2004-06-21 Fernando Perez <fperez@colorado.edu>
3286
3292
3287 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
3293 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
3288 non-existent items are found in $PATH. Reported by Thorsten.
3294 non-existent items are found in $PATH. Reported by Thorsten.
3289
3295
3290 2004-06-20 Fernando Perez <fperez@colorado.edu>
3296 2004-06-20 Fernando Perez <fperez@colorado.edu>
3291
3297
3292 * IPython/iplib.py (complete): modified the completer so that the
3298 * IPython/iplib.py (complete): modified the completer so that the
3293 order of priorities can be easily changed at runtime.
3299 order of priorities can be easily changed at runtime.
3294
3300
3295 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
3301 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
3296 Modified to auto-execute all lines beginning with '~', '/' or '.'.
3302 Modified to auto-execute all lines beginning with '~', '/' or '.'.
3297
3303
3298 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
3304 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
3299 expand Python variables prepended with $ in all system calls. The
3305 expand Python variables prepended with $ in all system calls. The
3300 same was done to InteractiveShell.handle_shell_escape. Now all
3306 same was done to InteractiveShell.handle_shell_escape. Now all
3301 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
3307 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
3302 expansion of python variables and expressions according to the
3308 expansion of python variables and expressions according to the
3303 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
3309 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
3304
3310
3305 Though PEP-215 has been rejected, a similar (but simpler) one
3311 Though PEP-215 has been rejected, a similar (but simpler) one
3306 seems like it will go into Python 2.4, PEP-292 -
3312 seems like it will go into Python 2.4, PEP-292 -
3307 http://www.python.org/peps/pep-0292.html.
3313 http://www.python.org/peps/pep-0292.html.
3308
3314
3309 I'll keep the full syntax of PEP-215, since IPython has since the
3315 I'll keep the full syntax of PEP-215, since IPython has since the
3310 start used Ka-Ping Yee's reference implementation discussed there
3316 start used Ka-Ping Yee's reference implementation discussed there
3311 (Itpl), and I actually like the powerful semantics it offers.
3317 (Itpl), and I actually like the powerful semantics it offers.
3312
3318
3313 In order to access normal shell variables, the $ has to be escaped
3319 In order to access normal shell variables, the $ has to be escaped
3314 via an extra $. For example:
3320 via an extra $. For example:
3315
3321
3316 In [7]: PATH='a python variable'
3322 In [7]: PATH='a python variable'
3317
3323
3318 In [8]: !echo $PATH
3324 In [8]: !echo $PATH
3319 a python variable
3325 a python variable
3320
3326
3321 In [9]: !echo $$PATH
3327 In [9]: !echo $$PATH
3322 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
3328 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
3323
3329
3324 (Magic.parse_options): escape $ so the shell doesn't evaluate
3330 (Magic.parse_options): escape $ so the shell doesn't evaluate
3325 things prematurely.
3331 things prematurely.
3326
3332
3327 * IPython/iplib.py (InteractiveShell.call_alias): added the
3333 * IPython/iplib.py (InteractiveShell.call_alias): added the
3328 ability for aliases to expand python variables via $.
3334 ability for aliases to expand python variables via $.
3329
3335
3330 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
3336 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
3331 system, now there's a @rehash/@rehashx pair of magics. These work
3337 system, now there's a @rehash/@rehashx pair of magics. These work
3332 like the csh rehash command, and can be invoked at any time. They
3338 like the csh rehash command, and can be invoked at any time. They
3333 build a table of aliases to everything in the user's $PATH
3339 build a table of aliases to everything in the user's $PATH
3334 (@rehash uses everything, @rehashx is slower but only adds
3340 (@rehash uses everything, @rehashx is slower but only adds
3335 executable files). With this, the pysh.py-based shell profile can
3341 executable files). With this, the pysh.py-based shell profile can
3336 now simply call rehash upon startup, and full access to all
3342 now simply call rehash upon startup, and full access to all
3337 programs in the user's path is obtained.
3343 programs in the user's path is obtained.
3338
3344
3339 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
3345 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
3340 functionality is now fully in place. I removed the old dynamic
3346 functionality is now fully in place. I removed the old dynamic
3341 code generation based approach, in favor of a much lighter one
3347 code generation based approach, in favor of a much lighter one
3342 based on a simple dict. The advantage is that this allows me to
3348 based on a simple dict. The advantage is that this allows me to
3343 now have thousands of aliases with negligible cost (unthinkable
3349 now have thousands of aliases with negligible cost (unthinkable
3344 with the old system).
3350 with the old system).
3345
3351
3346 2004-06-19 Fernando Perez <fperez@colorado.edu>
3352 2004-06-19 Fernando Perez <fperez@colorado.edu>
3347
3353
3348 * IPython/iplib.py (__init__): extended MagicCompleter class to
3354 * IPython/iplib.py (__init__): extended MagicCompleter class to
3349 also complete (last in priority) on user aliases.
3355 also complete (last in priority) on user aliases.
3350
3356
3351 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
3357 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
3352 call to eval.
3358 call to eval.
3353 (ItplNS.__init__): Added a new class which functions like Itpl,
3359 (ItplNS.__init__): Added a new class which functions like Itpl,
3354 but allows configuring the namespace for the evaluation to occur
3360 but allows configuring the namespace for the evaluation to occur
3355 in.
3361 in.
3356
3362
3357 2004-06-18 Fernando Perez <fperez@colorado.edu>
3363 2004-06-18 Fernando Perez <fperez@colorado.edu>
3358
3364
3359 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
3365 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
3360 better message when 'exit' or 'quit' are typed (a common newbie
3366 better message when 'exit' or 'quit' are typed (a common newbie
3361 confusion).
3367 confusion).
3362
3368
3363 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
3369 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
3364 check for Windows users.
3370 check for Windows users.
3365
3371
3366 * IPython/iplib.py (InteractiveShell.user_setup): removed
3372 * IPython/iplib.py (InteractiveShell.user_setup): removed
3367 disabling of colors for Windows. I'll test at runtime and issue a
3373 disabling of colors for Windows. I'll test at runtime and issue a
3368 warning if Gary's readline isn't found, as to nudge users to
3374 warning if Gary's readline isn't found, as to nudge users to
3369 download it.
3375 download it.
3370
3376
3371 2004-06-16 Fernando Perez <fperez@colorado.edu>
3377 2004-06-16 Fernando Perez <fperez@colorado.edu>
3372
3378
3373 * IPython/genutils.py (Stream.__init__): changed to print errors
3379 * IPython/genutils.py (Stream.__init__): changed to print errors
3374 to sys.stderr. I had a circular dependency here. Now it's
3380 to sys.stderr. I had a circular dependency here. Now it's
3375 possible to run ipython as IDLE's shell (consider this pre-alpha,
3381 possible to run ipython as IDLE's shell (consider this pre-alpha,
3376 since true stdout things end up in the starting terminal instead
3382 since true stdout things end up in the starting terminal instead
3377 of IDLE's out).
3383 of IDLE's out).
3378
3384
3379 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
3385 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
3380 users who haven't # updated their prompt_in2 definitions. Remove
3386 users who haven't # updated their prompt_in2 definitions. Remove
3381 eventually.
3387 eventually.
3382 (multiple_replace): added credit to original ASPN recipe.
3388 (multiple_replace): added credit to original ASPN recipe.
3383
3389
3384 2004-06-15 Fernando Perez <fperez@colorado.edu>
3390 2004-06-15 Fernando Perez <fperez@colorado.edu>
3385
3391
3386 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
3392 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
3387 list of auto-defined aliases.
3393 list of auto-defined aliases.
3388
3394
3389 2004-06-13 Fernando Perez <fperez@colorado.edu>
3395 2004-06-13 Fernando Perez <fperez@colorado.edu>
3390
3396
3391 * setup.py (scriptfiles): Don't trigger win_post_install unless an
3397 * setup.py (scriptfiles): Don't trigger win_post_install unless an
3392 install was really requested (so setup.py can be used for other
3398 install was really requested (so setup.py can be used for other
3393 things under Windows).
3399 things under Windows).
3394
3400
3395 2004-06-10 Fernando Perez <fperez@colorado.edu>
3401 2004-06-10 Fernando Perez <fperez@colorado.edu>
3396
3402
3397 * IPython/Logger.py (Logger.create_log): Manually remove any old
3403 * IPython/Logger.py (Logger.create_log): Manually remove any old
3398 backup, since os.remove may fail under Windows. Fixes bug
3404 backup, since os.remove may fail under Windows. Fixes bug
3399 reported by Thorsten.
3405 reported by Thorsten.
3400
3406
3401 2004-06-09 Fernando Perez <fperez@colorado.edu>
3407 2004-06-09 Fernando Perez <fperez@colorado.edu>
3402
3408
3403 * examples/example-embed.py: fixed all references to %n (replaced
3409 * examples/example-embed.py: fixed all references to %n (replaced
3404 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
3410 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
3405 for all examples and the manual as well.
3411 for all examples and the manual as well.
3406
3412
3407 2004-06-08 Fernando Perez <fperez@colorado.edu>
3413 2004-06-08 Fernando Perez <fperez@colorado.edu>
3408
3414
3409 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
3415 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
3410 alignment and color management. All 3 prompt subsystems now
3416 alignment and color management. All 3 prompt subsystems now
3411 inherit from BasePrompt.
3417 inherit from BasePrompt.
3412
3418
3413 * tools/release: updates for windows installer build and tag rpms
3419 * tools/release: updates for windows installer build and tag rpms
3414 with python version (since paths are fixed).
3420 with python version (since paths are fixed).
3415
3421
3416 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
3422 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
3417 which will become eventually obsolete. Also fixed the default
3423 which will become eventually obsolete. Also fixed the default
3418 prompt_in2 to use \D, so at least new users start with the correct
3424 prompt_in2 to use \D, so at least new users start with the correct
3419 defaults.
3425 defaults.
3420 WARNING: Users with existing ipythonrc files will need to apply
3426 WARNING: Users with existing ipythonrc files will need to apply
3421 this fix manually!
3427 this fix manually!
3422
3428
3423 * setup.py: make windows installer (.exe). This is finally the
3429 * setup.py: make windows installer (.exe). This is finally the
3424 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
3430 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
3425 which I hadn't included because it required Python 2.3 (or recent
3431 which I hadn't included because it required Python 2.3 (or recent
3426 distutils).
3432 distutils).
3427
3433
3428 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
3434 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
3429 usage of new '\D' escape.
3435 usage of new '\D' escape.
3430
3436
3431 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
3437 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
3432 lacks os.getuid())
3438 lacks os.getuid())
3433 (CachedOutput.set_colors): Added the ability to turn coloring
3439 (CachedOutput.set_colors): Added the ability to turn coloring
3434 on/off with @colors even for manually defined prompt colors. It
3440 on/off with @colors even for manually defined prompt colors. It
3435 uses a nasty global, but it works safely and via the generic color
3441 uses a nasty global, but it works safely and via the generic color
3436 handling mechanism.
3442 handling mechanism.
3437 (Prompt2.__init__): Introduced new escape '\D' for continuation
3443 (Prompt2.__init__): Introduced new escape '\D' for continuation
3438 prompts. It represents the counter ('\#') as dots.
3444 prompts. It represents the counter ('\#') as dots.
3439 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
3445 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
3440 need to update their ipythonrc files and replace '%n' with '\D' in
3446 need to update their ipythonrc files and replace '%n' with '\D' in
3441 their prompt_in2 settings everywhere. Sorry, but there's
3447 their prompt_in2 settings everywhere. Sorry, but there's
3442 otherwise no clean way to get all prompts to properly align. The
3448 otherwise no clean way to get all prompts to properly align. The
3443 ipythonrc shipped with IPython has been updated.
3449 ipythonrc shipped with IPython has been updated.
3444
3450
3445 2004-06-07 Fernando Perez <fperez@colorado.edu>
3451 2004-06-07 Fernando Perez <fperez@colorado.edu>
3446
3452
3447 * setup.py (isfile): Pass local_icons option to latex2html, so the
3453 * setup.py (isfile): Pass local_icons option to latex2html, so the
3448 resulting HTML file is self-contained. Thanks to
3454 resulting HTML file is self-contained. Thanks to
3449 dryice-AT-liu.com.cn for the tip.
3455 dryice-AT-liu.com.cn for the tip.
3450
3456
3451 * pysh.py: I created a new profile 'shell', which implements a
3457 * pysh.py: I created a new profile 'shell', which implements a
3452 _rudimentary_ IPython-based shell. This is in NO WAY a realy
3458 _rudimentary_ IPython-based shell. This is in NO WAY a realy
3453 system shell, nor will it become one anytime soon. It's mainly
3459 system shell, nor will it become one anytime soon. It's mainly
3454 meant to illustrate the use of the new flexible bash-like prompts.
3460 meant to illustrate the use of the new flexible bash-like prompts.
3455 I guess it could be used by hardy souls for true shell management,
3461 I guess it could be used by hardy souls for true shell management,
3456 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
3462 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
3457 profile. This uses the InterpreterExec extension provided by
3463 profile. This uses the InterpreterExec extension provided by
3458 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
3464 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
3459
3465
3460 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
3466 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
3461 auto-align itself with the length of the previous input prompt
3467 auto-align itself with the length of the previous input prompt
3462 (taking into account the invisible color escapes).
3468 (taking into account the invisible color escapes).
3463 (CachedOutput.__init__): Large restructuring of this class. Now
3469 (CachedOutput.__init__): Large restructuring of this class. Now
3464 all three prompts (primary1, primary2, output) are proper objects,
3470 all three prompts (primary1, primary2, output) are proper objects,
3465 managed by the 'parent' CachedOutput class. The code is still a
3471 managed by the 'parent' CachedOutput class. The code is still a
3466 bit hackish (all prompts share state via a pointer to the cache),
3472 bit hackish (all prompts share state via a pointer to the cache),
3467 but it's overall far cleaner than before.
3473 but it's overall far cleaner than before.
3468
3474
3469 * IPython/genutils.py (getoutputerror): modified to add verbose,
3475 * IPython/genutils.py (getoutputerror): modified to add verbose,
3470 debug and header options. This makes the interface of all getout*
3476 debug and header options. This makes the interface of all getout*
3471 functions uniform.
3477 functions uniform.
3472 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
3478 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
3473
3479
3474 * IPython/Magic.py (Magic.default_option): added a function to
3480 * IPython/Magic.py (Magic.default_option): added a function to
3475 allow registering default options for any magic command. This
3481 allow registering default options for any magic command. This
3476 makes it easy to have profiles which customize the magics globally
3482 makes it easy to have profiles which customize the magics globally
3477 for a certain use. The values set through this function are
3483 for a certain use. The values set through this function are
3478 picked up by the parse_options() method, which all magics should
3484 picked up by the parse_options() method, which all magics should
3479 use to parse their options.
3485 use to parse their options.
3480
3486
3481 * IPython/genutils.py (warn): modified the warnings framework to
3487 * IPython/genutils.py (warn): modified the warnings framework to
3482 use the Term I/O class. I'm trying to slowly unify all of
3488 use the Term I/O class. I'm trying to slowly unify all of
3483 IPython's I/O operations to pass through Term.
3489 IPython's I/O operations to pass through Term.
3484
3490
3485 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
3491 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
3486 the secondary prompt to correctly match the length of the primary
3492 the secondary prompt to correctly match the length of the primary
3487 one for any prompt. Now multi-line code will properly line up
3493 one for any prompt. Now multi-line code will properly line up
3488 even for path dependent prompts, such as the new ones available
3494 even for path dependent prompts, such as the new ones available
3489 via the prompt_specials.
3495 via the prompt_specials.
3490
3496
3491 2004-06-06 Fernando Perez <fperez@colorado.edu>
3497 2004-06-06 Fernando Perez <fperez@colorado.edu>
3492
3498
3493 * IPython/Prompts.py (prompt_specials): Added the ability to have
3499 * IPython/Prompts.py (prompt_specials): Added the ability to have
3494 bash-like special sequences in the prompts, which get
3500 bash-like special sequences in the prompts, which get
3495 automatically expanded. Things like hostname, current working
3501 automatically expanded. Things like hostname, current working
3496 directory and username are implemented already, but it's easy to
3502 directory and username are implemented already, but it's easy to
3497 add more in the future. Thanks to a patch by W.J. van der Laan
3503 add more in the future. Thanks to a patch by W.J. van der Laan
3498 <gnufnork-AT-hetdigitalegat.nl>
3504 <gnufnork-AT-hetdigitalegat.nl>
3499 (prompt_specials): Added color support for prompt strings, so
3505 (prompt_specials): Added color support for prompt strings, so
3500 users can define arbitrary color setups for their prompts.
3506 users can define arbitrary color setups for their prompts.
3501
3507
3502 2004-06-05 Fernando Perez <fperez@colorado.edu>
3508 2004-06-05 Fernando Perez <fperez@colorado.edu>
3503
3509
3504 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
3510 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
3505 code to load Gary Bishop's readline and configure it
3511 code to load Gary Bishop's readline and configure it
3506 automatically. Thanks to Gary for help on this.
3512 automatically. Thanks to Gary for help on this.
3507
3513
3508 2004-06-01 Fernando Perez <fperez@colorado.edu>
3514 2004-06-01 Fernando Perez <fperez@colorado.edu>
3509
3515
3510 * IPython/Logger.py (Logger.create_log): fix bug for logging
3516 * IPython/Logger.py (Logger.create_log): fix bug for logging
3511 with no filename (previous fix was incomplete).
3517 with no filename (previous fix was incomplete).
3512
3518
3513 2004-05-25 Fernando Perez <fperez@colorado.edu>
3519 2004-05-25 Fernando Perez <fperez@colorado.edu>
3514
3520
3515 * IPython/Magic.py (Magic.parse_options): fix bug where naked
3521 * IPython/Magic.py (Magic.parse_options): fix bug where naked
3516 parens would get passed to the shell.
3522 parens would get passed to the shell.
3517
3523
3518 2004-05-20 Fernando Perez <fperez@colorado.edu>
3524 2004-05-20 Fernando Perez <fperez@colorado.edu>
3519
3525
3520 * IPython/Magic.py (Magic.magic_prun): changed default profile
3526 * IPython/Magic.py (Magic.magic_prun): changed default profile
3521 sort order to 'time' (the more common profiling need).
3527 sort order to 'time' (the more common profiling need).
3522
3528
3523 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
3529 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
3524 so that source code shown is guaranteed in sync with the file on
3530 so that source code shown is guaranteed in sync with the file on
3525 disk (also changed in psource). Similar fix to the one for
3531 disk (also changed in psource). Similar fix to the one for
3526 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
3532 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
3527 <yann.ledu-AT-noos.fr>.
3533 <yann.ledu-AT-noos.fr>.
3528
3534
3529 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
3535 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
3530 with a single option would not be correctly parsed. Closes
3536 with a single option would not be correctly parsed. Closes
3531 http://www.scipy.net/roundup/ipython/issue14. This bug had been
3537 http://www.scipy.net/roundup/ipython/issue14. This bug had been
3532 introduced in 0.6.0 (on 2004-05-06).
3538 introduced in 0.6.0 (on 2004-05-06).
3533
3539
3534 2004-05-13 *** Released version 0.6.0
3540 2004-05-13 *** Released version 0.6.0
3535
3541
3536 2004-05-13 Fernando Perez <fperez@colorado.edu>
3542 2004-05-13 Fernando Perez <fperez@colorado.edu>
3537
3543
3538 * debian/: Added debian/ directory to CVS, so that debian support
3544 * debian/: Added debian/ directory to CVS, so that debian support
3539 is publicly accessible. The debian package is maintained by Jack
3545 is publicly accessible. The debian package is maintained by Jack
3540 Moffit <jack-AT-xiph.org>.
3546 Moffit <jack-AT-xiph.org>.
3541
3547
3542 * Documentation: included the notes about an ipython-based system
3548 * Documentation: included the notes about an ipython-based system
3543 shell (the hypothetical 'pysh') into the new_design.pdf document,
3549 shell (the hypothetical 'pysh') into the new_design.pdf document,
3544 so that these ideas get distributed to users along with the
3550 so that these ideas get distributed to users along with the
3545 official documentation.
3551 official documentation.
3546
3552
3547 2004-05-10 Fernando Perez <fperez@colorado.edu>
3553 2004-05-10 Fernando Perez <fperez@colorado.edu>
3548
3554
3549 * IPython/Logger.py (Logger.create_log): fix recently introduced
3555 * IPython/Logger.py (Logger.create_log): fix recently introduced
3550 bug (misindented line) where logstart would fail when not given an
3556 bug (misindented line) where logstart would fail when not given an
3551 explicit filename.
3557 explicit filename.
3552
3558
3553 2004-05-09 Fernando Perez <fperez@colorado.edu>
3559 2004-05-09 Fernando Perez <fperez@colorado.edu>
3554
3560
3555 * IPython/Magic.py (Magic.parse_options): skip system call when
3561 * IPython/Magic.py (Magic.parse_options): skip system call when
3556 there are no options to look for. Faster, cleaner for the common
3562 there are no options to look for. Faster, cleaner for the common
3557 case.
3563 case.
3558
3564
3559 * Documentation: many updates to the manual: describing Windows
3565 * Documentation: many updates to the manual: describing Windows
3560 support better, Gnuplot updates, credits, misc small stuff. Also
3566 support better, Gnuplot updates, credits, misc small stuff. Also
3561 updated the new_design doc a bit.
3567 updated the new_design doc a bit.
3562
3568
3563 2004-05-06 *** Released version 0.6.0.rc1
3569 2004-05-06 *** Released version 0.6.0.rc1
3564
3570
3565 2004-05-06 Fernando Perez <fperez@colorado.edu>
3571 2004-05-06 Fernando Perez <fperez@colorado.edu>
3566
3572
3567 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
3573 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
3568 operations to use the vastly more efficient list/''.join() method.
3574 operations to use the vastly more efficient list/''.join() method.
3569 (FormattedTB.text): Fix
3575 (FormattedTB.text): Fix
3570 http://www.scipy.net/roundup/ipython/issue12 - exception source
3576 http://www.scipy.net/roundup/ipython/issue12 - exception source
3571 extract not updated after reload. Thanks to Mike Salib
3577 extract not updated after reload. Thanks to Mike Salib
3572 <msalib-AT-mit.edu> for pinning the source of the problem.
3578 <msalib-AT-mit.edu> for pinning the source of the problem.
3573 Fortunately, the solution works inside ipython and doesn't require
3579 Fortunately, the solution works inside ipython and doesn't require
3574 any changes to python proper.
3580 any changes to python proper.
3575
3581
3576 * IPython/Magic.py (Magic.parse_options): Improved to process the
3582 * IPython/Magic.py (Magic.parse_options): Improved to process the
3577 argument list as a true shell would (by actually using the
3583 argument list as a true shell would (by actually using the
3578 underlying system shell). This way, all @magics automatically get
3584 underlying system shell). This way, all @magics automatically get
3579 shell expansion for variables. Thanks to a comment by Alex
3585 shell expansion for variables. Thanks to a comment by Alex
3580 Schmolck.
3586 Schmolck.
3581
3587
3582 2004-04-04 Fernando Perez <fperez@colorado.edu>
3588 2004-04-04 Fernando Perez <fperez@colorado.edu>
3583
3589
3584 * IPython/iplib.py (InteractiveShell.interact): Added a special
3590 * IPython/iplib.py (InteractiveShell.interact): Added a special
3585 trap for a debugger quit exception, which is basically impossible
3591 trap for a debugger quit exception, which is basically impossible
3586 to handle by normal mechanisms, given what pdb does to the stack.
3592 to handle by normal mechanisms, given what pdb does to the stack.
3587 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
3593 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
3588
3594
3589 2004-04-03 Fernando Perez <fperez@colorado.edu>
3595 2004-04-03 Fernando Perez <fperez@colorado.edu>
3590
3596
3591 * IPython/genutils.py (Term): Standardized the names of the Term
3597 * IPython/genutils.py (Term): Standardized the names of the Term
3592 class streams to cin/cout/cerr, following C++ naming conventions
3598 class streams to cin/cout/cerr, following C++ naming conventions
3593 (I can't use in/out/err because 'in' is not a valid attribute
3599 (I can't use in/out/err because 'in' is not a valid attribute
3594 name).
3600 name).
3595
3601
3596 * IPython/iplib.py (InteractiveShell.interact): don't increment
3602 * IPython/iplib.py (InteractiveShell.interact): don't increment
3597 the prompt if there's no user input. By Daniel 'Dang' Griffith
3603 the prompt if there's no user input. By Daniel 'Dang' Griffith
3598 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
3604 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
3599 Francois Pinard.
3605 Francois Pinard.
3600
3606
3601 2004-04-02 Fernando Perez <fperez@colorado.edu>
3607 2004-04-02 Fernando Perez <fperez@colorado.edu>
3602
3608
3603 * IPython/genutils.py (Stream.__init__): Modified to survive at
3609 * IPython/genutils.py (Stream.__init__): Modified to survive at
3604 least importing in contexts where stdin/out/err aren't true file
3610 least importing in contexts where stdin/out/err aren't true file
3605 objects, such as PyCrust (they lack fileno() and mode). However,
3611 objects, such as PyCrust (they lack fileno() and mode). However,
3606 the recovery facilities which rely on these things existing will
3612 the recovery facilities which rely on these things existing will
3607 not work.
3613 not work.
3608
3614
3609 2004-04-01 Fernando Perez <fperez@colorado.edu>
3615 2004-04-01 Fernando Perez <fperez@colorado.edu>
3610
3616
3611 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
3617 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
3612 use the new getoutputerror() function, so it properly
3618 use the new getoutputerror() function, so it properly
3613 distinguishes stdout/err.
3619 distinguishes stdout/err.
3614
3620
3615 * IPython/genutils.py (getoutputerror): added a function to
3621 * IPython/genutils.py (getoutputerror): added a function to
3616 capture separately the standard output and error of a command.
3622 capture separately the standard output and error of a command.
3617 After a comment from dang on the mailing lists. This code is
3623 After a comment from dang on the mailing lists. This code is
3618 basically a modified version of commands.getstatusoutput(), from
3624 basically a modified version of commands.getstatusoutput(), from
3619 the standard library.
3625 the standard library.
3620
3626
3621 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
3627 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
3622 '!!' as a special syntax (shorthand) to access @sx.
3628 '!!' as a special syntax (shorthand) to access @sx.
3623
3629
3624 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
3630 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
3625 command and return its output as a list split on '\n'.
3631 command and return its output as a list split on '\n'.
3626
3632
3627 2004-03-31 Fernando Perez <fperez@colorado.edu>
3633 2004-03-31 Fernando Perez <fperez@colorado.edu>
3628
3634
3629 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
3635 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
3630 method to dictionaries used as FakeModule instances if they lack
3636 method to dictionaries used as FakeModule instances if they lack
3631 it. At least pydoc in python2.3 breaks for runtime-defined
3637 it. At least pydoc in python2.3 breaks for runtime-defined
3632 functions without this hack. At some point I need to _really_
3638 functions without this hack. At some point I need to _really_
3633 understand what FakeModule is doing, because it's a gross hack.
3639 understand what FakeModule is doing, because it's a gross hack.
3634 But it solves Arnd's problem for now...
3640 But it solves Arnd's problem for now...
3635
3641
3636 2004-02-27 Fernando Perez <fperez@colorado.edu>
3642 2004-02-27 Fernando Perez <fperez@colorado.edu>
3637
3643
3638 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
3644 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
3639 mode would behave erratically. Also increased the number of
3645 mode would behave erratically. Also increased the number of
3640 possible logs in rotate mod to 999. Thanks to Rod Holland
3646 possible logs in rotate mod to 999. Thanks to Rod Holland
3641 <rhh@StructureLABS.com> for the report and fixes.
3647 <rhh@StructureLABS.com> for the report and fixes.
3642
3648
3643 2004-02-26 Fernando Perez <fperez@colorado.edu>
3649 2004-02-26 Fernando Perez <fperez@colorado.edu>
3644
3650
3645 * IPython/genutils.py (page): Check that the curses module really
3651 * IPython/genutils.py (page): Check that the curses module really
3646 has the initscr attribute before trying to use it. For some
3652 has the initscr attribute before trying to use it. For some
3647 reason, the Solaris curses module is missing this. I think this
3653 reason, the Solaris curses module is missing this. I think this
3648 should be considered a Solaris python bug, but I'm not sure.
3654 should be considered a Solaris python bug, but I'm not sure.
3649
3655
3650 2004-01-17 Fernando Perez <fperez@colorado.edu>
3656 2004-01-17 Fernando Perez <fperez@colorado.edu>
3651
3657
3652 * IPython/genutils.py (Stream.__init__): Changes to try to make
3658 * IPython/genutils.py (Stream.__init__): Changes to try to make
3653 ipython robust against stdin/out/err being closed by the user.
3659 ipython robust against stdin/out/err being closed by the user.
3654 This is 'user error' (and blocks a normal python session, at least
3660 This is 'user error' (and blocks a normal python session, at least
3655 the stdout case). However, Ipython should be able to survive such
3661 the stdout case). However, Ipython should be able to survive such
3656 instances of abuse as gracefully as possible. To simplify the
3662 instances of abuse as gracefully as possible. To simplify the
3657 coding and maintain compatibility with Gary Bishop's Term
3663 coding and maintain compatibility with Gary Bishop's Term
3658 contributions, I've made use of classmethods for this. I think
3664 contributions, I've made use of classmethods for this. I think
3659 this introduces a dependency on python 2.2.
3665 this introduces a dependency on python 2.2.
3660
3666
3661 2004-01-13 Fernando Perez <fperez@colorado.edu>
3667 2004-01-13 Fernando Perez <fperez@colorado.edu>
3662
3668
3663 * IPython/numutils.py (exp_safe): simplified the code a bit and
3669 * IPython/numutils.py (exp_safe): simplified the code a bit and
3664 removed the need for importing the kinds module altogether.
3670 removed the need for importing the kinds module altogether.
3665
3671
3666 2004-01-06 Fernando Perez <fperez@colorado.edu>
3672 2004-01-06 Fernando Perez <fperez@colorado.edu>
3667
3673
3668 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
3674 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
3669 a magic function instead, after some community feedback. No
3675 a magic function instead, after some community feedback. No
3670 special syntax will exist for it, but its name is deliberately
3676 special syntax will exist for it, but its name is deliberately
3671 very short.
3677 very short.
3672
3678
3673 2003-12-20 Fernando Perez <fperez@colorado.edu>
3679 2003-12-20 Fernando Perez <fperez@colorado.edu>
3674
3680
3675 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
3681 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
3676 new functionality, to automagically assign the result of a shell
3682 new functionality, to automagically assign the result of a shell
3677 command to a variable. I'll solicit some community feedback on
3683 command to a variable. I'll solicit some community feedback on
3678 this before making it permanent.
3684 this before making it permanent.
3679
3685
3680 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
3686 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
3681 requested about callables for which inspect couldn't obtain a
3687 requested about callables for which inspect couldn't obtain a
3682 proper argspec. Thanks to a crash report sent by Etienne
3688 proper argspec. Thanks to a crash report sent by Etienne
3683 Posthumus <etienne-AT-apple01.cs.vu.nl>.
3689 Posthumus <etienne-AT-apple01.cs.vu.nl>.
3684
3690
3685 2003-12-09 Fernando Perez <fperez@colorado.edu>
3691 2003-12-09 Fernando Perez <fperez@colorado.edu>
3686
3692
3687 * IPython/genutils.py (page): patch for the pager to work across
3693 * IPython/genutils.py (page): patch for the pager to work across
3688 various versions of Windows. By Gary Bishop.
3694 various versions of Windows. By Gary Bishop.
3689
3695
3690 2003-12-04 Fernando Perez <fperez@colorado.edu>
3696 2003-12-04 Fernando Perez <fperez@colorado.edu>
3691
3697
3692 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
3698 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
3693 Gnuplot.py version 1.7, whose internal names changed quite a bit.
3699 Gnuplot.py version 1.7, whose internal names changed quite a bit.
3694 While I tested this and it looks ok, there may still be corner
3700 While I tested this and it looks ok, there may still be corner
3695 cases I've missed.
3701 cases I've missed.
3696
3702
3697 2003-12-01 Fernando Perez <fperez@colorado.edu>
3703 2003-12-01 Fernando Perez <fperez@colorado.edu>
3698
3704
3699 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
3705 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
3700 where a line like 'p,q=1,2' would fail because the automagic
3706 where a line like 'p,q=1,2' would fail because the automagic
3701 system would be triggered for @p.
3707 system would be triggered for @p.
3702
3708
3703 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
3709 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
3704 cleanups, code unmodified.
3710 cleanups, code unmodified.
3705
3711
3706 * IPython/genutils.py (Term): added a class for IPython to handle
3712 * IPython/genutils.py (Term): added a class for IPython to handle
3707 output. In most cases it will just be a proxy for stdout/err, but
3713 output. In most cases it will just be a proxy for stdout/err, but
3708 having this allows modifications to be made for some platforms,
3714 having this allows modifications to be made for some platforms,
3709 such as handling color escapes under Windows. All of this code
3715 such as handling color escapes under Windows. All of this code
3710 was contributed by Gary Bishop, with minor modifications by me.
3716 was contributed by Gary Bishop, with minor modifications by me.
3711 The actual changes affect many files.
3717 The actual changes affect many files.
3712
3718
3713 2003-11-30 Fernando Perez <fperez@colorado.edu>
3719 2003-11-30 Fernando Perez <fperez@colorado.edu>
3714
3720
3715 * IPython/iplib.py (file_matches): new completion code, courtesy
3721 * IPython/iplib.py (file_matches): new completion code, courtesy
3716 of Jeff Collins. This enables filename completion again under
3722 of Jeff Collins. This enables filename completion again under
3717 python 2.3, which disabled it at the C level.
3723 python 2.3, which disabled it at the C level.
3718
3724
3719 2003-11-11 Fernando Perez <fperez@colorado.edu>
3725 2003-11-11 Fernando Perez <fperez@colorado.edu>
3720
3726
3721 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
3727 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
3722 for Numeric.array(map(...)), but often convenient.
3728 for Numeric.array(map(...)), but often convenient.
3723
3729
3724 2003-11-05 Fernando Perez <fperez@colorado.edu>
3730 2003-11-05 Fernando Perez <fperez@colorado.edu>
3725
3731
3726 * IPython/numutils.py (frange): Changed a call from int() to
3732 * IPython/numutils.py (frange): Changed a call from int() to
3727 int(round()) to prevent a problem reported with arange() in the
3733 int(round()) to prevent a problem reported with arange() in the
3728 numpy list.
3734 numpy list.
3729
3735
3730 2003-10-06 Fernando Perez <fperez@colorado.edu>
3736 2003-10-06 Fernando Perez <fperez@colorado.edu>
3731
3737
3732 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
3738 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
3733 prevent crashes if sys lacks an argv attribute (it happens with
3739 prevent crashes if sys lacks an argv attribute (it happens with
3734 embedded interpreters which build a bare-bones sys module).
3740 embedded interpreters which build a bare-bones sys module).
3735 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
3741 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
3736
3742
3737 2003-09-24 Fernando Perez <fperez@colorado.edu>
3743 2003-09-24 Fernando Perez <fperez@colorado.edu>
3738
3744
3739 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
3745 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
3740 to protect against poorly written user objects where __getattr__
3746 to protect against poorly written user objects where __getattr__
3741 raises exceptions other than AttributeError. Thanks to a bug
3747 raises exceptions other than AttributeError. Thanks to a bug
3742 report by Oliver Sander <osander-AT-gmx.de>.
3748 report by Oliver Sander <osander-AT-gmx.de>.
3743
3749
3744 * IPython/FakeModule.py (FakeModule.__repr__): this method was
3750 * IPython/FakeModule.py (FakeModule.__repr__): this method was
3745 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
3751 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
3746
3752
3747 2003-09-09 Fernando Perez <fperez@colorado.edu>
3753 2003-09-09 Fernando Perez <fperez@colorado.edu>
3748
3754
3749 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
3755 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
3750 unpacking a list whith a callable as first element would
3756 unpacking a list whith a callable as first element would
3751 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
3757 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
3752 Collins.
3758 Collins.
3753
3759
3754 2003-08-25 *** Released version 0.5.0
3760 2003-08-25 *** Released version 0.5.0
3755
3761
3756 2003-08-22 Fernando Perez <fperez@colorado.edu>
3762 2003-08-22 Fernando Perez <fperez@colorado.edu>
3757
3763
3758 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
3764 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
3759 improperly defined user exceptions. Thanks to feedback from Mark
3765 improperly defined user exceptions. Thanks to feedback from Mark
3760 Russell <mrussell-AT-verio.net>.
3766 Russell <mrussell-AT-verio.net>.
3761
3767
3762 2003-08-20 Fernando Perez <fperez@colorado.edu>
3768 2003-08-20 Fernando Perez <fperez@colorado.edu>
3763
3769
3764 * IPython/OInspect.py (Inspector.pinfo): changed String Form
3770 * IPython/OInspect.py (Inspector.pinfo): changed String Form
3765 printing so that it would print multi-line string forms starting
3771 printing so that it would print multi-line string forms starting
3766 with a new line. This way the formatting is better respected for
3772 with a new line. This way the formatting is better respected for
3767 objects which work hard to make nice string forms.
3773 objects which work hard to make nice string forms.
3768
3774
3769 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
3775 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
3770 autocall would overtake data access for objects with both
3776 autocall would overtake data access for objects with both
3771 __getitem__ and __call__.
3777 __getitem__ and __call__.
3772
3778
3773 2003-08-19 *** Released version 0.5.0-rc1
3779 2003-08-19 *** Released version 0.5.0-rc1
3774
3780
3775 2003-08-19 Fernando Perez <fperez@colorado.edu>
3781 2003-08-19 Fernando Perez <fperez@colorado.edu>
3776
3782
3777 * IPython/deep_reload.py (load_tail): single tiny change here
3783 * IPython/deep_reload.py (load_tail): single tiny change here
3778 seems to fix the long-standing bug of dreload() failing to work
3784 seems to fix the long-standing bug of dreload() failing to work
3779 for dotted names. But this module is pretty tricky, so I may have
3785 for dotted names. But this module is pretty tricky, so I may have
3780 missed some subtlety. Needs more testing!.
3786 missed some subtlety. Needs more testing!.
3781
3787
3782 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
3788 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
3783 exceptions which have badly implemented __str__ methods.
3789 exceptions which have badly implemented __str__ methods.
3784 (VerboseTB.text): harden against inspect.getinnerframes crashing,
3790 (VerboseTB.text): harden against inspect.getinnerframes crashing,
3785 which I've been getting reports about from Python 2.3 users. I
3791 which I've been getting reports about from Python 2.3 users. I
3786 wish I had a simple test case to reproduce the problem, so I could
3792 wish I had a simple test case to reproduce the problem, so I could
3787 either write a cleaner workaround or file a bug report if
3793 either write a cleaner workaround or file a bug report if
3788 necessary.
3794 necessary.
3789
3795
3790 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
3796 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
3791 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
3797 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
3792 a bug report by Tjabo Kloppenburg.
3798 a bug report by Tjabo Kloppenburg.
3793
3799
3794 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
3800 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
3795 crashes. Wrapped the pdb call in a blanket try/except, since pdb
3801 crashes. Wrapped the pdb call in a blanket try/except, since pdb
3796 seems rather unstable. Thanks to a bug report by Tjabo
3802 seems rather unstable. Thanks to a bug report by Tjabo
3797 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
3803 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
3798
3804
3799 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
3805 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
3800 this out soon because of the critical fixes in the inner loop for
3806 this out soon because of the critical fixes in the inner loop for
3801 generators.
3807 generators.
3802
3808
3803 * IPython/Magic.py (Magic.getargspec): removed. This (and
3809 * IPython/Magic.py (Magic.getargspec): removed. This (and
3804 _get_def) have been obsoleted by OInspect for a long time, I
3810 _get_def) have been obsoleted by OInspect for a long time, I
3805 hadn't noticed that they were dead code.
3811 hadn't noticed that they were dead code.
3806 (Magic._ofind): restored _ofind functionality for a few literals
3812 (Magic._ofind): restored _ofind functionality for a few literals
3807 (those in ["''",'""','[]','{}','()']). But it won't work anymore
3813 (those in ["''",'""','[]','{}','()']). But it won't work anymore
3808 for things like "hello".capitalize?, since that would require a
3814 for things like "hello".capitalize?, since that would require a
3809 potentially dangerous eval() again.
3815 potentially dangerous eval() again.
3810
3816
3811 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
3817 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
3812 logic a bit more to clean up the escapes handling and minimize the
3818 logic a bit more to clean up the escapes handling and minimize the
3813 use of _ofind to only necessary cases. The interactive 'feel' of
3819 use of _ofind to only necessary cases. The interactive 'feel' of
3814 IPython should have improved quite a bit with the changes in
3820 IPython should have improved quite a bit with the changes in
3815 _prefilter and _ofind (besides being far safer than before).
3821 _prefilter and _ofind (besides being far safer than before).
3816
3822
3817 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
3823 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
3818 obscure, never reported). Edit would fail to find the object to
3824 obscure, never reported). Edit would fail to find the object to
3819 edit under some circumstances.
3825 edit under some circumstances.
3820 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
3826 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
3821 which were causing double-calling of generators. Those eval calls
3827 which were causing double-calling of generators. Those eval calls
3822 were _very_ dangerous, since code with side effects could be
3828 were _very_ dangerous, since code with side effects could be
3823 triggered. As they say, 'eval is evil'... These were the
3829 triggered. As they say, 'eval is evil'... These were the
3824 nastiest evals in IPython. Besides, _ofind is now far simpler,
3830 nastiest evals in IPython. Besides, _ofind is now far simpler,
3825 and it should also be quite a bit faster. Its use of inspect is
3831 and it should also be quite a bit faster. Its use of inspect is
3826 also safer, so perhaps some of the inspect-related crashes I've
3832 also safer, so perhaps some of the inspect-related crashes I've
3827 seen lately with Python 2.3 might be taken care of. That will
3833 seen lately with Python 2.3 might be taken care of. That will
3828 need more testing.
3834 need more testing.
3829
3835
3830 2003-08-17 Fernando Perez <fperez@colorado.edu>
3836 2003-08-17 Fernando Perez <fperez@colorado.edu>
3831
3837
3832 * IPython/iplib.py (InteractiveShell._prefilter): significant
3838 * IPython/iplib.py (InteractiveShell._prefilter): significant
3833 simplifications to the logic for handling user escapes. Faster
3839 simplifications to the logic for handling user escapes. Faster
3834 and simpler code.
3840 and simpler code.
3835
3841
3836 2003-08-14 Fernando Perez <fperez@colorado.edu>
3842 2003-08-14 Fernando Perez <fperez@colorado.edu>
3837
3843
3838 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
3844 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
3839 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
3845 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
3840 but it should be quite a bit faster. And the recursive version
3846 but it should be quite a bit faster. And the recursive version
3841 generated O(log N) intermediate storage for all rank>1 arrays,
3847 generated O(log N) intermediate storage for all rank>1 arrays,
3842 even if they were contiguous.
3848 even if they were contiguous.
3843 (l1norm): Added this function.
3849 (l1norm): Added this function.
3844 (norm): Added this function for arbitrary norms (including
3850 (norm): Added this function for arbitrary norms (including
3845 l-infinity). l1 and l2 are still special cases for convenience
3851 l-infinity). l1 and l2 are still special cases for convenience
3846 and speed.
3852 and speed.
3847
3853
3848 2003-08-03 Fernando Perez <fperez@colorado.edu>
3854 2003-08-03 Fernando Perez <fperez@colorado.edu>
3849
3855
3850 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
3856 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
3851 exceptions, which now raise PendingDeprecationWarnings in Python
3857 exceptions, which now raise PendingDeprecationWarnings in Python
3852 2.3. There were some in Magic and some in Gnuplot2.
3858 2.3. There were some in Magic and some in Gnuplot2.
3853
3859
3854 2003-06-30 Fernando Perez <fperez@colorado.edu>
3860 2003-06-30 Fernando Perez <fperez@colorado.edu>
3855
3861
3856 * IPython/genutils.py (page): modified to call curses only for
3862 * IPython/genutils.py (page): modified to call curses only for
3857 terminals where TERM=='xterm'. After problems under many other
3863 terminals where TERM=='xterm'. After problems under many other
3858 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
3864 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
3859
3865
3860 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
3866 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
3861 would be triggered when readline was absent. This was just an old
3867 would be triggered when readline was absent. This was just an old
3862 debugging statement I'd forgotten to take out.
3868 debugging statement I'd forgotten to take out.
3863
3869
3864 2003-06-20 Fernando Perez <fperez@colorado.edu>
3870 2003-06-20 Fernando Perez <fperez@colorado.edu>
3865
3871
3866 * IPython/genutils.py (clock): modified to return only user time
3872 * IPython/genutils.py (clock): modified to return only user time
3867 (not counting system time), after a discussion on scipy. While
3873 (not counting system time), after a discussion on scipy. While
3868 system time may be a useful quantity occasionally, it may much
3874 system time may be a useful quantity occasionally, it may much
3869 more easily be skewed by occasional swapping or other similar
3875 more easily be skewed by occasional swapping or other similar
3870 activity.
3876 activity.
3871
3877
3872 2003-06-05 Fernando Perez <fperez@colorado.edu>
3878 2003-06-05 Fernando Perez <fperez@colorado.edu>
3873
3879
3874 * IPython/numutils.py (identity): new function, for building
3880 * IPython/numutils.py (identity): new function, for building
3875 arbitrary rank Kronecker deltas (mostly backwards compatible with
3881 arbitrary rank Kronecker deltas (mostly backwards compatible with
3876 Numeric.identity)
3882 Numeric.identity)
3877
3883
3878 2003-06-03 Fernando Perez <fperez@colorado.edu>
3884 2003-06-03 Fernando Perez <fperez@colorado.edu>
3879
3885
3880 * IPython/iplib.py (InteractiveShell.handle_magic): protect
3886 * IPython/iplib.py (InteractiveShell.handle_magic): protect
3881 arguments passed to magics with spaces, to allow trailing '\' to
3887 arguments passed to magics with spaces, to allow trailing '\' to
3882 work normally (mainly for Windows users).
3888 work normally (mainly for Windows users).
3883
3889
3884 2003-05-29 Fernando Perez <fperez@colorado.edu>
3890 2003-05-29 Fernando Perez <fperez@colorado.edu>
3885
3891
3886 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
3892 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
3887 instead of pydoc.help. This fixes a bizarre behavior where
3893 instead of pydoc.help. This fixes a bizarre behavior where
3888 printing '%s' % locals() would trigger the help system. Now
3894 printing '%s' % locals() would trigger the help system. Now
3889 ipython behaves like normal python does.
3895 ipython behaves like normal python does.
3890
3896
3891 Note that if one does 'from pydoc import help', the bizarre
3897 Note that if one does 'from pydoc import help', the bizarre
3892 behavior returns, but this will also happen in normal python, so
3898 behavior returns, but this will also happen in normal python, so
3893 it's not an ipython bug anymore (it has to do with how pydoc.help
3899 it's not an ipython bug anymore (it has to do with how pydoc.help
3894 is implemented).
3900 is implemented).
3895
3901
3896 2003-05-22 Fernando Perez <fperez@colorado.edu>
3902 2003-05-22 Fernando Perez <fperez@colorado.edu>
3897
3903
3898 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
3904 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
3899 return [] instead of None when nothing matches, also match to end
3905 return [] instead of None when nothing matches, also match to end
3900 of line. Patch by Gary Bishop.
3906 of line. Patch by Gary Bishop.
3901
3907
3902 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
3908 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
3903 protection as before, for files passed on the command line. This
3909 protection as before, for files passed on the command line. This
3904 prevents the CrashHandler from kicking in if user files call into
3910 prevents the CrashHandler from kicking in if user files call into
3905 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
3911 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
3906 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
3912 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
3907
3913
3908 2003-05-20 *** Released version 0.4.0
3914 2003-05-20 *** Released version 0.4.0
3909
3915
3910 2003-05-20 Fernando Perez <fperez@colorado.edu>
3916 2003-05-20 Fernando Perez <fperez@colorado.edu>
3911
3917
3912 * setup.py: added support for manpages. It's a bit hackish b/c of
3918 * setup.py: added support for manpages. It's a bit hackish b/c of
3913 a bug in the way the bdist_rpm distutils target handles gzipped
3919 a bug in the way the bdist_rpm distutils target handles gzipped
3914 manpages, but it works. After a patch by Jack.
3920 manpages, but it works. After a patch by Jack.
3915
3921
3916 2003-05-19 Fernando Perez <fperez@colorado.edu>
3922 2003-05-19 Fernando Perez <fperez@colorado.edu>
3917
3923
3918 * IPython/numutils.py: added a mockup of the kinds module, since
3924 * IPython/numutils.py: added a mockup of the kinds module, since
3919 it was recently removed from Numeric. This way, numutils will
3925 it was recently removed from Numeric. This way, numutils will
3920 work for all users even if they are missing kinds.
3926 work for all users even if they are missing kinds.
3921
3927
3922 * IPython/Magic.py (Magic._ofind): Harden against an inspect
3928 * IPython/Magic.py (Magic._ofind): Harden against an inspect
3923 failure, which can occur with SWIG-wrapped extensions. After a
3929 failure, which can occur with SWIG-wrapped extensions. After a
3924 crash report from Prabhu.
3930 crash report from Prabhu.
3925
3931
3926 2003-05-16 Fernando Perez <fperez@colorado.edu>
3932 2003-05-16 Fernando Perez <fperez@colorado.edu>
3927
3933
3928 * IPython/iplib.py (InteractiveShell.excepthook): New method to
3934 * IPython/iplib.py (InteractiveShell.excepthook): New method to
3929 protect ipython from user code which may call directly
3935 protect ipython from user code which may call directly
3930 sys.excepthook (this looks like an ipython crash to the user, even
3936 sys.excepthook (this looks like an ipython crash to the user, even
3931 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
3937 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
3932 This is especially important to help users of WxWindows, but may
3938 This is especially important to help users of WxWindows, but may
3933 also be useful in other cases.
3939 also be useful in other cases.
3934
3940
3935 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
3941 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
3936 an optional tb_offset to be specified, and to preserve exception
3942 an optional tb_offset to be specified, and to preserve exception
3937 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
3943 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
3938
3944
3939 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
3945 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
3940
3946
3941 2003-05-15 Fernando Perez <fperez@colorado.edu>
3947 2003-05-15 Fernando Perez <fperez@colorado.edu>
3942
3948
3943 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
3949 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
3944 installing for a new user under Windows.
3950 installing for a new user under Windows.
3945
3951
3946 2003-05-12 Fernando Perez <fperez@colorado.edu>
3952 2003-05-12 Fernando Perez <fperez@colorado.edu>
3947
3953
3948 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
3954 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
3949 handler for Emacs comint-based lines. Currently it doesn't do
3955 handler for Emacs comint-based lines. Currently it doesn't do
3950 much (but importantly, it doesn't update the history cache). In
3956 much (but importantly, it doesn't update the history cache). In
3951 the future it may be expanded if Alex needs more functionality
3957 the future it may be expanded if Alex needs more functionality
3952 there.
3958 there.
3953
3959
3954 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
3960 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
3955 info to crash reports.
3961 info to crash reports.
3956
3962
3957 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
3963 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
3958 just like Python's -c. Also fixed crash with invalid -color
3964 just like Python's -c. Also fixed crash with invalid -color
3959 option value at startup. Thanks to Will French
3965 option value at startup. Thanks to Will French
3960 <wfrench-AT-bestweb.net> for the bug report.
3966 <wfrench-AT-bestweb.net> for the bug report.
3961
3967
3962 2003-05-09 Fernando Perez <fperez@colorado.edu>
3968 2003-05-09 Fernando Perez <fperez@colorado.edu>
3963
3969
3964 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
3970 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
3965 to EvalDict (it's a mapping, after all) and simplified its code
3971 to EvalDict (it's a mapping, after all) and simplified its code
3966 quite a bit, after a nice discussion on c.l.py where Gustavo
3972 quite a bit, after a nice discussion on c.l.py where Gustavo
3967 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
3973 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
3968
3974
3969 2003-04-30 Fernando Perez <fperez@colorado.edu>
3975 2003-04-30 Fernando Perez <fperez@colorado.edu>
3970
3976
3971 * IPython/genutils.py (timings_out): modified it to reduce its
3977 * IPython/genutils.py (timings_out): modified it to reduce its
3972 overhead in the common reps==1 case.
3978 overhead in the common reps==1 case.
3973
3979
3974 2003-04-29 Fernando Perez <fperez@colorado.edu>
3980 2003-04-29 Fernando Perez <fperez@colorado.edu>
3975
3981
3976 * IPython/genutils.py (timings_out): Modified to use the resource
3982 * IPython/genutils.py (timings_out): Modified to use the resource
3977 module, which avoids the wraparound problems of time.clock().
3983 module, which avoids the wraparound problems of time.clock().
3978
3984
3979 2003-04-17 *** Released version 0.2.15pre4
3985 2003-04-17 *** Released version 0.2.15pre4
3980
3986
3981 2003-04-17 Fernando Perez <fperez@colorado.edu>
3987 2003-04-17 Fernando Perez <fperez@colorado.edu>
3982
3988
3983 * setup.py (scriptfiles): Split windows-specific stuff over to a
3989 * setup.py (scriptfiles): Split windows-specific stuff over to a
3984 separate file, in an attempt to have a Windows GUI installer.
3990 separate file, in an attempt to have a Windows GUI installer.
3985 That didn't work, but part of the groundwork is done.
3991 That didn't work, but part of the groundwork is done.
3986
3992
3987 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
3993 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
3988 indent/unindent with 4 spaces. Particularly useful in combination
3994 indent/unindent with 4 spaces. Particularly useful in combination
3989 with the new auto-indent option.
3995 with the new auto-indent option.
3990
3996
3991 2003-04-16 Fernando Perez <fperez@colorado.edu>
3997 2003-04-16 Fernando Perez <fperez@colorado.edu>
3992
3998
3993 * IPython/Magic.py: various replacements of self.rc for
3999 * IPython/Magic.py: various replacements of self.rc for
3994 self.shell.rc. A lot more remains to be done to fully disentangle
4000 self.shell.rc. A lot more remains to be done to fully disentangle
3995 this class from the main Shell class.
4001 this class from the main Shell class.
3996
4002
3997 * IPython/GnuplotRuntime.py: added checks for mouse support so
4003 * IPython/GnuplotRuntime.py: added checks for mouse support so
3998 that we don't try to enable it if the current gnuplot doesn't
4004 that we don't try to enable it if the current gnuplot doesn't
3999 really support it. Also added checks so that we don't try to
4005 really support it. Also added checks so that we don't try to
4000 enable persist under Windows (where Gnuplot doesn't recognize the
4006 enable persist under Windows (where Gnuplot doesn't recognize the
4001 option).
4007 option).
4002
4008
4003 * IPython/iplib.py (InteractiveShell.interact): Added optional
4009 * IPython/iplib.py (InteractiveShell.interact): Added optional
4004 auto-indenting code, after a patch by King C. Shu
4010 auto-indenting code, after a patch by King C. Shu
4005 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
4011 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
4006 get along well with pasting indented code. If I ever figure out
4012 get along well with pasting indented code. If I ever figure out
4007 how to make that part go well, it will become on by default.
4013 how to make that part go well, it will become on by default.
4008
4014
4009 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
4015 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
4010 crash ipython if there was an unmatched '%' in the user's prompt
4016 crash ipython if there was an unmatched '%' in the user's prompt
4011 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
4017 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
4012
4018
4013 * IPython/iplib.py (InteractiveShell.interact): removed the
4019 * IPython/iplib.py (InteractiveShell.interact): removed the
4014 ability to ask the user whether he wants to crash or not at the
4020 ability to ask the user whether he wants to crash or not at the
4015 'last line' exception handler. Calling functions at that point
4021 'last line' exception handler. Calling functions at that point
4016 changes the stack, and the error reports would have incorrect
4022 changes the stack, and the error reports would have incorrect
4017 tracebacks.
4023 tracebacks.
4018
4024
4019 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
4025 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
4020 pass through a peger a pretty-printed form of any object. After a
4026 pass through a peger a pretty-printed form of any object. After a
4021 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
4027 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
4022
4028
4023 2003-04-14 Fernando Perez <fperez@colorado.edu>
4029 2003-04-14 Fernando Perez <fperez@colorado.edu>
4024
4030
4025 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
4031 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
4026 all files in ~ would be modified at first install (instead of
4032 all files in ~ would be modified at first install (instead of
4027 ~/.ipython). This could be potentially disastrous, as the
4033 ~/.ipython). This could be potentially disastrous, as the
4028 modification (make line-endings native) could damage binary files.
4034 modification (make line-endings native) could damage binary files.
4029
4035
4030 2003-04-10 Fernando Perez <fperez@colorado.edu>
4036 2003-04-10 Fernando Perez <fperez@colorado.edu>
4031
4037
4032 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
4038 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
4033 handle only lines which are invalid python. This now means that
4039 handle only lines which are invalid python. This now means that
4034 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
4040 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
4035 for the bug report.
4041 for the bug report.
4036
4042
4037 2003-04-01 Fernando Perez <fperez@colorado.edu>
4043 2003-04-01 Fernando Perez <fperez@colorado.edu>
4038
4044
4039 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
4045 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
4040 where failing to set sys.last_traceback would crash pdb.pm().
4046 where failing to set sys.last_traceback would crash pdb.pm().
4041 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
4047 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
4042 report.
4048 report.
4043
4049
4044 2003-03-25 Fernando Perez <fperez@colorado.edu>
4050 2003-03-25 Fernando Perez <fperez@colorado.edu>
4045
4051
4046 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
4052 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
4047 before printing it (it had a lot of spurious blank lines at the
4053 before printing it (it had a lot of spurious blank lines at the
4048 end).
4054 end).
4049
4055
4050 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
4056 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
4051 output would be sent 21 times! Obviously people don't use this
4057 output would be sent 21 times! Obviously people don't use this
4052 too often, or I would have heard about it.
4058 too often, or I would have heard about it.
4053
4059
4054 2003-03-24 Fernando Perez <fperez@colorado.edu>
4060 2003-03-24 Fernando Perez <fperez@colorado.edu>
4055
4061
4056 * setup.py (scriptfiles): renamed the data_files parameter from
4062 * setup.py (scriptfiles): renamed the data_files parameter from
4057 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
4063 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
4058 for the patch.
4064 for the patch.
4059
4065
4060 2003-03-20 Fernando Perez <fperez@colorado.edu>
4066 2003-03-20 Fernando Perez <fperez@colorado.edu>
4061
4067
4062 * IPython/genutils.py (error): added error() and fatal()
4068 * IPython/genutils.py (error): added error() and fatal()
4063 functions.
4069 functions.
4064
4070
4065 2003-03-18 *** Released version 0.2.15pre3
4071 2003-03-18 *** Released version 0.2.15pre3
4066
4072
4067 2003-03-18 Fernando Perez <fperez@colorado.edu>
4073 2003-03-18 Fernando Perez <fperez@colorado.edu>
4068
4074
4069 * setupext/install_data_ext.py
4075 * setupext/install_data_ext.py
4070 (install_data_ext.initialize_options): Class contributed by Jack
4076 (install_data_ext.initialize_options): Class contributed by Jack
4071 Moffit for fixing the old distutils hack. He is sending this to
4077 Moffit for fixing the old distutils hack. He is sending this to
4072 the distutils folks so in the future we may not need it as a
4078 the distutils folks so in the future we may not need it as a
4073 private fix.
4079 private fix.
4074
4080
4075 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
4081 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
4076 changes for Debian packaging. See his patch for full details.
4082 changes for Debian packaging. See his patch for full details.
4077 The old distutils hack of making the ipythonrc* files carry a
4083 The old distutils hack of making the ipythonrc* files carry a
4078 bogus .py extension is gone, at last. Examples were moved to a
4084 bogus .py extension is gone, at last. Examples were moved to a
4079 separate subdir under doc/, and the separate executable scripts
4085 separate subdir under doc/, and the separate executable scripts
4080 now live in their own directory. Overall a great cleanup. The
4086 now live in their own directory. Overall a great cleanup. The
4081 manual was updated to use the new files, and setup.py has been
4087 manual was updated to use the new files, and setup.py has been
4082 fixed for this setup.
4088 fixed for this setup.
4083
4089
4084 * IPython/PyColorize.py (Parser.usage): made non-executable and
4090 * IPython/PyColorize.py (Parser.usage): made non-executable and
4085 created a pycolor wrapper around it to be included as a script.
4091 created a pycolor wrapper around it to be included as a script.
4086
4092
4087 2003-03-12 *** Released version 0.2.15pre2
4093 2003-03-12 *** Released version 0.2.15pre2
4088
4094
4089 2003-03-12 Fernando Perez <fperez@colorado.edu>
4095 2003-03-12 Fernando Perez <fperez@colorado.edu>
4090
4096
4091 * IPython/ColorANSI.py (make_color_table): Finally fixed the
4097 * IPython/ColorANSI.py (make_color_table): Finally fixed the
4092 long-standing problem with garbage characters in some terminals.
4098 long-standing problem with garbage characters in some terminals.
4093 The issue was really that the \001 and \002 escapes must _only_ be
4099 The issue was really that the \001 and \002 escapes must _only_ be
4094 passed to input prompts (which call readline), but _never_ to
4100 passed to input prompts (which call readline), but _never_ to
4095 normal text to be printed on screen. I changed ColorANSI to have
4101 normal text to be printed on screen. I changed ColorANSI to have
4096 two classes: TermColors and InputTermColors, each with the
4102 two classes: TermColors and InputTermColors, each with the
4097 appropriate escapes for input prompts or normal text. The code in
4103 appropriate escapes for input prompts or normal text. The code in
4098 Prompts.py got slightly more complicated, but this very old and
4104 Prompts.py got slightly more complicated, but this very old and
4099 annoying bug is finally fixed.
4105 annoying bug is finally fixed.
4100
4106
4101 All the credit for nailing down the real origin of this problem
4107 All the credit for nailing down the real origin of this problem
4102 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
4108 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
4103 *Many* thanks to him for spending quite a bit of effort on this.
4109 *Many* thanks to him for spending quite a bit of effort on this.
4104
4110
4105 2003-03-05 *** Released version 0.2.15pre1
4111 2003-03-05 *** Released version 0.2.15pre1
4106
4112
4107 2003-03-03 Fernando Perez <fperez@colorado.edu>
4113 2003-03-03 Fernando Perez <fperez@colorado.edu>
4108
4114
4109 * IPython/FakeModule.py: Moved the former _FakeModule to a
4115 * IPython/FakeModule.py: Moved the former _FakeModule to a
4110 separate file, because it's also needed by Magic (to fix a similar
4116 separate file, because it's also needed by Magic (to fix a similar
4111 pickle-related issue in @run).
4117 pickle-related issue in @run).
4112
4118
4113 2003-03-02 Fernando Perez <fperez@colorado.edu>
4119 2003-03-02 Fernando Perez <fperez@colorado.edu>
4114
4120
4115 * IPython/Magic.py (Magic.magic_autocall): new magic to control
4121 * IPython/Magic.py (Magic.magic_autocall): new magic to control
4116 the autocall option at runtime.
4122 the autocall option at runtime.
4117 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
4123 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
4118 across Magic.py to start separating Magic from InteractiveShell.
4124 across Magic.py to start separating Magic from InteractiveShell.
4119 (Magic._ofind): Fixed to return proper namespace for dotted
4125 (Magic._ofind): Fixed to return proper namespace for dotted
4120 names. Before, a dotted name would always return 'not currently
4126 names. Before, a dotted name would always return 'not currently
4121 defined', because it would find the 'parent'. s.x would be found,
4127 defined', because it would find the 'parent'. s.x would be found,
4122 but since 'x' isn't defined by itself, it would get confused.
4128 but since 'x' isn't defined by itself, it would get confused.
4123 (Magic.magic_run): Fixed pickling problems reported by Ralf
4129 (Magic.magic_run): Fixed pickling problems reported by Ralf
4124 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
4130 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
4125 that I'd used when Mike Heeter reported similar issues at the
4131 that I'd used when Mike Heeter reported similar issues at the
4126 top-level, but now for @run. It boils down to injecting the
4132 top-level, but now for @run. It boils down to injecting the
4127 namespace where code is being executed with something that looks
4133 namespace where code is being executed with something that looks
4128 enough like a module to fool pickle.dump(). Since a pickle stores
4134 enough like a module to fool pickle.dump(). Since a pickle stores
4129 a named reference to the importing module, we need this for
4135 a named reference to the importing module, we need this for
4130 pickles to save something sensible.
4136 pickles to save something sensible.
4131
4137
4132 * IPython/ipmaker.py (make_IPython): added an autocall option.
4138 * IPython/ipmaker.py (make_IPython): added an autocall option.
4133
4139
4134 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
4140 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
4135 the auto-eval code. Now autocalling is an option, and the code is
4141 the auto-eval code. Now autocalling is an option, and the code is
4136 also vastly safer. There is no more eval() involved at all.
4142 also vastly safer. There is no more eval() involved at all.
4137
4143
4138 2003-03-01 Fernando Perez <fperez@colorado.edu>
4144 2003-03-01 Fernando Perez <fperez@colorado.edu>
4139
4145
4140 * IPython/Magic.py (Magic._ofind): Changed interface to return a
4146 * IPython/Magic.py (Magic._ofind): Changed interface to return a
4141 dict with named keys instead of a tuple.
4147 dict with named keys instead of a tuple.
4142
4148
4143 * IPython: Started using CVS for IPython as of 0.2.15pre1.
4149 * IPython: Started using CVS for IPython as of 0.2.15pre1.
4144
4150
4145 * setup.py (make_shortcut): Fixed message about directories
4151 * setup.py (make_shortcut): Fixed message about directories
4146 created during Windows installation (the directories were ok, just
4152 created during Windows installation (the directories were ok, just
4147 the printed message was misleading). Thanks to Chris Liechti
4153 the printed message was misleading). Thanks to Chris Liechti
4148 <cliechti-AT-gmx.net> for the heads up.
4154 <cliechti-AT-gmx.net> for the heads up.
4149
4155
4150 2003-02-21 Fernando Perez <fperez@colorado.edu>
4156 2003-02-21 Fernando Perez <fperez@colorado.edu>
4151
4157
4152 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
4158 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
4153 of ValueError exception when checking for auto-execution. This
4159 of ValueError exception when checking for auto-execution. This
4154 one is raised by things like Numeric arrays arr.flat when the
4160 one is raised by things like Numeric arrays arr.flat when the
4155 array is non-contiguous.
4161 array is non-contiguous.
4156
4162
4157 2003-01-31 Fernando Perez <fperez@colorado.edu>
4163 2003-01-31 Fernando Perez <fperez@colorado.edu>
4158
4164
4159 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
4165 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
4160 not return any value at all (even though the command would get
4166 not return any value at all (even though the command would get
4161 executed).
4167 executed).
4162 (xsys): Flush stdout right after printing the command to ensure
4168 (xsys): Flush stdout right after printing the command to ensure
4163 proper ordering of commands and command output in the total
4169 proper ordering of commands and command output in the total
4164 output.
4170 output.
4165 (SystemExec/xsys/bq): Switched the names of xsys/bq and
4171 (SystemExec/xsys/bq): Switched the names of xsys/bq and
4166 system/getoutput as defaults. The old ones are kept for
4172 system/getoutput as defaults. The old ones are kept for
4167 compatibility reasons, so no code which uses this library needs
4173 compatibility reasons, so no code which uses this library needs
4168 changing.
4174 changing.
4169
4175
4170 2003-01-27 *** Released version 0.2.14
4176 2003-01-27 *** Released version 0.2.14
4171
4177
4172 2003-01-25 Fernando Perez <fperez@colorado.edu>
4178 2003-01-25 Fernando Perez <fperez@colorado.edu>
4173
4179
4174 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
4180 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
4175 functions defined in previous edit sessions could not be re-edited
4181 functions defined in previous edit sessions could not be re-edited
4176 (because the temp files were immediately removed). Now temp files
4182 (because the temp files were immediately removed). Now temp files
4177 are removed only at IPython's exit.
4183 are removed only at IPython's exit.
4178 (Magic.magic_run): Improved @run to perform shell-like expansions
4184 (Magic.magic_run): Improved @run to perform shell-like expansions
4179 on its arguments (~users and $VARS). With this, @run becomes more
4185 on its arguments (~users and $VARS). With this, @run becomes more
4180 like a normal command-line.
4186 like a normal command-line.
4181
4187
4182 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
4188 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
4183 bugs related to embedding and cleaned up that code. A fairly
4189 bugs related to embedding and cleaned up that code. A fairly
4184 important one was the impossibility to access the global namespace
4190 important one was the impossibility to access the global namespace
4185 through the embedded IPython (only local variables were visible).
4191 through the embedded IPython (only local variables were visible).
4186
4192
4187 2003-01-14 Fernando Perez <fperez@colorado.edu>
4193 2003-01-14 Fernando Perez <fperez@colorado.edu>
4188
4194
4189 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
4195 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
4190 auto-calling to be a bit more conservative. Now it doesn't get
4196 auto-calling to be a bit more conservative. Now it doesn't get
4191 triggered if any of '!=()<>' are in the rest of the input line, to
4197 triggered if any of '!=()<>' are in the rest of the input line, to
4192 allow comparing callables. Thanks to Alex for the heads up.
4198 allow comparing callables. Thanks to Alex for the heads up.
4193
4199
4194 2003-01-07 Fernando Perez <fperez@colorado.edu>
4200 2003-01-07 Fernando Perez <fperez@colorado.edu>
4195
4201
4196 * IPython/genutils.py (page): fixed estimation of the number of
4202 * IPython/genutils.py (page): fixed estimation of the number of
4197 lines in a string to be paged to simply count newlines. This
4203 lines in a string to be paged to simply count newlines. This
4198 prevents over-guessing due to embedded escape sequences. A better
4204 prevents over-guessing due to embedded escape sequences. A better
4199 long-term solution would involve stripping out the control chars
4205 long-term solution would involve stripping out the control chars
4200 for the count, but it's potentially so expensive I just don't
4206 for the count, but it's potentially so expensive I just don't
4201 think it's worth doing.
4207 think it's worth doing.
4202
4208
4203 2002-12-19 *** Released version 0.2.14pre50
4209 2002-12-19 *** Released version 0.2.14pre50
4204
4210
4205 2002-12-19 Fernando Perez <fperez@colorado.edu>
4211 2002-12-19 Fernando Perez <fperez@colorado.edu>
4206
4212
4207 * tools/release (version): Changed release scripts to inform
4213 * tools/release (version): Changed release scripts to inform
4208 Andrea and build a NEWS file with a list of recent changes.
4214 Andrea and build a NEWS file with a list of recent changes.
4209
4215
4210 * IPython/ColorANSI.py (__all__): changed terminal detection
4216 * IPython/ColorANSI.py (__all__): changed terminal detection
4211 code. Seems to work better for xterms without breaking
4217 code. Seems to work better for xterms without breaking
4212 konsole. Will need more testing to determine if WinXP and Mac OSX
4218 konsole. Will need more testing to determine if WinXP and Mac OSX
4213 also work ok.
4219 also work ok.
4214
4220
4215 2002-12-18 *** Released version 0.2.14pre49
4221 2002-12-18 *** Released version 0.2.14pre49
4216
4222
4217 2002-12-18 Fernando Perez <fperez@colorado.edu>
4223 2002-12-18 Fernando Perez <fperez@colorado.edu>
4218
4224
4219 * Docs: added new info about Mac OSX, from Andrea.
4225 * Docs: added new info about Mac OSX, from Andrea.
4220
4226
4221 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
4227 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
4222 allow direct plotting of python strings whose format is the same
4228 allow direct plotting of python strings whose format is the same
4223 of gnuplot data files.
4229 of gnuplot data files.
4224
4230
4225 2002-12-16 Fernando Perez <fperez@colorado.edu>
4231 2002-12-16 Fernando Perez <fperez@colorado.edu>
4226
4232
4227 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
4233 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
4228 value of exit question to be acknowledged.
4234 value of exit question to be acknowledged.
4229
4235
4230 2002-12-03 Fernando Perez <fperez@colorado.edu>
4236 2002-12-03 Fernando Perez <fperez@colorado.edu>
4231
4237
4232 * IPython/ipmaker.py: removed generators, which had been added
4238 * IPython/ipmaker.py: removed generators, which had been added
4233 by mistake in an earlier debugging run. This was causing trouble
4239 by mistake in an earlier debugging run. This was causing trouble
4234 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
4240 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
4235 for pointing this out.
4241 for pointing this out.
4236
4242
4237 2002-11-17 Fernando Perez <fperez@colorado.edu>
4243 2002-11-17 Fernando Perez <fperez@colorado.edu>
4238
4244
4239 * Manual: updated the Gnuplot section.
4245 * Manual: updated the Gnuplot section.
4240
4246
4241 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
4247 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
4242 a much better split of what goes in Runtime and what goes in
4248 a much better split of what goes in Runtime and what goes in
4243 Interactive.
4249 Interactive.
4244
4250
4245 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
4251 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
4246 being imported from iplib.
4252 being imported from iplib.
4247
4253
4248 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
4254 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
4249 for command-passing. Now the global Gnuplot instance is called
4255 for command-passing. Now the global Gnuplot instance is called
4250 'gp' instead of 'g', which was really a far too fragile and
4256 'gp' instead of 'g', which was really a far too fragile and
4251 common name.
4257 common name.
4252
4258
4253 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
4259 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
4254 bounding boxes generated by Gnuplot for square plots.
4260 bounding boxes generated by Gnuplot for square plots.
4255
4261
4256 * IPython/genutils.py (popkey): new function added. I should
4262 * IPython/genutils.py (popkey): new function added. I should
4257 suggest this on c.l.py as a dict method, it seems useful.
4263 suggest this on c.l.py as a dict method, it seems useful.
4258
4264
4259 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
4265 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
4260 to transparently handle PostScript generation. MUCH better than
4266 to transparently handle PostScript generation. MUCH better than
4261 the previous plot_eps/replot_eps (which I removed now). The code
4267 the previous plot_eps/replot_eps (which I removed now). The code
4262 is also fairly clean and well documented now (including
4268 is also fairly clean and well documented now (including
4263 docstrings).
4269 docstrings).
4264
4270
4265 2002-11-13 Fernando Perez <fperez@colorado.edu>
4271 2002-11-13 Fernando Perez <fperez@colorado.edu>
4266
4272
4267 * IPython/Magic.py (Magic.magic_edit): fixed docstring
4273 * IPython/Magic.py (Magic.magic_edit): fixed docstring
4268 (inconsistent with options).
4274 (inconsistent with options).
4269
4275
4270 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
4276 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
4271 manually disabled, I don't know why. Fixed it.
4277 manually disabled, I don't know why. Fixed it.
4272 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
4278 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
4273 eps output.
4279 eps output.
4274
4280
4275 2002-11-12 Fernando Perez <fperez@colorado.edu>
4281 2002-11-12 Fernando Perez <fperez@colorado.edu>
4276
4282
4277 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
4283 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
4278 don't propagate up to caller. Fixes crash reported by François
4284 don't propagate up to caller. Fixes crash reported by François
4279 Pinard.
4285 Pinard.
4280
4286
4281 2002-11-09 Fernando Perez <fperez@colorado.edu>
4287 2002-11-09 Fernando Perez <fperez@colorado.edu>
4282
4288
4283 * IPython/ipmaker.py (make_IPython): fixed problem with writing
4289 * IPython/ipmaker.py (make_IPython): fixed problem with writing
4284 history file for new users.
4290 history file for new users.
4285 (make_IPython): fixed bug where initial install would leave the
4291 (make_IPython): fixed bug where initial install would leave the
4286 user running in the .ipython dir.
4292 user running in the .ipython dir.
4287 (make_IPython): fixed bug where config dir .ipython would be
4293 (make_IPython): fixed bug where config dir .ipython would be
4288 created regardless of the given -ipythondir option. Thanks to Cory
4294 created regardless of the given -ipythondir option. Thanks to Cory
4289 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
4295 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
4290
4296
4291 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
4297 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
4292 type confirmations. Will need to use it in all of IPython's code
4298 type confirmations. Will need to use it in all of IPython's code
4293 consistently.
4299 consistently.
4294
4300
4295 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
4301 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
4296 context to print 31 lines instead of the default 5. This will make
4302 context to print 31 lines instead of the default 5. This will make
4297 the crash reports extremely detailed in case the problem is in
4303 the crash reports extremely detailed in case the problem is in
4298 libraries I don't have access to.
4304 libraries I don't have access to.
4299
4305
4300 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
4306 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
4301 line of defense' code to still crash, but giving users fair
4307 line of defense' code to still crash, but giving users fair
4302 warning. I don't want internal errors to go unreported: if there's
4308 warning. I don't want internal errors to go unreported: if there's
4303 an internal problem, IPython should crash and generate a full
4309 an internal problem, IPython should crash and generate a full
4304 report.
4310 report.
4305
4311
4306 2002-11-08 Fernando Perez <fperez@colorado.edu>
4312 2002-11-08 Fernando Perez <fperez@colorado.edu>
4307
4313
4308 * IPython/iplib.py (InteractiveShell.interact): added code to trap
4314 * IPython/iplib.py (InteractiveShell.interact): added code to trap
4309 otherwise uncaught exceptions which can appear if people set
4315 otherwise uncaught exceptions which can appear if people set
4310 sys.stdout to something badly broken. Thanks to a crash report
4316 sys.stdout to something badly broken. Thanks to a crash report
4311 from henni-AT-mail.brainbot.com.
4317 from henni-AT-mail.brainbot.com.
4312
4318
4313 2002-11-04 Fernando Perez <fperez@colorado.edu>
4319 2002-11-04 Fernando Perez <fperez@colorado.edu>
4314
4320
4315 * IPython/iplib.py (InteractiveShell.interact): added
4321 * IPython/iplib.py (InteractiveShell.interact): added
4316 __IPYTHON__active to the builtins. It's a flag which goes on when
4322 __IPYTHON__active to the builtins. It's a flag which goes on when
4317 the interaction starts and goes off again when it stops. This
4323 the interaction starts and goes off again when it stops. This
4318 allows embedding code to detect being inside IPython. Before this
4324 allows embedding code to detect being inside IPython. Before this
4319 was done via __IPYTHON__, but that only shows that an IPython
4325 was done via __IPYTHON__, but that only shows that an IPython
4320 instance has been created.
4326 instance has been created.
4321
4327
4322 * IPython/Magic.py (Magic.magic_env): I realized that in a
4328 * IPython/Magic.py (Magic.magic_env): I realized that in a
4323 UserDict, instance.data holds the data as a normal dict. So I
4329 UserDict, instance.data holds the data as a normal dict. So I
4324 modified @env to return os.environ.data instead of rebuilding a
4330 modified @env to return os.environ.data instead of rebuilding a
4325 dict by hand.
4331 dict by hand.
4326
4332
4327 2002-11-02 Fernando Perez <fperez@colorado.edu>
4333 2002-11-02 Fernando Perez <fperez@colorado.edu>
4328
4334
4329 * IPython/genutils.py (warn): changed so that level 1 prints no
4335 * IPython/genutils.py (warn): changed so that level 1 prints no
4330 header. Level 2 is now the default (with 'WARNING' header, as
4336 header. Level 2 is now the default (with 'WARNING' header, as
4331 before). I think I tracked all places where changes were needed in
4337 before). I think I tracked all places where changes were needed in
4332 IPython, but outside code using the old level numbering may have
4338 IPython, but outside code using the old level numbering may have
4333 broken.
4339 broken.
4334
4340
4335 * IPython/iplib.py (InteractiveShell.runcode): added this to
4341 * IPython/iplib.py (InteractiveShell.runcode): added this to
4336 handle the tracebacks in SystemExit traps correctly. The previous
4342 handle the tracebacks in SystemExit traps correctly. The previous
4337 code (through interact) was printing more of the stack than
4343 code (through interact) was printing more of the stack than
4338 necessary, showing IPython internal code to the user.
4344 necessary, showing IPython internal code to the user.
4339
4345
4340 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
4346 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
4341 default. Now that the default at the confirmation prompt is yes,
4347 default. Now that the default at the confirmation prompt is yes,
4342 it's not so intrusive. François' argument that ipython sessions
4348 it's not so intrusive. François' argument that ipython sessions
4343 tend to be complex enough not to lose them from an accidental C-d,
4349 tend to be complex enough not to lose them from an accidental C-d,
4344 is a valid one.
4350 is a valid one.
4345
4351
4346 * IPython/iplib.py (InteractiveShell.interact): added a
4352 * IPython/iplib.py (InteractiveShell.interact): added a
4347 showtraceback() call to the SystemExit trap, and modified the exit
4353 showtraceback() call to the SystemExit trap, and modified the exit
4348 confirmation to have yes as the default.
4354 confirmation to have yes as the default.
4349
4355
4350 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
4356 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
4351 this file. It's been gone from the code for a long time, this was
4357 this file. It's been gone from the code for a long time, this was
4352 simply leftover junk.
4358 simply leftover junk.
4353
4359
4354 2002-11-01 Fernando Perez <fperez@colorado.edu>
4360 2002-11-01 Fernando Perez <fperez@colorado.edu>
4355
4361
4356 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
4362 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
4357 added. If set, IPython now traps EOF and asks for
4363 added. If set, IPython now traps EOF and asks for
4358 confirmation. After a request by François Pinard.
4364 confirmation. After a request by François Pinard.
4359
4365
4360 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
4366 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
4361 of @abort, and with a new (better) mechanism for handling the
4367 of @abort, and with a new (better) mechanism for handling the
4362 exceptions.
4368 exceptions.
4363
4369
4364 2002-10-27 Fernando Perez <fperez@colorado.edu>
4370 2002-10-27 Fernando Perez <fperez@colorado.edu>
4365
4371
4366 * IPython/usage.py (__doc__): updated the --help information and
4372 * IPython/usage.py (__doc__): updated the --help information and
4367 the ipythonrc file to indicate that -log generates
4373 the ipythonrc file to indicate that -log generates
4368 ./ipython.log. Also fixed the corresponding info in @logstart.
4374 ./ipython.log. Also fixed the corresponding info in @logstart.
4369 This and several other fixes in the manuals thanks to reports by
4375 This and several other fixes in the manuals thanks to reports by
4370 François Pinard <pinard-AT-iro.umontreal.ca>.
4376 François Pinard <pinard-AT-iro.umontreal.ca>.
4371
4377
4372 * IPython/Logger.py (Logger.switch_log): Fixed error message to
4378 * IPython/Logger.py (Logger.switch_log): Fixed error message to
4373 refer to @logstart (instead of @log, which doesn't exist).
4379 refer to @logstart (instead of @log, which doesn't exist).
4374
4380
4375 * IPython/iplib.py (InteractiveShell._prefilter): fixed
4381 * IPython/iplib.py (InteractiveShell._prefilter): fixed
4376 AttributeError crash. Thanks to Christopher Armstrong
4382 AttributeError crash. Thanks to Christopher Armstrong
4377 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
4383 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
4378 introduced recently (in 0.2.14pre37) with the fix to the eval
4384 introduced recently (in 0.2.14pre37) with the fix to the eval
4379 problem mentioned below.
4385 problem mentioned below.
4380
4386
4381 2002-10-17 Fernando Perez <fperez@colorado.edu>
4387 2002-10-17 Fernando Perez <fperez@colorado.edu>
4382
4388
4383 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
4389 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
4384 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
4390 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
4385
4391
4386 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
4392 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
4387 this function to fix a problem reported by Alex Schmolck. He saw
4393 this function to fix a problem reported by Alex Schmolck. He saw
4388 it with list comprehensions and generators, which were getting
4394 it with list comprehensions and generators, which were getting
4389 called twice. The real problem was an 'eval' call in testing for
4395 called twice. The real problem was an 'eval' call in testing for
4390 automagic which was evaluating the input line silently.
4396 automagic which was evaluating the input line silently.
4391
4397
4392 This is a potentially very nasty bug, if the input has side
4398 This is a potentially very nasty bug, if the input has side
4393 effects which must not be repeated. The code is much cleaner now,
4399 effects which must not be repeated. The code is much cleaner now,
4394 without any blanket 'except' left and with a regexp test for
4400 without any blanket 'except' left and with a regexp test for
4395 actual function names.
4401 actual function names.
4396
4402
4397 But an eval remains, which I'm not fully comfortable with. I just
4403 But an eval remains, which I'm not fully comfortable with. I just
4398 don't know how to find out if an expression could be a callable in
4404 don't know how to find out if an expression could be a callable in
4399 the user's namespace without doing an eval on the string. However
4405 the user's namespace without doing an eval on the string. However
4400 that string is now much more strictly checked so that no code
4406 that string is now much more strictly checked so that no code
4401 slips by, so the eval should only happen for things that can
4407 slips by, so the eval should only happen for things that can
4402 really be only function/method names.
4408 really be only function/method names.
4403
4409
4404 2002-10-15 Fernando Perez <fperez@colorado.edu>
4410 2002-10-15 Fernando Perez <fperez@colorado.edu>
4405
4411
4406 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
4412 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
4407 OSX information to main manual, removed README_Mac_OSX file from
4413 OSX information to main manual, removed README_Mac_OSX file from
4408 distribution. Also updated credits for recent additions.
4414 distribution. Also updated credits for recent additions.
4409
4415
4410 2002-10-10 Fernando Perez <fperez@colorado.edu>
4416 2002-10-10 Fernando Perez <fperez@colorado.edu>
4411
4417
4412 * README_Mac_OSX: Added a README for Mac OSX users for fixing
4418 * README_Mac_OSX: Added a README for Mac OSX users for fixing
4413 terminal-related issues. Many thanks to Andrea Riciputi
4419 terminal-related issues. Many thanks to Andrea Riciputi
4414 <andrea.riciputi-AT-libero.it> for writing it.
4420 <andrea.riciputi-AT-libero.it> for writing it.
4415
4421
4416 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
4422 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
4417 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
4423 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
4418
4424
4419 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
4425 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
4420 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
4426 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
4421 <syver-en-AT-online.no> who both submitted patches for this problem.
4427 <syver-en-AT-online.no> who both submitted patches for this problem.
4422
4428
4423 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
4429 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
4424 global embedding to make sure that things don't overwrite user
4430 global embedding to make sure that things don't overwrite user
4425 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
4431 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
4426
4432
4427 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
4433 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
4428 compatibility. Thanks to Hayden Callow
4434 compatibility. Thanks to Hayden Callow
4429 <h.callow-AT-elec.canterbury.ac.nz>
4435 <h.callow-AT-elec.canterbury.ac.nz>
4430
4436
4431 2002-10-04 Fernando Perez <fperez@colorado.edu>
4437 2002-10-04 Fernando Perez <fperez@colorado.edu>
4432
4438
4433 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
4439 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
4434 Gnuplot.File objects.
4440 Gnuplot.File objects.
4435
4441
4436 2002-07-23 Fernando Perez <fperez@colorado.edu>
4442 2002-07-23 Fernando Perez <fperez@colorado.edu>
4437
4443
4438 * IPython/genutils.py (timing): Added timings() and timing() for
4444 * IPython/genutils.py (timing): Added timings() and timing() for
4439 quick access to the most commonly needed data, the execution
4445 quick access to the most commonly needed data, the execution
4440 times. Old timing() renamed to timings_out().
4446 times. Old timing() renamed to timings_out().
4441
4447
4442 2002-07-18 Fernando Perez <fperez@colorado.edu>
4448 2002-07-18 Fernando Perez <fperez@colorado.edu>
4443
4449
4444 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
4450 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
4445 bug with nested instances disrupting the parent's tab completion.
4451 bug with nested instances disrupting the parent's tab completion.
4446
4452
4447 * IPython/iplib.py (all_completions): Added Alex Schmolck's
4453 * IPython/iplib.py (all_completions): Added Alex Schmolck's
4448 all_completions code to begin the emacs integration.
4454 all_completions code to begin the emacs integration.
4449
4455
4450 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
4456 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
4451 argument to allow titling individual arrays when plotting.
4457 argument to allow titling individual arrays when plotting.
4452
4458
4453 2002-07-15 Fernando Perez <fperez@colorado.edu>
4459 2002-07-15 Fernando Perez <fperez@colorado.edu>
4454
4460
4455 * setup.py (make_shortcut): changed to retrieve the value of
4461 * setup.py (make_shortcut): changed to retrieve the value of
4456 'Program Files' directory from the registry (this value changes in
4462 'Program Files' directory from the registry (this value changes in
4457 non-english versions of Windows). Thanks to Thomas Fanslau
4463 non-english versions of Windows). Thanks to Thomas Fanslau
4458 <tfanslau-AT-gmx.de> for the report.
4464 <tfanslau-AT-gmx.de> for the report.
4459
4465
4460 2002-07-10 Fernando Perez <fperez@colorado.edu>
4466 2002-07-10 Fernando Perez <fperez@colorado.edu>
4461
4467
4462 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
4468 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
4463 a bug in pdb, which crashes if a line with only whitespace is
4469 a bug in pdb, which crashes if a line with only whitespace is
4464 entered. Bug report submitted to sourceforge.
4470 entered. Bug report submitted to sourceforge.
4465
4471
4466 2002-07-09 Fernando Perez <fperez@colorado.edu>
4472 2002-07-09 Fernando Perez <fperez@colorado.edu>
4467
4473
4468 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
4474 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
4469 reporting exceptions (it's a bug in inspect.py, I just set a
4475 reporting exceptions (it's a bug in inspect.py, I just set a
4470 workaround).
4476 workaround).
4471
4477
4472 2002-07-08 Fernando Perez <fperez@colorado.edu>
4478 2002-07-08 Fernando Perez <fperez@colorado.edu>
4473
4479
4474 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
4480 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
4475 __IPYTHON__ in __builtins__ to show up in user_ns.
4481 __IPYTHON__ in __builtins__ to show up in user_ns.
4476
4482
4477 2002-07-03 Fernando Perez <fperez@colorado.edu>
4483 2002-07-03 Fernando Perez <fperez@colorado.edu>
4478
4484
4479 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
4485 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
4480 name from @gp_set_instance to @gp_set_default.
4486 name from @gp_set_instance to @gp_set_default.
4481
4487
4482 * IPython/ipmaker.py (make_IPython): default editor value set to
4488 * IPython/ipmaker.py (make_IPython): default editor value set to
4483 '0' (a string), to match the rc file. Otherwise will crash when
4489 '0' (a string), to match the rc file. Otherwise will crash when
4484 .strip() is called on it.
4490 .strip() is called on it.
4485
4491
4486
4492
4487 2002-06-28 Fernando Perez <fperez@colorado.edu>
4493 2002-06-28 Fernando Perez <fperez@colorado.edu>
4488
4494
4489 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
4495 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
4490 of files in current directory when a file is executed via
4496 of files in current directory when a file is executed via
4491 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
4497 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
4492
4498
4493 * setup.py (manfiles): fix for rpm builds, submitted by RA
4499 * setup.py (manfiles): fix for rpm builds, submitted by RA
4494 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
4500 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
4495
4501
4496 * IPython/ipmaker.py (make_IPython): fixed lookup of default
4502 * IPython/ipmaker.py (make_IPython): fixed lookup of default
4497 editor when set to '0'. Problem was, '0' evaluates to True (it's a
4503 editor when set to '0'. Problem was, '0' evaluates to True (it's a
4498 string!). A. Schmolck caught this one.
4504 string!). A. Schmolck caught this one.
4499
4505
4500 2002-06-27 Fernando Perez <fperez@colorado.edu>
4506 2002-06-27 Fernando Perez <fperez@colorado.edu>
4501
4507
4502 * IPython/ipmaker.py (make_IPython): fixed bug when running user
4508 * IPython/ipmaker.py (make_IPython): fixed bug when running user
4503 defined files at the cmd line. __name__ wasn't being set to
4509 defined files at the cmd line. __name__ wasn't being set to
4504 __main__.
4510 __main__.
4505
4511
4506 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
4512 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
4507 regular lists and tuples besides Numeric arrays.
4513 regular lists and tuples besides Numeric arrays.
4508
4514
4509 * IPython/Prompts.py (CachedOutput.__call__): Added output
4515 * IPython/Prompts.py (CachedOutput.__call__): Added output
4510 supression for input ending with ';'. Similar to Mathematica and
4516 supression for input ending with ';'. Similar to Mathematica and
4511 Matlab. The _* vars and Out[] list are still updated, just like
4517 Matlab. The _* vars and Out[] list are still updated, just like
4512 Mathematica behaves.
4518 Mathematica behaves.
4513
4519
4514 2002-06-25 Fernando Perez <fperez@colorado.edu>
4520 2002-06-25 Fernando Perez <fperez@colorado.edu>
4515
4521
4516 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
4522 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
4517 .ini extensions for profiels under Windows.
4523 .ini extensions for profiels under Windows.
4518
4524
4519 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
4525 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
4520 string form. Fix contributed by Alexander Schmolck
4526 string form. Fix contributed by Alexander Schmolck
4521 <a.schmolck-AT-gmx.net>
4527 <a.schmolck-AT-gmx.net>
4522
4528
4523 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
4529 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
4524 pre-configured Gnuplot instance.
4530 pre-configured Gnuplot instance.
4525
4531
4526 2002-06-21 Fernando Perez <fperez@colorado.edu>
4532 2002-06-21 Fernando Perez <fperez@colorado.edu>
4527
4533
4528 * IPython/numutils.py (exp_safe): new function, works around the
4534 * IPython/numutils.py (exp_safe): new function, works around the
4529 underflow problems in Numeric.
4535 underflow problems in Numeric.
4530 (log2): New fn. Safe log in base 2: returns exact integer answer
4536 (log2): New fn. Safe log in base 2: returns exact integer answer
4531 for exact integer powers of 2.
4537 for exact integer powers of 2.
4532
4538
4533 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
4539 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
4534 properly.
4540 properly.
4535
4541
4536 2002-06-20 Fernando Perez <fperez@colorado.edu>
4542 2002-06-20 Fernando Perez <fperez@colorado.edu>
4537
4543
4538 * IPython/genutils.py (timing): new function like
4544 * IPython/genutils.py (timing): new function like
4539 Mathematica's. Similar to time_test, but returns more info.
4545 Mathematica's. Similar to time_test, but returns more info.
4540
4546
4541 2002-06-18 Fernando Perez <fperez@colorado.edu>
4547 2002-06-18 Fernando Perez <fperez@colorado.edu>
4542
4548
4543 * IPython/Magic.py (Magic.magic_save): modified @save and @r
4549 * IPython/Magic.py (Magic.magic_save): modified @save and @r
4544 according to Mike Heeter's suggestions.
4550 according to Mike Heeter's suggestions.
4545
4551
4546 2002-06-16 Fernando Perez <fperez@colorado.edu>
4552 2002-06-16 Fernando Perez <fperez@colorado.edu>
4547
4553
4548 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
4554 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
4549 system. GnuplotMagic is gone as a user-directory option. New files
4555 system. GnuplotMagic is gone as a user-directory option. New files
4550 make it easier to use all the gnuplot stuff both from external
4556 make it easier to use all the gnuplot stuff both from external
4551 programs as well as from IPython. Had to rewrite part of
4557 programs as well as from IPython. Had to rewrite part of
4552 hardcopy() b/c of a strange bug: often the ps files simply don't
4558 hardcopy() b/c of a strange bug: often the ps files simply don't
4553 get created, and require a repeat of the command (often several
4559 get created, and require a repeat of the command (often several
4554 times).
4560 times).
4555
4561
4556 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
4562 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
4557 resolve output channel at call time, so that if sys.stderr has
4563 resolve output channel at call time, so that if sys.stderr has
4558 been redirected by user this gets honored.
4564 been redirected by user this gets honored.
4559
4565
4560 2002-06-13 Fernando Perez <fperez@colorado.edu>
4566 2002-06-13 Fernando Perez <fperez@colorado.edu>
4561
4567
4562 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
4568 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
4563 IPShell. Kept a copy with the old names to avoid breaking people's
4569 IPShell. Kept a copy with the old names to avoid breaking people's
4564 embedded code.
4570 embedded code.
4565
4571
4566 * IPython/ipython: simplified it to the bare minimum after
4572 * IPython/ipython: simplified it to the bare minimum after
4567 Holger's suggestions. Added info about how to use it in
4573 Holger's suggestions. Added info about how to use it in
4568 PYTHONSTARTUP.
4574 PYTHONSTARTUP.
4569
4575
4570 * IPython/Shell.py (IPythonShell): changed the options passing
4576 * IPython/Shell.py (IPythonShell): changed the options passing
4571 from a string with funky %s replacements to a straight list. Maybe
4577 from a string with funky %s replacements to a straight list. Maybe
4572 a bit more typing, but it follows sys.argv conventions, so there's
4578 a bit more typing, but it follows sys.argv conventions, so there's
4573 less special-casing to remember.
4579 less special-casing to remember.
4574
4580
4575 2002-06-12 Fernando Perez <fperez@colorado.edu>
4581 2002-06-12 Fernando Perez <fperez@colorado.edu>
4576
4582
4577 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
4583 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
4578 command. Thanks to a suggestion by Mike Heeter.
4584 command. Thanks to a suggestion by Mike Heeter.
4579 (Magic.magic_pfile): added behavior to look at filenames if given
4585 (Magic.magic_pfile): added behavior to look at filenames if given
4580 arg is not a defined object.
4586 arg is not a defined object.
4581 (Magic.magic_save): New @save function to save code snippets. Also
4587 (Magic.magic_save): New @save function to save code snippets. Also
4582 a Mike Heeter idea.
4588 a Mike Heeter idea.
4583
4589
4584 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
4590 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
4585 plot() and replot(). Much more convenient now, especially for
4591 plot() and replot(). Much more convenient now, especially for
4586 interactive use.
4592 interactive use.
4587
4593
4588 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
4594 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
4589 filenames.
4595 filenames.
4590
4596
4591 2002-06-02 Fernando Perez <fperez@colorado.edu>
4597 2002-06-02 Fernando Perez <fperez@colorado.edu>
4592
4598
4593 * IPython/Struct.py (Struct.__init__): modified to admit
4599 * IPython/Struct.py (Struct.__init__): modified to admit
4594 initialization via another struct.
4600 initialization via another struct.
4595
4601
4596 * IPython/genutils.py (SystemExec.__init__): New stateful
4602 * IPython/genutils.py (SystemExec.__init__): New stateful
4597 interface to xsys and bq. Useful for writing system scripts.
4603 interface to xsys and bq. Useful for writing system scripts.
4598
4604
4599 2002-05-30 Fernando Perez <fperez@colorado.edu>
4605 2002-05-30 Fernando Perez <fperez@colorado.edu>
4600
4606
4601 * MANIFEST.in: Changed docfile selection to exclude all the lyx
4607 * MANIFEST.in: Changed docfile selection to exclude all the lyx
4602 documents. This will make the user download smaller (it's getting
4608 documents. This will make the user download smaller (it's getting
4603 too big).
4609 too big).
4604
4610
4605 2002-05-29 Fernando Perez <fperez@colorado.edu>
4611 2002-05-29 Fernando Perez <fperez@colorado.edu>
4606
4612
4607 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
4613 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
4608 fix problems with shelve and pickle. Seems to work, but I don't
4614 fix problems with shelve and pickle. Seems to work, but I don't
4609 know if corner cases break it. Thanks to Mike Heeter
4615 know if corner cases break it. Thanks to Mike Heeter
4610 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
4616 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
4611
4617
4612 2002-05-24 Fernando Perez <fperez@colorado.edu>
4618 2002-05-24 Fernando Perez <fperez@colorado.edu>
4613
4619
4614 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
4620 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
4615 macros having broken.
4621 macros having broken.
4616
4622
4617 2002-05-21 Fernando Perez <fperez@colorado.edu>
4623 2002-05-21 Fernando Perez <fperez@colorado.edu>
4618
4624
4619 * IPython/Magic.py (Magic.magic_logstart): fixed recently
4625 * IPython/Magic.py (Magic.magic_logstart): fixed recently
4620 introduced logging bug: all history before logging started was
4626 introduced logging bug: all history before logging started was
4621 being written one character per line! This came from the redesign
4627 being written one character per line! This came from the redesign
4622 of the input history as a special list which slices to strings,
4628 of the input history as a special list which slices to strings,
4623 not to lists.
4629 not to lists.
4624
4630
4625 2002-05-20 Fernando Perez <fperez@colorado.edu>
4631 2002-05-20 Fernando Perez <fperez@colorado.edu>
4626
4632
4627 * IPython/Prompts.py (CachedOutput.__init__): made the color table
4633 * IPython/Prompts.py (CachedOutput.__init__): made the color table
4628 be an attribute of all classes in this module. The design of these
4634 be an attribute of all classes in this module. The design of these
4629 classes needs some serious overhauling.
4635 classes needs some serious overhauling.
4630
4636
4631 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
4637 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
4632 which was ignoring '_' in option names.
4638 which was ignoring '_' in option names.
4633
4639
4634 * IPython/ultraTB.py (FormattedTB.__init__): Changed
4640 * IPython/ultraTB.py (FormattedTB.__init__): Changed
4635 'Verbose_novars' to 'Context' and made it the new default. It's a
4641 'Verbose_novars' to 'Context' and made it the new default. It's a
4636 bit more readable and also safer than verbose.
4642 bit more readable and also safer than verbose.
4637
4643
4638 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
4644 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
4639 triple-quoted strings.
4645 triple-quoted strings.
4640
4646
4641 * IPython/OInspect.py (__all__): new module exposing the object
4647 * IPython/OInspect.py (__all__): new module exposing the object
4642 introspection facilities. Now the corresponding magics are dummy
4648 introspection facilities. Now the corresponding magics are dummy
4643 wrappers around this. Having this module will make it much easier
4649 wrappers around this. Having this module will make it much easier
4644 to put these functions into our modified pdb.
4650 to put these functions into our modified pdb.
4645 This new object inspector system uses the new colorizing module,
4651 This new object inspector system uses the new colorizing module,
4646 so source code and other things are nicely syntax highlighted.
4652 so source code and other things are nicely syntax highlighted.
4647
4653
4648 2002-05-18 Fernando Perez <fperez@colorado.edu>
4654 2002-05-18 Fernando Perez <fperez@colorado.edu>
4649
4655
4650 * IPython/ColorANSI.py: Split the coloring tools into a separate
4656 * IPython/ColorANSI.py: Split the coloring tools into a separate
4651 module so I can use them in other code easier (they were part of
4657 module so I can use them in other code easier (they were part of
4652 ultraTB).
4658 ultraTB).
4653
4659
4654 2002-05-17 Fernando Perez <fperez@colorado.edu>
4660 2002-05-17 Fernando Perez <fperez@colorado.edu>
4655
4661
4656 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
4662 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
4657 fixed it to set the global 'g' also to the called instance, as
4663 fixed it to set the global 'g' also to the called instance, as
4658 long as 'g' was still a gnuplot instance (so it doesn't overwrite
4664 long as 'g' was still a gnuplot instance (so it doesn't overwrite
4659 user's 'g' variables).
4665 user's 'g' variables).
4660
4666
4661 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
4667 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
4662 global variables (aliases to _ih,_oh) so that users which expect
4668 global variables (aliases to _ih,_oh) so that users which expect
4663 In[5] or Out[7] to work aren't unpleasantly surprised.
4669 In[5] or Out[7] to work aren't unpleasantly surprised.
4664 (InputList.__getslice__): new class to allow executing slices of
4670 (InputList.__getslice__): new class to allow executing slices of
4665 input history directly. Very simple class, complements the use of
4671 input history directly. Very simple class, complements the use of
4666 macros.
4672 macros.
4667
4673
4668 2002-05-16 Fernando Perez <fperez@colorado.edu>
4674 2002-05-16 Fernando Perez <fperez@colorado.edu>
4669
4675
4670 * setup.py (docdirbase): make doc directory be just doc/IPython
4676 * setup.py (docdirbase): make doc directory be just doc/IPython
4671 without version numbers, it will reduce clutter for users.
4677 without version numbers, it will reduce clutter for users.
4672
4678
4673 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
4679 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
4674 execfile call to prevent possible memory leak. See for details:
4680 execfile call to prevent possible memory leak. See for details:
4675 http://mail.python.org/pipermail/python-list/2002-February/088476.html
4681 http://mail.python.org/pipermail/python-list/2002-February/088476.html
4676
4682
4677 2002-05-15 Fernando Perez <fperez@colorado.edu>
4683 2002-05-15 Fernando Perez <fperez@colorado.edu>
4678
4684
4679 * IPython/Magic.py (Magic.magic_psource): made the object
4685 * IPython/Magic.py (Magic.magic_psource): made the object
4680 introspection names be more standard: pdoc, pdef, pfile and
4686 introspection names be more standard: pdoc, pdef, pfile and
4681 psource. They all print/page their output, and it makes
4687 psource. They all print/page their output, and it makes
4682 remembering them easier. Kept old names for compatibility as
4688 remembering them easier. Kept old names for compatibility as
4683 aliases.
4689 aliases.
4684
4690
4685 2002-05-14 Fernando Perez <fperez@colorado.edu>
4691 2002-05-14 Fernando Perez <fperez@colorado.edu>
4686
4692
4687 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
4693 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
4688 what the mouse problem was. The trick is to use gnuplot with temp
4694 what the mouse problem was. The trick is to use gnuplot with temp
4689 files and NOT with pipes (for data communication), because having
4695 files and NOT with pipes (for data communication), because having
4690 both pipes and the mouse on is bad news.
4696 both pipes and the mouse on is bad news.
4691
4697
4692 2002-05-13 Fernando Perez <fperez@colorado.edu>
4698 2002-05-13 Fernando Perez <fperez@colorado.edu>
4693
4699
4694 * IPython/Magic.py (Magic._ofind): fixed namespace order search
4700 * IPython/Magic.py (Magic._ofind): fixed namespace order search
4695 bug. Information would be reported about builtins even when
4701 bug. Information would be reported about builtins even when
4696 user-defined functions overrode them.
4702 user-defined functions overrode them.
4697
4703
4698 2002-05-11 Fernando Perez <fperez@colorado.edu>
4704 2002-05-11 Fernando Perez <fperez@colorado.edu>
4699
4705
4700 * IPython/__init__.py (__all__): removed FlexCompleter from
4706 * IPython/__init__.py (__all__): removed FlexCompleter from
4701 __all__ so that things don't fail in platforms without readline.
4707 __all__ so that things don't fail in platforms without readline.
4702
4708
4703 2002-05-10 Fernando Perez <fperez@colorado.edu>
4709 2002-05-10 Fernando Perez <fperez@colorado.edu>
4704
4710
4705 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
4711 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
4706 it requires Numeric, effectively making Numeric a dependency for
4712 it requires Numeric, effectively making Numeric a dependency for
4707 IPython.
4713 IPython.
4708
4714
4709 * Released 0.2.13
4715 * Released 0.2.13
4710
4716
4711 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
4717 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
4712 profiler interface. Now all the major options from the profiler
4718 profiler interface. Now all the major options from the profiler
4713 module are directly supported in IPython, both for single
4719 module are directly supported in IPython, both for single
4714 expressions (@prun) and for full programs (@run -p).
4720 expressions (@prun) and for full programs (@run -p).
4715
4721
4716 2002-05-09 Fernando Perez <fperez@colorado.edu>
4722 2002-05-09 Fernando Perez <fperez@colorado.edu>
4717
4723
4718 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
4724 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
4719 magic properly formatted for screen.
4725 magic properly formatted for screen.
4720
4726
4721 * setup.py (make_shortcut): Changed things to put pdf version in
4727 * setup.py (make_shortcut): Changed things to put pdf version in
4722 doc/ instead of doc/manual (had to change lyxport a bit).
4728 doc/ instead of doc/manual (had to change lyxport a bit).
4723
4729
4724 * IPython/Magic.py (Profile.string_stats): made profile runs go
4730 * IPython/Magic.py (Profile.string_stats): made profile runs go
4725 through pager (they are long and a pager allows searching, saving,
4731 through pager (they are long and a pager allows searching, saving,
4726 etc.)
4732 etc.)
4727
4733
4728 2002-05-08 Fernando Perez <fperez@colorado.edu>
4734 2002-05-08 Fernando Perez <fperez@colorado.edu>
4729
4735
4730 * Released 0.2.12
4736 * Released 0.2.12
4731
4737
4732 2002-05-06 Fernando Perez <fperez@colorado.edu>
4738 2002-05-06 Fernando Perez <fperez@colorado.edu>
4733
4739
4734 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
4740 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
4735 introduced); 'hist n1 n2' was broken.
4741 introduced); 'hist n1 n2' was broken.
4736 (Magic.magic_pdb): added optional on/off arguments to @pdb
4742 (Magic.magic_pdb): added optional on/off arguments to @pdb
4737 (Magic.magic_run): added option -i to @run, which executes code in
4743 (Magic.magic_run): added option -i to @run, which executes code in
4738 the IPython namespace instead of a clean one. Also added @irun as
4744 the IPython namespace instead of a clean one. Also added @irun as
4739 an alias to @run -i.
4745 an alias to @run -i.
4740
4746
4741 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
4747 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
4742 fixed (it didn't really do anything, the namespaces were wrong).
4748 fixed (it didn't really do anything, the namespaces were wrong).
4743
4749
4744 * IPython/Debugger.py (__init__): Added workaround for python 2.1
4750 * IPython/Debugger.py (__init__): Added workaround for python 2.1
4745
4751
4746 * IPython/__init__.py (__all__): Fixed package namespace, now
4752 * IPython/__init__.py (__all__): Fixed package namespace, now
4747 'import IPython' does give access to IPython.<all> as
4753 'import IPython' does give access to IPython.<all> as
4748 expected. Also renamed __release__ to Release.
4754 expected. Also renamed __release__ to Release.
4749
4755
4750 * IPython/Debugger.py (__license__): created new Pdb class which
4756 * IPython/Debugger.py (__license__): created new Pdb class which
4751 functions like a drop-in for the normal pdb.Pdb but does NOT
4757 functions like a drop-in for the normal pdb.Pdb but does NOT
4752 import readline by default. This way it doesn't muck up IPython's
4758 import readline by default. This way it doesn't muck up IPython's
4753 readline handling, and now tab-completion finally works in the
4759 readline handling, and now tab-completion finally works in the
4754 debugger -- sort of. It completes things globally visible, but the
4760 debugger -- sort of. It completes things globally visible, but the
4755 completer doesn't track the stack as pdb walks it. That's a bit
4761 completer doesn't track the stack as pdb walks it. That's a bit
4756 tricky, and I'll have to implement it later.
4762 tricky, and I'll have to implement it later.
4757
4763
4758 2002-05-05 Fernando Perez <fperez@colorado.edu>
4764 2002-05-05 Fernando Perez <fperez@colorado.edu>
4759
4765
4760 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
4766 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
4761 magic docstrings when printed via ? (explicit \'s were being
4767 magic docstrings when printed via ? (explicit \'s were being
4762 printed).
4768 printed).
4763
4769
4764 * IPython/ipmaker.py (make_IPython): fixed namespace
4770 * IPython/ipmaker.py (make_IPython): fixed namespace
4765 identification bug. Now variables loaded via logs or command-line
4771 identification bug. Now variables loaded via logs or command-line
4766 files are recognized in the interactive namespace by @who.
4772 files are recognized in the interactive namespace by @who.
4767
4773
4768 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
4774 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
4769 log replay system stemming from the string form of Structs.
4775 log replay system stemming from the string form of Structs.
4770
4776
4771 * IPython/Magic.py (Macro.__init__): improved macros to properly
4777 * IPython/Magic.py (Macro.__init__): improved macros to properly
4772 handle magic commands in them.
4778 handle magic commands in them.
4773 (Magic.magic_logstart): usernames are now expanded so 'logstart
4779 (Magic.magic_logstart): usernames are now expanded so 'logstart
4774 ~/mylog' now works.
4780 ~/mylog' now works.
4775
4781
4776 * IPython/iplib.py (complete): fixed bug where paths starting with
4782 * IPython/iplib.py (complete): fixed bug where paths starting with
4777 '/' would be completed as magic names.
4783 '/' would be completed as magic names.
4778
4784
4779 2002-05-04 Fernando Perez <fperez@colorado.edu>
4785 2002-05-04 Fernando Perez <fperez@colorado.edu>
4780
4786
4781 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
4787 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
4782 allow running full programs under the profiler's control.
4788 allow running full programs under the profiler's control.
4783
4789
4784 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
4790 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
4785 mode to report exceptions verbosely but without formatting
4791 mode to report exceptions verbosely but without formatting
4786 variables. This addresses the issue of ipython 'freezing' (it's
4792 variables. This addresses the issue of ipython 'freezing' (it's
4787 not frozen, but caught in an expensive formatting loop) when huge
4793 not frozen, but caught in an expensive formatting loop) when huge
4788 variables are in the context of an exception.
4794 variables are in the context of an exception.
4789 (VerboseTB.text): Added '--->' markers at line where exception was
4795 (VerboseTB.text): Added '--->' markers at line where exception was
4790 triggered. Much clearer to read, especially in NoColor modes.
4796 triggered. Much clearer to read, especially in NoColor modes.
4791
4797
4792 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
4798 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
4793 implemented in reverse when changing to the new parse_options().
4799 implemented in reverse when changing to the new parse_options().
4794
4800
4795 2002-05-03 Fernando Perez <fperez@colorado.edu>
4801 2002-05-03 Fernando Perez <fperez@colorado.edu>
4796
4802
4797 * IPython/Magic.py (Magic.parse_options): new function so that
4803 * IPython/Magic.py (Magic.parse_options): new function so that
4798 magics can parse options easier.
4804 magics can parse options easier.
4799 (Magic.magic_prun): new function similar to profile.run(),
4805 (Magic.magic_prun): new function similar to profile.run(),
4800 suggested by Chris Hart.
4806 suggested by Chris Hart.
4801 (Magic.magic_cd): fixed behavior so that it only changes if
4807 (Magic.magic_cd): fixed behavior so that it only changes if
4802 directory actually is in history.
4808 directory actually is in history.
4803
4809
4804 * IPython/usage.py (__doc__): added information about potential
4810 * IPython/usage.py (__doc__): added information about potential
4805 slowness of Verbose exception mode when there are huge data
4811 slowness of Verbose exception mode when there are huge data
4806 structures to be formatted (thanks to Archie Paulson).
4812 structures to be formatted (thanks to Archie Paulson).
4807
4813
4808 * IPython/ipmaker.py (make_IPython): Changed default logging
4814 * IPython/ipmaker.py (make_IPython): Changed default logging
4809 (when simply called with -log) to use curr_dir/ipython.log in
4815 (when simply called with -log) to use curr_dir/ipython.log in
4810 rotate mode. Fixed crash which was occuring with -log before
4816 rotate mode. Fixed crash which was occuring with -log before
4811 (thanks to Jim Boyle).
4817 (thanks to Jim Boyle).
4812
4818
4813 2002-05-01 Fernando Perez <fperez@colorado.edu>
4819 2002-05-01 Fernando Perez <fperez@colorado.edu>
4814
4820
4815 * Released 0.2.11 for these fixes (mainly the ultraTB one which
4821 * Released 0.2.11 for these fixes (mainly the ultraTB one which
4816 was nasty -- though somewhat of a corner case).
4822 was nasty -- though somewhat of a corner case).
4817
4823
4818 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
4824 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
4819 text (was a bug).
4825 text (was a bug).
4820
4826
4821 2002-04-30 Fernando Perez <fperez@colorado.edu>
4827 2002-04-30 Fernando Perez <fperez@colorado.edu>
4822
4828
4823 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
4829 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
4824 a print after ^D or ^C from the user so that the In[] prompt
4830 a print after ^D or ^C from the user so that the In[] prompt
4825 doesn't over-run the gnuplot one.
4831 doesn't over-run the gnuplot one.
4826
4832
4827 2002-04-29 Fernando Perez <fperez@colorado.edu>
4833 2002-04-29 Fernando Perez <fperez@colorado.edu>
4828
4834
4829 * Released 0.2.10
4835 * Released 0.2.10
4830
4836
4831 * IPython/__release__.py (version): get date dynamically.
4837 * IPython/__release__.py (version): get date dynamically.
4832
4838
4833 * Misc. documentation updates thanks to Arnd's comments. Also ran
4839 * Misc. documentation updates thanks to Arnd's comments. Also ran
4834 a full spellcheck on the manual (hadn't been done in a while).
4840 a full spellcheck on the manual (hadn't been done in a while).
4835
4841
4836 2002-04-27 Fernando Perez <fperez@colorado.edu>
4842 2002-04-27 Fernando Perez <fperez@colorado.edu>
4837
4843
4838 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
4844 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
4839 starting a log in mid-session would reset the input history list.
4845 starting a log in mid-session would reset the input history list.
4840
4846
4841 2002-04-26 Fernando Perez <fperez@colorado.edu>
4847 2002-04-26 Fernando Perez <fperez@colorado.edu>
4842
4848
4843 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
4849 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
4844 all files were being included in an update. Now anything in
4850 all files were being included in an update. Now anything in
4845 UserConfig that matches [A-Za-z]*.py will go (this excludes
4851 UserConfig that matches [A-Za-z]*.py will go (this excludes
4846 __init__.py)
4852 __init__.py)
4847
4853
4848 2002-04-25 Fernando Perez <fperez@colorado.edu>
4854 2002-04-25 Fernando Perez <fperez@colorado.edu>
4849
4855
4850 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
4856 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
4851 to __builtins__ so that any form of embedded or imported code can
4857 to __builtins__ so that any form of embedded or imported code can
4852 test for being inside IPython.
4858 test for being inside IPython.
4853
4859
4854 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
4860 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
4855 changed to GnuplotMagic because it's now an importable module,
4861 changed to GnuplotMagic because it's now an importable module,
4856 this makes the name follow that of the standard Gnuplot module.
4862 this makes the name follow that of the standard Gnuplot module.
4857 GnuplotMagic can now be loaded at any time in mid-session.
4863 GnuplotMagic can now be loaded at any time in mid-session.
4858
4864
4859 2002-04-24 Fernando Perez <fperez@colorado.edu>
4865 2002-04-24 Fernando Perez <fperez@colorado.edu>
4860
4866
4861 * IPython/numutils.py: removed SIUnits. It doesn't properly set
4867 * IPython/numutils.py: removed SIUnits. It doesn't properly set
4862 the globals (IPython has its own namespace) and the
4868 the globals (IPython has its own namespace) and the
4863 PhysicalQuantity stuff is much better anyway.
4869 PhysicalQuantity stuff is much better anyway.
4864
4870
4865 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
4871 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
4866 embedding example to standard user directory for
4872 embedding example to standard user directory for
4867 distribution. Also put it in the manual.
4873 distribution. Also put it in the manual.
4868
4874
4869 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
4875 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
4870 instance as first argument (so it doesn't rely on some obscure
4876 instance as first argument (so it doesn't rely on some obscure
4871 hidden global).
4877 hidden global).
4872
4878
4873 * IPython/UserConfig/ipythonrc.py: put () back in accepted
4879 * IPython/UserConfig/ipythonrc.py: put () back in accepted
4874 delimiters. While it prevents ().TAB from working, it allows
4880 delimiters. While it prevents ().TAB from working, it allows
4875 completions in open (... expressions. This is by far a more common
4881 completions in open (... expressions. This is by far a more common
4876 case.
4882 case.
4877
4883
4878 2002-04-23 Fernando Perez <fperez@colorado.edu>
4884 2002-04-23 Fernando Perez <fperez@colorado.edu>
4879
4885
4880 * IPython/Extensions/InterpreterPasteInput.py: new
4886 * IPython/Extensions/InterpreterPasteInput.py: new
4881 syntax-processing module for pasting lines with >>> or ... at the
4887 syntax-processing module for pasting lines with >>> or ... at the
4882 start.
4888 start.
4883
4889
4884 * IPython/Extensions/PhysicalQ_Interactive.py
4890 * IPython/Extensions/PhysicalQ_Interactive.py
4885 (PhysicalQuantityInteractive.__int__): fixed to work with either
4891 (PhysicalQuantityInteractive.__int__): fixed to work with either
4886 Numeric or math.
4892 Numeric or math.
4887
4893
4888 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
4894 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
4889 provided profiles. Now we have:
4895 provided profiles. Now we have:
4890 -math -> math module as * and cmath with its own namespace.
4896 -math -> math module as * and cmath with its own namespace.
4891 -numeric -> Numeric as *, plus gnuplot & grace
4897 -numeric -> Numeric as *, plus gnuplot & grace
4892 -physics -> same as before
4898 -physics -> same as before
4893
4899
4894 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
4900 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
4895 user-defined magics wouldn't be found by @magic if they were
4901 user-defined magics wouldn't be found by @magic if they were
4896 defined as class methods. Also cleaned up the namespace search
4902 defined as class methods. Also cleaned up the namespace search
4897 logic and the string building (to use %s instead of many repeated
4903 logic and the string building (to use %s instead of many repeated
4898 string adds).
4904 string adds).
4899
4905
4900 * IPython/UserConfig/example-magic.py (magic_foo): updated example
4906 * IPython/UserConfig/example-magic.py (magic_foo): updated example
4901 of user-defined magics to operate with class methods (cleaner, in
4907 of user-defined magics to operate with class methods (cleaner, in
4902 line with the gnuplot code).
4908 line with the gnuplot code).
4903
4909
4904 2002-04-22 Fernando Perez <fperez@colorado.edu>
4910 2002-04-22 Fernando Perez <fperez@colorado.edu>
4905
4911
4906 * setup.py: updated dependency list so that manual is updated when
4912 * setup.py: updated dependency list so that manual is updated when
4907 all included files change.
4913 all included files change.
4908
4914
4909 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
4915 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
4910 the delimiter removal option (the fix is ugly right now).
4916 the delimiter removal option (the fix is ugly right now).
4911
4917
4912 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
4918 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
4913 all of the math profile (quicker loading, no conflict between
4919 all of the math profile (quicker loading, no conflict between
4914 g-9.8 and g-gnuplot).
4920 g-9.8 and g-gnuplot).
4915
4921
4916 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
4922 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
4917 name of post-mortem files to IPython_crash_report.txt.
4923 name of post-mortem files to IPython_crash_report.txt.
4918
4924
4919 * Cleanup/update of the docs. Added all the new readline info and
4925 * Cleanup/update of the docs. Added all the new readline info and
4920 formatted all lists as 'real lists'.
4926 formatted all lists as 'real lists'.
4921
4927
4922 * IPython/ipmaker.py (make_IPython): removed now-obsolete
4928 * IPython/ipmaker.py (make_IPython): removed now-obsolete
4923 tab-completion options, since the full readline parse_and_bind is
4929 tab-completion options, since the full readline parse_and_bind is
4924 now accessible.
4930 now accessible.
4925
4931
4926 * IPython/iplib.py (InteractiveShell.init_readline): Changed
4932 * IPython/iplib.py (InteractiveShell.init_readline): Changed
4927 handling of readline options. Now users can specify any string to
4933 handling of readline options. Now users can specify any string to
4928 be passed to parse_and_bind(), as well as the delimiters to be
4934 be passed to parse_and_bind(), as well as the delimiters to be
4929 removed.
4935 removed.
4930 (InteractiveShell.__init__): Added __name__ to the global
4936 (InteractiveShell.__init__): Added __name__ to the global
4931 namespace so that things like Itpl which rely on its existence
4937 namespace so that things like Itpl which rely on its existence
4932 don't crash.
4938 don't crash.
4933 (InteractiveShell._prefilter): Defined the default with a _ so
4939 (InteractiveShell._prefilter): Defined the default with a _ so
4934 that prefilter() is easier to override, while the default one
4940 that prefilter() is easier to override, while the default one
4935 remains available.
4941 remains available.
4936
4942
4937 2002-04-18 Fernando Perez <fperez@colorado.edu>
4943 2002-04-18 Fernando Perez <fperez@colorado.edu>
4938
4944
4939 * Added information about pdb in the docs.
4945 * Added information about pdb in the docs.
4940
4946
4941 2002-04-17 Fernando Perez <fperez@colorado.edu>
4947 2002-04-17 Fernando Perez <fperez@colorado.edu>
4942
4948
4943 * IPython/ipmaker.py (make_IPython): added rc_override option to
4949 * IPython/ipmaker.py (make_IPython): added rc_override option to
4944 allow passing config options at creation time which may override
4950 allow passing config options at creation time which may override
4945 anything set in the config files or command line. This is
4951 anything set in the config files or command line. This is
4946 particularly useful for configuring embedded instances.
4952 particularly useful for configuring embedded instances.
4947
4953
4948 2002-04-15 Fernando Perez <fperez@colorado.edu>
4954 2002-04-15 Fernando Perez <fperez@colorado.edu>
4949
4955
4950 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
4956 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
4951 crash embedded instances because of the input cache falling out of
4957 crash embedded instances because of the input cache falling out of
4952 sync with the output counter.
4958 sync with the output counter.
4953
4959
4954 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
4960 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
4955 mode which calls pdb after an uncaught exception in IPython itself.
4961 mode which calls pdb after an uncaught exception in IPython itself.
4956
4962
4957 2002-04-14 Fernando Perez <fperez@colorado.edu>
4963 2002-04-14 Fernando Perez <fperez@colorado.edu>
4958
4964
4959 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
4965 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
4960 readline, fix it back after each call.
4966 readline, fix it back after each call.
4961
4967
4962 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
4968 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
4963 method to force all access via __call__(), which guarantees that
4969 method to force all access via __call__(), which guarantees that
4964 traceback references are properly deleted.
4970 traceback references are properly deleted.
4965
4971
4966 * IPython/Prompts.py (CachedOutput._display): minor fixes to
4972 * IPython/Prompts.py (CachedOutput._display): minor fixes to
4967 improve printing when pprint is in use.
4973 improve printing when pprint is in use.
4968
4974
4969 2002-04-13 Fernando Perez <fperez@colorado.edu>
4975 2002-04-13 Fernando Perez <fperez@colorado.edu>
4970
4976
4971 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
4977 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
4972 exceptions aren't caught anymore. If the user triggers one, he
4978 exceptions aren't caught anymore. If the user triggers one, he
4973 should know why he's doing it and it should go all the way up,
4979 should know why he's doing it and it should go all the way up,
4974 just like any other exception. So now @abort will fully kill the
4980 just like any other exception. So now @abort will fully kill the
4975 embedded interpreter and the embedding code (unless that happens
4981 embedded interpreter and the embedding code (unless that happens
4976 to catch SystemExit).
4982 to catch SystemExit).
4977
4983
4978 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
4984 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
4979 and a debugger() method to invoke the interactive pdb debugger
4985 and a debugger() method to invoke the interactive pdb debugger
4980 after printing exception information. Also added the corresponding
4986 after printing exception information. Also added the corresponding
4981 -pdb option and @pdb magic to control this feature, and updated
4987 -pdb option and @pdb magic to control this feature, and updated
4982 the docs. After a suggestion from Christopher Hart
4988 the docs. After a suggestion from Christopher Hart
4983 (hart-AT-caltech.edu).
4989 (hart-AT-caltech.edu).
4984
4990
4985 2002-04-12 Fernando Perez <fperez@colorado.edu>
4991 2002-04-12 Fernando Perez <fperez@colorado.edu>
4986
4992
4987 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
4993 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
4988 the exception handlers defined by the user (not the CrashHandler)
4994 the exception handlers defined by the user (not the CrashHandler)
4989 so that user exceptions don't trigger an ipython bug report.
4995 so that user exceptions don't trigger an ipython bug report.
4990
4996
4991 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
4997 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
4992 configurable (it should have always been so).
4998 configurable (it should have always been so).
4993
4999
4994 2002-03-26 Fernando Perez <fperez@colorado.edu>
5000 2002-03-26 Fernando Perez <fperez@colorado.edu>
4995
5001
4996 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
5002 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
4997 and there to fix embedding namespace issues. This should all be
5003 and there to fix embedding namespace issues. This should all be
4998 done in a more elegant way.
5004 done in a more elegant way.
4999
5005
5000 2002-03-25 Fernando Perez <fperez@colorado.edu>
5006 2002-03-25 Fernando Perez <fperez@colorado.edu>
5001
5007
5002 * IPython/genutils.py (get_home_dir): Try to make it work under
5008 * IPython/genutils.py (get_home_dir): Try to make it work under
5003 win9x also.
5009 win9x also.
5004
5010
5005 2002-03-20 Fernando Perez <fperez@colorado.edu>
5011 2002-03-20 Fernando Perez <fperez@colorado.edu>
5006
5012
5007 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
5013 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
5008 sys.displayhook untouched upon __init__.
5014 sys.displayhook untouched upon __init__.
5009
5015
5010 2002-03-19 Fernando Perez <fperez@colorado.edu>
5016 2002-03-19 Fernando Perez <fperez@colorado.edu>
5011
5017
5012 * Released 0.2.9 (for embedding bug, basically).
5018 * Released 0.2.9 (for embedding bug, basically).
5013
5019
5014 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
5020 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
5015 exceptions so that enclosing shell's state can be restored.
5021 exceptions so that enclosing shell's state can be restored.
5016
5022
5017 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
5023 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
5018 naming conventions in the .ipython/ dir.
5024 naming conventions in the .ipython/ dir.
5019
5025
5020 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
5026 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
5021 from delimiters list so filenames with - in them get expanded.
5027 from delimiters list so filenames with - in them get expanded.
5022
5028
5023 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
5029 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
5024 sys.displayhook not being properly restored after an embedded call.
5030 sys.displayhook not being properly restored after an embedded call.
5025
5031
5026 2002-03-18 Fernando Perez <fperez@colorado.edu>
5032 2002-03-18 Fernando Perez <fperez@colorado.edu>
5027
5033
5028 * Released 0.2.8
5034 * Released 0.2.8
5029
5035
5030 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
5036 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
5031 some files weren't being included in a -upgrade.
5037 some files weren't being included in a -upgrade.
5032 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
5038 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
5033 on' so that the first tab completes.
5039 on' so that the first tab completes.
5034 (InteractiveShell.handle_magic): fixed bug with spaces around
5040 (InteractiveShell.handle_magic): fixed bug with spaces around
5035 quotes breaking many magic commands.
5041 quotes breaking many magic commands.
5036
5042
5037 * setup.py: added note about ignoring the syntax error messages at
5043 * setup.py: added note about ignoring the syntax error messages at
5038 installation.
5044 installation.
5039
5045
5040 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
5046 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
5041 streamlining the gnuplot interface, now there's only one magic @gp.
5047 streamlining the gnuplot interface, now there's only one magic @gp.
5042
5048
5043 2002-03-17 Fernando Perez <fperez@colorado.edu>
5049 2002-03-17 Fernando Perez <fperez@colorado.edu>
5044
5050
5045 * IPython/UserConfig/magic_gnuplot.py: new name for the
5051 * IPython/UserConfig/magic_gnuplot.py: new name for the
5046 example-magic_pm.py file. Much enhanced system, now with a shell
5052 example-magic_pm.py file. Much enhanced system, now with a shell
5047 for communicating directly with gnuplot, one command at a time.
5053 for communicating directly with gnuplot, one command at a time.
5048
5054
5049 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
5055 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
5050 setting __name__=='__main__'.
5056 setting __name__=='__main__'.
5051
5057
5052 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
5058 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
5053 mini-shell for accessing gnuplot from inside ipython. Should
5059 mini-shell for accessing gnuplot from inside ipython. Should
5054 extend it later for grace access too. Inspired by Arnd's
5060 extend it later for grace access too. Inspired by Arnd's
5055 suggestion.
5061 suggestion.
5056
5062
5057 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
5063 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
5058 calling magic functions with () in their arguments. Thanks to Arnd
5064 calling magic functions with () in their arguments. Thanks to Arnd
5059 Baecker for pointing this to me.
5065 Baecker for pointing this to me.
5060
5066
5061 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
5067 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
5062 infinitely for integer or complex arrays (only worked with floats).
5068 infinitely for integer or complex arrays (only worked with floats).
5063
5069
5064 2002-03-16 Fernando Perez <fperez@colorado.edu>
5070 2002-03-16 Fernando Perez <fperez@colorado.edu>
5065
5071
5066 * setup.py: Merged setup and setup_windows into a single script
5072 * setup.py: Merged setup and setup_windows into a single script
5067 which properly handles things for windows users.
5073 which properly handles things for windows users.
5068
5074
5069 2002-03-15 Fernando Perez <fperez@colorado.edu>
5075 2002-03-15 Fernando Perez <fperez@colorado.edu>
5070
5076
5071 * Big change to the manual: now the magics are all automatically
5077 * Big change to the manual: now the magics are all automatically
5072 documented. This information is generated from their docstrings
5078 documented. This information is generated from their docstrings
5073 and put in a latex file included by the manual lyx file. This way
5079 and put in a latex file included by the manual lyx file. This way
5074 we get always up to date information for the magics. The manual
5080 we get always up to date information for the magics. The manual
5075 now also has proper version information, also auto-synced.
5081 now also has proper version information, also auto-synced.
5076
5082
5077 For this to work, an undocumented --magic_docstrings option was added.
5083 For this to work, an undocumented --magic_docstrings option was added.
5078
5084
5079 2002-03-13 Fernando Perez <fperez@colorado.edu>
5085 2002-03-13 Fernando Perez <fperez@colorado.edu>
5080
5086
5081 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
5087 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
5082 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
5088 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
5083
5089
5084 2002-03-12 Fernando Perez <fperez@colorado.edu>
5090 2002-03-12 Fernando Perez <fperez@colorado.edu>
5085
5091
5086 * IPython/ultraTB.py (TermColors): changed color escapes again to
5092 * IPython/ultraTB.py (TermColors): changed color escapes again to
5087 fix the (old, reintroduced) line-wrapping bug. Basically, if
5093 fix the (old, reintroduced) line-wrapping bug. Basically, if
5088 \001..\002 aren't given in the color escapes, lines get wrapped
5094 \001..\002 aren't given in the color escapes, lines get wrapped
5089 weirdly. But giving those screws up old xterms and emacs terms. So
5095 weirdly. But giving those screws up old xterms and emacs terms. So
5090 I added some logic for emacs terms to be ok, but I can't identify old
5096 I added some logic for emacs terms to be ok, but I can't identify old
5091 xterms separately ($TERM=='xterm' for many terminals, like konsole).
5097 xterms separately ($TERM=='xterm' for many terminals, like konsole).
5092
5098
5093 2002-03-10 Fernando Perez <fperez@colorado.edu>
5099 2002-03-10 Fernando Perez <fperez@colorado.edu>
5094
5100
5095 * IPython/usage.py (__doc__): Various documentation cleanups and
5101 * IPython/usage.py (__doc__): Various documentation cleanups and
5096 updates, both in usage docstrings and in the manual.
5102 updates, both in usage docstrings and in the manual.
5097
5103
5098 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
5104 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
5099 handling of caching. Set minimum acceptabe value for having a
5105 handling of caching. Set minimum acceptabe value for having a
5100 cache at 20 values.
5106 cache at 20 values.
5101
5107
5102 * IPython/iplib.py (InteractiveShell.user_setup): moved the
5108 * IPython/iplib.py (InteractiveShell.user_setup): moved the
5103 install_first_time function to a method, renamed it and added an
5109 install_first_time function to a method, renamed it and added an
5104 'upgrade' mode. Now people can update their config directory with
5110 'upgrade' mode. Now people can update their config directory with
5105 a simple command line switch (-upgrade, also new).
5111 a simple command line switch (-upgrade, also new).
5106
5112
5107 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
5113 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
5108 @file (convenient for automagic users under Python >= 2.2).
5114 @file (convenient for automagic users under Python >= 2.2).
5109 Removed @files (it seemed more like a plural than an abbrev. of
5115 Removed @files (it seemed more like a plural than an abbrev. of
5110 'file show').
5116 'file show').
5111
5117
5112 * IPython/iplib.py (install_first_time): Fixed crash if there were
5118 * IPython/iplib.py (install_first_time): Fixed crash if there were
5113 backup files ('~') in .ipython/ install directory.
5119 backup files ('~') in .ipython/ install directory.
5114
5120
5115 * IPython/ipmaker.py (make_IPython): fixes for new prompt
5121 * IPython/ipmaker.py (make_IPython): fixes for new prompt
5116 system. Things look fine, but these changes are fairly
5122 system. Things look fine, but these changes are fairly
5117 intrusive. Test them for a few days.
5123 intrusive. Test them for a few days.
5118
5124
5119 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
5125 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
5120 the prompts system. Now all in/out prompt strings are user
5126 the prompts system. Now all in/out prompt strings are user
5121 controllable. This is particularly useful for embedding, as one
5127 controllable. This is particularly useful for embedding, as one
5122 can tag embedded instances with particular prompts.
5128 can tag embedded instances with particular prompts.
5123
5129
5124 Also removed global use of sys.ps1/2, which now allows nested
5130 Also removed global use of sys.ps1/2, which now allows nested
5125 embeddings without any problems. Added command-line options for
5131 embeddings without any problems. Added command-line options for
5126 the prompt strings.
5132 the prompt strings.
5127
5133
5128 2002-03-08 Fernando Perez <fperez@colorado.edu>
5134 2002-03-08 Fernando Perez <fperez@colorado.edu>
5129
5135
5130 * IPython/UserConfig/example-embed-short.py (ipshell): added
5136 * IPython/UserConfig/example-embed-short.py (ipshell): added
5131 example file with the bare minimum code for embedding.
5137 example file with the bare minimum code for embedding.
5132
5138
5133 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
5139 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
5134 functionality for the embeddable shell to be activated/deactivated
5140 functionality for the embeddable shell to be activated/deactivated
5135 either globally or at each call.
5141 either globally or at each call.
5136
5142
5137 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
5143 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
5138 rewriting the prompt with '--->' for auto-inputs with proper
5144 rewriting the prompt with '--->' for auto-inputs with proper
5139 coloring. Now the previous UGLY hack in handle_auto() is gone, and
5145 coloring. Now the previous UGLY hack in handle_auto() is gone, and
5140 this is handled by the prompts class itself, as it should.
5146 this is handled by the prompts class itself, as it should.
5141
5147
5142 2002-03-05 Fernando Perez <fperez@colorado.edu>
5148 2002-03-05 Fernando Perez <fperez@colorado.edu>
5143
5149
5144 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
5150 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
5145 @logstart to avoid name clashes with the math log function.
5151 @logstart to avoid name clashes with the math log function.
5146
5152
5147 * Big updates to X/Emacs section of the manual.
5153 * Big updates to X/Emacs section of the manual.
5148
5154
5149 * Removed ipython_emacs. Milan explained to me how to pass
5155 * Removed ipython_emacs. Milan explained to me how to pass
5150 arguments to ipython through Emacs. Some day I'm going to end up
5156 arguments to ipython through Emacs. Some day I'm going to end up
5151 learning some lisp...
5157 learning some lisp...
5152
5158
5153 2002-03-04 Fernando Perez <fperez@colorado.edu>
5159 2002-03-04 Fernando Perez <fperez@colorado.edu>
5154
5160
5155 * IPython/ipython_emacs: Created script to be used as the
5161 * IPython/ipython_emacs: Created script to be used as the
5156 py-python-command Emacs variable so we can pass IPython
5162 py-python-command Emacs variable so we can pass IPython
5157 parameters. I can't figure out how to tell Emacs directly to pass
5163 parameters. I can't figure out how to tell Emacs directly to pass
5158 parameters to IPython, so a dummy shell script will do it.
5164 parameters to IPython, so a dummy shell script will do it.
5159
5165
5160 Other enhancements made for things to work better under Emacs'
5166 Other enhancements made for things to work better under Emacs'
5161 various types of terminals. Many thanks to Milan Zamazal
5167 various types of terminals. Many thanks to Milan Zamazal
5162 <pdm-AT-zamazal.org> for all the suggestions and pointers.
5168 <pdm-AT-zamazal.org> for all the suggestions and pointers.
5163
5169
5164 2002-03-01 Fernando Perez <fperez@colorado.edu>
5170 2002-03-01 Fernando Perez <fperez@colorado.edu>
5165
5171
5166 * IPython/ipmaker.py (make_IPython): added a --readline! option so
5172 * IPython/ipmaker.py (make_IPython): added a --readline! option so
5167 that loading of readline is now optional. This gives better
5173 that loading of readline is now optional. This gives better
5168 control to emacs users.
5174 control to emacs users.
5169
5175
5170 * IPython/ultraTB.py (__date__): Modified color escape sequences
5176 * IPython/ultraTB.py (__date__): Modified color escape sequences
5171 and now things work fine under xterm and in Emacs' term buffers
5177 and now things work fine under xterm and in Emacs' term buffers
5172 (though not shell ones). Well, in emacs you get colors, but all
5178 (though not shell ones). Well, in emacs you get colors, but all
5173 seem to be 'light' colors (no difference between dark and light
5179 seem to be 'light' colors (no difference between dark and light
5174 ones). But the garbage chars are gone, and also in xterms. It
5180 ones). But the garbage chars are gone, and also in xterms. It
5175 seems that now I'm using 'cleaner' ansi sequences.
5181 seems that now I'm using 'cleaner' ansi sequences.
5176
5182
5177 2002-02-21 Fernando Perez <fperez@colorado.edu>
5183 2002-02-21 Fernando Perez <fperez@colorado.edu>
5178
5184
5179 * Released 0.2.7 (mainly to publish the scoping fix).
5185 * Released 0.2.7 (mainly to publish the scoping fix).
5180
5186
5181 * IPython/Logger.py (Logger.logstate): added. A corresponding
5187 * IPython/Logger.py (Logger.logstate): added. A corresponding
5182 @logstate magic was created.
5188 @logstate magic was created.
5183
5189
5184 * IPython/Magic.py: fixed nested scoping problem under Python
5190 * IPython/Magic.py: fixed nested scoping problem under Python
5185 2.1.x (automagic wasn't working).
5191 2.1.x (automagic wasn't working).
5186
5192
5187 2002-02-20 Fernando Perez <fperez@colorado.edu>
5193 2002-02-20 Fernando Perez <fperez@colorado.edu>
5188
5194
5189 * Released 0.2.6.
5195 * Released 0.2.6.
5190
5196
5191 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
5197 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
5192 option so that logs can come out without any headers at all.
5198 option so that logs can come out without any headers at all.
5193
5199
5194 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
5200 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
5195 SciPy.
5201 SciPy.
5196
5202
5197 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
5203 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
5198 that embedded IPython calls don't require vars() to be explicitly
5204 that embedded IPython calls don't require vars() to be explicitly
5199 passed. Now they are extracted from the caller's frame (code
5205 passed. Now they are extracted from the caller's frame (code
5200 snatched from Eric Jones' weave). Added better documentation to
5206 snatched from Eric Jones' weave). Added better documentation to
5201 the section on embedding and the example file.
5207 the section on embedding and the example file.
5202
5208
5203 * IPython/genutils.py (page): Changed so that under emacs, it just
5209 * IPython/genutils.py (page): Changed so that under emacs, it just
5204 prints the string. You can then page up and down in the emacs
5210 prints the string. You can then page up and down in the emacs
5205 buffer itself. This is how the builtin help() works.
5211 buffer itself. This is how the builtin help() works.
5206
5212
5207 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
5213 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
5208 macro scoping: macros need to be executed in the user's namespace
5214 macro scoping: macros need to be executed in the user's namespace
5209 to work as if they had been typed by the user.
5215 to work as if they had been typed by the user.
5210
5216
5211 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
5217 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
5212 execute automatically (no need to type 'exec...'). They then
5218 execute automatically (no need to type 'exec...'). They then
5213 behave like 'true macros'. The printing system was also modified
5219 behave like 'true macros'. The printing system was also modified
5214 for this to work.
5220 for this to work.
5215
5221
5216 2002-02-19 Fernando Perez <fperez@colorado.edu>
5222 2002-02-19 Fernando Perez <fperez@colorado.edu>
5217
5223
5218 * IPython/genutils.py (page_file): new function for paging files
5224 * IPython/genutils.py (page_file): new function for paging files
5219 in an OS-independent way. Also necessary for file viewing to work
5225 in an OS-independent way. Also necessary for file viewing to work
5220 well inside Emacs buffers.
5226 well inside Emacs buffers.
5221 (page): Added checks for being in an emacs buffer.
5227 (page): Added checks for being in an emacs buffer.
5222 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
5228 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
5223 same bug in iplib.
5229 same bug in iplib.
5224
5230
5225 2002-02-18 Fernando Perez <fperez@colorado.edu>
5231 2002-02-18 Fernando Perez <fperez@colorado.edu>
5226
5232
5227 * IPython/iplib.py (InteractiveShell.init_readline): modified use
5233 * IPython/iplib.py (InteractiveShell.init_readline): modified use
5228 of readline so that IPython can work inside an Emacs buffer.
5234 of readline so that IPython can work inside an Emacs buffer.
5229
5235
5230 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
5236 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
5231 method signatures (they weren't really bugs, but it looks cleaner
5237 method signatures (they weren't really bugs, but it looks cleaner
5232 and keeps PyChecker happy).
5238 and keeps PyChecker happy).
5233
5239
5234 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
5240 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
5235 for implementing various user-defined hooks. Currently only
5241 for implementing various user-defined hooks. Currently only
5236 display is done.
5242 display is done.
5237
5243
5238 * IPython/Prompts.py (CachedOutput._display): changed display
5244 * IPython/Prompts.py (CachedOutput._display): changed display
5239 functions so that they can be dynamically changed by users easily.
5245 functions so that they can be dynamically changed by users easily.
5240
5246
5241 * IPython/Extensions/numeric_formats.py (num_display): added an
5247 * IPython/Extensions/numeric_formats.py (num_display): added an
5242 extension for printing NumPy arrays in flexible manners. It
5248 extension for printing NumPy arrays in flexible manners. It
5243 doesn't do anything yet, but all the structure is in
5249 doesn't do anything yet, but all the structure is in
5244 place. Ultimately the plan is to implement output format control
5250 place. Ultimately the plan is to implement output format control
5245 like in Octave.
5251 like in Octave.
5246
5252
5247 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
5253 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
5248 methods are found at run-time by all the automatic machinery.
5254 methods are found at run-time by all the automatic machinery.
5249
5255
5250 2002-02-17 Fernando Perez <fperez@colorado.edu>
5256 2002-02-17 Fernando Perez <fperez@colorado.edu>
5251
5257
5252 * setup_Windows.py (make_shortcut): documented. Cleaned up the
5258 * setup_Windows.py (make_shortcut): documented. Cleaned up the
5253 whole file a little.
5259 whole file a little.
5254
5260
5255 * ToDo: closed this document. Now there's a new_design.lyx
5261 * ToDo: closed this document. Now there's a new_design.lyx
5256 document for all new ideas. Added making a pdf of it for the
5262 document for all new ideas. Added making a pdf of it for the
5257 end-user distro.
5263 end-user distro.
5258
5264
5259 * IPython/Logger.py (Logger.switch_log): Created this to replace
5265 * IPython/Logger.py (Logger.switch_log): Created this to replace
5260 logon() and logoff(). It also fixes a nasty crash reported by
5266 logon() and logoff(). It also fixes a nasty crash reported by
5261 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
5267 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
5262
5268
5263 * IPython/iplib.py (complete): got auto-completion to work with
5269 * IPython/iplib.py (complete): got auto-completion to work with
5264 automagic (I had wanted this for a long time).
5270 automagic (I had wanted this for a long time).
5265
5271
5266 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
5272 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
5267 to @file, since file() is now a builtin and clashes with automagic
5273 to @file, since file() is now a builtin and clashes with automagic
5268 for @file.
5274 for @file.
5269
5275
5270 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
5276 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
5271 of this was previously in iplib, which had grown to more than 2000
5277 of this was previously in iplib, which had grown to more than 2000
5272 lines, way too long. No new functionality, but it makes managing
5278 lines, way too long. No new functionality, but it makes managing
5273 the code a bit easier.
5279 the code a bit easier.
5274
5280
5275 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
5281 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
5276 information to crash reports.
5282 information to crash reports.
5277
5283
5278 2002-02-12 Fernando Perez <fperez@colorado.edu>
5284 2002-02-12 Fernando Perez <fperez@colorado.edu>
5279
5285
5280 * Released 0.2.5.
5286 * Released 0.2.5.
5281
5287
5282 2002-02-11 Fernando Perez <fperez@colorado.edu>
5288 2002-02-11 Fernando Perez <fperez@colorado.edu>
5283
5289
5284 * Wrote a relatively complete Windows installer. It puts
5290 * Wrote a relatively complete Windows installer. It puts
5285 everything in place, creates Start Menu entries and fixes the
5291 everything in place, creates Start Menu entries and fixes the
5286 color issues. Nothing fancy, but it works.
5292 color issues. Nothing fancy, but it works.
5287
5293
5288 2002-02-10 Fernando Perez <fperez@colorado.edu>
5294 2002-02-10 Fernando Perez <fperez@colorado.edu>
5289
5295
5290 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
5296 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
5291 os.path.expanduser() call so that we can type @run ~/myfile.py and
5297 os.path.expanduser() call so that we can type @run ~/myfile.py and
5292 have thigs work as expected.
5298 have thigs work as expected.
5293
5299
5294 * IPython/genutils.py (page): fixed exception handling so things
5300 * IPython/genutils.py (page): fixed exception handling so things
5295 work both in Unix and Windows correctly. Quitting a pager triggers
5301 work both in Unix and Windows correctly. Quitting a pager triggers
5296 an IOError/broken pipe in Unix, and in windows not finding a pager
5302 an IOError/broken pipe in Unix, and in windows not finding a pager
5297 is also an IOError, so I had to actually look at the return value
5303 is also an IOError, so I had to actually look at the return value
5298 of the exception, not just the exception itself. Should be ok now.
5304 of the exception, not just the exception itself. Should be ok now.
5299
5305
5300 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
5306 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
5301 modified to allow case-insensitive color scheme changes.
5307 modified to allow case-insensitive color scheme changes.
5302
5308
5303 2002-02-09 Fernando Perez <fperez@colorado.edu>
5309 2002-02-09 Fernando Perez <fperez@colorado.edu>
5304
5310
5305 * IPython/genutils.py (native_line_ends): new function to leave
5311 * IPython/genutils.py (native_line_ends): new function to leave
5306 user config files with os-native line-endings.
5312 user config files with os-native line-endings.
5307
5313
5308 * README and manual updates.
5314 * README and manual updates.
5309
5315
5310 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
5316 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
5311 instead of StringType to catch Unicode strings.
5317 instead of StringType to catch Unicode strings.
5312
5318
5313 * IPython/genutils.py (filefind): fixed bug for paths with
5319 * IPython/genutils.py (filefind): fixed bug for paths with
5314 embedded spaces (very common in Windows).
5320 embedded spaces (very common in Windows).
5315
5321
5316 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
5322 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
5317 files under Windows, so that they get automatically associated
5323 files under Windows, so that they get automatically associated
5318 with a text editor. Windows makes it a pain to handle
5324 with a text editor. Windows makes it a pain to handle
5319 extension-less files.
5325 extension-less files.
5320
5326
5321 * IPython/iplib.py (InteractiveShell.init_readline): Made the
5327 * IPython/iplib.py (InteractiveShell.init_readline): Made the
5322 warning about readline only occur for Posix. In Windows there's no
5328 warning about readline only occur for Posix. In Windows there's no
5323 way to get readline, so why bother with the warning.
5329 way to get readline, so why bother with the warning.
5324
5330
5325 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
5331 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
5326 for __str__ instead of dir(self), since dir() changed in 2.2.
5332 for __str__ instead of dir(self), since dir() changed in 2.2.
5327
5333
5328 * Ported to Windows! Tested on XP, I suspect it should work fine
5334 * Ported to Windows! Tested on XP, I suspect it should work fine
5329 on NT/2000, but I don't think it will work on 98 et al. That
5335 on NT/2000, but I don't think it will work on 98 et al. That
5330 series of Windows is such a piece of junk anyway that I won't try
5336 series of Windows is such a piece of junk anyway that I won't try
5331 porting it there. The XP port was straightforward, showed a few
5337 porting it there. The XP port was straightforward, showed a few
5332 bugs here and there (fixed all), in particular some string
5338 bugs here and there (fixed all), in particular some string
5333 handling stuff which required considering Unicode strings (which
5339 handling stuff which required considering Unicode strings (which
5334 Windows uses). This is good, but hasn't been too tested :) No
5340 Windows uses). This is good, but hasn't been too tested :) No
5335 fancy installer yet, I'll put a note in the manual so people at
5341 fancy installer yet, I'll put a note in the manual so people at
5336 least make manually a shortcut.
5342 least make manually a shortcut.
5337
5343
5338 * IPython/iplib.py (Magic.magic_colors): Unified the color options
5344 * IPython/iplib.py (Magic.magic_colors): Unified the color options
5339 into a single one, "colors". This now controls both prompt and
5345 into a single one, "colors". This now controls both prompt and
5340 exception color schemes, and can be changed both at startup
5346 exception color schemes, and can be changed both at startup
5341 (either via command-line switches or via ipythonrc files) and at
5347 (either via command-line switches or via ipythonrc files) and at
5342 runtime, with @colors.
5348 runtime, with @colors.
5343 (Magic.magic_run): renamed @prun to @run and removed the old
5349 (Magic.magic_run): renamed @prun to @run and removed the old
5344 @run. The two were too similar to warrant keeping both.
5350 @run. The two were too similar to warrant keeping both.
5345
5351
5346 2002-02-03 Fernando Perez <fperez@colorado.edu>
5352 2002-02-03 Fernando Perez <fperez@colorado.edu>
5347
5353
5348 * IPython/iplib.py (install_first_time): Added comment on how to
5354 * IPython/iplib.py (install_first_time): Added comment on how to
5349 configure the color options for first-time users. Put a <return>
5355 configure the color options for first-time users. Put a <return>
5350 request at the end so that small-terminal users get a chance to
5356 request at the end so that small-terminal users get a chance to
5351 read the startup info.
5357 read the startup info.
5352
5358
5353 2002-01-23 Fernando Perez <fperez@colorado.edu>
5359 2002-01-23 Fernando Perez <fperez@colorado.edu>
5354
5360
5355 * IPython/iplib.py (CachedOutput.update): Changed output memory
5361 * IPython/iplib.py (CachedOutput.update): Changed output memory
5356 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
5362 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
5357 input history we still use _i. Did this b/c these variable are
5363 input history we still use _i. Did this b/c these variable are
5358 very commonly used in interactive work, so the less we need to
5364 very commonly used in interactive work, so the less we need to
5359 type the better off we are.
5365 type the better off we are.
5360 (Magic.magic_prun): updated @prun to better handle the namespaces
5366 (Magic.magic_prun): updated @prun to better handle the namespaces
5361 the file will run in, including a fix for __name__ not being set
5367 the file will run in, including a fix for __name__ not being set
5362 before.
5368 before.
5363
5369
5364 2002-01-20 Fernando Perez <fperez@colorado.edu>
5370 2002-01-20 Fernando Perez <fperez@colorado.edu>
5365
5371
5366 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
5372 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
5367 extra garbage for Python 2.2. Need to look more carefully into
5373 extra garbage for Python 2.2. Need to look more carefully into
5368 this later.
5374 this later.
5369
5375
5370 2002-01-19 Fernando Perez <fperez@colorado.edu>
5376 2002-01-19 Fernando Perez <fperez@colorado.edu>
5371
5377
5372 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
5378 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
5373 display SyntaxError exceptions properly formatted when they occur
5379 display SyntaxError exceptions properly formatted when they occur
5374 (they can be triggered by imported code).
5380 (they can be triggered by imported code).
5375
5381
5376 2002-01-18 Fernando Perez <fperez@colorado.edu>
5382 2002-01-18 Fernando Perez <fperez@colorado.edu>
5377
5383
5378 * IPython/iplib.py (InteractiveShell.safe_execfile): now
5384 * IPython/iplib.py (InteractiveShell.safe_execfile): now
5379 SyntaxError exceptions are reported nicely formatted, instead of
5385 SyntaxError exceptions are reported nicely formatted, instead of
5380 spitting out only offset information as before.
5386 spitting out only offset information as before.
5381 (Magic.magic_prun): Added the @prun function for executing
5387 (Magic.magic_prun): Added the @prun function for executing
5382 programs with command line args inside IPython.
5388 programs with command line args inside IPython.
5383
5389
5384 2002-01-16 Fernando Perez <fperez@colorado.edu>
5390 2002-01-16 Fernando Perez <fperez@colorado.edu>
5385
5391
5386 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
5392 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
5387 to *not* include the last item given in a range. This brings their
5393 to *not* include the last item given in a range. This brings their
5388 behavior in line with Python's slicing:
5394 behavior in line with Python's slicing:
5389 a[n1:n2] -> a[n1]...a[n2-1]
5395 a[n1:n2] -> a[n1]...a[n2-1]
5390 It may be a bit less convenient, but I prefer to stick to Python's
5396 It may be a bit less convenient, but I prefer to stick to Python's
5391 conventions *everywhere*, so users never have to wonder.
5397 conventions *everywhere*, so users never have to wonder.
5392 (Magic.magic_macro): Added @macro function to ease the creation of
5398 (Magic.magic_macro): Added @macro function to ease the creation of
5393 macros.
5399 macros.
5394
5400
5395 2002-01-05 Fernando Perez <fperez@colorado.edu>
5401 2002-01-05 Fernando Perez <fperez@colorado.edu>
5396
5402
5397 * Released 0.2.4.
5403 * Released 0.2.4.
5398
5404
5399 * IPython/iplib.py (Magic.magic_pdef):
5405 * IPython/iplib.py (Magic.magic_pdef):
5400 (InteractiveShell.safe_execfile): report magic lines and error
5406 (InteractiveShell.safe_execfile): report magic lines and error
5401 lines without line numbers so one can easily copy/paste them for
5407 lines without line numbers so one can easily copy/paste them for
5402 re-execution.
5408 re-execution.
5403
5409
5404 * Updated manual with recent changes.
5410 * Updated manual with recent changes.
5405
5411
5406 * IPython/iplib.py (Magic.magic_oinfo): added constructor
5412 * IPython/iplib.py (Magic.magic_oinfo): added constructor
5407 docstring printing when class? is called. Very handy for knowing
5413 docstring printing when class? is called. Very handy for knowing
5408 how to create class instances (as long as __init__ is well
5414 how to create class instances (as long as __init__ is well
5409 documented, of course :)
5415 documented, of course :)
5410 (Magic.magic_doc): print both class and constructor docstrings.
5416 (Magic.magic_doc): print both class and constructor docstrings.
5411 (Magic.magic_pdef): give constructor info if passed a class and
5417 (Magic.magic_pdef): give constructor info if passed a class and
5412 __call__ info for callable object instances.
5418 __call__ info for callable object instances.
5413
5419
5414 2002-01-04 Fernando Perez <fperez@colorado.edu>
5420 2002-01-04 Fernando Perez <fperez@colorado.edu>
5415
5421
5416 * Made deep_reload() off by default. It doesn't always work
5422 * Made deep_reload() off by default. It doesn't always work
5417 exactly as intended, so it's probably safer to have it off. It's
5423 exactly as intended, so it's probably safer to have it off. It's
5418 still available as dreload() anyway, so nothing is lost.
5424 still available as dreload() anyway, so nothing is lost.
5419
5425
5420 2002-01-02 Fernando Perez <fperez@colorado.edu>
5426 2002-01-02 Fernando Perez <fperez@colorado.edu>
5421
5427
5422 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
5428 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
5423 so I wanted an updated release).
5429 so I wanted an updated release).
5424
5430
5425 2001-12-27 Fernando Perez <fperez@colorado.edu>
5431 2001-12-27 Fernando Perez <fperez@colorado.edu>
5426
5432
5427 * IPython/iplib.py (InteractiveShell.interact): Added the original
5433 * IPython/iplib.py (InteractiveShell.interact): Added the original
5428 code from 'code.py' for this module in order to change the
5434 code from 'code.py' for this module in order to change the
5429 handling of a KeyboardInterrupt. This was necessary b/c otherwise
5435 handling of a KeyboardInterrupt. This was necessary b/c otherwise
5430 the history cache would break when the user hit Ctrl-C, and
5436 the history cache would break when the user hit Ctrl-C, and
5431 interact() offers no way to add any hooks to it.
5437 interact() offers no way to add any hooks to it.
5432
5438
5433 2001-12-23 Fernando Perez <fperez@colorado.edu>
5439 2001-12-23 Fernando Perez <fperez@colorado.edu>
5434
5440
5435 * setup.py: added check for 'MANIFEST' before trying to remove
5441 * setup.py: added check for 'MANIFEST' before trying to remove
5436 it. Thanks to Sean Reifschneider.
5442 it. Thanks to Sean Reifschneider.
5437
5443
5438 2001-12-22 Fernando Perez <fperez@colorado.edu>
5444 2001-12-22 Fernando Perez <fperez@colorado.edu>
5439
5445
5440 * Released 0.2.2.
5446 * Released 0.2.2.
5441
5447
5442 * Finished (reasonably) writing the manual. Later will add the
5448 * Finished (reasonably) writing the manual. Later will add the
5443 python-standard navigation stylesheets, but for the time being
5449 python-standard navigation stylesheets, but for the time being
5444 it's fairly complete. Distribution will include html and pdf
5450 it's fairly complete. Distribution will include html and pdf
5445 versions.
5451 versions.
5446
5452
5447 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
5453 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
5448 (MayaVi author).
5454 (MayaVi author).
5449
5455
5450 2001-12-21 Fernando Perez <fperez@colorado.edu>
5456 2001-12-21 Fernando Perez <fperez@colorado.edu>
5451
5457
5452 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
5458 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
5453 good public release, I think (with the manual and the distutils
5459 good public release, I think (with the manual and the distutils
5454 installer). The manual can use some work, but that can go
5460 installer). The manual can use some work, but that can go
5455 slowly. Otherwise I think it's quite nice for end users. Next
5461 slowly. Otherwise I think it's quite nice for end users. Next
5456 summer, rewrite the guts of it...
5462 summer, rewrite the guts of it...
5457
5463
5458 * Changed format of ipythonrc files to use whitespace as the
5464 * Changed format of ipythonrc files to use whitespace as the
5459 separator instead of an explicit '='. Cleaner.
5465 separator instead of an explicit '='. Cleaner.
5460
5466
5461 2001-12-20 Fernando Perez <fperez@colorado.edu>
5467 2001-12-20 Fernando Perez <fperez@colorado.edu>
5462
5468
5463 * Started a manual in LyX. For now it's just a quick merge of the
5469 * Started a manual in LyX. For now it's just a quick merge of the
5464 various internal docstrings and READMEs. Later it may grow into a
5470 various internal docstrings and READMEs. Later it may grow into a
5465 nice, full-blown manual.
5471 nice, full-blown manual.
5466
5472
5467 * Set up a distutils based installer. Installation should now be
5473 * Set up a distutils based installer. Installation should now be
5468 trivially simple for end-users.
5474 trivially simple for end-users.
5469
5475
5470 2001-12-11 Fernando Perez <fperez@colorado.edu>
5476 2001-12-11 Fernando Perez <fperez@colorado.edu>
5471
5477
5472 * Released 0.2.0. First public release, announced it at
5478 * Released 0.2.0. First public release, announced it at
5473 comp.lang.python. From now on, just bugfixes...
5479 comp.lang.python. From now on, just bugfixes...
5474
5480
5475 * Went through all the files, set copyright/license notices and
5481 * Went through all the files, set copyright/license notices and
5476 cleaned up things. Ready for release.
5482 cleaned up things. Ready for release.
5477
5483
5478 2001-12-10 Fernando Perez <fperez@colorado.edu>
5484 2001-12-10 Fernando Perez <fperez@colorado.edu>
5479
5485
5480 * Changed the first-time installer not to use tarfiles. It's more
5486 * Changed the first-time installer not to use tarfiles. It's more
5481 robust now and less unix-dependent. Also makes it easier for
5487 robust now and less unix-dependent. Also makes it easier for
5482 people to later upgrade versions.
5488 people to later upgrade versions.
5483
5489
5484 * Changed @exit to @abort to reflect the fact that it's pretty
5490 * Changed @exit to @abort to reflect the fact that it's pretty
5485 brutal (a sys.exit()). The difference between @abort and Ctrl-D
5491 brutal (a sys.exit()). The difference between @abort and Ctrl-D
5486 becomes significant only when IPyhton is embedded: in that case,
5492 becomes significant only when IPyhton is embedded: in that case,
5487 C-D closes IPython only, but @abort kills the enclosing program
5493 C-D closes IPython only, but @abort kills the enclosing program
5488 too (unless it had called IPython inside a try catching
5494 too (unless it had called IPython inside a try catching
5489 SystemExit).
5495 SystemExit).
5490
5496
5491 * Created Shell module which exposes the actuall IPython Shell
5497 * Created Shell module which exposes the actuall IPython Shell
5492 classes, currently the normal and the embeddable one. This at
5498 classes, currently the normal and the embeddable one. This at
5493 least offers a stable interface we won't need to change when
5499 least offers a stable interface we won't need to change when
5494 (later) the internals are rewritten. That rewrite will be confined
5500 (later) the internals are rewritten. That rewrite will be confined
5495 to iplib and ipmaker, but the Shell interface should remain as is.
5501 to iplib and ipmaker, but the Shell interface should remain as is.
5496
5502
5497 * Added embed module which offers an embeddable IPShell object,
5503 * Added embed module which offers an embeddable IPShell object,
5498 useful to fire up IPython *inside* a running program. Great for
5504 useful to fire up IPython *inside* a running program. Great for
5499 debugging or dynamical data analysis.
5505 debugging or dynamical data analysis.
5500
5506
5501 2001-12-08 Fernando Perez <fperez@colorado.edu>
5507 2001-12-08 Fernando Perez <fperez@colorado.edu>
5502
5508
5503 * Fixed small bug preventing seeing info from methods of defined
5509 * Fixed small bug preventing seeing info from methods of defined
5504 objects (incorrect namespace in _ofind()).
5510 objects (incorrect namespace in _ofind()).
5505
5511
5506 * Documentation cleanup. Moved the main usage docstrings to a
5512 * Documentation cleanup. Moved the main usage docstrings to a
5507 separate file, usage.py (cleaner to maintain, and hopefully in the
5513 separate file, usage.py (cleaner to maintain, and hopefully in the
5508 future some perlpod-like way of producing interactive, man and
5514 future some perlpod-like way of producing interactive, man and
5509 html docs out of it will be found).
5515 html docs out of it will be found).
5510
5516
5511 * Added @profile to see your profile at any time.
5517 * Added @profile to see your profile at any time.
5512
5518
5513 * Added @p as an alias for 'print'. It's especially convenient if
5519 * Added @p as an alias for 'print'. It's especially convenient if
5514 using automagic ('p x' prints x).
5520 using automagic ('p x' prints x).
5515
5521
5516 * Small cleanups and fixes after a pychecker run.
5522 * Small cleanups and fixes after a pychecker run.
5517
5523
5518 * Changed the @cd command to handle @cd - and @cd -<n> for
5524 * Changed the @cd command to handle @cd - and @cd -<n> for
5519 visiting any directory in _dh.
5525 visiting any directory in _dh.
5520
5526
5521 * Introduced _dh, a history of visited directories. @dhist prints
5527 * Introduced _dh, a history of visited directories. @dhist prints
5522 it out with numbers.
5528 it out with numbers.
5523
5529
5524 2001-12-07 Fernando Perez <fperez@colorado.edu>
5530 2001-12-07 Fernando Perez <fperez@colorado.edu>
5525
5531
5526 * Released 0.1.22
5532 * Released 0.1.22
5527
5533
5528 * Made initialization a bit more robust against invalid color
5534 * Made initialization a bit more robust against invalid color
5529 options in user input (exit, not traceback-crash).
5535 options in user input (exit, not traceback-crash).
5530
5536
5531 * Changed the bug crash reporter to write the report only in the
5537 * Changed the bug crash reporter to write the report only in the
5532 user's .ipython directory. That way IPython won't litter people's
5538 user's .ipython directory. That way IPython won't litter people's
5533 hard disks with crash files all over the place. Also print on
5539 hard disks with crash files all over the place. Also print on
5534 screen the necessary mail command.
5540 screen the necessary mail command.
5535
5541
5536 * With the new ultraTB, implemented LightBG color scheme for light
5542 * With the new ultraTB, implemented LightBG color scheme for light
5537 background terminals. A lot of people like white backgrounds, so I
5543 background terminals. A lot of people like white backgrounds, so I
5538 guess we should at least give them something readable.
5544 guess we should at least give them something readable.
5539
5545
5540 2001-12-06 Fernando Perez <fperez@colorado.edu>
5546 2001-12-06 Fernando Perez <fperez@colorado.edu>
5541
5547
5542 * Modified the structure of ultraTB. Now there's a proper class
5548 * Modified the structure of ultraTB. Now there's a proper class
5543 for tables of color schemes which allow adding schemes easily and
5549 for tables of color schemes which allow adding schemes easily and
5544 switching the active scheme without creating a new instance every
5550 switching the active scheme without creating a new instance every
5545 time (which was ridiculous). The syntax for creating new schemes
5551 time (which was ridiculous). The syntax for creating new schemes
5546 is also cleaner. I think ultraTB is finally done, with a clean
5552 is also cleaner. I think ultraTB is finally done, with a clean
5547 class structure. Names are also much cleaner (now there's proper
5553 class structure. Names are also much cleaner (now there's proper
5548 color tables, no need for every variable to also have 'color' in
5554 color tables, no need for every variable to also have 'color' in
5549 its name).
5555 its name).
5550
5556
5551 * Broke down genutils into separate files. Now genutils only
5557 * Broke down genutils into separate files. Now genutils only
5552 contains utility functions, and classes have been moved to their
5558 contains utility functions, and classes have been moved to their
5553 own files (they had enough independent functionality to warrant
5559 own files (they had enough independent functionality to warrant
5554 it): ConfigLoader, OutputTrap, Struct.
5560 it): ConfigLoader, OutputTrap, Struct.
5555
5561
5556 2001-12-05 Fernando Perez <fperez@colorado.edu>
5562 2001-12-05 Fernando Perez <fperez@colorado.edu>
5557
5563
5558 * IPython turns 21! Released version 0.1.21, as a candidate for
5564 * IPython turns 21! Released version 0.1.21, as a candidate for
5559 public consumption. If all goes well, release in a few days.
5565 public consumption. If all goes well, release in a few days.
5560
5566
5561 * Fixed path bug (files in Extensions/ directory wouldn't be found
5567 * Fixed path bug (files in Extensions/ directory wouldn't be found
5562 unless IPython/ was explicitly in sys.path).
5568 unless IPython/ was explicitly in sys.path).
5563
5569
5564 * Extended the FlexCompleter class as MagicCompleter to allow
5570 * Extended the FlexCompleter class as MagicCompleter to allow
5565 completion of @-starting lines.
5571 completion of @-starting lines.
5566
5572
5567 * Created __release__.py file as a central repository for release
5573 * Created __release__.py file as a central repository for release
5568 info that other files can read from.
5574 info that other files can read from.
5569
5575
5570 * Fixed small bug in logging: when logging was turned on in
5576 * Fixed small bug in logging: when logging was turned on in
5571 mid-session, old lines with special meanings (!@?) were being
5577 mid-session, old lines with special meanings (!@?) were being
5572 logged without the prepended comment, which is necessary since
5578 logged without the prepended comment, which is necessary since
5573 they are not truly valid python syntax. This should make session
5579 they are not truly valid python syntax. This should make session
5574 restores produce less errors.
5580 restores produce less errors.
5575
5581
5576 * The namespace cleanup forced me to make a FlexCompleter class
5582 * The namespace cleanup forced me to make a FlexCompleter class
5577 which is nothing but a ripoff of rlcompleter, but with selectable
5583 which is nothing but a ripoff of rlcompleter, but with selectable
5578 namespace (rlcompleter only works in __main__.__dict__). I'll try
5584 namespace (rlcompleter only works in __main__.__dict__). I'll try
5579 to submit a note to the authors to see if this change can be
5585 to submit a note to the authors to see if this change can be
5580 incorporated in future rlcompleter releases (Dec.6: done)
5586 incorporated in future rlcompleter releases (Dec.6: done)
5581
5587
5582 * More fixes to namespace handling. It was a mess! Now all
5588 * More fixes to namespace handling. It was a mess! Now all
5583 explicit references to __main__.__dict__ are gone (except when
5589 explicit references to __main__.__dict__ are gone (except when
5584 really needed) and everything is handled through the namespace
5590 really needed) and everything is handled through the namespace
5585 dicts in the IPython instance. We seem to be getting somewhere
5591 dicts in the IPython instance. We seem to be getting somewhere
5586 with this, finally...
5592 with this, finally...
5587
5593
5588 * Small documentation updates.
5594 * Small documentation updates.
5589
5595
5590 * Created the Extensions directory under IPython (with an
5596 * Created the Extensions directory under IPython (with an
5591 __init__.py). Put the PhysicalQ stuff there. This directory should
5597 __init__.py). Put the PhysicalQ stuff there. This directory should
5592 be used for all special-purpose extensions.
5598 be used for all special-purpose extensions.
5593
5599
5594 * File renaming:
5600 * File renaming:
5595 ipythonlib --> ipmaker
5601 ipythonlib --> ipmaker
5596 ipplib --> iplib
5602 ipplib --> iplib
5597 This makes a bit more sense in terms of what these files actually do.
5603 This makes a bit more sense in terms of what these files actually do.
5598
5604
5599 * Moved all the classes and functions in ipythonlib to ipplib, so
5605 * Moved all the classes and functions in ipythonlib to ipplib, so
5600 now ipythonlib only has make_IPython(). This will ease up its
5606 now ipythonlib only has make_IPython(). This will ease up its
5601 splitting in smaller functional chunks later.
5607 splitting in smaller functional chunks later.
5602
5608
5603 * Cleaned up (done, I think) output of @whos. Better column
5609 * Cleaned up (done, I think) output of @whos. Better column
5604 formatting, and now shows str(var) for as much as it can, which is
5610 formatting, and now shows str(var) for as much as it can, which is
5605 typically what one gets with a 'print var'.
5611 typically what one gets with a 'print var'.
5606
5612
5607 2001-12-04 Fernando Perez <fperez@colorado.edu>
5613 2001-12-04 Fernando Perez <fperez@colorado.edu>
5608
5614
5609 * Fixed namespace problems. Now builtin/IPyhton/user names get
5615 * Fixed namespace problems. Now builtin/IPyhton/user names get
5610 properly reported in their namespace. Internal namespace handling
5616 properly reported in their namespace. Internal namespace handling
5611 is finally getting decent (not perfect yet, but much better than
5617 is finally getting decent (not perfect yet, but much better than
5612 the ad-hoc mess we had).
5618 the ad-hoc mess we had).
5613
5619
5614 * Removed -exit option. If people just want to run a python
5620 * Removed -exit option. If people just want to run a python
5615 script, that's what the normal interpreter is for. Less
5621 script, that's what the normal interpreter is for. Less
5616 unnecessary options, less chances for bugs.
5622 unnecessary options, less chances for bugs.
5617
5623
5618 * Added a crash handler which generates a complete post-mortem if
5624 * Added a crash handler which generates a complete post-mortem if
5619 IPython crashes. This will help a lot in tracking bugs down the
5625 IPython crashes. This will help a lot in tracking bugs down the
5620 road.
5626 road.
5621
5627
5622 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
5628 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
5623 which were boud to functions being reassigned would bypass the
5629 which were boud to functions being reassigned would bypass the
5624 logger, breaking the sync of _il with the prompt counter. This
5630 logger, breaking the sync of _il with the prompt counter. This
5625 would then crash IPython later when a new line was logged.
5631 would then crash IPython later when a new line was logged.
5626
5632
5627 2001-12-02 Fernando Perez <fperez@colorado.edu>
5633 2001-12-02 Fernando Perez <fperez@colorado.edu>
5628
5634
5629 * Made IPython a package. This means people don't have to clutter
5635 * Made IPython a package. This means people don't have to clutter
5630 their sys.path with yet another directory. Changed the INSTALL
5636 their sys.path with yet another directory. Changed the INSTALL
5631 file accordingly.
5637 file accordingly.
5632
5638
5633 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
5639 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
5634 sorts its output (so @who shows it sorted) and @whos formats the
5640 sorts its output (so @who shows it sorted) and @whos formats the
5635 table according to the width of the first column. Nicer, easier to
5641 table according to the width of the first column. Nicer, easier to
5636 read. Todo: write a generic table_format() which takes a list of
5642 read. Todo: write a generic table_format() which takes a list of
5637 lists and prints it nicely formatted, with optional row/column
5643 lists and prints it nicely formatted, with optional row/column
5638 separators and proper padding and justification.
5644 separators and proper padding and justification.
5639
5645
5640 * Released 0.1.20
5646 * Released 0.1.20
5641
5647
5642 * Fixed bug in @log which would reverse the inputcache list (a
5648 * Fixed bug in @log which would reverse the inputcache list (a
5643 copy operation was missing).
5649 copy operation was missing).
5644
5650
5645 * Code cleanup. @config was changed to use page(). Better, since
5651 * Code cleanup. @config was changed to use page(). Better, since
5646 its output is always quite long.
5652 its output is always quite long.
5647
5653
5648 * Itpl is back as a dependency. I was having too many problems
5654 * Itpl is back as a dependency. I was having too many problems
5649 getting the parametric aliases to work reliably, and it's just
5655 getting the parametric aliases to work reliably, and it's just
5650 easier to code weird string operations with it than playing %()s
5656 easier to code weird string operations with it than playing %()s
5651 games. It's only ~6k, so I don't think it's too big a deal.
5657 games. It's only ~6k, so I don't think it's too big a deal.
5652
5658
5653 * Found (and fixed) a very nasty bug with history. !lines weren't
5659 * Found (and fixed) a very nasty bug with history. !lines weren't
5654 getting cached, and the out of sync caches would crash
5660 getting cached, and the out of sync caches would crash
5655 IPython. Fixed it by reorganizing the prefilter/handlers/logger
5661 IPython. Fixed it by reorganizing the prefilter/handlers/logger
5656 division of labor a bit better. Bug fixed, cleaner structure.
5662 division of labor a bit better. Bug fixed, cleaner structure.
5657
5663
5658 2001-12-01 Fernando Perez <fperez@colorado.edu>
5664 2001-12-01 Fernando Perez <fperez@colorado.edu>
5659
5665
5660 * Released 0.1.19
5666 * Released 0.1.19
5661
5667
5662 * Added option -n to @hist to prevent line number printing. Much
5668 * Added option -n to @hist to prevent line number printing. Much
5663 easier to copy/paste code this way.
5669 easier to copy/paste code this way.
5664
5670
5665 * Created global _il to hold the input list. Allows easy
5671 * Created global _il to hold the input list. Allows easy
5666 re-execution of blocks of code by slicing it (inspired by Janko's
5672 re-execution of blocks of code by slicing it (inspired by Janko's
5667 comment on 'macros').
5673 comment on 'macros').
5668
5674
5669 * Small fixes and doc updates.
5675 * Small fixes and doc updates.
5670
5676
5671 * Rewrote @history function (was @h). Renamed it to @hist, @h is
5677 * Rewrote @history function (was @h). Renamed it to @hist, @h is
5672 much too fragile with automagic. Handles properly multi-line
5678 much too fragile with automagic. Handles properly multi-line
5673 statements and takes parameters.
5679 statements and takes parameters.
5674
5680
5675 2001-11-30 Fernando Perez <fperez@colorado.edu>
5681 2001-11-30 Fernando Perez <fperez@colorado.edu>
5676
5682
5677 * Version 0.1.18 released.
5683 * Version 0.1.18 released.
5678
5684
5679 * Fixed nasty namespace bug in initial module imports.
5685 * Fixed nasty namespace bug in initial module imports.
5680
5686
5681 * Added copyright/license notes to all code files (except
5687 * Added copyright/license notes to all code files (except
5682 DPyGetOpt). For the time being, LGPL. That could change.
5688 DPyGetOpt). For the time being, LGPL. That could change.
5683
5689
5684 * Rewrote a much nicer README, updated INSTALL, cleaned up
5690 * Rewrote a much nicer README, updated INSTALL, cleaned up
5685 ipythonrc-* samples.
5691 ipythonrc-* samples.
5686
5692
5687 * Overall code/documentation cleanup. Basically ready for
5693 * Overall code/documentation cleanup. Basically ready for
5688 release. Only remaining thing: licence decision (LGPL?).
5694 release. Only remaining thing: licence decision (LGPL?).
5689
5695
5690 * Converted load_config to a class, ConfigLoader. Now recursion
5696 * Converted load_config to a class, ConfigLoader. Now recursion
5691 control is better organized. Doesn't include the same file twice.
5697 control is better organized. Doesn't include the same file twice.
5692
5698
5693 2001-11-29 Fernando Perez <fperez@colorado.edu>
5699 2001-11-29 Fernando Perez <fperez@colorado.edu>
5694
5700
5695 * Got input history working. Changed output history variables from
5701 * Got input history working. Changed output history variables from
5696 _p to _o so that _i is for input and _o for output. Just cleaner
5702 _p to _o so that _i is for input and _o for output. Just cleaner
5697 convention.
5703 convention.
5698
5704
5699 * Implemented parametric aliases. This pretty much allows the
5705 * Implemented parametric aliases. This pretty much allows the
5700 alias system to offer full-blown shell convenience, I think.
5706 alias system to offer full-blown shell convenience, I think.
5701
5707
5702 * Version 0.1.17 released, 0.1.18 opened.
5708 * Version 0.1.17 released, 0.1.18 opened.
5703
5709
5704 * dot_ipython/ipythonrc (alias): added documentation.
5710 * dot_ipython/ipythonrc (alias): added documentation.
5705 (xcolor): Fixed small bug (xcolors -> xcolor)
5711 (xcolor): Fixed small bug (xcolors -> xcolor)
5706
5712
5707 * Changed the alias system. Now alias is a magic command to define
5713 * Changed the alias system. Now alias is a magic command to define
5708 aliases just like the shell. Rationale: the builtin magics should
5714 aliases just like the shell. Rationale: the builtin magics should
5709 be there for things deeply connected to IPython's
5715 be there for things deeply connected to IPython's
5710 architecture. And this is a much lighter system for what I think
5716 architecture. And this is a much lighter system for what I think
5711 is the really important feature: allowing users to define quickly
5717 is the really important feature: allowing users to define quickly
5712 magics that will do shell things for them, so they can customize
5718 magics that will do shell things for them, so they can customize
5713 IPython easily to match their work habits. If someone is really
5719 IPython easily to match their work habits. If someone is really
5714 desperate to have another name for a builtin alias, they can
5720 desperate to have another name for a builtin alias, they can
5715 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
5721 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
5716 works.
5722 works.
5717
5723
5718 2001-11-28 Fernando Perez <fperez@colorado.edu>
5724 2001-11-28 Fernando Perez <fperez@colorado.edu>
5719
5725
5720 * Changed @file so that it opens the source file at the proper
5726 * Changed @file so that it opens the source file at the proper
5721 line. Since it uses less, if your EDITOR environment is
5727 line. Since it uses less, if your EDITOR environment is
5722 configured, typing v will immediately open your editor of choice
5728 configured, typing v will immediately open your editor of choice
5723 right at the line where the object is defined. Not as quick as
5729 right at the line where the object is defined. Not as quick as
5724 having a direct @edit command, but for all intents and purposes it
5730 having a direct @edit command, but for all intents and purposes it
5725 works. And I don't have to worry about writing @edit to deal with
5731 works. And I don't have to worry about writing @edit to deal with
5726 all the editors, less does that.
5732 all the editors, less does that.
5727
5733
5728 * Version 0.1.16 released, 0.1.17 opened.
5734 * Version 0.1.16 released, 0.1.17 opened.
5729
5735
5730 * Fixed some nasty bugs in the page/page_dumb combo that could
5736 * Fixed some nasty bugs in the page/page_dumb combo that could
5731 crash IPython.
5737 crash IPython.
5732
5738
5733 2001-11-27 Fernando Perez <fperez@colorado.edu>
5739 2001-11-27 Fernando Perez <fperez@colorado.edu>
5734
5740
5735 * Version 0.1.15 released, 0.1.16 opened.
5741 * Version 0.1.15 released, 0.1.16 opened.
5736
5742
5737 * Finally got ? and ?? to work for undefined things: now it's
5743 * Finally got ? and ?? to work for undefined things: now it's
5738 possible to type {}.get? and get information about the get method
5744 possible to type {}.get? and get information about the get method
5739 of dicts, or os.path? even if only os is defined (so technically
5745 of dicts, or os.path? even if only os is defined (so technically
5740 os.path isn't). Works at any level. For example, after import os,
5746 os.path isn't). Works at any level. For example, after import os,
5741 os?, os.path?, os.path.abspath? all work. This is great, took some
5747 os?, os.path?, os.path.abspath? all work. This is great, took some
5742 work in _ofind.
5748 work in _ofind.
5743
5749
5744 * Fixed more bugs with logging. The sanest way to do it was to add
5750 * Fixed more bugs with logging. The sanest way to do it was to add
5745 to @log a 'mode' parameter. Killed two in one shot (this mode
5751 to @log a 'mode' parameter. Killed two in one shot (this mode
5746 option was a request of Janko's). I think it's finally clean
5752 option was a request of Janko's). I think it's finally clean
5747 (famous last words).
5753 (famous last words).
5748
5754
5749 * Added a page_dumb() pager which does a decent job of paging on
5755 * Added a page_dumb() pager which does a decent job of paging on
5750 screen, if better things (like less) aren't available. One less
5756 screen, if better things (like less) aren't available. One less
5751 unix dependency (someday maybe somebody will port this to
5757 unix dependency (someday maybe somebody will port this to
5752 windows).
5758 windows).
5753
5759
5754 * Fixed problem in magic_log: would lock of logging out if log
5760 * Fixed problem in magic_log: would lock of logging out if log
5755 creation failed (because it would still think it had succeeded).
5761 creation failed (because it would still think it had succeeded).
5756
5762
5757 * Improved the page() function using curses to auto-detect screen
5763 * Improved the page() function using curses to auto-detect screen
5758 size. Now it can make a much better decision on whether to print
5764 size. Now it can make a much better decision on whether to print
5759 or page a string. Option screen_length was modified: a value 0
5765 or page a string. Option screen_length was modified: a value 0
5760 means auto-detect, and that's the default now.
5766 means auto-detect, and that's the default now.
5761
5767
5762 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
5768 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
5763 go out. I'll test it for a few days, then talk to Janko about
5769 go out. I'll test it for a few days, then talk to Janko about
5764 licences and announce it.
5770 licences and announce it.
5765
5771
5766 * Fixed the length of the auto-generated ---> prompt which appears
5772 * Fixed the length of the auto-generated ---> prompt which appears
5767 for auto-parens and auto-quotes. Getting this right isn't trivial,
5773 for auto-parens and auto-quotes. Getting this right isn't trivial,
5768 with all the color escapes, different prompt types and optional
5774 with all the color escapes, different prompt types and optional
5769 separators. But it seems to be working in all the combinations.
5775 separators. But it seems to be working in all the combinations.
5770
5776
5771 2001-11-26 Fernando Perez <fperez@colorado.edu>
5777 2001-11-26 Fernando Perez <fperez@colorado.edu>
5772
5778
5773 * Wrote a regexp filter to get option types from the option names
5779 * Wrote a regexp filter to get option types from the option names
5774 string. This eliminates the need to manually keep two duplicate
5780 string. This eliminates the need to manually keep two duplicate
5775 lists.
5781 lists.
5776
5782
5777 * Removed the unneeded check_option_names. Now options are handled
5783 * Removed the unneeded check_option_names. Now options are handled
5778 in a much saner manner and it's easy to visually check that things
5784 in a much saner manner and it's easy to visually check that things
5779 are ok.
5785 are ok.
5780
5786
5781 * Updated version numbers on all files I modified to carry a
5787 * Updated version numbers on all files I modified to carry a
5782 notice so Janko and Nathan have clear version markers.
5788 notice so Janko and Nathan have clear version markers.
5783
5789
5784 * Updated docstring for ultraTB with my changes. I should send
5790 * Updated docstring for ultraTB with my changes. I should send
5785 this to Nathan.
5791 this to Nathan.
5786
5792
5787 * Lots of small fixes. Ran everything through pychecker again.
5793 * Lots of small fixes. Ran everything through pychecker again.
5788
5794
5789 * Made loading of deep_reload an cmd line option. If it's not too
5795 * Made loading of deep_reload an cmd line option. If it's not too
5790 kosher, now people can just disable it. With -nodeep_reload it's
5796 kosher, now people can just disable it. With -nodeep_reload it's
5791 still available as dreload(), it just won't overwrite reload().
5797 still available as dreload(), it just won't overwrite reload().
5792
5798
5793 * Moved many options to the no| form (-opt and -noopt
5799 * Moved many options to the no| form (-opt and -noopt
5794 accepted). Cleaner.
5800 accepted). Cleaner.
5795
5801
5796 * Changed magic_log so that if called with no parameters, it uses
5802 * Changed magic_log so that if called with no parameters, it uses
5797 'rotate' mode. That way auto-generated logs aren't automatically
5803 'rotate' mode. That way auto-generated logs aren't automatically
5798 over-written. For normal logs, now a backup is made if it exists
5804 over-written. For normal logs, now a backup is made if it exists
5799 (only 1 level of backups). A new 'backup' mode was added to the
5805 (only 1 level of backups). A new 'backup' mode was added to the
5800 Logger class to support this. This was a request by Janko.
5806 Logger class to support this. This was a request by Janko.
5801
5807
5802 * Added @logoff/@logon to stop/restart an active log.
5808 * Added @logoff/@logon to stop/restart an active log.
5803
5809
5804 * Fixed a lot of bugs in log saving/replay. It was pretty
5810 * Fixed a lot of bugs in log saving/replay. It was pretty
5805 broken. Now special lines (!@,/) appear properly in the command
5811 broken. Now special lines (!@,/) appear properly in the command
5806 history after a log replay.
5812 history after a log replay.
5807
5813
5808 * Tried and failed to implement full session saving via pickle. My
5814 * Tried and failed to implement full session saving via pickle. My
5809 idea was to pickle __main__.__dict__, but modules can't be
5815 idea was to pickle __main__.__dict__, but modules can't be
5810 pickled. This would be a better alternative to replaying logs, but
5816 pickled. This would be a better alternative to replaying logs, but
5811 seems quite tricky to get to work. Changed -session to be called
5817 seems quite tricky to get to work. Changed -session to be called
5812 -logplay, which more accurately reflects what it does. And if we
5818 -logplay, which more accurately reflects what it does. And if we
5813 ever get real session saving working, -session is now available.
5819 ever get real session saving working, -session is now available.
5814
5820
5815 * Implemented color schemes for prompts also. As for tracebacks,
5821 * Implemented color schemes for prompts also. As for tracebacks,
5816 currently only NoColor and Linux are supported. But now the
5822 currently only NoColor and Linux are supported. But now the
5817 infrastructure is in place, based on a generic ColorScheme
5823 infrastructure is in place, based on a generic ColorScheme
5818 class. So writing and activating new schemes both for the prompts
5824 class. So writing and activating new schemes both for the prompts
5819 and the tracebacks should be straightforward.
5825 and the tracebacks should be straightforward.
5820
5826
5821 * Version 0.1.13 released, 0.1.14 opened.
5827 * Version 0.1.13 released, 0.1.14 opened.
5822
5828
5823 * Changed handling of options for output cache. Now counter is
5829 * Changed handling of options for output cache. Now counter is
5824 hardwired starting at 1 and one specifies the maximum number of
5830 hardwired starting at 1 and one specifies the maximum number of
5825 entries *in the outcache* (not the max prompt counter). This is
5831 entries *in the outcache* (not the max prompt counter). This is
5826 much better, since many statements won't increase the cache
5832 much better, since many statements won't increase the cache
5827 count. It also eliminated some confusing options, now there's only
5833 count. It also eliminated some confusing options, now there's only
5828 one: cache_size.
5834 one: cache_size.
5829
5835
5830 * Added 'alias' magic function and magic_alias option in the
5836 * Added 'alias' magic function and magic_alias option in the
5831 ipythonrc file. Now the user can easily define whatever names he
5837 ipythonrc file. Now the user can easily define whatever names he
5832 wants for the magic functions without having to play weird
5838 wants for the magic functions without having to play weird
5833 namespace games. This gives IPython a real shell-like feel.
5839 namespace games. This gives IPython a real shell-like feel.
5834
5840
5835 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
5841 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
5836 @ or not).
5842 @ or not).
5837
5843
5838 This was one of the last remaining 'visible' bugs (that I know
5844 This was one of the last remaining 'visible' bugs (that I know
5839 of). I think if I can clean up the session loading so it works
5845 of). I think if I can clean up the session loading so it works
5840 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
5846 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
5841 about licensing).
5847 about licensing).
5842
5848
5843 2001-11-25 Fernando Perez <fperez@colorado.edu>
5849 2001-11-25 Fernando Perez <fperez@colorado.edu>
5844
5850
5845 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
5851 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
5846 there's a cleaner distinction between what ? and ?? show.
5852 there's a cleaner distinction between what ? and ?? show.
5847
5853
5848 * Added screen_length option. Now the user can define his own
5854 * Added screen_length option. Now the user can define his own
5849 screen size for page() operations.
5855 screen size for page() operations.
5850
5856
5851 * Implemented magic shell-like functions with automatic code
5857 * Implemented magic shell-like functions with automatic code
5852 generation. Now adding another function is just a matter of adding
5858 generation. Now adding another function is just a matter of adding
5853 an entry to a dict, and the function is dynamically generated at
5859 an entry to a dict, and the function is dynamically generated at
5854 run-time. Python has some really cool features!
5860 run-time. Python has some really cool features!
5855
5861
5856 * Renamed many options to cleanup conventions a little. Now all
5862 * Renamed many options to cleanup conventions a little. Now all
5857 are lowercase, and only underscores where needed. Also in the code
5863 are lowercase, and only underscores where needed. Also in the code
5858 option name tables are clearer.
5864 option name tables are clearer.
5859
5865
5860 * Changed prompts a little. Now input is 'In [n]:' instead of
5866 * Changed prompts a little. Now input is 'In [n]:' instead of
5861 'In[n]:='. This allows it the numbers to be aligned with the
5867 'In[n]:='. This allows it the numbers to be aligned with the
5862 Out[n] numbers, and removes usage of ':=' which doesn't exist in
5868 Out[n] numbers, and removes usage of ':=' which doesn't exist in
5863 Python (it was a Mathematica thing). The '...' continuation prompt
5869 Python (it was a Mathematica thing). The '...' continuation prompt
5864 was also changed a little to align better.
5870 was also changed a little to align better.
5865
5871
5866 * Fixed bug when flushing output cache. Not all _p<n> variables
5872 * Fixed bug when flushing output cache. Not all _p<n> variables
5867 exist, so their deletion needs to be wrapped in a try:
5873 exist, so their deletion needs to be wrapped in a try:
5868
5874
5869 * Figured out how to properly use inspect.formatargspec() (it
5875 * Figured out how to properly use inspect.formatargspec() (it
5870 requires the args preceded by *). So I removed all the code from
5876 requires the args preceded by *). So I removed all the code from
5871 _get_pdef in Magic, which was just replicating that.
5877 _get_pdef in Magic, which was just replicating that.
5872
5878
5873 * Added test to prefilter to allow redefining magic function names
5879 * Added test to prefilter to allow redefining magic function names
5874 as variables. This is ok, since the @ form is always available,
5880 as variables. This is ok, since the @ form is always available,
5875 but whe should allow the user to define a variable called 'ls' if
5881 but whe should allow the user to define a variable called 'ls' if
5876 he needs it.
5882 he needs it.
5877
5883
5878 * Moved the ToDo information from README into a separate ToDo.
5884 * Moved the ToDo information from README into a separate ToDo.
5879
5885
5880 * General code cleanup and small bugfixes. I think it's close to a
5886 * General code cleanup and small bugfixes. I think it's close to a
5881 state where it can be released, obviously with a big 'beta'
5887 state where it can be released, obviously with a big 'beta'
5882 warning on it.
5888 warning on it.
5883
5889
5884 * Got the magic function split to work. Now all magics are defined
5890 * Got the magic function split to work. Now all magics are defined
5885 in a separate class. It just organizes things a bit, and now
5891 in a separate class. It just organizes things a bit, and now
5886 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
5892 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
5887 was too long).
5893 was too long).
5888
5894
5889 * Changed @clear to @reset to avoid potential confusions with
5895 * Changed @clear to @reset to avoid potential confusions with
5890 the shell command clear. Also renamed @cl to @clear, which does
5896 the shell command clear. Also renamed @cl to @clear, which does
5891 exactly what people expect it to from their shell experience.
5897 exactly what people expect it to from their shell experience.
5892
5898
5893 Added a check to the @reset command (since it's so
5899 Added a check to the @reset command (since it's so
5894 destructive, it's probably a good idea to ask for confirmation).
5900 destructive, it's probably a good idea to ask for confirmation).
5895 But now reset only works for full namespace resetting. Since the
5901 But now reset only works for full namespace resetting. Since the
5896 del keyword is already there for deleting a few specific
5902 del keyword is already there for deleting a few specific
5897 variables, I don't see the point of having a redundant magic
5903 variables, I don't see the point of having a redundant magic
5898 function for the same task.
5904 function for the same task.
5899
5905
5900 2001-11-24 Fernando Perez <fperez@colorado.edu>
5906 2001-11-24 Fernando Perez <fperez@colorado.edu>
5901
5907
5902 * Updated the builtin docs (esp. the ? ones).
5908 * Updated the builtin docs (esp. the ? ones).
5903
5909
5904 * Ran all the code through pychecker. Not terribly impressed with
5910 * Ran all the code through pychecker. Not terribly impressed with
5905 it: lots of spurious warnings and didn't really find anything of
5911 it: lots of spurious warnings and didn't really find anything of
5906 substance (just a few modules being imported and not used).
5912 substance (just a few modules being imported and not used).
5907
5913
5908 * Implemented the new ultraTB functionality into IPython. New
5914 * Implemented the new ultraTB functionality into IPython. New
5909 option: xcolors. This chooses color scheme. xmode now only selects
5915 option: xcolors. This chooses color scheme. xmode now only selects
5910 between Plain and Verbose. Better orthogonality.
5916 between Plain and Verbose. Better orthogonality.
5911
5917
5912 * Large rewrite of ultraTB. Much cleaner now, with a separation of
5918 * Large rewrite of ultraTB. Much cleaner now, with a separation of
5913 mode and color scheme for the exception handlers. Now it's
5919 mode and color scheme for the exception handlers. Now it's
5914 possible to have the verbose traceback with no coloring.
5920 possible to have the verbose traceback with no coloring.
5915
5921
5916 2001-11-23 Fernando Perez <fperez@colorado.edu>
5922 2001-11-23 Fernando Perez <fperez@colorado.edu>
5917
5923
5918 * Version 0.1.12 released, 0.1.13 opened.
5924 * Version 0.1.12 released, 0.1.13 opened.
5919
5925
5920 * Removed option to set auto-quote and auto-paren escapes by
5926 * Removed option to set auto-quote and auto-paren escapes by
5921 user. The chances of breaking valid syntax are just too high. If
5927 user. The chances of breaking valid syntax are just too high. If
5922 someone *really* wants, they can always dig into the code.
5928 someone *really* wants, they can always dig into the code.
5923
5929
5924 * Made prompt separators configurable.
5930 * Made prompt separators configurable.
5925
5931
5926 2001-11-22 Fernando Perez <fperez@colorado.edu>
5932 2001-11-22 Fernando Perez <fperez@colorado.edu>
5927
5933
5928 * Small bugfixes in many places.
5934 * Small bugfixes in many places.
5929
5935
5930 * Removed the MyCompleter class from ipplib. It seemed redundant
5936 * Removed the MyCompleter class from ipplib. It seemed redundant
5931 with the C-p,C-n history search functionality. Less code to
5937 with the C-p,C-n history search functionality. Less code to
5932 maintain.
5938 maintain.
5933
5939
5934 * Moved all the original ipython.py code into ipythonlib.py. Right
5940 * Moved all the original ipython.py code into ipythonlib.py. Right
5935 now it's just one big dump into a function called make_IPython, so
5941 now it's just one big dump into a function called make_IPython, so
5936 no real modularity has been gained. But at least it makes the
5942 no real modularity has been gained. But at least it makes the
5937 wrapper script tiny, and since ipythonlib is a module, it gets
5943 wrapper script tiny, and since ipythonlib is a module, it gets
5938 compiled and startup is much faster.
5944 compiled and startup is much faster.
5939
5945
5940 This is a reasobably 'deep' change, so we should test it for a
5946 This is a reasobably 'deep' change, so we should test it for a
5941 while without messing too much more with the code.
5947 while without messing too much more with the code.
5942
5948
5943 2001-11-21 Fernando Perez <fperez@colorado.edu>
5949 2001-11-21 Fernando Perez <fperez@colorado.edu>
5944
5950
5945 * Version 0.1.11 released, 0.1.12 opened for further work.
5951 * Version 0.1.11 released, 0.1.12 opened for further work.
5946
5952
5947 * Removed dependency on Itpl. It was only needed in one place. It
5953 * Removed dependency on Itpl. It was only needed in one place. It
5948 would be nice if this became part of python, though. It makes life
5954 would be nice if this became part of python, though. It makes life
5949 *a lot* easier in some cases.
5955 *a lot* easier in some cases.
5950
5956
5951 * Simplified the prefilter code a bit. Now all handlers are
5957 * Simplified the prefilter code a bit. Now all handlers are
5952 expected to explicitly return a value (at least a blank string).
5958 expected to explicitly return a value (at least a blank string).
5953
5959
5954 * Heavy edits in ipplib. Removed the help system altogether. Now
5960 * Heavy edits in ipplib. Removed the help system altogether. Now
5955 obj?/?? is used for inspecting objects, a magic @doc prints
5961 obj?/?? is used for inspecting objects, a magic @doc prints
5956 docstrings, and full-blown Python help is accessed via the 'help'
5962 docstrings, and full-blown Python help is accessed via the 'help'
5957 keyword. This cleans up a lot of code (less to maintain) and does
5963 keyword. This cleans up a lot of code (less to maintain) and does
5958 the job. Since 'help' is now a standard Python component, might as
5964 the job. Since 'help' is now a standard Python component, might as
5959 well use it and remove duplicate functionality.
5965 well use it and remove duplicate functionality.
5960
5966
5961 Also removed the option to use ipplib as a standalone program. By
5967 Also removed the option to use ipplib as a standalone program. By
5962 now it's too dependent on other parts of IPython to function alone.
5968 now it's too dependent on other parts of IPython to function alone.
5963
5969
5964 * Fixed bug in genutils.pager. It would crash if the pager was
5970 * Fixed bug in genutils.pager. It would crash if the pager was
5965 exited immediately after opening (broken pipe).
5971 exited immediately after opening (broken pipe).
5966
5972
5967 * Trimmed down the VerboseTB reporting a little. The header is
5973 * Trimmed down the VerboseTB reporting a little. The header is
5968 much shorter now and the repeated exception arguments at the end
5974 much shorter now and the repeated exception arguments at the end
5969 have been removed. For interactive use the old header seemed a bit
5975 have been removed. For interactive use the old header seemed a bit
5970 excessive.
5976 excessive.
5971
5977
5972 * Fixed small bug in output of @whos for variables with multi-word
5978 * Fixed small bug in output of @whos for variables with multi-word
5973 types (only first word was displayed).
5979 types (only first word was displayed).
5974
5980
5975 2001-11-17 Fernando Perez <fperez@colorado.edu>
5981 2001-11-17 Fernando Perez <fperez@colorado.edu>
5976
5982
5977 * Version 0.1.10 released, 0.1.11 opened for further work.
5983 * Version 0.1.10 released, 0.1.11 opened for further work.
5978
5984
5979 * Modified dirs and friends. dirs now *returns* the stack (not
5985 * Modified dirs and friends. dirs now *returns* the stack (not
5980 prints), so one can manipulate it as a variable. Convenient to
5986 prints), so one can manipulate it as a variable. Convenient to
5981 travel along many directories.
5987 travel along many directories.
5982
5988
5983 * Fixed bug in magic_pdef: would only work with functions with
5989 * Fixed bug in magic_pdef: would only work with functions with
5984 arguments with default values.
5990 arguments with default values.
5985
5991
5986 2001-11-14 Fernando Perez <fperez@colorado.edu>
5992 2001-11-14 Fernando Perez <fperez@colorado.edu>
5987
5993
5988 * Added the PhysicsInput stuff to dot_ipython so it ships as an
5994 * Added the PhysicsInput stuff to dot_ipython so it ships as an
5989 example with IPython. Various other minor fixes and cleanups.
5995 example with IPython. Various other minor fixes and cleanups.
5990
5996
5991 * Version 0.1.9 released, 0.1.10 opened for further work.
5997 * Version 0.1.9 released, 0.1.10 opened for further work.
5992
5998
5993 * Added sys.path to the list of directories searched in the
5999 * Added sys.path to the list of directories searched in the
5994 execfile= option. It used to be the current directory and the
6000 execfile= option. It used to be the current directory and the
5995 user's IPYTHONDIR only.
6001 user's IPYTHONDIR only.
5996
6002
5997 2001-11-13 Fernando Perez <fperez@colorado.edu>
6003 2001-11-13 Fernando Perez <fperez@colorado.edu>
5998
6004
5999 * Reinstated the raw_input/prefilter separation that Janko had
6005 * Reinstated the raw_input/prefilter separation that Janko had
6000 initially. This gives a more convenient setup for extending the
6006 initially. This gives a more convenient setup for extending the
6001 pre-processor from the outside: raw_input always gets a string,
6007 pre-processor from the outside: raw_input always gets a string,
6002 and prefilter has to process it. We can then redefine prefilter
6008 and prefilter has to process it. We can then redefine prefilter
6003 from the outside and implement extensions for special
6009 from the outside and implement extensions for special
6004 purposes.
6010 purposes.
6005
6011
6006 Today I got one for inputting PhysicalQuantity objects
6012 Today I got one for inputting PhysicalQuantity objects
6007 (from Scientific) without needing any function calls at
6013 (from Scientific) without needing any function calls at
6008 all. Extremely convenient, and it's all done as a user-level
6014 all. Extremely convenient, and it's all done as a user-level
6009 extension (no IPython code was touched). Now instead of:
6015 extension (no IPython code was touched). Now instead of:
6010 a = PhysicalQuantity(4.2,'m/s**2')
6016 a = PhysicalQuantity(4.2,'m/s**2')
6011 one can simply say
6017 one can simply say
6012 a = 4.2 m/s**2
6018 a = 4.2 m/s**2
6013 or even
6019 or even
6014 a = 4.2 m/s^2
6020 a = 4.2 m/s^2
6015
6021
6016 I use this, but it's also a proof of concept: IPython really is
6022 I use this, but it's also a proof of concept: IPython really is
6017 fully user-extensible, even at the level of the parsing of the
6023 fully user-extensible, even at the level of the parsing of the
6018 command line. It's not trivial, but it's perfectly doable.
6024 command line. It's not trivial, but it's perfectly doable.
6019
6025
6020 * Added 'add_flip' method to inclusion conflict resolver. Fixes
6026 * Added 'add_flip' method to inclusion conflict resolver. Fixes
6021 the problem of modules being loaded in the inverse order in which
6027 the problem of modules being loaded in the inverse order in which
6022 they were defined in
6028 they were defined in
6023
6029
6024 * Version 0.1.8 released, 0.1.9 opened for further work.
6030 * Version 0.1.8 released, 0.1.9 opened for further work.
6025
6031
6026 * Added magics pdef, source and file. They respectively show the
6032 * Added magics pdef, source and file. They respectively show the
6027 definition line ('prototype' in C), source code and full python
6033 definition line ('prototype' in C), source code and full python
6028 file for any callable object. The object inspector oinfo uses
6034 file for any callable object. The object inspector oinfo uses
6029 these to show the same information.
6035 these to show the same information.
6030
6036
6031 * Version 0.1.7 released, 0.1.8 opened for further work.
6037 * Version 0.1.7 released, 0.1.8 opened for further work.
6032
6038
6033 * Separated all the magic functions into a class called Magic. The
6039 * Separated all the magic functions into a class called Magic. The
6034 InteractiveShell class was becoming too big for Xemacs to handle
6040 InteractiveShell class was becoming too big for Xemacs to handle
6035 (de-indenting a line would lock it up for 10 seconds while it
6041 (de-indenting a line would lock it up for 10 seconds while it
6036 backtracked on the whole class!)
6042 backtracked on the whole class!)
6037
6043
6038 FIXME: didn't work. It can be done, but right now namespaces are
6044 FIXME: didn't work. It can be done, but right now namespaces are
6039 all messed up. Do it later (reverted it for now, so at least
6045 all messed up. Do it later (reverted it for now, so at least
6040 everything works as before).
6046 everything works as before).
6041
6047
6042 * Got the object introspection system (magic_oinfo) working! I
6048 * Got the object introspection system (magic_oinfo) working! I
6043 think this is pretty much ready for release to Janko, so he can
6049 think this is pretty much ready for release to Janko, so he can
6044 test it for a while and then announce it. Pretty much 100% of what
6050 test it for a while and then announce it. Pretty much 100% of what
6045 I wanted for the 'phase 1' release is ready. Happy, tired.
6051 I wanted for the 'phase 1' release is ready. Happy, tired.
6046
6052
6047 2001-11-12 Fernando Perez <fperez@colorado.edu>
6053 2001-11-12 Fernando Perez <fperez@colorado.edu>
6048
6054
6049 * Version 0.1.6 released, 0.1.7 opened for further work.
6055 * Version 0.1.6 released, 0.1.7 opened for further work.
6050
6056
6051 * Fixed bug in printing: it used to test for truth before
6057 * Fixed bug in printing: it used to test for truth before
6052 printing, so 0 wouldn't print. Now checks for None.
6058 printing, so 0 wouldn't print. Now checks for None.
6053
6059
6054 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
6060 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
6055 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
6061 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
6056 reaches by hand into the outputcache. Think of a better way to do
6062 reaches by hand into the outputcache. Think of a better way to do
6057 this later.
6063 this later.
6058
6064
6059 * Various small fixes thanks to Nathan's comments.
6065 * Various small fixes thanks to Nathan's comments.
6060
6066
6061 * Changed magic_pprint to magic_Pprint. This way it doesn't
6067 * Changed magic_pprint to magic_Pprint. This way it doesn't
6062 collide with pprint() and the name is consistent with the command
6068 collide with pprint() and the name is consistent with the command
6063 line option.
6069 line option.
6064
6070
6065 * Changed prompt counter behavior to be fully like
6071 * Changed prompt counter behavior to be fully like
6066 Mathematica's. That is, even input that doesn't return a result
6072 Mathematica's. That is, even input that doesn't return a result
6067 raises the prompt counter. The old behavior was kind of confusing
6073 raises the prompt counter. The old behavior was kind of confusing
6068 (getting the same prompt number several times if the operation
6074 (getting the same prompt number several times if the operation
6069 didn't return a result).
6075 didn't return a result).
6070
6076
6071 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
6077 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
6072
6078
6073 * Fixed -Classic mode (wasn't working anymore).
6079 * Fixed -Classic mode (wasn't working anymore).
6074
6080
6075 * Added colored prompts using Nathan's new code. Colors are
6081 * Added colored prompts using Nathan's new code. Colors are
6076 currently hardwired, they can be user-configurable. For
6082 currently hardwired, they can be user-configurable. For
6077 developers, they can be chosen in file ipythonlib.py, at the
6083 developers, they can be chosen in file ipythonlib.py, at the
6078 beginning of the CachedOutput class def.
6084 beginning of the CachedOutput class def.
6079
6085
6080 2001-11-11 Fernando Perez <fperez@colorado.edu>
6086 2001-11-11 Fernando Perez <fperez@colorado.edu>
6081
6087
6082 * Version 0.1.5 released, 0.1.6 opened for further work.
6088 * Version 0.1.5 released, 0.1.6 opened for further work.
6083
6089
6084 * Changed magic_env to *return* the environment as a dict (not to
6090 * Changed magic_env to *return* the environment as a dict (not to
6085 print it). This way it prints, but it can also be processed.
6091 print it). This way it prints, but it can also be processed.
6086
6092
6087 * Added Verbose exception reporting to interactive
6093 * Added Verbose exception reporting to interactive
6088 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
6094 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
6089 traceback. Had to make some changes to the ultraTB file. This is
6095 traceback. Had to make some changes to the ultraTB file. This is
6090 probably the last 'big' thing in my mental todo list. This ties
6096 probably the last 'big' thing in my mental todo list. This ties
6091 in with the next entry:
6097 in with the next entry:
6092
6098
6093 * Changed -Xi and -Xf to a single -xmode option. Now all the user
6099 * Changed -Xi and -Xf to a single -xmode option. Now all the user
6094 has to specify is Plain, Color or Verbose for all exception
6100 has to specify is Plain, Color or Verbose for all exception
6095 handling.
6101 handling.
6096
6102
6097 * Removed ShellServices option. All this can really be done via
6103 * Removed ShellServices option. All this can really be done via
6098 the magic system. It's easier to extend, cleaner and has automatic
6104 the magic system. It's easier to extend, cleaner and has automatic
6099 namespace protection and documentation.
6105 namespace protection and documentation.
6100
6106
6101 2001-11-09 Fernando Perez <fperez@colorado.edu>
6107 2001-11-09 Fernando Perez <fperez@colorado.edu>
6102
6108
6103 * Fixed bug in output cache flushing (missing parameter to
6109 * Fixed bug in output cache flushing (missing parameter to
6104 __init__). Other small bugs fixed (found using pychecker).
6110 __init__). Other small bugs fixed (found using pychecker).
6105
6111
6106 * Version 0.1.4 opened for bugfixing.
6112 * Version 0.1.4 opened for bugfixing.
6107
6113
6108 2001-11-07 Fernando Perez <fperez@colorado.edu>
6114 2001-11-07 Fernando Perez <fperez@colorado.edu>
6109
6115
6110 * Version 0.1.3 released, mainly because of the raw_input bug.
6116 * Version 0.1.3 released, mainly because of the raw_input bug.
6111
6117
6112 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
6118 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
6113 and when testing for whether things were callable, a call could
6119 and when testing for whether things were callable, a call could
6114 actually be made to certain functions. They would get called again
6120 actually be made to certain functions. They would get called again
6115 once 'really' executed, with a resulting double call. A disaster
6121 once 'really' executed, with a resulting double call. A disaster
6116 in many cases (list.reverse() would never work!).
6122 in many cases (list.reverse() would never work!).
6117
6123
6118 * Removed prefilter() function, moved its code to raw_input (which
6124 * Removed prefilter() function, moved its code to raw_input (which
6119 after all was just a near-empty caller for prefilter). This saves
6125 after all was just a near-empty caller for prefilter). This saves
6120 a function call on every prompt, and simplifies the class a tiny bit.
6126 a function call on every prompt, and simplifies the class a tiny bit.
6121
6127
6122 * Fix _ip to __ip name in magic example file.
6128 * Fix _ip to __ip name in magic example file.
6123
6129
6124 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
6130 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
6125 work with non-gnu versions of tar.
6131 work with non-gnu versions of tar.
6126
6132
6127 2001-11-06 Fernando Perez <fperez@colorado.edu>
6133 2001-11-06 Fernando Perez <fperez@colorado.edu>
6128
6134
6129 * Version 0.1.2. Just to keep track of the recent changes.
6135 * Version 0.1.2. Just to keep track of the recent changes.
6130
6136
6131 * Fixed nasty bug in output prompt routine. It used to check 'if
6137 * Fixed nasty bug in output prompt routine. It used to check 'if
6132 arg != None...'. Problem is, this fails if arg implements a
6138 arg != None...'. Problem is, this fails if arg implements a
6133 special comparison (__cmp__) which disallows comparing to
6139 special comparison (__cmp__) which disallows comparing to
6134 None. Found it when trying to use the PhysicalQuantity module from
6140 None. Found it when trying to use the PhysicalQuantity module from
6135 ScientificPython.
6141 ScientificPython.
6136
6142
6137 2001-11-05 Fernando Perez <fperez@colorado.edu>
6143 2001-11-05 Fernando Perez <fperez@colorado.edu>
6138
6144
6139 * Also added dirs. Now the pushd/popd/dirs family functions
6145 * Also added dirs. Now the pushd/popd/dirs family functions
6140 basically like the shell, with the added convenience of going home
6146 basically like the shell, with the added convenience of going home
6141 when called with no args.
6147 when called with no args.
6142
6148
6143 * pushd/popd slightly modified to mimic shell behavior more
6149 * pushd/popd slightly modified to mimic shell behavior more
6144 closely.
6150 closely.
6145
6151
6146 * Added env,pushd,popd from ShellServices as magic functions. I
6152 * Added env,pushd,popd from ShellServices as magic functions. I
6147 think the cleanest will be to port all desired functions from
6153 think the cleanest will be to port all desired functions from
6148 ShellServices as magics and remove ShellServices altogether. This
6154 ShellServices as magics and remove ShellServices altogether. This
6149 will provide a single, clean way of adding functionality
6155 will provide a single, clean way of adding functionality
6150 (shell-type or otherwise) to IP.
6156 (shell-type or otherwise) to IP.
6151
6157
6152 2001-11-04 Fernando Perez <fperez@colorado.edu>
6158 2001-11-04 Fernando Perez <fperez@colorado.edu>
6153
6159
6154 * Added .ipython/ directory to sys.path. This way users can keep
6160 * Added .ipython/ directory to sys.path. This way users can keep
6155 customizations there and access them via import.
6161 customizations there and access them via import.
6156
6162
6157 2001-11-03 Fernando Perez <fperez@colorado.edu>
6163 2001-11-03 Fernando Perez <fperez@colorado.edu>
6158
6164
6159 * Opened version 0.1.1 for new changes.
6165 * Opened version 0.1.1 for new changes.
6160
6166
6161 * Changed version number to 0.1.0: first 'public' release, sent to
6167 * Changed version number to 0.1.0: first 'public' release, sent to
6162 Nathan and Janko.
6168 Nathan and Janko.
6163
6169
6164 * Lots of small fixes and tweaks.
6170 * Lots of small fixes and tweaks.
6165
6171
6166 * Minor changes to whos format. Now strings are shown, snipped if
6172 * Minor changes to whos format. Now strings are shown, snipped if
6167 too long.
6173 too long.
6168
6174
6169 * Changed ShellServices to work on __main__ so they show up in @who
6175 * Changed ShellServices to work on __main__ so they show up in @who
6170
6176
6171 * Help also works with ? at the end of a line:
6177 * Help also works with ? at the end of a line:
6172 ?sin and sin?
6178 ?sin and sin?
6173 both produce the same effect. This is nice, as often I use the
6179 both produce the same effect. This is nice, as often I use the
6174 tab-complete to find the name of a method, but I used to then have
6180 tab-complete to find the name of a method, but I used to then have
6175 to go to the beginning of the line to put a ? if I wanted more
6181 to go to the beginning of the line to put a ? if I wanted more
6176 info. Now I can just add the ? and hit return. Convenient.
6182 info. Now I can just add the ? and hit return. Convenient.
6177
6183
6178 2001-11-02 Fernando Perez <fperez@colorado.edu>
6184 2001-11-02 Fernando Perez <fperez@colorado.edu>
6179
6185
6180 * Python version check (>=2.1) added.
6186 * Python version check (>=2.1) added.
6181
6187
6182 * Added LazyPython documentation. At this point the docs are quite
6188 * Added LazyPython documentation. At this point the docs are quite
6183 a mess. A cleanup is in order.
6189 a mess. A cleanup is in order.
6184
6190
6185 * Auto-installer created. For some bizarre reason, the zipfiles
6191 * Auto-installer created. For some bizarre reason, the zipfiles
6186 module isn't working on my system. So I made a tar version
6192 module isn't working on my system. So I made a tar version
6187 (hopefully the command line options in various systems won't kill
6193 (hopefully the command line options in various systems won't kill
6188 me).
6194 me).
6189
6195
6190 * Fixes to Struct in genutils. Now all dictionary-like methods are
6196 * Fixes to Struct in genutils. Now all dictionary-like methods are
6191 protected (reasonably).
6197 protected (reasonably).
6192
6198
6193 * Added pager function to genutils and changed ? to print usage
6199 * Added pager function to genutils and changed ? to print usage
6194 note through it (it was too long).
6200 note through it (it was too long).
6195
6201
6196 * Added the LazyPython functionality. Works great! I changed the
6202 * Added the LazyPython functionality. Works great! I changed the
6197 auto-quote escape to ';', it's on home row and next to '. But
6203 auto-quote escape to ';', it's on home row and next to '. But
6198 both auto-quote and auto-paren (still /) escapes are command-line
6204 both auto-quote and auto-paren (still /) escapes are command-line
6199 parameters.
6205 parameters.
6200
6206
6201
6207
6202 2001-11-01 Fernando Perez <fperez@colorado.edu>
6208 2001-11-01 Fernando Perez <fperez@colorado.edu>
6203
6209
6204 * Version changed to 0.0.7. Fairly large change: configuration now
6210 * Version changed to 0.0.7. Fairly large change: configuration now
6205 is all stored in a directory, by default .ipython. There, all
6211 is all stored in a directory, by default .ipython. There, all
6206 config files have normal looking names (not .names)
6212 config files have normal looking names (not .names)
6207
6213
6208 * Version 0.0.6 Released first to Lucas and Archie as a test
6214 * Version 0.0.6 Released first to Lucas and Archie as a test
6209 run. Since it's the first 'semi-public' release, change version to
6215 run. Since it's the first 'semi-public' release, change version to
6210 > 0.0.6 for any changes now.
6216 > 0.0.6 for any changes now.
6211
6217
6212 * Stuff I had put in the ipplib.py changelog:
6218 * Stuff I had put in the ipplib.py changelog:
6213
6219
6214 Changes to InteractiveShell:
6220 Changes to InteractiveShell:
6215
6221
6216 - Made the usage message a parameter.
6222 - Made the usage message a parameter.
6217
6223
6218 - Require the name of the shell variable to be given. It's a bit
6224 - Require the name of the shell variable to be given. It's a bit
6219 of a hack, but allows the name 'shell' not to be hardwired in the
6225 of a hack, but allows the name 'shell' not to be hardwired in the
6220 magic (@) handler, which is problematic b/c it requires
6226 magic (@) handler, which is problematic b/c it requires
6221 polluting the global namespace with 'shell'. This in turn is
6227 polluting the global namespace with 'shell'. This in turn is
6222 fragile: if a user redefines a variable called shell, things
6228 fragile: if a user redefines a variable called shell, things
6223 break.
6229 break.
6224
6230
6225 - magic @: all functions available through @ need to be defined
6231 - magic @: all functions available through @ need to be defined
6226 as magic_<name>, even though they can be called simply as
6232 as magic_<name>, even though they can be called simply as
6227 @<name>. This allows the special command @magic to gather
6233 @<name>. This allows the special command @magic to gather
6228 information automatically about all existing magic functions,
6234 information automatically about all existing magic functions,
6229 even if they are run-time user extensions, by parsing the shell
6235 even if they are run-time user extensions, by parsing the shell
6230 instance __dict__ looking for special magic_ names.
6236 instance __dict__ looking for special magic_ names.
6231
6237
6232 - mainloop: added *two* local namespace parameters. This allows
6238 - mainloop: added *two* local namespace parameters. This allows
6233 the class to differentiate between parameters which were there
6239 the class to differentiate between parameters which were there
6234 before and after command line initialization was processed. This
6240 before and after command line initialization was processed. This
6235 way, later @who can show things loaded at startup by the
6241 way, later @who can show things loaded at startup by the
6236 user. This trick was necessary to make session saving/reloading
6242 user. This trick was necessary to make session saving/reloading
6237 really work: ideally after saving/exiting/reloading a session,
6243 really work: ideally after saving/exiting/reloading a session,
6238 *everything* should look the same, including the output of @who. I
6244 *everything* should look the same, including the output of @who. I
6239 was only able to make this work with this double namespace
6245 was only able to make this work with this double namespace
6240 trick.
6246 trick.
6241
6247
6242 - added a header to the logfile which allows (almost) full
6248 - added a header to the logfile which allows (almost) full
6243 session restoring.
6249 session restoring.
6244
6250
6245 - prepend lines beginning with @ or !, with a and log
6251 - prepend lines beginning with @ or !, with a and log
6246 them. Why? !lines: may be useful to know what you did @lines:
6252 them. Why? !lines: may be useful to know what you did @lines:
6247 they may affect session state. So when restoring a session, at
6253 they may affect session state. So when restoring a session, at
6248 least inform the user of their presence. I couldn't quite get
6254 least inform the user of their presence. I couldn't quite get
6249 them to properly re-execute, but at least the user is warned.
6255 them to properly re-execute, but at least the user is warned.
6250
6256
6251 * Started ChangeLog.
6257 * Started ChangeLog.
General Comments 0
You need to be logged in to leave comments. Login now