##// END OF EJS Templates
# auto tag for blocks, minor pycat fix.
fperez -
Show More
@@ -1,2473 +1,2474
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """Magic functions for InteractiveShell.
2 """Magic functions for InteractiveShell.
3
3
4 $Id: Magic.py 906 2005-09-24 00:26:14Z fperez $"""
4 $Id: Magic.py 907 2005-09-24 00:59:56Z fperez $"""
5
5
6 #*****************************************************************************
6 #*****************************************************************************
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
8 # Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu>
8 # Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu>
9 #
9 #
10 # Distributed under the terms of the BSD License. The full license is in
10 # Distributed under the terms of the BSD License. The full license is in
11 # the file COPYING, distributed as part of this software.
11 # the file COPYING, distributed as part of this software.
12 #*****************************************************************************
12 #*****************************************************************************
13
13
14 #****************************************************************************
14 #****************************************************************************
15 # Modules and globals
15 # Modules and globals
16
16
17 from IPython import Release
17 from IPython import Release
18 __author__ = '%s <%s>\n%s <%s>' % \
18 __author__ = '%s <%s>\n%s <%s>' % \
19 ( Release.authors['Janko'] + Release.authors['Fernando'] )
19 ( Release.authors['Janko'] + Release.authors['Fernando'] )
20 __license__ = Release.license
20 __license__ = Release.license
21
21
22 # Python standard modules
22 # Python standard modules
23 import __builtin__
23 import __builtin__
24 import os,sys,inspect,pydoc,re,tempfile,pdb,bdb,time
24 import os,sys,inspect,pydoc,re,tempfile,pdb,bdb,time
25 try:
25 try:
26 import profile,pstats
26 import profile,pstats
27 except ImportError:
27 except ImportError:
28 profile = pstats = None
28 profile = pstats = None
29 from getopt import getopt
29 from getopt import getopt
30 from pprint import pprint, pformat
30 from pprint import pprint, pformat
31 from cStringIO import StringIO
31 from cStringIO import StringIO
32
32
33 # Homebrewed
33 # Homebrewed
34 from IPython.Struct import Struct
34 from IPython.Struct import Struct
35 from IPython.Itpl import Itpl, itpl, printpl,itplns
35 from IPython.Itpl import Itpl, itpl, printpl,itplns
36 from IPython.FakeModule import FakeModule
36 from IPython.FakeModule import FakeModule
37 from IPython import OInspect
37 from IPython import OInspect
38 from IPython.PyColorize import Parser
38 from IPython.PyColorize import Parser
39 from IPython.genutils import *
39 from IPython.genutils import *
40
40
41 # Globals to be set later by Magic constructor
41 # Globals to be set later by Magic constructor
42 MAGIC_PREFIX = ''
42 MAGIC_PREFIX = ''
43 MAGIC_ESCAPE = ''
43 MAGIC_ESCAPE = ''
44
44
45 #***************************************************************************
45 #***************************************************************************
46 # Utility functions
46 # Utility functions
47 def magic2python(cmd):
47 def magic2python(cmd):
48 """Convert a command string of magic syntax to valid Python code."""
48 """Convert a command string of magic syntax to valid Python code."""
49
49
50 if cmd.startswith('#'+MAGIC_ESCAPE) or \
50 if cmd.startswith('#'+MAGIC_ESCAPE) or \
51 cmd.startswith(MAGIC_ESCAPE):
51 cmd.startswith(MAGIC_ESCAPE):
52 if cmd[0]=='#':
52 if cmd[0]=='#':
53 cmd = cmd[1:]
53 cmd = cmd[1:]
54 # we need to return the proper line end later
54 # we need to return the proper line end later
55 if cmd[-1] == '\n':
55 if cmd[-1] == '\n':
56 endl = '\n'
56 endl = '\n'
57 else:
57 else:
58 endl = ''
58 endl = ''
59 try:
59 try:
60 func,args = cmd[1:].split(' ',1)
60 func,args = cmd[1:].split(' ',1)
61 except:
61 except:
62 func,args = cmd[1:].rstrip(),''
62 func,args = cmd[1:].rstrip(),''
63 args = args.replace('"','\\"').replace("'","\\'").rstrip()
63 args = args.replace('"','\\"').replace("'","\\'").rstrip()
64 return '%s%s ("%s")%s' % (MAGIC_PREFIX,func,args,endl)
64 return '%s%s ("%s")%s' % (MAGIC_PREFIX,func,args,endl)
65 else:
65 else:
66 return cmd
66 return cmd
67
67
68 def on_off(tag):
68 def on_off(tag):
69 """Return an ON/OFF string for a 1/0 input. Simple utility function."""
69 """Return an ON/OFF string for a 1/0 input. Simple utility function."""
70 return ['OFF','ON'][tag]
70 return ['OFF','ON'][tag]
71
71
72 def get_py_filename(name):
72 def get_py_filename(name):
73 """Return a valid python filename in the current directory.
73 """Return a valid python filename in the current directory.
74
74
75 If the given name is not a file, it adds '.py' and searches again.
75 If the given name is not a file, it adds '.py' and searches again.
76 Raises IOError with an informative message if the file isn't found."""
76 Raises IOError with an informative message if the file isn't found."""
77
77
78 name = os.path.expanduser(name)
78 name = os.path.expanduser(name)
79 if not os.path.isfile(name) and not name.endswith('.py'):
79 if not os.path.isfile(name) and not name.endswith('.py'):
80 name += '.py'
80 name += '.py'
81 if os.path.isfile(name):
81 if os.path.isfile(name):
82 return name
82 return name
83 else:
83 else:
84 raise IOError,'File `%s` not found.' % name
84 raise IOError,'File `%s` not found.' % name
85
85
86
86
87 #****************************************************************************
87 #****************************************************************************
88 # Utility classes
88 # Utility classes
89 class Macro:
89 class Macro:
90 """Simple class to store the value of macros as strings.
90 """Simple class to store the value of macros as strings.
91
91
92 This allows us to later exec them by checking when something is an
92 This allows us to later exec them by checking when something is an
93 instance of this class."""
93 instance of this class."""
94
94
95 def __init__(self,cmds):
95 def __init__(self,cmds):
96 """Build a macro from a list of commands."""
96 """Build a macro from a list of commands."""
97
97
98 # Since the list may include multi-line entries, first make sure that
98 # Since the list may include multi-line entries, first make sure that
99 # they've been all broken up before passing it to magic2python
99 # they've been all broken up before passing it to magic2python
100 cmdlist = map(magic2python,''.join(cmds).split('\n'))
100 cmdlist = map(magic2python,''.join(cmds).split('\n'))
101 self.value = '\n'.join(cmdlist)
101 self.value = '\n'.join(cmdlist)
102
102
103 def __str__(self):
103 def __str__(self):
104 return self.value
104 return self.value
105
105
106 #***************************************************************************
106 #***************************************************************************
107 # Main class implementing Magic functionality
107 # Main class implementing Magic functionality
108 class Magic:
108 class Magic:
109 """Magic functions for InteractiveShell.
109 """Magic functions for InteractiveShell.
110
110
111 Shell functions which can be reached as %function_name. All magic
111 Shell functions which can be reached as %function_name. All magic
112 functions should accept a string, which they can parse for their own
112 functions should accept a string, which they can parse for their own
113 needs. This can make some functions easier to type, eg `%cd ../`
113 needs. This can make some functions easier to type, eg `%cd ../`
114 vs. `%cd("../")`
114 vs. `%cd("../")`
115
115
116 ALL definitions MUST begin with the prefix magic_. The user won't need it
116 ALL definitions MUST begin with the prefix magic_. The user won't need it
117 at the command line, but it is is needed in the definition. """
117 at the command line, but it is is needed in the definition. """
118
118
119 # class globals
119 # class globals
120 auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.',
120 auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.',
121 'Automagic is ON, % prefix NOT needed for magic functions.']
121 'Automagic is ON, % prefix NOT needed for magic functions.']
122
122
123 #......................................................................
123 #......................................................................
124 # some utility functions
124 # some utility functions
125
125
126 def __init__(self,shell):
126 def __init__(self,shell):
127 # XXX This is hackish, clean up later to avoid these messy globals
127 # XXX This is hackish, clean up later to avoid these messy globals
128 global MAGIC_PREFIX, MAGIC_ESCAPE
128 global MAGIC_PREFIX, MAGIC_ESCAPE
129
129
130 self.options_table = {}
130 self.options_table = {}
131 MAGIC_PREFIX = shell.name+'.magic_'
131 MAGIC_PREFIX = shell.name+'.magic_'
132 MAGIC_ESCAPE = shell.ESC_MAGIC
132 MAGIC_ESCAPE = shell.ESC_MAGIC
133 if profile is None:
133 if profile is None:
134 self.magic_prun = self.profile_missing_notice
134 self.magic_prun = self.profile_missing_notice
135
135
136 def profile_missing_notice(self, *args, **kwargs):
136 def profile_missing_notice(self, *args, **kwargs):
137 error("""\
137 error("""\
138 The profile module could not be found. If you are a Debian user,
138 The profile module could not be found. If you are a Debian user,
139 it has been removed from the standard Debian package because of its non-free
139 it has been removed from the standard Debian package because of its non-free
140 license. To use profiling, please install"python2.3-profiler" from non-free.""")
140 license. To use profiling, please install"python2.3-profiler" from non-free.""")
141
141
142 def default_option(self,fn,optstr):
142 def default_option(self,fn,optstr):
143 """Make an entry in the options_table for fn, with value optstr"""
143 """Make an entry in the options_table for fn, with value optstr"""
144
144
145 if fn not in self.lsmagic():
145 if fn not in self.lsmagic():
146 error("%s is not a magic function" % fn)
146 error("%s is not a magic function" % fn)
147 self.options_table[fn] = optstr
147 self.options_table[fn] = optstr
148
148
149 def lsmagic(self):
149 def lsmagic(self):
150 """Return a list of currently available magic functions.
150 """Return a list of currently available magic functions.
151
151
152 Gives a list of the bare names after mangling (['ls','cd', ...], not
152 Gives a list of the bare names after mangling (['ls','cd', ...], not
153 ['magic_ls','magic_cd',...]"""
153 ['magic_ls','magic_cd',...]"""
154
154
155 # FIXME. This needs a cleanup, in the way the magics list is built.
155 # FIXME. This needs a cleanup, in the way the magics list is built.
156
156
157 # magics in class definition
157 # magics in class definition
158 class_magic = lambda fn: fn.startswith('magic_') and \
158 class_magic = lambda fn: fn.startswith('magic_') and \
159 callable(Magic.__dict__[fn])
159 callable(Magic.__dict__[fn])
160 # in instance namespace (run-time user additions)
160 # in instance namespace (run-time user additions)
161 inst_magic = lambda fn: fn.startswith('magic_') and \
161 inst_magic = lambda fn: fn.startswith('magic_') and \
162 callable(self.__dict__[fn])
162 callable(self.__dict__[fn])
163 # and bound magics by user (so they can access self):
163 # and bound magics by user (so they can access self):
164 inst_bound_magic = lambda fn: fn.startswith('magic_') and \
164 inst_bound_magic = lambda fn: fn.startswith('magic_') and \
165 callable(self.__class__.__dict__[fn])
165 callable(self.__class__.__dict__[fn])
166 magics = filter(class_magic,Magic.__dict__.keys()) + \
166 magics = filter(class_magic,Magic.__dict__.keys()) + \
167 filter(inst_magic,self.__dict__.keys()) + \
167 filter(inst_magic,self.__dict__.keys()) + \
168 filter(inst_bound_magic,self.__class__.__dict__.keys())
168 filter(inst_bound_magic,self.__class__.__dict__.keys())
169 out = []
169 out = []
170 for fn in magics:
170 for fn in magics:
171 out.append(fn.replace('magic_','',1))
171 out.append(fn.replace('magic_','',1))
172 out.sort()
172 out.sort()
173 return out
173 return out
174
174
175 def set_shell(self,shell):
175 def set_shell(self,shell):
176 self.shell = shell
176 self.shell = shell
177 self.alias_table = shell.alias_table
177 self.alias_table = shell.alias_table
178
178
179 def extract_input_slices(self,slices):
179 def extract_input_slices(self,slices):
180 """Return as a string a set of input history slices.
180 """Return as a string a set of input history slices.
181
181
182 The set of slices is given as a list of strings (like ['1','4:8','9'],
182 The set of slices is given as a list of strings (like ['1','4:8','9'],
183 since this function is for use by magic functions which get their
183 since this function is for use by magic functions which get their
184 arguments as strings."""
184 arguments as strings."""
185
185
186 cmds = []
186 cmds = []
187 for chunk in slices:
187 for chunk in slices:
188 if ':' in chunk:
188 if ':' in chunk:
189 ini,fin = map(int,chunk.split(':'))
189 ini,fin = map(int,chunk.split(':'))
190 else:
190 else:
191 ini = int(chunk)
191 ini = int(chunk)
192 fin = ini+1
192 fin = ini+1
193 cmds.append(self.shell.input_hist[ini:fin])
193 cmds.append(self.shell.input_hist[ini:fin])
194 return cmds
194 return cmds
195
195
196 def _ofind(self,oname):
196 def _ofind(self,oname):
197 """Find an object in the available namespaces.
197 """Find an object in the available namespaces.
198
198
199 self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic
199 self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic
200
200
201 Has special code to detect magic functions.
201 Has special code to detect magic functions.
202 """
202 """
203
203
204 oname = oname.strip()
204 oname = oname.strip()
205
205
206 # Namespaces to search in:
206 # Namespaces to search in:
207 user_ns = self.shell.user_ns
207 user_ns = self.shell.user_ns
208 internal_ns = self.shell.internal_ns
208 internal_ns = self.shell.internal_ns
209 builtin_ns = __builtin__.__dict__
209 builtin_ns = __builtin__.__dict__
210 alias_ns = self.shell.alias_table
210 alias_ns = self.shell.alias_table
211
211
212 # Put them in a list. The order is important so that we find things in
212 # Put them in a list. The order is important so that we find things in
213 # the same order that Python finds them.
213 # the same order that Python finds them.
214 namespaces = [ ('Interactive',user_ns),
214 namespaces = [ ('Interactive',user_ns),
215 ('IPython internal',internal_ns),
215 ('IPython internal',internal_ns),
216 ('Python builtin',builtin_ns),
216 ('Python builtin',builtin_ns),
217 ('Alias',alias_ns),
217 ('Alias',alias_ns),
218 ]
218 ]
219
219
220 # initialize results to 'null'
220 # initialize results to 'null'
221 found = 0; obj = None; ospace = None; ds = None;
221 found = 0; obj = None; ospace = None; ds = None;
222 ismagic = 0; isalias = 0
222 ismagic = 0; isalias = 0
223
223
224 # Look for the given name by splitting it in parts. If the head is
224 # Look for the given name by splitting it in parts. If the head is
225 # found, then we look for all the remaining parts as members, and only
225 # found, then we look for all the remaining parts as members, and only
226 # declare success if we can find them all.
226 # declare success if we can find them all.
227 oname_parts = oname.split('.')
227 oname_parts = oname.split('.')
228 oname_head, oname_rest = oname_parts[0],oname_parts[1:]
228 oname_head, oname_rest = oname_parts[0],oname_parts[1:]
229 for nsname,ns in namespaces:
229 for nsname,ns in namespaces:
230 try:
230 try:
231 obj = ns[oname_head]
231 obj = ns[oname_head]
232 except KeyError:
232 except KeyError:
233 continue
233 continue
234 else:
234 else:
235 for part in oname_rest:
235 for part in oname_rest:
236 try:
236 try:
237 obj = getattr(obj,part)
237 obj = getattr(obj,part)
238 except:
238 except:
239 # Blanket except b/c some badly implemented objects
239 # Blanket except b/c some badly implemented objects
240 # allow __getattr__ to raise exceptions other than
240 # allow __getattr__ to raise exceptions other than
241 # AttributeError, which then crashes IPython.
241 # AttributeError, which then crashes IPython.
242 break
242 break
243 else:
243 else:
244 # If we finish the for loop (no break), we got all members
244 # If we finish the for loop (no break), we got all members
245 found = 1
245 found = 1
246 ospace = nsname
246 ospace = nsname
247 if ns == alias_ns:
247 if ns == alias_ns:
248 isalias = 1
248 isalias = 1
249 break # namespace loop
249 break # namespace loop
250
250
251 # Try to see if it's magic
251 # Try to see if it's magic
252 if not found:
252 if not found:
253 if oname.startswith(self.shell.ESC_MAGIC):
253 if oname.startswith(self.shell.ESC_MAGIC):
254 oname = oname[1:]
254 oname = oname[1:]
255 obj = getattr(self,'magic_'+oname,None)
255 obj = getattr(self,'magic_'+oname,None)
256 if obj is not None:
256 if obj is not None:
257 found = 1
257 found = 1
258 ospace = 'IPython internal'
258 ospace = 'IPython internal'
259 ismagic = 1
259 ismagic = 1
260
260
261 # Last try: special-case some literals like '', [], {}, etc:
261 # Last try: special-case some literals like '', [], {}, etc:
262 if not found and oname_head in ["''",'""','[]','{}','()']:
262 if not found and oname_head in ["''",'""','[]','{}','()']:
263 obj = eval(oname_head)
263 obj = eval(oname_head)
264 found = 1
264 found = 1
265 ospace = 'Interactive'
265 ospace = 'Interactive'
266
266
267 return {'found':found, 'obj':obj, 'namespace':ospace,
267 return {'found':found, 'obj':obj, 'namespace':ospace,
268 'ismagic':ismagic, 'isalias':isalias}
268 'ismagic':ismagic, 'isalias':isalias}
269
269
270 def arg_err(self,func):
270 def arg_err(self,func):
271 """Print docstring if incorrect arguments were passed"""
271 """Print docstring if incorrect arguments were passed"""
272 print 'Error in arguments:'
272 print 'Error in arguments:'
273 print OInspect.getdoc(func)
273 print OInspect.getdoc(func)
274
274
275
275
276 def format_latex(self,str):
276 def format_latex(self,str):
277 """Format a string for latex inclusion."""
277 """Format a string for latex inclusion."""
278
278
279 # Characters that need to be escaped for latex:
279 # Characters that need to be escaped for latex:
280 escape_re = re.compile(r'(%|_|\$)',re.MULTILINE)
280 escape_re = re.compile(r'(%|_|\$)',re.MULTILINE)
281 # Magic command names as headers:
281 # Magic command names as headers:
282 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
282 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
283 re.MULTILINE)
283 re.MULTILINE)
284 # Magic commands
284 # Magic commands
285 cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC,
285 cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC,
286 re.MULTILINE)
286 re.MULTILINE)
287 # Paragraph continue
287 # Paragraph continue
288 par_re = re.compile(r'\\$',re.MULTILINE)
288 par_re = re.compile(r'\\$',re.MULTILINE)
289
289
290 str = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',str)
290 str = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',str)
291 str = cmd_re.sub(r'\\texttt{\g<cmd>}',str)
291 str = cmd_re.sub(r'\\texttt{\g<cmd>}',str)
292 str = par_re.sub(r'\\\\',str)
292 str = par_re.sub(r'\\\\',str)
293 str = escape_re.sub(r'\\\1',str)
293 str = escape_re.sub(r'\\\1',str)
294 return str
294 return str
295
295
296 def format_screen(self,str):
296 def format_screen(self,str):
297 """Format a string for screen printing.
297 """Format a string for screen printing.
298
298
299 This removes some latex-type format codes."""
299 This removes some latex-type format codes."""
300 # Paragraph continue
300 # Paragraph continue
301 par_re = re.compile(r'\\$',re.MULTILINE)
301 par_re = re.compile(r'\\$',re.MULTILINE)
302 str = par_re.sub('',str)
302 str = par_re.sub('',str)
303 return str
303 return str
304
304
305 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
305 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
306 """Parse options passed to an argument string.
306 """Parse options passed to an argument string.
307
307
308 The interface is similar to that of getopt(), but it returns back a
308 The interface is similar to that of getopt(), but it returns back a
309 Struct with the options as keys and the stripped argument string still
309 Struct with the options as keys and the stripped argument string still
310 as a string.
310 as a string.
311
311
312 arg_str is quoted as a true sys.argv vector by calling on the fly a
312 arg_str is quoted as a true sys.argv vector by calling on the fly a
313 python process in a subshell. This allows us to easily expand
313 python process in a subshell. This allows us to easily expand
314 variables, glob files, quote arguments, etc, with all the power and
314 variables, glob files, quote arguments, etc, with all the power and
315 correctness of the underlying system shell.
315 correctness of the underlying system shell.
316
316
317 Options:
317 Options:
318 -mode: default 'string'. If given as 'list', the argument string is
318 -mode: default 'string'. If given as 'list', the argument string is
319 returned as a list (split on whitespace) instead of a string.
319 returned as a list (split on whitespace) instead of a string.
320
320
321 -list_all: put all option values in lists. Normally only options
321 -list_all: put all option values in lists. Normally only options
322 appearing more than once are put in a list."""
322 appearing more than once are put in a list."""
323
323
324 # inject default options at the beginning of the input line
324 # inject default options at the beginning of the input line
325 caller = sys._getframe(1).f_code.co_name.replace('magic_','')
325 caller = sys._getframe(1).f_code.co_name.replace('magic_','')
326 arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str)
326 arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str)
327
327
328 mode = kw.get('mode','string')
328 mode = kw.get('mode','string')
329 if mode not in ['string','list']:
329 if mode not in ['string','list']:
330 raise ValueError,'incorrect mode given: %s' % mode
330 raise ValueError,'incorrect mode given: %s' % mode
331 # Get options
331 # Get options
332 list_all = kw.get('list_all',0)
332 list_all = kw.get('list_all',0)
333
333
334 # Check if we have more than one argument to warrant extra processing:
334 # Check if we have more than one argument to warrant extra processing:
335 odict = {} # Dictionary with options
335 odict = {} # Dictionary with options
336 args = arg_str.split()
336 args = arg_str.split()
337 if len(args) >= 1:
337 if len(args) >= 1:
338 # If the list of inputs only has 0 or 1 thing in it, there's no
338 # If the list of inputs only has 0 or 1 thing in it, there's no
339 # need to look for options
339 # need to look for options
340 argv = shlex_split(arg_str)
340 argv = shlex_split(arg_str)
341 # Do regular option processing
341 # Do regular option processing
342 opts,args = getopt(argv,opt_str,*long_opts)
342 opts,args = getopt(argv,opt_str,*long_opts)
343 for o,a in opts:
343 for o,a in opts:
344 if o.startswith('--'):
344 if o.startswith('--'):
345 o = o[2:]
345 o = o[2:]
346 else:
346 else:
347 o = o[1:]
347 o = o[1:]
348 try:
348 try:
349 odict[o].append(a)
349 odict[o].append(a)
350 except AttributeError:
350 except AttributeError:
351 odict[o] = [odict[o],a]
351 odict[o] = [odict[o],a]
352 except KeyError:
352 except KeyError:
353 if list_all:
353 if list_all:
354 odict[o] = [a]
354 odict[o] = [a]
355 else:
355 else:
356 odict[o] = a
356 odict[o] = a
357
357
358 # Prepare opts,args for return
358 # Prepare opts,args for return
359 opts = Struct(odict)
359 opts = Struct(odict)
360 if mode == 'string':
360 if mode == 'string':
361 args = ' '.join(args)
361 args = ' '.join(args)
362
362
363 return opts,args
363 return opts,args
364
364
365 #......................................................................
365 #......................................................................
366 # And now the actual magic functions
366 # And now the actual magic functions
367
367
368 # Functions for IPython shell work (vars,funcs, config, etc)
368 # Functions for IPython shell work (vars,funcs, config, etc)
369 def magic_lsmagic(self, parameter_s = ''):
369 def magic_lsmagic(self, parameter_s = ''):
370 """List currently available magic functions."""
370 """List currently available magic functions."""
371 mesc = self.shell.ESC_MAGIC
371 mesc = self.shell.ESC_MAGIC
372 print 'Available magic functions:\n'+mesc+\
372 print 'Available magic functions:\n'+mesc+\
373 (' '+mesc).join(self.lsmagic())
373 (' '+mesc).join(self.lsmagic())
374 print '\n' + Magic.auto_status[self.shell.rc.automagic]
374 print '\n' + Magic.auto_status[self.shell.rc.automagic]
375 return None
375 return None
376
376
377 def magic_magic(self, parameter_s = ''):
377 def magic_magic(self, parameter_s = ''):
378 """Print information about the magic function system."""
378 """Print information about the magic function system."""
379
379
380 mode = ''
380 mode = ''
381 try:
381 try:
382 if parameter_s.split()[0] == '-latex':
382 if parameter_s.split()[0] == '-latex':
383 mode = 'latex'
383 mode = 'latex'
384 except:
384 except:
385 pass
385 pass
386
386
387 magic_docs = []
387 magic_docs = []
388 for fname in self.lsmagic():
388 for fname in self.lsmagic():
389 mname = 'magic_' + fname
389 mname = 'magic_' + fname
390 for space in (Magic,self,self.__class__):
390 for space in (Magic,self,self.__class__):
391 try:
391 try:
392 fn = space.__dict__[mname]
392 fn = space.__dict__[mname]
393 except KeyError:
393 except KeyError:
394 pass
394 pass
395 else:
395 else:
396 break
396 break
397 magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC,
397 magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC,
398 fname,fn.__doc__))
398 fname,fn.__doc__))
399 magic_docs = ''.join(magic_docs)
399 magic_docs = ''.join(magic_docs)
400
400
401 if mode == 'latex':
401 if mode == 'latex':
402 print self.format_latex(magic_docs)
402 print self.format_latex(magic_docs)
403 return
403 return
404 else:
404 else:
405 magic_docs = self.format_screen(magic_docs)
405 magic_docs = self.format_screen(magic_docs)
406
406
407 outmsg = """
407 outmsg = """
408 IPython's 'magic' functions
408 IPython's 'magic' functions
409 ===========================
409 ===========================
410
410
411 The magic function system provides a series of functions which allow you to
411 The magic function system provides a series of functions which allow you to
412 control the behavior of IPython itself, plus a lot of system-type
412 control the behavior of IPython itself, plus a lot of system-type
413 features. All these functions are prefixed with a % character, but parameters
413 features. All these functions are prefixed with a % character, but parameters
414 are given without parentheses or quotes.
414 are given without parentheses or quotes.
415
415
416 NOTE: If you have 'automagic' enabled (via the command line option or with the
416 NOTE: If you have 'automagic' enabled (via the command line option or with the
417 %automagic function), you don't need to type in the % explicitly. By default,
417 %automagic function), you don't need to type in the % explicitly. By default,
418 IPython ships with automagic on, so you should only rarely need the % escape.
418 IPython ships with automagic on, so you should only rarely need the % escape.
419
419
420 Example: typing '%cd mydir' (without the quotes) changes you working directory
420 Example: typing '%cd mydir' (without the quotes) changes you working directory
421 to 'mydir', if it exists.
421 to 'mydir', if it exists.
422
422
423 You can define your own magic functions to extend the system. See the supplied
423 You can define your own magic functions to extend the system. See the supplied
424 ipythonrc and example-magic.py files for details (in your ipython
424 ipythonrc and example-magic.py files for details (in your ipython
425 configuration directory, typically $HOME/.ipython/).
425 configuration directory, typically $HOME/.ipython/).
426
426
427 You can also define your own aliased names for magic functions. In your
427 You can also define your own aliased names for magic functions. In your
428 ipythonrc file, placing a line like:
428 ipythonrc file, placing a line like:
429
429
430 execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
430 execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
431
431
432 will define %pf as a new name for %profile.
432 will define %pf as a new name for %profile.
433
433
434 You can also call magics in code using the ipmagic() function, which IPython
434 You can also call magics in code using the ipmagic() function, which IPython
435 automatically adds to the builtin namespace. Type 'ipmagic?' for details.
435 automatically adds to the builtin namespace. Type 'ipmagic?' for details.
436
436
437 For a list of the available magic functions, use %lsmagic. For a description
437 For a list of the available magic functions, use %lsmagic. For a description
438 of any of them, type %magic_name?, e.g. '%cd?'.
438 of any of them, type %magic_name?, e.g. '%cd?'.
439
439
440 Currently the magic system has the following functions:\n"""
440 Currently the magic system has the following functions:\n"""
441
441
442 mesc = self.shell.ESC_MAGIC
442 mesc = self.shell.ESC_MAGIC
443 outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):"
443 outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):"
444 "\n\n%s%s\n\n%s" % (outmsg,
444 "\n\n%s%s\n\n%s" % (outmsg,
445 magic_docs,mesc,mesc,
445 magic_docs,mesc,mesc,
446 (' '+mesc).join(self.lsmagic()),
446 (' '+mesc).join(self.lsmagic()),
447 Magic.auto_status[self.shell.rc.automagic] ) )
447 Magic.auto_status[self.shell.rc.automagic] ) )
448
448
449 page(outmsg,screen_lines=self.shell.rc.screen_length)
449 page(outmsg,screen_lines=self.shell.rc.screen_length)
450
450
451 def magic_automagic(self, parameter_s = ''):
451 def magic_automagic(self, parameter_s = ''):
452 """Make magic functions callable without having to type the initial %.
452 """Make magic functions callable without having to type the initial %.
453
453
454 Toggles on/off (when off, you must call it as %automagic, of
454 Toggles on/off (when off, you must call it as %automagic, of
455 course). Note that magic functions have lowest priority, so if there's
455 course). Note that magic functions have lowest priority, so if there's
456 a variable whose name collides with that of a magic fn, automagic
456 a variable whose name collides with that of a magic fn, automagic
457 won't work for that function (you get the variable instead). However,
457 won't work for that function (you get the variable instead). However,
458 if you delete the variable (del var), the previously shadowed magic
458 if you delete the variable (del var), the previously shadowed magic
459 function becomes visible to automagic again."""
459 function becomes visible to automagic again."""
460
460
461 rc = self.shell.rc
461 rc = self.shell.rc
462 rc.automagic = not rc.automagic
462 rc.automagic = not rc.automagic
463 print '\n' + Magic.auto_status[rc.automagic]
463 print '\n' + Magic.auto_status[rc.automagic]
464
464
465 def magic_autocall(self, parameter_s = ''):
465 def magic_autocall(self, parameter_s = ''):
466 """Make functions callable without having to type parentheses.
466 """Make functions callable without having to type parentheses.
467
467
468 This toggles the autocall command line option on and off."""
468 This toggles the autocall command line option on and off."""
469
469
470 rc = self.shell.rc
470 rc = self.shell.rc
471 rc.autocall = not rc.autocall
471 rc.autocall = not rc.autocall
472 print "Automatic calling is:",['OFF','ON'][rc.autocall]
472 print "Automatic calling is:",['OFF','ON'][rc.autocall]
473
473
474 def magic_autoindent(self, parameter_s = ''):
474 def magic_autoindent(self, parameter_s = ''):
475 """Toggle autoindent on/off (if available)."""
475 """Toggle autoindent on/off (if available)."""
476
476
477 self.shell.set_autoindent()
477 self.shell.set_autoindent()
478 print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent]
478 print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent]
479
479
480 def magic_system_verbose(self, parameter_s = ''):
480 def magic_system_verbose(self, parameter_s = ''):
481 """Toggle verbose printing of system calls on/off."""
481 """Toggle verbose printing of system calls on/off."""
482
482
483 self.shell.rc_set_toggle('system_verbose')
483 self.shell.rc_set_toggle('system_verbose')
484 print "System verbose printing is:",\
484 print "System verbose printing is:",\
485 ['OFF','ON'][self.shell.rc.system_verbose]
485 ['OFF','ON'][self.shell.rc.system_verbose]
486
486
487 def magic_history(self, parameter_s = ''):
487 def magic_history(self, parameter_s = ''):
488 """Print input history (_i<n> variables), with most recent last.
488 """Print input history (_i<n> variables), with most recent last.
489
489
490 %history [-n] -> print at most 40 inputs (some may be multi-line)\\
490 %history [-n] -> print at most 40 inputs (some may be multi-line)\\
491 %history [-n] n -> print at most n inputs\\
491 %history [-n] n -> print at most n inputs\\
492 %history [-n] n1 n2 -> print inputs between n1 and n2 (n2 not included)\\
492 %history [-n] n1 n2 -> print inputs between n1 and n2 (n2 not included)\\
493
493
494 Each input's number <n> is shown, and is accessible as the
494 Each input's number <n> is shown, and is accessible as the
495 automatically generated variable _i<n>. Multi-line statements are
495 automatically generated variable _i<n>. Multi-line statements are
496 printed starting at a new line for easy copy/paste.
496 printed starting at a new line for easy copy/paste.
497
497
498 If option -n is used, input numbers are not printed. This is useful if
498 If option -n is used, input numbers are not printed. This is useful if
499 you want to get a printout of many lines which can be directly pasted
499 you want to get a printout of many lines which can be directly pasted
500 into a text editor.
500 into a text editor.
501
501
502 This feature is only available if numbered prompts are in use."""
502 This feature is only available if numbered prompts are in use."""
503
503
504 if not self.do_full_cache:
504 if not self.do_full_cache:
505 print 'This feature is only available if numbered prompts are in use.'
505 print 'This feature is only available if numbered prompts are in use.'
506 return
506 return
507 opts,args = self.parse_options(parameter_s,'n',mode='list')
507 opts,args = self.parse_options(parameter_s,'n',mode='list')
508
508
509 default_length = 40
509 default_length = 40
510 if len(args) == 0:
510 if len(args) == 0:
511 final = self.outputcache.prompt_count
511 final = self.outputcache.prompt_count
512 init = max(1,final-default_length)
512 init = max(1,final-default_length)
513 elif len(args) == 1:
513 elif len(args) == 1:
514 final = self.outputcache.prompt_count
514 final = self.outputcache.prompt_count
515 init = max(1,final-int(args[0]))
515 init = max(1,final-int(args[0]))
516 elif len(args) == 2:
516 elif len(args) == 2:
517 init,final = map(int,args)
517 init,final = map(int,args)
518 else:
518 else:
519 warn('%hist takes 0, 1 or 2 arguments separated by spaces.')
519 warn('%hist takes 0, 1 or 2 arguments separated by spaces.')
520 print self.magic_hist.__doc__
520 print self.magic_hist.__doc__
521 return
521 return
522 width = len(str(final))
522 width = len(str(final))
523 line_sep = ['','\n']
523 line_sep = ['','\n']
524 input_hist = self.shell.input_hist
524 input_hist = self.shell.input_hist
525 print_nums = not opts.has_key('n')
525 print_nums = not opts.has_key('n')
526 for in_num in range(init,final):
526 for in_num in range(init,final):
527 inline = input_hist[in_num]
527 inline = input_hist[in_num]
528 multiline = inline.count('\n') > 1
528 multiline = inline.count('\n') > 1
529 if print_nums:
529 if print_nums:
530 print str(in_num).ljust(width)+':'+ line_sep[multiline],
530 print str(in_num).ljust(width)+':'+ line_sep[multiline],
531 if inline.startswith('#'+self.shell.ESC_MAGIC) or \
531 if inline.startswith('#'+self.shell.ESC_MAGIC) or \
532 inline.startswith('#!'):
532 inline.startswith('#!'):
533 print inline[1:],
533 print inline[1:],
534 else:
534 else:
535 print inline,
535 print inline,
536
536
537 def magic_hist(self, parameter_s=''):
537 def magic_hist(self, parameter_s=''):
538 """Alternate name for %history."""
538 """Alternate name for %history."""
539 return self.magic_history(parameter_s)
539 return self.magic_history(parameter_s)
540
540
541 def magic_p(self, parameter_s=''):
541 def magic_p(self, parameter_s=''):
542 """Just a short alias for Python's 'print'."""
542 """Just a short alias for Python's 'print'."""
543 exec 'print ' + parameter_s in self.shell.user_ns
543 exec 'print ' + parameter_s in self.shell.user_ns
544
544
545 def magic_r(self, parameter_s=''):
545 def magic_r(self, parameter_s=''):
546 """Repeat previous input.
546 """Repeat previous input.
547
547
548 If given an argument, repeats the previous command which starts with
548 If given an argument, repeats the previous command which starts with
549 the same string, otherwise it just repeats the previous input.
549 the same string, otherwise it just repeats the previous input.
550
550
551 Shell escaped commands (with ! as first character) are not recognized
551 Shell escaped commands (with ! as first character) are not recognized
552 by this system, only pure python code and magic commands.
552 by this system, only pure python code and magic commands.
553 """
553 """
554
554
555 start = parameter_s.strip()
555 start = parameter_s.strip()
556 esc_magic = self.shell.ESC_MAGIC
556 esc_magic = self.shell.ESC_MAGIC
557 # Identify magic commands even if automagic is on (which means
557 # Identify magic commands even if automagic is on (which means
558 # the in-memory version is different from that typed by the user).
558 # the in-memory version is different from that typed by the user).
559 if self.shell.rc.automagic:
559 if self.shell.rc.automagic:
560 start_magic = esc_magic+start
560 start_magic = esc_magic+start
561 else:
561 else:
562 start_magic = start
562 start_magic = start
563 # Look through the input history in reverse
563 # Look through the input history in reverse
564 for n in range(len(self.shell.input_hist)-2,0,-1):
564 for n in range(len(self.shell.input_hist)-2,0,-1):
565 input = self.shell.input_hist[n]
565 input = self.shell.input_hist[n]
566 # skip plain 'r' lines so we don't recurse to infinity
566 # skip plain 'r' lines so we don't recurse to infinity
567 if input != 'ipmagic("r")\n' and \
567 if input != 'ipmagic("r")\n' and \
568 (input.startswith(start) or input.startswith(start_magic)):
568 (input.startswith(start) or input.startswith(start_magic)):
569 #print 'match',`input` # dbg
569 #print 'match',`input` # dbg
570 if input.startswith(esc_magic):
570 if input.startswith(esc_magic):
571 input = magic2python(input)
571 input = magic2python(input)
572 #print 'modified',`input` # dbg
572 #print 'modified',`input` # dbg
573 print 'Executing:',input,
573 print 'Executing:',input,
574 exec input in self.shell.user_ns
574 exec input in self.shell.user_ns
575 return
575 return
576 print 'No previous input matching `%s` found.' % start
576 print 'No previous input matching `%s` found.' % start
577
577
578 def magic_page(self, parameter_s=''):
578 def magic_page(self, parameter_s=''):
579 """Pretty print the object and display it through a pager.
579 """Pretty print the object and display it through a pager.
580
580
581 If no parameter is given, use _ (last output)."""
581 If no parameter is given, use _ (last output)."""
582 # After a function contributed by Olivier Aubert, slightly modified.
582 # After a function contributed by Olivier Aubert, slightly modified.
583
583
584 oname = parameter_s and parameter_s or '_'
584 oname = parameter_s and parameter_s or '_'
585 info = self._ofind(oname)
585 info = self._ofind(oname)
586 if info['found']:
586 if info['found']:
587 page(pformat(info['obj']))
587 page(pformat(info['obj']))
588 else:
588 else:
589 print 'Object `%s` not found' % oname
589 print 'Object `%s` not found' % oname
590
590
591 def magic_profile(self, parameter_s=''):
591 def magic_profile(self, parameter_s=''):
592 """Print your currently active IPyhton profile."""
592 """Print your currently active IPyhton profile."""
593 if self.shell.rc.profile:
593 if self.shell.rc.profile:
594 printpl('Current IPython profile: $self.shell.rc.profile.')
594 printpl('Current IPython profile: $self.shell.rc.profile.')
595 else:
595 else:
596 print 'No profile active.'
596 print 'No profile active.'
597
597
598 def _inspect(self,meth,oname,**kw):
598 def _inspect(self,meth,oname,**kw):
599 """Generic interface to the inspector system.
599 """Generic interface to the inspector system.
600
600
601 This function is meant to be called by pdef, pdoc & friends."""
601 This function is meant to be called by pdef, pdoc & friends."""
602
602
603 oname = oname.strip()
603 oname = oname.strip()
604 info = Struct(self._ofind(oname))
604 info = Struct(self._ofind(oname))
605 if info.found:
605 if info.found:
606 pmethod = getattr(self.shell.inspector,meth)
606 pmethod = getattr(self.shell.inspector,meth)
607 formatter = info.ismagic and self.format_screen or None
607 formatter = info.ismagic and self.format_screen or None
608 if meth == 'pdoc':
608 if meth == 'pdoc':
609 pmethod(info.obj,oname,formatter)
609 pmethod(info.obj,oname,formatter)
610 elif meth == 'pinfo':
610 elif meth == 'pinfo':
611 pmethod(info.obj,oname,formatter,info,**kw)
611 pmethod(info.obj,oname,formatter,info,**kw)
612 else:
612 else:
613 pmethod(info.obj,oname)
613 pmethod(info.obj,oname)
614 else:
614 else:
615 print 'Object `%s` not found.' % oname
615 print 'Object `%s` not found.' % oname
616 return 'not found' # so callers can take other action
616 return 'not found' # so callers can take other action
617
617
618 def magic_pdef(self, parameter_s=''):
618 def magic_pdef(self, parameter_s=''):
619 """Print the definition header for any callable object.
619 """Print the definition header for any callable object.
620
620
621 If the object is a class, print the constructor information."""
621 If the object is a class, print the constructor information."""
622 self._inspect('pdef',parameter_s)
622 self._inspect('pdef',parameter_s)
623
623
624 def magic_pdoc(self, parameter_s=''):
624 def magic_pdoc(self, parameter_s=''):
625 """Print the docstring for an object.
625 """Print the docstring for an object.
626
626
627 If the given object is a class, it will print both the class and the
627 If the given object is a class, it will print both the class and the
628 constructor docstrings."""
628 constructor docstrings."""
629 self._inspect('pdoc',parameter_s)
629 self._inspect('pdoc',parameter_s)
630
630
631 def magic_psource(self, parameter_s=''):
631 def magic_psource(self, parameter_s=''):
632 """Print (or run through pager) the source code for an object."""
632 """Print (or run through pager) the source code for an object."""
633 self._inspect('psource',parameter_s)
633 self._inspect('psource',parameter_s)
634
634
635 def magic_pfile(self, parameter_s=''):
635 def magic_pfile(self, parameter_s=''):
636 """Print (or run through pager) the file where an object is defined.
636 """Print (or run through pager) the file where an object is defined.
637
637
638 The file opens at the line where the object definition begins. IPython
638 The file opens at the line where the object definition begins. IPython
639 will honor the environment variable PAGER if set, and otherwise will
639 will honor the environment variable PAGER if set, and otherwise will
640 do its best to print the file in a convenient form.
640 do its best to print the file in a convenient form.
641
641
642 If the given argument is not an object currently defined, IPython will
642 If the given argument is not an object currently defined, IPython will
643 try to interpret it as a filename (automatically adding a .py extension
643 try to interpret it as a filename (automatically adding a .py extension
644 if needed). You can thus use %pfile as a syntax highlighting code
644 if needed). You can thus use %pfile as a syntax highlighting code
645 viewer."""
645 viewer."""
646
646
647 # first interpret argument as an object name
647 # first interpret argument as an object name
648 out = self._inspect('pfile',parameter_s)
648 out = self._inspect('pfile',parameter_s)
649 # if not, try the input as a filename
649 # if not, try the input as a filename
650 if out == 'not found':
650 if out == 'not found':
651 try:
651 try:
652 filename = get_py_filename(parameter_s)
652 filename = get_py_filename(parameter_s)
653 except IOError,msg:
653 except IOError,msg:
654 print msg
654 print msg
655 return
655 return
656 page(self.shell.inspector.format(file(filename).read()))
656 page(self.shell.inspector.format(file(filename).read()))
657
657
658 def magic_pinfo(self, parameter_s=''):
658 def magic_pinfo(self, parameter_s=''):
659 """Provide detailed information about an object.
659 """Provide detailed information about an object.
660
660
661 '%pinfo object' is just a synonym for object? or ?object."""
661 '%pinfo object' is just a synonym for object? or ?object."""
662
662
663 #print 'pinfo par: <%s>' % parameter_s # dbg
663 #print 'pinfo par: <%s>' % parameter_s # dbg
664
664
665 # detail_level: 0 -> obj? , 1 -> obj??
665 # detail_level: 0 -> obj? , 1 -> obj??
666 detail_level = 0
666 detail_level = 0
667 # We need to detect if we got called as 'pinfo pinfo foo', which can
667 # We need to detect if we got called as 'pinfo pinfo foo', which can
668 # happen if the user types 'pinfo foo?' at the cmd line.
668 # happen if the user types 'pinfo foo?' at the cmd line.
669 pinfo,qmark1,oname,qmark2 = \
669 pinfo,qmark1,oname,qmark2 = \
670 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
670 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
671 if pinfo or qmark1 or qmark2:
671 if pinfo or qmark1 or qmark2:
672 detail_level = 1
672 detail_level = 1
673 self._inspect('pinfo',oname,detail_level=detail_level)
673 self._inspect('pinfo',oname,detail_level=detail_level)
674
674
675 def magic_who_ls(self, parameter_s=''):
675 def magic_who_ls(self, parameter_s=''):
676 """Return a sorted list of all interactive variables.
676 """Return a sorted list of all interactive variables.
677
677
678 If arguments are given, only variables of types matching these
678 If arguments are given, only variables of types matching these
679 arguments are returned."""
679 arguments are returned."""
680
680
681 user_ns = self.shell.user_ns
681 user_ns = self.shell.user_ns
682 out = []
682 out = []
683 typelist = parameter_s.split()
683 typelist = parameter_s.split()
684 for i in self.shell.user_ns.keys():
684 for i in self.shell.user_ns.keys():
685 if not (i.startswith('_') or i.startswith('_i')) \
685 if not (i.startswith('_') or i.startswith('_i')) \
686 and not (self.internal_ns.has_key(i) or
686 and not (self.internal_ns.has_key(i) or
687 self.user_config_ns.has_key(i)):
687 self.user_config_ns.has_key(i)):
688 if typelist:
688 if typelist:
689 if type(user_ns[i]).__name__ in typelist:
689 if type(user_ns[i]).__name__ in typelist:
690 out.append(i)
690 out.append(i)
691 else:
691 else:
692 out.append(i)
692 out.append(i)
693 out.sort()
693 out.sort()
694 return out
694 return out
695
695
696 def magic_who(self, parameter_s=''):
696 def magic_who(self, parameter_s=''):
697 """Print all interactive variables, with some minimal formatting.
697 """Print all interactive variables, with some minimal formatting.
698
698
699 If any arguments are given, only variables whose type matches one of
699 If any arguments are given, only variables whose type matches one of
700 these are printed. For example:
700 these are printed. For example:
701
701
702 %who function str
702 %who function str
703
703
704 will only list functions and strings, excluding all other types of
704 will only list functions and strings, excluding all other types of
705 variables. To find the proper type names, simply use type(var) at a
705 variables. To find the proper type names, simply use type(var) at a
706 command line to see how python prints type names. For example:
706 command line to see how python prints type names. For example:
707
707
708 In [1]: type('hello')\\
708 In [1]: type('hello')\\
709 Out[1]: <type 'str'>
709 Out[1]: <type 'str'>
710
710
711 indicates that the type name for strings is 'str'.
711 indicates that the type name for strings is 'str'.
712
712
713 %who always excludes executed names loaded through your configuration
713 %who always excludes executed names loaded through your configuration
714 file and things which are internal to IPython.
714 file and things which are internal to IPython.
715
715
716 This is deliberate, as typically you may load many modules and the
716 This is deliberate, as typically you may load many modules and the
717 purpose of %who is to show you only what you've manually defined."""
717 purpose of %who is to show you only what you've manually defined."""
718
718
719 varlist = self.magic_who_ls(parameter_s)
719 varlist = self.magic_who_ls(parameter_s)
720 if not varlist:
720 if not varlist:
721 print 'Interactive namespace is empty.'
721 print 'Interactive namespace is empty.'
722 return
722 return
723
723
724 # if we have variables, move on...
724 # if we have variables, move on...
725
725
726 # stupid flushing problem: when prompts have no separators, stdout is
726 # stupid flushing problem: when prompts have no separators, stdout is
727 # getting lost. I'm starting to think this is a python bug. I'm having
727 # getting lost. I'm starting to think this is a python bug. I'm having
728 # to force a flush with a print because even a sys.stdout.flush
728 # to force a flush with a print because even a sys.stdout.flush
729 # doesn't seem to do anything!
729 # doesn't seem to do anything!
730
730
731 count = 0
731 count = 0
732 for i in varlist:
732 for i in varlist:
733 print i+'\t',
733 print i+'\t',
734 count += 1
734 count += 1
735 if count > 8:
735 if count > 8:
736 count = 0
736 count = 0
737 print
737 print
738 sys.stdout.flush() # FIXME. Why the hell isn't this flushing???
738 sys.stdout.flush() # FIXME. Why the hell isn't this flushing???
739
739
740 print # well, this does force a flush at the expense of an extra \n
740 print # well, this does force a flush at the expense of an extra \n
741
741
742 def magic_whos(self, parameter_s=''):
742 def magic_whos(self, parameter_s=''):
743 """Like %who, but gives some extra information about each variable.
743 """Like %who, but gives some extra information about each variable.
744
744
745 The same type filtering of %who can be applied here.
745 The same type filtering of %who can be applied here.
746
746
747 For all variables, the type is printed. Additionally it prints:
747 For all variables, the type is printed. Additionally it prints:
748
748
749 - For {},[],(): their length.
749 - For {},[],(): their length.
750
750
751 - For Numeric arrays, a summary with shape, number of elements,
751 - For Numeric arrays, a summary with shape, number of elements,
752 typecode and size in memory.
752 typecode and size in memory.
753
753
754 - Everything else: a string representation, snipping their middle if
754 - Everything else: a string representation, snipping their middle if
755 too long."""
755 too long."""
756
756
757 varnames = self.magic_who_ls(parameter_s)
757 varnames = self.magic_who_ls(parameter_s)
758 if not varnames:
758 if not varnames:
759 print 'Interactive namespace is empty.'
759 print 'Interactive namespace is empty.'
760 return
760 return
761
761
762 # if we have variables, move on...
762 # if we have variables, move on...
763
763
764 # for these types, show len() instead of data:
764 # for these types, show len() instead of data:
765 seq_types = [types.DictType,types.ListType,types.TupleType]
765 seq_types = [types.DictType,types.ListType,types.TupleType]
766
766
767 # for Numeric arrays, display summary info
767 # for Numeric arrays, display summary info
768 try:
768 try:
769 import Numeric
769 import Numeric
770 except ImportError:
770 except ImportError:
771 array_type = None
771 array_type = None
772 else:
772 else:
773 array_type = Numeric.ArrayType.__name__
773 array_type = Numeric.ArrayType.__name__
774
774
775 # Find all variable names and types so we can figure out column sizes
775 # Find all variable names and types so we can figure out column sizes
776 get_vars = lambda i: self.locals[i]
776 get_vars = lambda i: self.locals[i]
777 type_name = lambda v: type(v).__name__
777 type_name = lambda v: type(v).__name__
778 varlist = map(get_vars,varnames)
778 varlist = map(get_vars,varnames)
779 typelist = map(type_name,varlist)
779 typelist = map(type_name,varlist)
780 # column labels and # of spaces as separator
780 # column labels and # of spaces as separator
781 varlabel = 'Variable'
781 varlabel = 'Variable'
782 typelabel = 'Type'
782 typelabel = 'Type'
783 datalabel = 'Data/Info'
783 datalabel = 'Data/Info'
784 colsep = 3
784 colsep = 3
785 # variable format strings
785 # variable format strings
786 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
786 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
787 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
787 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
788 aformat = "%s: %s elems, type `%s`, %s bytes"
788 aformat = "%s: %s elems, type `%s`, %s bytes"
789 # find the size of the columns to format the output nicely
789 # find the size of the columns to format the output nicely
790 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
790 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
791 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
791 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
792 # table header
792 # table header
793 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
793 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
794 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
794 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
795 # and the table itself
795 # and the table itself
796 kb = 1024
796 kb = 1024
797 Mb = 1048576 # kb**2
797 Mb = 1048576 # kb**2
798 for vname,var,vtype in zip(varnames,varlist,typelist):
798 for vname,var,vtype in zip(varnames,varlist,typelist):
799 print itpl(vformat),
799 print itpl(vformat),
800 if vtype in seq_types:
800 if vtype in seq_types:
801 print len(var)
801 print len(var)
802 elif vtype==array_type:
802 elif vtype==array_type:
803 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
803 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
804 vsize = Numeric.size(var)
804 vsize = Numeric.size(var)
805 vbytes = vsize*var.itemsize()
805 vbytes = vsize*var.itemsize()
806 if vbytes < 100000:
806 if vbytes < 100000:
807 print aformat % (vshape,vsize,var.typecode(),vbytes)
807 print aformat % (vshape,vsize,var.typecode(),vbytes)
808 else:
808 else:
809 print aformat % (vshape,vsize,var.typecode(),vbytes),
809 print aformat % (vshape,vsize,var.typecode(),vbytes),
810 if vbytes < Mb:
810 if vbytes < Mb:
811 print '(%s kb)' % (vbytes/kb,)
811 print '(%s kb)' % (vbytes/kb,)
812 else:
812 else:
813 print '(%s Mb)' % (vbytes/Mb,)
813 print '(%s Mb)' % (vbytes/Mb,)
814 else:
814 else:
815 vstr = str(var)
815 vstr = str(var)
816 if len(vstr) < 50:
816 if len(vstr) < 50:
817 print vstr
817 print vstr
818 else:
818 else:
819 printpl(vfmt_short)
819 printpl(vfmt_short)
820
820
821 def magic_reset(self, parameter_s=''):
821 def magic_reset(self, parameter_s=''):
822 """Resets the namespace by removing all names defined by the user.
822 """Resets the namespace by removing all names defined by the user.
823
823
824 Input/Output history are left around in case you need them."""
824 Input/Output history are left around in case you need them."""
825
825
826 ans = raw_input(
826 ans = raw_input(
827 "Once deleted, variables cannot be recovered. Proceed (y/n)? ")
827 "Once deleted, variables cannot be recovered. Proceed (y/n)? ")
828 if not ans.lower() == 'y':
828 if not ans.lower() == 'y':
829 print 'Nothing done.'
829 print 'Nothing done.'
830 return
830 return
831 for i in self.magic_who_ls():
831 for i in self.magic_who_ls():
832 del(self.locals[i])
832 del(self.locals[i])
833
833
834 def magic_config(self,parameter_s=''):
834 def magic_config(self,parameter_s=''):
835 """Show IPython's internal configuration."""
835 """Show IPython's internal configuration."""
836
836
837 page('Current configuration structure:\n'+
837 page('Current configuration structure:\n'+
838 pformat(self.shell.rc.dict()))
838 pformat(self.shell.rc.dict()))
839
839
840 def magic_logstart(self,parameter_s=''):
840 def magic_logstart(self,parameter_s=''):
841 """Start logging anywhere in a session.
841 """Start logging anywhere in a session.
842
842
843 %logstart [log_name [log_mode]]
843 %logstart [log_name [log_mode]]
844
844
845 If no name is given, it defaults to a file named 'ipython.log' in your
845 If no name is given, it defaults to a file named 'ipython.log' in your
846 current directory, in 'rotate' mode (see below).
846 current directory, in 'rotate' mode (see below).
847
847
848 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
848 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
849 history up to that point and then continues logging.
849 history up to that point and then continues logging.
850
850
851 %logstart takes a second optional parameter: logging mode. This can be one
851 %logstart takes a second optional parameter: logging mode. This can be one
852 of (note that the modes are given unquoted):\\
852 of (note that the modes are given unquoted):\\
853 over: overwrite existing log.\\
853 over: overwrite existing log.\\
854 backup: rename (if exists) to name~ and start name.\\
854 backup: rename (if exists) to name~ and start name.\\
855 append: well, that says it.\\
855 append: well, that says it.\\
856 rotate: create rotating logs name.1~, name.2~, etc.
856 rotate: create rotating logs name.1~, name.2~, etc.
857 """
857 """
858
858
859 #FIXME. This function should all be moved to the Logger class.
859 #FIXME. This function should all be moved to the Logger class.
860
860
861 valid_modes = qw('over backup append rotate')
861 valid_modes = qw('over backup append rotate')
862 if self.LOG:
862 if self.LOG:
863 print 'Logging is already in place. Logfile:',self.LOG
863 print 'Logging is already in place. Logfile:',self.LOG
864 return
864 return
865
865
866 par = parameter_s.strip()
866 par = parameter_s.strip()
867 if not par:
867 if not par:
868 logname = self.LOGDEF
868 logname = self.LOGDEF
869 logmode = 'rotate' # use rotate for the auto-generated logs
869 logmode = 'rotate' # use rotate for the auto-generated logs
870 else:
870 else:
871 try:
871 try:
872 logname,logmode = par.split()
872 logname,logmode = par.split()
873 except:
873 except:
874 try:
874 try:
875 logname = par
875 logname = par
876 logmode = 'backup'
876 logmode = 'backup'
877 except:
877 except:
878 warn('Usage: %log [log_name [log_mode]]')
878 warn('Usage: %log [log_name [log_mode]]')
879 return
879 return
880 if not logmode in valid_modes:
880 if not logmode in valid_modes:
881 warn('Logging NOT activated.\n'
881 warn('Logging NOT activated.\n'
882 'Usage: %log [log_name [log_mode]]\n'
882 'Usage: %log [log_name [log_mode]]\n'
883 'Valid modes: '+str(valid_modes))
883 'Valid modes: '+str(valid_modes))
884 return
884 return
885
885
886 # If we made it this far, I think we're ok:
886 # If we made it this far, I think we're ok:
887 print 'Activating auto-logging.'
887 print 'Activating auto-logging.'
888 print 'Current session state plus future input saved to:',logname
888 print 'Current session state plus future input saved to:',logname
889 print 'Logging mode: ',logmode
889 print 'Logging mode: ',logmode
890 # put logname into rc struct as if it had been called on the command line,
890 # put logname into rc struct as if it had been called on the command line,
891 # so it ends up saved in the log header
891 # so it ends up saved in the log header
892 # Save it in case we need to restore it...
892 # Save it in case we need to restore it...
893 old_logfile = self.shell.rc.opts.get('logfile','')
893 old_logfile = self.shell.rc.opts.get('logfile','')
894 logname = os.path.expanduser(logname)
894 logname = os.path.expanduser(logname)
895 self.shell.rc.opts.logfile = logname
895 self.shell.rc.opts.logfile = logname
896 self.LOGMODE = logmode # FIXME: this should be set through a function.
896 self.LOGMODE = logmode # FIXME: this should be set through a function.
897 try:
897 try:
898 header = str(self.LOGHEAD)
898 header = str(self.LOGHEAD)
899 self.create_log(header,logname)
899 self.create_log(header,logname)
900 self.logstart(header,logname)
900 self.logstart(header,logname)
901 except:
901 except:
902 self.LOG = '' # we are NOT logging, something went wrong
902 self.LOG = '' # we are NOT logging, something went wrong
903 self.shell.rc.opts.logfile = old_logfile
903 self.shell.rc.opts.logfile = old_logfile
904 warn("Couldn't start log: "+str(sys.exc_info()[1]))
904 warn("Couldn't start log: "+str(sys.exc_info()[1]))
905 else: # log input history up to this point
905 else: # log input history up to this point
906 self.logfile.write(self.shell.user_ns['_ih'][1:])
906 self.logfile.write(self.shell.user_ns['_ih'][1:])
907 self.logfile.flush()
907 self.logfile.flush()
908
908
909 def magic_logoff(self,parameter_s=''):
909 def magic_logoff(self,parameter_s=''):
910 """Temporarily stop logging.
910 """Temporarily stop logging.
911
911
912 You must have previously started logging."""
912 You must have previously started logging."""
913 self.switch_log(0)
913 self.switch_log(0)
914
914
915 def magic_logon(self,parameter_s=''):
915 def magic_logon(self,parameter_s=''):
916 """Restart logging.
916 """Restart logging.
917
917
918 This function is for restarting logging which you've temporarily
918 This function is for restarting logging which you've temporarily
919 stopped with %logoff. For starting logging for the first time, you
919 stopped with %logoff. For starting logging for the first time, you
920 must use the %logstart function, which allows you to specify an
920 must use the %logstart function, which allows you to specify an
921 optional log filename."""
921 optional log filename."""
922
922
923 self.switch_log(1)
923 self.switch_log(1)
924
924
925 def magic_logstate(self,parameter_s=''):
925 def magic_logstate(self,parameter_s=''):
926 """Print the status of the logging system."""
926 """Print the status of the logging system."""
927
927
928 self.logstate()
928 self.logstate()
929
929
930 def magic_pdb(self, parameter_s=''):
930 def magic_pdb(self, parameter_s=''):
931 """Control the calling of the pdb interactive debugger.
931 """Control the calling of the pdb interactive debugger.
932
932
933 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
933 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
934 argument it works as a toggle.
934 argument it works as a toggle.
935
935
936 When an exception is triggered, IPython can optionally call the
936 When an exception is triggered, IPython can optionally call the
937 interactive pdb debugger after the traceback printout. %pdb toggles
937 interactive pdb debugger after the traceback printout. %pdb toggles
938 this feature on and off."""
938 this feature on and off."""
939
939
940 par = parameter_s.strip().lower()
940 par = parameter_s.strip().lower()
941
941
942 if par:
942 if par:
943 try:
943 try:
944 pdb = {'off':0,'0':0,'on':1,'1':1}[par]
944 pdb = {'off':0,'0':0,'on':1,'1':1}[par]
945 except KeyError:
945 except KeyError:
946 print 'Incorrect argument. Use on/1, off/0 or nothing for a toggle.'
946 print 'Incorrect argument. Use on/1, off/0 or nothing for a toggle.'
947 return
947 return
948 else:
948 else:
949 self.shell.InteractiveTB.call_pdb = pdb
949 self.shell.InteractiveTB.call_pdb = pdb
950 else:
950 else:
951 self.shell.InteractiveTB.call_pdb = 1 - self.shell.InteractiveTB.call_pdb
951 self.shell.InteractiveTB.call_pdb = 1 - self.shell.InteractiveTB.call_pdb
952 print 'Automatic pdb calling has been turned',\
952 print 'Automatic pdb calling has been turned',\
953 on_off(self.shell.InteractiveTB.call_pdb)
953 on_off(self.shell.InteractiveTB.call_pdb)
954
954
955
955
956 def magic_prun(self, parameter_s ='',user_mode=1,
956 def magic_prun(self, parameter_s ='',user_mode=1,
957 opts=None,arg_lst=None,prog_ns=None):
957 opts=None,arg_lst=None,prog_ns=None):
958
958
959 """Run a statement through the python code profiler.
959 """Run a statement through the python code profiler.
960
960
961 Usage:\\
961 Usage:\\
962 %prun [options] statement
962 %prun [options] statement
963
963
964 The given statement (which doesn't require quote marks) is run via the
964 The given statement (which doesn't require quote marks) is run via the
965 python profiler in a manner similar to the profile.run() function.
965 python profiler in a manner similar to the profile.run() function.
966 Namespaces are internally managed to work correctly; profile.run
966 Namespaces are internally managed to work correctly; profile.run
967 cannot be used in IPython because it makes certain assumptions about
967 cannot be used in IPython because it makes certain assumptions about
968 namespaces which do not hold under IPython.
968 namespaces which do not hold under IPython.
969
969
970 Options:
970 Options:
971
971
972 -l <limit>: you can place restrictions on what or how much of the
972 -l <limit>: you can place restrictions on what or how much of the
973 profile gets printed. The limit value can be:
973 profile gets printed. The limit value can be:
974
974
975 * A string: only information for function names containing this string
975 * A string: only information for function names containing this string
976 is printed.
976 is printed.
977
977
978 * An integer: only these many lines are printed.
978 * An integer: only these many lines are printed.
979
979
980 * A float (between 0 and 1): this fraction of the report is printed
980 * A float (between 0 and 1): this fraction of the report is printed
981 (for example, use a limit of 0.4 to see the topmost 40% only).
981 (for example, use a limit of 0.4 to see the topmost 40% only).
982
982
983 You can combine several limits with repeated use of the option. For
983 You can combine several limits with repeated use of the option. For
984 example, '-l __init__ -l 5' will print only the topmost 5 lines of
984 example, '-l __init__ -l 5' will print only the topmost 5 lines of
985 information about class constructors.
985 information about class constructors.
986
986
987 -r: return the pstats.Stats object generated by the profiling. This
987 -r: return the pstats.Stats object generated by the profiling. This
988 object has all the information about the profile in it, and you can
988 object has all the information about the profile in it, and you can
989 later use it for further analysis or in other functions.
989 later use it for further analysis or in other functions.
990
990
991 Since magic functions have a particular form of calling which prevents
991 Since magic functions have a particular form of calling which prevents
992 you from writing something like:\\
992 you from writing something like:\\
993 In [1]: p = %prun -r print 4 # invalid!\\
993 In [1]: p = %prun -r print 4 # invalid!\\
994 you must instead use IPython's automatic variables to assign this:\\
994 you must instead use IPython's automatic variables to assign this:\\
995 In [1]: %prun -r print 4 \\
995 In [1]: %prun -r print 4 \\
996 Out[1]: <pstats.Stats instance at 0x8222cec>\\
996 Out[1]: <pstats.Stats instance at 0x8222cec>\\
997 In [2]: stats = _
997 In [2]: stats = _
998
998
999 If you really need to assign this value via an explicit function call,
999 If you really need to assign this value via an explicit function call,
1000 you can always tap directly into the true name of the magic function
1000 you can always tap directly into the true name of the magic function
1001 by using the ipmagic function (which IPython automatically adds to the
1001 by using the ipmagic function (which IPython automatically adds to the
1002 builtins):\\
1002 builtins):\\
1003 In [3]: stats = ipmagic('prun','-r print 4')
1003 In [3]: stats = ipmagic('prun','-r print 4')
1004
1004
1005 You can type ipmagic? for more details on ipmagic.
1005 You can type ipmagic? for more details on ipmagic.
1006
1006
1007 -s <key>: sort profile by given key. You can provide more than one key
1007 -s <key>: sort profile by given key. You can provide more than one key
1008 by using the option several times: '-s key1 -s key2 -s key3...'. The
1008 by using the option several times: '-s key1 -s key2 -s key3...'. The
1009 default sorting key is 'time'.
1009 default sorting key is 'time'.
1010
1010
1011 The following is copied verbatim from the profile documentation
1011 The following is copied verbatim from the profile documentation
1012 referenced below:
1012 referenced below:
1013
1013
1014 When more than one key is provided, additional keys are used as
1014 When more than one key is provided, additional keys are used as
1015 secondary criteria when the there is equality in all keys selected
1015 secondary criteria when the there is equality in all keys selected
1016 before them.
1016 before them.
1017
1017
1018 Abbreviations can be used for any key names, as long as the
1018 Abbreviations can be used for any key names, as long as the
1019 abbreviation is unambiguous. The following are the keys currently
1019 abbreviation is unambiguous. The following are the keys currently
1020 defined:
1020 defined:
1021
1021
1022 Valid Arg Meaning\\
1022 Valid Arg Meaning\\
1023 "calls" call count\\
1023 "calls" call count\\
1024 "cumulative" cumulative time\\
1024 "cumulative" cumulative time\\
1025 "file" file name\\
1025 "file" file name\\
1026 "module" file name\\
1026 "module" file name\\
1027 "pcalls" primitive call count\\
1027 "pcalls" primitive call count\\
1028 "line" line number\\
1028 "line" line number\\
1029 "name" function name\\
1029 "name" function name\\
1030 "nfl" name/file/line\\
1030 "nfl" name/file/line\\
1031 "stdname" standard name\\
1031 "stdname" standard name\\
1032 "time" internal time
1032 "time" internal time
1033
1033
1034 Note that all sorts on statistics are in descending order (placing
1034 Note that all sorts on statistics are in descending order (placing
1035 most time consuming items first), where as name, file, and line number
1035 most time consuming items first), where as name, file, and line number
1036 searches are in ascending order (i.e., alphabetical). The subtle
1036 searches are in ascending order (i.e., alphabetical). The subtle
1037 distinction between "nfl" and "stdname" is that the standard name is a
1037 distinction between "nfl" and "stdname" is that the standard name is a
1038 sort of the name as printed, which means that the embedded line
1038 sort of the name as printed, which means that the embedded line
1039 numbers get compared in an odd way. For example, lines 3, 20, and 40
1039 numbers get compared in an odd way. For example, lines 3, 20, and 40
1040 would (if the file names were the same) appear in the string order
1040 would (if the file names were the same) appear in the string order
1041 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1041 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1042 line numbers. In fact, sort_stats("nfl") is the same as
1042 line numbers. In fact, sort_stats("nfl") is the same as
1043 sort_stats("name", "file", "line").
1043 sort_stats("name", "file", "line").
1044
1044
1045 -T <filename>: save profile results as shown on screen to a text
1045 -T <filename>: save profile results as shown on screen to a text
1046 file. The profile is still shown on screen.
1046 file. The profile is still shown on screen.
1047
1047
1048 -D <filename>: save (via dump_stats) profile statistics to given
1048 -D <filename>: save (via dump_stats) profile statistics to given
1049 filename. This data is in a format understod by the pstats module, and
1049 filename. This data is in a format understod by the pstats module, and
1050 is generated by a call to the dump_stats() method of profile
1050 is generated by a call to the dump_stats() method of profile
1051 objects. The profile is still shown on screen.
1051 objects. The profile is still shown on screen.
1052
1052
1053 If you want to run complete programs under the profiler's control, use
1053 If you want to run complete programs under the profiler's control, use
1054 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1054 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1055 contains profiler specific options as described here.
1055 contains profiler specific options as described here.
1056
1056
1057 You can read the complete documentation for the profile module with:\\
1057 You can read the complete documentation for the profile module with:\\
1058 In [1]: import profile; profile.help() """
1058 In [1]: import profile; profile.help() """
1059
1059
1060 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1060 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1061 # protect user quote marks
1061 # protect user quote marks
1062 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1062 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1063
1063
1064 if user_mode: # regular user call
1064 if user_mode: # regular user call
1065 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1065 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1066 list_all=1)
1066 list_all=1)
1067 namespace = self.shell.user_ns
1067 namespace = self.shell.user_ns
1068 else: # called to run a program by %run -p
1068 else: # called to run a program by %run -p
1069 try:
1069 try:
1070 filename = get_py_filename(arg_lst[0])
1070 filename = get_py_filename(arg_lst[0])
1071 except IOError,msg:
1071 except IOError,msg:
1072 error(msg)
1072 error(msg)
1073 return
1073 return
1074
1074
1075 arg_str = 'execfile(filename,prog_ns)'
1075 arg_str = 'execfile(filename,prog_ns)'
1076 namespace = locals()
1076 namespace = locals()
1077
1077
1078 opts.merge(opts_def)
1078 opts.merge(opts_def)
1079
1079
1080 prof = profile.Profile()
1080 prof = profile.Profile()
1081 try:
1081 try:
1082 prof = prof.runctx(arg_str,namespace,namespace)
1082 prof = prof.runctx(arg_str,namespace,namespace)
1083 sys_exit = ''
1083 sys_exit = ''
1084 except SystemExit:
1084 except SystemExit:
1085 sys_exit = """*** SystemExit exception caught in code being profiled."""
1085 sys_exit = """*** SystemExit exception caught in code being profiled."""
1086
1086
1087 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1087 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1088
1088
1089 lims = opts.l
1089 lims = opts.l
1090 if lims:
1090 if lims:
1091 lims = [] # rebuild lims with ints/floats/strings
1091 lims = [] # rebuild lims with ints/floats/strings
1092 for lim in opts.l:
1092 for lim in opts.l:
1093 try:
1093 try:
1094 lims.append(int(lim))
1094 lims.append(int(lim))
1095 except ValueError:
1095 except ValueError:
1096 try:
1096 try:
1097 lims.append(float(lim))
1097 lims.append(float(lim))
1098 except ValueError:
1098 except ValueError:
1099 lims.append(lim)
1099 lims.append(lim)
1100
1100
1101 # trap output
1101 # trap output
1102 sys_stdout = sys.stdout
1102 sys_stdout = sys.stdout
1103 stdout_trap = StringIO()
1103 stdout_trap = StringIO()
1104 try:
1104 try:
1105 sys.stdout = stdout_trap
1105 sys.stdout = stdout_trap
1106 stats.print_stats(*lims)
1106 stats.print_stats(*lims)
1107 finally:
1107 finally:
1108 sys.stdout = sys_stdout
1108 sys.stdout = sys_stdout
1109 output = stdout_trap.getvalue()
1109 output = stdout_trap.getvalue()
1110 output = output.rstrip()
1110 output = output.rstrip()
1111
1111
1112 page(output,screen_lines=self.shell.rc.screen_length)
1112 page(output,screen_lines=self.shell.rc.screen_length)
1113 print sys_exit,
1113 print sys_exit,
1114
1114
1115 dump_file = opts.D[0]
1115 dump_file = opts.D[0]
1116 text_file = opts.T[0]
1116 text_file = opts.T[0]
1117 if dump_file:
1117 if dump_file:
1118 prof.dump_stats(dump_file)
1118 prof.dump_stats(dump_file)
1119 print '\n*** Profile stats marshalled to file',\
1119 print '\n*** Profile stats marshalled to file',\
1120 `dump_file`+'.',sys_exit
1120 `dump_file`+'.',sys_exit
1121 if text_file:
1121 if text_file:
1122 file(text_file,'w').write(output)
1122 file(text_file,'w').write(output)
1123 print '\n*** Profile printout saved to text file',\
1123 print '\n*** Profile printout saved to text file',\
1124 `text_file`+'.',sys_exit
1124 `text_file`+'.',sys_exit
1125
1125
1126 if opts.has_key('r'):
1126 if opts.has_key('r'):
1127 return stats
1127 return stats
1128 else:
1128 else:
1129 return None
1129 return None
1130
1130
1131 def magic_run(self, parameter_s ='',runner=None):
1131 def magic_run(self, parameter_s ='',runner=None):
1132 """Run the named file inside IPython as a program.
1132 """Run the named file inside IPython as a program.
1133
1133
1134 Usage:\\
1134 Usage:\\
1135 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1135 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1136
1136
1137 Parameters after the filename are passed as command-line arguments to
1137 Parameters after the filename are passed as command-line arguments to
1138 the program (put in sys.argv). Then, control returns to IPython's
1138 the program (put in sys.argv). Then, control returns to IPython's
1139 prompt.
1139 prompt.
1140
1140
1141 This is similar to running at a system prompt:\\
1141 This is similar to running at a system prompt:\\
1142 $ python file args\\
1142 $ python file args\\
1143 but with the advantage of giving you IPython's tracebacks, and of
1143 but with the advantage of giving you IPython's tracebacks, and of
1144 loading all variables into your interactive namespace for further use
1144 loading all variables into your interactive namespace for further use
1145 (unless -p is used, see below).
1145 (unless -p is used, see below).
1146
1146
1147 The file is executed in a namespace initially consisting only of
1147 The file is executed in a namespace initially consisting only of
1148 __name__=='__main__' and sys.argv constructed as indicated. It thus
1148 __name__=='__main__' and sys.argv constructed as indicated. It thus
1149 sees its environment as if it were being run as a stand-alone
1149 sees its environment as if it were being run as a stand-alone
1150 program. But after execution, the IPython interactive namespace gets
1150 program. But after execution, the IPython interactive namespace gets
1151 updated with all variables defined in the program (except for __name__
1151 updated with all variables defined in the program (except for __name__
1152 and sys.argv). This allows for very convenient loading of code for
1152 and sys.argv). This allows for very convenient loading of code for
1153 interactive work, while giving each program a 'clean sheet' to run in.
1153 interactive work, while giving each program a 'clean sheet' to run in.
1154
1154
1155 Options:
1155 Options:
1156
1156
1157 -n: __name__ is NOT set to '__main__', but to the running file's name
1157 -n: __name__ is NOT set to '__main__', but to the running file's name
1158 without extension (as python does under import). This allows running
1158 without extension (as python does under import). This allows running
1159 scripts and reloading the definitions in them without calling code
1159 scripts and reloading the definitions in them without calling code
1160 protected by an ' if __name__ == "__main__" ' clause.
1160 protected by an ' if __name__ == "__main__" ' clause.
1161
1161
1162 -i: run the file in IPython's namespace instead of an empty one. This
1162 -i: run the file in IPython's namespace instead of an empty one. This
1163 is useful if you are experimenting with code written in a text editor
1163 is useful if you are experimenting with code written in a text editor
1164 which depends on variables defined interactively.
1164 which depends on variables defined interactively.
1165
1165
1166 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1166 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1167 being run. This is particularly useful if IPython is being used to
1167 being run. This is particularly useful if IPython is being used to
1168 run unittests, which always exit with a sys.exit() call. In such
1168 run unittests, which always exit with a sys.exit() call. In such
1169 cases you are interested in the output of the test results, not in
1169 cases you are interested in the output of the test results, not in
1170 seeing a traceback of the unittest module.
1170 seeing a traceback of the unittest module.
1171
1171
1172 -t: print timing information at the end of the run. IPython will give
1172 -t: print timing information at the end of the run. IPython will give
1173 you an estimated CPU time consumption for your script, which under
1173 you an estimated CPU time consumption for your script, which under
1174 Unix uses the resource module to avoid the wraparound problems of
1174 Unix uses the resource module to avoid the wraparound problems of
1175 time.clock(). Under Unix, an estimate of time spent on system tasks
1175 time.clock(). Under Unix, an estimate of time spent on system tasks
1176 is also given (for Windows platforms this is reported as 0.0).
1176 is also given (for Windows platforms this is reported as 0.0).
1177
1177
1178 If -t is given, an additional -N<N> option can be given, where <N>
1178 If -t is given, an additional -N<N> option can be given, where <N>
1179 must be an integer indicating how many times you want the script to
1179 must be an integer indicating how many times you want the script to
1180 run. The final timing report will include total and per run results.
1180 run. The final timing report will include total and per run results.
1181
1181
1182 For example (testing the script uniq_stable.py):
1182 For example (testing the script uniq_stable.py):
1183
1183
1184 In [1]: run -t uniq_stable
1184 In [1]: run -t uniq_stable
1185
1185
1186 IPython CPU timings (estimated):\\
1186 IPython CPU timings (estimated):\\
1187 User : 0.19597 s.\\
1187 User : 0.19597 s.\\
1188 System: 0.0 s.\\
1188 System: 0.0 s.\\
1189
1189
1190 In [2]: run -t -N5 uniq_stable
1190 In [2]: run -t -N5 uniq_stable
1191
1191
1192 IPython CPU timings (estimated):\\
1192 IPython CPU timings (estimated):\\
1193 Total runs performed: 5\\
1193 Total runs performed: 5\\
1194 Times : Total Per run\\
1194 Times : Total Per run\\
1195 User : 0.910862 s, 0.1821724 s.\\
1195 User : 0.910862 s, 0.1821724 s.\\
1196 System: 0.0 s, 0.0 s.
1196 System: 0.0 s, 0.0 s.
1197
1197
1198 -d: run your program under the control of pdb, the Python debugger.
1198 -d: run your program under the control of pdb, the Python debugger.
1199 This allows you to execute your program step by step, watch variables,
1199 This allows you to execute your program step by step, watch variables,
1200 etc. Internally, what IPython does is similar to calling:
1200 etc. Internally, what IPython does is similar to calling:
1201
1201
1202 pdb.run('execfile("YOURFILENAME")')
1202 pdb.run('execfile("YOURFILENAME")')
1203
1203
1204 with a breakpoint set on line 1 of your file. You can change the line
1204 with a breakpoint set on line 1 of your file. You can change the line
1205 number for this automatic breakpoint to be <N> by using the -bN option
1205 number for this automatic breakpoint to be <N> by using the -bN option
1206 (where N must be an integer). For example:
1206 (where N must be an integer). For example:
1207
1207
1208 %run -d -b40 myscript
1208 %run -d -b40 myscript
1209
1209
1210 will set the first breakpoint at line 40 in myscript.py. Note that
1210 will set the first breakpoint at line 40 in myscript.py. Note that
1211 the first breakpoint must be set on a line which actually does
1211 the first breakpoint must be set on a line which actually does
1212 something (not a comment or docstring) for it to stop execution.
1212 something (not a comment or docstring) for it to stop execution.
1213
1213
1214 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1214 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1215 first enter 'c' (without qoutes) to start execution up to the first
1215 first enter 'c' (without qoutes) to start execution up to the first
1216 breakpoint.
1216 breakpoint.
1217
1217
1218 Entering 'help' gives information about the use of the debugger. You
1218 Entering 'help' gives information about the use of the debugger. You
1219 can easily see pdb's full documentation with "import pdb;pdb.help()"
1219 can easily see pdb's full documentation with "import pdb;pdb.help()"
1220 at a prompt.
1220 at a prompt.
1221
1221
1222 -p: run program under the control of the Python profiler module (which
1222 -p: run program under the control of the Python profiler module (which
1223 prints a detailed report of execution times, function calls, etc).
1223 prints a detailed report of execution times, function calls, etc).
1224
1224
1225 You can pass other options after -p which affect the behavior of the
1225 You can pass other options after -p which affect the behavior of the
1226 profiler itself. See the docs for %prun for details.
1226 profiler itself. See the docs for %prun for details.
1227
1227
1228 In this mode, the program's variables do NOT propagate back to the
1228 In this mode, the program's variables do NOT propagate back to the
1229 IPython interactive namespace (because they remain in the namespace
1229 IPython interactive namespace (because they remain in the namespace
1230 where the profiler executes them).
1230 where the profiler executes them).
1231
1231
1232 Internally this triggers a call to %prun, see its documentation for
1232 Internally this triggers a call to %prun, see its documentation for
1233 details on the options available specifically for profiling."""
1233 details on the options available specifically for profiling."""
1234
1234
1235 # get arguments and set sys.argv for program to be run.
1235 # get arguments and set sys.argv for program to be run.
1236 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1236 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1237 mode='list',list_all=1)
1237 mode='list',list_all=1)
1238
1238
1239 try:
1239 try:
1240 filename = get_py_filename(arg_lst[0])
1240 filename = get_py_filename(arg_lst[0])
1241 except IndexError:
1241 except IndexError:
1242 warn('you must provide at least a filename.')
1242 warn('you must provide at least a filename.')
1243 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1243 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1244 return
1244 return
1245 except IOError,msg:
1245 except IOError,msg:
1246 error(msg)
1246 error(msg)
1247 return
1247 return
1248
1248
1249 # Control the response to exit() calls made by the script being run
1249 # Control the response to exit() calls made by the script being run
1250 exit_ignore = opts.has_key('e')
1250 exit_ignore = opts.has_key('e')
1251
1251
1252 # Make sure that the running script gets a proper sys.argv as if it
1252 # Make sure that the running script gets a proper sys.argv as if it
1253 # were run from a system shell.
1253 # were run from a system shell.
1254 save_argv = sys.argv # save it for later restoring
1254 save_argv = sys.argv # save it for later restoring
1255 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1255 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1256
1256
1257 if opts.has_key('i'):
1257 if opts.has_key('i'):
1258 prog_ns = self.shell.user_ns
1258 prog_ns = self.shell.user_ns
1259 __name__save = self.shell.user_ns['__name__']
1259 __name__save = self.shell.user_ns['__name__']
1260 prog_ns['__name__'] = '__main__'
1260 prog_ns['__name__'] = '__main__'
1261 else:
1261 else:
1262 if opts.has_key('n'):
1262 if opts.has_key('n'):
1263 name = os.path.splitext(os.path.basename(filename))[0]
1263 name = os.path.splitext(os.path.basename(filename))[0]
1264 else:
1264 else:
1265 name = '__main__'
1265 name = '__main__'
1266 prog_ns = {'__name__':name}
1266 prog_ns = {'__name__':name}
1267
1267
1268 # pickle fix. See iplib for an explanation
1268 # pickle fix. See iplib for an explanation
1269 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1269 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1270
1270
1271 stats = None
1271 stats = None
1272 try:
1272 try:
1273 if opts.has_key('p'):
1273 if opts.has_key('p'):
1274 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1274 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1275 else:
1275 else:
1276 if opts.has_key('d'):
1276 if opts.has_key('d'):
1277 deb = pdb.Pdb()
1277 deb = pdb.Pdb()
1278 # reset Breakpoint state, which is moronically kept
1278 # reset Breakpoint state, which is moronically kept
1279 # in a class
1279 # in a class
1280 bdb.Breakpoint.next = 1
1280 bdb.Breakpoint.next = 1
1281 bdb.Breakpoint.bplist = {}
1281 bdb.Breakpoint.bplist = {}
1282 bdb.Breakpoint.bpbynumber = [None]
1282 bdb.Breakpoint.bpbynumber = [None]
1283 # Set an initial breakpoint to stop execution
1283 # Set an initial breakpoint to stop execution
1284 maxtries = 10
1284 maxtries = 10
1285 bp = int(opts.get('b',[1])[0])
1285 bp = int(opts.get('b',[1])[0])
1286 checkline = deb.checkline(filename,bp)
1286 checkline = deb.checkline(filename,bp)
1287 if not checkline:
1287 if not checkline:
1288 for bp in range(bp+1,bp+maxtries+1):
1288 for bp in range(bp+1,bp+maxtries+1):
1289 if deb.checkline(filename,bp):
1289 if deb.checkline(filename,bp):
1290 break
1290 break
1291 else:
1291 else:
1292 msg = ("\nI failed to find a valid line to set "
1292 msg = ("\nI failed to find a valid line to set "
1293 "a breakpoint\n"
1293 "a breakpoint\n"
1294 "after trying up to line: %s.\n"
1294 "after trying up to line: %s.\n"
1295 "Please set a valid breakpoint manually "
1295 "Please set a valid breakpoint manually "
1296 "with the -b option." % bp)
1296 "with the -b option." % bp)
1297 error(msg)
1297 error(msg)
1298 return
1298 return
1299 # if we find a good linenumber, set the breakpoint
1299 # if we find a good linenumber, set the breakpoint
1300 deb.do_break('%s:%s' % (filename,bp))
1300 deb.do_break('%s:%s' % (filename,bp))
1301 # Start file run
1301 # Start file run
1302 print "NOTE: Enter 'c' at the",
1302 print "NOTE: Enter 'c' at the",
1303 print "(Pdb) prompt to start your script."
1303 print "(Pdb) prompt to start your script."
1304 deb.run('execfile("%s")' % filename,prog_ns)
1304 deb.run('execfile("%s")' % filename,prog_ns)
1305 else:
1305 else:
1306 if runner is None:
1306 if runner is None:
1307 runner = self.shell.safe_execfile
1307 runner = self.shell.safe_execfile
1308 if opts.has_key('t'):
1308 if opts.has_key('t'):
1309 try:
1309 try:
1310 nruns = int(opts['N'][0])
1310 nruns = int(opts['N'][0])
1311 if nruns < 1:
1311 if nruns < 1:
1312 error('Number of runs must be >=1')
1312 error('Number of runs must be >=1')
1313 return
1313 return
1314 except (KeyError):
1314 except (KeyError):
1315 nruns = 1
1315 nruns = 1
1316 if nruns == 1:
1316 if nruns == 1:
1317 t0 = clock2()
1317 t0 = clock2()
1318 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1318 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1319 t1 = clock2()
1319 t1 = clock2()
1320 t_usr = t1[0]-t0[0]
1320 t_usr = t1[0]-t0[0]
1321 t_sys = t1[1]-t1[1]
1321 t_sys = t1[1]-t1[1]
1322 print "\nIPython CPU timings (estimated):"
1322 print "\nIPython CPU timings (estimated):"
1323 print " User : %10s s." % t_usr
1323 print " User : %10s s." % t_usr
1324 print " System: %10s s." % t_sys
1324 print " System: %10s s." % t_sys
1325 else:
1325 else:
1326 runs = range(nruns)
1326 runs = range(nruns)
1327 t0 = clock2()
1327 t0 = clock2()
1328 for nr in runs:
1328 for nr in runs:
1329 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1329 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1330 t1 = clock2()
1330 t1 = clock2()
1331 t_usr = t1[0]-t0[0]
1331 t_usr = t1[0]-t0[0]
1332 t_sys = t1[1]-t1[1]
1332 t_sys = t1[1]-t1[1]
1333 print "\nIPython CPU timings (estimated):"
1333 print "\nIPython CPU timings (estimated):"
1334 print "Total runs performed:",nruns
1334 print "Total runs performed:",nruns
1335 print " Times : %10s %10s" % ('Total','Per run')
1335 print " Times : %10s %10s" % ('Total','Per run')
1336 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1336 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1337 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1337 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1338
1338
1339 else:
1339 else:
1340 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1340 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1341 if opts.has_key('i'):
1341 if opts.has_key('i'):
1342 self.shell.user_ns['__name__'] = __name__save
1342 self.shell.user_ns['__name__'] = __name__save
1343 else:
1343 else:
1344 # update IPython interactive namespace
1344 # update IPython interactive namespace
1345 del prog_ns['__name__']
1345 del prog_ns['__name__']
1346 self.shell.user_ns.update(prog_ns)
1346 self.shell.user_ns.update(prog_ns)
1347 finally:
1347 finally:
1348 sys.argv = save_argv
1348 sys.argv = save_argv
1349 return stats
1349 return stats
1350
1350
1351 def magic_runlog(self, parameter_s =''):
1351 def magic_runlog(self, parameter_s =''):
1352 """Run files as logs.
1352 """Run files as logs.
1353
1353
1354 Usage:\\
1354 Usage:\\
1355 %runlog file1 file2 ...
1355 %runlog file1 file2 ...
1356
1356
1357 Run the named files (treating them as log files) in sequence inside
1357 Run the named files (treating them as log files) in sequence inside
1358 the interpreter, and return to the prompt. This is much slower than
1358 the interpreter, and return to the prompt. This is much slower than
1359 %run because each line is executed in a try/except block, but it
1359 %run because each line is executed in a try/except block, but it
1360 allows running files with syntax errors in them.
1360 allows running files with syntax errors in them.
1361
1361
1362 Normally IPython will guess when a file is one of its own logfiles, so
1362 Normally IPython will guess when a file is one of its own logfiles, so
1363 you can typically use %run even for logs. This shorthand allows you to
1363 you can typically use %run even for logs. This shorthand allows you to
1364 force any file to be treated as a log file."""
1364 force any file to be treated as a log file."""
1365
1365
1366 for f in parameter_s.split():
1366 for f in parameter_s.split():
1367 self.shell.safe_execfile(f,self.shell.user_ns,
1367 self.shell.safe_execfile(f,self.shell.user_ns,
1368 self.shell.user_ns,islog=1)
1368 self.shell.user_ns,islog=1)
1369
1369
1370 def magic_time(self,parameter_s = ''):
1370 def magic_time(self,parameter_s = ''):
1371 """Time execution of a Python statement or expression.
1371 """Time execution of a Python statement or expression.
1372
1372
1373 The CPU and wall clock times are printed, and the value of the
1373 The CPU and wall clock times are printed, and the value of the
1374 expression (if any) is returned. Note that under Win32, system time
1374 expression (if any) is returned. Note that under Win32, system time
1375 is always reported as 0, since it can not be measured.
1375 is always reported as 0, since it can not be measured.
1376
1376
1377 This function provides very basic timing functionality. In Python
1377 This function provides very basic timing functionality. In Python
1378 2.3, the timeit module offers more control and sophistication, but for
1378 2.3, the timeit module offers more control and sophistication, but for
1379 now IPython supports Python 2.2, so we can not rely on timeit being
1379 now IPython supports Python 2.2, so we can not rely on timeit being
1380 present.
1380 present.
1381
1381
1382 Some examples:
1382 Some examples:
1383
1383
1384 In [1]: time 2**128
1384 In [1]: time 2**128
1385 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1385 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1386 Wall time: 0.00
1386 Wall time: 0.00
1387 Out[1]: 340282366920938463463374607431768211456L
1387 Out[1]: 340282366920938463463374607431768211456L
1388
1388
1389 In [2]: n = 1000000
1389 In [2]: n = 1000000
1390
1390
1391 In [3]: time sum(range(n))
1391 In [3]: time sum(range(n))
1392 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1392 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1393 Wall time: 1.37
1393 Wall time: 1.37
1394 Out[3]: 499999500000L
1394 Out[3]: 499999500000L
1395
1395
1396 In [4]: time print 'hello world'
1396 In [4]: time print 'hello world'
1397 hello world
1397 hello world
1398 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1398 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1399 Wall time: 0.00
1399 Wall time: 0.00
1400 """
1400 """
1401
1401
1402 # fail immediately if the given expression can't be compiled
1402 # fail immediately if the given expression can't be compiled
1403 try:
1403 try:
1404 mode = 'eval'
1404 mode = 'eval'
1405 code = compile(parameter_s,'<timed eval>',mode)
1405 code = compile(parameter_s,'<timed eval>',mode)
1406 except SyntaxError:
1406 except SyntaxError:
1407 mode = 'exec'
1407 mode = 'exec'
1408 code = compile(parameter_s,'<timed exec>',mode)
1408 code = compile(parameter_s,'<timed exec>',mode)
1409 # skew measurement as little as possible
1409 # skew measurement as little as possible
1410 glob = self.shell.user_ns
1410 glob = self.shell.user_ns
1411 clk = clock2
1411 clk = clock2
1412 wtime = time.time
1412 wtime = time.time
1413 # time execution
1413 # time execution
1414 wall_st = wtime()
1414 wall_st = wtime()
1415 if mode=='eval':
1415 if mode=='eval':
1416 st = clk()
1416 st = clk()
1417 out = eval(code,glob)
1417 out = eval(code,glob)
1418 end = clk()
1418 end = clk()
1419 else:
1419 else:
1420 st = clk()
1420 st = clk()
1421 exec code in glob
1421 exec code in glob
1422 end = clk()
1422 end = clk()
1423 out = None
1423 out = None
1424 wall_end = wtime()
1424 wall_end = wtime()
1425 # Compute actual times and report
1425 # Compute actual times and report
1426 wall_time = wall_end-wall_st
1426 wall_time = wall_end-wall_st
1427 cpu_user = end[0]-st[0]
1427 cpu_user = end[0]-st[0]
1428 cpu_sys = end[1]-st[1]
1428 cpu_sys = end[1]-st[1]
1429 cpu_tot = cpu_user+cpu_sys
1429 cpu_tot = cpu_user+cpu_sys
1430 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1430 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1431 (cpu_user,cpu_sys,cpu_tot)
1431 (cpu_user,cpu_sys,cpu_tot)
1432 print "Wall time: %.2f" % wall_time
1432 print "Wall time: %.2f" % wall_time
1433 return out
1433 return out
1434
1434
1435 def magic_macro(self,parameter_s = ''):
1435 def magic_macro(self,parameter_s = ''):
1436 """Define a set of input lines as a macro for future re-execution.
1436 """Define a set of input lines as a macro for future re-execution.
1437
1437
1438 Usage:\\
1438 Usage:\\
1439 %macro name n1:n2 n3:n4 ... n5 .. n6 ...
1439 %macro name n1:n2 n3:n4 ... n5 .. n6 ...
1440
1440
1441 This will define a global variable called `name` which is a string
1441 This will define a global variable called `name` which is a string
1442 made of joining the slices and lines you specify (n1,n2,... numbers
1442 made of joining the slices and lines you specify (n1,n2,... numbers
1443 above) from your input history into a single string. This variable
1443 above) from your input history into a single string. This variable
1444 acts like an automatic function which re-executes those lines as if
1444 acts like an automatic function which re-executes those lines as if
1445 you had typed them. You just type 'name' at the prompt and the code
1445 you had typed them. You just type 'name' at the prompt and the code
1446 executes.
1446 executes.
1447
1447
1448 Note that the slices use the standard Python slicing notation (5:8
1448 Note that the slices use the standard Python slicing notation (5:8
1449 means include lines numbered 5,6,7).
1449 means include lines numbered 5,6,7).
1450
1450
1451 For example, if your history contains (%hist prints it):
1451 For example, if your history contains (%hist prints it):
1452
1452
1453 44: x=1\\
1453 44: x=1\\
1454 45: y=3\\
1454 45: y=3\\
1455 46: z=x+y\\
1455 46: z=x+y\\
1456 47: print x\\
1456 47: print x\\
1457 48: a=5\\
1457 48: a=5\\
1458 49: print 'x',x,'y',y\\
1458 49: print 'x',x,'y',y\\
1459
1459
1460 you can create a macro with lines 44 through 47 (included) and line 49
1460 you can create a macro with lines 44 through 47 (included) and line 49
1461 called my_macro with:
1461 called my_macro with:
1462
1462
1463 In [51]: %macro my_macro 44:48 49
1463 In [51]: %macro my_macro 44:48 49
1464
1464
1465 Now, typing `my_macro` (without quotes) will re-execute all this code
1465 Now, typing `my_macro` (without quotes) will re-execute all this code
1466 in one pass.
1466 in one pass.
1467
1467
1468 You don't need to give the line-numbers in order, and any given line
1468 You don't need to give the line-numbers in order, and any given line
1469 number can appear multiple times. You can assemble macros with any
1469 number can appear multiple times. You can assemble macros with any
1470 lines from your input history in any order.
1470 lines from your input history in any order.
1471
1471
1472 The macro is a simple object which holds its value in an attribute,
1472 The macro is a simple object which holds its value in an attribute,
1473 but IPython's display system checks for macros and executes them as
1473 but IPython's display system checks for macros and executes them as
1474 code instead of printing them when you type their name.
1474 code instead of printing them when you type their name.
1475
1475
1476 You can view a macro's contents by explicitly printing it with:
1476 You can view a macro's contents by explicitly printing it with:
1477
1477
1478 'print macro_name'.
1478 'print macro_name'.
1479
1479
1480 For one-off cases which DON'T contain magic function calls in them you
1480 For one-off cases which DON'T contain magic function calls in them you
1481 can obtain similar results by explicitly executing slices from your
1481 can obtain similar results by explicitly executing slices from your
1482 input history with:
1482 input history with:
1483
1483
1484 In [60]: exec In[44:48]+In[49]"""
1484 In [60]: exec In[44:48]+In[49]"""
1485
1485
1486 args = parameter_s.split()
1486 args = parameter_s.split()
1487 name,ranges = args[0], args[1:]
1487 name,ranges = args[0], args[1:]
1488 #print 'rng',ranges # dbg
1488 #print 'rng',ranges # dbg
1489 cmds = self.extract_input_slices(ranges)
1489 cmds = self.extract_input_slices(ranges)
1490 macro = Macro(cmds)
1490 macro = Macro(cmds)
1491 self.shell.user_ns.update({name:macro})
1491 self.shell.user_ns.update({name:macro})
1492 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1492 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1493 print 'Macro contents:'
1493 print 'Macro contents:'
1494 print str(macro).rstrip(),
1494 print str(macro).rstrip(),
1495
1495
1496 def magic_save(self,parameter_s = ''):
1496 def magic_save(self,parameter_s = ''):
1497 """Save a set of lines to a given filename.
1497 """Save a set of lines to a given filename.
1498
1498
1499 Usage:\\
1499 Usage:\\
1500 %save filename n1:n2 n3:n4 ... n5 .. n6 ...
1500 %save filename n1:n2 n3:n4 ... n5 .. n6 ...
1501
1501
1502 This function uses the same syntax as %macro for line extraction, but
1502 This function uses the same syntax as %macro for line extraction, but
1503 instead of creating a macro it saves the resulting string to the
1503 instead of creating a macro it saves the resulting string to the
1504 filename you specify.
1504 filename you specify.
1505
1505
1506 It adds a '.py' extension to the file if you don't do so yourself, and
1506 It adds a '.py' extension to the file if you don't do so yourself, and
1507 it asks for confirmation before overwriting existing files."""
1507 it asks for confirmation before overwriting existing files."""
1508
1508
1509 args = parameter_s.split()
1509 args = parameter_s.split()
1510 fname,ranges = args[0], args[1:]
1510 fname,ranges = args[0], args[1:]
1511 if not fname.endswith('.py'):
1511 if not fname.endswith('.py'):
1512 fname += '.py'
1512 fname += '.py'
1513 if os.path.isfile(fname):
1513 if os.path.isfile(fname):
1514 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1514 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1515 if ans.lower() not in ['y','yes']:
1515 if ans.lower() not in ['y','yes']:
1516 print 'Operation cancelled.'
1516 print 'Operation cancelled.'
1517 return
1517 return
1518 cmds = ''.join(self.extract_input_slices(ranges))
1518 cmds = ''.join(self.extract_input_slices(ranges))
1519 f = file(fname,'w')
1519 f = file(fname,'w')
1520 f.write(cmds)
1520 f.write(cmds)
1521 f.close()
1521 f.close()
1522 print 'The following commands were written to file `%s`:' % fname
1522 print 'The following commands were written to file `%s`:' % fname
1523 print cmds
1523 print cmds
1524
1524
1525 def magic_ed(self,parameter_s = ''):
1525 def magic_ed(self,parameter_s = ''):
1526 """Alias to %edit."""
1526 """Alias to %edit."""
1527 return self.magic_edit(parameter_s)
1527 return self.magic_edit(parameter_s)
1528
1528
1529 def magic_edit(self,parameter_s = '',last_call=['','']):
1529 def magic_edit(self,parameter_s = '',last_call=['','']):
1530 """Bring up an editor and execute the resulting code.
1530 """Bring up an editor and execute the resulting code.
1531
1531
1532 Usage:
1532 Usage:
1533 %edit [options] [args]
1533 %edit [options] [args]
1534
1534
1535 %edit runs IPython's editor hook. The default version of this hook is
1535 %edit runs IPython's editor hook. The default version of this hook is
1536 set to call the __IPYTHON__.rc.editor command. This is read from your
1536 set to call the __IPYTHON__.rc.editor command. This is read from your
1537 environment variable $EDITOR. If this isn't found, it will default to
1537 environment variable $EDITOR. If this isn't found, it will default to
1538 vi under Linux/Unix and to notepad under Windows. See the end of this
1538 vi under Linux/Unix and to notepad under Windows. See the end of this
1539 docstring for how to change the editor hook.
1539 docstring for how to change the editor hook.
1540
1540
1541 You can also set the value of this editor via the command line option
1541 You can also set the value of this editor via the command line option
1542 '-editor' or in your ipythonrc file. This is useful if you wish to use
1542 '-editor' or in your ipythonrc file. This is useful if you wish to use
1543 specifically for IPython an editor different from your typical default
1543 specifically for IPython an editor different from your typical default
1544 (and for Windows users who typically don't set environment variables).
1544 (and for Windows users who typically don't set environment variables).
1545
1545
1546 This command allows you to conveniently edit multi-line code right in
1546 This command allows you to conveniently edit multi-line code right in
1547 your IPython session.
1547 your IPython session.
1548
1548
1549 If called without arguments, %edit opens up an empty editor with a
1549 If called without arguments, %edit opens up an empty editor with a
1550 temporary file and will execute the contents of this file when you
1550 temporary file and will execute the contents of this file when you
1551 close it (don't forget to save it!).
1551 close it (don't forget to save it!).
1552
1552
1553 Options:
1553 Options:
1554
1554
1555 -p: this will call the editor with the same data as the previous time
1555 -p: this will call the editor with the same data as the previous time
1556 it was used, regardless of how long ago (in your current session) it
1556 it was used, regardless of how long ago (in your current session) it
1557 was.
1557 was.
1558
1558
1559 -x: do not execute the edited code immediately upon exit. This is
1559 -x: do not execute the edited code immediately upon exit. This is
1560 mainly useful if you are editing programs which need to be called with
1560 mainly useful if you are editing programs which need to be called with
1561 command line arguments, which you can then do using %run.
1561 command line arguments, which you can then do using %run.
1562
1562
1563 Arguments:
1563 Arguments:
1564
1564
1565 If arguments are given, the following possibilites exist:
1565 If arguments are given, the following possibilites exist:
1566
1566
1567 - The arguments are numbers or pairs of colon-separated numbers (like
1567 - The arguments are numbers or pairs of colon-separated numbers (like
1568 1 4:8 9). These are interpreted as lines of previous input to be
1568 1 4:8 9). These are interpreted as lines of previous input to be
1569 loaded into the editor. The syntax is the same of the %macro command.
1569 loaded into the editor. The syntax is the same of the %macro command.
1570
1570
1571 - If the argument doesn't start with a number, it is evaluated as a
1571 - If the argument doesn't start with a number, it is evaluated as a
1572 variable and its contents loaded into the editor. You can thus edit
1572 variable and its contents loaded into the editor. You can thus edit
1573 any string which contains python code (including the result of
1573 any string which contains python code (including the result of
1574 previous edits).
1574 previous edits).
1575
1575
1576 - If the argument is the name of an object (other than a string),
1576 - If the argument is the name of an object (other than a string),
1577 IPython will try to locate the file where it was defined and open the
1577 IPython will try to locate the file where it was defined and open the
1578 editor at the point where it is defined. You can use `%edit function`
1578 editor at the point where it is defined. You can use `%edit function`
1579 to load an editor exactly at the point where 'function' is defined,
1579 to load an editor exactly at the point where 'function' is defined,
1580 edit it and have the file be executed automatically.
1580 edit it and have the file be executed automatically.
1581
1581
1582 Note: opening at an exact line is only supported under Unix, and some
1582 Note: opening at an exact line is only supported under Unix, and some
1583 editors (like kedit and gedit up to Gnome 2.8) do not understand the
1583 editors (like kedit and gedit up to Gnome 2.8) do not understand the
1584 '+NUMBER' parameter necessary for this feature. Good editors like
1584 '+NUMBER' parameter necessary for this feature. Good editors like
1585 (X)Emacs, vi, jed, pico and joe all do.
1585 (X)Emacs, vi, jed, pico and joe all do.
1586
1586
1587 - If the argument is not found as a variable, IPython will look for a
1587 - If the argument is not found as a variable, IPython will look for a
1588 file with that name (adding .py if necessary) and load it into the
1588 file with that name (adding .py if necessary) and load it into the
1589 editor. It will execute its contents with execfile() when you exit,
1589 editor. It will execute its contents with execfile() when you exit,
1590 loading any code in the file into your interactive namespace.
1590 loading any code in the file into your interactive namespace.
1591
1591
1592 After executing your code, %edit will return as output the code you
1592 After executing your code, %edit will return as output the code you
1593 typed in the editor (except when it was an existing file). This way
1593 typed in the editor (except when it was an existing file). This way
1594 you can reload the code in further invocations of %edit as a variable,
1594 you can reload the code in further invocations of %edit as a variable,
1595 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
1595 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
1596 the output.
1596 the output.
1597
1597
1598 Note that %edit is also available through the alias %ed.
1598 Note that %edit is also available through the alias %ed.
1599
1599
1600 This is an example of creating a simple function inside the editor and
1600 This is an example of creating a simple function inside the editor and
1601 then modifying it. First, start up the editor:
1601 then modifying it. First, start up the editor:
1602
1602
1603 In [1]: ed\\
1603 In [1]: ed\\
1604 Editing... done. Executing edited code...\\
1604 Editing... done. Executing edited code...\\
1605 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
1605 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
1606
1606
1607 We can then call the function foo():
1607 We can then call the function foo():
1608
1608
1609 In [2]: foo()\\
1609 In [2]: foo()\\
1610 foo() was defined in an editing session
1610 foo() was defined in an editing session
1611
1611
1612 Now we edit foo. IPython automatically loads the editor with the
1612 Now we edit foo. IPython automatically loads the editor with the
1613 (temporary) file where foo() was previously defined:
1613 (temporary) file where foo() was previously defined:
1614
1614
1615 In [3]: ed foo\\
1615 In [3]: ed foo\\
1616 Editing... done. Executing edited code...
1616 Editing... done. Executing edited code...
1617
1617
1618 And if we call foo() again we get the modified version:
1618 And if we call foo() again we get the modified version:
1619
1619
1620 In [4]: foo()\\
1620 In [4]: foo()\\
1621 foo() has now been changed!
1621 foo() has now been changed!
1622
1622
1623 Here is an example of how to edit a code snippet successive
1623 Here is an example of how to edit a code snippet successive
1624 times. First we call the editor:
1624 times. First we call the editor:
1625
1625
1626 In [8]: ed\\
1626 In [8]: ed\\
1627 Editing... done. Executing edited code...\\
1627 Editing... done. Executing edited code...\\
1628 hello\\
1628 hello\\
1629 Out[8]: "print 'hello'\\n"
1629 Out[8]: "print 'hello'\\n"
1630
1630
1631 Now we call it again with the previous output (stored in _):
1631 Now we call it again with the previous output (stored in _):
1632
1632
1633 In [9]: ed _\\
1633 In [9]: ed _\\
1634 Editing... done. Executing edited code...\\
1634 Editing... done. Executing edited code...\\
1635 hello world\\
1635 hello world\\
1636 Out[9]: "print 'hello world'\\n"
1636 Out[9]: "print 'hello world'\\n"
1637
1637
1638 Now we call it with the output #8 (stored in _8, also as Out[8]):
1638 Now we call it with the output #8 (stored in _8, also as Out[8]):
1639
1639
1640 In [10]: ed _8\\
1640 In [10]: ed _8\\
1641 Editing... done. Executing edited code...\\
1641 Editing... done. Executing edited code...\\
1642 hello again\\
1642 hello again\\
1643 Out[10]: "print 'hello again'\\n"
1643 Out[10]: "print 'hello again'\\n"
1644
1644
1645
1645
1646 Changing the default editor hook:
1646 Changing the default editor hook:
1647
1647
1648 If you wish to write your own editor hook, you can put it in a
1648 If you wish to write your own editor hook, you can put it in a
1649 configuration file which you load at startup time. The default hook
1649 configuration file which you load at startup time. The default hook
1650 is defined in the IPython.hooks module, and you can use that as a
1650 is defined in the IPython.hooks module, and you can use that as a
1651 starting example for further modifications. That file also has
1651 starting example for further modifications. That file also has
1652 general instructions on how to set a new hook for use once you've
1652 general instructions on how to set a new hook for use once you've
1653 defined it."""
1653 defined it."""
1654
1654
1655 # FIXME: This function has become a convoluted mess. It needs a
1655 # FIXME: This function has become a convoluted mess. It needs a
1656 # ground-up rewrite with clean, simple logic.
1656 # ground-up rewrite with clean, simple logic.
1657
1657
1658 def make_filename(arg):
1658 def make_filename(arg):
1659 "Make a filename from the given args"
1659 "Make a filename from the given args"
1660 try:
1660 try:
1661 filename = get_py_filename(arg)
1661 filename = get_py_filename(arg)
1662 except IOError:
1662 except IOError:
1663 if args.endswith('.py'):
1663 if args.endswith('.py'):
1664 filename = arg
1664 filename = arg
1665 else:
1665 else:
1666 filename = None
1666 filename = None
1667 return filename
1667 return filename
1668
1668
1669 # custom exceptions
1669 # custom exceptions
1670 class DataIsObject(Exception): pass
1670 class DataIsObject(Exception): pass
1671
1671
1672 opts,args = self.parse_options(parameter_s,'px')
1672 opts,args = self.parse_options(parameter_s,'px')
1673
1673
1674 # Default line number value
1674 # Default line number value
1675 lineno = None
1675 lineno = None
1676 if opts.has_key('p'):
1676 if opts.has_key('p'):
1677 args = '_%s' % last_call[0]
1677 args = '_%s' % last_call[0]
1678 if not self.shell.user_ns.has_key(args):
1678 if not self.shell.user_ns.has_key(args):
1679 args = last_call[1]
1679 args = last_call[1]
1680
1680
1681 # use last_call to remember the state of the previous call, but don't
1681 # use last_call to remember the state of the previous call, but don't
1682 # let it be clobbered by successive '-p' calls.
1682 # let it be clobbered by successive '-p' calls.
1683 try:
1683 try:
1684 last_call[0] = self.shell.outputcache.prompt_count
1684 last_call[0] = self.shell.outputcache.prompt_count
1685 if not opts.has_key('p'):
1685 if not opts.has_key('p'):
1686 last_call[1] = parameter_s
1686 last_call[1] = parameter_s
1687 except:
1687 except:
1688 pass
1688 pass
1689
1689
1690 # by default this is done with temp files, except when the given
1690 # by default this is done with temp files, except when the given
1691 # arg is a filename
1691 # arg is a filename
1692 use_temp = 1
1692 use_temp = 1
1693
1693
1694 if re.match(r'\d',args):
1694 if re.match(r'\d',args):
1695 # Mode where user specifies ranges of lines, like in %macro.
1695 # Mode where user specifies ranges of lines, like in %macro.
1696 # This means that you can't edit files whose names begin with
1696 # This means that you can't edit files whose names begin with
1697 # numbers this way. Tough.
1697 # numbers this way. Tough.
1698 ranges = args.split()
1698 ranges = args.split()
1699 data = ''.join(self.extract_input_slices(ranges))
1699 data = ''.join(self.extract_input_slices(ranges))
1700 elif args.endswith('.py'):
1700 elif args.endswith('.py'):
1701 filename = make_filename(args)
1701 filename = make_filename(args)
1702 data = ''
1702 data = ''
1703 use_temp = 0
1703 use_temp = 0
1704 elif args:
1704 elif args:
1705 try:
1705 try:
1706 # Load the parameter given as a variable. If not a string,
1706 # Load the parameter given as a variable. If not a string,
1707 # process it as an object instead (below)
1707 # process it as an object instead (below)
1708
1708
1709 #print '*** args',args,'type',type(args) # dbg
1709 #print '*** args',args,'type',type(args) # dbg
1710 data = eval(args,self.shell.user_ns)
1710 data = eval(args,self.shell.user_ns)
1711 if not type(data) in StringTypes:
1711 if not type(data) in StringTypes:
1712 raise DataIsObject
1712 raise DataIsObject
1713 except (NameError,SyntaxError):
1713 except (NameError,SyntaxError):
1714 # given argument is not a variable, try as a filename
1714 # given argument is not a variable, try as a filename
1715 filename = make_filename(args)
1715 filename = make_filename(args)
1716 if filename is None:
1716 if filename is None:
1717 warn("Argument given (%s) can't be found as a variable "
1717 warn("Argument given (%s) can't be found as a variable "
1718 "or as a filename." % args)
1718 "or as a filename." % args)
1719 return
1719 return
1720 data = ''
1720 data = ''
1721 use_temp = 0
1721 use_temp = 0
1722 except DataIsObject:
1722 except DataIsObject:
1723 # For objects, try to edit the file where they are defined
1723 # For objects, try to edit the file where they are defined
1724 try:
1724 try:
1725 filename = inspect.getabsfile(data)
1725 filename = inspect.getabsfile(data)
1726 datafile = 1
1726 datafile = 1
1727 except TypeError:
1727 except TypeError:
1728 filename = make_filename(args)
1728 filename = make_filename(args)
1729 datafile = 1
1729 datafile = 1
1730 warn('Could not find file where `%s` is defined.\n'
1730 warn('Could not find file where `%s` is defined.\n'
1731 'Opening a file named `%s`' % (args,filename))
1731 'Opening a file named `%s`' % (args,filename))
1732 # Now, make sure we can actually read the source (if it was in
1732 # Now, make sure we can actually read the source (if it was in
1733 # a temp file it's gone by now).
1733 # a temp file it's gone by now).
1734 if datafile:
1734 if datafile:
1735 try:
1735 try:
1736 lineno = inspect.getsourcelines(data)[1]
1736 lineno = inspect.getsourcelines(data)[1]
1737 except IOError:
1737 except IOError:
1738 filename = make_filename(args)
1738 filename = make_filename(args)
1739 if filename is None:
1739 if filename is None:
1740 warn('The file `%s` where `%s` was defined cannot '
1740 warn('The file `%s` where `%s` was defined cannot '
1741 'be read.' % (filename,data))
1741 'be read.' % (filename,data))
1742 return
1742 return
1743 use_temp = 0
1743 use_temp = 0
1744 else:
1744 else:
1745 data = ''
1745 data = ''
1746
1746
1747 if use_temp:
1747 if use_temp:
1748 filename = tempfile.mktemp('.py')
1748 filename = tempfile.mktemp('.py')
1749 self.shell.tempfiles.append(filename)
1749 self.shell.tempfiles.append(filename)
1750
1750
1751 if data and use_temp:
1751 if data and use_temp:
1752 tmp_file = open(filename,'w')
1752 tmp_file = open(filename,'w')
1753 tmp_file.write(data)
1753 tmp_file.write(data)
1754 tmp_file.close()
1754 tmp_file.close()
1755
1755
1756 # do actual editing here
1756 # do actual editing here
1757 print 'Editing...',
1757 print 'Editing...',
1758 sys.stdout.flush()
1758 sys.stdout.flush()
1759 self.shell.hooks.editor(filename,lineno)
1759 self.shell.hooks.editor(filename,lineno)
1760 if opts.has_key('x'): # -x prevents actual execution
1760 if opts.has_key('x'): # -x prevents actual execution
1761 print
1761 print
1762 else:
1762 else:
1763 print 'done. Executing edited code...'
1763 print 'done. Executing edited code...'
1764 try:
1764 try:
1765 execfile(filename,self.shell.user_ns)
1765 execfile(filename,self.shell.user_ns)
1766 except IOError,msg:
1766 except IOError,msg:
1767 if msg.filename == filename:
1767 if msg.filename == filename:
1768 warn('File not found. Did you forget to save?')
1768 warn('File not found. Did you forget to save?')
1769 return
1769 return
1770 else:
1770 else:
1771 self.shell.showtraceback()
1771 self.shell.showtraceback()
1772 except:
1772 except:
1773 self.shell.showtraceback()
1773 self.shell.showtraceback()
1774 if use_temp:
1774 if use_temp:
1775 contents = open(filename).read()
1775 contents = open(filename).read()
1776 return contents
1776 return contents
1777
1777
1778 def magic_xmode(self,parameter_s = ''):
1778 def magic_xmode(self,parameter_s = ''):
1779 """Switch modes for the exception handlers.
1779 """Switch modes for the exception handlers.
1780
1780
1781 Valid modes: Plain, Context and Verbose.
1781 Valid modes: Plain, Context and Verbose.
1782
1782
1783 If called without arguments, acts as a toggle."""
1783 If called without arguments, acts as a toggle."""
1784
1784
1785 new_mode = parameter_s.strip().capitalize()
1785 new_mode = parameter_s.strip().capitalize()
1786 try:
1786 try:
1787 self.InteractiveTB.set_mode(mode = new_mode)
1787 self.InteractiveTB.set_mode(mode = new_mode)
1788 print 'Exception reporting mode:',self.InteractiveTB.mode
1788 print 'Exception reporting mode:',self.InteractiveTB.mode
1789 except:
1789 except:
1790 warn('Error changing exception modes.\n' + str(sys.exc_info()[1]))
1790 warn('Error changing exception modes.\n' + str(sys.exc_info()[1]))
1791
1791
1792 def magic_colors(self,parameter_s = ''):
1792 def magic_colors(self,parameter_s = ''):
1793 """Switch color scheme for prompts, info system and exception handlers.
1793 """Switch color scheme for prompts, info system and exception handlers.
1794
1794
1795 Currently implemented schemes: NoColor, Linux, LightBG.
1795 Currently implemented schemes: NoColor, Linux, LightBG.
1796
1796
1797 Color scheme names are not case-sensitive."""
1797 Color scheme names are not case-sensitive."""
1798
1798
1799 new_scheme = parameter_s.strip()
1799 new_scheme = parameter_s.strip()
1800 if not new_scheme:
1800 if not new_scheme:
1801 print 'You must specify a color scheme.'
1801 print 'You must specify a color scheme.'
1802 return
1802 return
1803 # Under Windows, check for Gary Bishop's readline, which is necessary
1803 # Under Windows, check for Gary Bishop's readline, which is necessary
1804 # for ANSI coloring
1804 # for ANSI coloring
1805 if os.name in ['nt','dos']:
1805 if os.name in ['nt','dos']:
1806 try:
1806 try:
1807 import readline
1807 import readline
1808 except ImportError:
1808 except ImportError:
1809 has_readline = 0
1809 has_readline = 0
1810 else:
1810 else:
1811 try:
1811 try:
1812 readline.GetOutputFile()
1812 readline.GetOutputFile()
1813 except AttributeError:
1813 except AttributeError:
1814 has_readline = 0
1814 has_readline = 0
1815 else:
1815 else:
1816 has_readline = 1
1816 has_readline = 1
1817 if not has_readline:
1817 if not has_readline:
1818 msg = """\
1818 msg = """\
1819 Proper color support under MS Windows requires Gary Bishop's readline library.
1819 Proper color support under MS Windows requires Gary Bishop's readline library.
1820 You can find it at:
1820 You can find it at:
1821 http://sourceforge.net/projects/uncpythontools
1821 http://sourceforge.net/projects/uncpythontools
1822 Gary's readline needs the ctypes module, from:
1822 Gary's readline needs the ctypes module, from:
1823 http://starship.python.net/crew/theller/ctypes
1823 http://starship.python.net/crew/theller/ctypes
1824
1824
1825 Defaulting color scheme to 'NoColor'"""
1825 Defaulting color scheme to 'NoColor'"""
1826 new_scheme = 'NoColor'
1826 new_scheme = 'NoColor'
1827 warn(msg)
1827 warn(msg)
1828
1828
1829 # Set prompt colors
1829 # Set prompt colors
1830 try:
1830 try:
1831 self.shell.outputcache.set_colors(new_scheme)
1831 self.shell.outputcache.set_colors(new_scheme)
1832 except:
1832 except:
1833 warn('Error changing prompt color schemes.\n'
1833 warn('Error changing prompt color schemes.\n'
1834 + str(sys.exc_info()[1]))
1834 + str(sys.exc_info()[1]))
1835 else:
1835 else:
1836 self.shell.rc.colors = \
1836 self.shell.rc.colors = \
1837 self.shell.outputcache.color_table.active_scheme_name
1837 self.shell.outputcache.color_table.active_scheme_name
1838 # Set exception colors
1838 # Set exception colors
1839 try:
1839 try:
1840 self.shell.InteractiveTB.set_colors(scheme = new_scheme)
1840 self.shell.InteractiveTB.set_colors(scheme = new_scheme)
1841 self.shell.SyntaxTB.set_colors(scheme = new_scheme)
1841 self.shell.SyntaxTB.set_colors(scheme = new_scheme)
1842 except:
1842 except:
1843 warn('Error changing exception color schemes.\n'
1843 warn('Error changing exception color schemes.\n'
1844 + str(sys.exc_info()[1]))
1844 + str(sys.exc_info()[1]))
1845 # Set info (for 'object?') colors
1845 # Set info (for 'object?') colors
1846 if self.shell.rc.color_info:
1846 if self.shell.rc.color_info:
1847 try:
1847 try:
1848 self.shell.inspector.set_active_scheme(new_scheme)
1848 self.shell.inspector.set_active_scheme(new_scheme)
1849 except:
1849 except:
1850 warn('Error changing object inspector color schemes.\n'
1850 warn('Error changing object inspector color schemes.\n'
1851 + str(sys.exc_info()[1]))
1851 + str(sys.exc_info()[1]))
1852 else:
1852 else:
1853 self.shell.inspector.set_active_scheme('NoColor')
1853 self.shell.inspector.set_active_scheme('NoColor')
1854
1854
1855 def magic_color_info(self,parameter_s = ''):
1855 def magic_color_info(self,parameter_s = ''):
1856 """Toggle color_info.
1856 """Toggle color_info.
1857
1857
1858 The color_info configuration parameter controls whether colors are
1858 The color_info configuration parameter controls whether colors are
1859 used for displaying object details (by things like %psource, %pfile or
1859 used for displaying object details (by things like %psource, %pfile or
1860 the '?' system). This function toggles this value with each call.
1860 the '?' system). This function toggles this value with each call.
1861
1861
1862 Note that unless you have a fairly recent pager (less works better
1862 Note that unless you have a fairly recent pager (less works better
1863 than more) in your system, using colored object information displays
1863 than more) in your system, using colored object information displays
1864 will not work properly. Test it and see."""
1864 will not work properly. Test it and see."""
1865
1865
1866 self.shell.rc.color_info = 1 - self.shell.rc.color_info
1866 self.shell.rc.color_info = 1 - self.shell.rc.color_info
1867 self.magic_colors(self.shell.rc.colors)
1867 self.magic_colors(self.shell.rc.colors)
1868 print 'Object introspection functions have now coloring:',
1868 print 'Object introspection functions have now coloring:',
1869 print ['OFF','ON'][self.shell.rc.color_info]
1869 print ['OFF','ON'][self.shell.rc.color_info]
1870
1870
1871 def magic_Pprint(self, parameter_s=''):
1871 def magic_Pprint(self, parameter_s=''):
1872 """Toggle pretty printing on/off."""
1872 """Toggle pretty printing on/off."""
1873
1873
1874 self.shell.outputcache.Pprint = 1 - self.shell.outputcache.Pprint
1874 self.shell.outputcache.Pprint = 1 - self.shell.outputcache.Pprint
1875 print 'Pretty printing has been turned', \
1875 print 'Pretty printing has been turned', \
1876 ['OFF','ON'][self.shell.outputcache.Pprint]
1876 ['OFF','ON'][self.shell.outputcache.Pprint]
1877
1877
1878 def magic_Exit(self, parameter_s=''):
1878 def magic_Exit(self, parameter_s=''):
1879 """Exit IPython without confirmation."""
1879 """Exit IPython without confirmation."""
1880
1880
1881 self.shell.exit_now = True
1881 self.shell.exit_now = True
1882
1882
1883 def magic_Quit(self, parameter_s=''):
1883 def magic_Quit(self, parameter_s=''):
1884 """Exit IPython without confirmation (like %Exit)."""
1884 """Exit IPython without confirmation (like %Exit)."""
1885
1885
1886 self.shell.exit_now = True
1886 self.shell.exit_now = True
1887
1887
1888 #......................................................................
1888 #......................................................................
1889 # Functions to implement unix shell-type things
1889 # Functions to implement unix shell-type things
1890
1890
1891 def magic_alias(self, parameter_s = ''):
1891 def magic_alias(self, parameter_s = ''):
1892 """Define an alias for a system command.
1892 """Define an alias for a system command.
1893
1893
1894 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
1894 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
1895
1895
1896 Then, typing 'alias_name params' will execute the system command 'cmd
1896 Then, typing 'alias_name params' will execute the system command 'cmd
1897 params' (from your underlying operating system).
1897 params' (from your underlying operating system).
1898
1898
1899 Aliases have lower precedence than magic functions and Python normal
1899 Aliases have lower precedence than magic functions and Python normal
1900 variables, so if 'foo' is both a Python variable and an alias, the
1900 variables, so if 'foo' is both a Python variable and an alias, the
1901 alias can not be executed until 'del foo' removes the Python variable.
1901 alias can not be executed until 'del foo' removes the Python variable.
1902
1902
1903 You can use the %l specifier in an alias definition to represent the
1903 You can use the %l specifier in an alias definition to represent the
1904 whole line when the alias is called. For example:
1904 whole line when the alias is called. For example:
1905
1905
1906 In [2]: alias all echo "Input in brackets: <%l>"\\
1906 In [2]: alias all echo "Input in brackets: <%l>"\\
1907 In [3]: all hello world\\
1907 In [3]: all hello world\\
1908 Input in brackets: <hello world>
1908 Input in brackets: <hello world>
1909
1909
1910 You can also define aliases with parameters using %s specifiers (one
1910 You can also define aliases with parameters using %s specifiers (one
1911 per parameter):
1911 per parameter):
1912
1912
1913 In [1]: alias parts echo first %s second %s\\
1913 In [1]: alias parts echo first %s second %s\\
1914 In [2]: %parts A B\\
1914 In [2]: %parts A B\\
1915 first A second B\\
1915 first A second B\\
1916 In [3]: %parts A\\
1916 In [3]: %parts A\\
1917 Incorrect number of arguments: 2 expected.\\
1917 Incorrect number of arguments: 2 expected.\\
1918 parts is an alias to: 'echo first %s second %s'
1918 parts is an alias to: 'echo first %s second %s'
1919
1919
1920 Note that %l and %s are mutually exclusive. You can only use one or
1920 Note that %l and %s are mutually exclusive. You can only use one or
1921 the other in your aliases.
1921 the other in your aliases.
1922
1922
1923 Aliases expand Python variables just like system calls using ! or !!
1923 Aliases expand Python variables just like system calls using ! or !!
1924 do: all expressions prefixed with '$' get expanded. For details of
1924 do: all expressions prefixed with '$' get expanded. For details of
1925 the semantic rules, see PEP-215:
1925 the semantic rules, see PEP-215:
1926 http://www.python.org/peps/pep-0215.html. This is the library used by
1926 http://www.python.org/peps/pep-0215.html. This is the library used by
1927 IPython for variable expansion. If you want to access a true shell
1927 IPython for variable expansion. If you want to access a true shell
1928 variable, an extra $ is necessary to prevent its expansion by IPython:
1928 variable, an extra $ is necessary to prevent its expansion by IPython:
1929
1929
1930 In [6]: alias show echo\\
1930 In [6]: alias show echo\\
1931 In [7]: PATH='A Python string'\\
1931 In [7]: PATH='A Python string'\\
1932 In [8]: show $PATH\\
1932 In [8]: show $PATH\\
1933 A Python string\\
1933 A Python string\\
1934 In [9]: show $$PATH\\
1934 In [9]: show $$PATH\\
1935 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1935 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1936
1936
1937 You can use the alias facility to acess all of $PATH. See the %rehash
1937 You can use the alias facility to acess all of $PATH. See the %rehash
1938 and %rehashx functions, which automatically create aliases for the
1938 and %rehashx functions, which automatically create aliases for the
1939 contents of your $PATH.
1939 contents of your $PATH.
1940
1940
1941 If called with no parameters, %alias prints the current alias table."""
1941 If called with no parameters, %alias prints the current alias table."""
1942
1942
1943 par = parameter_s.strip()
1943 par = parameter_s.strip()
1944 if not par:
1944 if not par:
1945 if self.shell.rc.automagic:
1945 if self.shell.rc.automagic:
1946 prechar = ''
1946 prechar = ''
1947 else:
1947 else:
1948 prechar = self.shell.ESC_MAGIC
1948 prechar = self.shell.ESC_MAGIC
1949 print 'Alias\t\tSystem Command\n'+'-'*30
1949 print 'Alias\t\tSystem Command\n'+'-'*30
1950 atab = self.shell.alias_table
1950 atab = self.shell.alias_table
1951 aliases = atab.keys()
1951 aliases = atab.keys()
1952 aliases.sort()
1952 aliases.sort()
1953 for alias in aliases:
1953 for alias in aliases:
1954 print prechar+alias+'\t\t'+atab[alias][1]
1954 print prechar+alias+'\t\t'+atab[alias][1]
1955 print '-'*30+'\nTotal number of aliases:',len(aliases)
1955 print '-'*30+'\nTotal number of aliases:',len(aliases)
1956 return
1956 return
1957 try:
1957 try:
1958 alias,cmd = par.split(None,1)
1958 alias,cmd = par.split(None,1)
1959 except:
1959 except:
1960 print OInspect.getdoc(self.magic_alias)
1960 print OInspect.getdoc(self.magic_alias)
1961 else:
1961 else:
1962 nargs = cmd.count('%s')
1962 nargs = cmd.count('%s')
1963 if nargs>0 and cmd.find('%l')>=0:
1963 if nargs>0 and cmd.find('%l')>=0:
1964 error('The %s and %l specifiers are mutually exclusive '
1964 error('The %s and %l specifiers are mutually exclusive '
1965 'in alias definitions.')
1965 'in alias definitions.')
1966 else: # all looks OK
1966 else: # all looks OK
1967 self.shell.alias_table[alias] = (nargs,cmd)
1967 self.shell.alias_table[alias] = (nargs,cmd)
1968 self.shell.alias_table_validate(verbose=1)
1968 self.shell.alias_table_validate(verbose=1)
1969 # end magic_alias
1969 # end magic_alias
1970
1970
1971 def magic_unalias(self, parameter_s = ''):
1971 def magic_unalias(self, parameter_s = ''):
1972 """Remove an alias"""
1972 """Remove an alias"""
1973
1973
1974 aname = parameter_s.strip()
1974 aname = parameter_s.strip()
1975 if aname in self.shell.alias_table:
1975 if aname in self.shell.alias_table:
1976 del self.shell.alias_table[aname]
1976 del self.shell.alias_table[aname]
1977
1977
1978 def magic_rehash(self, parameter_s = ''):
1978 def magic_rehash(self, parameter_s = ''):
1979 """Update the alias table with all entries in $PATH.
1979 """Update the alias table with all entries in $PATH.
1980
1980
1981 This version does no checks on execute permissions or whether the
1981 This version does no checks on execute permissions or whether the
1982 contents of $PATH are truly files (instead of directories or something
1982 contents of $PATH are truly files (instead of directories or something
1983 else). For such a safer (but slower) version, use %rehashx."""
1983 else). For such a safer (but slower) version, use %rehashx."""
1984
1984
1985 # This function (and rehashx) manipulate the alias_table directly
1985 # This function (and rehashx) manipulate the alias_table directly
1986 # rather than calling magic_alias, for speed reasons. A rehash on a
1986 # rather than calling magic_alias, for speed reasons. A rehash on a
1987 # typical Linux box involves several thousand entries, so efficiency
1987 # typical Linux box involves several thousand entries, so efficiency
1988 # here is a top concern.
1988 # here is a top concern.
1989
1989
1990 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
1990 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
1991 alias_table = self.shell.alias_table
1991 alias_table = self.shell.alias_table
1992 for pdir in path:
1992 for pdir in path:
1993 for ff in os.listdir(pdir):
1993 for ff in os.listdir(pdir):
1994 # each entry in the alias table must be (N,name), where
1994 # each entry in the alias table must be (N,name), where
1995 # N is the number of positional arguments of the alias.
1995 # N is the number of positional arguments of the alias.
1996 alias_table[ff] = (0,ff)
1996 alias_table[ff] = (0,ff)
1997 # Make sure the alias table doesn't contain keywords or builtins
1997 # Make sure the alias table doesn't contain keywords or builtins
1998 self.shell.alias_table_validate()
1998 self.shell.alias_table_validate()
1999 # Call again init_auto_alias() so we get 'rm -i' and other modified
1999 # Call again init_auto_alias() so we get 'rm -i' and other modified
2000 # aliases since %rehash will probably clobber them
2000 # aliases since %rehash will probably clobber them
2001 self.shell.init_auto_alias()
2001 self.shell.init_auto_alias()
2002
2002
2003 def magic_rehashx(self, parameter_s = ''):
2003 def magic_rehashx(self, parameter_s = ''):
2004 """Update the alias table with all executable files in $PATH.
2004 """Update the alias table with all executable files in $PATH.
2005
2005
2006 This version explicitly checks that every entry in $PATH is a file
2006 This version explicitly checks that every entry in $PATH is a file
2007 with execute access (os.X_OK), so it is much slower than %rehash.
2007 with execute access (os.X_OK), so it is much slower than %rehash.
2008
2008
2009 Under Windows, it checks executability as a match agains a
2009 Under Windows, it checks executability as a match agains a
2010 '|'-separated string of extensions, stored in the IPython config
2010 '|'-separated string of extensions, stored in the IPython config
2011 variable win_exec_ext. This defaults to 'exe|com|bat'. """
2011 variable win_exec_ext. This defaults to 'exe|com|bat'. """
2012
2012
2013 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2013 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2014 alias_table = self.shell.alias_table
2014 alias_table = self.shell.alias_table
2015
2015
2016 if os.name == 'posix':
2016 if os.name == 'posix':
2017 isexec = lambda fname:os.path.isfile(fname) and \
2017 isexec = lambda fname:os.path.isfile(fname) and \
2018 os.access(fname,os.X_OK)
2018 os.access(fname,os.X_OK)
2019 else:
2019 else:
2020
2020
2021 try:
2021 try:
2022 winext = os.environ['pathext'].replace(';','|').replace('.','')
2022 winext = os.environ['pathext'].replace(';','|').replace('.','')
2023 except KeyError:
2023 except KeyError:
2024 winext = 'exe|com|bat'
2024 winext = 'exe|com|bat'
2025
2025
2026 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2026 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2027 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2027 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2028 savedir = os.getcwd()
2028 savedir = os.getcwd()
2029 try:
2029 try:
2030 # write the whole loop for posix/Windows so we don't have an if in
2030 # write the whole loop for posix/Windows so we don't have an if in
2031 # the innermost part
2031 # the innermost part
2032 if os.name == 'posix':
2032 if os.name == 'posix':
2033 for pdir in path:
2033 for pdir in path:
2034 os.chdir(pdir)
2034 os.chdir(pdir)
2035 for ff in os.listdir(pdir):
2035 for ff in os.listdir(pdir):
2036 if isexec(ff):
2036 if isexec(ff):
2037 # each entry in the alias table must be (N,name),
2037 # each entry in the alias table must be (N,name),
2038 # where N is the number of positional arguments of the
2038 # where N is the number of positional arguments of the
2039 # alias.
2039 # alias.
2040 alias_table[ff] = (0,ff)
2040 alias_table[ff] = (0,ff)
2041 else:
2041 else:
2042 for pdir in path:
2042 for pdir in path:
2043 os.chdir(pdir)
2043 os.chdir(pdir)
2044 for ff in os.listdir(pdir):
2044 for ff in os.listdir(pdir):
2045 if isexec(ff):
2045 if isexec(ff):
2046 alias_table[execre.sub(r'\1',ff)] = (0,ff)
2046 alias_table[execre.sub(r'\1',ff)] = (0,ff)
2047 # Make sure the alias table doesn't contain keywords or builtins
2047 # Make sure the alias table doesn't contain keywords or builtins
2048 self.shell.alias_table_validate()
2048 self.shell.alias_table_validate()
2049 # Call again init_auto_alias() so we get 'rm -i' and other
2049 # Call again init_auto_alias() so we get 'rm -i' and other
2050 # modified aliases since %rehashx will probably clobber them
2050 # modified aliases since %rehashx will probably clobber them
2051 self.shell.init_auto_alias()
2051 self.shell.init_auto_alias()
2052 finally:
2052 finally:
2053 os.chdir(savedir)
2053 os.chdir(savedir)
2054
2054
2055 def magic_pwd(self, parameter_s = ''):
2055 def magic_pwd(self, parameter_s = ''):
2056 """Return the current working directory path."""
2056 """Return the current working directory path."""
2057 return os.getcwd()
2057 return os.getcwd()
2058
2058
2059 def magic_cd(self, parameter_s=''):
2059 def magic_cd(self, parameter_s=''):
2060 """Change the current working directory.
2060 """Change the current working directory.
2061
2061
2062 This command automatically maintains an internal list of directories
2062 This command automatically maintains an internal list of directories
2063 you visit during your IPython session, in the variable _dh. The
2063 you visit during your IPython session, in the variable _dh. The
2064 command %dhist shows this history nicely formatted.
2064 command %dhist shows this history nicely formatted.
2065
2065
2066 Usage:
2066 Usage:
2067
2067
2068 cd 'dir': changes to directory 'dir'.
2068 cd 'dir': changes to directory 'dir'.
2069
2069
2070 cd -: changes to the last visited directory.
2070 cd -: changes to the last visited directory.
2071
2071
2072 cd -<n>: changes to the n-th directory in the directory history.
2072 cd -<n>: changes to the n-th directory in the directory history.
2073
2073
2074 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2074 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2075 (note: cd <bookmark_name> is enough if there is no
2075 (note: cd <bookmark_name> is enough if there is no
2076 directory <bookmark_name>, but a bookmark with the name exists.)
2076 directory <bookmark_name>, but a bookmark with the name exists.)
2077
2077
2078 Options:
2078 Options:
2079
2079
2080 -q: quiet. Do not print the working directory after the cd command is
2080 -q: quiet. Do not print the working directory after the cd command is
2081 executed. By default IPython's cd command does print this directory,
2081 executed. By default IPython's cd command does print this directory,
2082 since the default prompts do not display path information.
2082 since the default prompts do not display path information.
2083
2083
2084 Note that !cd doesn't work for this purpose because the shell where
2084 Note that !cd doesn't work for this purpose because the shell where
2085 !command runs is immediately discarded after executing 'command'."""
2085 !command runs is immediately discarded after executing 'command'."""
2086
2086
2087 parameter_s = parameter_s.strip()
2087 parameter_s = parameter_s.strip()
2088 bkms = self.shell.persist.get("bookmarks",{})
2088 bkms = self.shell.persist.get("bookmarks",{})
2089
2089
2090 numcd = re.match(r'(-)(\d+)$',parameter_s)
2090 numcd = re.match(r'(-)(\d+)$',parameter_s)
2091 # jump in directory history by number
2091 # jump in directory history by number
2092 if numcd:
2092 if numcd:
2093 nn = int(numcd.group(2))
2093 nn = int(numcd.group(2))
2094 try:
2094 try:
2095 ps = self.shell.user_ns['_dh'][nn]
2095 ps = self.shell.user_ns['_dh'][nn]
2096 except IndexError:
2096 except IndexError:
2097 print 'The requested directory does not exist in history.'
2097 print 'The requested directory does not exist in history.'
2098 return
2098 return
2099 else:
2099 else:
2100 opts = {}
2100 opts = {}
2101 else:
2101 else:
2102 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2102 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2103 # jump to previous
2103 # jump to previous
2104 if ps == '-':
2104 if ps == '-':
2105 try:
2105 try:
2106 ps = self.shell.user_ns['_dh'][-2]
2106 ps = self.shell.user_ns['_dh'][-2]
2107 except IndexError:
2107 except IndexError:
2108 print 'No previous directory to change to.'
2108 print 'No previous directory to change to.'
2109 return
2109 return
2110 # jump to bookmark
2110 # jump to bookmark
2111 elif opts.has_key('b') or (bkms.has_key(ps) and not os.path.isdir(ps)):
2111 elif opts.has_key('b') or (bkms.has_key(ps) and not os.path.isdir(ps)):
2112 if bkms.has_key(ps):
2112 if bkms.has_key(ps):
2113 target = bkms[ps]
2113 target = bkms[ps]
2114 print '(bookmark:%s) -> %s' % (ps,target)
2114 print '(bookmark:%s) -> %s' % (ps,target)
2115 ps = target
2115 ps = target
2116 else:
2116 else:
2117 if bkms:
2117 if bkms:
2118 error("Bookmark '%s' not found. "
2118 error("Bookmark '%s' not found. "
2119 "Use '%bookmark -l' to see your bookmarks." % ps)
2119 "Use '%bookmark -l' to see your bookmarks." % ps)
2120 else:
2120 else:
2121 print "Bookmarks not set - use %bookmark <bookmarkname>"
2121 print "Bookmarks not set - use %bookmark <bookmarkname>"
2122 return
2122 return
2123
2123
2124 # at this point ps should point to the target dir
2124 # at this point ps should point to the target dir
2125 if ps:
2125 if ps:
2126 try:
2126 try:
2127 os.chdir(os.path.expanduser(ps))
2127 os.chdir(os.path.expanduser(ps))
2128 except OSError:
2128 except OSError:
2129 print sys.exc_info()[1]
2129 print sys.exc_info()[1]
2130 else:
2130 else:
2131 self.shell.user_ns['_dh'].append(os.getcwd())
2131 self.shell.user_ns['_dh'].append(os.getcwd())
2132 else:
2132 else:
2133 os.chdir(self.home_dir)
2133 os.chdir(self.home_dir)
2134 self.shell.user_ns['_dh'].append(os.getcwd())
2134 self.shell.user_ns['_dh'].append(os.getcwd())
2135 if not 'q' in opts:
2135 if not 'q' in opts:
2136 print self.shell.user_ns['_dh'][-1]
2136 print self.shell.user_ns['_dh'][-1]
2137
2137
2138 def magic_dhist(self, parameter_s=''):
2138 def magic_dhist(self, parameter_s=''):
2139 """Print your history of visited directories.
2139 """Print your history of visited directories.
2140
2140
2141 %dhist -> print full history\\
2141 %dhist -> print full history\\
2142 %dhist n -> print last n entries only\\
2142 %dhist n -> print last n entries only\\
2143 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2143 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2144
2144
2145 This history is automatically maintained by the %cd command, and
2145 This history is automatically maintained by the %cd command, and
2146 always available as the global list variable _dh. You can use %cd -<n>
2146 always available as the global list variable _dh. You can use %cd -<n>
2147 to go to directory number <n>."""
2147 to go to directory number <n>."""
2148
2148
2149 dh = self.shell.user_ns['_dh']
2149 dh = self.shell.user_ns['_dh']
2150 if parameter_s:
2150 if parameter_s:
2151 try:
2151 try:
2152 args = map(int,parameter_s.split())
2152 args = map(int,parameter_s.split())
2153 except:
2153 except:
2154 self.arg_err(Magic.magic_dhist)
2154 self.arg_err(Magic.magic_dhist)
2155 return
2155 return
2156 if len(args) == 1:
2156 if len(args) == 1:
2157 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2157 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2158 elif len(args) == 2:
2158 elif len(args) == 2:
2159 ini,fin = args
2159 ini,fin = args
2160 else:
2160 else:
2161 self.arg_err(Magic.magic_dhist)
2161 self.arg_err(Magic.magic_dhist)
2162 return
2162 return
2163 else:
2163 else:
2164 ini,fin = 0,len(dh)
2164 ini,fin = 0,len(dh)
2165 nlprint(dh,
2165 nlprint(dh,
2166 header = 'Directory history (kept in _dh)',
2166 header = 'Directory history (kept in _dh)',
2167 start=ini,stop=fin)
2167 start=ini,stop=fin)
2168
2168
2169 def magic_env(self, parameter_s=''):
2169 def magic_env(self, parameter_s=''):
2170 """List environment variables."""
2170 """List environment variables."""
2171
2171
2172 # environ is an instance of UserDict
2172 # environ is an instance of UserDict
2173 return os.environ.data
2173 return os.environ.data
2174
2174
2175 def magic_pushd(self, parameter_s=''):
2175 def magic_pushd(self, parameter_s=''):
2176 """Place the current dir on stack and change directory.
2176 """Place the current dir on stack and change directory.
2177
2177
2178 Usage:\\
2178 Usage:\\
2179 %pushd ['dirname']
2179 %pushd ['dirname']
2180
2180
2181 %pushd with no arguments does a %pushd to your home directory.
2181 %pushd with no arguments does a %pushd to your home directory.
2182 """
2182 """
2183 if parameter_s == '': parameter_s = '~'
2183 if parameter_s == '': parameter_s = '~'
2184 if len(self.dir_stack)>0 and os.path.expanduser(parameter_s) != \
2184 if len(self.dir_stack)>0 and os.path.expanduser(parameter_s) != \
2185 os.path.expanduser(self.dir_stack[0]):
2185 os.path.expanduser(self.dir_stack[0]):
2186 try:
2186 try:
2187 self.magic_cd(parameter_s)
2187 self.magic_cd(parameter_s)
2188 self.dir_stack.insert(0,os.getcwd().replace(self.home_dir,'~'))
2188 self.dir_stack.insert(0,os.getcwd().replace(self.home_dir,'~'))
2189 self.magic_dirs()
2189 self.magic_dirs()
2190 except:
2190 except:
2191 print 'Invalid directory'
2191 print 'Invalid directory'
2192 else:
2192 else:
2193 print 'You are already there!'
2193 print 'You are already there!'
2194
2194
2195 def magic_popd(self, parameter_s=''):
2195 def magic_popd(self, parameter_s=''):
2196 """Change to directory popped off the top of the stack.
2196 """Change to directory popped off the top of the stack.
2197 """
2197 """
2198 if len (self.dir_stack) > 1:
2198 if len (self.dir_stack) > 1:
2199 self.dir_stack.pop(0)
2199 self.dir_stack.pop(0)
2200 self.magic_cd(self.dir_stack[0])
2200 self.magic_cd(self.dir_stack[0])
2201 print self.dir_stack[0]
2201 print self.dir_stack[0]
2202 else:
2202 else:
2203 print "You can't remove the starting directory from the stack:",\
2203 print "You can't remove the starting directory from the stack:",\
2204 self.dir_stack
2204 self.dir_stack
2205
2205
2206 def magic_dirs(self, parameter_s=''):
2206 def magic_dirs(self, parameter_s=''):
2207 """Return the current directory stack."""
2207 """Return the current directory stack."""
2208
2208
2209 return self.dir_stack[:]
2209 return self.dir_stack[:]
2210
2210
2211 def magic_sc(self, parameter_s=''):
2211 def magic_sc(self, parameter_s=''):
2212 """Shell capture - execute a shell command and capture its output.
2212 """Shell capture - execute a shell command and capture its output.
2213
2213
2214 %sc [options] varname=command
2214 %sc [options] varname=command
2215
2215
2216 IPython will run the given command using commands.getoutput(), and
2216 IPython will run the given command using commands.getoutput(), and
2217 will then update the user's interactive namespace with a variable
2217 will then update the user's interactive namespace with a variable
2218 called varname, containing the value of the call. Your command can
2218 called varname, containing the value of the call. Your command can
2219 contain shell wildcards, pipes, etc.
2219 contain shell wildcards, pipes, etc.
2220
2220
2221 The '=' sign in the syntax is mandatory, and the variable name you
2221 The '=' sign in the syntax is mandatory, and the variable name you
2222 supply must follow Python's standard conventions for valid names.
2222 supply must follow Python's standard conventions for valid names.
2223
2223
2224 Options:
2224 Options:
2225
2225
2226 -l: list output. Split the output on newlines into a list before
2226 -l: list output. Split the output on newlines into a list before
2227 assigning it to the given variable. By default the output is stored
2227 assigning it to the given variable. By default the output is stored
2228 as a single string.
2228 as a single string.
2229
2229
2230 -v: verbose. Print the contents of the variable.
2230 -v: verbose. Print the contents of the variable.
2231
2231
2232 In most cases you should not need to split as a list, because the
2232 In most cases you should not need to split as a list, because the
2233 returned value is a special type of string which can automatically
2233 returned value is a special type of string which can automatically
2234 provide its contents either as a list (split on newlines) or as a
2234 provide its contents either as a list (split on newlines) or as a
2235 space-separated string. These are convenient, respectively, either
2235 space-separated string. These are convenient, respectively, either
2236 for sequential processing or to be passed to a shell command.
2236 for sequential processing or to be passed to a shell command.
2237
2237
2238 For example:
2238 For example:
2239
2239
2240 # Capture into variable a
2240 # Capture into variable a
2241 In [9]: sc a=ls *py
2241 In [9]: sc a=ls *py
2242
2242
2243 # a is a string with embedded newlines
2243 # a is a string with embedded newlines
2244 In [10]: a
2244 In [10]: a
2245 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2245 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2246
2246
2247 # which can be seen as a list:
2247 # which can be seen as a list:
2248 In [11]: a.l
2248 In [11]: a.l
2249 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2249 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2250
2250
2251 # or as a whitespace-separated string:
2251 # or as a whitespace-separated string:
2252 In [12]: a.s
2252 In [12]: a.s
2253 Out[12]: 'setup.py win32_manual_post_install.py'
2253 Out[12]: 'setup.py win32_manual_post_install.py'
2254
2254
2255 # a.s is useful to pass as a single command line:
2255 # a.s is useful to pass as a single command line:
2256 In [13]: !wc -l $a.s
2256 In [13]: !wc -l $a.s
2257 146 setup.py
2257 146 setup.py
2258 130 win32_manual_post_install.py
2258 130 win32_manual_post_install.py
2259 276 total
2259 276 total
2260
2260
2261 # while the list form is useful to loop over:
2261 # while the list form is useful to loop over:
2262 In [14]: for f in a.l:
2262 In [14]: for f in a.l:
2263 ....: !wc -l $f
2263 ....: !wc -l $f
2264 ....:
2264 ....:
2265 146 setup.py
2265 146 setup.py
2266 130 win32_manual_post_install.py
2266 130 win32_manual_post_install.py
2267
2267
2268 Similiarly, the lists returned by the -l option are also special, in
2268 Similiarly, the lists returned by the -l option are also special, in
2269 the sense that you can equally invoke the .s attribute on them to
2269 the sense that you can equally invoke the .s attribute on them to
2270 automatically get a whitespace-separated string from their contents:
2270 automatically get a whitespace-separated string from their contents:
2271
2271
2272 In [1]: sc -l b=ls *py
2272 In [1]: sc -l b=ls *py
2273
2273
2274 In [2]: b
2274 In [2]: b
2275 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2275 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2276
2276
2277 In [3]: b.s
2277 In [3]: b.s
2278 Out[3]: 'setup.py win32_manual_post_install.py'
2278 Out[3]: 'setup.py win32_manual_post_install.py'
2279
2279
2280 In summary, both the lists and strings used for ouptut capture have
2280 In summary, both the lists and strings used for ouptut capture have
2281 the following special attributes:
2281 the following special attributes:
2282
2282
2283 .l (or .list) : value as list.
2283 .l (or .list) : value as list.
2284 .n (or .nlstr): value as newline-separated string.
2284 .n (or .nlstr): value as newline-separated string.
2285 .s (or .spstr): value as space-separated string.
2285 .s (or .spstr): value as space-separated string.
2286 """
2286 """
2287
2287
2288 opts,args = self.parse_options(parameter_s,'lv')
2288 opts,args = self.parse_options(parameter_s,'lv')
2289 # Try to get a variable name and command to run
2289 # Try to get a variable name and command to run
2290 try:
2290 try:
2291 # the variable name must be obtained from the parse_options
2291 # the variable name must be obtained from the parse_options
2292 # output, which uses shlex.split to strip options out.
2292 # output, which uses shlex.split to strip options out.
2293 var,_ = args.split('=',1)
2293 var,_ = args.split('=',1)
2294 var = var.strip()
2294 var = var.strip()
2295 # But the the command has to be extracted from the original input
2295 # But the the command has to be extracted from the original input
2296 # parameter_s, not on what parse_options returns, to avoid the
2296 # parameter_s, not on what parse_options returns, to avoid the
2297 # quote stripping which shlex.split performs on it.
2297 # quote stripping which shlex.split performs on it.
2298 _,cmd = parameter_s.split('=',1)
2298 _,cmd = parameter_s.split('=',1)
2299 except ValueError:
2299 except ValueError:
2300 var,cmd = '',''
2300 var,cmd = '',''
2301 if not var:
2301 if not var:
2302 error('you must specify a variable to assign the command to.')
2302 error('you must specify a variable to assign the command to.')
2303 return
2303 return
2304 # If all looks ok, proceed
2304 # If all looks ok, proceed
2305 out,err = self.shell.getoutputerror(cmd)
2305 out,err = self.shell.getoutputerror(cmd)
2306 if err:
2306 if err:
2307 print >> Term.cerr,err
2307 print >> Term.cerr,err
2308 if opts.has_key('l'):
2308 if opts.has_key('l'):
2309 out = SList(out.split('\n'))
2309 out = SList(out.split('\n'))
2310 else:
2310 else:
2311 out = LSString(out)
2311 out = LSString(out)
2312 if opts.has_key('v'):
2312 if opts.has_key('v'):
2313 print '%s ==\n%s' % (var,pformat(out))
2313 print '%s ==\n%s' % (var,pformat(out))
2314 self.shell.user_ns.update({var:out})
2314 self.shell.user_ns.update({var:out})
2315
2315
2316 def magic_sx(self, parameter_s=''):
2316 def magic_sx(self, parameter_s=''):
2317 """Shell execute - run a shell command and capture its output.
2317 """Shell execute - run a shell command and capture its output.
2318
2318
2319 %sx command
2319 %sx command
2320
2320
2321 IPython will run the given command using commands.getoutput(), and
2321 IPython will run the given command using commands.getoutput(), and
2322 return the result formatted as a list (split on '\\n'). Since the
2322 return the result formatted as a list (split on '\\n'). Since the
2323 output is _returned_, it will be stored in ipython's regular output
2323 output is _returned_, it will be stored in ipython's regular output
2324 cache Out[N] and in the '_N' automatic variables.
2324 cache Out[N] and in the '_N' automatic variables.
2325
2325
2326 Notes:
2326 Notes:
2327
2327
2328 1) If an input line begins with '!!', then %sx is automatically
2328 1) If an input line begins with '!!', then %sx is automatically
2329 invoked. That is, while:
2329 invoked. That is, while:
2330 !ls
2330 !ls
2331 causes ipython to simply issue system('ls'), typing
2331 causes ipython to simply issue system('ls'), typing
2332 !!ls
2332 !!ls
2333 is a shorthand equivalent to:
2333 is a shorthand equivalent to:
2334 %sx ls
2334 %sx ls
2335
2335
2336 2) %sx differs from %sc in that %sx automatically splits into a list,
2336 2) %sx differs from %sc in that %sx automatically splits into a list,
2337 like '%sc -l'. The reason for this is to make it as easy as possible
2337 like '%sc -l'. The reason for this is to make it as easy as possible
2338 to process line-oriented shell output via further python commands.
2338 to process line-oriented shell output via further python commands.
2339 %sc is meant to provide much finer control, but requires more
2339 %sc is meant to provide much finer control, but requires more
2340 typing.
2340 typing.
2341
2341
2342 3) Just like %sc -l, this is a list with special attributes:
2342 3) Just like %sc -l, this is a list with special attributes:
2343
2343
2344 .l (or .list) : value as list.
2344 .l (or .list) : value as list.
2345 .n (or .nlstr): value as newline-separated string.
2345 .n (or .nlstr): value as newline-separated string.
2346 .s (or .spstr): value as whitespace-separated string.
2346 .s (or .spstr): value as whitespace-separated string.
2347
2347
2348 This is very useful when trying to use such lists as arguments to
2348 This is very useful when trying to use such lists as arguments to
2349 system commands."""
2349 system commands."""
2350
2350
2351 if parameter_s:
2351 if parameter_s:
2352 out,err = self.shell.getoutputerror(parameter_s)
2352 out,err = self.shell.getoutputerror(parameter_s)
2353 if err:
2353 if err:
2354 print >> Term.cerr,err
2354 print >> Term.cerr,err
2355 return SList(out.split('\n'))
2355 return SList(out.split('\n'))
2356
2356
2357 def magic_bg(self, parameter_s=''):
2357 def magic_bg(self, parameter_s=''):
2358 """Run a job in the background, in a separate thread.
2358 """Run a job in the background, in a separate thread.
2359
2359
2360 For example,
2360 For example,
2361
2361
2362 %bg myfunc(x,y,z=1)
2362 %bg myfunc(x,y,z=1)
2363
2363
2364 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2364 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2365 execution starts, a message will be printed indicating the job
2365 execution starts, a message will be printed indicating the job
2366 number. If your job number is 5, you can use
2366 number. If your job number is 5, you can use
2367
2367
2368 myvar = jobs.result(5) or myvar = jobs[5].result
2368 myvar = jobs.result(5) or myvar = jobs[5].result
2369
2369
2370 to assign this result to variable 'myvar'.
2370 to assign this result to variable 'myvar'.
2371
2371
2372 IPython has a job manager, accessible via the 'jobs' object. You can
2372 IPython has a job manager, accessible via the 'jobs' object. You can
2373 type jobs? to get more information about it, and use jobs.<TAB> to see
2373 type jobs? to get more information about it, and use jobs.<TAB> to see
2374 its attributes. All attributes not starting with an underscore are
2374 its attributes. All attributes not starting with an underscore are
2375 meant for public use.
2375 meant for public use.
2376
2376
2377 In particular, look at the jobs.new() method, which is used to create
2377 In particular, look at the jobs.new() method, which is used to create
2378 new jobs. This magic %bg function is just a convenience wrapper
2378 new jobs. This magic %bg function is just a convenience wrapper
2379 around jobs.new(), for expression-based jobs. If you want to create a
2379 around jobs.new(), for expression-based jobs. If you want to create a
2380 new job with an explicit function object and arguments, you must call
2380 new job with an explicit function object and arguments, you must call
2381 jobs.new() directly.
2381 jobs.new() directly.
2382
2382
2383 The jobs.new docstring also describes in detail several important
2383 The jobs.new docstring also describes in detail several important
2384 caveats associated with a thread-based model for background job
2384 caveats associated with a thread-based model for background job
2385 execution. Type jobs.new? for details.
2385 execution. Type jobs.new? for details.
2386
2386
2387 You can check the status of all jobs with jobs.status().
2387 You can check the status of all jobs with jobs.status().
2388
2388
2389 The jobs variable is set by IPython into the Python builtin namespace.
2389 The jobs variable is set by IPython into the Python builtin namespace.
2390 If you ever declare a variable named 'jobs', you will shadow this
2390 If you ever declare a variable named 'jobs', you will shadow this
2391 name. You can either delete your global jobs variable to regain
2391 name. You can either delete your global jobs variable to regain
2392 access to the job manager, or make a new name and assign it manually
2392 access to the job manager, or make a new name and assign it manually
2393 to the manager (stored in IPython's namespace). For example, to
2393 to the manager (stored in IPython's namespace). For example, to
2394 assign the job manager to the Jobs name, use:
2394 assign the job manager to the Jobs name, use:
2395
2395
2396 Jobs = __builtins__.jobs"""
2396 Jobs = __builtins__.jobs"""
2397
2397
2398 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2398 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2399
2399
2400 def magic_bookmark(self, parameter_s=''):
2400 def magic_bookmark(self, parameter_s=''):
2401 """Manage IPython's bookmark system.
2401 """Manage IPython's bookmark system.
2402
2402
2403 %bookmark <name> - set bookmark to current dir
2403 %bookmark <name> - set bookmark to current dir
2404 %bookmark <name> <dir> - set bookmark to <dir>
2404 %bookmark <name> <dir> - set bookmark to <dir>
2405 %bookmark -l - list all bookmarks
2405 %bookmark -l - list all bookmarks
2406 %bookmark -d <name> - remove bookmark
2406 %bookmark -d <name> - remove bookmark
2407 %bookmark -r - remove all bookmarks
2407 %bookmark -r - remove all bookmarks
2408
2408
2409 You can later on access a bookmarked folder with:
2409 You can later on access a bookmarked folder with:
2410 %cd -b <name>
2410 %cd -b <name>
2411 or simply '%cd <name>' if there is no directory called <name> AND
2411 or simply '%cd <name>' if there is no directory called <name> AND
2412 there is such a bookmark defined.
2412 there is such a bookmark defined.
2413
2413
2414 Your bookmarks persist through IPython sessions, but they are
2414 Your bookmarks persist through IPython sessions, but they are
2415 associated with each profile."""
2415 associated with each profile."""
2416
2416
2417 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2417 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2418 if len(args) > 2:
2418 if len(args) > 2:
2419 error('You can only give at most two arguments')
2419 error('You can only give at most two arguments')
2420 return
2420 return
2421
2421
2422 bkms = self.shell.persist.get('bookmarks',{})
2422 bkms = self.shell.persist.get('bookmarks',{})
2423
2423
2424 if opts.has_key('d'):
2424 if opts.has_key('d'):
2425 try:
2425 try:
2426 todel = args[0]
2426 todel = args[0]
2427 except IndexError:
2427 except IndexError:
2428 error('You must provide a bookmark to delete')
2428 error('You must provide a bookmark to delete')
2429 else:
2429 else:
2430 try:
2430 try:
2431 del bkms[todel]
2431 del bkms[todel]
2432 except:
2432 except:
2433 error("Can't delete bookmark '%s'" % todel)
2433 error("Can't delete bookmark '%s'" % todel)
2434 elif opts.has_key('r'):
2434 elif opts.has_key('r'):
2435 bkms = {}
2435 bkms = {}
2436 elif opts.has_key('l'):
2436 elif opts.has_key('l'):
2437 bks = bkms.keys()
2437 bks = bkms.keys()
2438 bks.sort()
2438 bks.sort()
2439 if bks:
2439 if bks:
2440 size = max(map(len,bks))
2440 size = max(map(len,bks))
2441 else:
2441 else:
2442 size = 0
2442 size = 0
2443 fmt = '%-'+str(size)+'s -> %s'
2443 fmt = '%-'+str(size)+'s -> %s'
2444 print 'Current bookmarks:'
2444 print 'Current bookmarks:'
2445 for bk in bks:
2445 for bk in bks:
2446 print fmt % (bk,bkms[bk])
2446 print fmt % (bk,bkms[bk])
2447 else:
2447 else:
2448 if not args:
2448 if not args:
2449 error("You must specify the bookmark name")
2449 error("You must specify the bookmark name")
2450 elif len(args)==1:
2450 elif len(args)==1:
2451 bkms[args[0]] = os.getcwd()
2451 bkms[args[0]] = os.getcwd()
2452 elif len(args)==2:
2452 elif len(args)==2:
2453 bkms[args[0]] = args[1]
2453 bkms[args[0]] = args[1]
2454 self.persist['bookmarks'] = bkms
2454 self.persist['bookmarks'] = bkms
2455
2455
2456 def magic_pycat(self, parameter_s=''):
2456 def magic_pycat(self, parameter_s=''):
2457 """Show a syntax-highlighted file through a pager.
2457 """Show a syntax-highlighted file through a pager.
2458
2458
2459 This magic is similar to the cat utility, but it will assume the file
2459 This magic is similar to the cat utility, but it will assume the file
2460 to be Python source and will show it with syntax highlighting. """
2460 to be Python source and will show it with syntax highlighting. """
2461
2461
2462 try:
2462 try:
2463 filename = get_py_filename(parameter_s)
2463 filename = get_py_filename(parameter_s)
2464 except IndexError:
2464 except IndexError:
2465 warn('you must provide at least a filename.')
2465 warn('you must provide at least a filename.')
2466 return
2466 fobj=open(filename,'r')
2467 fobj=open(filename,'r')
2467 source = fobj.read()
2468 source = fobj.read()
2468 fobj.close()
2469 fobj.close()
2469 colorize = Parser().format
2470 colorize = Parser().format
2470 colorized_src = colorize(source,'str',self.shell.rc['colors'])
2471 colorized_src = colorize(source,'str',self.shell.rc['colors'])
2471 page(colorized_src,screen_lines=self.shell.rc.screen_length)
2472 page(colorized_src,screen_lines=self.shell.rc.screen_length)
2472
2473
2473 # end Magic
2474 # end Magic
@@ -1,178 +1,201
1 """Module for interactive demos using IPython.
1 """Module for interactive demos using IPython.
2
2
3 Sorry, but this uses Python 2.3 features, so it won't work in 2.2 environments.
3 Sorry, but this uses Python 2.3 features, so it won't work in 2.2 environments.
4 """
4 """
5 #*****************************************************************************
5 #*****************************************************************************
6 # Copyright (C) 2005 Fernando Perez. <Fernando.Perez@colorado.edu>
6 # Copyright (C) 2005 Fernando Perez. <Fernando.Perez@colorado.edu>
7 #
7 #
8 # Distributed under the terms of the BSD License. The full license is in
8 # Distributed under the terms of the BSD License. The full license is in
9 # the file COPYING, distributed as part of this software.
9 # the file COPYING, distributed as part of this software.
10 #
10 #
11 #*****************************************************************************
11 #*****************************************************************************
12
12
13 import sys
13 import sys
14 import exceptions
14 import exceptions
15 import re
15 import re
16
16
17 from IPython.PyColorize import Parser
17 from IPython.PyColorize import Parser
18 from IPython.genutils import marquee, shlex_split
18 from IPython.genutils import marquee, shlex_split
19
19
20 class DemoError(exceptions.Exception): pass
20 class DemoError(exceptions.Exception): pass
21
21
22 class Demo:
22 class Demo:
23 def __init__(self,fname,arg_str='',mark_pause='# pause',
23 def __init__(self,fname,arg_str='',mark_pause='# pause',
24 mark_silent='# silent',auto=False):
24 mark_silent='# silent',mark_auto='# auto',auto=False):
25 """Make a new demo object. To run the demo, simply call the object.
25 """Make a new demo object. To run the demo, simply call the object.
26
26
27 Inputs:
27 Inputs:
28
28
29 - fname = filename.
29 - fname = filename.
30
30
31 Optional inputs:
31 Optional inputs:
32
32
33 - arg_str(''): a string of arguments, internally converted to a list
33 - arg_str(''): a string of arguments, internally converted to a list
34 just like sys.argv, so the demo script can see a similar
34 just like sys.argv, so the demo script can see a similar
35 environment.
35 environment.
36
36
37 - mark_pause ('# pause'), mark_silent('# silent'): marks for pausing
37 - mark_pause ('# pause'): marks for pausing (block boundaries). The
38 (block boundaries) and to tag blocks as silent. The marks are
38 marks are turned into regexps which match them as standalone in a
39 turned into regexps which match them as standalone in a line, with
39 line, with all leading/trailing whitespace ignored.
40 all leading/trailing whitespace ignored.
40
41
41 - mark_silent('# silent'): mark blocks as silent, which means that
42 - auto(False): flag to run each block automatically without
42 they are executed without printing their content to screen. Silent
43 confirmation. Note that silent blocks are always automatically
43 blocks are always automatically executed.
44 executed. This flag is an attribute of the object, and can be
44
45 changed at runtime simply by reassigning it.
45 - mark_auto ('# auto'): mark individual blocks as automatically
46 executed (without asking for confirmation).
47
48 - auto(False): global flag to run all blocks automatically without
49 confirmation. This attribute overrides the block-level tags and
50 applies to the whole demo. It is an attribute of the object, and
51 can be changed at runtime simply by reassigning it to a boolean
52 value.
46 """
53 """
47
54
48 self.fname = fname
55 self.fname = fname
49 self.mark_pause = mark_pause
56 self.sys_argv = [fname] + shlex_split(arg_str)
50 self.re_pause = re.compile(r'^\s*%s\s*$' % mark_pause,re.MULTILINE)
57 self.mark_pause = mark_pause
51 self.mark_silent = mark_silent
58 self.mark_silent = mark_silent
52 self.re_silent = re.compile(r'^\s*%s\s*$' % mark_silent,re.MULTILINE)
59 self.re_pause = re.compile(r'^\s*%s\s*$' % mark_pause,re.MULTILINE)
53 self.auto = auto
60 self.re_silent = re.compile(r'^\s*%s\s*$' % mark_silent,re.MULTILINE)
54 self.sys_argv = [fname]+shlex_split(arg_str)
61 self.re_auto = re.compile(r'^\s*%s\s*$' % mark_auto,re.MULTILINE)
62 self.auto = auto
55
63
56 # get a few things from ipython. While it's a bit ugly design-wise,
64 # get a few things from ipython. While it's a bit ugly design-wise,
57 # it ensures that things like color scheme and the like are always in
65 # it ensures that things like color scheme and the like are always in
58 # sync with the ipython mode being used. This class is only meant to
66 # sync with the ipython mode being used. This class is only meant to
59 # be used inside ipython anyways, so it's OK.
67 # be used inside ipython anyways, so it's OK.
60 self.ip_showtraceback = __IPYTHON__.showtraceback
68 self.ip_showtb = __IPYTHON__.showtraceback
61 self.ip_ns = __IPYTHON__.user_ns
69 self.ip_ns = __IPYTHON__.user_ns
62 self.ip_colors = __IPYTHON__.rc['colors']
70 self.ip_colors = __IPYTHON__.rc['colors']
71 self.colorize = Parser().format
72
73 # load user data and initialize data structures
74 self.reload()
63
75
76 def reload(self):
77 """Reload source from disk and initialize state."""
64 # read data and parse into blocks
78 # read data and parse into blocks
65 fobj = file(fname,'r')
79 fobj = file(self.fname,'r')
66 self.src = fobj.read()
80 self.src = fobj.read()
67 fobj.close()
81 fobj.close()
68 self.src_blocks = [b.strip() for b in self.re_pause.split(self.src) if b]
82 src_blocks = [b.strip() for b in self.re_pause.split(self.src) if b]
69 self.silent = [bool(self.re_silent.findall(b)) for b in self.src_blocks]
83 self._silent = [bool(self.re_silent.findall(b)) for b in src_blocks]
70 self.nblocks = len(self.src_blocks)
84 self._auto = [bool(self.re_auto.findall(b)) for b in src_blocks]
85 # strip out the 'auto' markers
86 src_b = []
87 auto_strip = lambda s: self.re_auto.sub('',s)
88 for i,b in enumerate(src_blocks):
89 if self._auto[i]:
90 src_b.append(auto_strip(b))
91 else:
92 src_b.append(b)
93 self.nblocks = len(src_b)
94 self.src_blocks = src_b
71
95
72 # try to colorize blocks
96 # try to colorize blocks
73 colorize = Parser().format
74 col_scheme = self.ip_colors
97 col_scheme = self.ip_colors
75 self.src_blocks_colored = [colorize(s_blk,'str',col_scheme)
98 self.src_blocks_colored = [self.colorize(s_blk,'str',col_scheme)
76 for s_blk in self.src_blocks]
99 for s_blk in self.src_blocks]
77
100 # ensure clean namespace and seek offset
78 # finish initialization
79 self.reset()
101 self.reset()
80
102
81 def reset(self):
103 def reset(self):
82 """Reset the namespace and seek pointer to restart the demo"""
104 """Reset the namespace and seek pointer to restart the demo"""
83 self.user_ns = {}
105 self.user_ns = {}
84 self.finished = False
106 self.finished = False
85 self.block_index = 0
107 self.block_index = 0
86
108
87 def again(self):
109 def again(self):
88 """Repeat the last block"""
110 """Repeat the last block"""
89 self.block_index -= 1
111 self.block_index -= 1
90 self.finished = False
112 self.finished = False
91 self()
113 self()
92
114
93 def _validate_index(self,index):
115 def _validate_index(self,index):
94 if index<0 or index>=self.nblocks:
116 if index<0 or index>=self.nblocks:
95 raise ValueError('invalid block index %s' % index)
117 raise ValueError('invalid block index %s' % index)
96
118
97 def seek(self,index):
119 def seek(self,index):
98 """Move the current seek pointer to the given block"""
120 """Move the current seek pointer to the given block"""
99 self._validate_index(index)
121 self._validate_index(index)
100 self.block_index = index-1
122 self.block_index = index
101 self.finished = False
123 self.finished = False
102
124
103 def show_block(self,index=None):
125 def show(self,index=None):
104 """Show a single block on screen"""
126 """Show a single block on screen"""
105 if index is None:
127 if index is None:
106 if self.finished:
128 if self.finished:
107 print 'Demo finished. Use reset() if you want to rerun it.'
129 print 'Demo finished. Use reset() if you want to rerun it.'
108 return
130 return
109 index = self.block_index
131 index = self.block_index
110 else:
132 else:
111 self._validate_index(index)
133 self._validate_index(index)
112 print marquee('<%s> block # %s (%s remaining)' %
134 print marquee('<%s> block # %s (%s remaining)' %
113 (self.fname,index,self.nblocks-index-1))
135 (self.fname,index,self.nblocks-index-1))
114 print self.src_blocks_colored[index],
136 print self.src_blocks_colored[index],
115
137
116 def show(self):
138 def show_all(self):
117 """Show entire demo on screen, block by block"""
139 """Show entire demo on screen, block by block"""
118
140
119 fname = self.fname
141 fname = self.fname
120 nblocks = self.nblocks
142 nblocks = self.nblocks
121 silent = self.silent
143 silent = self._silent
122 for index,block in enumerate(self.src_blocks_colored):
144 for index,block in enumerate(self.src_blocks_colored):
123 if silent[index]:
145 if silent[index]:
124 print marquee('<%s> SILENT block # %s (%s remaining)' %
146 print marquee('<%s> SILENT block # %s (%s remaining)' %
125 (fname,index,nblocks-index-1))
147 (fname,index,nblocks-index-1))
126 else:
148 else:
127 print marquee('<%s> block # %s (%s remaining)' %
149 print marquee('<%s> block # %s (%s remaining)' %
128 (fname,index,nblocks-index-1))
150 (fname,index,nblocks-index-1))
129 print block,
151 print block,
130
152
131 def __call__(self,index=None):
153 def __call__(self,index=None):
132 """run a block of the demo.
154 """run a block of the demo.
133
155
134 If index is given, it should be an integer >=1 and <= nblocks. This
156 If index is given, it should be an integer >=1 and <= nblocks. This
135 means that the calling convention is one off from typical Python
157 means that the calling convention is one off from typical Python
136 lists. The reason for the inconsistency is that the demo always
158 lists. The reason for the inconsistency is that the demo always
137 prints 'Block n/N, and N is the total, so it would be very odd to use
159 prints 'Block n/N, and N is the total, so it would be very odd to use
138 zero-indexing here."""
160 zero-indexing here."""
139
161
140 if index is None and self.finished:
162 if index is None and self.finished:
141 print 'Demo finished. Use reset() if you want to rerun it.'
163 print 'Demo finished. Use reset() if you want to rerun it.'
142 return
164 return
143 if index is None:
165 if index is None:
144 index = self.block_index
166 index = self.block_index
145 self._validate_index(index)
167 self._validate_index(index)
146 try:
168 try:
147 next_block = self.src_blocks[index]
169 next_block = self.src_blocks[index]
148 self.block_index += 1
170 self.block_index += 1
149 if self.silent[index]:
171 if self._silent[index]:
150 print marquee('Executing silent block # %s (%s remaining)' %
172 print marquee('Executing silent block # %s (%s remaining)' %
151 (index,self.nblocks-index-1))
173 (index,self.nblocks-index-1))
152 else:
174 else:
153 self.show_block(index)
175 self.show(index)
154 if self.auto:
176 if self.auto or self._auto[index]:
155 print marquee('output')
177 print marquee('output')
156 else:
178 else:
157 print marquee('Press <q> to quit, <Enter> to execute...'),
179 print marquee('Press <q> to quit, <Enter> to execute...'),
158 ans = raw_input().strip()
180 ans = raw_input().strip()
159 if ans:
181 if ans:
160 print marquee('Block NOT executed')
182 print marquee('Block NOT executed')
161 return
183 return
162 try:
184 try:
163 save_argv = sys.argv
185 save_argv = sys.argv
164 sys.argv = self.sys_argv
186 sys.argv = self.sys_argv
165 exec next_block in self.user_ns
187 exec next_block in self.user_ns
166 finally:
188 finally:
167 sys.argv = save_argv
189 sys.argv = save_argv
168
190
169 except:
191 except:
170 self.ip_showtraceback(filename=self.fname)
192 self.ip_showtb(filename=self.fname)
171 else:
193 else:
172 self.ip_ns.update(self.user_ns)
194 self.ip_ns.update(self.user_ns)
173
195
174 if self.block_index == self.nblocks:
196 if self.block_index == self.nblocks:
175 print
197 print
176 print marquee(' END OF DEMO ')
198 print marquee(' END OF DEMO ')
177 print marquee('Use reset() if you want to rerun it.')
199 print marquee('Use reset() if you want to rerun it.')
178 self.finished = True
200 self.finished = True
201
@@ -1,4396 +1,4399
1 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
1 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
2
2
3 * IPython/demo.py (Demo.__init__): added support for individually
4 tagging blocks for automatic execution.
5
3 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
6 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
4 syntax-highlighted python sources, requested by John.
7 syntax-highlighted python sources, requested by John.
5
8
6 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
9 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
7
10
8 * IPython/demo.py (Demo.again): fix bug where again() blocks after
11 * IPython/demo.py (Demo.again): fix bug where again() blocks after
9 finishing.
12 finishing.
10
13
11 * IPython/genutils.py (shlex_split): moved from Magic to here,
14 * IPython/genutils.py (shlex_split): moved from Magic to here,
12 where all 2.2 compatibility stuff lives. I needed it for demo.py.
15 where all 2.2 compatibility stuff lives. I needed it for demo.py.
13
16
14 * IPython/demo.py (Demo.__init__): added support for silent
17 * IPython/demo.py (Demo.__init__): added support for silent
15 blocks, improved marks as regexps, docstrings written.
18 blocks, improved marks as regexps, docstrings written.
16 (Demo.__init__): better docstring, added support for sys.argv.
19 (Demo.__init__): better docstring, added support for sys.argv.
17
20
18 * IPython/genutils.py (marquee): little utility used by the demo
21 * IPython/genutils.py (marquee): little utility used by the demo
19 code, handy in general.
22 code, handy in general.
20
23
21 * IPython/demo.py (Demo.__init__): new class for interactive
24 * IPython/demo.py (Demo.__init__): new class for interactive
22 demos. Not documented yet, I just wrote it in a hurry for
25 demos. Not documented yet, I just wrote it in a hurry for
23 scipy'05. Will docstring later.
26 scipy'05. Will docstring later.
24
27
25 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
28 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
26
29
27 * IPython/Shell.py (sigint_handler): Drastic simplification which
30 * IPython/Shell.py (sigint_handler): Drastic simplification which
28 also seems to make Ctrl-C work correctly across threads! This is
31 also seems to make Ctrl-C work correctly across threads! This is
29 so simple, that I can't beleive I'd missed it before. Needs more
32 so simple, that I can't beleive I'd missed it before. Needs more
30 testing, though.
33 testing, though.
31 (KBINT): Never mind, revert changes. I'm sure I'd tried something
34 (KBINT): Never mind, revert changes. I'm sure I'd tried something
32 like this before...
35 like this before...
33
36
34 * IPython/genutils.py (get_home_dir): add protection against
37 * IPython/genutils.py (get_home_dir): add protection against
35 non-dirs in win32 registry.
38 non-dirs in win32 registry.
36
39
37 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
40 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
38 bug where dict was mutated while iterating (pysh crash).
41 bug where dict was mutated while iterating (pysh crash).
39
42
40 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
43 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
41
44
42 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
45 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
43 spurious newlines added by this routine. After a report by
46 spurious newlines added by this routine. After a report by
44 F. Mantegazza.
47 F. Mantegazza.
45
48
46 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
49 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
47
50
48 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
51 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
49 calls. These were a leftover from the GTK 1.x days, and can cause
52 calls. These were a leftover from the GTK 1.x days, and can cause
50 problems in certain cases (after a report by John Hunter).
53 problems in certain cases (after a report by John Hunter).
51
54
52 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
55 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
53 os.getcwd() fails at init time. Thanks to patch from David Remahl
56 os.getcwd() fails at init time. Thanks to patch from David Remahl
54 <chmod007 AT mac.com>.
57 <chmod007 AT mac.com>.
55 (InteractiveShell.__init__): prevent certain special magics from
58 (InteractiveShell.__init__): prevent certain special magics from
56 being shadowed by aliases. Closes
59 being shadowed by aliases. Closes
57 http://www.scipy.net/roundup/ipython/issue41.
60 http://www.scipy.net/roundup/ipython/issue41.
58
61
59 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
62 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
60
63
61 * IPython/iplib.py (InteractiveShell.complete): Added new
64 * IPython/iplib.py (InteractiveShell.complete): Added new
62 top-level completion method to expose the completion mechanism
65 top-level completion method to expose the completion mechanism
63 beyond readline-based environments.
66 beyond readline-based environments.
64
67
65 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
68 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
66
69
67 * tools/ipsvnc (svnversion): fix svnversion capture.
70 * tools/ipsvnc (svnversion): fix svnversion capture.
68
71
69 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
72 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
70 attribute to self, which was missing. Before, it was set by a
73 attribute to self, which was missing. Before, it was set by a
71 routine which in certain cases wasn't being called, so the
74 routine which in certain cases wasn't being called, so the
72 instance could end up missing the attribute. This caused a crash.
75 instance could end up missing the attribute. This caused a crash.
73 Closes http://www.scipy.net/roundup/ipython/issue40.
76 Closes http://www.scipy.net/roundup/ipython/issue40.
74
77
75 2005-08-16 Fernando Perez <fperez@colorado.edu>
78 2005-08-16 Fernando Perez <fperez@colorado.edu>
76
79
77 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
80 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
78 contains non-string attribute. Closes
81 contains non-string attribute. Closes
79 http://www.scipy.net/roundup/ipython/issue38.
82 http://www.scipy.net/roundup/ipython/issue38.
80
83
81 2005-08-14 Fernando Perez <fperez@colorado.edu>
84 2005-08-14 Fernando Perez <fperez@colorado.edu>
82
85
83 * tools/ipsvnc: Minor improvements, to add changeset info.
86 * tools/ipsvnc: Minor improvements, to add changeset info.
84
87
85 2005-08-12 Fernando Perez <fperez@colorado.edu>
88 2005-08-12 Fernando Perez <fperez@colorado.edu>
86
89
87 * IPython/iplib.py (runsource): remove self.code_to_run_src
90 * IPython/iplib.py (runsource): remove self.code_to_run_src
88 attribute. I realized this is nothing more than
91 attribute. I realized this is nothing more than
89 '\n'.join(self.buffer), and having the same data in two different
92 '\n'.join(self.buffer), and having the same data in two different
90 places is just asking for synchronization bugs. This may impact
93 places is just asking for synchronization bugs. This may impact
91 people who have custom exception handlers, so I need to warn
94 people who have custom exception handlers, so I need to warn
92 ipython-dev about it (F. Mantegazza may use them).
95 ipython-dev about it (F. Mantegazza may use them).
93
96
94 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
97 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
95
98
96 * IPython/genutils.py: fix 2.2 compatibility (generators)
99 * IPython/genutils.py: fix 2.2 compatibility (generators)
97
100
98 2005-07-18 Fernando Perez <fperez@colorado.edu>
101 2005-07-18 Fernando Perez <fperez@colorado.edu>
99
102
100 * IPython/genutils.py (get_home_dir): fix to help users with
103 * IPython/genutils.py (get_home_dir): fix to help users with
101 invalid $HOME under win32.
104 invalid $HOME under win32.
102
105
103 2005-07-17 Fernando Perez <fperez@colorado.edu>
106 2005-07-17 Fernando Perez <fperez@colorado.edu>
104
107
105 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
108 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
106 some old hacks and clean up a bit other routines; code should be
109 some old hacks and clean up a bit other routines; code should be
107 simpler and a bit faster.
110 simpler and a bit faster.
108
111
109 * IPython/iplib.py (interact): removed some last-resort attempts
112 * IPython/iplib.py (interact): removed some last-resort attempts
110 to survive broken stdout/stderr. That code was only making it
113 to survive broken stdout/stderr. That code was only making it
111 harder to abstract out the i/o (necessary for gui integration),
114 harder to abstract out the i/o (necessary for gui integration),
112 and the crashes it could prevent were extremely rare in practice
115 and the crashes it could prevent were extremely rare in practice
113 (besides being fully user-induced in a pretty violent manner).
116 (besides being fully user-induced in a pretty violent manner).
114
117
115 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
118 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
116 Nothing major yet, but the code is simpler to read; this should
119 Nothing major yet, but the code is simpler to read; this should
117 make it easier to do more serious modifications in the future.
120 make it easier to do more serious modifications in the future.
118
121
119 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
122 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
120 which broke in .15 (thanks to a report by Ville).
123 which broke in .15 (thanks to a report by Ville).
121
124
122 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
125 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
123 be quite correct, I know next to nothing about unicode). This
126 be quite correct, I know next to nothing about unicode). This
124 will allow unicode strings to be used in prompts, amongst other
127 will allow unicode strings to be used in prompts, amongst other
125 cases. It also will prevent ipython from crashing when unicode
128 cases. It also will prevent ipython from crashing when unicode
126 shows up unexpectedly in many places. If ascii encoding fails, we
129 shows up unexpectedly in many places. If ascii encoding fails, we
127 assume utf_8. Currently the encoding is not a user-visible
130 assume utf_8. Currently the encoding is not a user-visible
128 setting, though it could be made so if there is demand for it.
131 setting, though it could be made so if there is demand for it.
129
132
130 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
133 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
131
134
132 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
135 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
133
136
134 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
137 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
135
138
136 * IPython/genutils.py: Add 2.2 compatibility here, so all other
139 * IPython/genutils.py: Add 2.2 compatibility here, so all other
137 code can work transparently for 2.2/2.3.
140 code can work transparently for 2.2/2.3.
138
141
139 2005-07-16 Fernando Perez <fperez@colorado.edu>
142 2005-07-16 Fernando Perez <fperez@colorado.edu>
140
143
141 * IPython/ultraTB.py (ExceptionColors): Make a global variable
144 * IPython/ultraTB.py (ExceptionColors): Make a global variable
142 out of the color scheme table used for coloring exception
145 out of the color scheme table used for coloring exception
143 tracebacks. This allows user code to add new schemes at runtime.
146 tracebacks. This allows user code to add new schemes at runtime.
144 This is a minimally modified version of the patch at
147 This is a minimally modified version of the patch at
145 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
148 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
146 for the contribution.
149 for the contribution.
147
150
148 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
151 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
149 slightly modified version of the patch in
152 slightly modified version of the patch in
150 http://www.scipy.net/roundup/ipython/issue34, which also allows me
153 http://www.scipy.net/roundup/ipython/issue34, which also allows me
151 to remove the previous try/except solution (which was costlier).
154 to remove the previous try/except solution (which was costlier).
152 Thanks to Gaetan Lehmann <gaetan.lehmann AT jouy.inra.fr> for the fix.
155 Thanks to Gaetan Lehmann <gaetan.lehmann AT jouy.inra.fr> for the fix.
153
156
154 2005-06-08 Fernando Perez <fperez@colorado.edu>
157 2005-06-08 Fernando Perez <fperez@colorado.edu>
155
158
156 * IPython/iplib.py (write/write_err): Add methods to abstract all
159 * IPython/iplib.py (write/write_err): Add methods to abstract all
157 I/O a bit more.
160 I/O a bit more.
158
161
159 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
162 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
160 warning, reported by Aric Hagberg, fix by JD Hunter.
163 warning, reported by Aric Hagberg, fix by JD Hunter.
161
164
162 2005-06-02 *** Released version 0.6.15
165 2005-06-02 *** Released version 0.6.15
163
166
164 2005-06-01 Fernando Perez <fperez@colorado.edu>
167 2005-06-01 Fernando Perez <fperez@colorado.edu>
165
168
166 * IPython/iplib.py (MagicCompleter.file_matches): Fix
169 * IPython/iplib.py (MagicCompleter.file_matches): Fix
167 tab-completion of filenames within open-quoted strings. Note that
170 tab-completion of filenames within open-quoted strings. Note that
168 this requires that in ~/.ipython/ipythonrc, users change the
171 this requires that in ~/.ipython/ipythonrc, users change the
169 readline delimiters configuration to read:
172 readline delimiters configuration to read:
170
173
171 readline_remove_delims -/~
174 readline_remove_delims -/~
172
175
173
176
174 2005-05-31 *** Released version 0.6.14
177 2005-05-31 *** Released version 0.6.14
175
178
176 2005-05-29 Fernando Perez <fperez@colorado.edu>
179 2005-05-29 Fernando Perez <fperez@colorado.edu>
177
180
178 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
181 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
179 with files not on the filesystem. Reported by Eliyahu Sandler
182 with files not on the filesystem. Reported by Eliyahu Sandler
180 <eli@gondolin.net>
183 <eli@gondolin.net>
181
184
182 2005-05-22 Fernando Perez <fperez@colorado.edu>
185 2005-05-22 Fernando Perez <fperez@colorado.edu>
183
186
184 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
187 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
185 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
188 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
186
189
187 2005-05-19 Fernando Perez <fperez@colorado.edu>
190 2005-05-19 Fernando Perez <fperez@colorado.edu>
188
191
189 * IPython/iplib.py (safe_execfile): close a file which could be
192 * IPython/iplib.py (safe_execfile): close a file which could be
190 left open (causing problems in win32, which locks open files).
193 left open (causing problems in win32, which locks open files).
191 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
194 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
192
195
193 2005-05-18 Fernando Perez <fperez@colorado.edu>
196 2005-05-18 Fernando Perez <fperez@colorado.edu>
194
197
195 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
198 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
196 keyword arguments correctly to safe_execfile().
199 keyword arguments correctly to safe_execfile().
197
200
198 2005-05-13 Fernando Perez <fperez@colorado.edu>
201 2005-05-13 Fernando Perez <fperez@colorado.edu>
199
202
200 * ipython.1: Added info about Qt to manpage, and threads warning
203 * ipython.1: Added info about Qt to manpage, and threads warning
201 to usage page (invoked with --help).
204 to usage page (invoked with --help).
202
205
203 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
206 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
204 new matcher (it goes at the end of the priority list) to do
207 new matcher (it goes at the end of the priority list) to do
205 tab-completion on named function arguments. Submitted by George
208 tab-completion on named function arguments. Submitted by George
206 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
209 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
207 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
210 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
208 for more details.
211 for more details.
209
212
210 * IPython/Magic.py (magic_run): Added new -e flag to ignore
213 * IPython/Magic.py (magic_run): Added new -e flag to ignore
211 SystemExit exceptions in the script being run. Thanks to a report
214 SystemExit exceptions in the script being run. Thanks to a report
212 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
215 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
213 producing very annoying behavior when running unit tests.
216 producing very annoying behavior when running unit tests.
214
217
215 2005-05-12 Fernando Perez <fperez@colorado.edu>
218 2005-05-12 Fernando Perez <fperez@colorado.edu>
216
219
217 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
220 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
218 which I'd broken (again) due to a changed regexp. In the process,
221 which I'd broken (again) due to a changed regexp. In the process,
219 added ';' as an escape to auto-quote the whole line without
222 added ';' as an escape to auto-quote the whole line without
220 splitting its arguments. Thanks to a report by Jerry McRae
223 splitting its arguments. Thanks to a report by Jerry McRae
221 <qrs0xyc02-AT-sneakemail.com>.
224 <qrs0xyc02-AT-sneakemail.com>.
222
225
223 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
226 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
224 possible crashes caused by a TokenError. Reported by Ed Schofield
227 possible crashes caused by a TokenError. Reported by Ed Schofield
225 <schofield-AT-ftw.at>.
228 <schofield-AT-ftw.at>.
226
229
227 2005-05-06 Fernando Perez <fperez@colorado.edu>
230 2005-05-06 Fernando Perez <fperez@colorado.edu>
228
231
229 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
232 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
230
233
231 2005-04-29 Fernando Perez <fperez@colorado.edu>
234 2005-04-29 Fernando Perez <fperez@colorado.edu>
232
235
233 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
236 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
234 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
237 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
235 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
238 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
236 which provides support for Qt interactive usage (similar to the
239 which provides support for Qt interactive usage (similar to the
237 existing one for WX and GTK). This had been often requested.
240 existing one for WX and GTK). This had been often requested.
238
241
239 2005-04-14 *** Released version 0.6.13
242 2005-04-14 *** Released version 0.6.13
240
243
241 2005-04-08 Fernando Perez <fperez@colorado.edu>
244 2005-04-08 Fernando Perez <fperez@colorado.edu>
242
245
243 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
246 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
244 from _ofind, which gets called on almost every input line. Now,
247 from _ofind, which gets called on almost every input line. Now,
245 we only try to get docstrings if they are actually going to be
248 we only try to get docstrings if they are actually going to be
246 used (the overhead of fetching unnecessary docstrings can be
249 used (the overhead of fetching unnecessary docstrings can be
247 noticeable for certain objects, such as Pyro proxies).
250 noticeable for certain objects, such as Pyro proxies).
248
251
249 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
252 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
250 for completers. For some reason I had been passing them the state
253 for completers. For some reason I had been passing them the state
251 variable, which completers never actually need, and was in
254 variable, which completers never actually need, and was in
252 conflict with the rlcompleter API. Custom completers ONLY need to
255 conflict with the rlcompleter API. Custom completers ONLY need to
253 take the text parameter.
256 take the text parameter.
254
257
255 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
258 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
256 work correctly in pysh. I've also moved all the logic which used
259 work correctly in pysh. I've also moved all the logic which used
257 to be in pysh.py here, which will prevent problems with future
260 to be in pysh.py here, which will prevent problems with future
258 upgrades. However, this time I must warn users to update their
261 upgrades. However, this time I must warn users to update their
259 pysh profile to include the line
262 pysh profile to include the line
260
263
261 import_all IPython.Extensions.InterpreterExec
264 import_all IPython.Extensions.InterpreterExec
262
265
263 because otherwise things won't work for them. They MUST also
266 because otherwise things won't work for them. They MUST also
264 delete pysh.py and the line
267 delete pysh.py and the line
265
268
266 execfile pysh.py
269 execfile pysh.py
267
270
268 from their ipythonrc-pysh.
271 from their ipythonrc-pysh.
269
272
270 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
273 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
271 robust in the face of objects whose dir() returns non-strings
274 robust in the face of objects whose dir() returns non-strings
272 (which it shouldn't, but some broken libs like ITK do). Thanks to
275 (which it shouldn't, but some broken libs like ITK do). Thanks to
273 a patch by John Hunter (implemented differently, though). Also
276 a patch by John Hunter (implemented differently, though). Also
274 minor improvements by using .extend instead of + on lists.
277 minor improvements by using .extend instead of + on lists.
275
278
276 * pysh.py:
279 * pysh.py:
277
280
278 2005-04-06 Fernando Perez <fperez@colorado.edu>
281 2005-04-06 Fernando Perez <fperez@colorado.edu>
279
282
280 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
283 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
281 by default, so that all users benefit from it. Those who don't
284 by default, so that all users benefit from it. Those who don't
282 want it can still turn it off.
285 want it can still turn it off.
283
286
284 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
287 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
285 config file, I'd forgotten about this, so users were getting it
288 config file, I'd forgotten about this, so users were getting it
286 off by default.
289 off by default.
287
290
288 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
291 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
289 consistency. Now magics can be called in multiline statements,
292 consistency. Now magics can be called in multiline statements,
290 and python variables can be expanded in magic calls via $var.
293 and python variables can be expanded in magic calls via $var.
291 This makes the magic system behave just like aliases or !system
294 This makes the magic system behave just like aliases or !system
292 calls.
295 calls.
293
296
294 2005-03-28 Fernando Perez <fperez@colorado.edu>
297 2005-03-28 Fernando Perez <fperez@colorado.edu>
295
298
296 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
299 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
297 expensive string additions for building command. Add support for
300 expensive string additions for building command. Add support for
298 trailing ';' when autocall is used.
301 trailing ';' when autocall is used.
299
302
300 2005-03-26 Fernando Perez <fperez@colorado.edu>
303 2005-03-26 Fernando Perez <fperez@colorado.edu>
301
304
302 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
305 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
303 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
306 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
304 ipython.el robust against prompts with any number of spaces
307 ipython.el robust against prompts with any number of spaces
305 (including 0) after the ':' character.
308 (including 0) after the ':' character.
306
309
307 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
310 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
308 continuation prompt, which misled users to think the line was
311 continuation prompt, which misled users to think the line was
309 already indented. Closes debian Bug#300847, reported to me by
312 already indented. Closes debian Bug#300847, reported to me by
310 Norbert Tretkowski <tretkowski-AT-inittab.de>.
313 Norbert Tretkowski <tretkowski-AT-inittab.de>.
311
314
312 2005-03-23 Fernando Perez <fperez@colorado.edu>
315 2005-03-23 Fernando Perez <fperez@colorado.edu>
313
316
314 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
317 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
315 properly aligned if they have embedded newlines.
318 properly aligned if they have embedded newlines.
316
319
317 * IPython/iplib.py (runlines): Add a public method to expose
320 * IPython/iplib.py (runlines): Add a public method to expose
318 IPython's code execution machinery, so that users can run strings
321 IPython's code execution machinery, so that users can run strings
319 as if they had been typed at the prompt interactively.
322 as if they had been typed at the prompt interactively.
320 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
323 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
321 methods which can call the system shell, but with python variable
324 methods which can call the system shell, but with python variable
322 expansion. The three such methods are: __IPYTHON__.system,
325 expansion. The three such methods are: __IPYTHON__.system,
323 .getoutput and .getoutputerror. These need to be documented in a
326 .getoutput and .getoutputerror. These need to be documented in a
324 'public API' section (to be written) of the manual.
327 'public API' section (to be written) of the manual.
325
328
326 2005-03-20 Fernando Perez <fperez@colorado.edu>
329 2005-03-20 Fernando Perez <fperez@colorado.edu>
327
330
328 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
331 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
329 for custom exception handling. This is quite powerful, and it
332 for custom exception handling. This is quite powerful, and it
330 allows for user-installable exception handlers which can trap
333 allows for user-installable exception handlers which can trap
331 custom exceptions at runtime and treat them separately from
334 custom exceptions at runtime and treat them separately from
332 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
335 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
333 Mantegazza <mantegazza-AT-ill.fr>.
336 Mantegazza <mantegazza-AT-ill.fr>.
334 (InteractiveShell.set_custom_completer): public API function to
337 (InteractiveShell.set_custom_completer): public API function to
335 add new completers at runtime.
338 add new completers at runtime.
336
339
337 2005-03-19 Fernando Perez <fperez@colorado.edu>
340 2005-03-19 Fernando Perez <fperez@colorado.edu>
338
341
339 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
342 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
340 allow objects which provide their docstrings via non-standard
343 allow objects which provide their docstrings via non-standard
341 mechanisms (like Pyro proxies) to still be inspected by ipython's
344 mechanisms (like Pyro proxies) to still be inspected by ipython's
342 ? system.
345 ? system.
343
346
344 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
347 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
345 automatic capture system. I tried quite hard to make it work
348 automatic capture system. I tried quite hard to make it work
346 reliably, and simply failed. I tried many combinations with the
349 reliably, and simply failed. I tried many combinations with the
347 subprocess module, but eventually nothing worked in all needed
350 subprocess module, but eventually nothing worked in all needed
348 cases (not blocking stdin for the child, duplicating stdout
351 cases (not blocking stdin for the child, duplicating stdout
349 without blocking, etc). The new %sc/%sx still do capture to these
352 without blocking, etc). The new %sc/%sx still do capture to these
350 magical list/string objects which make shell use much more
353 magical list/string objects which make shell use much more
351 conveninent, so not all is lost.
354 conveninent, so not all is lost.
352
355
353 XXX - FIX MANUAL for the change above!
356 XXX - FIX MANUAL for the change above!
354
357
355 (runsource): I copied code.py's runsource() into ipython to modify
358 (runsource): I copied code.py's runsource() into ipython to modify
356 it a bit. Now the code object and source to be executed are
359 it a bit. Now the code object and source to be executed are
357 stored in ipython. This makes this info accessible to third-party
360 stored in ipython. This makes this info accessible to third-party
358 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
361 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
359 Mantegazza <mantegazza-AT-ill.fr>.
362 Mantegazza <mantegazza-AT-ill.fr>.
360
363
361 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
364 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
362 history-search via readline (like C-p/C-n). I'd wanted this for a
365 history-search via readline (like C-p/C-n). I'd wanted this for a
363 long time, but only recently found out how to do it. For users
366 long time, but only recently found out how to do it. For users
364 who already have their ipythonrc files made and want this, just
367 who already have their ipythonrc files made and want this, just
365 add:
368 add:
366
369
367 readline_parse_and_bind "\e[A": history-search-backward
370 readline_parse_and_bind "\e[A": history-search-backward
368 readline_parse_and_bind "\e[B": history-search-forward
371 readline_parse_and_bind "\e[B": history-search-forward
369
372
370 2005-03-18 Fernando Perez <fperez@colorado.edu>
373 2005-03-18 Fernando Perez <fperez@colorado.edu>
371
374
372 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
375 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
373 LSString and SList classes which allow transparent conversions
376 LSString and SList classes which allow transparent conversions
374 between list mode and whitespace-separated string.
377 between list mode and whitespace-separated string.
375 (magic_r): Fix recursion problem in %r.
378 (magic_r): Fix recursion problem in %r.
376
379
377 * IPython/genutils.py (LSString): New class to be used for
380 * IPython/genutils.py (LSString): New class to be used for
378 automatic storage of the results of all alias/system calls in _o
381 automatic storage of the results of all alias/system calls in _o
379 and _e (stdout/err). These provide a .l/.list attribute which
382 and _e (stdout/err). These provide a .l/.list attribute which
380 does automatic splitting on newlines. This means that for most
383 does automatic splitting on newlines. This means that for most
381 uses, you'll never need to do capturing of output with %sc/%sx
384 uses, you'll never need to do capturing of output with %sc/%sx
382 anymore, since ipython keeps this always done for you. Note that
385 anymore, since ipython keeps this always done for you. Note that
383 only the LAST results are stored, the _o/e variables are
386 only the LAST results are stored, the _o/e variables are
384 overwritten on each call. If you need to save their contents
387 overwritten on each call. If you need to save their contents
385 further, simply bind them to any other name.
388 further, simply bind them to any other name.
386
389
387 2005-03-17 Fernando Perez <fperez@colorado.edu>
390 2005-03-17 Fernando Perez <fperez@colorado.edu>
388
391
389 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
392 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
390 prompt namespace handling.
393 prompt namespace handling.
391
394
392 2005-03-16 Fernando Perez <fperez@colorado.edu>
395 2005-03-16 Fernando Perez <fperez@colorado.edu>
393
396
394 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
397 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
395 classic prompts to be '>>> ' (final space was missing, and it
398 classic prompts to be '>>> ' (final space was missing, and it
396 trips the emacs python mode).
399 trips the emacs python mode).
397 (BasePrompt.__str__): Added safe support for dynamic prompt
400 (BasePrompt.__str__): Added safe support for dynamic prompt
398 strings. Now you can set your prompt string to be '$x', and the
401 strings. Now you can set your prompt string to be '$x', and the
399 value of x will be printed from your interactive namespace. The
402 value of x will be printed from your interactive namespace. The
400 interpolation syntax includes the full Itpl support, so
403 interpolation syntax includes the full Itpl support, so
401 ${foo()+x+bar()} is a valid prompt string now, and the function
404 ${foo()+x+bar()} is a valid prompt string now, and the function
402 calls will be made at runtime.
405 calls will be made at runtime.
403
406
404 2005-03-15 Fernando Perez <fperez@colorado.edu>
407 2005-03-15 Fernando Perez <fperez@colorado.edu>
405
408
406 * IPython/Magic.py (magic_history): renamed %hist to %history, to
409 * IPython/Magic.py (magic_history): renamed %hist to %history, to
407 avoid name clashes in pylab. %hist still works, it just forwards
410 avoid name clashes in pylab. %hist still works, it just forwards
408 the call to %history.
411 the call to %history.
409
412
410 2005-03-02 *** Released version 0.6.12
413 2005-03-02 *** Released version 0.6.12
411
414
412 2005-03-02 Fernando Perez <fperez@colorado.edu>
415 2005-03-02 Fernando Perez <fperez@colorado.edu>
413
416
414 * IPython/iplib.py (handle_magic): log magic calls properly as
417 * IPython/iplib.py (handle_magic): log magic calls properly as
415 ipmagic() function calls.
418 ipmagic() function calls.
416
419
417 * IPython/Magic.py (magic_time): Improved %time to support
420 * IPython/Magic.py (magic_time): Improved %time to support
418 statements and provide wall-clock as well as CPU time.
421 statements and provide wall-clock as well as CPU time.
419
422
420 2005-02-27 Fernando Perez <fperez@colorado.edu>
423 2005-02-27 Fernando Perez <fperez@colorado.edu>
421
424
422 * IPython/hooks.py: New hooks module, to expose user-modifiable
425 * IPython/hooks.py: New hooks module, to expose user-modifiable
423 IPython functionality in a clean manner. For now only the editor
426 IPython functionality in a clean manner. For now only the editor
424 hook is actually written, and other thigns which I intend to turn
427 hook is actually written, and other thigns which I intend to turn
425 into proper hooks aren't yet there. The display and prefilter
428 into proper hooks aren't yet there. The display and prefilter
426 stuff, for example, should be hooks. But at least now the
429 stuff, for example, should be hooks. But at least now the
427 framework is in place, and the rest can be moved here with more
430 framework is in place, and the rest can be moved here with more
428 time later. IPython had had a .hooks variable for a long time for
431 time later. IPython had had a .hooks variable for a long time for
429 this purpose, but I'd never actually used it for anything.
432 this purpose, but I'd never actually used it for anything.
430
433
431 2005-02-26 Fernando Perez <fperez@colorado.edu>
434 2005-02-26 Fernando Perez <fperez@colorado.edu>
432
435
433 * IPython/ipmaker.py (make_IPython): make the default ipython
436 * IPython/ipmaker.py (make_IPython): make the default ipython
434 directory be called _ipython under win32, to follow more the
437 directory be called _ipython under win32, to follow more the
435 naming peculiarities of that platform (where buggy software like
438 naming peculiarities of that platform (where buggy software like
436 Visual Sourcesafe breaks with .named directories). Reported by
439 Visual Sourcesafe breaks with .named directories). Reported by
437 Ville Vainio.
440 Ville Vainio.
438
441
439 2005-02-23 Fernando Perez <fperez@colorado.edu>
442 2005-02-23 Fernando Perez <fperez@colorado.edu>
440
443
441 * IPython/iplib.py (InteractiveShell.__init__): removed a few
444 * IPython/iplib.py (InteractiveShell.__init__): removed a few
442 auto_aliases for win32 which were causing problems. Users can
445 auto_aliases for win32 which were causing problems. Users can
443 define the ones they personally like.
446 define the ones they personally like.
444
447
445 2005-02-21 Fernando Perez <fperez@colorado.edu>
448 2005-02-21 Fernando Perez <fperez@colorado.edu>
446
449
447 * IPython/Magic.py (magic_time): new magic to time execution of
450 * IPython/Magic.py (magic_time): new magic to time execution of
448 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
451 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
449
452
450 2005-02-19 Fernando Perez <fperez@colorado.edu>
453 2005-02-19 Fernando Perez <fperez@colorado.edu>
451
454
452 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
455 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
453 into keys (for prompts, for example).
456 into keys (for prompts, for example).
454
457
455 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
458 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
456 prompts in case users want them. This introduces a small behavior
459 prompts in case users want them. This introduces a small behavior
457 change: ipython does not automatically add a space to all prompts
460 change: ipython does not automatically add a space to all prompts
458 anymore. To get the old prompts with a space, users should add it
461 anymore. To get the old prompts with a space, users should add it
459 manually to their ipythonrc file, so for example prompt_in1 should
462 manually to their ipythonrc file, so for example prompt_in1 should
460 now read 'In [\#]: ' instead of 'In [\#]:'.
463 now read 'In [\#]: ' instead of 'In [\#]:'.
461 (BasePrompt.__init__): New option prompts_pad_left (only in rc
464 (BasePrompt.__init__): New option prompts_pad_left (only in rc
462 file) to control left-padding of secondary prompts.
465 file) to control left-padding of secondary prompts.
463
466
464 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
467 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
465 the profiler can't be imported. Fix for Debian, which removed
468 the profiler can't be imported. Fix for Debian, which removed
466 profile.py because of License issues. I applied a slightly
469 profile.py because of License issues. I applied a slightly
467 modified version of the original Debian patch at
470 modified version of the original Debian patch at
468 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
471 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
469
472
470 2005-02-17 Fernando Perez <fperez@colorado.edu>
473 2005-02-17 Fernando Perez <fperez@colorado.edu>
471
474
472 * IPython/genutils.py (native_line_ends): Fix bug which would
475 * IPython/genutils.py (native_line_ends): Fix bug which would
473 cause improper line-ends under win32 b/c I was not opening files
476 cause improper line-ends under win32 b/c I was not opening files
474 in binary mode. Bug report and fix thanks to Ville.
477 in binary mode. Bug report and fix thanks to Ville.
475
478
476 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
479 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
477 trying to catch spurious foo[1] autocalls. My fix actually broke
480 trying to catch spurious foo[1] autocalls. My fix actually broke
478 ',/' autoquote/call with explicit escape (bad regexp).
481 ',/' autoquote/call with explicit escape (bad regexp).
479
482
480 2005-02-15 *** Released version 0.6.11
483 2005-02-15 *** Released version 0.6.11
481
484
482 2005-02-14 Fernando Perez <fperez@colorado.edu>
485 2005-02-14 Fernando Perez <fperez@colorado.edu>
483
486
484 * IPython/background_jobs.py: New background job management
487 * IPython/background_jobs.py: New background job management
485 subsystem. This is implemented via a new set of classes, and
488 subsystem. This is implemented via a new set of classes, and
486 IPython now provides a builtin 'jobs' object for background job
489 IPython now provides a builtin 'jobs' object for background job
487 execution. A convenience %bg magic serves as a lightweight
490 execution. A convenience %bg magic serves as a lightweight
488 frontend for starting the more common type of calls. This was
491 frontend for starting the more common type of calls. This was
489 inspired by discussions with B. Granger and the BackgroundCommand
492 inspired by discussions with B. Granger and the BackgroundCommand
490 class described in the book Python Scripting for Computational
493 class described in the book Python Scripting for Computational
491 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
494 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
492 (although ultimately no code from this text was used, as IPython's
495 (although ultimately no code from this text was used, as IPython's
493 system is a separate implementation).
496 system is a separate implementation).
494
497
495 * IPython/iplib.py (MagicCompleter.python_matches): add new option
498 * IPython/iplib.py (MagicCompleter.python_matches): add new option
496 to control the completion of single/double underscore names
499 to control the completion of single/double underscore names
497 separately. As documented in the example ipytonrc file, the
500 separately. As documented in the example ipytonrc file, the
498 readline_omit__names variable can now be set to 2, to omit even
501 readline_omit__names variable can now be set to 2, to omit even
499 single underscore names. Thanks to a patch by Brian Wong
502 single underscore names. Thanks to a patch by Brian Wong
500 <BrianWong-AT-AirgoNetworks.Com>.
503 <BrianWong-AT-AirgoNetworks.Com>.
501 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
504 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
502 be autocalled as foo([1]) if foo were callable. A problem for
505 be autocalled as foo([1]) if foo were callable. A problem for
503 things which are both callable and implement __getitem__.
506 things which are both callable and implement __getitem__.
504 (init_readline): Fix autoindentation for win32. Thanks to a patch
507 (init_readline): Fix autoindentation for win32. Thanks to a patch
505 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
508 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
506
509
507 2005-02-12 Fernando Perez <fperez@colorado.edu>
510 2005-02-12 Fernando Perez <fperez@colorado.edu>
508
511
509 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
512 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
510 which I had written long ago to sort out user error messages which
513 which I had written long ago to sort out user error messages which
511 may occur during startup. This seemed like a good idea initially,
514 may occur during startup. This seemed like a good idea initially,
512 but it has proven a disaster in retrospect. I don't want to
515 but it has proven a disaster in retrospect. I don't want to
513 change much code for now, so my fix is to set the internal 'debug'
516 change much code for now, so my fix is to set the internal 'debug'
514 flag to true everywhere, whose only job was precisely to control
517 flag to true everywhere, whose only job was precisely to control
515 this subsystem. This closes issue 28 (as well as avoiding all
518 this subsystem. This closes issue 28 (as well as avoiding all
516 sorts of strange hangups which occur from time to time).
519 sorts of strange hangups which occur from time to time).
517
520
518 2005-02-07 Fernando Perez <fperez@colorado.edu>
521 2005-02-07 Fernando Perez <fperez@colorado.edu>
519
522
520 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
523 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
521 previous call produced a syntax error.
524 previous call produced a syntax error.
522
525
523 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
526 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
524 classes without constructor.
527 classes without constructor.
525
528
526 2005-02-06 Fernando Perez <fperez@colorado.edu>
529 2005-02-06 Fernando Perez <fperez@colorado.edu>
527
530
528 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
531 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
529 completions with the results of each matcher, so we return results
532 completions with the results of each matcher, so we return results
530 to the user from all namespaces. This breaks with ipython
533 to the user from all namespaces. This breaks with ipython
531 tradition, but I think it's a nicer behavior. Now you get all
534 tradition, but I think it's a nicer behavior. Now you get all
532 possible completions listed, from all possible namespaces (python,
535 possible completions listed, from all possible namespaces (python,
533 filesystem, magics...) After a request by John Hunter
536 filesystem, magics...) After a request by John Hunter
534 <jdhunter-AT-nitace.bsd.uchicago.edu>.
537 <jdhunter-AT-nitace.bsd.uchicago.edu>.
535
538
536 2005-02-05 Fernando Perez <fperez@colorado.edu>
539 2005-02-05 Fernando Perez <fperez@colorado.edu>
537
540
538 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
541 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
539 the call had quote characters in it (the quotes were stripped).
542 the call had quote characters in it (the quotes were stripped).
540
543
541 2005-01-31 Fernando Perez <fperez@colorado.edu>
544 2005-01-31 Fernando Perez <fperez@colorado.edu>
542
545
543 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
546 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
544 Itpl.itpl() to make the code more robust against psyco
547 Itpl.itpl() to make the code more robust against psyco
545 optimizations.
548 optimizations.
546
549
547 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
550 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
548 of causing an exception. Quicker, cleaner.
551 of causing an exception. Quicker, cleaner.
549
552
550 2005-01-28 Fernando Perez <fperez@colorado.edu>
553 2005-01-28 Fernando Perez <fperez@colorado.edu>
551
554
552 * scripts/ipython_win_post_install.py (install): hardcode
555 * scripts/ipython_win_post_install.py (install): hardcode
553 sys.prefix+'python.exe' as the executable path. It turns out that
556 sys.prefix+'python.exe' as the executable path. It turns out that
554 during the post-installation run, sys.executable resolves to the
557 during the post-installation run, sys.executable resolves to the
555 name of the binary installer! I should report this as a distutils
558 name of the binary installer! I should report this as a distutils
556 bug, I think. I updated the .10 release with this tiny fix, to
559 bug, I think. I updated the .10 release with this tiny fix, to
557 avoid annoying the lists further.
560 avoid annoying the lists further.
558
561
559 2005-01-27 *** Released version 0.6.10
562 2005-01-27 *** Released version 0.6.10
560
563
561 2005-01-27 Fernando Perez <fperez@colorado.edu>
564 2005-01-27 Fernando Perez <fperez@colorado.edu>
562
565
563 * IPython/numutils.py (norm): Added 'inf' as optional name for
566 * IPython/numutils.py (norm): Added 'inf' as optional name for
564 L-infinity norm, included references to mathworld.com for vector
567 L-infinity norm, included references to mathworld.com for vector
565 norm definitions.
568 norm definitions.
566 (amin/amax): added amin/amax for array min/max. Similar to what
569 (amin/amax): added amin/amax for array min/max. Similar to what
567 pylab ships with after the recent reorganization of names.
570 pylab ships with after the recent reorganization of names.
568 (spike/spike_odd): removed deprecated spike/spike_odd functions.
571 (spike/spike_odd): removed deprecated spike/spike_odd functions.
569
572
570 * ipython.el: committed Alex's recent fixes and improvements.
573 * ipython.el: committed Alex's recent fixes and improvements.
571 Tested with python-mode from CVS, and it looks excellent. Since
574 Tested with python-mode from CVS, and it looks excellent. Since
572 python-mode hasn't released anything in a while, I'm temporarily
575 python-mode hasn't released anything in a while, I'm temporarily
573 putting a copy of today's CVS (v 4.70) of python-mode in:
576 putting a copy of today's CVS (v 4.70) of python-mode in:
574 http://ipython.scipy.org/tmp/python-mode.el
577 http://ipython.scipy.org/tmp/python-mode.el
575
578
576 * scripts/ipython_win_post_install.py (install): Win32 fix to use
579 * scripts/ipython_win_post_install.py (install): Win32 fix to use
577 sys.executable for the executable name, instead of assuming it's
580 sys.executable for the executable name, instead of assuming it's
578 called 'python.exe' (the post-installer would have produced broken
581 called 'python.exe' (the post-installer would have produced broken
579 setups on systems with a differently named python binary).
582 setups on systems with a differently named python binary).
580
583
581 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
584 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
582 references to os.linesep, to make the code more
585 references to os.linesep, to make the code more
583 platform-independent. This is also part of the win32 coloring
586 platform-independent. This is also part of the win32 coloring
584 fixes.
587 fixes.
585
588
586 * IPython/genutils.py (page_dumb): Remove attempts to chop long
589 * IPython/genutils.py (page_dumb): Remove attempts to chop long
587 lines, which actually cause coloring bugs because the length of
590 lines, which actually cause coloring bugs because the length of
588 the line is very difficult to correctly compute with embedded
591 the line is very difficult to correctly compute with embedded
589 escapes. This was the source of all the coloring problems under
592 escapes. This was the source of all the coloring problems under
590 Win32. I think that _finally_, Win32 users have a properly
593 Win32. I think that _finally_, Win32 users have a properly
591 working ipython in all respects. This would never have happened
594 working ipython in all respects. This would never have happened
592 if not for Gary Bishop and Viktor Ransmayr's great help and work.
595 if not for Gary Bishop and Viktor Ransmayr's great help and work.
593
596
594 2005-01-26 *** Released version 0.6.9
597 2005-01-26 *** Released version 0.6.9
595
598
596 2005-01-25 Fernando Perez <fperez@colorado.edu>
599 2005-01-25 Fernando Perez <fperez@colorado.edu>
597
600
598 * setup.py: finally, we have a true Windows installer, thanks to
601 * setup.py: finally, we have a true Windows installer, thanks to
599 the excellent work of Viktor Ransmayr
602 the excellent work of Viktor Ransmayr
600 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
603 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
601 Windows users. The setup routine is quite a bit cleaner thanks to
604 Windows users. The setup routine is quite a bit cleaner thanks to
602 this, and the post-install script uses the proper functions to
605 this, and the post-install script uses the proper functions to
603 allow a clean de-installation using the standard Windows Control
606 allow a clean de-installation using the standard Windows Control
604 Panel.
607 Panel.
605
608
606 * IPython/genutils.py (get_home_dir): changed to use the $HOME
609 * IPython/genutils.py (get_home_dir): changed to use the $HOME
607 environment variable under all OSes (including win32) if
610 environment variable under all OSes (including win32) if
608 available. This will give consistency to win32 users who have set
611 available. This will give consistency to win32 users who have set
609 this variable for any reason. If os.environ['HOME'] fails, the
612 this variable for any reason. If os.environ['HOME'] fails, the
610 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
613 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
611
614
612 2005-01-24 Fernando Perez <fperez@colorado.edu>
615 2005-01-24 Fernando Perez <fperez@colorado.edu>
613
616
614 * IPython/numutils.py (empty_like): add empty_like(), similar to
617 * IPython/numutils.py (empty_like): add empty_like(), similar to
615 zeros_like() but taking advantage of the new empty() Numeric routine.
618 zeros_like() but taking advantage of the new empty() Numeric routine.
616
619
617 2005-01-23 *** Released version 0.6.8
620 2005-01-23 *** Released version 0.6.8
618
621
619 2005-01-22 Fernando Perez <fperez@colorado.edu>
622 2005-01-22 Fernando Perez <fperez@colorado.edu>
620
623
621 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
624 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
622 automatic show() calls. After discussing things with JDH, it
625 automatic show() calls. After discussing things with JDH, it
623 turns out there are too many corner cases where this can go wrong.
626 turns out there are too many corner cases where this can go wrong.
624 It's best not to try to be 'too smart', and simply have ipython
627 It's best not to try to be 'too smart', and simply have ipython
625 reproduce as much as possible the default behavior of a normal
628 reproduce as much as possible the default behavior of a normal
626 python shell.
629 python shell.
627
630
628 * IPython/iplib.py (InteractiveShell.__init__): Modified the
631 * IPython/iplib.py (InteractiveShell.__init__): Modified the
629 line-splitting regexp and _prefilter() to avoid calling getattr()
632 line-splitting regexp and _prefilter() to avoid calling getattr()
630 on assignments. This closes
633 on assignments. This closes
631 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
634 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
632 readline uses getattr(), so a simple <TAB> keypress is still
635 readline uses getattr(), so a simple <TAB> keypress is still
633 enough to trigger getattr() calls on an object.
636 enough to trigger getattr() calls on an object.
634
637
635 2005-01-21 Fernando Perez <fperez@colorado.edu>
638 2005-01-21 Fernando Perez <fperez@colorado.edu>
636
639
637 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
640 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
638 docstring under pylab so it doesn't mask the original.
641 docstring under pylab so it doesn't mask the original.
639
642
640 2005-01-21 *** Released version 0.6.7
643 2005-01-21 *** Released version 0.6.7
641
644
642 2005-01-21 Fernando Perez <fperez@colorado.edu>
645 2005-01-21 Fernando Perez <fperez@colorado.edu>
643
646
644 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
647 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
645 signal handling for win32 users in multithreaded mode.
648 signal handling for win32 users in multithreaded mode.
646
649
647 2005-01-17 Fernando Perez <fperez@colorado.edu>
650 2005-01-17 Fernando Perez <fperez@colorado.edu>
648
651
649 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
652 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
650 instances with no __init__. After a crash report by Norbert Nemec
653 instances with no __init__. After a crash report by Norbert Nemec
651 <Norbert-AT-nemec-online.de>.
654 <Norbert-AT-nemec-online.de>.
652
655
653 2005-01-14 Fernando Perez <fperez@colorado.edu>
656 2005-01-14 Fernando Perez <fperez@colorado.edu>
654
657
655 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
658 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
656 names for verbose exceptions, when multiple dotted names and the
659 names for verbose exceptions, when multiple dotted names and the
657 'parent' object were present on the same line.
660 'parent' object were present on the same line.
658
661
659 2005-01-11 Fernando Perez <fperez@colorado.edu>
662 2005-01-11 Fernando Perez <fperez@colorado.edu>
660
663
661 * IPython/genutils.py (flag_calls): new utility to trap and flag
664 * IPython/genutils.py (flag_calls): new utility to trap and flag
662 calls in functions. I need it to clean up matplotlib support.
665 calls in functions. I need it to clean up matplotlib support.
663 Also removed some deprecated code in genutils.
666 Also removed some deprecated code in genutils.
664
667
665 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
668 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
666 that matplotlib scripts called with %run, which don't call show()
669 that matplotlib scripts called with %run, which don't call show()
667 themselves, still have their plotting windows open.
670 themselves, still have their plotting windows open.
668
671
669 2005-01-05 Fernando Perez <fperez@colorado.edu>
672 2005-01-05 Fernando Perez <fperez@colorado.edu>
670
673
671 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
674 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
672 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
675 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
673
676
674 2004-12-19 Fernando Perez <fperez@colorado.edu>
677 2004-12-19 Fernando Perez <fperez@colorado.edu>
675
678
676 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
679 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
677 parent_runcode, which was an eyesore. The same result can be
680 parent_runcode, which was an eyesore. The same result can be
678 obtained with Python's regular superclass mechanisms.
681 obtained with Python's regular superclass mechanisms.
679
682
680 2004-12-17 Fernando Perez <fperez@colorado.edu>
683 2004-12-17 Fernando Perez <fperez@colorado.edu>
681
684
682 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
685 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
683 reported by Prabhu.
686 reported by Prabhu.
684 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
687 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
685 sys.stderr) instead of explicitly calling sys.stderr. This helps
688 sys.stderr) instead of explicitly calling sys.stderr. This helps
686 maintain our I/O abstractions clean, for future GUI embeddings.
689 maintain our I/O abstractions clean, for future GUI embeddings.
687
690
688 * IPython/genutils.py (info): added new utility for sys.stderr
691 * IPython/genutils.py (info): added new utility for sys.stderr
689 unified info message handling (thin wrapper around warn()).
692 unified info message handling (thin wrapper around warn()).
690
693
691 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
694 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
692 composite (dotted) names on verbose exceptions.
695 composite (dotted) names on verbose exceptions.
693 (VerboseTB.nullrepr): harden against another kind of errors which
696 (VerboseTB.nullrepr): harden against another kind of errors which
694 Python's inspect module can trigger, and which were crashing
697 Python's inspect module can trigger, and which were crashing
695 IPython. Thanks to a report by Marco Lombardi
698 IPython. Thanks to a report by Marco Lombardi
696 <mlombard-AT-ma010192.hq.eso.org>.
699 <mlombard-AT-ma010192.hq.eso.org>.
697
700
698 2004-12-13 *** Released version 0.6.6
701 2004-12-13 *** Released version 0.6.6
699
702
700 2004-12-12 Fernando Perez <fperez@colorado.edu>
703 2004-12-12 Fernando Perez <fperez@colorado.edu>
701
704
702 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
705 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
703 generated by pygtk upon initialization if it was built without
706 generated by pygtk upon initialization if it was built without
704 threads (for matplotlib users). After a crash reported by
707 threads (for matplotlib users). After a crash reported by
705 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
708 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
706
709
707 * IPython/ipmaker.py (make_IPython): fix small bug in the
710 * IPython/ipmaker.py (make_IPython): fix small bug in the
708 import_some parameter for multiple imports.
711 import_some parameter for multiple imports.
709
712
710 * IPython/iplib.py (ipmagic): simplified the interface of
713 * IPython/iplib.py (ipmagic): simplified the interface of
711 ipmagic() to take a single string argument, just as it would be
714 ipmagic() to take a single string argument, just as it would be
712 typed at the IPython cmd line.
715 typed at the IPython cmd line.
713 (ipalias): Added new ipalias() with an interface identical to
716 (ipalias): Added new ipalias() with an interface identical to
714 ipmagic(). This completes exposing a pure python interface to the
717 ipmagic(). This completes exposing a pure python interface to the
715 alias and magic system, which can be used in loops or more complex
718 alias and magic system, which can be used in loops or more complex
716 code where IPython's automatic line mangling is not active.
719 code where IPython's automatic line mangling is not active.
717
720
718 * IPython/genutils.py (timing): changed interface of timing to
721 * IPython/genutils.py (timing): changed interface of timing to
719 simply run code once, which is the most common case. timings()
722 simply run code once, which is the most common case. timings()
720 remains unchanged, for the cases where you want multiple runs.
723 remains unchanged, for the cases where you want multiple runs.
721
724
722 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
725 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
723 bug where Python2.2 crashes with exec'ing code which does not end
726 bug where Python2.2 crashes with exec'ing code which does not end
724 in a single newline. Python 2.3 is OK, so I hadn't noticed this
727 in a single newline. Python 2.3 is OK, so I hadn't noticed this
725 before.
728 before.
726
729
727 2004-12-10 Fernando Perez <fperez@colorado.edu>
730 2004-12-10 Fernando Perez <fperez@colorado.edu>
728
731
729 * IPython/Magic.py (Magic.magic_prun): changed name of option from
732 * IPython/Magic.py (Magic.magic_prun): changed name of option from
730 -t to -T, to accomodate the new -t flag in %run (the %run and
733 -t to -T, to accomodate the new -t flag in %run (the %run and
731 %prun options are kind of intermixed, and it's not easy to change
734 %prun options are kind of intermixed, and it's not easy to change
732 this with the limitations of python's getopt).
735 this with the limitations of python's getopt).
733
736
734 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
737 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
735 the execution of scripts. It's not as fine-tuned as timeit.py,
738 the execution of scripts. It's not as fine-tuned as timeit.py,
736 but it works from inside ipython (and under 2.2, which lacks
739 but it works from inside ipython (and under 2.2, which lacks
737 timeit.py). Optionally a number of runs > 1 can be given for
740 timeit.py). Optionally a number of runs > 1 can be given for
738 timing very short-running code.
741 timing very short-running code.
739
742
740 * IPython/genutils.py (uniq_stable): new routine which returns a
743 * IPython/genutils.py (uniq_stable): new routine which returns a
741 list of unique elements in any iterable, but in stable order of
744 list of unique elements in any iterable, but in stable order of
742 appearance. I needed this for the ultraTB fixes, and it's a handy
745 appearance. I needed this for the ultraTB fixes, and it's a handy
743 utility.
746 utility.
744
747
745 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
748 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
746 dotted names in Verbose exceptions. This had been broken since
749 dotted names in Verbose exceptions. This had been broken since
747 the very start, now x.y will properly be printed in a Verbose
750 the very start, now x.y will properly be printed in a Verbose
748 traceback, instead of x being shown and y appearing always as an
751 traceback, instead of x being shown and y appearing always as an
749 'undefined global'. Getting this to work was a bit tricky,
752 'undefined global'. Getting this to work was a bit tricky,
750 because by default python tokenizers are stateless. Saved by
753 because by default python tokenizers are stateless. Saved by
751 python's ability to easily add a bit of state to an arbitrary
754 python's ability to easily add a bit of state to an arbitrary
752 function (without needing to build a full-blown callable object).
755 function (without needing to build a full-blown callable object).
753
756
754 Also big cleanup of this code, which had horrendous runtime
757 Also big cleanup of this code, which had horrendous runtime
755 lookups of zillions of attributes for colorization. Moved all
758 lookups of zillions of attributes for colorization. Moved all
756 this code into a few templates, which make it cleaner and quicker.
759 this code into a few templates, which make it cleaner and quicker.
757
760
758 Printout quality was also improved for Verbose exceptions: one
761 Printout quality was also improved for Verbose exceptions: one
759 variable per line, and memory addresses are printed (this can be
762 variable per line, and memory addresses are printed (this can be
760 quite handy in nasty debugging situations, which is what Verbose
763 quite handy in nasty debugging situations, which is what Verbose
761 is for).
764 is for).
762
765
763 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
766 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
764 the command line as scripts to be loaded by embedded instances.
767 the command line as scripts to be loaded by embedded instances.
765 Doing so has the potential for an infinite recursion if there are
768 Doing so has the potential for an infinite recursion if there are
766 exceptions thrown in the process. This fixes a strange crash
769 exceptions thrown in the process. This fixes a strange crash
767 reported by Philippe MULLER <muller-AT-irit.fr>.
770 reported by Philippe MULLER <muller-AT-irit.fr>.
768
771
769 2004-12-09 Fernando Perez <fperez@colorado.edu>
772 2004-12-09 Fernando Perez <fperez@colorado.edu>
770
773
771 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
774 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
772 to reflect new names in matplotlib, which now expose the
775 to reflect new names in matplotlib, which now expose the
773 matlab-compatible interface via a pylab module instead of the
776 matlab-compatible interface via a pylab module instead of the
774 'matlab' name. The new code is backwards compatible, so users of
777 'matlab' name. The new code is backwards compatible, so users of
775 all matplotlib versions are OK. Patch by J. Hunter.
778 all matplotlib versions are OK. Patch by J. Hunter.
776
779
777 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
780 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
778 of __init__ docstrings for instances (class docstrings are already
781 of __init__ docstrings for instances (class docstrings are already
779 automatically printed). Instances with customized docstrings
782 automatically printed). Instances with customized docstrings
780 (indep. of the class) are also recognized and all 3 separate
783 (indep. of the class) are also recognized and all 3 separate
781 docstrings are printed (instance, class, constructor). After some
784 docstrings are printed (instance, class, constructor). After some
782 comments/suggestions by J. Hunter.
785 comments/suggestions by J. Hunter.
783
786
784 2004-12-05 Fernando Perez <fperez@colorado.edu>
787 2004-12-05 Fernando Perez <fperez@colorado.edu>
785
788
786 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
789 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
787 warnings when tab-completion fails and triggers an exception.
790 warnings when tab-completion fails and triggers an exception.
788
791
789 2004-12-03 Fernando Perez <fperez@colorado.edu>
792 2004-12-03 Fernando Perez <fperez@colorado.edu>
790
793
791 * IPython/Magic.py (magic_prun): Fix bug where an exception would
794 * IPython/Magic.py (magic_prun): Fix bug where an exception would
792 be triggered when using 'run -p'. An incorrect option flag was
795 be triggered when using 'run -p'. An incorrect option flag was
793 being set ('d' instead of 'D').
796 being set ('d' instead of 'D').
794 (manpage): fix missing escaped \- sign.
797 (manpage): fix missing escaped \- sign.
795
798
796 2004-11-30 *** Released version 0.6.5
799 2004-11-30 *** Released version 0.6.5
797
800
798 2004-11-30 Fernando Perez <fperez@colorado.edu>
801 2004-11-30 Fernando Perez <fperez@colorado.edu>
799
802
800 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
803 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
801 setting with -d option.
804 setting with -d option.
802
805
803 * setup.py (docfiles): Fix problem where the doc glob I was using
806 * setup.py (docfiles): Fix problem where the doc glob I was using
804 was COMPLETELY BROKEN. It was giving the right files by pure
807 was COMPLETELY BROKEN. It was giving the right files by pure
805 accident, but failed once I tried to include ipython.el. Note:
808 accident, but failed once I tried to include ipython.el. Note:
806 glob() does NOT allow you to do exclusion on multiple endings!
809 glob() does NOT allow you to do exclusion on multiple endings!
807
810
808 2004-11-29 Fernando Perez <fperez@colorado.edu>
811 2004-11-29 Fernando Perez <fperez@colorado.edu>
809
812
810 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
813 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
811 the manpage as the source. Better formatting & consistency.
814 the manpage as the source. Better formatting & consistency.
812
815
813 * IPython/Magic.py (magic_run): Added new -d option, to run
816 * IPython/Magic.py (magic_run): Added new -d option, to run
814 scripts under the control of the python pdb debugger. Note that
817 scripts under the control of the python pdb debugger. Note that
815 this required changing the %prun option -d to -D, to avoid a clash
818 this required changing the %prun option -d to -D, to avoid a clash
816 (since %run must pass options to %prun, and getopt is too dumb to
819 (since %run must pass options to %prun, and getopt is too dumb to
817 handle options with string values with embedded spaces). Thanks
820 handle options with string values with embedded spaces). Thanks
818 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
821 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
819 (magic_who_ls): added type matching to %who and %whos, so that one
822 (magic_who_ls): added type matching to %who and %whos, so that one
820 can filter their output to only include variables of certain
823 can filter their output to only include variables of certain
821 types. Another suggestion by Matthew.
824 types. Another suggestion by Matthew.
822 (magic_whos): Added memory summaries in kb and Mb for arrays.
825 (magic_whos): Added memory summaries in kb and Mb for arrays.
823 (magic_who): Improve formatting (break lines every 9 vars).
826 (magic_who): Improve formatting (break lines every 9 vars).
824
827
825 2004-11-28 Fernando Perez <fperez@colorado.edu>
828 2004-11-28 Fernando Perez <fperez@colorado.edu>
826
829
827 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
830 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
828 cache when empty lines were present.
831 cache when empty lines were present.
829
832
830 2004-11-24 Fernando Perez <fperez@colorado.edu>
833 2004-11-24 Fernando Perez <fperez@colorado.edu>
831
834
832 * IPython/usage.py (__doc__): document the re-activated threading
835 * IPython/usage.py (__doc__): document the re-activated threading
833 options for WX and GTK.
836 options for WX and GTK.
834
837
835 2004-11-23 Fernando Perez <fperez@colorado.edu>
838 2004-11-23 Fernando Perez <fperez@colorado.edu>
836
839
837 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
840 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
838 the -wthread and -gthread options, along with a new -tk one to try
841 the -wthread and -gthread options, along with a new -tk one to try
839 and coordinate Tk threading with wx/gtk. The tk support is very
842 and coordinate Tk threading with wx/gtk. The tk support is very
840 platform dependent, since it seems to require Tcl and Tk to be
843 platform dependent, since it seems to require Tcl and Tk to be
841 built with threads (Fedora1/2 appears NOT to have it, but in
844 built with threads (Fedora1/2 appears NOT to have it, but in
842 Prabhu's Debian boxes it works OK). But even with some Tk
845 Prabhu's Debian boxes it works OK). But even with some Tk
843 limitations, this is a great improvement.
846 limitations, this is a great improvement.
844
847
845 * IPython/Prompts.py (prompt_specials_color): Added \t for time
848 * IPython/Prompts.py (prompt_specials_color): Added \t for time
846 info in user prompts. Patch by Prabhu.
849 info in user prompts. Patch by Prabhu.
847
850
848 2004-11-18 Fernando Perez <fperez@colorado.edu>
851 2004-11-18 Fernando Perez <fperez@colorado.edu>
849
852
850 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
853 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
851 EOFErrors and bail, to avoid infinite loops if a non-terminating
854 EOFErrors and bail, to avoid infinite loops if a non-terminating
852 file is fed into ipython. Patch submitted in issue 19 by user,
855 file is fed into ipython. Patch submitted in issue 19 by user,
853 many thanks.
856 many thanks.
854
857
855 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
858 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
856 autoquote/parens in continuation prompts, which can cause lots of
859 autoquote/parens in continuation prompts, which can cause lots of
857 problems. Closes roundup issue 20.
860 problems. Closes roundup issue 20.
858
861
859 2004-11-17 Fernando Perez <fperez@colorado.edu>
862 2004-11-17 Fernando Perez <fperez@colorado.edu>
860
863
861 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
864 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
862 reported as debian bug #280505. I'm not sure my local changelog
865 reported as debian bug #280505. I'm not sure my local changelog
863 entry has the proper debian format (Jack?).
866 entry has the proper debian format (Jack?).
864
867
865 2004-11-08 *** Released version 0.6.4
868 2004-11-08 *** Released version 0.6.4
866
869
867 2004-11-08 Fernando Perez <fperez@colorado.edu>
870 2004-11-08 Fernando Perez <fperez@colorado.edu>
868
871
869 * IPython/iplib.py (init_readline): Fix exit message for Windows
872 * IPython/iplib.py (init_readline): Fix exit message for Windows
870 when readline is active. Thanks to a report by Eric Jones
873 when readline is active. Thanks to a report by Eric Jones
871 <eric-AT-enthought.com>.
874 <eric-AT-enthought.com>.
872
875
873 2004-11-07 Fernando Perez <fperez@colorado.edu>
876 2004-11-07 Fernando Perez <fperez@colorado.edu>
874
877
875 * IPython/genutils.py (page): Add a trap for OSError exceptions,
878 * IPython/genutils.py (page): Add a trap for OSError exceptions,
876 sometimes seen by win2k/cygwin users.
879 sometimes seen by win2k/cygwin users.
877
880
878 2004-11-06 Fernando Perez <fperez@colorado.edu>
881 2004-11-06 Fernando Perez <fperez@colorado.edu>
879
882
880 * IPython/iplib.py (interact): Change the handling of %Exit from
883 * IPython/iplib.py (interact): Change the handling of %Exit from
881 trying to propagate a SystemExit to an internal ipython flag.
884 trying to propagate a SystemExit to an internal ipython flag.
882 This is less elegant than using Python's exception mechanism, but
885 This is less elegant than using Python's exception mechanism, but
883 I can't get that to work reliably with threads, so under -pylab
886 I can't get that to work reliably with threads, so under -pylab
884 %Exit was hanging IPython. Cross-thread exception handling is
887 %Exit was hanging IPython. Cross-thread exception handling is
885 really a bitch. Thaks to a bug report by Stephen Walton
888 really a bitch. Thaks to a bug report by Stephen Walton
886 <stephen.walton-AT-csun.edu>.
889 <stephen.walton-AT-csun.edu>.
887
890
888 2004-11-04 Fernando Perez <fperez@colorado.edu>
891 2004-11-04 Fernando Perez <fperez@colorado.edu>
889
892
890 * IPython/iplib.py (raw_input_original): store a pointer to the
893 * IPython/iplib.py (raw_input_original): store a pointer to the
891 true raw_input to harden against code which can modify it
894 true raw_input to harden against code which can modify it
892 (wx.py.PyShell does this and would otherwise crash ipython).
895 (wx.py.PyShell does this and would otherwise crash ipython).
893 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
896 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
894
897
895 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
898 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
896 Ctrl-C problem, which does not mess up the input line.
899 Ctrl-C problem, which does not mess up the input line.
897
900
898 2004-11-03 Fernando Perez <fperez@colorado.edu>
901 2004-11-03 Fernando Perez <fperez@colorado.edu>
899
902
900 * IPython/Release.py: Changed licensing to BSD, in all files.
903 * IPython/Release.py: Changed licensing to BSD, in all files.
901 (name): lowercase name for tarball/RPM release.
904 (name): lowercase name for tarball/RPM release.
902
905
903 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
906 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
904 use throughout ipython.
907 use throughout ipython.
905
908
906 * IPython/Magic.py (Magic._ofind): Switch to using the new
909 * IPython/Magic.py (Magic._ofind): Switch to using the new
907 OInspect.getdoc() function.
910 OInspect.getdoc() function.
908
911
909 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
912 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
910 of the line currently being canceled via Ctrl-C. It's extremely
913 of the line currently being canceled via Ctrl-C. It's extremely
911 ugly, but I don't know how to do it better (the problem is one of
914 ugly, but I don't know how to do it better (the problem is one of
912 handling cross-thread exceptions).
915 handling cross-thread exceptions).
913
916
914 2004-10-28 Fernando Perez <fperez@colorado.edu>
917 2004-10-28 Fernando Perez <fperez@colorado.edu>
915
918
916 * IPython/Shell.py (signal_handler): add signal handlers to trap
919 * IPython/Shell.py (signal_handler): add signal handlers to trap
917 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
920 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
918 report by Francesc Alted.
921 report by Francesc Alted.
919
922
920 2004-10-21 Fernando Perez <fperez@colorado.edu>
923 2004-10-21 Fernando Perez <fperez@colorado.edu>
921
924
922 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
925 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
923 to % for pysh syntax extensions.
926 to % for pysh syntax extensions.
924
927
925 2004-10-09 Fernando Perez <fperez@colorado.edu>
928 2004-10-09 Fernando Perez <fperez@colorado.edu>
926
929
927 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
930 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
928 arrays to print a more useful summary, without calling str(arr).
931 arrays to print a more useful summary, without calling str(arr).
929 This avoids the problem of extremely lengthy computations which
932 This avoids the problem of extremely lengthy computations which
930 occur if arr is large, and appear to the user as a system lockup
933 occur if arr is large, and appear to the user as a system lockup
931 with 100% cpu activity. After a suggestion by Kristian Sandberg
934 with 100% cpu activity. After a suggestion by Kristian Sandberg
932 <Kristian.Sandberg@colorado.edu>.
935 <Kristian.Sandberg@colorado.edu>.
933 (Magic.__init__): fix bug in global magic escapes not being
936 (Magic.__init__): fix bug in global magic escapes not being
934 correctly set.
937 correctly set.
935
938
936 2004-10-08 Fernando Perez <fperez@colorado.edu>
939 2004-10-08 Fernando Perez <fperez@colorado.edu>
937
940
938 * IPython/Magic.py (__license__): change to absolute imports of
941 * IPython/Magic.py (__license__): change to absolute imports of
939 ipython's own internal packages, to start adapting to the absolute
942 ipython's own internal packages, to start adapting to the absolute
940 import requirement of PEP-328.
943 import requirement of PEP-328.
941
944
942 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
945 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
943 files, and standardize author/license marks through the Release
946 files, and standardize author/license marks through the Release
944 module instead of having per/file stuff (except for files with
947 module instead of having per/file stuff (except for files with
945 particular licenses, like the MIT/PSF-licensed codes).
948 particular licenses, like the MIT/PSF-licensed codes).
946
949
947 * IPython/Debugger.py: remove dead code for python 2.1
950 * IPython/Debugger.py: remove dead code for python 2.1
948
951
949 2004-10-04 Fernando Perez <fperez@colorado.edu>
952 2004-10-04 Fernando Perez <fperez@colorado.edu>
950
953
951 * IPython/iplib.py (ipmagic): New function for accessing magics
954 * IPython/iplib.py (ipmagic): New function for accessing magics
952 via a normal python function call.
955 via a normal python function call.
953
956
954 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
957 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
955 from '@' to '%', to accomodate the new @decorator syntax of python
958 from '@' to '%', to accomodate the new @decorator syntax of python
956 2.4.
959 2.4.
957
960
958 2004-09-29 Fernando Perez <fperez@colorado.edu>
961 2004-09-29 Fernando Perez <fperez@colorado.edu>
959
962
960 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
963 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
961 matplotlib.use to prevent running scripts which try to switch
964 matplotlib.use to prevent running scripts which try to switch
962 interactive backends from within ipython. This will just crash
965 interactive backends from within ipython. This will just crash
963 the python interpreter, so we can't allow it (but a detailed error
966 the python interpreter, so we can't allow it (but a detailed error
964 is given to the user).
967 is given to the user).
965
968
966 2004-09-28 Fernando Perez <fperez@colorado.edu>
969 2004-09-28 Fernando Perez <fperez@colorado.edu>
967
970
968 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
971 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
969 matplotlib-related fixes so that using @run with non-matplotlib
972 matplotlib-related fixes so that using @run with non-matplotlib
970 scripts doesn't pop up spurious plot windows. This requires
973 scripts doesn't pop up spurious plot windows. This requires
971 matplotlib >= 0.63, where I had to make some changes as well.
974 matplotlib >= 0.63, where I had to make some changes as well.
972
975
973 * IPython/ipmaker.py (make_IPython): update version requirement to
976 * IPython/ipmaker.py (make_IPython): update version requirement to
974 python 2.2.
977 python 2.2.
975
978
976 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
979 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
977 banner arg for embedded customization.
980 banner arg for embedded customization.
978
981
979 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
982 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
980 explicit uses of __IP as the IPython's instance name. Now things
983 explicit uses of __IP as the IPython's instance name. Now things
981 are properly handled via the shell.name value. The actual code
984 are properly handled via the shell.name value. The actual code
982 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
985 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
983 is much better than before. I'll clean things completely when the
986 is much better than before. I'll clean things completely when the
984 magic stuff gets a real overhaul.
987 magic stuff gets a real overhaul.
985
988
986 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
989 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
987 minor changes to debian dir.
990 minor changes to debian dir.
988
991
989 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
992 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
990 pointer to the shell itself in the interactive namespace even when
993 pointer to the shell itself in the interactive namespace even when
991 a user-supplied dict is provided. This is needed for embedding
994 a user-supplied dict is provided. This is needed for embedding
992 purposes (found by tests with Michel Sanner).
995 purposes (found by tests with Michel Sanner).
993
996
994 2004-09-27 Fernando Perez <fperez@colorado.edu>
997 2004-09-27 Fernando Perez <fperez@colorado.edu>
995
998
996 * IPython/UserConfig/ipythonrc: remove []{} from
999 * IPython/UserConfig/ipythonrc: remove []{} from
997 readline_remove_delims, so that things like [modname.<TAB> do
1000 readline_remove_delims, so that things like [modname.<TAB> do
998 proper completion. This disables [].TAB, but that's a less common
1001 proper completion. This disables [].TAB, but that's a less common
999 case than module names in list comprehensions, for example.
1002 case than module names in list comprehensions, for example.
1000 Thanks to a report by Andrea Riciputi.
1003 Thanks to a report by Andrea Riciputi.
1001
1004
1002 2004-09-09 Fernando Perez <fperez@colorado.edu>
1005 2004-09-09 Fernando Perez <fperez@colorado.edu>
1003
1006
1004 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1007 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1005 blocking problems in win32 and osx. Fix by John.
1008 blocking problems in win32 and osx. Fix by John.
1006
1009
1007 2004-09-08 Fernando Perez <fperez@colorado.edu>
1010 2004-09-08 Fernando Perez <fperez@colorado.edu>
1008
1011
1009 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1012 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1010 for Win32 and OSX. Fix by John Hunter.
1013 for Win32 and OSX. Fix by John Hunter.
1011
1014
1012 2004-08-30 *** Released version 0.6.3
1015 2004-08-30 *** Released version 0.6.3
1013
1016
1014 2004-08-30 Fernando Perez <fperez@colorado.edu>
1017 2004-08-30 Fernando Perez <fperez@colorado.edu>
1015
1018
1016 * setup.py (isfile): Add manpages to list of dependent files to be
1019 * setup.py (isfile): Add manpages to list of dependent files to be
1017 updated.
1020 updated.
1018
1021
1019 2004-08-27 Fernando Perez <fperez@colorado.edu>
1022 2004-08-27 Fernando Perez <fperez@colorado.edu>
1020
1023
1021 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1024 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1022 for now. They don't really work with standalone WX/GTK code
1025 for now. They don't really work with standalone WX/GTK code
1023 (though matplotlib IS working fine with both of those backends).
1026 (though matplotlib IS working fine with both of those backends).
1024 This will neeed much more testing. I disabled most things with
1027 This will neeed much more testing. I disabled most things with
1025 comments, so turning it back on later should be pretty easy.
1028 comments, so turning it back on later should be pretty easy.
1026
1029
1027 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1030 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1028 autocalling of expressions like r'foo', by modifying the line
1031 autocalling of expressions like r'foo', by modifying the line
1029 split regexp. Closes
1032 split regexp. Closes
1030 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1033 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1031 Riley <ipythonbugs-AT-sabi.net>.
1034 Riley <ipythonbugs-AT-sabi.net>.
1032 (InteractiveShell.mainloop): honor --nobanner with banner
1035 (InteractiveShell.mainloop): honor --nobanner with banner
1033 extensions.
1036 extensions.
1034
1037
1035 * IPython/Shell.py: Significant refactoring of all classes, so
1038 * IPython/Shell.py: Significant refactoring of all classes, so
1036 that we can really support ALL matplotlib backends and threading
1039 that we can really support ALL matplotlib backends and threading
1037 models (John spotted a bug with Tk which required this). Now we
1040 models (John spotted a bug with Tk which required this). Now we
1038 should support single-threaded, WX-threads and GTK-threads, both
1041 should support single-threaded, WX-threads and GTK-threads, both
1039 for generic code and for matplotlib.
1042 for generic code and for matplotlib.
1040
1043
1041 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1044 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1042 -pylab, to simplify things for users. Will also remove the pylab
1045 -pylab, to simplify things for users. Will also remove the pylab
1043 profile, since now all of matplotlib configuration is directly
1046 profile, since now all of matplotlib configuration is directly
1044 handled here. This also reduces startup time.
1047 handled here. This also reduces startup time.
1045
1048
1046 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1049 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1047 shell wasn't being correctly called. Also in IPShellWX.
1050 shell wasn't being correctly called. Also in IPShellWX.
1048
1051
1049 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1052 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1050 fine-tune banner.
1053 fine-tune banner.
1051
1054
1052 * IPython/numutils.py (spike): Deprecate these spike functions,
1055 * IPython/numutils.py (spike): Deprecate these spike functions,
1053 delete (long deprecated) gnuplot_exec handler.
1056 delete (long deprecated) gnuplot_exec handler.
1054
1057
1055 2004-08-26 Fernando Perez <fperez@colorado.edu>
1058 2004-08-26 Fernando Perez <fperez@colorado.edu>
1056
1059
1057 * ipython.1: Update for threading options, plus some others which
1060 * ipython.1: Update for threading options, plus some others which
1058 were missing.
1061 were missing.
1059
1062
1060 * IPython/ipmaker.py (__call__): Added -wthread option for
1063 * IPython/ipmaker.py (__call__): Added -wthread option for
1061 wxpython thread handling. Make sure threading options are only
1064 wxpython thread handling. Make sure threading options are only
1062 valid at the command line.
1065 valid at the command line.
1063
1066
1064 * scripts/ipython: moved shell selection into a factory function
1067 * scripts/ipython: moved shell selection into a factory function
1065 in Shell.py, to keep the starter script to a minimum.
1068 in Shell.py, to keep the starter script to a minimum.
1066
1069
1067 2004-08-25 Fernando Perez <fperez@colorado.edu>
1070 2004-08-25 Fernando Perez <fperez@colorado.edu>
1068
1071
1069 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1072 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1070 John. Along with some recent changes he made to matplotlib, the
1073 John. Along with some recent changes he made to matplotlib, the
1071 next versions of both systems should work very well together.
1074 next versions of both systems should work very well together.
1072
1075
1073 2004-08-24 Fernando Perez <fperez@colorado.edu>
1076 2004-08-24 Fernando Perez <fperez@colorado.edu>
1074
1077
1075 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1078 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1076 tried to switch the profiling to using hotshot, but I'm getting
1079 tried to switch the profiling to using hotshot, but I'm getting
1077 strange errors from prof.runctx() there. I may be misreading the
1080 strange errors from prof.runctx() there. I may be misreading the
1078 docs, but it looks weird. For now the profiling code will
1081 docs, but it looks weird. For now the profiling code will
1079 continue to use the standard profiler.
1082 continue to use the standard profiler.
1080
1083
1081 2004-08-23 Fernando Perez <fperez@colorado.edu>
1084 2004-08-23 Fernando Perez <fperez@colorado.edu>
1082
1085
1083 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1086 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1084 threaded shell, by John Hunter. It's not quite ready yet, but
1087 threaded shell, by John Hunter. It's not quite ready yet, but
1085 close.
1088 close.
1086
1089
1087 2004-08-22 Fernando Perez <fperez@colorado.edu>
1090 2004-08-22 Fernando Perez <fperez@colorado.edu>
1088
1091
1089 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1092 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1090 in Magic and ultraTB.
1093 in Magic and ultraTB.
1091
1094
1092 * ipython.1: document threading options in manpage.
1095 * ipython.1: document threading options in manpage.
1093
1096
1094 * scripts/ipython: Changed name of -thread option to -gthread,
1097 * scripts/ipython: Changed name of -thread option to -gthread,
1095 since this is GTK specific. I want to leave the door open for a
1098 since this is GTK specific. I want to leave the door open for a
1096 -wthread option for WX, which will most likely be necessary. This
1099 -wthread option for WX, which will most likely be necessary. This
1097 change affects usage and ipmaker as well.
1100 change affects usage and ipmaker as well.
1098
1101
1099 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1102 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1100 handle the matplotlib shell issues. Code by John Hunter
1103 handle the matplotlib shell issues. Code by John Hunter
1101 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1104 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1102 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1105 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1103 broken (and disabled for end users) for now, but it puts the
1106 broken (and disabled for end users) for now, but it puts the
1104 infrastructure in place.
1107 infrastructure in place.
1105
1108
1106 2004-08-21 Fernando Perez <fperez@colorado.edu>
1109 2004-08-21 Fernando Perez <fperez@colorado.edu>
1107
1110
1108 * ipythonrc-pylab: Add matplotlib support.
1111 * ipythonrc-pylab: Add matplotlib support.
1109
1112
1110 * matplotlib_config.py: new files for matplotlib support, part of
1113 * matplotlib_config.py: new files for matplotlib support, part of
1111 the pylab profile.
1114 the pylab profile.
1112
1115
1113 * IPython/usage.py (__doc__): documented the threading options.
1116 * IPython/usage.py (__doc__): documented the threading options.
1114
1117
1115 2004-08-20 Fernando Perez <fperez@colorado.edu>
1118 2004-08-20 Fernando Perez <fperez@colorado.edu>
1116
1119
1117 * ipython: Modified the main calling routine to handle the -thread
1120 * ipython: Modified the main calling routine to handle the -thread
1118 and -mpthread options. This needs to be done as a top-level hack,
1121 and -mpthread options. This needs to be done as a top-level hack,
1119 because it determines which class to instantiate for IPython
1122 because it determines which class to instantiate for IPython
1120 itself.
1123 itself.
1121
1124
1122 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1125 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1123 classes to support multithreaded GTK operation without blocking,
1126 classes to support multithreaded GTK operation without blocking,
1124 and matplotlib with all backends. This is a lot of still very
1127 and matplotlib with all backends. This is a lot of still very
1125 experimental code, and threads are tricky. So it may still have a
1128 experimental code, and threads are tricky. So it may still have a
1126 few rough edges... This code owes a lot to
1129 few rough edges... This code owes a lot to
1127 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1130 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1128 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1131 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1129 to John Hunter for all the matplotlib work.
1132 to John Hunter for all the matplotlib work.
1130
1133
1131 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1134 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1132 options for gtk thread and matplotlib support.
1135 options for gtk thread and matplotlib support.
1133
1136
1134 2004-08-16 Fernando Perez <fperez@colorado.edu>
1137 2004-08-16 Fernando Perez <fperez@colorado.edu>
1135
1138
1136 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1139 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1137 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1140 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1138 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1141 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1139
1142
1140 2004-08-11 Fernando Perez <fperez@colorado.edu>
1143 2004-08-11 Fernando Perez <fperez@colorado.edu>
1141
1144
1142 * setup.py (isfile): Fix build so documentation gets updated for
1145 * setup.py (isfile): Fix build so documentation gets updated for
1143 rpms (it was only done for .tgz builds).
1146 rpms (it was only done for .tgz builds).
1144
1147
1145 2004-08-10 Fernando Perez <fperez@colorado.edu>
1148 2004-08-10 Fernando Perez <fperez@colorado.edu>
1146
1149
1147 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1150 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1148
1151
1149 * iplib.py : Silence syntax error exceptions in tab-completion.
1152 * iplib.py : Silence syntax error exceptions in tab-completion.
1150
1153
1151 2004-08-05 Fernando Perez <fperez@colorado.edu>
1154 2004-08-05 Fernando Perez <fperez@colorado.edu>
1152
1155
1153 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1156 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1154 'color off' mark for continuation prompts. This was causing long
1157 'color off' mark for continuation prompts. This was causing long
1155 continuation lines to mis-wrap.
1158 continuation lines to mis-wrap.
1156
1159
1157 2004-08-01 Fernando Perez <fperez@colorado.edu>
1160 2004-08-01 Fernando Perez <fperez@colorado.edu>
1158
1161
1159 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1162 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1160 for building ipython to be a parameter. All this is necessary
1163 for building ipython to be a parameter. All this is necessary
1161 right now to have a multithreaded version, but this insane
1164 right now to have a multithreaded version, but this insane
1162 non-design will be cleaned up soon. For now, it's a hack that
1165 non-design will be cleaned up soon. For now, it's a hack that
1163 works.
1166 works.
1164
1167
1165 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1168 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1166 args in various places. No bugs so far, but it's a dangerous
1169 args in various places. No bugs so far, but it's a dangerous
1167 practice.
1170 practice.
1168
1171
1169 2004-07-31 Fernando Perez <fperez@colorado.edu>
1172 2004-07-31 Fernando Perez <fperez@colorado.edu>
1170
1173
1171 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1174 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1172 fix completion of files with dots in their names under most
1175 fix completion of files with dots in their names under most
1173 profiles (pysh was OK because the completion order is different).
1176 profiles (pysh was OK because the completion order is different).
1174
1177
1175 2004-07-27 Fernando Perez <fperez@colorado.edu>
1178 2004-07-27 Fernando Perez <fperez@colorado.edu>
1176
1179
1177 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1180 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1178 keywords manually, b/c the one in keyword.py was removed in python
1181 keywords manually, b/c the one in keyword.py was removed in python
1179 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1182 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1180 This is NOT a bug under python 2.3 and earlier.
1183 This is NOT a bug under python 2.3 and earlier.
1181
1184
1182 2004-07-26 Fernando Perez <fperez@colorado.edu>
1185 2004-07-26 Fernando Perez <fperez@colorado.edu>
1183
1186
1184 * IPython/ultraTB.py (VerboseTB.text): Add another
1187 * IPython/ultraTB.py (VerboseTB.text): Add another
1185 linecache.checkcache() call to try to prevent inspect.py from
1188 linecache.checkcache() call to try to prevent inspect.py from
1186 crashing under python 2.3. I think this fixes
1189 crashing under python 2.3. I think this fixes
1187 http://www.scipy.net/roundup/ipython/issue17.
1190 http://www.scipy.net/roundup/ipython/issue17.
1188
1191
1189 2004-07-26 *** Released version 0.6.2
1192 2004-07-26 *** Released version 0.6.2
1190
1193
1191 2004-07-26 Fernando Perez <fperez@colorado.edu>
1194 2004-07-26 Fernando Perez <fperez@colorado.edu>
1192
1195
1193 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1196 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1194 fail for any number.
1197 fail for any number.
1195 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1198 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1196 empty bookmarks.
1199 empty bookmarks.
1197
1200
1198 2004-07-26 *** Released version 0.6.1
1201 2004-07-26 *** Released version 0.6.1
1199
1202
1200 2004-07-26 Fernando Perez <fperez@colorado.edu>
1203 2004-07-26 Fernando Perez <fperez@colorado.edu>
1201
1204
1202 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1205 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1203
1206
1204 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1207 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1205 escaping '()[]{}' in filenames.
1208 escaping '()[]{}' in filenames.
1206
1209
1207 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1210 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1208 Python 2.2 users who lack a proper shlex.split.
1211 Python 2.2 users who lack a proper shlex.split.
1209
1212
1210 2004-07-19 Fernando Perez <fperez@colorado.edu>
1213 2004-07-19 Fernando Perez <fperez@colorado.edu>
1211
1214
1212 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1215 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1213 for reading readline's init file. I follow the normal chain:
1216 for reading readline's init file. I follow the normal chain:
1214 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1217 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1215 report by Mike Heeter. This closes
1218 report by Mike Heeter. This closes
1216 http://www.scipy.net/roundup/ipython/issue16.
1219 http://www.scipy.net/roundup/ipython/issue16.
1217
1220
1218 2004-07-18 Fernando Perez <fperez@colorado.edu>
1221 2004-07-18 Fernando Perez <fperez@colorado.edu>
1219
1222
1220 * IPython/iplib.py (__init__): Add better handling of '\' under
1223 * IPython/iplib.py (__init__): Add better handling of '\' under
1221 Win32 for filenames. After a patch by Ville.
1224 Win32 for filenames. After a patch by Ville.
1222
1225
1223 2004-07-17 Fernando Perez <fperez@colorado.edu>
1226 2004-07-17 Fernando Perez <fperez@colorado.edu>
1224
1227
1225 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1228 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1226 autocalling would be triggered for 'foo is bar' if foo is
1229 autocalling would be triggered for 'foo is bar' if foo is
1227 callable. I also cleaned up the autocall detection code to use a
1230 callable. I also cleaned up the autocall detection code to use a
1228 regexp, which is faster. Bug reported by Alexander Schmolck.
1231 regexp, which is faster. Bug reported by Alexander Schmolck.
1229
1232
1230 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1233 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1231 '?' in them would confuse the help system. Reported by Alex
1234 '?' in them would confuse the help system. Reported by Alex
1232 Schmolck.
1235 Schmolck.
1233
1236
1234 2004-07-16 Fernando Perez <fperez@colorado.edu>
1237 2004-07-16 Fernando Perez <fperez@colorado.edu>
1235
1238
1236 * IPython/GnuplotInteractive.py (__all__): added plot2.
1239 * IPython/GnuplotInteractive.py (__all__): added plot2.
1237
1240
1238 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1241 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1239 plotting dictionaries, lists or tuples of 1d arrays.
1242 plotting dictionaries, lists or tuples of 1d arrays.
1240
1243
1241 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1244 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1242 optimizations.
1245 optimizations.
1243
1246
1244 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1247 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1245 the information which was there from Janko's original IPP code:
1248 the information which was there from Janko's original IPP code:
1246
1249
1247 03.05.99 20:53 porto.ifm.uni-kiel.de
1250 03.05.99 20:53 porto.ifm.uni-kiel.de
1248 --Started changelog.
1251 --Started changelog.
1249 --make clear do what it say it does
1252 --make clear do what it say it does
1250 --added pretty output of lines from inputcache
1253 --added pretty output of lines from inputcache
1251 --Made Logger a mixin class, simplifies handling of switches
1254 --Made Logger a mixin class, simplifies handling of switches
1252 --Added own completer class. .string<TAB> expands to last history
1255 --Added own completer class. .string<TAB> expands to last history
1253 line which starts with string. The new expansion is also present
1256 line which starts with string. The new expansion is also present
1254 with Ctrl-r from the readline library. But this shows, who this
1257 with Ctrl-r from the readline library. But this shows, who this
1255 can be done for other cases.
1258 can be done for other cases.
1256 --Added convention that all shell functions should accept a
1259 --Added convention that all shell functions should accept a
1257 parameter_string This opens the door for different behaviour for
1260 parameter_string This opens the door for different behaviour for
1258 each function. @cd is a good example of this.
1261 each function. @cd is a good example of this.
1259
1262
1260 04.05.99 12:12 porto.ifm.uni-kiel.de
1263 04.05.99 12:12 porto.ifm.uni-kiel.de
1261 --added logfile rotation
1264 --added logfile rotation
1262 --added new mainloop method which freezes first the namespace
1265 --added new mainloop method which freezes first the namespace
1263
1266
1264 07.05.99 21:24 porto.ifm.uni-kiel.de
1267 07.05.99 21:24 porto.ifm.uni-kiel.de
1265 --added the docreader classes. Now there is a help system.
1268 --added the docreader classes. Now there is a help system.
1266 -This is only a first try. Currently it's not easy to put new
1269 -This is only a first try. Currently it's not easy to put new
1267 stuff in the indices. But this is the way to go. Info would be
1270 stuff in the indices. But this is the way to go. Info would be
1268 better, but HTML is every where and not everybody has an info
1271 better, but HTML is every where and not everybody has an info
1269 system installed and it's not so easy to change html-docs to info.
1272 system installed and it's not so easy to change html-docs to info.
1270 --added global logfile option
1273 --added global logfile option
1271 --there is now a hook for object inspection method pinfo needs to
1274 --there is now a hook for object inspection method pinfo needs to
1272 be provided for this. Can be reached by two '??'.
1275 be provided for this. Can be reached by two '??'.
1273
1276
1274 08.05.99 20:51 porto.ifm.uni-kiel.de
1277 08.05.99 20:51 porto.ifm.uni-kiel.de
1275 --added a README
1278 --added a README
1276 --bug in rc file. Something has changed so functions in the rc
1279 --bug in rc file. Something has changed so functions in the rc
1277 file need to reference the shell and not self. Not clear if it's a
1280 file need to reference the shell and not self. Not clear if it's a
1278 bug or feature.
1281 bug or feature.
1279 --changed rc file for new behavior
1282 --changed rc file for new behavior
1280
1283
1281 2004-07-15 Fernando Perez <fperez@colorado.edu>
1284 2004-07-15 Fernando Perez <fperez@colorado.edu>
1282
1285
1283 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1286 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1284 cache was falling out of sync in bizarre manners when multi-line
1287 cache was falling out of sync in bizarre manners when multi-line
1285 input was present. Minor optimizations and cleanup.
1288 input was present. Minor optimizations and cleanup.
1286
1289
1287 (Logger): Remove old Changelog info for cleanup. This is the
1290 (Logger): Remove old Changelog info for cleanup. This is the
1288 information which was there from Janko's original code:
1291 information which was there from Janko's original code:
1289
1292
1290 Changes to Logger: - made the default log filename a parameter
1293 Changes to Logger: - made the default log filename a parameter
1291
1294
1292 - put a check for lines beginning with !@? in log(). Needed
1295 - put a check for lines beginning with !@? in log(). Needed
1293 (even if the handlers properly log their lines) for mid-session
1296 (even if the handlers properly log their lines) for mid-session
1294 logging activation to work properly. Without this, lines logged
1297 logging activation to work properly. Without this, lines logged
1295 in mid session, which get read from the cache, would end up
1298 in mid session, which get read from the cache, would end up
1296 'bare' (with !@? in the open) in the log. Now they are caught
1299 'bare' (with !@? in the open) in the log. Now they are caught
1297 and prepended with a #.
1300 and prepended with a #.
1298
1301
1299 * IPython/iplib.py (InteractiveShell.init_readline): added check
1302 * IPython/iplib.py (InteractiveShell.init_readline): added check
1300 in case MagicCompleter fails to be defined, so we don't crash.
1303 in case MagicCompleter fails to be defined, so we don't crash.
1301
1304
1302 2004-07-13 Fernando Perez <fperez@colorado.edu>
1305 2004-07-13 Fernando Perez <fperez@colorado.edu>
1303
1306
1304 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1307 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1305 of EPS if the requested filename ends in '.eps'.
1308 of EPS if the requested filename ends in '.eps'.
1306
1309
1307 2004-07-04 Fernando Perez <fperez@colorado.edu>
1310 2004-07-04 Fernando Perez <fperez@colorado.edu>
1308
1311
1309 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1312 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1310 escaping of quotes when calling the shell.
1313 escaping of quotes when calling the shell.
1311
1314
1312 2004-07-02 Fernando Perez <fperez@colorado.edu>
1315 2004-07-02 Fernando Perez <fperez@colorado.edu>
1313
1316
1314 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1317 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1315 gettext not working because we were clobbering '_'. Fixes
1318 gettext not working because we were clobbering '_'. Fixes
1316 http://www.scipy.net/roundup/ipython/issue6.
1319 http://www.scipy.net/roundup/ipython/issue6.
1317
1320
1318 2004-07-01 Fernando Perez <fperez@colorado.edu>
1321 2004-07-01 Fernando Perez <fperez@colorado.edu>
1319
1322
1320 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1323 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1321 into @cd. Patch by Ville.
1324 into @cd. Patch by Ville.
1322
1325
1323 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1326 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1324 new function to store things after ipmaker runs. Patch by Ville.
1327 new function to store things after ipmaker runs. Patch by Ville.
1325 Eventually this will go away once ipmaker is removed and the class
1328 Eventually this will go away once ipmaker is removed and the class
1326 gets cleaned up, but for now it's ok. Key functionality here is
1329 gets cleaned up, but for now it's ok. Key functionality here is
1327 the addition of the persistent storage mechanism, a dict for
1330 the addition of the persistent storage mechanism, a dict for
1328 keeping data across sessions (for now just bookmarks, but more can
1331 keeping data across sessions (for now just bookmarks, but more can
1329 be implemented later).
1332 be implemented later).
1330
1333
1331 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
1334 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
1332 persistent across sections. Patch by Ville, I modified it
1335 persistent across sections. Patch by Ville, I modified it
1333 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
1336 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
1334 added a '-l' option to list all bookmarks.
1337 added a '-l' option to list all bookmarks.
1335
1338
1336 * IPython/iplib.py (InteractiveShell.atexit_operations): new
1339 * IPython/iplib.py (InteractiveShell.atexit_operations): new
1337 center for cleanup. Registered with atexit.register(). I moved
1340 center for cleanup. Registered with atexit.register(). I moved
1338 here the old exit_cleanup(). After a patch by Ville.
1341 here the old exit_cleanup(). After a patch by Ville.
1339
1342
1340 * IPython/Magic.py (get_py_filename): added '~' to the accepted
1343 * IPython/Magic.py (get_py_filename): added '~' to the accepted
1341 characters in the hacked shlex_split for python 2.2.
1344 characters in the hacked shlex_split for python 2.2.
1342
1345
1343 * IPython/iplib.py (file_matches): more fixes to filenames with
1346 * IPython/iplib.py (file_matches): more fixes to filenames with
1344 whitespace in them. It's not perfect, but limitations in python's
1347 whitespace in them. It's not perfect, but limitations in python's
1345 readline make it impossible to go further.
1348 readline make it impossible to go further.
1346
1349
1347 2004-06-29 Fernando Perez <fperez@colorado.edu>
1350 2004-06-29 Fernando Perez <fperez@colorado.edu>
1348
1351
1349 * IPython/iplib.py (file_matches): escape whitespace correctly in
1352 * IPython/iplib.py (file_matches): escape whitespace correctly in
1350 filename completions. Bug reported by Ville.
1353 filename completions. Bug reported by Ville.
1351
1354
1352 2004-06-28 Fernando Perez <fperez@colorado.edu>
1355 2004-06-28 Fernando Perez <fperez@colorado.edu>
1353
1356
1354 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
1357 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
1355 the history file will be called 'history-PROFNAME' (or just
1358 the history file will be called 'history-PROFNAME' (or just
1356 'history' if no profile is loaded). I was getting annoyed at
1359 'history' if no profile is loaded). I was getting annoyed at
1357 getting my Numerical work history clobbered by pysh sessions.
1360 getting my Numerical work history clobbered by pysh sessions.
1358
1361
1359 * IPython/iplib.py (InteractiveShell.__init__): Internal
1362 * IPython/iplib.py (InteractiveShell.__init__): Internal
1360 getoutputerror() function so that we can honor the system_verbose
1363 getoutputerror() function so that we can honor the system_verbose
1361 flag for _all_ system calls. I also added escaping of #
1364 flag for _all_ system calls. I also added escaping of #
1362 characters here to avoid confusing Itpl.
1365 characters here to avoid confusing Itpl.
1363
1366
1364 * IPython/Magic.py (shlex_split): removed call to shell in
1367 * IPython/Magic.py (shlex_split): removed call to shell in
1365 parse_options and replaced it with shlex.split(). The annoying
1368 parse_options and replaced it with shlex.split(). The annoying
1366 part was that in Python 2.2, shlex.split() doesn't exist, so I had
1369 part was that in Python 2.2, shlex.split() doesn't exist, so I had
1367 to backport it from 2.3, with several frail hacks (the shlex
1370 to backport it from 2.3, with several frail hacks (the shlex
1368 module is rather limited in 2.2). Thanks to a suggestion by Ville
1371 module is rather limited in 2.2). Thanks to a suggestion by Ville
1369 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
1372 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
1370 problem.
1373 problem.
1371
1374
1372 (Magic.magic_system_verbose): new toggle to print the actual
1375 (Magic.magic_system_verbose): new toggle to print the actual
1373 system calls made by ipython. Mainly for debugging purposes.
1376 system calls made by ipython. Mainly for debugging purposes.
1374
1377
1375 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
1378 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
1376 doesn't support persistence. Reported (and fix suggested) by
1379 doesn't support persistence. Reported (and fix suggested) by
1377 Travis Caldwell <travis_caldwell2000@yahoo.com>.
1380 Travis Caldwell <travis_caldwell2000@yahoo.com>.
1378
1381
1379 2004-06-26 Fernando Perez <fperez@colorado.edu>
1382 2004-06-26 Fernando Perez <fperez@colorado.edu>
1380
1383
1381 * IPython/Logger.py (Logger.log): fix to handle correctly empty
1384 * IPython/Logger.py (Logger.log): fix to handle correctly empty
1382 continue prompts.
1385 continue prompts.
1383
1386
1384 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
1387 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
1385 function (basically a big docstring) and a few more things here to
1388 function (basically a big docstring) and a few more things here to
1386 speedup startup. pysh.py is now very lightweight. We want because
1389 speedup startup. pysh.py is now very lightweight. We want because
1387 it gets execfile'd, while InterpreterExec gets imported, so
1390 it gets execfile'd, while InterpreterExec gets imported, so
1388 byte-compilation saves time.
1391 byte-compilation saves time.
1389
1392
1390 2004-06-25 Fernando Perez <fperez@colorado.edu>
1393 2004-06-25 Fernando Perez <fperez@colorado.edu>
1391
1394
1392 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
1395 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
1393 -NUM', which was recently broken.
1396 -NUM', which was recently broken.
1394
1397
1395 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
1398 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
1396 in multi-line input (but not !!, which doesn't make sense there).
1399 in multi-line input (but not !!, which doesn't make sense there).
1397
1400
1398 * IPython/UserConfig/ipythonrc: made autoindent on by default.
1401 * IPython/UserConfig/ipythonrc: made autoindent on by default.
1399 It's just too useful, and people can turn it off in the less
1402 It's just too useful, and people can turn it off in the less
1400 common cases where it's a problem.
1403 common cases where it's a problem.
1401
1404
1402 2004-06-24 Fernando Perez <fperez@colorado.edu>
1405 2004-06-24 Fernando Perez <fperez@colorado.edu>
1403
1406
1404 * IPython/iplib.py (InteractiveShell._prefilter): big change -
1407 * IPython/iplib.py (InteractiveShell._prefilter): big change -
1405 special syntaxes (like alias calling) is now allied in multi-line
1408 special syntaxes (like alias calling) is now allied in multi-line
1406 input. This is still _very_ experimental, but it's necessary for
1409 input. This is still _very_ experimental, but it's necessary for
1407 efficient shell usage combining python looping syntax with system
1410 efficient shell usage combining python looping syntax with system
1408 calls. For now it's restricted to aliases, I don't think it
1411 calls. For now it's restricted to aliases, I don't think it
1409 really even makes sense to have this for magics.
1412 really even makes sense to have this for magics.
1410
1413
1411 2004-06-23 Fernando Perez <fperez@colorado.edu>
1414 2004-06-23 Fernando Perez <fperez@colorado.edu>
1412
1415
1413 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
1416 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
1414 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
1417 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
1415
1418
1416 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
1419 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
1417 extensions under Windows (after code sent by Gary Bishop). The
1420 extensions under Windows (after code sent by Gary Bishop). The
1418 extensions considered 'executable' are stored in IPython's rc
1421 extensions considered 'executable' are stored in IPython's rc
1419 structure as win_exec_ext.
1422 structure as win_exec_ext.
1420
1423
1421 * IPython/genutils.py (shell): new function, like system() but
1424 * IPython/genutils.py (shell): new function, like system() but
1422 without return value. Very useful for interactive shell work.
1425 without return value. Very useful for interactive shell work.
1423
1426
1424 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
1427 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
1425 delete aliases.
1428 delete aliases.
1426
1429
1427 * IPython/iplib.py (InteractiveShell.alias_table_update): make
1430 * IPython/iplib.py (InteractiveShell.alias_table_update): make
1428 sure that the alias table doesn't contain python keywords.
1431 sure that the alias table doesn't contain python keywords.
1429
1432
1430 2004-06-21 Fernando Perez <fperez@colorado.edu>
1433 2004-06-21 Fernando Perez <fperez@colorado.edu>
1431
1434
1432 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
1435 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
1433 non-existent items are found in $PATH. Reported by Thorsten.
1436 non-existent items are found in $PATH. Reported by Thorsten.
1434
1437
1435 2004-06-20 Fernando Perez <fperez@colorado.edu>
1438 2004-06-20 Fernando Perez <fperez@colorado.edu>
1436
1439
1437 * IPython/iplib.py (complete): modified the completer so that the
1440 * IPython/iplib.py (complete): modified the completer so that the
1438 order of priorities can be easily changed at runtime.
1441 order of priorities can be easily changed at runtime.
1439
1442
1440 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
1443 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
1441 Modified to auto-execute all lines beginning with '~', '/' or '.'.
1444 Modified to auto-execute all lines beginning with '~', '/' or '.'.
1442
1445
1443 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
1446 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
1444 expand Python variables prepended with $ in all system calls. The
1447 expand Python variables prepended with $ in all system calls. The
1445 same was done to InteractiveShell.handle_shell_escape. Now all
1448 same was done to InteractiveShell.handle_shell_escape. Now all
1446 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
1449 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
1447 expansion of python variables and expressions according to the
1450 expansion of python variables and expressions according to the
1448 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
1451 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
1449
1452
1450 Though PEP-215 has been rejected, a similar (but simpler) one
1453 Though PEP-215 has been rejected, a similar (but simpler) one
1451 seems like it will go into Python 2.4, PEP-292 -
1454 seems like it will go into Python 2.4, PEP-292 -
1452 http://www.python.org/peps/pep-0292.html.
1455 http://www.python.org/peps/pep-0292.html.
1453
1456
1454 I'll keep the full syntax of PEP-215, since IPython has since the
1457 I'll keep the full syntax of PEP-215, since IPython has since the
1455 start used Ka-Ping Yee's reference implementation discussed there
1458 start used Ka-Ping Yee's reference implementation discussed there
1456 (Itpl), and I actually like the powerful semantics it offers.
1459 (Itpl), and I actually like the powerful semantics it offers.
1457
1460
1458 In order to access normal shell variables, the $ has to be escaped
1461 In order to access normal shell variables, the $ has to be escaped
1459 via an extra $. For example:
1462 via an extra $. For example:
1460
1463
1461 In [7]: PATH='a python variable'
1464 In [7]: PATH='a python variable'
1462
1465
1463 In [8]: !echo $PATH
1466 In [8]: !echo $PATH
1464 a python variable
1467 a python variable
1465
1468
1466 In [9]: !echo $$PATH
1469 In [9]: !echo $$PATH
1467 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1470 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1468
1471
1469 (Magic.parse_options): escape $ so the shell doesn't evaluate
1472 (Magic.parse_options): escape $ so the shell doesn't evaluate
1470 things prematurely.
1473 things prematurely.
1471
1474
1472 * IPython/iplib.py (InteractiveShell.call_alias): added the
1475 * IPython/iplib.py (InteractiveShell.call_alias): added the
1473 ability for aliases to expand python variables via $.
1476 ability for aliases to expand python variables via $.
1474
1477
1475 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
1478 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
1476 system, now there's a @rehash/@rehashx pair of magics. These work
1479 system, now there's a @rehash/@rehashx pair of magics. These work
1477 like the csh rehash command, and can be invoked at any time. They
1480 like the csh rehash command, and can be invoked at any time. They
1478 build a table of aliases to everything in the user's $PATH
1481 build a table of aliases to everything in the user's $PATH
1479 (@rehash uses everything, @rehashx is slower but only adds
1482 (@rehash uses everything, @rehashx is slower but only adds
1480 executable files). With this, the pysh.py-based shell profile can
1483 executable files). With this, the pysh.py-based shell profile can
1481 now simply call rehash upon startup, and full access to all
1484 now simply call rehash upon startup, and full access to all
1482 programs in the user's path is obtained.
1485 programs in the user's path is obtained.
1483
1486
1484 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
1487 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
1485 functionality is now fully in place. I removed the old dynamic
1488 functionality is now fully in place. I removed the old dynamic
1486 code generation based approach, in favor of a much lighter one
1489 code generation based approach, in favor of a much lighter one
1487 based on a simple dict. The advantage is that this allows me to
1490 based on a simple dict. The advantage is that this allows me to
1488 now have thousands of aliases with negligible cost (unthinkable
1491 now have thousands of aliases with negligible cost (unthinkable
1489 with the old system).
1492 with the old system).
1490
1493
1491 2004-06-19 Fernando Perez <fperez@colorado.edu>
1494 2004-06-19 Fernando Perez <fperez@colorado.edu>
1492
1495
1493 * IPython/iplib.py (__init__): extended MagicCompleter class to
1496 * IPython/iplib.py (__init__): extended MagicCompleter class to
1494 also complete (last in priority) on user aliases.
1497 also complete (last in priority) on user aliases.
1495
1498
1496 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
1499 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
1497 call to eval.
1500 call to eval.
1498 (ItplNS.__init__): Added a new class which functions like Itpl,
1501 (ItplNS.__init__): Added a new class which functions like Itpl,
1499 but allows configuring the namespace for the evaluation to occur
1502 but allows configuring the namespace for the evaluation to occur
1500 in.
1503 in.
1501
1504
1502 2004-06-18 Fernando Perez <fperez@colorado.edu>
1505 2004-06-18 Fernando Perez <fperez@colorado.edu>
1503
1506
1504 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
1507 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
1505 better message when 'exit' or 'quit' are typed (a common newbie
1508 better message when 'exit' or 'quit' are typed (a common newbie
1506 confusion).
1509 confusion).
1507
1510
1508 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
1511 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
1509 check for Windows users.
1512 check for Windows users.
1510
1513
1511 * IPython/iplib.py (InteractiveShell.user_setup): removed
1514 * IPython/iplib.py (InteractiveShell.user_setup): removed
1512 disabling of colors for Windows. I'll test at runtime and issue a
1515 disabling of colors for Windows. I'll test at runtime and issue a
1513 warning if Gary's readline isn't found, as to nudge users to
1516 warning if Gary's readline isn't found, as to nudge users to
1514 download it.
1517 download it.
1515
1518
1516 2004-06-16 Fernando Perez <fperez@colorado.edu>
1519 2004-06-16 Fernando Perez <fperez@colorado.edu>
1517
1520
1518 * IPython/genutils.py (Stream.__init__): changed to print errors
1521 * IPython/genutils.py (Stream.__init__): changed to print errors
1519 to sys.stderr. I had a circular dependency here. Now it's
1522 to sys.stderr. I had a circular dependency here. Now it's
1520 possible to run ipython as IDLE's shell (consider this pre-alpha,
1523 possible to run ipython as IDLE's shell (consider this pre-alpha,
1521 since true stdout things end up in the starting terminal instead
1524 since true stdout things end up in the starting terminal instead
1522 of IDLE's out).
1525 of IDLE's out).
1523
1526
1524 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
1527 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
1525 users who haven't # updated their prompt_in2 definitions. Remove
1528 users who haven't # updated their prompt_in2 definitions. Remove
1526 eventually.
1529 eventually.
1527 (multiple_replace): added credit to original ASPN recipe.
1530 (multiple_replace): added credit to original ASPN recipe.
1528
1531
1529 2004-06-15 Fernando Perez <fperez@colorado.edu>
1532 2004-06-15 Fernando Perez <fperez@colorado.edu>
1530
1533
1531 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
1534 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
1532 list of auto-defined aliases.
1535 list of auto-defined aliases.
1533
1536
1534 2004-06-13 Fernando Perez <fperez@colorado.edu>
1537 2004-06-13 Fernando Perez <fperez@colorado.edu>
1535
1538
1536 * setup.py (scriptfiles): Don't trigger win_post_install unless an
1539 * setup.py (scriptfiles): Don't trigger win_post_install unless an
1537 install was really requested (so setup.py can be used for other
1540 install was really requested (so setup.py can be used for other
1538 things under Windows).
1541 things under Windows).
1539
1542
1540 2004-06-10 Fernando Perez <fperez@colorado.edu>
1543 2004-06-10 Fernando Perez <fperez@colorado.edu>
1541
1544
1542 * IPython/Logger.py (Logger.create_log): Manually remove any old
1545 * IPython/Logger.py (Logger.create_log): Manually remove any old
1543 backup, since os.remove may fail under Windows. Fixes bug
1546 backup, since os.remove may fail under Windows. Fixes bug
1544 reported by Thorsten.
1547 reported by Thorsten.
1545
1548
1546 2004-06-09 Fernando Perez <fperez@colorado.edu>
1549 2004-06-09 Fernando Perez <fperez@colorado.edu>
1547
1550
1548 * examples/example-embed.py: fixed all references to %n (replaced
1551 * examples/example-embed.py: fixed all references to %n (replaced
1549 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
1552 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
1550 for all examples and the manual as well.
1553 for all examples and the manual as well.
1551
1554
1552 2004-06-08 Fernando Perez <fperez@colorado.edu>
1555 2004-06-08 Fernando Perez <fperez@colorado.edu>
1553
1556
1554 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
1557 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
1555 alignment and color management. All 3 prompt subsystems now
1558 alignment and color management. All 3 prompt subsystems now
1556 inherit from BasePrompt.
1559 inherit from BasePrompt.
1557
1560
1558 * tools/release: updates for windows installer build and tag rpms
1561 * tools/release: updates for windows installer build and tag rpms
1559 with python version (since paths are fixed).
1562 with python version (since paths are fixed).
1560
1563
1561 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
1564 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
1562 which will become eventually obsolete. Also fixed the default
1565 which will become eventually obsolete. Also fixed the default
1563 prompt_in2 to use \D, so at least new users start with the correct
1566 prompt_in2 to use \D, so at least new users start with the correct
1564 defaults.
1567 defaults.
1565 WARNING: Users with existing ipythonrc files will need to apply
1568 WARNING: Users with existing ipythonrc files will need to apply
1566 this fix manually!
1569 this fix manually!
1567
1570
1568 * setup.py: make windows installer (.exe). This is finally the
1571 * setup.py: make windows installer (.exe). This is finally the
1569 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
1572 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
1570 which I hadn't included because it required Python 2.3 (or recent
1573 which I hadn't included because it required Python 2.3 (or recent
1571 distutils).
1574 distutils).
1572
1575
1573 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
1576 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
1574 usage of new '\D' escape.
1577 usage of new '\D' escape.
1575
1578
1576 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
1579 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
1577 lacks os.getuid())
1580 lacks os.getuid())
1578 (CachedOutput.set_colors): Added the ability to turn coloring
1581 (CachedOutput.set_colors): Added the ability to turn coloring
1579 on/off with @colors even for manually defined prompt colors. It
1582 on/off with @colors even for manually defined prompt colors. It
1580 uses a nasty global, but it works safely and via the generic color
1583 uses a nasty global, but it works safely and via the generic color
1581 handling mechanism.
1584 handling mechanism.
1582 (Prompt2.__init__): Introduced new escape '\D' for continuation
1585 (Prompt2.__init__): Introduced new escape '\D' for continuation
1583 prompts. It represents the counter ('\#') as dots.
1586 prompts. It represents the counter ('\#') as dots.
1584 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
1587 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
1585 need to update their ipythonrc files and replace '%n' with '\D' in
1588 need to update their ipythonrc files and replace '%n' with '\D' in
1586 their prompt_in2 settings everywhere. Sorry, but there's
1589 their prompt_in2 settings everywhere. Sorry, but there's
1587 otherwise no clean way to get all prompts to properly align. The
1590 otherwise no clean way to get all prompts to properly align. The
1588 ipythonrc shipped with IPython has been updated.
1591 ipythonrc shipped with IPython has been updated.
1589
1592
1590 2004-06-07 Fernando Perez <fperez@colorado.edu>
1593 2004-06-07 Fernando Perez <fperez@colorado.edu>
1591
1594
1592 * setup.py (isfile): Pass local_icons option to latex2html, so the
1595 * setup.py (isfile): Pass local_icons option to latex2html, so the
1593 resulting HTML file is self-contained. Thanks to
1596 resulting HTML file is self-contained. Thanks to
1594 dryice-AT-liu.com.cn for the tip.
1597 dryice-AT-liu.com.cn for the tip.
1595
1598
1596 * pysh.py: I created a new profile 'shell', which implements a
1599 * pysh.py: I created a new profile 'shell', which implements a
1597 _rudimentary_ IPython-based shell. This is in NO WAY a realy
1600 _rudimentary_ IPython-based shell. This is in NO WAY a realy
1598 system shell, nor will it become one anytime soon. It's mainly
1601 system shell, nor will it become one anytime soon. It's mainly
1599 meant to illustrate the use of the new flexible bash-like prompts.
1602 meant to illustrate the use of the new flexible bash-like prompts.
1600 I guess it could be used by hardy souls for true shell management,
1603 I guess it could be used by hardy souls for true shell management,
1601 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
1604 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
1602 profile. This uses the InterpreterExec extension provided by
1605 profile. This uses the InterpreterExec extension provided by
1603 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
1606 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
1604
1607
1605 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
1608 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
1606 auto-align itself with the length of the previous input prompt
1609 auto-align itself with the length of the previous input prompt
1607 (taking into account the invisible color escapes).
1610 (taking into account the invisible color escapes).
1608 (CachedOutput.__init__): Large restructuring of this class. Now
1611 (CachedOutput.__init__): Large restructuring of this class. Now
1609 all three prompts (primary1, primary2, output) are proper objects,
1612 all three prompts (primary1, primary2, output) are proper objects,
1610 managed by the 'parent' CachedOutput class. The code is still a
1613 managed by the 'parent' CachedOutput class. The code is still a
1611 bit hackish (all prompts share state via a pointer to the cache),
1614 bit hackish (all prompts share state via a pointer to the cache),
1612 but it's overall far cleaner than before.
1615 but it's overall far cleaner than before.
1613
1616
1614 * IPython/genutils.py (getoutputerror): modified to add verbose,
1617 * IPython/genutils.py (getoutputerror): modified to add verbose,
1615 debug and header options. This makes the interface of all getout*
1618 debug and header options. This makes the interface of all getout*
1616 functions uniform.
1619 functions uniform.
1617 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
1620 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
1618
1621
1619 * IPython/Magic.py (Magic.default_option): added a function to
1622 * IPython/Magic.py (Magic.default_option): added a function to
1620 allow registering default options for any magic command. This
1623 allow registering default options for any magic command. This
1621 makes it easy to have profiles which customize the magics globally
1624 makes it easy to have profiles which customize the magics globally
1622 for a certain use. The values set through this function are
1625 for a certain use. The values set through this function are
1623 picked up by the parse_options() method, which all magics should
1626 picked up by the parse_options() method, which all magics should
1624 use to parse their options.
1627 use to parse their options.
1625
1628
1626 * IPython/genutils.py (warn): modified the warnings framework to
1629 * IPython/genutils.py (warn): modified the warnings framework to
1627 use the Term I/O class. I'm trying to slowly unify all of
1630 use the Term I/O class. I'm trying to slowly unify all of
1628 IPython's I/O operations to pass through Term.
1631 IPython's I/O operations to pass through Term.
1629
1632
1630 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
1633 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
1631 the secondary prompt to correctly match the length of the primary
1634 the secondary prompt to correctly match the length of the primary
1632 one for any prompt. Now multi-line code will properly line up
1635 one for any prompt. Now multi-line code will properly line up
1633 even for path dependent prompts, such as the new ones available
1636 even for path dependent prompts, such as the new ones available
1634 via the prompt_specials.
1637 via the prompt_specials.
1635
1638
1636 2004-06-06 Fernando Perez <fperez@colorado.edu>
1639 2004-06-06 Fernando Perez <fperez@colorado.edu>
1637
1640
1638 * IPython/Prompts.py (prompt_specials): Added the ability to have
1641 * IPython/Prompts.py (prompt_specials): Added the ability to have
1639 bash-like special sequences in the prompts, which get
1642 bash-like special sequences in the prompts, which get
1640 automatically expanded. Things like hostname, current working
1643 automatically expanded. Things like hostname, current working
1641 directory and username are implemented already, but it's easy to
1644 directory and username are implemented already, but it's easy to
1642 add more in the future. Thanks to a patch by W.J. van der Laan
1645 add more in the future. Thanks to a patch by W.J. van der Laan
1643 <gnufnork-AT-hetdigitalegat.nl>
1646 <gnufnork-AT-hetdigitalegat.nl>
1644 (prompt_specials): Added color support for prompt strings, so
1647 (prompt_specials): Added color support for prompt strings, so
1645 users can define arbitrary color setups for their prompts.
1648 users can define arbitrary color setups for their prompts.
1646
1649
1647 2004-06-05 Fernando Perez <fperez@colorado.edu>
1650 2004-06-05 Fernando Perez <fperez@colorado.edu>
1648
1651
1649 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
1652 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
1650 code to load Gary Bishop's readline and configure it
1653 code to load Gary Bishop's readline and configure it
1651 automatically. Thanks to Gary for help on this.
1654 automatically. Thanks to Gary for help on this.
1652
1655
1653 2004-06-01 Fernando Perez <fperez@colorado.edu>
1656 2004-06-01 Fernando Perez <fperez@colorado.edu>
1654
1657
1655 * IPython/Logger.py (Logger.create_log): fix bug for logging
1658 * IPython/Logger.py (Logger.create_log): fix bug for logging
1656 with no filename (previous fix was incomplete).
1659 with no filename (previous fix was incomplete).
1657
1660
1658 2004-05-25 Fernando Perez <fperez@colorado.edu>
1661 2004-05-25 Fernando Perez <fperez@colorado.edu>
1659
1662
1660 * IPython/Magic.py (Magic.parse_options): fix bug where naked
1663 * IPython/Magic.py (Magic.parse_options): fix bug where naked
1661 parens would get passed to the shell.
1664 parens would get passed to the shell.
1662
1665
1663 2004-05-20 Fernando Perez <fperez@colorado.edu>
1666 2004-05-20 Fernando Perez <fperez@colorado.edu>
1664
1667
1665 * IPython/Magic.py (Magic.magic_prun): changed default profile
1668 * IPython/Magic.py (Magic.magic_prun): changed default profile
1666 sort order to 'time' (the more common profiling need).
1669 sort order to 'time' (the more common profiling need).
1667
1670
1668 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
1671 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
1669 so that source code shown is guaranteed in sync with the file on
1672 so that source code shown is guaranteed in sync with the file on
1670 disk (also changed in psource). Similar fix to the one for
1673 disk (also changed in psource). Similar fix to the one for
1671 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
1674 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
1672 <yann.ledu-AT-noos.fr>.
1675 <yann.ledu-AT-noos.fr>.
1673
1676
1674 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
1677 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
1675 with a single option would not be correctly parsed. Closes
1678 with a single option would not be correctly parsed. Closes
1676 http://www.scipy.net/roundup/ipython/issue14. This bug had been
1679 http://www.scipy.net/roundup/ipython/issue14. This bug had been
1677 introduced in 0.6.0 (on 2004-05-06).
1680 introduced in 0.6.0 (on 2004-05-06).
1678
1681
1679 2004-05-13 *** Released version 0.6.0
1682 2004-05-13 *** Released version 0.6.0
1680
1683
1681 2004-05-13 Fernando Perez <fperez@colorado.edu>
1684 2004-05-13 Fernando Perez <fperez@colorado.edu>
1682
1685
1683 * debian/: Added debian/ directory to CVS, so that debian support
1686 * debian/: Added debian/ directory to CVS, so that debian support
1684 is publicly accessible. The debian package is maintained by Jack
1687 is publicly accessible. The debian package is maintained by Jack
1685 Moffit <jack-AT-xiph.org>.
1688 Moffit <jack-AT-xiph.org>.
1686
1689
1687 * Documentation: included the notes about an ipython-based system
1690 * Documentation: included the notes about an ipython-based system
1688 shell (the hypothetical 'pysh') into the new_design.pdf document,
1691 shell (the hypothetical 'pysh') into the new_design.pdf document,
1689 so that these ideas get distributed to users along with the
1692 so that these ideas get distributed to users along with the
1690 official documentation.
1693 official documentation.
1691
1694
1692 2004-05-10 Fernando Perez <fperez@colorado.edu>
1695 2004-05-10 Fernando Perez <fperez@colorado.edu>
1693
1696
1694 * IPython/Logger.py (Logger.create_log): fix recently introduced
1697 * IPython/Logger.py (Logger.create_log): fix recently introduced
1695 bug (misindented line) where logstart would fail when not given an
1698 bug (misindented line) where logstart would fail when not given an
1696 explicit filename.
1699 explicit filename.
1697
1700
1698 2004-05-09 Fernando Perez <fperez@colorado.edu>
1701 2004-05-09 Fernando Perez <fperez@colorado.edu>
1699
1702
1700 * IPython/Magic.py (Magic.parse_options): skip system call when
1703 * IPython/Magic.py (Magic.parse_options): skip system call when
1701 there are no options to look for. Faster, cleaner for the common
1704 there are no options to look for. Faster, cleaner for the common
1702 case.
1705 case.
1703
1706
1704 * Documentation: many updates to the manual: describing Windows
1707 * Documentation: many updates to the manual: describing Windows
1705 support better, Gnuplot updates, credits, misc small stuff. Also
1708 support better, Gnuplot updates, credits, misc small stuff. Also
1706 updated the new_design doc a bit.
1709 updated the new_design doc a bit.
1707
1710
1708 2004-05-06 *** Released version 0.6.0.rc1
1711 2004-05-06 *** Released version 0.6.0.rc1
1709
1712
1710 2004-05-06 Fernando Perez <fperez@colorado.edu>
1713 2004-05-06 Fernando Perez <fperez@colorado.edu>
1711
1714
1712 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
1715 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
1713 operations to use the vastly more efficient list/''.join() method.
1716 operations to use the vastly more efficient list/''.join() method.
1714 (FormattedTB.text): Fix
1717 (FormattedTB.text): Fix
1715 http://www.scipy.net/roundup/ipython/issue12 - exception source
1718 http://www.scipy.net/roundup/ipython/issue12 - exception source
1716 extract not updated after reload. Thanks to Mike Salib
1719 extract not updated after reload. Thanks to Mike Salib
1717 <msalib-AT-mit.edu> for pinning the source of the problem.
1720 <msalib-AT-mit.edu> for pinning the source of the problem.
1718 Fortunately, the solution works inside ipython and doesn't require
1721 Fortunately, the solution works inside ipython and doesn't require
1719 any changes to python proper.
1722 any changes to python proper.
1720
1723
1721 * IPython/Magic.py (Magic.parse_options): Improved to process the
1724 * IPython/Magic.py (Magic.parse_options): Improved to process the
1722 argument list as a true shell would (by actually using the
1725 argument list as a true shell would (by actually using the
1723 underlying system shell). This way, all @magics automatically get
1726 underlying system shell). This way, all @magics automatically get
1724 shell expansion for variables. Thanks to a comment by Alex
1727 shell expansion for variables. Thanks to a comment by Alex
1725 Schmolck.
1728 Schmolck.
1726
1729
1727 2004-04-04 Fernando Perez <fperez@colorado.edu>
1730 2004-04-04 Fernando Perez <fperez@colorado.edu>
1728
1731
1729 * IPython/iplib.py (InteractiveShell.interact): Added a special
1732 * IPython/iplib.py (InteractiveShell.interact): Added a special
1730 trap for a debugger quit exception, which is basically impossible
1733 trap for a debugger quit exception, which is basically impossible
1731 to handle by normal mechanisms, given what pdb does to the stack.
1734 to handle by normal mechanisms, given what pdb does to the stack.
1732 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
1735 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
1733
1736
1734 2004-04-03 Fernando Perez <fperez@colorado.edu>
1737 2004-04-03 Fernando Perez <fperez@colorado.edu>
1735
1738
1736 * IPython/genutils.py (Term): Standardized the names of the Term
1739 * IPython/genutils.py (Term): Standardized the names of the Term
1737 class streams to cin/cout/cerr, following C++ naming conventions
1740 class streams to cin/cout/cerr, following C++ naming conventions
1738 (I can't use in/out/err because 'in' is not a valid attribute
1741 (I can't use in/out/err because 'in' is not a valid attribute
1739 name).
1742 name).
1740
1743
1741 * IPython/iplib.py (InteractiveShell.interact): don't increment
1744 * IPython/iplib.py (InteractiveShell.interact): don't increment
1742 the prompt if there's no user input. By Daniel 'Dang' Griffith
1745 the prompt if there's no user input. By Daniel 'Dang' Griffith
1743 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
1746 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
1744 Francois Pinard.
1747 Francois Pinard.
1745
1748
1746 2004-04-02 Fernando Perez <fperez@colorado.edu>
1749 2004-04-02 Fernando Perez <fperez@colorado.edu>
1747
1750
1748 * IPython/genutils.py (Stream.__init__): Modified to survive at
1751 * IPython/genutils.py (Stream.__init__): Modified to survive at
1749 least importing in contexts where stdin/out/err aren't true file
1752 least importing in contexts where stdin/out/err aren't true file
1750 objects, such as PyCrust (they lack fileno() and mode). However,
1753 objects, such as PyCrust (they lack fileno() and mode). However,
1751 the recovery facilities which rely on these things existing will
1754 the recovery facilities which rely on these things existing will
1752 not work.
1755 not work.
1753
1756
1754 2004-04-01 Fernando Perez <fperez@colorado.edu>
1757 2004-04-01 Fernando Perez <fperez@colorado.edu>
1755
1758
1756 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
1759 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
1757 use the new getoutputerror() function, so it properly
1760 use the new getoutputerror() function, so it properly
1758 distinguishes stdout/err.
1761 distinguishes stdout/err.
1759
1762
1760 * IPython/genutils.py (getoutputerror): added a function to
1763 * IPython/genutils.py (getoutputerror): added a function to
1761 capture separately the standard output and error of a command.
1764 capture separately the standard output and error of a command.
1762 After a comment from dang on the mailing lists. This code is
1765 After a comment from dang on the mailing lists. This code is
1763 basically a modified version of commands.getstatusoutput(), from
1766 basically a modified version of commands.getstatusoutput(), from
1764 the standard library.
1767 the standard library.
1765
1768
1766 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
1769 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
1767 '!!' as a special syntax (shorthand) to access @sx.
1770 '!!' as a special syntax (shorthand) to access @sx.
1768
1771
1769 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
1772 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
1770 command and return its output as a list split on '\n'.
1773 command and return its output as a list split on '\n'.
1771
1774
1772 2004-03-31 Fernando Perez <fperez@colorado.edu>
1775 2004-03-31 Fernando Perez <fperez@colorado.edu>
1773
1776
1774 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
1777 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
1775 method to dictionaries used as FakeModule instances if they lack
1778 method to dictionaries used as FakeModule instances if they lack
1776 it. At least pydoc in python2.3 breaks for runtime-defined
1779 it. At least pydoc in python2.3 breaks for runtime-defined
1777 functions without this hack. At some point I need to _really_
1780 functions without this hack. At some point I need to _really_
1778 understand what FakeModule is doing, because it's a gross hack.
1781 understand what FakeModule is doing, because it's a gross hack.
1779 But it solves Arnd's problem for now...
1782 But it solves Arnd's problem for now...
1780
1783
1781 2004-02-27 Fernando Perez <fperez@colorado.edu>
1784 2004-02-27 Fernando Perez <fperez@colorado.edu>
1782
1785
1783 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
1786 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
1784 mode would behave erratically. Also increased the number of
1787 mode would behave erratically. Also increased the number of
1785 possible logs in rotate mod to 999. Thanks to Rod Holland
1788 possible logs in rotate mod to 999. Thanks to Rod Holland
1786 <rhh@StructureLABS.com> for the report and fixes.
1789 <rhh@StructureLABS.com> for the report and fixes.
1787
1790
1788 2004-02-26 Fernando Perez <fperez@colorado.edu>
1791 2004-02-26 Fernando Perez <fperez@colorado.edu>
1789
1792
1790 * IPython/genutils.py (page): Check that the curses module really
1793 * IPython/genutils.py (page): Check that the curses module really
1791 has the initscr attribute before trying to use it. For some
1794 has the initscr attribute before trying to use it. For some
1792 reason, the Solaris curses module is missing this. I think this
1795 reason, the Solaris curses module is missing this. I think this
1793 should be considered a Solaris python bug, but I'm not sure.
1796 should be considered a Solaris python bug, but I'm not sure.
1794
1797
1795 2004-01-17 Fernando Perez <fperez@colorado.edu>
1798 2004-01-17 Fernando Perez <fperez@colorado.edu>
1796
1799
1797 * IPython/genutils.py (Stream.__init__): Changes to try to make
1800 * IPython/genutils.py (Stream.__init__): Changes to try to make
1798 ipython robust against stdin/out/err being closed by the user.
1801 ipython robust against stdin/out/err being closed by the user.
1799 This is 'user error' (and blocks a normal python session, at least
1802 This is 'user error' (and blocks a normal python session, at least
1800 the stdout case). However, Ipython should be able to survive such
1803 the stdout case). However, Ipython should be able to survive such
1801 instances of abuse as gracefully as possible. To simplify the
1804 instances of abuse as gracefully as possible. To simplify the
1802 coding and maintain compatibility with Gary Bishop's Term
1805 coding and maintain compatibility with Gary Bishop's Term
1803 contributions, I've made use of classmethods for this. I think
1806 contributions, I've made use of classmethods for this. I think
1804 this introduces a dependency on python 2.2.
1807 this introduces a dependency on python 2.2.
1805
1808
1806 2004-01-13 Fernando Perez <fperez@colorado.edu>
1809 2004-01-13 Fernando Perez <fperez@colorado.edu>
1807
1810
1808 * IPython/numutils.py (exp_safe): simplified the code a bit and
1811 * IPython/numutils.py (exp_safe): simplified the code a bit and
1809 removed the need for importing the kinds module altogether.
1812 removed the need for importing the kinds module altogether.
1810
1813
1811 2004-01-06 Fernando Perez <fperez@colorado.edu>
1814 2004-01-06 Fernando Perez <fperez@colorado.edu>
1812
1815
1813 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
1816 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
1814 a magic function instead, after some community feedback. No
1817 a magic function instead, after some community feedback. No
1815 special syntax will exist for it, but its name is deliberately
1818 special syntax will exist for it, but its name is deliberately
1816 very short.
1819 very short.
1817
1820
1818 2003-12-20 Fernando Perez <fperez@colorado.edu>
1821 2003-12-20 Fernando Perez <fperez@colorado.edu>
1819
1822
1820 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
1823 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
1821 new functionality, to automagically assign the result of a shell
1824 new functionality, to automagically assign the result of a shell
1822 command to a variable. I'll solicit some community feedback on
1825 command to a variable. I'll solicit some community feedback on
1823 this before making it permanent.
1826 this before making it permanent.
1824
1827
1825 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
1828 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
1826 requested about callables for which inspect couldn't obtain a
1829 requested about callables for which inspect couldn't obtain a
1827 proper argspec. Thanks to a crash report sent by Etienne
1830 proper argspec. Thanks to a crash report sent by Etienne
1828 Posthumus <etienne-AT-apple01.cs.vu.nl>.
1831 Posthumus <etienne-AT-apple01.cs.vu.nl>.
1829
1832
1830 2003-12-09 Fernando Perez <fperez@colorado.edu>
1833 2003-12-09 Fernando Perez <fperez@colorado.edu>
1831
1834
1832 * IPython/genutils.py (page): patch for the pager to work across
1835 * IPython/genutils.py (page): patch for the pager to work across
1833 various versions of Windows. By Gary Bishop.
1836 various versions of Windows. By Gary Bishop.
1834
1837
1835 2003-12-04 Fernando Perez <fperez@colorado.edu>
1838 2003-12-04 Fernando Perez <fperez@colorado.edu>
1836
1839
1837 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
1840 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
1838 Gnuplot.py version 1.7, whose internal names changed quite a bit.
1841 Gnuplot.py version 1.7, whose internal names changed quite a bit.
1839 While I tested this and it looks ok, there may still be corner
1842 While I tested this and it looks ok, there may still be corner
1840 cases I've missed.
1843 cases I've missed.
1841
1844
1842 2003-12-01 Fernando Perez <fperez@colorado.edu>
1845 2003-12-01 Fernando Perez <fperez@colorado.edu>
1843
1846
1844 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
1847 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
1845 where a line like 'p,q=1,2' would fail because the automagic
1848 where a line like 'p,q=1,2' would fail because the automagic
1846 system would be triggered for @p.
1849 system would be triggered for @p.
1847
1850
1848 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
1851 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
1849 cleanups, code unmodified.
1852 cleanups, code unmodified.
1850
1853
1851 * IPython/genutils.py (Term): added a class for IPython to handle
1854 * IPython/genutils.py (Term): added a class for IPython to handle
1852 output. In most cases it will just be a proxy for stdout/err, but
1855 output. In most cases it will just be a proxy for stdout/err, but
1853 having this allows modifications to be made for some platforms,
1856 having this allows modifications to be made for some platforms,
1854 such as handling color escapes under Windows. All of this code
1857 such as handling color escapes under Windows. All of this code
1855 was contributed by Gary Bishop, with minor modifications by me.
1858 was contributed by Gary Bishop, with minor modifications by me.
1856 The actual changes affect many files.
1859 The actual changes affect many files.
1857
1860
1858 2003-11-30 Fernando Perez <fperez@colorado.edu>
1861 2003-11-30 Fernando Perez <fperez@colorado.edu>
1859
1862
1860 * IPython/iplib.py (file_matches): new completion code, courtesy
1863 * IPython/iplib.py (file_matches): new completion code, courtesy
1861 of Jeff Collins. This enables filename completion again under
1864 of Jeff Collins. This enables filename completion again under
1862 python 2.3, which disabled it at the C level.
1865 python 2.3, which disabled it at the C level.
1863
1866
1864 2003-11-11 Fernando Perez <fperez@colorado.edu>
1867 2003-11-11 Fernando Perez <fperez@colorado.edu>
1865
1868
1866 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
1869 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
1867 for Numeric.array(map(...)), but often convenient.
1870 for Numeric.array(map(...)), but often convenient.
1868
1871
1869 2003-11-05 Fernando Perez <fperez@colorado.edu>
1872 2003-11-05 Fernando Perez <fperez@colorado.edu>
1870
1873
1871 * IPython/numutils.py (frange): Changed a call from int() to
1874 * IPython/numutils.py (frange): Changed a call from int() to
1872 int(round()) to prevent a problem reported with arange() in the
1875 int(round()) to prevent a problem reported with arange() in the
1873 numpy list.
1876 numpy list.
1874
1877
1875 2003-10-06 Fernando Perez <fperez@colorado.edu>
1878 2003-10-06 Fernando Perez <fperez@colorado.edu>
1876
1879
1877 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
1880 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
1878 prevent crashes if sys lacks an argv attribute (it happens with
1881 prevent crashes if sys lacks an argv attribute (it happens with
1879 embedded interpreters which build a bare-bones sys module).
1882 embedded interpreters which build a bare-bones sys module).
1880 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
1883 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
1881
1884
1882 2003-09-24 Fernando Perez <fperez@colorado.edu>
1885 2003-09-24 Fernando Perez <fperez@colorado.edu>
1883
1886
1884 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
1887 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
1885 to protect against poorly written user objects where __getattr__
1888 to protect against poorly written user objects where __getattr__
1886 raises exceptions other than AttributeError. Thanks to a bug
1889 raises exceptions other than AttributeError. Thanks to a bug
1887 report by Oliver Sander <osander-AT-gmx.de>.
1890 report by Oliver Sander <osander-AT-gmx.de>.
1888
1891
1889 * IPython/FakeModule.py (FakeModule.__repr__): this method was
1892 * IPython/FakeModule.py (FakeModule.__repr__): this method was
1890 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
1893 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
1891
1894
1892 2003-09-09 Fernando Perez <fperez@colorado.edu>
1895 2003-09-09 Fernando Perez <fperez@colorado.edu>
1893
1896
1894 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1897 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1895 unpacking a list whith a callable as first element would
1898 unpacking a list whith a callable as first element would
1896 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
1899 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
1897 Collins.
1900 Collins.
1898
1901
1899 2003-08-25 *** Released version 0.5.0
1902 2003-08-25 *** Released version 0.5.0
1900
1903
1901 2003-08-22 Fernando Perez <fperez@colorado.edu>
1904 2003-08-22 Fernando Perez <fperez@colorado.edu>
1902
1905
1903 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
1906 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
1904 improperly defined user exceptions. Thanks to feedback from Mark
1907 improperly defined user exceptions. Thanks to feedback from Mark
1905 Russell <mrussell-AT-verio.net>.
1908 Russell <mrussell-AT-verio.net>.
1906
1909
1907 2003-08-20 Fernando Perez <fperez@colorado.edu>
1910 2003-08-20 Fernando Perez <fperez@colorado.edu>
1908
1911
1909 * IPython/OInspect.py (Inspector.pinfo): changed String Form
1912 * IPython/OInspect.py (Inspector.pinfo): changed String Form
1910 printing so that it would print multi-line string forms starting
1913 printing so that it would print multi-line string forms starting
1911 with a new line. This way the formatting is better respected for
1914 with a new line. This way the formatting is better respected for
1912 objects which work hard to make nice string forms.
1915 objects which work hard to make nice string forms.
1913
1916
1914 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
1917 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
1915 autocall would overtake data access for objects with both
1918 autocall would overtake data access for objects with both
1916 __getitem__ and __call__.
1919 __getitem__ and __call__.
1917
1920
1918 2003-08-19 *** Released version 0.5.0-rc1
1921 2003-08-19 *** Released version 0.5.0-rc1
1919
1922
1920 2003-08-19 Fernando Perez <fperez@colorado.edu>
1923 2003-08-19 Fernando Perez <fperez@colorado.edu>
1921
1924
1922 * IPython/deep_reload.py (load_tail): single tiny change here
1925 * IPython/deep_reload.py (load_tail): single tiny change here
1923 seems to fix the long-standing bug of dreload() failing to work
1926 seems to fix the long-standing bug of dreload() failing to work
1924 for dotted names. But this module is pretty tricky, so I may have
1927 for dotted names. But this module is pretty tricky, so I may have
1925 missed some subtlety. Needs more testing!.
1928 missed some subtlety. Needs more testing!.
1926
1929
1927 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
1930 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
1928 exceptions which have badly implemented __str__ methods.
1931 exceptions which have badly implemented __str__ methods.
1929 (VerboseTB.text): harden against inspect.getinnerframes crashing,
1932 (VerboseTB.text): harden against inspect.getinnerframes crashing,
1930 which I've been getting reports about from Python 2.3 users. I
1933 which I've been getting reports about from Python 2.3 users. I
1931 wish I had a simple test case to reproduce the problem, so I could
1934 wish I had a simple test case to reproduce the problem, so I could
1932 either write a cleaner workaround or file a bug report if
1935 either write a cleaner workaround or file a bug report if
1933 necessary.
1936 necessary.
1934
1937
1935 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
1938 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
1936 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
1939 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
1937 a bug report by Tjabo Kloppenburg.
1940 a bug report by Tjabo Kloppenburg.
1938
1941
1939 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
1942 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
1940 crashes. Wrapped the pdb call in a blanket try/except, since pdb
1943 crashes. Wrapped the pdb call in a blanket try/except, since pdb
1941 seems rather unstable. Thanks to a bug report by Tjabo
1944 seems rather unstable. Thanks to a bug report by Tjabo
1942 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
1945 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
1943
1946
1944 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
1947 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
1945 this out soon because of the critical fixes in the inner loop for
1948 this out soon because of the critical fixes in the inner loop for
1946 generators.
1949 generators.
1947
1950
1948 * IPython/Magic.py (Magic.getargspec): removed. This (and
1951 * IPython/Magic.py (Magic.getargspec): removed. This (and
1949 _get_def) have been obsoleted by OInspect for a long time, I
1952 _get_def) have been obsoleted by OInspect for a long time, I
1950 hadn't noticed that they were dead code.
1953 hadn't noticed that they were dead code.
1951 (Magic._ofind): restored _ofind functionality for a few literals
1954 (Magic._ofind): restored _ofind functionality for a few literals
1952 (those in ["''",'""','[]','{}','()']). But it won't work anymore
1955 (those in ["''",'""','[]','{}','()']). But it won't work anymore
1953 for things like "hello".capitalize?, since that would require a
1956 for things like "hello".capitalize?, since that would require a
1954 potentially dangerous eval() again.
1957 potentially dangerous eval() again.
1955
1958
1956 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
1959 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
1957 logic a bit more to clean up the escapes handling and minimize the
1960 logic a bit more to clean up the escapes handling and minimize the
1958 use of _ofind to only necessary cases. The interactive 'feel' of
1961 use of _ofind to only necessary cases. The interactive 'feel' of
1959 IPython should have improved quite a bit with the changes in
1962 IPython should have improved quite a bit with the changes in
1960 _prefilter and _ofind (besides being far safer than before).
1963 _prefilter and _ofind (besides being far safer than before).
1961
1964
1962 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
1965 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
1963 obscure, never reported). Edit would fail to find the object to
1966 obscure, never reported). Edit would fail to find the object to
1964 edit under some circumstances.
1967 edit under some circumstances.
1965 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
1968 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
1966 which were causing double-calling of generators. Those eval calls
1969 which were causing double-calling of generators. Those eval calls
1967 were _very_ dangerous, since code with side effects could be
1970 were _very_ dangerous, since code with side effects could be
1968 triggered. As they say, 'eval is evil'... These were the
1971 triggered. As they say, 'eval is evil'... These were the
1969 nastiest evals in IPython. Besides, _ofind is now far simpler,
1972 nastiest evals in IPython. Besides, _ofind is now far simpler,
1970 and it should also be quite a bit faster. Its use of inspect is
1973 and it should also be quite a bit faster. Its use of inspect is
1971 also safer, so perhaps some of the inspect-related crashes I've
1974 also safer, so perhaps some of the inspect-related crashes I've
1972 seen lately with Python 2.3 might be taken care of. That will
1975 seen lately with Python 2.3 might be taken care of. That will
1973 need more testing.
1976 need more testing.
1974
1977
1975 2003-08-17 Fernando Perez <fperez@colorado.edu>
1978 2003-08-17 Fernando Perez <fperez@colorado.edu>
1976
1979
1977 * IPython/iplib.py (InteractiveShell._prefilter): significant
1980 * IPython/iplib.py (InteractiveShell._prefilter): significant
1978 simplifications to the logic for handling user escapes. Faster
1981 simplifications to the logic for handling user escapes. Faster
1979 and simpler code.
1982 and simpler code.
1980
1983
1981 2003-08-14 Fernando Perez <fperez@colorado.edu>
1984 2003-08-14 Fernando Perez <fperez@colorado.edu>
1982
1985
1983 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
1986 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
1984 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
1987 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
1985 but it should be quite a bit faster. And the recursive version
1988 but it should be quite a bit faster. And the recursive version
1986 generated O(log N) intermediate storage for all rank>1 arrays,
1989 generated O(log N) intermediate storage for all rank>1 arrays,
1987 even if they were contiguous.
1990 even if they were contiguous.
1988 (l1norm): Added this function.
1991 (l1norm): Added this function.
1989 (norm): Added this function for arbitrary norms (including
1992 (norm): Added this function for arbitrary norms (including
1990 l-infinity). l1 and l2 are still special cases for convenience
1993 l-infinity). l1 and l2 are still special cases for convenience
1991 and speed.
1994 and speed.
1992
1995
1993 2003-08-03 Fernando Perez <fperez@colorado.edu>
1996 2003-08-03 Fernando Perez <fperez@colorado.edu>
1994
1997
1995 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
1998 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
1996 exceptions, which now raise PendingDeprecationWarnings in Python
1999 exceptions, which now raise PendingDeprecationWarnings in Python
1997 2.3. There were some in Magic and some in Gnuplot2.
2000 2.3. There were some in Magic and some in Gnuplot2.
1998
2001
1999 2003-06-30 Fernando Perez <fperez@colorado.edu>
2002 2003-06-30 Fernando Perez <fperez@colorado.edu>
2000
2003
2001 * IPython/genutils.py (page): modified to call curses only for
2004 * IPython/genutils.py (page): modified to call curses only for
2002 terminals where TERM=='xterm'. After problems under many other
2005 terminals where TERM=='xterm'. After problems under many other
2003 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2006 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2004
2007
2005 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2008 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2006 would be triggered when readline was absent. This was just an old
2009 would be triggered when readline was absent. This was just an old
2007 debugging statement I'd forgotten to take out.
2010 debugging statement I'd forgotten to take out.
2008
2011
2009 2003-06-20 Fernando Perez <fperez@colorado.edu>
2012 2003-06-20 Fernando Perez <fperez@colorado.edu>
2010
2013
2011 * IPython/genutils.py (clock): modified to return only user time
2014 * IPython/genutils.py (clock): modified to return only user time
2012 (not counting system time), after a discussion on scipy. While
2015 (not counting system time), after a discussion on scipy. While
2013 system time may be a useful quantity occasionally, it may much
2016 system time may be a useful quantity occasionally, it may much
2014 more easily be skewed by occasional swapping or other similar
2017 more easily be skewed by occasional swapping or other similar
2015 activity.
2018 activity.
2016
2019
2017 2003-06-05 Fernando Perez <fperez@colorado.edu>
2020 2003-06-05 Fernando Perez <fperez@colorado.edu>
2018
2021
2019 * IPython/numutils.py (identity): new function, for building
2022 * IPython/numutils.py (identity): new function, for building
2020 arbitrary rank Kronecker deltas (mostly backwards compatible with
2023 arbitrary rank Kronecker deltas (mostly backwards compatible with
2021 Numeric.identity)
2024 Numeric.identity)
2022
2025
2023 2003-06-03 Fernando Perez <fperez@colorado.edu>
2026 2003-06-03 Fernando Perez <fperez@colorado.edu>
2024
2027
2025 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2028 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2026 arguments passed to magics with spaces, to allow trailing '\' to
2029 arguments passed to magics with spaces, to allow trailing '\' to
2027 work normally (mainly for Windows users).
2030 work normally (mainly for Windows users).
2028
2031
2029 2003-05-29 Fernando Perez <fperez@colorado.edu>
2032 2003-05-29 Fernando Perez <fperez@colorado.edu>
2030
2033
2031 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2034 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2032 instead of pydoc.help. This fixes a bizarre behavior where
2035 instead of pydoc.help. This fixes a bizarre behavior where
2033 printing '%s' % locals() would trigger the help system. Now
2036 printing '%s' % locals() would trigger the help system. Now
2034 ipython behaves like normal python does.
2037 ipython behaves like normal python does.
2035
2038
2036 Note that if one does 'from pydoc import help', the bizarre
2039 Note that if one does 'from pydoc import help', the bizarre
2037 behavior returns, but this will also happen in normal python, so
2040 behavior returns, but this will also happen in normal python, so
2038 it's not an ipython bug anymore (it has to do with how pydoc.help
2041 it's not an ipython bug anymore (it has to do with how pydoc.help
2039 is implemented).
2042 is implemented).
2040
2043
2041 2003-05-22 Fernando Perez <fperez@colorado.edu>
2044 2003-05-22 Fernando Perez <fperez@colorado.edu>
2042
2045
2043 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2046 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2044 return [] instead of None when nothing matches, also match to end
2047 return [] instead of None when nothing matches, also match to end
2045 of line. Patch by Gary Bishop.
2048 of line. Patch by Gary Bishop.
2046
2049
2047 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2050 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2048 protection as before, for files passed on the command line. This
2051 protection as before, for files passed on the command line. This
2049 prevents the CrashHandler from kicking in if user files call into
2052 prevents the CrashHandler from kicking in if user files call into
2050 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2053 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2051 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2054 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2052
2055
2053 2003-05-20 *** Released version 0.4.0
2056 2003-05-20 *** Released version 0.4.0
2054
2057
2055 2003-05-20 Fernando Perez <fperez@colorado.edu>
2058 2003-05-20 Fernando Perez <fperez@colorado.edu>
2056
2059
2057 * setup.py: added support for manpages. It's a bit hackish b/c of
2060 * setup.py: added support for manpages. It's a bit hackish b/c of
2058 a bug in the way the bdist_rpm distutils target handles gzipped
2061 a bug in the way the bdist_rpm distutils target handles gzipped
2059 manpages, but it works. After a patch by Jack.
2062 manpages, but it works. After a patch by Jack.
2060
2063
2061 2003-05-19 Fernando Perez <fperez@colorado.edu>
2064 2003-05-19 Fernando Perez <fperez@colorado.edu>
2062
2065
2063 * IPython/numutils.py: added a mockup of the kinds module, since
2066 * IPython/numutils.py: added a mockup of the kinds module, since
2064 it was recently removed from Numeric. This way, numutils will
2067 it was recently removed from Numeric. This way, numutils will
2065 work for all users even if they are missing kinds.
2068 work for all users even if they are missing kinds.
2066
2069
2067 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2070 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2068 failure, which can occur with SWIG-wrapped extensions. After a
2071 failure, which can occur with SWIG-wrapped extensions. After a
2069 crash report from Prabhu.
2072 crash report from Prabhu.
2070
2073
2071 2003-05-16 Fernando Perez <fperez@colorado.edu>
2074 2003-05-16 Fernando Perez <fperez@colorado.edu>
2072
2075
2073 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2076 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2074 protect ipython from user code which may call directly
2077 protect ipython from user code which may call directly
2075 sys.excepthook (this looks like an ipython crash to the user, even
2078 sys.excepthook (this looks like an ipython crash to the user, even
2076 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2079 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2077 This is especially important to help users of WxWindows, but may
2080 This is especially important to help users of WxWindows, but may
2078 also be useful in other cases.
2081 also be useful in other cases.
2079
2082
2080 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2083 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2081 an optional tb_offset to be specified, and to preserve exception
2084 an optional tb_offset to be specified, and to preserve exception
2082 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2085 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2083
2086
2084 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2087 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2085
2088
2086 2003-05-15 Fernando Perez <fperez@colorado.edu>
2089 2003-05-15 Fernando Perez <fperez@colorado.edu>
2087
2090
2088 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2091 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2089 installing for a new user under Windows.
2092 installing for a new user under Windows.
2090
2093
2091 2003-05-12 Fernando Perez <fperez@colorado.edu>
2094 2003-05-12 Fernando Perez <fperez@colorado.edu>
2092
2095
2093 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2096 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2094 handler for Emacs comint-based lines. Currently it doesn't do
2097 handler for Emacs comint-based lines. Currently it doesn't do
2095 much (but importantly, it doesn't update the history cache). In
2098 much (but importantly, it doesn't update the history cache). In
2096 the future it may be expanded if Alex needs more functionality
2099 the future it may be expanded if Alex needs more functionality
2097 there.
2100 there.
2098
2101
2099 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2102 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2100 info to crash reports.
2103 info to crash reports.
2101
2104
2102 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2105 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2103 just like Python's -c. Also fixed crash with invalid -color
2106 just like Python's -c. Also fixed crash with invalid -color
2104 option value at startup. Thanks to Will French
2107 option value at startup. Thanks to Will French
2105 <wfrench-AT-bestweb.net> for the bug report.
2108 <wfrench-AT-bestweb.net> for the bug report.
2106
2109
2107 2003-05-09 Fernando Perez <fperez@colorado.edu>
2110 2003-05-09 Fernando Perez <fperez@colorado.edu>
2108
2111
2109 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2112 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2110 to EvalDict (it's a mapping, after all) and simplified its code
2113 to EvalDict (it's a mapping, after all) and simplified its code
2111 quite a bit, after a nice discussion on c.l.py where Gustavo
2114 quite a bit, after a nice discussion on c.l.py where Gustavo
2112 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
2115 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
2113
2116
2114 2003-04-30 Fernando Perez <fperez@colorado.edu>
2117 2003-04-30 Fernando Perez <fperez@colorado.edu>
2115
2118
2116 * IPython/genutils.py (timings_out): modified it to reduce its
2119 * IPython/genutils.py (timings_out): modified it to reduce its
2117 overhead in the common reps==1 case.
2120 overhead in the common reps==1 case.
2118
2121
2119 2003-04-29 Fernando Perez <fperez@colorado.edu>
2122 2003-04-29 Fernando Perez <fperez@colorado.edu>
2120
2123
2121 * IPython/genutils.py (timings_out): Modified to use the resource
2124 * IPython/genutils.py (timings_out): Modified to use the resource
2122 module, which avoids the wraparound problems of time.clock().
2125 module, which avoids the wraparound problems of time.clock().
2123
2126
2124 2003-04-17 *** Released version 0.2.15pre4
2127 2003-04-17 *** Released version 0.2.15pre4
2125
2128
2126 2003-04-17 Fernando Perez <fperez@colorado.edu>
2129 2003-04-17 Fernando Perez <fperez@colorado.edu>
2127
2130
2128 * setup.py (scriptfiles): Split windows-specific stuff over to a
2131 * setup.py (scriptfiles): Split windows-specific stuff over to a
2129 separate file, in an attempt to have a Windows GUI installer.
2132 separate file, in an attempt to have a Windows GUI installer.
2130 That didn't work, but part of the groundwork is done.
2133 That didn't work, but part of the groundwork is done.
2131
2134
2132 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2135 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2133 indent/unindent with 4 spaces. Particularly useful in combination
2136 indent/unindent with 4 spaces. Particularly useful in combination
2134 with the new auto-indent option.
2137 with the new auto-indent option.
2135
2138
2136 2003-04-16 Fernando Perez <fperez@colorado.edu>
2139 2003-04-16 Fernando Perez <fperez@colorado.edu>
2137
2140
2138 * IPython/Magic.py: various replacements of self.rc for
2141 * IPython/Magic.py: various replacements of self.rc for
2139 self.shell.rc. A lot more remains to be done to fully disentangle
2142 self.shell.rc. A lot more remains to be done to fully disentangle
2140 this class from the main Shell class.
2143 this class from the main Shell class.
2141
2144
2142 * IPython/GnuplotRuntime.py: added checks for mouse support so
2145 * IPython/GnuplotRuntime.py: added checks for mouse support so
2143 that we don't try to enable it if the current gnuplot doesn't
2146 that we don't try to enable it if the current gnuplot doesn't
2144 really support it. Also added checks so that we don't try to
2147 really support it. Also added checks so that we don't try to
2145 enable persist under Windows (where Gnuplot doesn't recognize the
2148 enable persist under Windows (where Gnuplot doesn't recognize the
2146 option).
2149 option).
2147
2150
2148 * IPython/iplib.py (InteractiveShell.interact): Added optional
2151 * IPython/iplib.py (InteractiveShell.interact): Added optional
2149 auto-indenting code, after a patch by King C. Shu
2152 auto-indenting code, after a patch by King C. Shu
2150 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2153 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2151 get along well with pasting indented code. If I ever figure out
2154 get along well with pasting indented code. If I ever figure out
2152 how to make that part go well, it will become on by default.
2155 how to make that part go well, it will become on by default.
2153
2156
2154 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2157 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2155 crash ipython if there was an unmatched '%' in the user's prompt
2158 crash ipython if there was an unmatched '%' in the user's prompt
2156 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2159 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2157
2160
2158 * IPython/iplib.py (InteractiveShell.interact): removed the
2161 * IPython/iplib.py (InteractiveShell.interact): removed the
2159 ability to ask the user whether he wants to crash or not at the
2162 ability to ask the user whether he wants to crash or not at the
2160 'last line' exception handler. Calling functions at that point
2163 'last line' exception handler. Calling functions at that point
2161 changes the stack, and the error reports would have incorrect
2164 changes the stack, and the error reports would have incorrect
2162 tracebacks.
2165 tracebacks.
2163
2166
2164 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2167 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2165 pass through a peger a pretty-printed form of any object. After a
2168 pass through a peger a pretty-printed form of any object. After a
2166 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2169 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2167
2170
2168 2003-04-14 Fernando Perez <fperez@colorado.edu>
2171 2003-04-14 Fernando Perez <fperez@colorado.edu>
2169
2172
2170 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2173 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2171 all files in ~ would be modified at first install (instead of
2174 all files in ~ would be modified at first install (instead of
2172 ~/.ipython). This could be potentially disastrous, as the
2175 ~/.ipython). This could be potentially disastrous, as the
2173 modification (make line-endings native) could damage binary files.
2176 modification (make line-endings native) could damage binary files.
2174
2177
2175 2003-04-10 Fernando Perez <fperez@colorado.edu>
2178 2003-04-10 Fernando Perez <fperez@colorado.edu>
2176
2179
2177 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2180 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2178 handle only lines which are invalid python. This now means that
2181 handle only lines which are invalid python. This now means that
2179 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2182 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2180 for the bug report.
2183 for the bug report.
2181
2184
2182 2003-04-01 Fernando Perez <fperez@colorado.edu>
2185 2003-04-01 Fernando Perez <fperez@colorado.edu>
2183
2186
2184 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2187 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2185 where failing to set sys.last_traceback would crash pdb.pm().
2188 where failing to set sys.last_traceback would crash pdb.pm().
2186 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2189 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2187 report.
2190 report.
2188
2191
2189 2003-03-25 Fernando Perez <fperez@colorado.edu>
2192 2003-03-25 Fernando Perez <fperez@colorado.edu>
2190
2193
2191 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2194 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2192 before printing it (it had a lot of spurious blank lines at the
2195 before printing it (it had a lot of spurious blank lines at the
2193 end).
2196 end).
2194
2197
2195 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2198 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2196 output would be sent 21 times! Obviously people don't use this
2199 output would be sent 21 times! Obviously people don't use this
2197 too often, or I would have heard about it.
2200 too often, or I would have heard about it.
2198
2201
2199 2003-03-24 Fernando Perez <fperez@colorado.edu>
2202 2003-03-24 Fernando Perez <fperez@colorado.edu>
2200
2203
2201 * setup.py (scriptfiles): renamed the data_files parameter from
2204 * setup.py (scriptfiles): renamed the data_files parameter from
2202 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2205 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2203 for the patch.
2206 for the patch.
2204
2207
2205 2003-03-20 Fernando Perez <fperez@colorado.edu>
2208 2003-03-20 Fernando Perez <fperez@colorado.edu>
2206
2209
2207 * IPython/genutils.py (error): added error() and fatal()
2210 * IPython/genutils.py (error): added error() and fatal()
2208 functions.
2211 functions.
2209
2212
2210 2003-03-18 *** Released version 0.2.15pre3
2213 2003-03-18 *** Released version 0.2.15pre3
2211
2214
2212 2003-03-18 Fernando Perez <fperez@colorado.edu>
2215 2003-03-18 Fernando Perez <fperez@colorado.edu>
2213
2216
2214 * setupext/install_data_ext.py
2217 * setupext/install_data_ext.py
2215 (install_data_ext.initialize_options): Class contributed by Jack
2218 (install_data_ext.initialize_options): Class contributed by Jack
2216 Moffit for fixing the old distutils hack. He is sending this to
2219 Moffit for fixing the old distutils hack. He is sending this to
2217 the distutils folks so in the future we may not need it as a
2220 the distutils folks so in the future we may not need it as a
2218 private fix.
2221 private fix.
2219
2222
2220 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2223 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2221 changes for Debian packaging. See his patch for full details.
2224 changes for Debian packaging. See his patch for full details.
2222 The old distutils hack of making the ipythonrc* files carry a
2225 The old distutils hack of making the ipythonrc* files carry a
2223 bogus .py extension is gone, at last. Examples were moved to a
2226 bogus .py extension is gone, at last. Examples were moved to a
2224 separate subdir under doc/, and the separate executable scripts
2227 separate subdir under doc/, and the separate executable scripts
2225 now live in their own directory. Overall a great cleanup. The
2228 now live in their own directory. Overall a great cleanup. The
2226 manual was updated to use the new files, and setup.py has been
2229 manual was updated to use the new files, and setup.py has been
2227 fixed for this setup.
2230 fixed for this setup.
2228
2231
2229 * IPython/PyColorize.py (Parser.usage): made non-executable and
2232 * IPython/PyColorize.py (Parser.usage): made non-executable and
2230 created a pycolor wrapper around it to be included as a script.
2233 created a pycolor wrapper around it to be included as a script.
2231
2234
2232 2003-03-12 *** Released version 0.2.15pre2
2235 2003-03-12 *** Released version 0.2.15pre2
2233
2236
2234 2003-03-12 Fernando Perez <fperez@colorado.edu>
2237 2003-03-12 Fernando Perez <fperez@colorado.edu>
2235
2238
2236 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2239 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2237 long-standing problem with garbage characters in some terminals.
2240 long-standing problem with garbage characters in some terminals.
2238 The issue was really that the \001 and \002 escapes must _only_ be
2241 The issue was really that the \001 and \002 escapes must _only_ be
2239 passed to input prompts (which call readline), but _never_ to
2242 passed to input prompts (which call readline), but _never_ to
2240 normal text to be printed on screen. I changed ColorANSI to have
2243 normal text to be printed on screen. I changed ColorANSI to have
2241 two classes: TermColors and InputTermColors, each with the
2244 two classes: TermColors and InputTermColors, each with the
2242 appropriate escapes for input prompts or normal text. The code in
2245 appropriate escapes for input prompts or normal text. The code in
2243 Prompts.py got slightly more complicated, but this very old and
2246 Prompts.py got slightly more complicated, but this very old and
2244 annoying bug is finally fixed.
2247 annoying bug is finally fixed.
2245
2248
2246 All the credit for nailing down the real origin of this problem
2249 All the credit for nailing down the real origin of this problem
2247 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2250 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2248 *Many* thanks to him for spending quite a bit of effort on this.
2251 *Many* thanks to him for spending quite a bit of effort on this.
2249
2252
2250 2003-03-05 *** Released version 0.2.15pre1
2253 2003-03-05 *** Released version 0.2.15pre1
2251
2254
2252 2003-03-03 Fernando Perez <fperez@colorado.edu>
2255 2003-03-03 Fernando Perez <fperez@colorado.edu>
2253
2256
2254 * IPython/FakeModule.py: Moved the former _FakeModule to a
2257 * IPython/FakeModule.py: Moved the former _FakeModule to a
2255 separate file, because it's also needed by Magic (to fix a similar
2258 separate file, because it's also needed by Magic (to fix a similar
2256 pickle-related issue in @run).
2259 pickle-related issue in @run).
2257
2260
2258 2003-03-02 Fernando Perez <fperez@colorado.edu>
2261 2003-03-02 Fernando Perez <fperez@colorado.edu>
2259
2262
2260 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2263 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2261 the autocall option at runtime.
2264 the autocall option at runtime.
2262 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2265 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2263 across Magic.py to start separating Magic from InteractiveShell.
2266 across Magic.py to start separating Magic from InteractiveShell.
2264 (Magic._ofind): Fixed to return proper namespace for dotted
2267 (Magic._ofind): Fixed to return proper namespace for dotted
2265 names. Before, a dotted name would always return 'not currently
2268 names. Before, a dotted name would always return 'not currently
2266 defined', because it would find the 'parent'. s.x would be found,
2269 defined', because it would find the 'parent'. s.x would be found,
2267 but since 'x' isn't defined by itself, it would get confused.
2270 but since 'x' isn't defined by itself, it would get confused.
2268 (Magic.magic_run): Fixed pickling problems reported by Ralf
2271 (Magic.magic_run): Fixed pickling problems reported by Ralf
2269 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2272 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2270 that I'd used when Mike Heeter reported similar issues at the
2273 that I'd used when Mike Heeter reported similar issues at the
2271 top-level, but now for @run. It boils down to injecting the
2274 top-level, but now for @run. It boils down to injecting the
2272 namespace where code is being executed with something that looks
2275 namespace where code is being executed with something that looks
2273 enough like a module to fool pickle.dump(). Since a pickle stores
2276 enough like a module to fool pickle.dump(). Since a pickle stores
2274 a named reference to the importing module, we need this for
2277 a named reference to the importing module, we need this for
2275 pickles to save something sensible.
2278 pickles to save something sensible.
2276
2279
2277 * IPython/ipmaker.py (make_IPython): added an autocall option.
2280 * IPython/ipmaker.py (make_IPython): added an autocall option.
2278
2281
2279 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2282 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2280 the auto-eval code. Now autocalling is an option, and the code is
2283 the auto-eval code. Now autocalling is an option, and the code is
2281 also vastly safer. There is no more eval() involved at all.
2284 also vastly safer. There is no more eval() involved at all.
2282
2285
2283 2003-03-01 Fernando Perez <fperez@colorado.edu>
2286 2003-03-01 Fernando Perez <fperez@colorado.edu>
2284
2287
2285 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2288 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2286 dict with named keys instead of a tuple.
2289 dict with named keys instead of a tuple.
2287
2290
2288 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2291 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2289
2292
2290 * setup.py (make_shortcut): Fixed message about directories
2293 * setup.py (make_shortcut): Fixed message about directories
2291 created during Windows installation (the directories were ok, just
2294 created during Windows installation (the directories were ok, just
2292 the printed message was misleading). Thanks to Chris Liechti
2295 the printed message was misleading). Thanks to Chris Liechti
2293 <cliechti-AT-gmx.net> for the heads up.
2296 <cliechti-AT-gmx.net> for the heads up.
2294
2297
2295 2003-02-21 Fernando Perez <fperez@colorado.edu>
2298 2003-02-21 Fernando Perez <fperez@colorado.edu>
2296
2299
2297 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2300 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2298 of ValueError exception when checking for auto-execution. This
2301 of ValueError exception when checking for auto-execution. This
2299 one is raised by things like Numeric arrays arr.flat when the
2302 one is raised by things like Numeric arrays arr.flat when the
2300 array is non-contiguous.
2303 array is non-contiguous.
2301
2304
2302 2003-01-31 Fernando Perez <fperez@colorado.edu>
2305 2003-01-31 Fernando Perez <fperez@colorado.edu>
2303
2306
2304 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2307 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2305 not return any value at all (even though the command would get
2308 not return any value at all (even though the command would get
2306 executed).
2309 executed).
2307 (xsys): Flush stdout right after printing the command to ensure
2310 (xsys): Flush stdout right after printing the command to ensure
2308 proper ordering of commands and command output in the total
2311 proper ordering of commands and command output in the total
2309 output.
2312 output.
2310 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2313 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2311 system/getoutput as defaults. The old ones are kept for
2314 system/getoutput as defaults. The old ones are kept for
2312 compatibility reasons, so no code which uses this library needs
2315 compatibility reasons, so no code which uses this library needs
2313 changing.
2316 changing.
2314
2317
2315 2003-01-27 *** Released version 0.2.14
2318 2003-01-27 *** Released version 0.2.14
2316
2319
2317 2003-01-25 Fernando Perez <fperez@colorado.edu>
2320 2003-01-25 Fernando Perez <fperez@colorado.edu>
2318
2321
2319 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2322 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2320 functions defined in previous edit sessions could not be re-edited
2323 functions defined in previous edit sessions could not be re-edited
2321 (because the temp files were immediately removed). Now temp files
2324 (because the temp files were immediately removed). Now temp files
2322 are removed only at IPython's exit.
2325 are removed only at IPython's exit.
2323 (Magic.magic_run): Improved @run to perform shell-like expansions
2326 (Magic.magic_run): Improved @run to perform shell-like expansions
2324 on its arguments (~users and $VARS). With this, @run becomes more
2327 on its arguments (~users and $VARS). With this, @run becomes more
2325 like a normal command-line.
2328 like a normal command-line.
2326
2329
2327 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2330 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2328 bugs related to embedding and cleaned up that code. A fairly
2331 bugs related to embedding and cleaned up that code. A fairly
2329 important one was the impossibility to access the global namespace
2332 important one was the impossibility to access the global namespace
2330 through the embedded IPython (only local variables were visible).
2333 through the embedded IPython (only local variables were visible).
2331
2334
2332 2003-01-14 Fernando Perez <fperez@colorado.edu>
2335 2003-01-14 Fernando Perez <fperez@colorado.edu>
2333
2336
2334 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
2337 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
2335 auto-calling to be a bit more conservative. Now it doesn't get
2338 auto-calling to be a bit more conservative. Now it doesn't get
2336 triggered if any of '!=()<>' are in the rest of the input line, to
2339 triggered if any of '!=()<>' are in the rest of the input line, to
2337 allow comparing callables. Thanks to Alex for the heads up.
2340 allow comparing callables. Thanks to Alex for the heads up.
2338
2341
2339 2003-01-07 Fernando Perez <fperez@colorado.edu>
2342 2003-01-07 Fernando Perez <fperez@colorado.edu>
2340
2343
2341 * IPython/genutils.py (page): fixed estimation of the number of
2344 * IPython/genutils.py (page): fixed estimation of the number of
2342 lines in a string to be paged to simply count newlines. This
2345 lines in a string to be paged to simply count newlines. This
2343 prevents over-guessing due to embedded escape sequences. A better
2346 prevents over-guessing due to embedded escape sequences. A better
2344 long-term solution would involve stripping out the control chars
2347 long-term solution would involve stripping out the control chars
2345 for the count, but it's potentially so expensive I just don't
2348 for the count, but it's potentially so expensive I just don't
2346 think it's worth doing.
2349 think it's worth doing.
2347
2350
2348 2002-12-19 *** Released version 0.2.14pre50
2351 2002-12-19 *** Released version 0.2.14pre50
2349
2352
2350 2002-12-19 Fernando Perez <fperez@colorado.edu>
2353 2002-12-19 Fernando Perez <fperez@colorado.edu>
2351
2354
2352 * tools/release (version): Changed release scripts to inform
2355 * tools/release (version): Changed release scripts to inform
2353 Andrea and build a NEWS file with a list of recent changes.
2356 Andrea and build a NEWS file with a list of recent changes.
2354
2357
2355 * IPython/ColorANSI.py (__all__): changed terminal detection
2358 * IPython/ColorANSI.py (__all__): changed terminal detection
2356 code. Seems to work better for xterms without breaking
2359 code. Seems to work better for xterms without breaking
2357 konsole. Will need more testing to determine if WinXP and Mac OSX
2360 konsole. Will need more testing to determine if WinXP and Mac OSX
2358 also work ok.
2361 also work ok.
2359
2362
2360 2002-12-18 *** Released version 0.2.14pre49
2363 2002-12-18 *** Released version 0.2.14pre49
2361
2364
2362 2002-12-18 Fernando Perez <fperez@colorado.edu>
2365 2002-12-18 Fernando Perez <fperez@colorado.edu>
2363
2366
2364 * Docs: added new info about Mac OSX, from Andrea.
2367 * Docs: added new info about Mac OSX, from Andrea.
2365
2368
2366 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
2369 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
2367 allow direct plotting of python strings whose format is the same
2370 allow direct plotting of python strings whose format is the same
2368 of gnuplot data files.
2371 of gnuplot data files.
2369
2372
2370 2002-12-16 Fernando Perez <fperez@colorado.edu>
2373 2002-12-16 Fernando Perez <fperez@colorado.edu>
2371
2374
2372 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
2375 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
2373 value of exit question to be acknowledged.
2376 value of exit question to be acknowledged.
2374
2377
2375 2002-12-03 Fernando Perez <fperez@colorado.edu>
2378 2002-12-03 Fernando Perez <fperez@colorado.edu>
2376
2379
2377 * IPython/ipmaker.py: removed generators, which had been added
2380 * IPython/ipmaker.py: removed generators, which had been added
2378 by mistake in an earlier debugging run. This was causing trouble
2381 by mistake in an earlier debugging run. This was causing trouble
2379 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
2382 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
2380 for pointing this out.
2383 for pointing this out.
2381
2384
2382 2002-11-17 Fernando Perez <fperez@colorado.edu>
2385 2002-11-17 Fernando Perez <fperez@colorado.edu>
2383
2386
2384 * Manual: updated the Gnuplot section.
2387 * Manual: updated the Gnuplot section.
2385
2388
2386 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
2389 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
2387 a much better split of what goes in Runtime and what goes in
2390 a much better split of what goes in Runtime and what goes in
2388 Interactive.
2391 Interactive.
2389
2392
2390 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
2393 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
2391 being imported from iplib.
2394 being imported from iplib.
2392
2395
2393 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
2396 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
2394 for command-passing. Now the global Gnuplot instance is called
2397 for command-passing. Now the global Gnuplot instance is called
2395 'gp' instead of 'g', which was really a far too fragile and
2398 'gp' instead of 'g', which was really a far too fragile and
2396 common name.
2399 common name.
2397
2400
2398 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
2401 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
2399 bounding boxes generated by Gnuplot for square plots.
2402 bounding boxes generated by Gnuplot for square plots.
2400
2403
2401 * IPython/genutils.py (popkey): new function added. I should
2404 * IPython/genutils.py (popkey): new function added. I should
2402 suggest this on c.l.py as a dict method, it seems useful.
2405 suggest this on c.l.py as a dict method, it seems useful.
2403
2406
2404 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
2407 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
2405 to transparently handle PostScript generation. MUCH better than
2408 to transparently handle PostScript generation. MUCH better than
2406 the previous plot_eps/replot_eps (which I removed now). The code
2409 the previous plot_eps/replot_eps (which I removed now). The code
2407 is also fairly clean and well documented now (including
2410 is also fairly clean and well documented now (including
2408 docstrings).
2411 docstrings).
2409
2412
2410 2002-11-13 Fernando Perez <fperez@colorado.edu>
2413 2002-11-13 Fernando Perez <fperez@colorado.edu>
2411
2414
2412 * IPython/Magic.py (Magic.magic_edit): fixed docstring
2415 * IPython/Magic.py (Magic.magic_edit): fixed docstring
2413 (inconsistent with options).
2416 (inconsistent with options).
2414
2417
2415 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
2418 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
2416 manually disabled, I don't know why. Fixed it.
2419 manually disabled, I don't know why. Fixed it.
2417 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
2420 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
2418 eps output.
2421 eps output.
2419
2422
2420 2002-11-12 Fernando Perez <fperez@colorado.edu>
2423 2002-11-12 Fernando Perez <fperez@colorado.edu>
2421
2424
2422 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
2425 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
2423 don't propagate up to caller. Fixes crash reported by François
2426 don't propagate up to caller. Fixes crash reported by François
2424 Pinard.
2427 Pinard.
2425
2428
2426 2002-11-09 Fernando Perez <fperez@colorado.edu>
2429 2002-11-09 Fernando Perez <fperez@colorado.edu>
2427
2430
2428 * IPython/ipmaker.py (make_IPython): fixed problem with writing
2431 * IPython/ipmaker.py (make_IPython): fixed problem with writing
2429 history file for new users.
2432 history file for new users.
2430 (make_IPython): fixed bug where initial install would leave the
2433 (make_IPython): fixed bug where initial install would leave the
2431 user running in the .ipython dir.
2434 user running in the .ipython dir.
2432 (make_IPython): fixed bug where config dir .ipython would be
2435 (make_IPython): fixed bug where config dir .ipython would be
2433 created regardless of the given -ipythondir option. Thanks to Cory
2436 created regardless of the given -ipythondir option. Thanks to Cory
2434 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
2437 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
2435
2438
2436 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
2439 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
2437 type confirmations. Will need to use it in all of IPython's code
2440 type confirmations. Will need to use it in all of IPython's code
2438 consistently.
2441 consistently.
2439
2442
2440 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
2443 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
2441 context to print 31 lines instead of the default 5. This will make
2444 context to print 31 lines instead of the default 5. This will make
2442 the crash reports extremely detailed in case the problem is in
2445 the crash reports extremely detailed in case the problem is in
2443 libraries I don't have access to.
2446 libraries I don't have access to.
2444
2447
2445 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
2448 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
2446 line of defense' code to still crash, but giving users fair
2449 line of defense' code to still crash, but giving users fair
2447 warning. I don't want internal errors to go unreported: if there's
2450 warning. I don't want internal errors to go unreported: if there's
2448 an internal problem, IPython should crash and generate a full
2451 an internal problem, IPython should crash and generate a full
2449 report.
2452 report.
2450
2453
2451 2002-11-08 Fernando Perez <fperez@colorado.edu>
2454 2002-11-08 Fernando Perez <fperez@colorado.edu>
2452
2455
2453 * IPython/iplib.py (InteractiveShell.interact): added code to trap
2456 * IPython/iplib.py (InteractiveShell.interact): added code to trap
2454 otherwise uncaught exceptions which can appear if people set
2457 otherwise uncaught exceptions which can appear if people set
2455 sys.stdout to something badly broken. Thanks to a crash report
2458 sys.stdout to something badly broken. Thanks to a crash report
2456 from henni-AT-mail.brainbot.com.
2459 from henni-AT-mail.brainbot.com.
2457
2460
2458 2002-11-04 Fernando Perez <fperez@colorado.edu>
2461 2002-11-04 Fernando Perez <fperez@colorado.edu>
2459
2462
2460 * IPython/iplib.py (InteractiveShell.interact): added
2463 * IPython/iplib.py (InteractiveShell.interact): added
2461 __IPYTHON__active to the builtins. It's a flag which goes on when
2464 __IPYTHON__active to the builtins. It's a flag which goes on when
2462 the interaction starts and goes off again when it stops. This
2465 the interaction starts and goes off again when it stops. This
2463 allows embedding code to detect being inside IPython. Before this
2466 allows embedding code to detect being inside IPython. Before this
2464 was done via __IPYTHON__, but that only shows that an IPython
2467 was done via __IPYTHON__, but that only shows that an IPython
2465 instance has been created.
2468 instance has been created.
2466
2469
2467 * IPython/Magic.py (Magic.magic_env): I realized that in a
2470 * IPython/Magic.py (Magic.magic_env): I realized that in a
2468 UserDict, instance.data holds the data as a normal dict. So I
2471 UserDict, instance.data holds the data as a normal dict. So I
2469 modified @env to return os.environ.data instead of rebuilding a
2472 modified @env to return os.environ.data instead of rebuilding a
2470 dict by hand.
2473 dict by hand.
2471
2474
2472 2002-11-02 Fernando Perez <fperez@colorado.edu>
2475 2002-11-02 Fernando Perez <fperez@colorado.edu>
2473
2476
2474 * IPython/genutils.py (warn): changed so that level 1 prints no
2477 * IPython/genutils.py (warn): changed so that level 1 prints no
2475 header. Level 2 is now the default (with 'WARNING' header, as
2478 header. Level 2 is now the default (with 'WARNING' header, as
2476 before). I think I tracked all places where changes were needed in
2479 before). I think I tracked all places where changes were needed in
2477 IPython, but outside code using the old level numbering may have
2480 IPython, but outside code using the old level numbering may have
2478 broken.
2481 broken.
2479
2482
2480 * IPython/iplib.py (InteractiveShell.runcode): added this to
2483 * IPython/iplib.py (InteractiveShell.runcode): added this to
2481 handle the tracebacks in SystemExit traps correctly. The previous
2484 handle the tracebacks in SystemExit traps correctly. The previous
2482 code (through interact) was printing more of the stack than
2485 code (through interact) was printing more of the stack than
2483 necessary, showing IPython internal code to the user.
2486 necessary, showing IPython internal code to the user.
2484
2487
2485 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
2488 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
2486 default. Now that the default at the confirmation prompt is yes,
2489 default. Now that the default at the confirmation prompt is yes,
2487 it's not so intrusive. François' argument that ipython sessions
2490 it's not so intrusive. François' argument that ipython sessions
2488 tend to be complex enough not to lose them from an accidental C-d,
2491 tend to be complex enough not to lose them from an accidental C-d,
2489 is a valid one.
2492 is a valid one.
2490
2493
2491 * IPython/iplib.py (InteractiveShell.interact): added a
2494 * IPython/iplib.py (InteractiveShell.interact): added a
2492 showtraceback() call to the SystemExit trap, and modified the exit
2495 showtraceback() call to the SystemExit trap, and modified the exit
2493 confirmation to have yes as the default.
2496 confirmation to have yes as the default.
2494
2497
2495 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
2498 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
2496 this file. It's been gone from the code for a long time, this was
2499 this file. It's been gone from the code for a long time, this was
2497 simply leftover junk.
2500 simply leftover junk.
2498
2501
2499 2002-11-01 Fernando Perez <fperez@colorado.edu>
2502 2002-11-01 Fernando Perez <fperez@colorado.edu>
2500
2503
2501 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
2504 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
2502 added. If set, IPython now traps EOF and asks for
2505 added. If set, IPython now traps EOF and asks for
2503 confirmation. After a request by François Pinard.
2506 confirmation. After a request by François Pinard.
2504
2507
2505 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
2508 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
2506 of @abort, and with a new (better) mechanism for handling the
2509 of @abort, and with a new (better) mechanism for handling the
2507 exceptions.
2510 exceptions.
2508
2511
2509 2002-10-27 Fernando Perez <fperez@colorado.edu>
2512 2002-10-27 Fernando Perez <fperez@colorado.edu>
2510
2513
2511 * IPython/usage.py (__doc__): updated the --help information and
2514 * IPython/usage.py (__doc__): updated the --help information and
2512 the ipythonrc file to indicate that -log generates
2515 the ipythonrc file to indicate that -log generates
2513 ./ipython.log. Also fixed the corresponding info in @logstart.
2516 ./ipython.log. Also fixed the corresponding info in @logstart.
2514 This and several other fixes in the manuals thanks to reports by
2517 This and several other fixes in the manuals thanks to reports by
2515 François Pinard <pinard-AT-iro.umontreal.ca>.
2518 François Pinard <pinard-AT-iro.umontreal.ca>.
2516
2519
2517 * IPython/Logger.py (Logger.switch_log): Fixed error message to
2520 * IPython/Logger.py (Logger.switch_log): Fixed error message to
2518 refer to @logstart (instead of @log, which doesn't exist).
2521 refer to @logstart (instead of @log, which doesn't exist).
2519
2522
2520 * IPython/iplib.py (InteractiveShell._prefilter): fixed
2523 * IPython/iplib.py (InteractiveShell._prefilter): fixed
2521 AttributeError crash. Thanks to Christopher Armstrong
2524 AttributeError crash. Thanks to Christopher Armstrong
2522 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
2525 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
2523 introduced recently (in 0.2.14pre37) with the fix to the eval
2526 introduced recently (in 0.2.14pre37) with the fix to the eval
2524 problem mentioned below.
2527 problem mentioned below.
2525
2528
2526 2002-10-17 Fernando Perez <fperez@colorado.edu>
2529 2002-10-17 Fernando Perez <fperez@colorado.edu>
2527
2530
2528 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
2531 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
2529 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
2532 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
2530
2533
2531 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
2534 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
2532 this function to fix a problem reported by Alex Schmolck. He saw
2535 this function to fix a problem reported by Alex Schmolck. He saw
2533 it with list comprehensions and generators, which were getting
2536 it with list comprehensions and generators, which were getting
2534 called twice. The real problem was an 'eval' call in testing for
2537 called twice. The real problem was an 'eval' call in testing for
2535 automagic which was evaluating the input line silently.
2538 automagic which was evaluating the input line silently.
2536
2539
2537 This is a potentially very nasty bug, if the input has side
2540 This is a potentially very nasty bug, if the input has side
2538 effects which must not be repeated. The code is much cleaner now,
2541 effects which must not be repeated. The code is much cleaner now,
2539 without any blanket 'except' left and with a regexp test for
2542 without any blanket 'except' left and with a regexp test for
2540 actual function names.
2543 actual function names.
2541
2544
2542 But an eval remains, which I'm not fully comfortable with. I just
2545 But an eval remains, which I'm not fully comfortable with. I just
2543 don't know how to find out if an expression could be a callable in
2546 don't know how to find out if an expression could be a callable in
2544 the user's namespace without doing an eval on the string. However
2547 the user's namespace without doing an eval on the string. However
2545 that string is now much more strictly checked so that no code
2548 that string is now much more strictly checked so that no code
2546 slips by, so the eval should only happen for things that can
2549 slips by, so the eval should only happen for things that can
2547 really be only function/method names.
2550 really be only function/method names.
2548
2551
2549 2002-10-15 Fernando Perez <fperez@colorado.edu>
2552 2002-10-15 Fernando Perez <fperez@colorado.edu>
2550
2553
2551 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
2554 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
2552 OSX information to main manual, removed README_Mac_OSX file from
2555 OSX information to main manual, removed README_Mac_OSX file from
2553 distribution. Also updated credits for recent additions.
2556 distribution. Also updated credits for recent additions.
2554
2557
2555 2002-10-10 Fernando Perez <fperez@colorado.edu>
2558 2002-10-10 Fernando Perez <fperez@colorado.edu>
2556
2559
2557 * README_Mac_OSX: Added a README for Mac OSX users for fixing
2560 * README_Mac_OSX: Added a README for Mac OSX users for fixing
2558 terminal-related issues. Many thanks to Andrea Riciputi
2561 terminal-related issues. Many thanks to Andrea Riciputi
2559 <andrea.riciputi-AT-libero.it> for writing it.
2562 <andrea.riciputi-AT-libero.it> for writing it.
2560
2563
2561 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
2564 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
2562 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2565 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2563
2566
2564 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
2567 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
2565 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
2568 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
2566 <syver-en-AT-online.no> who both submitted patches for this problem.
2569 <syver-en-AT-online.no> who both submitted patches for this problem.
2567
2570
2568 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
2571 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
2569 global embedding to make sure that things don't overwrite user
2572 global embedding to make sure that things don't overwrite user
2570 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
2573 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
2571
2574
2572 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
2575 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
2573 compatibility. Thanks to Hayden Callow
2576 compatibility. Thanks to Hayden Callow
2574 <h.callow-AT-elec.canterbury.ac.nz>
2577 <h.callow-AT-elec.canterbury.ac.nz>
2575
2578
2576 2002-10-04 Fernando Perez <fperez@colorado.edu>
2579 2002-10-04 Fernando Perez <fperez@colorado.edu>
2577
2580
2578 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
2581 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
2579 Gnuplot.File objects.
2582 Gnuplot.File objects.
2580
2583
2581 2002-07-23 Fernando Perez <fperez@colorado.edu>
2584 2002-07-23 Fernando Perez <fperez@colorado.edu>
2582
2585
2583 * IPython/genutils.py (timing): Added timings() and timing() for
2586 * IPython/genutils.py (timing): Added timings() and timing() for
2584 quick access to the most commonly needed data, the execution
2587 quick access to the most commonly needed data, the execution
2585 times. Old timing() renamed to timings_out().
2588 times. Old timing() renamed to timings_out().
2586
2589
2587 2002-07-18 Fernando Perez <fperez@colorado.edu>
2590 2002-07-18 Fernando Perez <fperez@colorado.edu>
2588
2591
2589 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
2592 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
2590 bug with nested instances disrupting the parent's tab completion.
2593 bug with nested instances disrupting the parent's tab completion.
2591
2594
2592 * IPython/iplib.py (all_completions): Added Alex Schmolck's
2595 * IPython/iplib.py (all_completions): Added Alex Schmolck's
2593 all_completions code to begin the emacs integration.
2596 all_completions code to begin the emacs integration.
2594
2597
2595 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
2598 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
2596 argument to allow titling individual arrays when plotting.
2599 argument to allow titling individual arrays when plotting.
2597
2600
2598 2002-07-15 Fernando Perez <fperez@colorado.edu>
2601 2002-07-15 Fernando Perez <fperez@colorado.edu>
2599
2602
2600 * setup.py (make_shortcut): changed to retrieve the value of
2603 * setup.py (make_shortcut): changed to retrieve the value of
2601 'Program Files' directory from the registry (this value changes in
2604 'Program Files' directory from the registry (this value changes in
2602 non-english versions of Windows). Thanks to Thomas Fanslau
2605 non-english versions of Windows). Thanks to Thomas Fanslau
2603 <tfanslau-AT-gmx.de> for the report.
2606 <tfanslau-AT-gmx.de> for the report.
2604
2607
2605 2002-07-10 Fernando Perez <fperez@colorado.edu>
2608 2002-07-10 Fernando Perez <fperez@colorado.edu>
2606
2609
2607 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
2610 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
2608 a bug in pdb, which crashes if a line with only whitespace is
2611 a bug in pdb, which crashes if a line with only whitespace is
2609 entered. Bug report submitted to sourceforge.
2612 entered. Bug report submitted to sourceforge.
2610
2613
2611 2002-07-09 Fernando Perez <fperez@colorado.edu>
2614 2002-07-09 Fernando Perez <fperez@colorado.edu>
2612
2615
2613 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
2616 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
2614 reporting exceptions (it's a bug in inspect.py, I just set a
2617 reporting exceptions (it's a bug in inspect.py, I just set a
2615 workaround).
2618 workaround).
2616
2619
2617 2002-07-08 Fernando Perez <fperez@colorado.edu>
2620 2002-07-08 Fernando Perez <fperez@colorado.edu>
2618
2621
2619 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
2622 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
2620 __IPYTHON__ in __builtins__ to show up in user_ns.
2623 __IPYTHON__ in __builtins__ to show up in user_ns.
2621
2624
2622 2002-07-03 Fernando Perez <fperez@colorado.edu>
2625 2002-07-03 Fernando Perez <fperez@colorado.edu>
2623
2626
2624 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
2627 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
2625 name from @gp_set_instance to @gp_set_default.
2628 name from @gp_set_instance to @gp_set_default.
2626
2629
2627 * IPython/ipmaker.py (make_IPython): default editor value set to
2630 * IPython/ipmaker.py (make_IPython): default editor value set to
2628 '0' (a string), to match the rc file. Otherwise will crash when
2631 '0' (a string), to match the rc file. Otherwise will crash when
2629 .strip() is called on it.
2632 .strip() is called on it.
2630
2633
2631
2634
2632 2002-06-28 Fernando Perez <fperez@colorado.edu>
2635 2002-06-28 Fernando Perez <fperez@colorado.edu>
2633
2636
2634 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
2637 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
2635 of files in current directory when a file is executed via
2638 of files in current directory when a file is executed via
2636 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
2639 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
2637
2640
2638 * setup.py (manfiles): fix for rpm builds, submitted by RA
2641 * setup.py (manfiles): fix for rpm builds, submitted by RA
2639 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
2642 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
2640
2643
2641 * IPython/ipmaker.py (make_IPython): fixed lookup of default
2644 * IPython/ipmaker.py (make_IPython): fixed lookup of default
2642 editor when set to '0'. Problem was, '0' evaluates to True (it's a
2645 editor when set to '0'. Problem was, '0' evaluates to True (it's a
2643 string!). A. Schmolck caught this one.
2646 string!). A. Schmolck caught this one.
2644
2647
2645 2002-06-27 Fernando Perez <fperez@colorado.edu>
2648 2002-06-27 Fernando Perez <fperez@colorado.edu>
2646
2649
2647 * IPython/ipmaker.py (make_IPython): fixed bug when running user
2650 * IPython/ipmaker.py (make_IPython): fixed bug when running user
2648 defined files at the cmd line. __name__ wasn't being set to
2651 defined files at the cmd line. __name__ wasn't being set to
2649 __main__.
2652 __main__.
2650
2653
2651 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
2654 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
2652 regular lists and tuples besides Numeric arrays.
2655 regular lists and tuples besides Numeric arrays.
2653
2656
2654 * IPython/Prompts.py (CachedOutput.__call__): Added output
2657 * IPython/Prompts.py (CachedOutput.__call__): Added output
2655 supression for input ending with ';'. Similar to Mathematica and
2658 supression for input ending with ';'. Similar to Mathematica and
2656 Matlab. The _* vars and Out[] list are still updated, just like
2659 Matlab. The _* vars and Out[] list are still updated, just like
2657 Mathematica behaves.
2660 Mathematica behaves.
2658
2661
2659 2002-06-25 Fernando Perez <fperez@colorado.edu>
2662 2002-06-25 Fernando Perez <fperez@colorado.edu>
2660
2663
2661 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
2664 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
2662 .ini extensions for profiels under Windows.
2665 .ini extensions for profiels under Windows.
2663
2666
2664 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
2667 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
2665 string form. Fix contributed by Alexander Schmolck
2668 string form. Fix contributed by Alexander Schmolck
2666 <a.schmolck-AT-gmx.net>
2669 <a.schmolck-AT-gmx.net>
2667
2670
2668 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
2671 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
2669 pre-configured Gnuplot instance.
2672 pre-configured Gnuplot instance.
2670
2673
2671 2002-06-21 Fernando Perez <fperez@colorado.edu>
2674 2002-06-21 Fernando Perez <fperez@colorado.edu>
2672
2675
2673 * IPython/numutils.py (exp_safe): new function, works around the
2676 * IPython/numutils.py (exp_safe): new function, works around the
2674 underflow problems in Numeric.
2677 underflow problems in Numeric.
2675 (log2): New fn. Safe log in base 2: returns exact integer answer
2678 (log2): New fn. Safe log in base 2: returns exact integer answer
2676 for exact integer powers of 2.
2679 for exact integer powers of 2.
2677
2680
2678 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
2681 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
2679 properly.
2682 properly.
2680
2683
2681 2002-06-20 Fernando Perez <fperez@colorado.edu>
2684 2002-06-20 Fernando Perez <fperez@colorado.edu>
2682
2685
2683 * IPython/genutils.py (timing): new function like
2686 * IPython/genutils.py (timing): new function like
2684 Mathematica's. Similar to time_test, but returns more info.
2687 Mathematica's. Similar to time_test, but returns more info.
2685
2688
2686 2002-06-18 Fernando Perez <fperez@colorado.edu>
2689 2002-06-18 Fernando Perez <fperez@colorado.edu>
2687
2690
2688 * IPython/Magic.py (Magic.magic_save): modified @save and @r
2691 * IPython/Magic.py (Magic.magic_save): modified @save and @r
2689 according to Mike Heeter's suggestions.
2692 according to Mike Heeter's suggestions.
2690
2693
2691 2002-06-16 Fernando Perez <fperez@colorado.edu>
2694 2002-06-16 Fernando Perez <fperez@colorado.edu>
2692
2695
2693 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
2696 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
2694 system. GnuplotMagic is gone as a user-directory option. New files
2697 system. GnuplotMagic is gone as a user-directory option. New files
2695 make it easier to use all the gnuplot stuff both from external
2698 make it easier to use all the gnuplot stuff both from external
2696 programs as well as from IPython. Had to rewrite part of
2699 programs as well as from IPython. Had to rewrite part of
2697 hardcopy() b/c of a strange bug: often the ps files simply don't
2700 hardcopy() b/c of a strange bug: often the ps files simply don't
2698 get created, and require a repeat of the command (often several
2701 get created, and require a repeat of the command (often several
2699 times).
2702 times).
2700
2703
2701 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
2704 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
2702 resolve output channel at call time, so that if sys.stderr has
2705 resolve output channel at call time, so that if sys.stderr has
2703 been redirected by user this gets honored.
2706 been redirected by user this gets honored.
2704
2707
2705 2002-06-13 Fernando Perez <fperez@colorado.edu>
2708 2002-06-13 Fernando Perez <fperez@colorado.edu>
2706
2709
2707 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
2710 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
2708 IPShell. Kept a copy with the old names to avoid breaking people's
2711 IPShell. Kept a copy with the old names to avoid breaking people's
2709 embedded code.
2712 embedded code.
2710
2713
2711 * IPython/ipython: simplified it to the bare minimum after
2714 * IPython/ipython: simplified it to the bare minimum after
2712 Holger's suggestions. Added info about how to use it in
2715 Holger's suggestions. Added info about how to use it in
2713 PYTHONSTARTUP.
2716 PYTHONSTARTUP.
2714
2717
2715 * IPython/Shell.py (IPythonShell): changed the options passing
2718 * IPython/Shell.py (IPythonShell): changed the options passing
2716 from a string with funky %s replacements to a straight list. Maybe
2719 from a string with funky %s replacements to a straight list. Maybe
2717 a bit more typing, but it follows sys.argv conventions, so there's
2720 a bit more typing, but it follows sys.argv conventions, so there's
2718 less special-casing to remember.
2721 less special-casing to remember.
2719
2722
2720 2002-06-12 Fernando Perez <fperez@colorado.edu>
2723 2002-06-12 Fernando Perez <fperez@colorado.edu>
2721
2724
2722 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
2725 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
2723 command. Thanks to a suggestion by Mike Heeter.
2726 command. Thanks to a suggestion by Mike Heeter.
2724 (Magic.magic_pfile): added behavior to look at filenames if given
2727 (Magic.magic_pfile): added behavior to look at filenames if given
2725 arg is not a defined object.
2728 arg is not a defined object.
2726 (Magic.magic_save): New @save function to save code snippets. Also
2729 (Magic.magic_save): New @save function to save code snippets. Also
2727 a Mike Heeter idea.
2730 a Mike Heeter idea.
2728
2731
2729 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
2732 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
2730 plot() and replot(). Much more convenient now, especially for
2733 plot() and replot(). Much more convenient now, especially for
2731 interactive use.
2734 interactive use.
2732
2735
2733 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
2736 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
2734 filenames.
2737 filenames.
2735
2738
2736 2002-06-02 Fernando Perez <fperez@colorado.edu>
2739 2002-06-02 Fernando Perez <fperez@colorado.edu>
2737
2740
2738 * IPython/Struct.py (Struct.__init__): modified to admit
2741 * IPython/Struct.py (Struct.__init__): modified to admit
2739 initialization via another struct.
2742 initialization via another struct.
2740
2743
2741 * IPython/genutils.py (SystemExec.__init__): New stateful
2744 * IPython/genutils.py (SystemExec.__init__): New stateful
2742 interface to xsys and bq. Useful for writing system scripts.
2745 interface to xsys and bq. Useful for writing system scripts.
2743
2746
2744 2002-05-30 Fernando Perez <fperez@colorado.edu>
2747 2002-05-30 Fernando Perez <fperez@colorado.edu>
2745
2748
2746 * MANIFEST.in: Changed docfile selection to exclude all the lyx
2749 * MANIFEST.in: Changed docfile selection to exclude all the lyx
2747 documents. This will make the user download smaller (it's getting
2750 documents. This will make the user download smaller (it's getting
2748 too big).
2751 too big).
2749
2752
2750 2002-05-29 Fernando Perez <fperez@colorado.edu>
2753 2002-05-29 Fernando Perez <fperez@colorado.edu>
2751
2754
2752 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
2755 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
2753 fix problems with shelve and pickle. Seems to work, but I don't
2756 fix problems with shelve and pickle. Seems to work, but I don't
2754 know if corner cases break it. Thanks to Mike Heeter
2757 know if corner cases break it. Thanks to Mike Heeter
2755 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
2758 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
2756
2759
2757 2002-05-24 Fernando Perez <fperez@colorado.edu>
2760 2002-05-24 Fernando Perez <fperez@colorado.edu>
2758
2761
2759 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
2762 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
2760 macros having broken.
2763 macros having broken.
2761
2764
2762 2002-05-21 Fernando Perez <fperez@colorado.edu>
2765 2002-05-21 Fernando Perez <fperez@colorado.edu>
2763
2766
2764 * IPython/Magic.py (Magic.magic_logstart): fixed recently
2767 * IPython/Magic.py (Magic.magic_logstart): fixed recently
2765 introduced logging bug: all history before logging started was
2768 introduced logging bug: all history before logging started was
2766 being written one character per line! This came from the redesign
2769 being written one character per line! This came from the redesign
2767 of the input history as a special list which slices to strings,
2770 of the input history as a special list which slices to strings,
2768 not to lists.
2771 not to lists.
2769
2772
2770 2002-05-20 Fernando Perez <fperez@colorado.edu>
2773 2002-05-20 Fernando Perez <fperez@colorado.edu>
2771
2774
2772 * IPython/Prompts.py (CachedOutput.__init__): made the color table
2775 * IPython/Prompts.py (CachedOutput.__init__): made the color table
2773 be an attribute of all classes in this module. The design of these
2776 be an attribute of all classes in this module. The design of these
2774 classes needs some serious overhauling.
2777 classes needs some serious overhauling.
2775
2778
2776 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
2779 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
2777 which was ignoring '_' in option names.
2780 which was ignoring '_' in option names.
2778
2781
2779 * IPython/ultraTB.py (FormattedTB.__init__): Changed
2782 * IPython/ultraTB.py (FormattedTB.__init__): Changed
2780 'Verbose_novars' to 'Context' and made it the new default. It's a
2783 'Verbose_novars' to 'Context' and made it the new default. It's a
2781 bit more readable and also safer than verbose.
2784 bit more readable and also safer than verbose.
2782
2785
2783 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
2786 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
2784 triple-quoted strings.
2787 triple-quoted strings.
2785
2788
2786 * IPython/OInspect.py (__all__): new module exposing the object
2789 * IPython/OInspect.py (__all__): new module exposing the object
2787 introspection facilities. Now the corresponding magics are dummy
2790 introspection facilities. Now the corresponding magics are dummy
2788 wrappers around this. Having this module will make it much easier
2791 wrappers around this. Having this module will make it much easier
2789 to put these functions into our modified pdb.
2792 to put these functions into our modified pdb.
2790 This new object inspector system uses the new colorizing module,
2793 This new object inspector system uses the new colorizing module,
2791 so source code and other things are nicely syntax highlighted.
2794 so source code and other things are nicely syntax highlighted.
2792
2795
2793 2002-05-18 Fernando Perez <fperez@colorado.edu>
2796 2002-05-18 Fernando Perez <fperez@colorado.edu>
2794
2797
2795 * IPython/ColorANSI.py: Split the coloring tools into a separate
2798 * IPython/ColorANSI.py: Split the coloring tools into a separate
2796 module so I can use them in other code easier (they were part of
2799 module so I can use them in other code easier (they were part of
2797 ultraTB).
2800 ultraTB).
2798
2801
2799 2002-05-17 Fernando Perez <fperez@colorado.edu>
2802 2002-05-17 Fernando Perez <fperez@colorado.edu>
2800
2803
2801 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
2804 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
2802 fixed it to set the global 'g' also to the called instance, as
2805 fixed it to set the global 'g' also to the called instance, as
2803 long as 'g' was still a gnuplot instance (so it doesn't overwrite
2806 long as 'g' was still a gnuplot instance (so it doesn't overwrite
2804 user's 'g' variables).
2807 user's 'g' variables).
2805
2808
2806 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
2809 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
2807 global variables (aliases to _ih,_oh) so that users which expect
2810 global variables (aliases to _ih,_oh) so that users which expect
2808 In[5] or Out[7] to work aren't unpleasantly surprised.
2811 In[5] or Out[7] to work aren't unpleasantly surprised.
2809 (InputList.__getslice__): new class to allow executing slices of
2812 (InputList.__getslice__): new class to allow executing slices of
2810 input history directly. Very simple class, complements the use of
2813 input history directly. Very simple class, complements the use of
2811 macros.
2814 macros.
2812
2815
2813 2002-05-16 Fernando Perez <fperez@colorado.edu>
2816 2002-05-16 Fernando Perez <fperez@colorado.edu>
2814
2817
2815 * setup.py (docdirbase): make doc directory be just doc/IPython
2818 * setup.py (docdirbase): make doc directory be just doc/IPython
2816 without version numbers, it will reduce clutter for users.
2819 without version numbers, it will reduce clutter for users.
2817
2820
2818 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
2821 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
2819 execfile call to prevent possible memory leak. See for details:
2822 execfile call to prevent possible memory leak. See for details:
2820 http://mail.python.org/pipermail/python-list/2002-February/088476.html
2823 http://mail.python.org/pipermail/python-list/2002-February/088476.html
2821
2824
2822 2002-05-15 Fernando Perez <fperez@colorado.edu>
2825 2002-05-15 Fernando Perez <fperez@colorado.edu>
2823
2826
2824 * IPython/Magic.py (Magic.magic_psource): made the object
2827 * IPython/Magic.py (Magic.magic_psource): made the object
2825 introspection names be more standard: pdoc, pdef, pfile and
2828 introspection names be more standard: pdoc, pdef, pfile and
2826 psource. They all print/page their output, and it makes
2829 psource. They all print/page their output, and it makes
2827 remembering them easier. Kept old names for compatibility as
2830 remembering them easier. Kept old names for compatibility as
2828 aliases.
2831 aliases.
2829
2832
2830 2002-05-14 Fernando Perez <fperez@colorado.edu>
2833 2002-05-14 Fernando Perez <fperez@colorado.edu>
2831
2834
2832 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
2835 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
2833 what the mouse problem was. The trick is to use gnuplot with temp
2836 what the mouse problem was. The trick is to use gnuplot with temp
2834 files and NOT with pipes (for data communication), because having
2837 files and NOT with pipes (for data communication), because having
2835 both pipes and the mouse on is bad news.
2838 both pipes and the mouse on is bad news.
2836
2839
2837 2002-05-13 Fernando Perez <fperez@colorado.edu>
2840 2002-05-13 Fernando Perez <fperez@colorado.edu>
2838
2841
2839 * IPython/Magic.py (Magic._ofind): fixed namespace order search
2842 * IPython/Magic.py (Magic._ofind): fixed namespace order search
2840 bug. Information would be reported about builtins even when
2843 bug. Information would be reported about builtins even when
2841 user-defined functions overrode them.
2844 user-defined functions overrode them.
2842
2845
2843 2002-05-11 Fernando Perez <fperez@colorado.edu>
2846 2002-05-11 Fernando Perez <fperez@colorado.edu>
2844
2847
2845 * IPython/__init__.py (__all__): removed FlexCompleter from
2848 * IPython/__init__.py (__all__): removed FlexCompleter from
2846 __all__ so that things don't fail in platforms without readline.
2849 __all__ so that things don't fail in platforms without readline.
2847
2850
2848 2002-05-10 Fernando Perez <fperez@colorado.edu>
2851 2002-05-10 Fernando Perez <fperez@colorado.edu>
2849
2852
2850 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
2853 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
2851 it requires Numeric, effectively making Numeric a dependency for
2854 it requires Numeric, effectively making Numeric a dependency for
2852 IPython.
2855 IPython.
2853
2856
2854 * Released 0.2.13
2857 * Released 0.2.13
2855
2858
2856 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
2859 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
2857 profiler interface. Now all the major options from the profiler
2860 profiler interface. Now all the major options from the profiler
2858 module are directly supported in IPython, both for single
2861 module are directly supported in IPython, both for single
2859 expressions (@prun) and for full programs (@run -p).
2862 expressions (@prun) and for full programs (@run -p).
2860
2863
2861 2002-05-09 Fernando Perez <fperez@colorado.edu>
2864 2002-05-09 Fernando Perez <fperez@colorado.edu>
2862
2865
2863 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
2866 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
2864 magic properly formatted for screen.
2867 magic properly formatted for screen.
2865
2868
2866 * setup.py (make_shortcut): Changed things to put pdf version in
2869 * setup.py (make_shortcut): Changed things to put pdf version in
2867 doc/ instead of doc/manual (had to change lyxport a bit).
2870 doc/ instead of doc/manual (had to change lyxport a bit).
2868
2871
2869 * IPython/Magic.py (Profile.string_stats): made profile runs go
2872 * IPython/Magic.py (Profile.string_stats): made profile runs go
2870 through pager (they are long and a pager allows searching, saving,
2873 through pager (they are long and a pager allows searching, saving,
2871 etc.)
2874 etc.)
2872
2875
2873 2002-05-08 Fernando Perez <fperez@colorado.edu>
2876 2002-05-08 Fernando Perez <fperez@colorado.edu>
2874
2877
2875 * Released 0.2.12
2878 * Released 0.2.12
2876
2879
2877 2002-05-06 Fernando Perez <fperez@colorado.edu>
2880 2002-05-06 Fernando Perez <fperez@colorado.edu>
2878
2881
2879 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
2882 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
2880 introduced); 'hist n1 n2' was broken.
2883 introduced); 'hist n1 n2' was broken.
2881 (Magic.magic_pdb): added optional on/off arguments to @pdb
2884 (Magic.magic_pdb): added optional on/off arguments to @pdb
2882 (Magic.magic_run): added option -i to @run, which executes code in
2885 (Magic.magic_run): added option -i to @run, which executes code in
2883 the IPython namespace instead of a clean one. Also added @irun as
2886 the IPython namespace instead of a clean one. Also added @irun as
2884 an alias to @run -i.
2887 an alias to @run -i.
2885
2888
2886 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
2889 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
2887 fixed (it didn't really do anything, the namespaces were wrong).
2890 fixed (it didn't really do anything, the namespaces were wrong).
2888
2891
2889 * IPython/Debugger.py (__init__): Added workaround for python 2.1
2892 * IPython/Debugger.py (__init__): Added workaround for python 2.1
2890
2893
2891 * IPython/__init__.py (__all__): Fixed package namespace, now
2894 * IPython/__init__.py (__all__): Fixed package namespace, now
2892 'import IPython' does give access to IPython.<all> as
2895 'import IPython' does give access to IPython.<all> as
2893 expected. Also renamed __release__ to Release.
2896 expected. Also renamed __release__ to Release.
2894
2897
2895 * IPython/Debugger.py (__license__): created new Pdb class which
2898 * IPython/Debugger.py (__license__): created new Pdb class which
2896 functions like a drop-in for the normal pdb.Pdb but does NOT
2899 functions like a drop-in for the normal pdb.Pdb but does NOT
2897 import readline by default. This way it doesn't muck up IPython's
2900 import readline by default. This way it doesn't muck up IPython's
2898 readline handling, and now tab-completion finally works in the
2901 readline handling, and now tab-completion finally works in the
2899 debugger -- sort of. It completes things globally visible, but the
2902 debugger -- sort of. It completes things globally visible, but the
2900 completer doesn't track the stack as pdb walks it. That's a bit
2903 completer doesn't track the stack as pdb walks it. That's a bit
2901 tricky, and I'll have to implement it later.
2904 tricky, and I'll have to implement it later.
2902
2905
2903 2002-05-05 Fernando Perez <fperez@colorado.edu>
2906 2002-05-05 Fernando Perez <fperez@colorado.edu>
2904
2907
2905 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
2908 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
2906 magic docstrings when printed via ? (explicit \'s were being
2909 magic docstrings when printed via ? (explicit \'s were being
2907 printed).
2910 printed).
2908
2911
2909 * IPython/ipmaker.py (make_IPython): fixed namespace
2912 * IPython/ipmaker.py (make_IPython): fixed namespace
2910 identification bug. Now variables loaded via logs or command-line
2913 identification bug. Now variables loaded via logs or command-line
2911 files are recognized in the interactive namespace by @who.
2914 files are recognized in the interactive namespace by @who.
2912
2915
2913 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
2916 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
2914 log replay system stemming from the string form of Structs.
2917 log replay system stemming from the string form of Structs.
2915
2918
2916 * IPython/Magic.py (Macro.__init__): improved macros to properly
2919 * IPython/Magic.py (Macro.__init__): improved macros to properly
2917 handle magic commands in them.
2920 handle magic commands in them.
2918 (Magic.magic_logstart): usernames are now expanded so 'logstart
2921 (Magic.magic_logstart): usernames are now expanded so 'logstart
2919 ~/mylog' now works.
2922 ~/mylog' now works.
2920
2923
2921 * IPython/iplib.py (complete): fixed bug where paths starting with
2924 * IPython/iplib.py (complete): fixed bug where paths starting with
2922 '/' would be completed as magic names.
2925 '/' would be completed as magic names.
2923
2926
2924 2002-05-04 Fernando Perez <fperez@colorado.edu>
2927 2002-05-04 Fernando Perez <fperez@colorado.edu>
2925
2928
2926 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
2929 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
2927 allow running full programs under the profiler's control.
2930 allow running full programs under the profiler's control.
2928
2931
2929 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
2932 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
2930 mode to report exceptions verbosely but without formatting
2933 mode to report exceptions verbosely but without formatting
2931 variables. This addresses the issue of ipython 'freezing' (it's
2934 variables. This addresses the issue of ipython 'freezing' (it's
2932 not frozen, but caught in an expensive formatting loop) when huge
2935 not frozen, but caught in an expensive formatting loop) when huge
2933 variables are in the context of an exception.
2936 variables are in the context of an exception.
2934 (VerboseTB.text): Added '--->' markers at line where exception was
2937 (VerboseTB.text): Added '--->' markers at line where exception was
2935 triggered. Much clearer to read, especially in NoColor modes.
2938 triggered. Much clearer to read, especially in NoColor modes.
2936
2939
2937 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
2940 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
2938 implemented in reverse when changing to the new parse_options().
2941 implemented in reverse when changing to the new parse_options().
2939
2942
2940 2002-05-03 Fernando Perez <fperez@colorado.edu>
2943 2002-05-03 Fernando Perez <fperez@colorado.edu>
2941
2944
2942 * IPython/Magic.py (Magic.parse_options): new function so that
2945 * IPython/Magic.py (Magic.parse_options): new function so that
2943 magics can parse options easier.
2946 magics can parse options easier.
2944 (Magic.magic_prun): new function similar to profile.run(),
2947 (Magic.magic_prun): new function similar to profile.run(),
2945 suggested by Chris Hart.
2948 suggested by Chris Hart.
2946 (Magic.magic_cd): fixed behavior so that it only changes if
2949 (Magic.magic_cd): fixed behavior so that it only changes if
2947 directory actually is in history.
2950 directory actually is in history.
2948
2951
2949 * IPython/usage.py (__doc__): added information about potential
2952 * IPython/usage.py (__doc__): added information about potential
2950 slowness of Verbose exception mode when there are huge data
2953 slowness of Verbose exception mode when there are huge data
2951 structures to be formatted (thanks to Archie Paulson).
2954 structures to be formatted (thanks to Archie Paulson).
2952
2955
2953 * IPython/ipmaker.py (make_IPython): Changed default logging
2956 * IPython/ipmaker.py (make_IPython): Changed default logging
2954 (when simply called with -log) to use curr_dir/ipython.log in
2957 (when simply called with -log) to use curr_dir/ipython.log in
2955 rotate mode. Fixed crash which was occuring with -log before
2958 rotate mode. Fixed crash which was occuring with -log before
2956 (thanks to Jim Boyle).
2959 (thanks to Jim Boyle).
2957
2960
2958 2002-05-01 Fernando Perez <fperez@colorado.edu>
2961 2002-05-01 Fernando Perez <fperez@colorado.edu>
2959
2962
2960 * Released 0.2.11 for these fixes (mainly the ultraTB one which
2963 * Released 0.2.11 for these fixes (mainly the ultraTB one which
2961 was nasty -- though somewhat of a corner case).
2964 was nasty -- though somewhat of a corner case).
2962
2965
2963 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
2966 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
2964 text (was a bug).
2967 text (was a bug).
2965
2968
2966 2002-04-30 Fernando Perez <fperez@colorado.edu>
2969 2002-04-30 Fernando Perez <fperez@colorado.edu>
2967
2970
2968 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
2971 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
2969 a print after ^D or ^C from the user so that the In[] prompt
2972 a print after ^D or ^C from the user so that the In[] prompt
2970 doesn't over-run the gnuplot one.
2973 doesn't over-run the gnuplot one.
2971
2974
2972 2002-04-29 Fernando Perez <fperez@colorado.edu>
2975 2002-04-29 Fernando Perez <fperez@colorado.edu>
2973
2976
2974 * Released 0.2.10
2977 * Released 0.2.10
2975
2978
2976 * IPython/__release__.py (version): get date dynamically.
2979 * IPython/__release__.py (version): get date dynamically.
2977
2980
2978 * Misc. documentation updates thanks to Arnd's comments. Also ran
2981 * Misc. documentation updates thanks to Arnd's comments. Also ran
2979 a full spellcheck on the manual (hadn't been done in a while).
2982 a full spellcheck on the manual (hadn't been done in a while).
2980
2983
2981 2002-04-27 Fernando Perez <fperez@colorado.edu>
2984 2002-04-27 Fernando Perez <fperez@colorado.edu>
2982
2985
2983 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
2986 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
2984 starting a log in mid-session would reset the input history list.
2987 starting a log in mid-session would reset the input history list.
2985
2988
2986 2002-04-26 Fernando Perez <fperez@colorado.edu>
2989 2002-04-26 Fernando Perez <fperez@colorado.edu>
2987
2990
2988 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
2991 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
2989 all files were being included in an update. Now anything in
2992 all files were being included in an update. Now anything in
2990 UserConfig that matches [A-Za-z]*.py will go (this excludes
2993 UserConfig that matches [A-Za-z]*.py will go (this excludes
2991 __init__.py)
2994 __init__.py)
2992
2995
2993 2002-04-25 Fernando Perez <fperez@colorado.edu>
2996 2002-04-25 Fernando Perez <fperez@colorado.edu>
2994
2997
2995 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
2998 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
2996 to __builtins__ so that any form of embedded or imported code can
2999 to __builtins__ so that any form of embedded or imported code can
2997 test for being inside IPython.
3000 test for being inside IPython.
2998
3001
2999 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3002 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3000 changed to GnuplotMagic because it's now an importable module,
3003 changed to GnuplotMagic because it's now an importable module,
3001 this makes the name follow that of the standard Gnuplot module.
3004 this makes the name follow that of the standard Gnuplot module.
3002 GnuplotMagic can now be loaded at any time in mid-session.
3005 GnuplotMagic can now be loaded at any time in mid-session.
3003
3006
3004 2002-04-24 Fernando Perez <fperez@colorado.edu>
3007 2002-04-24 Fernando Perez <fperez@colorado.edu>
3005
3008
3006 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3009 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3007 the globals (IPython has its own namespace) and the
3010 the globals (IPython has its own namespace) and the
3008 PhysicalQuantity stuff is much better anyway.
3011 PhysicalQuantity stuff is much better anyway.
3009
3012
3010 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3013 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3011 embedding example to standard user directory for
3014 embedding example to standard user directory for
3012 distribution. Also put it in the manual.
3015 distribution. Also put it in the manual.
3013
3016
3014 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3017 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3015 instance as first argument (so it doesn't rely on some obscure
3018 instance as first argument (so it doesn't rely on some obscure
3016 hidden global).
3019 hidden global).
3017
3020
3018 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3021 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3019 delimiters. While it prevents ().TAB from working, it allows
3022 delimiters. While it prevents ().TAB from working, it allows
3020 completions in open (... expressions. This is by far a more common
3023 completions in open (... expressions. This is by far a more common
3021 case.
3024 case.
3022
3025
3023 2002-04-23 Fernando Perez <fperez@colorado.edu>
3026 2002-04-23 Fernando Perez <fperez@colorado.edu>
3024
3027
3025 * IPython/Extensions/InterpreterPasteInput.py: new
3028 * IPython/Extensions/InterpreterPasteInput.py: new
3026 syntax-processing module for pasting lines with >>> or ... at the
3029 syntax-processing module for pasting lines with >>> or ... at the
3027 start.
3030 start.
3028
3031
3029 * IPython/Extensions/PhysicalQ_Interactive.py
3032 * IPython/Extensions/PhysicalQ_Interactive.py
3030 (PhysicalQuantityInteractive.__int__): fixed to work with either
3033 (PhysicalQuantityInteractive.__int__): fixed to work with either
3031 Numeric or math.
3034 Numeric or math.
3032
3035
3033 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3036 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3034 provided profiles. Now we have:
3037 provided profiles. Now we have:
3035 -math -> math module as * and cmath with its own namespace.
3038 -math -> math module as * and cmath with its own namespace.
3036 -numeric -> Numeric as *, plus gnuplot & grace
3039 -numeric -> Numeric as *, plus gnuplot & grace
3037 -physics -> same as before
3040 -physics -> same as before
3038
3041
3039 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3042 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3040 user-defined magics wouldn't be found by @magic if they were
3043 user-defined magics wouldn't be found by @magic if they were
3041 defined as class methods. Also cleaned up the namespace search
3044 defined as class methods. Also cleaned up the namespace search
3042 logic and the string building (to use %s instead of many repeated
3045 logic and the string building (to use %s instead of many repeated
3043 string adds).
3046 string adds).
3044
3047
3045 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3048 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3046 of user-defined magics to operate with class methods (cleaner, in
3049 of user-defined magics to operate with class methods (cleaner, in
3047 line with the gnuplot code).
3050 line with the gnuplot code).
3048
3051
3049 2002-04-22 Fernando Perez <fperez@colorado.edu>
3052 2002-04-22 Fernando Perez <fperez@colorado.edu>
3050
3053
3051 * setup.py: updated dependency list so that manual is updated when
3054 * setup.py: updated dependency list so that manual is updated when
3052 all included files change.
3055 all included files change.
3053
3056
3054 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3057 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3055 the delimiter removal option (the fix is ugly right now).
3058 the delimiter removal option (the fix is ugly right now).
3056
3059
3057 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3060 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3058 all of the math profile (quicker loading, no conflict between
3061 all of the math profile (quicker loading, no conflict between
3059 g-9.8 and g-gnuplot).
3062 g-9.8 and g-gnuplot).
3060
3063
3061 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3064 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3062 name of post-mortem files to IPython_crash_report.txt.
3065 name of post-mortem files to IPython_crash_report.txt.
3063
3066
3064 * Cleanup/update of the docs. Added all the new readline info and
3067 * Cleanup/update of the docs. Added all the new readline info and
3065 formatted all lists as 'real lists'.
3068 formatted all lists as 'real lists'.
3066
3069
3067 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3070 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3068 tab-completion options, since the full readline parse_and_bind is
3071 tab-completion options, since the full readline parse_and_bind is
3069 now accessible.
3072 now accessible.
3070
3073
3071 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3074 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3072 handling of readline options. Now users can specify any string to
3075 handling of readline options. Now users can specify any string to
3073 be passed to parse_and_bind(), as well as the delimiters to be
3076 be passed to parse_and_bind(), as well as the delimiters to be
3074 removed.
3077 removed.
3075 (InteractiveShell.__init__): Added __name__ to the global
3078 (InteractiveShell.__init__): Added __name__ to the global
3076 namespace so that things like Itpl which rely on its existence
3079 namespace so that things like Itpl which rely on its existence
3077 don't crash.
3080 don't crash.
3078 (InteractiveShell._prefilter): Defined the default with a _ so
3081 (InteractiveShell._prefilter): Defined the default with a _ so
3079 that prefilter() is easier to override, while the default one
3082 that prefilter() is easier to override, while the default one
3080 remains available.
3083 remains available.
3081
3084
3082 2002-04-18 Fernando Perez <fperez@colorado.edu>
3085 2002-04-18 Fernando Perez <fperez@colorado.edu>
3083
3086
3084 * Added information about pdb in the docs.
3087 * Added information about pdb in the docs.
3085
3088
3086 2002-04-17 Fernando Perez <fperez@colorado.edu>
3089 2002-04-17 Fernando Perez <fperez@colorado.edu>
3087
3090
3088 * IPython/ipmaker.py (make_IPython): added rc_override option to
3091 * IPython/ipmaker.py (make_IPython): added rc_override option to
3089 allow passing config options at creation time which may override
3092 allow passing config options at creation time which may override
3090 anything set in the config files or command line. This is
3093 anything set in the config files or command line. This is
3091 particularly useful for configuring embedded instances.
3094 particularly useful for configuring embedded instances.
3092
3095
3093 2002-04-15 Fernando Perez <fperez@colorado.edu>
3096 2002-04-15 Fernando Perez <fperez@colorado.edu>
3094
3097
3095 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3098 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3096 crash embedded instances because of the input cache falling out of
3099 crash embedded instances because of the input cache falling out of
3097 sync with the output counter.
3100 sync with the output counter.
3098
3101
3099 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3102 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3100 mode which calls pdb after an uncaught exception in IPython itself.
3103 mode which calls pdb after an uncaught exception in IPython itself.
3101
3104
3102 2002-04-14 Fernando Perez <fperez@colorado.edu>
3105 2002-04-14 Fernando Perez <fperez@colorado.edu>
3103
3106
3104 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3107 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3105 readline, fix it back after each call.
3108 readline, fix it back after each call.
3106
3109
3107 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3110 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3108 method to force all access via __call__(), which guarantees that
3111 method to force all access via __call__(), which guarantees that
3109 traceback references are properly deleted.
3112 traceback references are properly deleted.
3110
3113
3111 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3114 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3112 improve printing when pprint is in use.
3115 improve printing when pprint is in use.
3113
3116
3114 2002-04-13 Fernando Perez <fperez@colorado.edu>
3117 2002-04-13 Fernando Perez <fperez@colorado.edu>
3115
3118
3116 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3119 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3117 exceptions aren't caught anymore. If the user triggers one, he
3120 exceptions aren't caught anymore. If the user triggers one, he
3118 should know why he's doing it and it should go all the way up,
3121 should know why he's doing it and it should go all the way up,
3119 just like any other exception. So now @abort will fully kill the
3122 just like any other exception. So now @abort will fully kill the
3120 embedded interpreter and the embedding code (unless that happens
3123 embedded interpreter and the embedding code (unless that happens
3121 to catch SystemExit).
3124 to catch SystemExit).
3122
3125
3123 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3126 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3124 and a debugger() method to invoke the interactive pdb debugger
3127 and a debugger() method to invoke the interactive pdb debugger
3125 after printing exception information. Also added the corresponding
3128 after printing exception information. Also added the corresponding
3126 -pdb option and @pdb magic to control this feature, and updated
3129 -pdb option and @pdb magic to control this feature, and updated
3127 the docs. After a suggestion from Christopher Hart
3130 the docs. After a suggestion from Christopher Hart
3128 (hart-AT-caltech.edu).
3131 (hart-AT-caltech.edu).
3129
3132
3130 2002-04-12 Fernando Perez <fperez@colorado.edu>
3133 2002-04-12 Fernando Perez <fperez@colorado.edu>
3131
3134
3132 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3135 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3133 the exception handlers defined by the user (not the CrashHandler)
3136 the exception handlers defined by the user (not the CrashHandler)
3134 so that user exceptions don't trigger an ipython bug report.
3137 so that user exceptions don't trigger an ipython bug report.
3135
3138
3136 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3139 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3137 configurable (it should have always been so).
3140 configurable (it should have always been so).
3138
3141
3139 2002-03-26 Fernando Perez <fperez@colorado.edu>
3142 2002-03-26 Fernando Perez <fperez@colorado.edu>
3140
3143
3141 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3144 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3142 and there to fix embedding namespace issues. This should all be
3145 and there to fix embedding namespace issues. This should all be
3143 done in a more elegant way.
3146 done in a more elegant way.
3144
3147
3145 2002-03-25 Fernando Perez <fperez@colorado.edu>
3148 2002-03-25 Fernando Perez <fperez@colorado.edu>
3146
3149
3147 * IPython/genutils.py (get_home_dir): Try to make it work under
3150 * IPython/genutils.py (get_home_dir): Try to make it work under
3148 win9x also.
3151 win9x also.
3149
3152
3150 2002-03-20 Fernando Perez <fperez@colorado.edu>
3153 2002-03-20 Fernando Perez <fperez@colorado.edu>
3151
3154
3152 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3155 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3153 sys.displayhook untouched upon __init__.
3156 sys.displayhook untouched upon __init__.
3154
3157
3155 2002-03-19 Fernando Perez <fperez@colorado.edu>
3158 2002-03-19 Fernando Perez <fperez@colorado.edu>
3156
3159
3157 * Released 0.2.9 (for embedding bug, basically).
3160 * Released 0.2.9 (for embedding bug, basically).
3158
3161
3159 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3162 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3160 exceptions so that enclosing shell's state can be restored.
3163 exceptions so that enclosing shell's state can be restored.
3161
3164
3162 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3165 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3163 naming conventions in the .ipython/ dir.
3166 naming conventions in the .ipython/ dir.
3164
3167
3165 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3168 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3166 from delimiters list so filenames with - in them get expanded.
3169 from delimiters list so filenames with - in them get expanded.
3167
3170
3168 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3171 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3169 sys.displayhook not being properly restored after an embedded call.
3172 sys.displayhook not being properly restored after an embedded call.
3170
3173
3171 2002-03-18 Fernando Perez <fperez@colorado.edu>
3174 2002-03-18 Fernando Perez <fperez@colorado.edu>
3172
3175
3173 * Released 0.2.8
3176 * Released 0.2.8
3174
3177
3175 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3178 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3176 some files weren't being included in a -upgrade.
3179 some files weren't being included in a -upgrade.
3177 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3180 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3178 on' so that the first tab completes.
3181 on' so that the first tab completes.
3179 (InteractiveShell.handle_magic): fixed bug with spaces around
3182 (InteractiveShell.handle_magic): fixed bug with spaces around
3180 quotes breaking many magic commands.
3183 quotes breaking many magic commands.
3181
3184
3182 * setup.py: added note about ignoring the syntax error messages at
3185 * setup.py: added note about ignoring the syntax error messages at
3183 installation.
3186 installation.
3184
3187
3185 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3188 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3186 streamlining the gnuplot interface, now there's only one magic @gp.
3189 streamlining the gnuplot interface, now there's only one magic @gp.
3187
3190
3188 2002-03-17 Fernando Perez <fperez@colorado.edu>
3191 2002-03-17 Fernando Perez <fperez@colorado.edu>
3189
3192
3190 * IPython/UserConfig/magic_gnuplot.py: new name for the
3193 * IPython/UserConfig/magic_gnuplot.py: new name for the
3191 example-magic_pm.py file. Much enhanced system, now with a shell
3194 example-magic_pm.py file. Much enhanced system, now with a shell
3192 for communicating directly with gnuplot, one command at a time.
3195 for communicating directly with gnuplot, one command at a time.
3193
3196
3194 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3197 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3195 setting __name__=='__main__'.
3198 setting __name__=='__main__'.
3196
3199
3197 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3200 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3198 mini-shell for accessing gnuplot from inside ipython. Should
3201 mini-shell for accessing gnuplot from inside ipython. Should
3199 extend it later for grace access too. Inspired by Arnd's
3202 extend it later for grace access too. Inspired by Arnd's
3200 suggestion.
3203 suggestion.
3201
3204
3202 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3205 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3203 calling magic functions with () in their arguments. Thanks to Arnd
3206 calling magic functions with () in their arguments. Thanks to Arnd
3204 Baecker for pointing this to me.
3207 Baecker for pointing this to me.
3205
3208
3206 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3209 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3207 infinitely for integer or complex arrays (only worked with floats).
3210 infinitely for integer or complex arrays (only worked with floats).
3208
3211
3209 2002-03-16 Fernando Perez <fperez@colorado.edu>
3212 2002-03-16 Fernando Perez <fperez@colorado.edu>
3210
3213
3211 * setup.py: Merged setup and setup_windows into a single script
3214 * setup.py: Merged setup and setup_windows into a single script
3212 which properly handles things for windows users.
3215 which properly handles things for windows users.
3213
3216
3214 2002-03-15 Fernando Perez <fperez@colorado.edu>
3217 2002-03-15 Fernando Perez <fperez@colorado.edu>
3215
3218
3216 * Big change to the manual: now the magics are all automatically
3219 * Big change to the manual: now the magics are all automatically
3217 documented. This information is generated from their docstrings
3220 documented. This information is generated from their docstrings
3218 and put in a latex file included by the manual lyx file. This way
3221 and put in a latex file included by the manual lyx file. This way
3219 we get always up to date information for the magics. The manual
3222 we get always up to date information for the magics. The manual
3220 now also has proper version information, also auto-synced.
3223 now also has proper version information, also auto-synced.
3221
3224
3222 For this to work, an undocumented --magic_docstrings option was added.
3225 For this to work, an undocumented --magic_docstrings option was added.
3223
3226
3224 2002-03-13 Fernando Perez <fperez@colorado.edu>
3227 2002-03-13 Fernando Perez <fperez@colorado.edu>
3225
3228
3226 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3229 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3227 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3230 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3228
3231
3229 2002-03-12 Fernando Perez <fperez@colorado.edu>
3232 2002-03-12 Fernando Perez <fperez@colorado.edu>
3230
3233
3231 * IPython/ultraTB.py (TermColors): changed color escapes again to
3234 * IPython/ultraTB.py (TermColors): changed color escapes again to
3232 fix the (old, reintroduced) line-wrapping bug. Basically, if
3235 fix the (old, reintroduced) line-wrapping bug. Basically, if
3233 \001..\002 aren't given in the color escapes, lines get wrapped
3236 \001..\002 aren't given in the color escapes, lines get wrapped
3234 weirdly. But giving those screws up old xterms and emacs terms. So
3237 weirdly. But giving those screws up old xterms and emacs terms. So
3235 I added some logic for emacs terms to be ok, but I can't identify old
3238 I added some logic for emacs terms to be ok, but I can't identify old
3236 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3239 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3237
3240
3238 2002-03-10 Fernando Perez <fperez@colorado.edu>
3241 2002-03-10 Fernando Perez <fperez@colorado.edu>
3239
3242
3240 * IPython/usage.py (__doc__): Various documentation cleanups and
3243 * IPython/usage.py (__doc__): Various documentation cleanups and
3241 updates, both in usage docstrings and in the manual.
3244 updates, both in usage docstrings and in the manual.
3242
3245
3243 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3246 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3244 handling of caching. Set minimum acceptabe value for having a
3247 handling of caching. Set minimum acceptabe value for having a
3245 cache at 20 values.
3248 cache at 20 values.
3246
3249
3247 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3250 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3248 install_first_time function to a method, renamed it and added an
3251 install_first_time function to a method, renamed it and added an
3249 'upgrade' mode. Now people can update their config directory with
3252 'upgrade' mode. Now people can update their config directory with
3250 a simple command line switch (-upgrade, also new).
3253 a simple command line switch (-upgrade, also new).
3251
3254
3252 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3255 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3253 @file (convenient for automagic users under Python >= 2.2).
3256 @file (convenient for automagic users under Python >= 2.2).
3254 Removed @files (it seemed more like a plural than an abbrev. of
3257 Removed @files (it seemed more like a plural than an abbrev. of
3255 'file show').
3258 'file show').
3256
3259
3257 * IPython/iplib.py (install_first_time): Fixed crash if there were
3260 * IPython/iplib.py (install_first_time): Fixed crash if there were
3258 backup files ('~') in .ipython/ install directory.
3261 backup files ('~') in .ipython/ install directory.
3259
3262
3260 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3263 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3261 system. Things look fine, but these changes are fairly
3264 system. Things look fine, but these changes are fairly
3262 intrusive. Test them for a few days.
3265 intrusive. Test them for a few days.
3263
3266
3264 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3267 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3265 the prompts system. Now all in/out prompt strings are user
3268 the prompts system. Now all in/out prompt strings are user
3266 controllable. This is particularly useful for embedding, as one
3269 controllable. This is particularly useful for embedding, as one
3267 can tag embedded instances with particular prompts.
3270 can tag embedded instances with particular prompts.
3268
3271
3269 Also removed global use of sys.ps1/2, which now allows nested
3272 Also removed global use of sys.ps1/2, which now allows nested
3270 embeddings without any problems. Added command-line options for
3273 embeddings without any problems. Added command-line options for
3271 the prompt strings.
3274 the prompt strings.
3272
3275
3273 2002-03-08 Fernando Perez <fperez@colorado.edu>
3276 2002-03-08 Fernando Perez <fperez@colorado.edu>
3274
3277
3275 * IPython/UserConfig/example-embed-short.py (ipshell): added
3278 * IPython/UserConfig/example-embed-short.py (ipshell): added
3276 example file with the bare minimum code for embedding.
3279 example file with the bare minimum code for embedding.
3277
3280
3278 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3281 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3279 functionality for the embeddable shell to be activated/deactivated
3282 functionality for the embeddable shell to be activated/deactivated
3280 either globally or at each call.
3283 either globally or at each call.
3281
3284
3282 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3285 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3283 rewriting the prompt with '--->' for auto-inputs with proper
3286 rewriting the prompt with '--->' for auto-inputs with proper
3284 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3287 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3285 this is handled by the prompts class itself, as it should.
3288 this is handled by the prompts class itself, as it should.
3286
3289
3287 2002-03-05 Fernando Perez <fperez@colorado.edu>
3290 2002-03-05 Fernando Perez <fperez@colorado.edu>
3288
3291
3289 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3292 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3290 @logstart to avoid name clashes with the math log function.
3293 @logstart to avoid name clashes with the math log function.
3291
3294
3292 * Big updates to X/Emacs section of the manual.
3295 * Big updates to X/Emacs section of the manual.
3293
3296
3294 * Removed ipython_emacs. Milan explained to me how to pass
3297 * Removed ipython_emacs. Milan explained to me how to pass
3295 arguments to ipython through Emacs. Some day I'm going to end up
3298 arguments to ipython through Emacs. Some day I'm going to end up
3296 learning some lisp...
3299 learning some lisp...
3297
3300
3298 2002-03-04 Fernando Perez <fperez@colorado.edu>
3301 2002-03-04 Fernando Perez <fperez@colorado.edu>
3299
3302
3300 * IPython/ipython_emacs: Created script to be used as the
3303 * IPython/ipython_emacs: Created script to be used as the
3301 py-python-command Emacs variable so we can pass IPython
3304 py-python-command Emacs variable so we can pass IPython
3302 parameters. I can't figure out how to tell Emacs directly to pass
3305 parameters. I can't figure out how to tell Emacs directly to pass
3303 parameters to IPython, so a dummy shell script will do it.
3306 parameters to IPython, so a dummy shell script will do it.
3304
3307
3305 Other enhancements made for things to work better under Emacs'
3308 Other enhancements made for things to work better under Emacs'
3306 various types of terminals. Many thanks to Milan Zamazal
3309 various types of terminals. Many thanks to Milan Zamazal
3307 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3310 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3308
3311
3309 2002-03-01 Fernando Perez <fperez@colorado.edu>
3312 2002-03-01 Fernando Perez <fperez@colorado.edu>
3310
3313
3311 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3314 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3312 that loading of readline is now optional. This gives better
3315 that loading of readline is now optional. This gives better
3313 control to emacs users.
3316 control to emacs users.
3314
3317
3315 * IPython/ultraTB.py (__date__): Modified color escape sequences
3318 * IPython/ultraTB.py (__date__): Modified color escape sequences
3316 and now things work fine under xterm and in Emacs' term buffers
3319 and now things work fine under xterm and in Emacs' term buffers
3317 (though not shell ones). Well, in emacs you get colors, but all
3320 (though not shell ones). Well, in emacs you get colors, but all
3318 seem to be 'light' colors (no difference between dark and light
3321 seem to be 'light' colors (no difference between dark and light
3319 ones). But the garbage chars are gone, and also in xterms. It
3322 ones). But the garbage chars are gone, and also in xterms. It
3320 seems that now I'm using 'cleaner' ansi sequences.
3323 seems that now I'm using 'cleaner' ansi sequences.
3321
3324
3322 2002-02-21 Fernando Perez <fperez@colorado.edu>
3325 2002-02-21 Fernando Perez <fperez@colorado.edu>
3323
3326
3324 * Released 0.2.7 (mainly to publish the scoping fix).
3327 * Released 0.2.7 (mainly to publish the scoping fix).
3325
3328
3326 * IPython/Logger.py (Logger.logstate): added. A corresponding
3329 * IPython/Logger.py (Logger.logstate): added. A corresponding
3327 @logstate magic was created.
3330 @logstate magic was created.
3328
3331
3329 * IPython/Magic.py: fixed nested scoping problem under Python
3332 * IPython/Magic.py: fixed nested scoping problem under Python
3330 2.1.x (automagic wasn't working).
3333 2.1.x (automagic wasn't working).
3331
3334
3332 2002-02-20 Fernando Perez <fperez@colorado.edu>
3335 2002-02-20 Fernando Perez <fperez@colorado.edu>
3333
3336
3334 * Released 0.2.6.
3337 * Released 0.2.6.
3335
3338
3336 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
3339 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
3337 option so that logs can come out without any headers at all.
3340 option so that logs can come out without any headers at all.
3338
3341
3339 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
3342 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
3340 SciPy.
3343 SciPy.
3341
3344
3342 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
3345 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
3343 that embedded IPython calls don't require vars() to be explicitly
3346 that embedded IPython calls don't require vars() to be explicitly
3344 passed. Now they are extracted from the caller's frame (code
3347 passed. Now they are extracted from the caller's frame (code
3345 snatched from Eric Jones' weave). Added better documentation to
3348 snatched from Eric Jones' weave). Added better documentation to
3346 the section on embedding and the example file.
3349 the section on embedding and the example file.
3347
3350
3348 * IPython/genutils.py (page): Changed so that under emacs, it just
3351 * IPython/genutils.py (page): Changed so that under emacs, it just
3349 prints the string. You can then page up and down in the emacs
3352 prints the string. You can then page up and down in the emacs
3350 buffer itself. This is how the builtin help() works.
3353 buffer itself. This is how the builtin help() works.
3351
3354
3352 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
3355 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
3353 macro scoping: macros need to be executed in the user's namespace
3356 macro scoping: macros need to be executed in the user's namespace
3354 to work as if they had been typed by the user.
3357 to work as if they had been typed by the user.
3355
3358
3356 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
3359 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
3357 execute automatically (no need to type 'exec...'). They then
3360 execute automatically (no need to type 'exec...'). They then
3358 behave like 'true macros'. The printing system was also modified
3361 behave like 'true macros'. The printing system was also modified
3359 for this to work.
3362 for this to work.
3360
3363
3361 2002-02-19 Fernando Perez <fperez@colorado.edu>
3364 2002-02-19 Fernando Perez <fperez@colorado.edu>
3362
3365
3363 * IPython/genutils.py (page_file): new function for paging files
3366 * IPython/genutils.py (page_file): new function for paging files
3364 in an OS-independent way. Also necessary for file viewing to work
3367 in an OS-independent way. Also necessary for file viewing to work
3365 well inside Emacs buffers.
3368 well inside Emacs buffers.
3366 (page): Added checks for being in an emacs buffer.
3369 (page): Added checks for being in an emacs buffer.
3367 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
3370 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
3368 same bug in iplib.
3371 same bug in iplib.
3369
3372
3370 2002-02-18 Fernando Perez <fperez@colorado.edu>
3373 2002-02-18 Fernando Perez <fperez@colorado.edu>
3371
3374
3372 * IPython/iplib.py (InteractiveShell.init_readline): modified use
3375 * IPython/iplib.py (InteractiveShell.init_readline): modified use
3373 of readline so that IPython can work inside an Emacs buffer.
3376 of readline so that IPython can work inside an Emacs buffer.
3374
3377
3375 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
3378 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
3376 method signatures (they weren't really bugs, but it looks cleaner
3379 method signatures (they weren't really bugs, but it looks cleaner
3377 and keeps PyChecker happy).
3380 and keeps PyChecker happy).
3378
3381
3379 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
3382 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
3380 for implementing various user-defined hooks. Currently only
3383 for implementing various user-defined hooks. Currently only
3381 display is done.
3384 display is done.
3382
3385
3383 * IPython/Prompts.py (CachedOutput._display): changed display
3386 * IPython/Prompts.py (CachedOutput._display): changed display
3384 functions so that they can be dynamically changed by users easily.
3387 functions so that they can be dynamically changed by users easily.
3385
3388
3386 * IPython/Extensions/numeric_formats.py (num_display): added an
3389 * IPython/Extensions/numeric_formats.py (num_display): added an
3387 extension for printing NumPy arrays in flexible manners. It
3390 extension for printing NumPy arrays in flexible manners. It
3388 doesn't do anything yet, but all the structure is in
3391 doesn't do anything yet, but all the structure is in
3389 place. Ultimately the plan is to implement output format control
3392 place. Ultimately the plan is to implement output format control
3390 like in Octave.
3393 like in Octave.
3391
3394
3392 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
3395 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
3393 methods are found at run-time by all the automatic machinery.
3396 methods are found at run-time by all the automatic machinery.
3394
3397
3395 2002-02-17 Fernando Perez <fperez@colorado.edu>
3398 2002-02-17 Fernando Perez <fperez@colorado.edu>
3396
3399
3397 * setup_Windows.py (make_shortcut): documented. Cleaned up the
3400 * setup_Windows.py (make_shortcut): documented. Cleaned up the
3398 whole file a little.
3401 whole file a little.
3399
3402
3400 * ToDo: closed this document. Now there's a new_design.lyx
3403 * ToDo: closed this document. Now there's a new_design.lyx
3401 document for all new ideas. Added making a pdf of it for the
3404 document for all new ideas. Added making a pdf of it for the
3402 end-user distro.
3405 end-user distro.
3403
3406
3404 * IPython/Logger.py (Logger.switch_log): Created this to replace
3407 * IPython/Logger.py (Logger.switch_log): Created this to replace
3405 logon() and logoff(). It also fixes a nasty crash reported by
3408 logon() and logoff(). It also fixes a nasty crash reported by
3406 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
3409 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
3407
3410
3408 * IPython/iplib.py (complete): got auto-completion to work with
3411 * IPython/iplib.py (complete): got auto-completion to work with
3409 automagic (I had wanted this for a long time).
3412 automagic (I had wanted this for a long time).
3410
3413
3411 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
3414 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
3412 to @file, since file() is now a builtin and clashes with automagic
3415 to @file, since file() is now a builtin and clashes with automagic
3413 for @file.
3416 for @file.
3414
3417
3415 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
3418 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
3416 of this was previously in iplib, which had grown to more than 2000
3419 of this was previously in iplib, which had grown to more than 2000
3417 lines, way too long. No new functionality, but it makes managing
3420 lines, way too long. No new functionality, but it makes managing
3418 the code a bit easier.
3421 the code a bit easier.
3419
3422
3420 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
3423 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
3421 information to crash reports.
3424 information to crash reports.
3422
3425
3423 2002-02-12 Fernando Perez <fperez@colorado.edu>
3426 2002-02-12 Fernando Perez <fperez@colorado.edu>
3424
3427
3425 * Released 0.2.5.
3428 * Released 0.2.5.
3426
3429
3427 2002-02-11 Fernando Perez <fperez@colorado.edu>
3430 2002-02-11 Fernando Perez <fperez@colorado.edu>
3428
3431
3429 * Wrote a relatively complete Windows installer. It puts
3432 * Wrote a relatively complete Windows installer. It puts
3430 everything in place, creates Start Menu entries and fixes the
3433 everything in place, creates Start Menu entries and fixes the
3431 color issues. Nothing fancy, but it works.
3434 color issues. Nothing fancy, but it works.
3432
3435
3433 2002-02-10 Fernando Perez <fperez@colorado.edu>
3436 2002-02-10 Fernando Perez <fperez@colorado.edu>
3434
3437
3435 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
3438 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
3436 os.path.expanduser() call so that we can type @run ~/myfile.py and
3439 os.path.expanduser() call so that we can type @run ~/myfile.py and
3437 have thigs work as expected.
3440 have thigs work as expected.
3438
3441
3439 * IPython/genutils.py (page): fixed exception handling so things
3442 * IPython/genutils.py (page): fixed exception handling so things
3440 work both in Unix and Windows correctly. Quitting a pager triggers
3443 work both in Unix and Windows correctly. Quitting a pager triggers
3441 an IOError/broken pipe in Unix, and in windows not finding a pager
3444 an IOError/broken pipe in Unix, and in windows not finding a pager
3442 is also an IOError, so I had to actually look at the return value
3445 is also an IOError, so I had to actually look at the return value
3443 of the exception, not just the exception itself. Should be ok now.
3446 of the exception, not just the exception itself. Should be ok now.
3444
3447
3445 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
3448 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
3446 modified to allow case-insensitive color scheme changes.
3449 modified to allow case-insensitive color scheme changes.
3447
3450
3448 2002-02-09 Fernando Perez <fperez@colorado.edu>
3451 2002-02-09 Fernando Perez <fperez@colorado.edu>
3449
3452
3450 * IPython/genutils.py (native_line_ends): new function to leave
3453 * IPython/genutils.py (native_line_ends): new function to leave
3451 user config files with os-native line-endings.
3454 user config files with os-native line-endings.
3452
3455
3453 * README and manual updates.
3456 * README and manual updates.
3454
3457
3455 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
3458 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
3456 instead of StringType to catch Unicode strings.
3459 instead of StringType to catch Unicode strings.
3457
3460
3458 * IPython/genutils.py (filefind): fixed bug for paths with
3461 * IPython/genutils.py (filefind): fixed bug for paths with
3459 embedded spaces (very common in Windows).
3462 embedded spaces (very common in Windows).
3460
3463
3461 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
3464 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
3462 files under Windows, so that they get automatically associated
3465 files under Windows, so that they get automatically associated
3463 with a text editor. Windows makes it a pain to handle
3466 with a text editor. Windows makes it a pain to handle
3464 extension-less files.
3467 extension-less files.
3465
3468
3466 * IPython/iplib.py (InteractiveShell.init_readline): Made the
3469 * IPython/iplib.py (InteractiveShell.init_readline): Made the
3467 warning about readline only occur for Posix. In Windows there's no
3470 warning about readline only occur for Posix. In Windows there's no
3468 way to get readline, so why bother with the warning.
3471 way to get readline, so why bother with the warning.
3469
3472
3470 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
3473 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
3471 for __str__ instead of dir(self), since dir() changed in 2.2.
3474 for __str__ instead of dir(self), since dir() changed in 2.2.
3472
3475
3473 * Ported to Windows! Tested on XP, I suspect it should work fine
3476 * Ported to Windows! Tested on XP, I suspect it should work fine
3474 on NT/2000, but I don't think it will work on 98 et al. That
3477 on NT/2000, but I don't think it will work on 98 et al. That
3475 series of Windows is such a piece of junk anyway that I won't try
3478 series of Windows is such a piece of junk anyway that I won't try
3476 porting it there. The XP port was straightforward, showed a few
3479 porting it there. The XP port was straightforward, showed a few
3477 bugs here and there (fixed all), in particular some string
3480 bugs here and there (fixed all), in particular some string
3478 handling stuff which required considering Unicode strings (which
3481 handling stuff which required considering Unicode strings (which
3479 Windows uses). This is good, but hasn't been too tested :) No
3482 Windows uses). This is good, but hasn't been too tested :) No
3480 fancy installer yet, I'll put a note in the manual so people at
3483 fancy installer yet, I'll put a note in the manual so people at
3481 least make manually a shortcut.
3484 least make manually a shortcut.
3482
3485
3483 * IPython/iplib.py (Magic.magic_colors): Unified the color options
3486 * IPython/iplib.py (Magic.magic_colors): Unified the color options
3484 into a single one, "colors". This now controls both prompt and
3487 into a single one, "colors". This now controls both prompt and
3485 exception color schemes, and can be changed both at startup
3488 exception color schemes, and can be changed both at startup
3486 (either via command-line switches or via ipythonrc files) and at
3489 (either via command-line switches or via ipythonrc files) and at
3487 runtime, with @colors.
3490 runtime, with @colors.
3488 (Magic.magic_run): renamed @prun to @run and removed the old
3491 (Magic.magic_run): renamed @prun to @run and removed the old
3489 @run. The two were too similar to warrant keeping both.
3492 @run. The two were too similar to warrant keeping both.
3490
3493
3491 2002-02-03 Fernando Perez <fperez@colorado.edu>
3494 2002-02-03 Fernando Perez <fperez@colorado.edu>
3492
3495
3493 * IPython/iplib.py (install_first_time): Added comment on how to
3496 * IPython/iplib.py (install_first_time): Added comment on how to
3494 configure the color options for first-time users. Put a <return>
3497 configure the color options for first-time users. Put a <return>
3495 request at the end so that small-terminal users get a chance to
3498 request at the end so that small-terminal users get a chance to
3496 read the startup info.
3499 read the startup info.
3497
3500
3498 2002-01-23 Fernando Perez <fperez@colorado.edu>
3501 2002-01-23 Fernando Perez <fperez@colorado.edu>
3499
3502
3500 * IPython/iplib.py (CachedOutput.update): Changed output memory
3503 * IPython/iplib.py (CachedOutput.update): Changed output memory
3501 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
3504 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
3502 input history we still use _i. Did this b/c these variable are
3505 input history we still use _i. Did this b/c these variable are
3503 very commonly used in interactive work, so the less we need to
3506 very commonly used in interactive work, so the less we need to
3504 type the better off we are.
3507 type the better off we are.
3505 (Magic.magic_prun): updated @prun to better handle the namespaces
3508 (Magic.magic_prun): updated @prun to better handle the namespaces
3506 the file will run in, including a fix for __name__ not being set
3509 the file will run in, including a fix for __name__ not being set
3507 before.
3510 before.
3508
3511
3509 2002-01-20 Fernando Perez <fperez@colorado.edu>
3512 2002-01-20 Fernando Perez <fperez@colorado.edu>
3510
3513
3511 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
3514 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
3512 extra garbage for Python 2.2. Need to look more carefully into
3515 extra garbage for Python 2.2. Need to look more carefully into
3513 this later.
3516 this later.
3514
3517
3515 2002-01-19 Fernando Perez <fperez@colorado.edu>
3518 2002-01-19 Fernando Perez <fperez@colorado.edu>
3516
3519
3517 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
3520 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
3518 display SyntaxError exceptions properly formatted when they occur
3521 display SyntaxError exceptions properly formatted when they occur
3519 (they can be triggered by imported code).
3522 (they can be triggered by imported code).
3520
3523
3521 2002-01-18 Fernando Perez <fperez@colorado.edu>
3524 2002-01-18 Fernando Perez <fperez@colorado.edu>
3522
3525
3523 * IPython/iplib.py (InteractiveShell.safe_execfile): now
3526 * IPython/iplib.py (InteractiveShell.safe_execfile): now
3524 SyntaxError exceptions are reported nicely formatted, instead of
3527 SyntaxError exceptions are reported nicely formatted, instead of
3525 spitting out only offset information as before.
3528 spitting out only offset information as before.
3526 (Magic.magic_prun): Added the @prun function for executing
3529 (Magic.magic_prun): Added the @prun function for executing
3527 programs with command line args inside IPython.
3530 programs with command line args inside IPython.
3528
3531
3529 2002-01-16 Fernando Perez <fperez@colorado.edu>
3532 2002-01-16 Fernando Perez <fperez@colorado.edu>
3530
3533
3531 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
3534 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
3532 to *not* include the last item given in a range. This brings their
3535 to *not* include the last item given in a range. This brings their
3533 behavior in line with Python's slicing:
3536 behavior in line with Python's slicing:
3534 a[n1:n2] -> a[n1]...a[n2-1]
3537 a[n1:n2] -> a[n1]...a[n2-1]
3535 It may be a bit less convenient, but I prefer to stick to Python's
3538 It may be a bit less convenient, but I prefer to stick to Python's
3536 conventions *everywhere*, so users never have to wonder.
3539 conventions *everywhere*, so users never have to wonder.
3537 (Magic.magic_macro): Added @macro function to ease the creation of
3540 (Magic.magic_macro): Added @macro function to ease the creation of
3538 macros.
3541 macros.
3539
3542
3540 2002-01-05 Fernando Perez <fperez@colorado.edu>
3543 2002-01-05 Fernando Perez <fperez@colorado.edu>
3541
3544
3542 * Released 0.2.4.
3545 * Released 0.2.4.
3543
3546
3544 * IPython/iplib.py (Magic.magic_pdef):
3547 * IPython/iplib.py (Magic.magic_pdef):
3545 (InteractiveShell.safe_execfile): report magic lines and error
3548 (InteractiveShell.safe_execfile): report magic lines and error
3546 lines without line numbers so one can easily copy/paste them for
3549 lines without line numbers so one can easily copy/paste them for
3547 re-execution.
3550 re-execution.
3548
3551
3549 * Updated manual with recent changes.
3552 * Updated manual with recent changes.
3550
3553
3551 * IPython/iplib.py (Magic.magic_oinfo): added constructor
3554 * IPython/iplib.py (Magic.magic_oinfo): added constructor
3552 docstring printing when class? is called. Very handy for knowing
3555 docstring printing when class? is called. Very handy for knowing
3553 how to create class instances (as long as __init__ is well
3556 how to create class instances (as long as __init__ is well
3554 documented, of course :)
3557 documented, of course :)
3555 (Magic.magic_doc): print both class and constructor docstrings.
3558 (Magic.magic_doc): print both class and constructor docstrings.
3556 (Magic.magic_pdef): give constructor info if passed a class and
3559 (Magic.magic_pdef): give constructor info if passed a class and
3557 __call__ info for callable object instances.
3560 __call__ info for callable object instances.
3558
3561
3559 2002-01-04 Fernando Perez <fperez@colorado.edu>
3562 2002-01-04 Fernando Perez <fperez@colorado.edu>
3560
3563
3561 * Made deep_reload() off by default. It doesn't always work
3564 * Made deep_reload() off by default. It doesn't always work
3562 exactly as intended, so it's probably safer to have it off. It's
3565 exactly as intended, so it's probably safer to have it off. It's
3563 still available as dreload() anyway, so nothing is lost.
3566 still available as dreload() anyway, so nothing is lost.
3564
3567
3565 2002-01-02 Fernando Perez <fperez@colorado.edu>
3568 2002-01-02 Fernando Perez <fperez@colorado.edu>
3566
3569
3567 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
3570 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
3568 so I wanted an updated release).
3571 so I wanted an updated release).
3569
3572
3570 2001-12-27 Fernando Perez <fperez@colorado.edu>
3573 2001-12-27 Fernando Perez <fperez@colorado.edu>
3571
3574
3572 * IPython/iplib.py (InteractiveShell.interact): Added the original
3575 * IPython/iplib.py (InteractiveShell.interact): Added the original
3573 code from 'code.py' for this module in order to change the
3576 code from 'code.py' for this module in order to change the
3574 handling of a KeyboardInterrupt. This was necessary b/c otherwise
3577 handling of a KeyboardInterrupt. This was necessary b/c otherwise
3575 the history cache would break when the user hit Ctrl-C, and
3578 the history cache would break when the user hit Ctrl-C, and
3576 interact() offers no way to add any hooks to it.
3579 interact() offers no way to add any hooks to it.
3577
3580
3578 2001-12-23 Fernando Perez <fperez@colorado.edu>
3581 2001-12-23 Fernando Perez <fperez@colorado.edu>
3579
3582
3580 * setup.py: added check for 'MANIFEST' before trying to remove
3583 * setup.py: added check for 'MANIFEST' before trying to remove
3581 it. Thanks to Sean Reifschneider.
3584 it. Thanks to Sean Reifschneider.
3582
3585
3583 2001-12-22 Fernando Perez <fperez@colorado.edu>
3586 2001-12-22 Fernando Perez <fperez@colorado.edu>
3584
3587
3585 * Released 0.2.2.
3588 * Released 0.2.2.
3586
3589
3587 * Finished (reasonably) writing the manual. Later will add the
3590 * Finished (reasonably) writing the manual. Later will add the
3588 python-standard navigation stylesheets, but for the time being
3591 python-standard navigation stylesheets, but for the time being
3589 it's fairly complete. Distribution will include html and pdf
3592 it's fairly complete. Distribution will include html and pdf
3590 versions.
3593 versions.
3591
3594
3592 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
3595 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
3593 (MayaVi author).
3596 (MayaVi author).
3594
3597
3595 2001-12-21 Fernando Perez <fperez@colorado.edu>
3598 2001-12-21 Fernando Perez <fperez@colorado.edu>
3596
3599
3597 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
3600 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
3598 good public release, I think (with the manual and the distutils
3601 good public release, I think (with the manual and the distutils
3599 installer). The manual can use some work, but that can go
3602 installer). The manual can use some work, but that can go
3600 slowly. Otherwise I think it's quite nice for end users. Next
3603 slowly. Otherwise I think it's quite nice for end users. Next
3601 summer, rewrite the guts of it...
3604 summer, rewrite the guts of it...
3602
3605
3603 * Changed format of ipythonrc files to use whitespace as the
3606 * Changed format of ipythonrc files to use whitespace as the
3604 separator instead of an explicit '='. Cleaner.
3607 separator instead of an explicit '='. Cleaner.
3605
3608
3606 2001-12-20 Fernando Perez <fperez@colorado.edu>
3609 2001-12-20 Fernando Perez <fperez@colorado.edu>
3607
3610
3608 * Started a manual in LyX. For now it's just a quick merge of the
3611 * Started a manual in LyX. For now it's just a quick merge of the
3609 various internal docstrings and READMEs. Later it may grow into a
3612 various internal docstrings and READMEs. Later it may grow into a
3610 nice, full-blown manual.
3613 nice, full-blown manual.
3611
3614
3612 * Set up a distutils based installer. Installation should now be
3615 * Set up a distutils based installer. Installation should now be
3613 trivially simple for end-users.
3616 trivially simple for end-users.
3614
3617
3615 2001-12-11 Fernando Perez <fperez@colorado.edu>
3618 2001-12-11 Fernando Perez <fperez@colorado.edu>
3616
3619
3617 * Released 0.2.0. First public release, announced it at
3620 * Released 0.2.0. First public release, announced it at
3618 comp.lang.python. From now on, just bugfixes...
3621 comp.lang.python. From now on, just bugfixes...
3619
3622
3620 * Went through all the files, set copyright/license notices and
3623 * Went through all the files, set copyright/license notices and
3621 cleaned up things. Ready for release.
3624 cleaned up things. Ready for release.
3622
3625
3623 2001-12-10 Fernando Perez <fperez@colorado.edu>
3626 2001-12-10 Fernando Perez <fperez@colorado.edu>
3624
3627
3625 * Changed the first-time installer not to use tarfiles. It's more
3628 * Changed the first-time installer not to use tarfiles. It's more
3626 robust now and less unix-dependent. Also makes it easier for
3629 robust now and less unix-dependent. Also makes it easier for
3627 people to later upgrade versions.
3630 people to later upgrade versions.
3628
3631
3629 * Changed @exit to @abort to reflect the fact that it's pretty
3632 * Changed @exit to @abort to reflect the fact that it's pretty
3630 brutal (a sys.exit()). The difference between @abort and Ctrl-D
3633 brutal (a sys.exit()). The difference between @abort and Ctrl-D
3631 becomes significant only when IPyhton is embedded: in that case,
3634 becomes significant only when IPyhton is embedded: in that case,
3632 C-D closes IPython only, but @abort kills the enclosing program
3635 C-D closes IPython only, but @abort kills the enclosing program
3633 too (unless it had called IPython inside a try catching
3636 too (unless it had called IPython inside a try catching
3634 SystemExit).
3637 SystemExit).
3635
3638
3636 * Created Shell module which exposes the actuall IPython Shell
3639 * Created Shell module which exposes the actuall IPython Shell
3637 classes, currently the normal and the embeddable one. This at
3640 classes, currently the normal and the embeddable one. This at
3638 least offers a stable interface we won't need to change when
3641 least offers a stable interface we won't need to change when
3639 (later) the internals are rewritten. That rewrite will be confined
3642 (later) the internals are rewritten. That rewrite will be confined
3640 to iplib and ipmaker, but the Shell interface should remain as is.
3643 to iplib and ipmaker, but the Shell interface should remain as is.
3641
3644
3642 * Added embed module which offers an embeddable IPShell object,
3645 * Added embed module which offers an embeddable IPShell object,
3643 useful to fire up IPython *inside* a running program. Great for
3646 useful to fire up IPython *inside* a running program. Great for
3644 debugging or dynamical data analysis.
3647 debugging or dynamical data analysis.
3645
3648
3646 2001-12-08 Fernando Perez <fperez@colorado.edu>
3649 2001-12-08 Fernando Perez <fperez@colorado.edu>
3647
3650
3648 * Fixed small bug preventing seeing info from methods of defined
3651 * Fixed small bug preventing seeing info from methods of defined
3649 objects (incorrect namespace in _ofind()).
3652 objects (incorrect namespace in _ofind()).
3650
3653
3651 * Documentation cleanup. Moved the main usage docstrings to a
3654 * Documentation cleanup. Moved the main usage docstrings to a
3652 separate file, usage.py (cleaner to maintain, and hopefully in the
3655 separate file, usage.py (cleaner to maintain, and hopefully in the
3653 future some perlpod-like way of producing interactive, man and
3656 future some perlpod-like way of producing interactive, man and
3654 html docs out of it will be found).
3657 html docs out of it will be found).
3655
3658
3656 * Added @profile to see your profile at any time.
3659 * Added @profile to see your profile at any time.
3657
3660
3658 * Added @p as an alias for 'print'. It's especially convenient if
3661 * Added @p as an alias for 'print'. It's especially convenient if
3659 using automagic ('p x' prints x).
3662 using automagic ('p x' prints x).
3660
3663
3661 * Small cleanups and fixes after a pychecker run.
3664 * Small cleanups and fixes after a pychecker run.
3662
3665
3663 * Changed the @cd command to handle @cd - and @cd -<n> for
3666 * Changed the @cd command to handle @cd - and @cd -<n> for
3664 visiting any directory in _dh.
3667 visiting any directory in _dh.
3665
3668
3666 * Introduced _dh, a history of visited directories. @dhist prints
3669 * Introduced _dh, a history of visited directories. @dhist prints
3667 it out with numbers.
3670 it out with numbers.
3668
3671
3669 2001-12-07 Fernando Perez <fperez@colorado.edu>
3672 2001-12-07 Fernando Perez <fperez@colorado.edu>
3670
3673
3671 * Released 0.1.22
3674 * Released 0.1.22
3672
3675
3673 * Made initialization a bit more robust against invalid color
3676 * Made initialization a bit more robust against invalid color
3674 options in user input (exit, not traceback-crash).
3677 options in user input (exit, not traceback-crash).
3675
3678
3676 * Changed the bug crash reporter to write the report only in the
3679 * Changed the bug crash reporter to write the report only in the
3677 user's .ipython directory. That way IPython won't litter people's
3680 user's .ipython directory. That way IPython won't litter people's
3678 hard disks with crash files all over the place. Also print on
3681 hard disks with crash files all over the place. Also print on
3679 screen the necessary mail command.
3682 screen the necessary mail command.
3680
3683
3681 * With the new ultraTB, implemented LightBG color scheme for light
3684 * With the new ultraTB, implemented LightBG color scheme for light
3682 background terminals. A lot of people like white backgrounds, so I
3685 background terminals. A lot of people like white backgrounds, so I
3683 guess we should at least give them something readable.
3686 guess we should at least give them something readable.
3684
3687
3685 2001-12-06 Fernando Perez <fperez@colorado.edu>
3688 2001-12-06 Fernando Perez <fperez@colorado.edu>
3686
3689
3687 * Modified the structure of ultraTB. Now there's a proper class
3690 * Modified the structure of ultraTB. Now there's a proper class
3688 for tables of color schemes which allow adding schemes easily and
3691 for tables of color schemes which allow adding schemes easily and
3689 switching the active scheme without creating a new instance every
3692 switching the active scheme without creating a new instance every
3690 time (which was ridiculous). The syntax for creating new schemes
3693 time (which was ridiculous). The syntax for creating new schemes
3691 is also cleaner. I think ultraTB is finally done, with a clean
3694 is also cleaner. I think ultraTB is finally done, with a clean
3692 class structure. Names are also much cleaner (now there's proper
3695 class structure. Names are also much cleaner (now there's proper
3693 color tables, no need for every variable to also have 'color' in
3696 color tables, no need for every variable to also have 'color' in
3694 its name).
3697 its name).
3695
3698
3696 * Broke down genutils into separate files. Now genutils only
3699 * Broke down genutils into separate files. Now genutils only
3697 contains utility functions, and classes have been moved to their
3700 contains utility functions, and classes have been moved to their
3698 own files (they had enough independent functionality to warrant
3701 own files (they had enough independent functionality to warrant
3699 it): ConfigLoader, OutputTrap, Struct.
3702 it): ConfigLoader, OutputTrap, Struct.
3700
3703
3701 2001-12-05 Fernando Perez <fperez@colorado.edu>
3704 2001-12-05 Fernando Perez <fperez@colorado.edu>
3702
3705
3703 * IPython turns 21! Released version 0.1.21, as a candidate for
3706 * IPython turns 21! Released version 0.1.21, as a candidate for
3704 public consumption. If all goes well, release in a few days.
3707 public consumption. If all goes well, release in a few days.
3705
3708
3706 * Fixed path bug (files in Extensions/ directory wouldn't be found
3709 * Fixed path bug (files in Extensions/ directory wouldn't be found
3707 unless IPython/ was explicitly in sys.path).
3710 unless IPython/ was explicitly in sys.path).
3708
3711
3709 * Extended the FlexCompleter class as MagicCompleter to allow
3712 * Extended the FlexCompleter class as MagicCompleter to allow
3710 completion of @-starting lines.
3713 completion of @-starting lines.
3711
3714
3712 * Created __release__.py file as a central repository for release
3715 * Created __release__.py file as a central repository for release
3713 info that other files can read from.
3716 info that other files can read from.
3714
3717
3715 * Fixed small bug in logging: when logging was turned on in
3718 * Fixed small bug in logging: when logging was turned on in
3716 mid-session, old lines with special meanings (!@?) were being
3719 mid-session, old lines with special meanings (!@?) were being
3717 logged without the prepended comment, which is necessary since
3720 logged without the prepended comment, which is necessary since
3718 they are not truly valid python syntax. This should make session
3721 they are not truly valid python syntax. This should make session
3719 restores produce less errors.
3722 restores produce less errors.
3720
3723
3721 * The namespace cleanup forced me to make a FlexCompleter class
3724 * The namespace cleanup forced me to make a FlexCompleter class
3722 which is nothing but a ripoff of rlcompleter, but with selectable
3725 which is nothing but a ripoff of rlcompleter, but with selectable
3723 namespace (rlcompleter only works in __main__.__dict__). I'll try
3726 namespace (rlcompleter only works in __main__.__dict__). I'll try
3724 to submit a note to the authors to see if this change can be
3727 to submit a note to the authors to see if this change can be
3725 incorporated in future rlcompleter releases (Dec.6: done)
3728 incorporated in future rlcompleter releases (Dec.6: done)
3726
3729
3727 * More fixes to namespace handling. It was a mess! Now all
3730 * More fixes to namespace handling. It was a mess! Now all
3728 explicit references to __main__.__dict__ are gone (except when
3731 explicit references to __main__.__dict__ are gone (except when
3729 really needed) and everything is handled through the namespace
3732 really needed) and everything is handled through the namespace
3730 dicts in the IPython instance. We seem to be getting somewhere
3733 dicts in the IPython instance. We seem to be getting somewhere
3731 with this, finally...
3734 with this, finally...
3732
3735
3733 * Small documentation updates.
3736 * Small documentation updates.
3734
3737
3735 * Created the Extensions directory under IPython (with an
3738 * Created the Extensions directory under IPython (with an
3736 __init__.py). Put the PhysicalQ stuff there. This directory should
3739 __init__.py). Put the PhysicalQ stuff there. This directory should
3737 be used for all special-purpose extensions.
3740 be used for all special-purpose extensions.
3738
3741
3739 * File renaming:
3742 * File renaming:
3740 ipythonlib --> ipmaker
3743 ipythonlib --> ipmaker
3741 ipplib --> iplib
3744 ipplib --> iplib
3742 This makes a bit more sense in terms of what these files actually do.
3745 This makes a bit more sense in terms of what these files actually do.
3743
3746
3744 * Moved all the classes and functions in ipythonlib to ipplib, so
3747 * Moved all the classes and functions in ipythonlib to ipplib, so
3745 now ipythonlib only has make_IPython(). This will ease up its
3748 now ipythonlib only has make_IPython(). This will ease up its
3746 splitting in smaller functional chunks later.
3749 splitting in smaller functional chunks later.
3747
3750
3748 * Cleaned up (done, I think) output of @whos. Better column
3751 * Cleaned up (done, I think) output of @whos. Better column
3749 formatting, and now shows str(var) for as much as it can, which is
3752 formatting, and now shows str(var) for as much as it can, which is
3750 typically what one gets with a 'print var'.
3753 typically what one gets with a 'print var'.
3751
3754
3752 2001-12-04 Fernando Perez <fperez@colorado.edu>
3755 2001-12-04 Fernando Perez <fperez@colorado.edu>
3753
3756
3754 * Fixed namespace problems. Now builtin/IPyhton/user names get
3757 * Fixed namespace problems. Now builtin/IPyhton/user names get
3755 properly reported in their namespace. Internal namespace handling
3758 properly reported in their namespace. Internal namespace handling
3756 is finally getting decent (not perfect yet, but much better than
3759 is finally getting decent (not perfect yet, but much better than
3757 the ad-hoc mess we had).
3760 the ad-hoc mess we had).
3758
3761
3759 * Removed -exit option. If people just want to run a python
3762 * Removed -exit option. If people just want to run a python
3760 script, that's what the normal interpreter is for. Less
3763 script, that's what the normal interpreter is for. Less
3761 unnecessary options, less chances for bugs.
3764 unnecessary options, less chances for bugs.
3762
3765
3763 * Added a crash handler which generates a complete post-mortem if
3766 * Added a crash handler which generates a complete post-mortem if
3764 IPython crashes. This will help a lot in tracking bugs down the
3767 IPython crashes. This will help a lot in tracking bugs down the
3765 road.
3768 road.
3766
3769
3767 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
3770 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
3768 which were boud to functions being reassigned would bypass the
3771 which were boud to functions being reassigned would bypass the
3769 logger, breaking the sync of _il with the prompt counter. This
3772 logger, breaking the sync of _il with the prompt counter. This
3770 would then crash IPython later when a new line was logged.
3773 would then crash IPython later when a new line was logged.
3771
3774
3772 2001-12-02 Fernando Perez <fperez@colorado.edu>
3775 2001-12-02 Fernando Perez <fperez@colorado.edu>
3773
3776
3774 * Made IPython a package. This means people don't have to clutter
3777 * Made IPython a package. This means people don't have to clutter
3775 their sys.path with yet another directory. Changed the INSTALL
3778 their sys.path with yet another directory. Changed the INSTALL
3776 file accordingly.
3779 file accordingly.
3777
3780
3778 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
3781 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
3779 sorts its output (so @who shows it sorted) and @whos formats the
3782 sorts its output (so @who shows it sorted) and @whos formats the
3780 table according to the width of the first column. Nicer, easier to
3783 table according to the width of the first column. Nicer, easier to
3781 read. Todo: write a generic table_format() which takes a list of
3784 read. Todo: write a generic table_format() which takes a list of
3782 lists and prints it nicely formatted, with optional row/column
3785 lists and prints it nicely formatted, with optional row/column
3783 separators and proper padding and justification.
3786 separators and proper padding and justification.
3784
3787
3785 * Released 0.1.20
3788 * Released 0.1.20
3786
3789
3787 * Fixed bug in @log which would reverse the inputcache list (a
3790 * Fixed bug in @log which would reverse the inputcache list (a
3788 copy operation was missing).
3791 copy operation was missing).
3789
3792
3790 * Code cleanup. @config was changed to use page(). Better, since
3793 * Code cleanup. @config was changed to use page(). Better, since
3791 its output is always quite long.
3794 its output is always quite long.
3792
3795
3793 * Itpl is back as a dependency. I was having too many problems
3796 * Itpl is back as a dependency. I was having too many problems
3794 getting the parametric aliases to work reliably, and it's just
3797 getting the parametric aliases to work reliably, and it's just
3795 easier to code weird string operations with it than playing %()s
3798 easier to code weird string operations with it than playing %()s
3796 games. It's only ~6k, so I don't think it's too big a deal.
3799 games. It's only ~6k, so I don't think it's too big a deal.
3797
3800
3798 * Found (and fixed) a very nasty bug with history. !lines weren't
3801 * Found (and fixed) a very nasty bug with history. !lines weren't
3799 getting cached, and the out of sync caches would crash
3802 getting cached, and the out of sync caches would crash
3800 IPython. Fixed it by reorganizing the prefilter/handlers/logger
3803 IPython. Fixed it by reorganizing the prefilter/handlers/logger
3801 division of labor a bit better. Bug fixed, cleaner structure.
3804 division of labor a bit better. Bug fixed, cleaner structure.
3802
3805
3803 2001-12-01 Fernando Perez <fperez@colorado.edu>
3806 2001-12-01 Fernando Perez <fperez@colorado.edu>
3804
3807
3805 * Released 0.1.19
3808 * Released 0.1.19
3806
3809
3807 * Added option -n to @hist to prevent line number printing. Much
3810 * Added option -n to @hist to prevent line number printing. Much
3808 easier to copy/paste code this way.
3811 easier to copy/paste code this way.
3809
3812
3810 * Created global _il to hold the input list. Allows easy
3813 * Created global _il to hold the input list. Allows easy
3811 re-execution of blocks of code by slicing it (inspired by Janko's
3814 re-execution of blocks of code by slicing it (inspired by Janko's
3812 comment on 'macros').
3815 comment on 'macros').
3813
3816
3814 * Small fixes and doc updates.
3817 * Small fixes and doc updates.
3815
3818
3816 * Rewrote @history function (was @h). Renamed it to @hist, @h is
3819 * Rewrote @history function (was @h). Renamed it to @hist, @h is
3817 much too fragile with automagic. Handles properly multi-line
3820 much too fragile with automagic. Handles properly multi-line
3818 statements and takes parameters.
3821 statements and takes parameters.
3819
3822
3820 2001-11-30 Fernando Perez <fperez@colorado.edu>
3823 2001-11-30 Fernando Perez <fperez@colorado.edu>
3821
3824
3822 * Version 0.1.18 released.
3825 * Version 0.1.18 released.
3823
3826
3824 * Fixed nasty namespace bug in initial module imports.
3827 * Fixed nasty namespace bug in initial module imports.
3825
3828
3826 * Added copyright/license notes to all code files (except
3829 * Added copyright/license notes to all code files (except
3827 DPyGetOpt). For the time being, LGPL. That could change.
3830 DPyGetOpt). For the time being, LGPL. That could change.
3828
3831
3829 * Rewrote a much nicer README, updated INSTALL, cleaned up
3832 * Rewrote a much nicer README, updated INSTALL, cleaned up
3830 ipythonrc-* samples.
3833 ipythonrc-* samples.
3831
3834
3832 * Overall code/documentation cleanup. Basically ready for
3835 * Overall code/documentation cleanup. Basically ready for
3833 release. Only remaining thing: licence decision (LGPL?).
3836 release. Only remaining thing: licence decision (LGPL?).
3834
3837
3835 * Converted load_config to a class, ConfigLoader. Now recursion
3838 * Converted load_config to a class, ConfigLoader. Now recursion
3836 control is better organized. Doesn't include the same file twice.
3839 control is better organized. Doesn't include the same file twice.
3837
3840
3838 2001-11-29 Fernando Perez <fperez@colorado.edu>
3841 2001-11-29 Fernando Perez <fperez@colorado.edu>
3839
3842
3840 * Got input history working. Changed output history variables from
3843 * Got input history working. Changed output history variables from
3841 _p to _o so that _i is for input and _o for output. Just cleaner
3844 _p to _o so that _i is for input and _o for output. Just cleaner
3842 convention.
3845 convention.
3843
3846
3844 * Implemented parametric aliases. This pretty much allows the
3847 * Implemented parametric aliases. This pretty much allows the
3845 alias system to offer full-blown shell convenience, I think.
3848 alias system to offer full-blown shell convenience, I think.
3846
3849
3847 * Version 0.1.17 released, 0.1.18 opened.
3850 * Version 0.1.17 released, 0.1.18 opened.
3848
3851
3849 * dot_ipython/ipythonrc (alias): added documentation.
3852 * dot_ipython/ipythonrc (alias): added documentation.
3850 (xcolor): Fixed small bug (xcolors -> xcolor)
3853 (xcolor): Fixed small bug (xcolors -> xcolor)
3851
3854
3852 * Changed the alias system. Now alias is a magic command to define
3855 * Changed the alias system. Now alias is a magic command to define
3853 aliases just like the shell. Rationale: the builtin magics should
3856 aliases just like the shell. Rationale: the builtin magics should
3854 be there for things deeply connected to IPython's
3857 be there for things deeply connected to IPython's
3855 architecture. And this is a much lighter system for what I think
3858 architecture. And this is a much lighter system for what I think
3856 is the really important feature: allowing users to define quickly
3859 is the really important feature: allowing users to define quickly
3857 magics that will do shell things for them, so they can customize
3860 magics that will do shell things for them, so they can customize
3858 IPython easily to match their work habits. If someone is really
3861 IPython easily to match their work habits. If someone is really
3859 desperate to have another name for a builtin alias, they can
3862 desperate to have another name for a builtin alias, they can
3860 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
3863 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
3861 works.
3864 works.
3862
3865
3863 2001-11-28 Fernando Perez <fperez@colorado.edu>
3866 2001-11-28 Fernando Perez <fperez@colorado.edu>
3864
3867
3865 * Changed @file so that it opens the source file at the proper
3868 * Changed @file so that it opens the source file at the proper
3866 line. Since it uses less, if your EDITOR environment is
3869 line. Since it uses less, if your EDITOR environment is
3867 configured, typing v will immediately open your editor of choice
3870 configured, typing v will immediately open your editor of choice
3868 right at the line where the object is defined. Not as quick as
3871 right at the line where the object is defined. Not as quick as
3869 having a direct @edit command, but for all intents and purposes it
3872 having a direct @edit command, but for all intents and purposes it
3870 works. And I don't have to worry about writing @edit to deal with
3873 works. And I don't have to worry about writing @edit to deal with
3871 all the editors, less does that.
3874 all the editors, less does that.
3872
3875
3873 * Version 0.1.16 released, 0.1.17 opened.
3876 * Version 0.1.16 released, 0.1.17 opened.
3874
3877
3875 * Fixed some nasty bugs in the page/page_dumb combo that could
3878 * Fixed some nasty bugs in the page/page_dumb combo that could
3876 crash IPython.
3879 crash IPython.
3877
3880
3878 2001-11-27 Fernando Perez <fperez@colorado.edu>
3881 2001-11-27 Fernando Perez <fperez@colorado.edu>
3879
3882
3880 * Version 0.1.15 released, 0.1.16 opened.
3883 * Version 0.1.15 released, 0.1.16 opened.
3881
3884
3882 * Finally got ? and ?? to work for undefined things: now it's
3885 * Finally got ? and ?? to work for undefined things: now it's
3883 possible to type {}.get? and get information about the get method
3886 possible to type {}.get? and get information about the get method
3884 of dicts, or os.path? even if only os is defined (so technically
3887 of dicts, or os.path? even if only os is defined (so technically
3885 os.path isn't). Works at any level. For example, after import os,
3888 os.path isn't). Works at any level. For example, after import os,
3886 os?, os.path?, os.path.abspath? all work. This is great, took some
3889 os?, os.path?, os.path.abspath? all work. This is great, took some
3887 work in _ofind.
3890 work in _ofind.
3888
3891
3889 * Fixed more bugs with logging. The sanest way to do it was to add
3892 * Fixed more bugs with logging. The sanest way to do it was to add
3890 to @log a 'mode' parameter. Killed two in one shot (this mode
3893 to @log a 'mode' parameter. Killed two in one shot (this mode
3891 option was a request of Janko's). I think it's finally clean
3894 option was a request of Janko's). I think it's finally clean
3892 (famous last words).
3895 (famous last words).
3893
3896
3894 * Added a page_dumb() pager which does a decent job of paging on
3897 * Added a page_dumb() pager which does a decent job of paging on
3895 screen, if better things (like less) aren't available. One less
3898 screen, if better things (like less) aren't available. One less
3896 unix dependency (someday maybe somebody will port this to
3899 unix dependency (someday maybe somebody will port this to
3897 windows).
3900 windows).
3898
3901
3899 * Fixed problem in magic_log: would lock of logging out if log
3902 * Fixed problem in magic_log: would lock of logging out if log
3900 creation failed (because it would still think it had succeeded).
3903 creation failed (because it would still think it had succeeded).
3901
3904
3902 * Improved the page() function using curses to auto-detect screen
3905 * Improved the page() function using curses to auto-detect screen
3903 size. Now it can make a much better decision on whether to print
3906 size. Now it can make a much better decision on whether to print
3904 or page a string. Option screen_length was modified: a value 0
3907 or page a string. Option screen_length was modified: a value 0
3905 means auto-detect, and that's the default now.
3908 means auto-detect, and that's the default now.
3906
3909
3907 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
3910 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
3908 go out. I'll test it for a few days, then talk to Janko about
3911 go out. I'll test it for a few days, then talk to Janko about
3909 licences and announce it.
3912 licences and announce it.
3910
3913
3911 * Fixed the length of the auto-generated ---> prompt which appears
3914 * Fixed the length of the auto-generated ---> prompt which appears
3912 for auto-parens and auto-quotes. Getting this right isn't trivial,
3915 for auto-parens and auto-quotes. Getting this right isn't trivial,
3913 with all the color escapes, different prompt types and optional
3916 with all the color escapes, different prompt types and optional
3914 separators. But it seems to be working in all the combinations.
3917 separators. But it seems to be working in all the combinations.
3915
3918
3916 2001-11-26 Fernando Perez <fperez@colorado.edu>
3919 2001-11-26 Fernando Perez <fperez@colorado.edu>
3917
3920
3918 * Wrote a regexp filter to get option types from the option names
3921 * Wrote a regexp filter to get option types from the option names
3919 string. This eliminates the need to manually keep two duplicate
3922 string. This eliminates the need to manually keep two duplicate
3920 lists.
3923 lists.
3921
3924
3922 * Removed the unneeded check_option_names. Now options are handled
3925 * Removed the unneeded check_option_names. Now options are handled
3923 in a much saner manner and it's easy to visually check that things
3926 in a much saner manner and it's easy to visually check that things
3924 are ok.
3927 are ok.
3925
3928
3926 * Updated version numbers on all files I modified to carry a
3929 * Updated version numbers on all files I modified to carry a
3927 notice so Janko and Nathan have clear version markers.
3930 notice so Janko and Nathan have clear version markers.
3928
3931
3929 * Updated docstring for ultraTB with my changes. I should send
3932 * Updated docstring for ultraTB with my changes. I should send
3930 this to Nathan.
3933 this to Nathan.
3931
3934
3932 * Lots of small fixes. Ran everything through pychecker again.
3935 * Lots of small fixes. Ran everything through pychecker again.
3933
3936
3934 * Made loading of deep_reload an cmd line option. If it's not too
3937 * Made loading of deep_reload an cmd line option. If it's not too
3935 kosher, now people can just disable it. With -nodeep_reload it's
3938 kosher, now people can just disable it. With -nodeep_reload it's
3936 still available as dreload(), it just won't overwrite reload().
3939 still available as dreload(), it just won't overwrite reload().
3937
3940
3938 * Moved many options to the no| form (-opt and -noopt
3941 * Moved many options to the no| form (-opt and -noopt
3939 accepted). Cleaner.
3942 accepted). Cleaner.
3940
3943
3941 * Changed magic_log so that if called with no parameters, it uses
3944 * Changed magic_log so that if called with no parameters, it uses
3942 'rotate' mode. That way auto-generated logs aren't automatically
3945 'rotate' mode. That way auto-generated logs aren't automatically
3943 over-written. For normal logs, now a backup is made if it exists
3946 over-written. For normal logs, now a backup is made if it exists
3944 (only 1 level of backups). A new 'backup' mode was added to the
3947 (only 1 level of backups). A new 'backup' mode was added to the
3945 Logger class to support this. This was a request by Janko.
3948 Logger class to support this. This was a request by Janko.
3946
3949
3947 * Added @logoff/@logon to stop/restart an active log.
3950 * Added @logoff/@logon to stop/restart an active log.
3948
3951
3949 * Fixed a lot of bugs in log saving/replay. It was pretty
3952 * Fixed a lot of bugs in log saving/replay. It was pretty
3950 broken. Now special lines (!@,/) appear properly in the command
3953 broken. Now special lines (!@,/) appear properly in the command
3951 history after a log replay.
3954 history after a log replay.
3952
3955
3953 * Tried and failed to implement full session saving via pickle. My
3956 * Tried and failed to implement full session saving via pickle. My
3954 idea was to pickle __main__.__dict__, but modules can't be
3957 idea was to pickle __main__.__dict__, but modules can't be
3955 pickled. This would be a better alternative to replaying logs, but
3958 pickled. This would be a better alternative to replaying logs, but
3956 seems quite tricky to get to work. Changed -session to be called
3959 seems quite tricky to get to work. Changed -session to be called
3957 -logplay, which more accurately reflects what it does. And if we
3960 -logplay, which more accurately reflects what it does. And if we
3958 ever get real session saving working, -session is now available.
3961 ever get real session saving working, -session is now available.
3959
3962
3960 * Implemented color schemes for prompts also. As for tracebacks,
3963 * Implemented color schemes for prompts also. As for tracebacks,
3961 currently only NoColor and Linux are supported. But now the
3964 currently only NoColor and Linux are supported. But now the
3962 infrastructure is in place, based on a generic ColorScheme
3965 infrastructure is in place, based on a generic ColorScheme
3963 class. So writing and activating new schemes both for the prompts
3966 class. So writing and activating new schemes both for the prompts
3964 and the tracebacks should be straightforward.
3967 and the tracebacks should be straightforward.
3965
3968
3966 * Version 0.1.13 released, 0.1.14 opened.
3969 * Version 0.1.13 released, 0.1.14 opened.
3967
3970
3968 * Changed handling of options for output cache. Now counter is
3971 * Changed handling of options for output cache. Now counter is
3969 hardwired starting at 1 and one specifies the maximum number of
3972 hardwired starting at 1 and one specifies the maximum number of
3970 entries *in the outcache* (not the max prompt counter). This is
3973 entries *in the outcache* (not the max prompt counter). This is
3971 much better, since many statements won't increase the cache
3974 much better, since many statements won't increase the cache
3972 count. It also eliminated some confusing options, now there's only
3975 count. It also eliminated some confusing options, now there's only
3973 one: cache_size.
3976 one: cache_size.
3974
3977
3975 * Added 'alias' magic function and magic_alias option in the
3978 * Added 'alias' magic function and magic_alias option in the
3976 ipythonrc file. Now the user can easily define whatever names he
3979 ipythonrc file. Now the user can easily define whatever names he
3977 wants for the magic functions without having to play weird
3980 wants for the magic functions without having to play weird
3978 namespace games. This gives IPython a real shell-like feel.
3981 namespace games. This gives IPython a real shell-like feel.
3979
3982
3980 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
3983 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
3981 @ or not).
3984 @ or not).
3982
3985
3983 This was one of the last remaining 'visible' bugs (that I know
3986 This was one of the last remaining 'visible' bugs (that I know
3984 of). I think if I can clean up the session loading so it works
3987 of). I think if I can clean up the session loading so it works
3985 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
3988 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
3986 about licensing).
3989 about licensing).
3987
3990
3988 2001-11-25 Fernando Perez <fperez@colorado.edu>
3991 2001-11-25 Fernando Perez <fperez@colorado.edu>
3989
3992
3990 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
3993 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
3991 there's a cleaner distinction between what ? and ?? show.
3994 there's a cleaner distinction between what ? and ?? show.
3992
3995
3993 * Added screen_length option. Now the user can define his own
3996 * Added screen_length option. Now the user can define his own
3994 screen size for page() operations.
3997 screen size for page() operations.
3995
3998
3996 * Implemented magic shell-like functions with automatic code
3999 * Implemented magic shell-like functions with automatic code
3997 generation. Now adding another function is just a matter of adding
4000 generation. Now adding another function is just a matter of adding
3998 an entry to a dict, and the function is dynamically generated at
4001 an entry to a dict, and the function is dynamically generated at
3999 run-time. Python has some really cool features!
4002 run-time. Python has some really cool features!
4000
4003
4001 * Renamed many options to cleanup conventions a little. Now all
4004 * Renamed many options to cleanup conventions a little. Now all
4002 are lowercase, and only underscores where needed. Also in the code
4005 are lowercase, and only underscores where needed. Also in the code
4003 option name tables are clearer.
4006 option name tables are clearer.
4004
4007
4005 * Changed prompts a little. Now input is 'In [n]:' instead of
4008 * Changed prompts a little. Now input is 'In [n]:' instead of
4006 'In[n]:='. This allows it the numbers to be aligned with the
4009 'In[n]:='. This allows it the numbers to be aligned with the
4007 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4010 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4008 Python (it was a Mathematica thing). The '...' continuation prompt
4011 Python (it was a Mathematica thing). The '...' continuation prompt
4009 was also changed a little to align better.
4012 was also changed a little to align better.
4010
4013
4011 * Fixed bug when flushing output cache. Not all _p<n> variables
4014 * Fixed bug when flushing output cache. Not all _p<n> variables
4012 exist, so their deletion needs to be wrapped in a try:
4015 exist, so their deletion needs to be wrapped in a try:
4013
4016
4014 * Figured out how to properly use inspect.formatargspec() (it
4017 * Figured out how to properly use inspect.formatargspec() (it
4015 requires the args preceded by *). So I removed all the code from
4018 requires the args preceded by *). So I removed all the code from
4016 _get_pdef in Magic, which was just replicating that.
4019 _get_pdef in Magic, which was just replicating that.
4017
4020
4018 * Added test to prefilter to allow redefining magic function names
4021 * Added test to prefilter to allow redefining magic function names
4019 as variables. This is ok, since the @ form is always available,
4022 as variables. This is ok, since the @ form is always available,
4020 but whe should allow the user to define a variable called 'ls' if
4023 but whe should allow the user to define a variable called 'ls' if
4021 he needs it.
4024 he needs it.
4022
4025
4023 * Moved the ToDo information from README into a separate ToDo.
4026 * Moved the ToDo information from README into a separate ToDo.
4024
4027
4025 * General code cleanup and small bugfixes. I think it's close to a
4028 * General code cleanup and small bugfixes. I think it's close to a
4026 state where it can be released, obviously with a big 'beta'
4029 state where it can be released, obviously with a big 'beta'
4027 warning on it.
4030 warning on it.
4028
4031
4029 * Got the magic function split to work. Now all magics are defined
4032 * Got the magic function split to work. Now all magics are defined
4030 in a separate class. It just organizes things a bit, and now
4033 in a separate class. It just organizes things a bit, and now
4031 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4034 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4032 was too long).
4035 was too long).
4033
4036
4034 * Changed @clear to @reset to avoid potential confusions with
4037 * Changed @clear to @reset to avoid potential confusions with
4035 the shell command clear. Also renamed @cl to @clear, which does
4038 the shell command clear. Also renamed @cl to @clear, which does
4036 exactly what people expect it to from their shell experience.
4039 exactly what people expect it to from their shell experience.
4037
4040
4038 Added a check to the @reset command (since it's so
4041 Added a check to the @reset command (since it's so
4039 destructive, it's probably a good idea to ask for confirmation).
4042 destructive, it's probably a good idea to ask for confirmation).
4040 But now reset only works for full namespace resetting. Since the
4043 But now reset only works for full namespace resetting. Since the
4041 del keyword is already there for deleting a few specific
4044 del keyword is already there for deleting a few specific
4042 variables, I don't see the point of having a redundant magic
4045 variables, I don't see the point of having a redundant magic
4043 function for the same task.
4046 function for the same task.
4044
4047
4045 2001-11-24 Fernando Perez <fperez@colorado.edu>
4048 2001-11-24 Fernando Perez <fperez@colorado.edu>
4046
4049
4047 * Updated the builtin docs (esp. the ? ones).
4050 * Updated the builtin docs (esp. the ? ones).
4048
4051
4049 * Ran all the code through pychecker. Not terribly impressed with
4052 * Ran all the code through pychecker. Not terribly impressed with
4050 it: lots of spurious warnings and didn't really find anything of
4053 it: lots of spurious warnings and didn't really find anything of
4051 substance (just a few modules being imported and not used).
4054 substance (just a few modules being imported and not used).
4052
4055
4053 * Implemented the new ultraTB functionality into IPython. New
4056 * Implemented the new ultraTB functionality into IPython. New
4054 option: xcolors. This chooses color scheme. xmode now only selects
4057 option: xcolors. This chooses color scheme. xmode now only selects
4055 between Plain and Verbose. Better orthogonality.
4058 between Plain and Verbose. Better orthogonality.
4056
4059
4057 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4060 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4058 mode and color scheme for the exception handlers. Now it's
4061 mode and color scheme for the exception handlers. Now it's
4059 possible to have the verbose traceback with no coloring.
4062 possible to have the verbose traceback with no coloring.
4060
4063
4061 2001-11-23 Fernando Perez <fperez@colorado.edu>
4064 2001-11-23 Fernando Perez <fperez@colorado.edu>
4062
4065
4063 * Version 0.1.12 released, 0.1.13 opened.
4066 * Version 0.1.12 released, 0.1.13 opened.
4064
4067
4065 * Removed option to set auto-quote and auto-paren escapes by
4068 * Removed option to set auto-quote and auto-paren escapes by
4066 user. The chances of breaking valid syntax are just too high. If
4069 user. The chances of breaking valid syntax are just too high. If
4067 someone *really* wants, they can always dig into the code.
4070 someone *really* wants, they can always dig into the code.
4068
4071
4069 * Made prompt separators configurable.
4072 * Made prompt separators configurable.
4070
4073
4071 2001-11-22 Fernando Perez <fperez@colorado.edu>
4074 2001-11-22 Fernando Perez <fperez@colorado.edu>
4072
4075
4073 * Small bugfixes in many places.
4076 * Small bugfixes in many places.
4074
4077
4075 * Removed the MyCompleter class from ipplib. It seemed redundant
4078 * Removed the MyCompleter class from ipplib. It seemed redundant
4076 with the C-p,C-n history search functionality. Less code to
4079 with the C-p,C-n history search functionality. Less code to
4077 maintain.
4080 maintain.
4078
4081
4079 * Moved all the original ipython.py code into ipythonlib.py. Right
4082 * Moved all the original ipython.py code into ipythonlib.py. Right
4080 now it's just one big dump into a function called make_IPython, so
4083 now it's just one big dump into a function called make_IPython, so
4081 no real modularity has been gained. But at least it makes the
4084 no real modularity has been gained. But at least it makes the
4082 wrapper script tiny, and since ipythonlib is a module, it gets
4085 wrapper script tiny, and since ipythonlib is a module, it gets
4083 compiled and startup is much faster.
4086 compiled and startup is much faster.
4084
4087
4085 This is a reasobably 'deep' change, so we should test it for a
4088 This is a reasobably 'deep' change, so we should test it for a
4086 while without messing too much more with the code.
4089 while without messing too much more with the code.
4087
4090
4088 2001-11-21 Fernando Perez <fperez@colorado.edu>
4091 2001-11-21 Fernando Perez <fperez@colorado.edu>
4089
4092
4090 * Version 0.1.11 released, 0.1.12 opened for further work.
4093 * Version 0.1.11 released, 0.1.12 opened for further work.
4091
4094
4092 * Removed dependency on Itpl. It was only needed in one place. It
4095 * Removed dependency on Itpl. It was only needed in one place. It
4093 would be nice if this became part of python, though. It makes life
4096 would be nice if this became part of python, though. It makes life
4094 *a lot* easier in some cases.
4097 *a lot* easier in some cases.
4095
4098
4096 * Simplified the prefilter code a bit. Now all handlers are
4099 * Simplified the prefilter code a bit. Now all handlers are
4097 expected to explicitly return a value (at least a blank string).
4100 expected to explicitly return a value (at least a blank string).
4098
4101
4099 * Heavy edits in ipplib. Removed the help system altogether. Now
4102 * Heavy edits in ipplib. Removed the help system altogether. Now
4100 obj?/?? is used for inspecting objects, a magic @doc prints
4103 obj?/?? is used for inspecting objects, a magic @doc prints
4101 docstrings, and full-blown Python help is accessed via the 'help'
4104 docstrings, and full-blown Python help is accessed via the 'help'
4102 keyword. This cleans up a lot of code (less to maintain) and does
4105 keyword. This cleans up a lot of code (less to maintain) and does
4103 the job. Since 'help' is now a standard Python component, might as
4106 the job. Since 'help' is now a standard Python component, might as
4104 well use it and remove duplicate functionality.
4107 well use it and remove duplicate functionality.
4105
4108
4106 Also removed the option to use ipplib as a standalone program. By
4109 Also removed the option to use ipplib as a standalone program. By
4107 now it's too dependent on other parts of IPython to function alone.
4110 now it's too dependent on other parts of IPython to function alone.
4108
4111
4109 * Fixed bug in genutils.pager. It would crash if the pager was
4112 * Fixed bug in genutils.pager. It would crash if the pager was
4110 exited immediately after opening (broken pipe).
4113 exited immediately after opening (broken pipe).
4111
4114
4112 * Trimmed down the VerboseTB reporting a little. The header is
4115 * Trimmed down the VerboseTB reporting a little. The header is
4113 much shorter now and the repeated exception arguments at the end
4116 much shorter now and the repeated exception arguments at the end
4114 have been removed. For interactive use the old header seemed a bit
4117 have been removed. For interactive use the old header seemed a bit
4115 excessive.
4118 excessive.
4116
4119
4117 * Fixed small bug in output of @whos for variables with multi-word
4120 * Fixed small bug in output of @whos for variables with multi-word
4118 types (only first word was displayed).
4121 types (only first word was displayed).
4119
4122
4120 2001-11-17 Fernando Perez <fperez@colorado.edu>
4123 2001-11-17 Fernando Perez <fperez@colorado.edu>
4121
4124
4122 * Version 0.1.10 released, 0.1.11 opened for further work.
4125 * Version 0.1.10 released, 0.1.11 opened for further work.
4123
4126
4124 * Modified dirs and friends. dirs now *returns* the stack (not
4127 * Modified dirs and friends. dirs now *returns* the stack (not
4125 prints), so one can manipulate it as a variable. Convenient to
4128 prints), so one can manipulate it as a variable. Convenient to
4126 travel along many directories.
4129 travel along many directories.
4127
4130
4128 * Fixed bug in magic_pdef: would only work with functions with
4131 * Fixed bug in magic_pdef: would only work with functions with
4129 arguments with default values.
4132 arguments with default values.
4130
4133
4131 2001-11-14 Fernando Perez <fperez@colorado.edu>
4134 2001-11-14 Fernando Perez <fperez@colorado.edu>
4132
4135
4133 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4136 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4134 example with IPython. Various other minor fixes and cleanups.
4137 example with IPython. Various other minor fixes and cleanups.
4135
4138
4136 * Version 0.1.9 released, 0.1.10 opened for further work.
4139 * Version 0.1.9 released, 0.1.10 opened for further work.
4137
4140
4138 * Added sys.path to the list of directories searched in the
4141 * Added sys.path to the list of directories searched in the
4139 execfile= option. It used to be the current directory and the
4142 execfile= option. It used to be the current directory and the
4140 user's IPYTHONDIR only.
4143 user's IPYTHONDIR only.
4141
4144
4142 2001-11-13 Fernando Perez <fperez@colorado.edu>
4145 2001-11-13 Fernando Perez <fperez@colorado.edu>
4143
4146
4144 * Reinstated the raw_input/prefilter separation that Janko had
4147 * Reinstated the raw_input/prefilter separation that Janko had
4145 initially. This gives a more convenient setup for extending the
4148 initially. This gives a more convenient setup for extending the
4146 pre-processor from the outside: raw_input always gets a string,
4149 pre-processor from the outside: raw_input always gets a string,
4147 and prefilter has to process it. We can then redefine prefilter
4150 and prefilter has to process it. We can then redefine prefilter
4148 from the outside and implement extensions for special
4151 from the outside and implement extensions for special
4149 purposes.
4152 purposes.
4150
4153
4151 Today I got one for inputting PhysicalQuantity objects
4154 Today I got one for inputting PhysicalQuantity objects
4152 (from Scientific) without needing any function calls at
4155 (from Scientific) without needing any function calls at
4153 all. Extremely convenient, and it's all done as a user-level
4156 all. Extremely convenient, and it's all done as a user-level
4154 extension (no IPython code was touched). Now instead of:
4157 extension (no IPython code was touched). Now instead of:
4155 a = PhysicalQuantity(4.2,'m/s**2')
4158 a = PhysicalQuantity(4.2,'m/s**2')
4156 one can simply say
4159 one can simply say
4157 a = 4.2 m/s**2
4160 a = 4.2 m/s**2
4158 or even
4161 or even
4159 a = 4.2 m/s^2
4162 a = 4.2 m/s^2
4160
4163
4161 I use this, but it's also a proof of concept: IPython really is
4164 I use this, but it's also a proof of concept: IPython really is
4162 fully user-extensible, even at the level of the parsing of the
4165 fully user-extensible, even at the level of the parsing of the
4163 command line. It's not trivial, but it's perfectly doable.
4166 command line. It's not trivial, but it's perfectly doable.
4164
4167
4165 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4168 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4166 the problem of modules being loaded in the inverse order in which
4169 the problem of modules being loaded in the inverse order in which
4167 they were defined in
4170 they were defined in
4168
4171
4169 * Version 0.1.8 released, 0.1.9 opened for further work.
4172 * Version 0.1.8 released, 0.1.9 opened for further work.
4170
4173
4171 * Added magics pdef, source and file. They respectively show the
4174 * Added magics pdef, source and file. They respectively show the
4172 definition line ('prototype' in C), source code and full python
4175 definition line ('prototype' in C), source code and full python
4173 file for any callable object. The object inspector oinfo uses
4176 file for any callable object. The object inspector oinfo uses
4174 these to show the same information.
4177 these to show the same information.
4175
4178
4176 * Version 0.1.7 released, 0.1.8 opened for further work.
4179 * Version 0.1.7 released, 0.1.8 opened for further work.
4177
4180
4178 * Separated all the magic functions into a class called Magic. The
4181 * Separated all the magic functions into a class called Magic. The
4179 InteractiveShell class was becoming too big for Xemacs to handle
4182 InteractiveShell class was becoming too big for Xemacs to handle
4180 (de-indenting a line would lock it up for 10 seconds while it
4183 (de-indenting a line would lock it up for 10 seconds while it
4181 backtracked on the whole class!)
4184 backtracked on the whole class!)
4182
4185
4183 FIXME: didn't work. It can be done, but right now namespaces are
4186 FIXME: didn't work. It can be done, but right now namespaces are
4184 all messed up. Do it later (reverted it for now, so at least
4187 all messed up. Do it later (reverted it for now, so at least
4185 everything works as before).
4188 everything works as before).
4186
4189
4187 * Got the object introspection system (magic_oinfo) working! I
4190 * Got the object introspection system (magic_oinfo) working! I
4188 think this is pretty much ready for release to Janko, so he can
4191 think this is pretty much ready for release to Janko, so he can
4189 test it for a while and then announce it. Pretty much 100% of what
4192 test it for a while and then announce it. Pretty much 100% of what
4190 I wanted for the 'phase 1' release is ready. Happy, tired.
4193 I wanted for the 'phase 1' release is ready. Happy, tired.
4191
4194
4192 2001-11-12 Fernando Perez <fperez@colorado.edu>
4195 2001-11-12 Fernando Perez <fperez@colorado.edu>
4193
4196
4194 * Version 0.1.6 released, 0.1.7 opened for further work.
4197 * Version 0.1.6 released, 0.1.7 opened for further work.
4195
4198
4196 * Fixed bug in printing: it used to test for truth before
4199 * Fixed bug in printing: it used to test for truth before
4197 printing, so 0 wouldn't print. Now checks for None.
4200 printing, so 0 wouldn't print. Now checks for None.
4198
4201
4199 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4202 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4200 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4203 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4201 reaches by hand into the outputcache. Think of a better way to do
4204 reaches by hand into the outputcache. Think of a better way to do
4202 this later.
4205 this later.
4203
4206
4204 * Various small fixes thanks to Nathan's comments.
4207 * Various small fixes thanks to Nathan's comments.
4205
4208
4206 * Changed magic_pprint to magic_Pprint. This way it doesn't
4209 * Changed magic_pprint to magic_Pprint. This way it doesn't
4207 collide with pprint() and the name is consistent with the command
4210 collide with pprint() and the name is consistent with the command
4208 line option.
4211 line option.
4209
4212
4210 * Changed prompt counter behavior to be fully like
4213 * Changed prompt counter behavior to be fully like
4211 Mathematica's. That is, even input that doesn't return a result
4214 Mathematica's. That is, even input that doesn't return a result
4212 raises the prompt counter. The old behavior was kind of confusing
4215 raises the prompt counter. The old behavior was kind of confusing
4213 (getting the same prompt number several times if the operation
4216 (getting the same prompt number several times if the operation
4214 didn't return a result).
4217 didn't return a result).
4215
4218
4216 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4219 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4217
4220
4218 * Fixed -Classic mode (wasn't working anymore).
4221 * Fixed -Classic mode (wasn't working anymore).
4219
4222
4220 * Added colored prompts using Nathan's new code. Colors are
4223 * Added colored prompts using Nathan's new code. Colors are
4221 currently hardwired, they can be user-configurable. For
4224 currently hardwired, they can be user-configurable. For
4222 developers, they can be chosen in file ipythonlib.py, at the
4225 developers, they can be chosen in file ipythonlib.py, at the
4223 beginning of the CachedOutput class def.
4226 beginning of the CachedOutput class def.
4224
4227
4225 2001-11-11 Fernando Perez <fperez@colorado.edu>
4228 2001-11-11 Fernando Perez <fperez@colorado.edu>
4226
4229
4227 * Version 0.1.5 released, 0.1.6 opened for further work.
4230 * Version 0.1.5 released, 0.1.6 opened for further work.
4228
4231
4229 * Changed magic_env to *return* the environment as a dict (not to
4232 * Changed magic_env to *return* the environment as a dict (not to
4230 print it). This way it prints, but it can also be processed.
4233 print it). This way it prints, but it can also be processed.
4231
4234
4232 * Added Verbose exception reporting to interactive
4235 * Added Verbose exception reporting to interactive
4233 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4236 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4234 traceback. Had to make some changes to the ultraTB file. This is
4237 traceback. Had to make some changes to the ultraTB file. This is
4235 probably the last 'big' thing in my mental todo list. This ties
4238 probably the last 'big' thing in my mental todo list. This ties
4236 in with the next entry:
4239 in with the next entry:
4237
4240
4238 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4241 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4239 has to specify is Plain, Color or Verbose for all exception
4242 has to specify is Plain, Color or Verbose for all exception
4240 handling.
4243 handling.
4241
4244
4242 * Removed ShellServices option. All this can really be done via
4245 * Removed ShellServices option. All this can really be done via
4243 the magic system. It's easier to extend, cleaner and has automatic
4246 the magic system. It's easier to extend, cleaner and has automatic
4244 namespace protection and documentation.
4247 namespace protection and documentation.
4245
4248
4246 2001-11-09 Fernando Perez <fperez@colorado.edu>
4249 2001-11-09 Fernando Perez <fperez@colorado.edu>
4247
4250
4248 * Fixed bug in output cache flushing (missing parameter to
4251 * Fixed bug in output cache flushing (missing parameter to
4249 __init__). Other small bugs fixed (found using pychecker).
4252 __init__). Other small bugs fixed (found using pychecker).
4250
4253
4251 * Version 0.1.4 opened for bugfixing.
4254 * Version 0.1.4 opened for bugfixing.
4252
4255
4253 2001-11-07 Fernando Perez <fperez@colorado.edu>
4256 2001-11-07 Fernando Perez <fperez@colorado.edu>
4254
4257
4255 * Version 0.1.3 released, mainly because of the raw_input bug.
4258 * Version 0.1.3 released, mainly because of the raw_input bug.
4256
4259
4257 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4260 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4258 and when testing for whether things were callable, a call could
4261 and when testing for whether things were callable, a call could
4259 actually be made to certain functions. They would get called again
4262 actually be made to certain functions. They would get called again
4260 once 'really' executed, with a resulting double call. A disaster
4263 once 'really' executed, with a resulting double call. A disaster
4261 in many cases (list.reverse() would never work!).
4264 in many cases (list.reverse() would never work!).
4262
4265
4263 * Removed prefilter() function, moved its code to raw_input (which
4266 * Removed prefilter() function, moved its code to raw_input (which
4264 after all was just a near-empty caller for prefilter). This saves
4267 after all was just a near-empty caller for prefilter). This saves
4265 a function call on every prompt, and simplifies the class a tiny bit.
4268 a function call on every prompt, and simplifies the class a tiny bit.
4266
4269
4267 * Fix _ip to __ip name in magic example file.
4270 * Fix _ip to __ip name in magic example file.
4268
4271
4269 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4272 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4270 work with non-gnu versions of tar.
4273 work with non-gnu versions of tar.
4271
4274
4272 2001-11-06 Fernando Perez <fperez@colorado.edu>
4275 2001-11-06 Fernando Perez <fperez@colorado.edu>
4273
4276
4274 * Version 0.1.2. Just to keep track of the recent changes.
4277 * Version 0.1.2. Just to keep track of the recent changes.
4275
4278
4276 * Fixed nasty bug in output prompt routine. It used to check 'if
4279 * Fixed nasty bug in output prompt routine. It used to check 'if
4277 arg != None...'. Problem is, this fails if arg implements a
4280 arg != None...'. Problem is, this fails if arg implements a
4278 special comparison (__cmp__) which disallows comparing to
4281 special comparison (__cmp__) which disallows comparing to
4279 None. Found it when trying to use the PhysicalQuantity module from
4282 None. Found it when trying to use the PhysicalQuantity module from
4280 ScientificPython.
4283 ScientificPython.
4281
4284
4282 2001-11-05 Fernando Perez <fperez@colorado.edu>
4285 2001-11-05 Fernando Perez <fperez@colorado.edu>
4283
4286
4284 * Also added dirs. Now the pushd/popd/dirs family functions
4287 * Also added dirs. Now the pushd/popd/dirs family functions
4285 basically like the shell, with the added convenience of going home
4288 basically like the shell, with the added convenience of going home
4286 when called with no args.
4289 when called with no args.
4287
4290
4288 * pushd/popd slightly modified to mimic shell behavior more
4291 * pushd/popd slightly modified to mimic shell behavior more
4289 closely.
4292 closely.
4290
4293
4291 * Added env,pushd,popd from ShellServices as magic functions. I
4294 * Added env,pushd,popd from ShellServices as magic functions. I
4292 think the cleanest will be to port all desired functions from
4295 think the cleanest will be to port all desired functions from
4293 ShellServices as magics and remove ShellServices altogether. This
4296 ShellServices as magics and remove ShellServices altogether. This
4294 will provide a single, clean way of adding functionality
4297 will provide a single, clean way of adding functionality
4295 (shell-type or otherwise) to IP.
4298 (shell-type or otherwise) to IP.
4296
4299
4297 2001-11-04 Fernando Perez <fperez@colorado.edu>
4300 2001-11-04 Fernando Perez <fperez@colorado.edu>
4298
4301
4299 * Added .ipython/ directory to sys.path. This way users can keep
4302 * Added .ipython/ directory to sys.path. This way users can keep
4300 customizations there and access them via import.
4303 customizations there and access them via import.
4301
4304
4302 2001-11-03 Fernando Perez <fperez@colorado.edu>
4305 2001-11-03 Fernando Perez <fperez@colorado.edu>
4303
4306
4304 * Opened version 0.1.1 for new changes.
4307 * Opened version 0.1.1 for new changes.
4305
4308
4306 * Changed version number to 0.1.0: first 'public' release, sent to
4309 * Changed version number to 0.1.0: first 'public' release, sent to
4307 Nathan and Janko.
4310 Nathan and Janko.
4308
4311
4309 * Lots of small fixes and tweaks.
4312 * Lots of small fixes and tweaks.
4310
4313
4311 * Minor changes to whos format. Now strings are shown, snipped if
4314 * Minor changes to whos format. Now strings are shown, snipped if
4312 too long.
4315 too long.
4313
4316
4314 * Changed ShellServices to work on __main__ so they show up in @who
4317 * Changed ShellServices to work on __main__ so they show up in @who
4315
4318
4316 * Help also works with ? at the end of a line:
4319 * Help also works with ? at the end of a line:
4317 ?sin and sin?
4320 ?sin and sin?
4318 both produce the same effect. This is nice, as often I use the
4321 both produce the same effect. This is nice, as often I use the
4319 tab-complete to find the name of a method, but I used to then have
4322 tab-complete to find the name of a method, but I used to then have
4320 to go to the beginning of the line to put a ? if I wanted more
4323 to go to the beginning of the line to put a ? if I wanted more
4321 info. Now I can just add the ? and hit return. Convenient.
4324 info. Now I can just add the ? and hit return. Convenient.
4322
4325
4323 2001-11-02 Fernando Perez <fperez@colorado.edu>
4326 2001-11-02 Fernando Perez <fperez@colorado.edu>
4324
4327
4325 * Python version check (>=2.1) added.
4328 * Python version check (>=2.1) added.
4326
4329
4327 * Added LazyPython documentation. At this point the docs are quite
4330 * Added LazyPython documentation. At this point the docs are quite
4328 a mess. A cleanup is in order.
4331 a mess. A cleanup is in order.
4329
4332
4330 * Auto-installer created. For some bizarre reason, the zipfiles
4333 * Auto-installer created. For some bizarre reason, the zipfiles
4331 module isn't working on my system. So I made a tar version
4334 module isn't working on my system. So I made a tar version
4332 (hopefully the command line options in various systems won't kill
4335 (hopefully the command line options in various systems won't kill
4333 me).
4336 me).
4334
4337
4335 * Fixes to Struct in genutils. Now all dictionary-like methods are
4338 * Fixes to Struct in genutils. Now all dictionary-like methods are
4336 protected (reasonably).
4339 protected (reasonably).
4337
4340
4338 * Added pager function to genutils and changed ? to print usage
4341 * Added pager function to genutils and changed ? to print usage
4339 note through it (it was too long).
4342 note through it (it was too long).
4340
4343
4341 * Added the LazyPython functionality. Works great! I changed the
4344 * Added the LazyPython functionality. Works great! I changed the
4342 auto-quote escape to ';', it's on home row and next to '. But
4345 auto-quote escape to ';', it's on home row and next to '. But
4343 both auto-quote and auto-paren (still /) escapes are command-line
4346 both auto-quote and auto-paren (still /) escapes are command-line
4344 parameters.
4347 parameters.
4345
4348
4346
4349
4347 2001-11-01 Fernando Perez <fperez@colorado.edu>
4350 2001-11-01 Fernando Perez <fperez@colorado.edu>
4348
4351
4349 * Version changed to 0.0.7. Fairly large change: configuration now
4352 * Version changed to 0.0.7. Fairly large change: configuration now
4350 is all stored in a directory, by default .ipython. There, all
4353 is all stored in a directory, by default .ipython. There, all
4351 config files have normal looking names (not .names)
4354 config files have normal looking names (not .names)
4352
4355
4353 * Version 0.0.6 Released first to Lucas and Archie as a test
4356 * Version 0.0.6 Released first to Lucas and Archie as a test
4354 run. Since it's the first 'semi-public' release, change version to
4357 run. Since it's the first 'semi-public' release, change version to
4355 > 0.0.6 for any changes now.
4358 > 0.0.6 for any changes now.
4356
4359
4357 * Stuff I had put in the ipplib.py changelog:
4360 * Stuff I had put in the ipplib.py changelog:
4358
4361
4359 Changes to InteractiveShell:
4362 Changes to InteractiveShell:
4360
4363
4361 - Made the usage message a parameter.
4364 - Made the usage message a parameter.
4362
4365
4363 - Require the name of the shell variable to be given. It's a bit
4366 - Require the name of the shell variable to be given. It's a bit
4364 of a hack, but allows the name 'shell' not to be hardwire in the
4367 of a hack, but allows the name 'shell' not to be hardwire in the
4365 magic (@) handler, which is problematic b/c it requires
4368 magic (@) handler, which is problematic b/c it requires
4366 polluting the global namespace with 'shell'. This in turn is
4369 polluting the global namespace with 'shell'. This in turn is
4367 fragile: if a user redefines a variable called shell, things
4370 fragile: if a user redefines a variable called shell, things
4368 break.
4371 break.
4369
4372
4370 - magic @: all functions available through @ need to be defined
4373 - magic @: all functions available through @ need to be defined
4371 as magic_<name>, even though they can be called simply as
4374 as magic_<name>, even though they can be called simply as
4372 @<name>. This allows the special command @magic to gather
4375 @<name>. This allows the special command @magic to gather
4373 information automatically about all existing magic functions,
4376 information automatically about all existing magic functions,
4374 even if they are run-time user extensions, by parsing the shell
4377 even if they are run-time user extensions, by parsing the shell
4375 instance __dict__ looking for special magic_ names.
4378 instance __dict__ looking for special magic_ names.
4376
4379
4377 - mainloop: added *two* local namespace parameters. This allows
4380 - mainloop: added *two* local namespace parameters. This allows
4378 the class to differentiate between parameters which were there
4381 the class to differentiate between parameters which were there
4379 before and after command line initialization was processed. This
4382 before and after command line initialization was processed. This
4380 way, later @who can show things loaded at startup by the
4383 way, later @who can show things loaded at startup by the
4381 user. This trick was necessary to make session saving/reloading
4384 user. This trick was necessary to make session saving/reloading
4382 really work: ideally after saving/exiting/reloading a session,
4385 really work: ideally after saving/exiting/reloading a session,
4383 *everythin* should look the same, including the output of @who. I
4386 *everythin* should look the same, including the output of @who. I
4384 was only able to make this work with this double namespace
4387 was only able to make this work with this double namespace
4385 trick.
4388 trick.
4386
4389
4387 - added a header to the logfile which allows (almost) full
4390 - added a header to the logfile which allows (almost) full
4388 session restoring.
4391 session restoring.
4389
4392
4390 - prepend lines beginning with @ or !, with a and log
4393 - prepend lines beginning with @ or !, with a and log
4391 them. Why? !lines: may be useful to know what you did @lines:
4394 them. Why? !lines: may be useful to know what you did @lines:
4392 they may affect session state. So when restoring a session, at
4395 they may affect session state. So when restoring a session, at
4393 least inform the user of their presence. I couldn't quite get
4396 least inform the user of their presence. I couldn't quite get
4394 them to properly re-execute, but at least the user is warned.
4397 them to properly re-execute, but at least the user is warned.
4395
4398
4396 * Started ChangeLog.
4399 * Started ChangeLog.
General Comments 0
You need to be logged in to leave comments. Login now