##// END OF EJS Templates
wildcard fixes for subclasses
fperez -
Show More
@@ -1,2509 +1,2510 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """Magic functions for InteractiveShell.
2 """Magic functions for InteractiveShell.
3
3
4 $Id: Magic.py 919 2005-10-15 07:57:05Z fperez $"""
4 $Id: Magic.py 922 2005-11-13 10:21:08Z 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.PyColorize import Parser
37 from IPython.PyColorize import Parser
38 from IPython import OInspect
38 from IPython import OInspect
39 from IPython import wildcard
39 from IPython import wildcard
40 from IPython.genutils import *
40 from IPython.genutils import *
41
41
42 # Globals to be set later by Magic constructor
42 # Globals to be set later by Magic constructor
43 MAGIC_PREFIX = ''
43 MAGIC_PREFIX = ''
44 MAGIC_ESCAPE = ''
44 MAGIC_ESCAPE = ''
45
45
46 #***************************************************************************
46 #***************************************************************************
47 # Utility functions
47 # Utility functions
48 def magic2python(cmd):
48 def magic2python(cmd):
49 """Convert a command string of magic syntax to valid Python code."""
49 """Convert a command string of magic syntax to valid Python code."""
50
50
51 if cmd.startswith('#'+MAGIC_ESCAPE) or \
51 if cmd.startswith('#'+MAGIC_ESCAPE) or \
52 cmd.startswith(MAGIC_ESCAPE):
52 cmd.startswith(MAGIC_ESCAPE):
53 if cmd[0]=='#':
53 if cmd[0]=='#':
54 cmd = cmd[1:]
54 cmd = cmd[1:]
55 # we need to return the proper line end later
55 # we need to return the proper line end later
56 if cmd[-1] == '\n':
56 if cmd[-1] == '\n':
57 endl = '\n'
57 endl = '\n'
58 else:
58 else:
59 endl = ''
59 endl = ''
60 try:
60 try:
61 func,args = cmd[1:].split(' ',1)
61 func,args = cmd[1:].split(' ',1)
62 except:
62 except:
63 func,args = cmd[1:].rstrip(),''
63 func,args = cmd[1:].rstrip(),''
64 args = args.replace('"','\\"').replace("'","\\'").rstrip()
64 args = args.replace('"','\\"').replace("'","\\'").rstrip()
65 return '%s%s ("%s")%s' % (MAGIC_PREFIX,func,args,endl)
65 return '%s%s ("%s")%s' % (MAGIC_PREFIX,func,args,endl)
66 else:
66 else:
67 return cmd
67 return cmd
68
68
69 def on_off(tag):
69 def on_off(tag):
70 """Return an ON/OFF string for a 1/0 input. Simple utility function."""
70 """Return an ON/OFF string for a 1/0 input. Simple utility function."""
71 return ['OFF','ON'][tag]
71 return ['OFF','ON'][tag]
72
72
73
73
74 #****************************************************************************
74 #****************************************************************************
75 # Utility classes
75 # Utility classes
76 class Macro:
76 class Macro:
77 """Simple class to store the value of macros as strings.
77 """Simple class to store the value of macros as strings.
78
78
79 This allows us to later exec them by checking when something is an
79 This allows us to later exec them by checking when something is an
80 instance of this class."""
80 instance of this class."""
81
81
82 def __init__(self,cmds):
82 def __init__(self,cmds):
83 """Build a macro from a list of commands."""
83 """Build a macro from a list of commands."""
84
84
85 # Since the list may include multi-line entries, first make sure that
85 # Since the list may include multi-line entries, first make sure that
86 # they've been all broken up before passing it to magic2python
86 # they've been all broken up before passing it to magic2python
87 cmdlist = map(magic2python,''.join(cmds).split('\n'))
87 cmdlist = map(magic2python,''.join(cmds).split('\n'))
88 self.value = '\n'.join(cmdlist)
88 self.value = '\n'.join(cmdlist)
89
89
90 def __str__(self):
90 def __str__(self):
91 return self.value
91 return self.value
92
92
93 #***************************************************************************
93 #***************************************************************************
94 # Main class implementing Magic functionality
94 # Main class implementing Magic functionality
95 class Magic:
95 class Magic:
96 """Magic functions for InteractiveShell.
96 """Magic functions for InteractiveShell.
97
97
98 Shell functions which can be reached as %function_name. All magic
98 Shell functions which can be reached as %function_name. All magic
99 functions should accept a string, which they can parse for their own
99 functions should accept a string, which they can parse for their own
100 needs. This can make some functions easier to type, eg `%cd ../`
100 needs. This can make some functions easier to type, eg `%cd ../`
101 vs. `%cd("../")`
101 vs. `%cd("../")`
102
102
103 ALL definitions MUST begin with the prefix magic_. The user won't need it
103 ALL definitions MUST begin with the prefix magic_. The user won't need it
104 at the command line, but it is is needed in the definition. """
104 at the command line, but it is is needed in the definition. """
105
105
106 # class globals
106 # class globals
107 auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.',
107 auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.',
108 'Automagic is ON, % prefix NOT needed for magic functions.']
108 'Automagic is ON, % prefix NOT needed for magic functions.']
109
109
110 #......................................................................
110 #......................................................................
111 # some utility functions
111 # some utility functions
112
112
113 def __init__(self,shell):
113 def __init__(self,shell):
114 # XXX This is hackish, clean up later to avoid these messy globals
114 # XXX This is hackish, clean up later to avoid these messy globals
115 global MAGIC_PREFIX, MAGIC_ESCAPE
115 global MAGIC_PREFIX, MAGIC_ESCAPE
116
116
117 self.options_table = {}
117 self.options_table = {}
118 MAGIC_PREFIX = shell.name+'.magic_'
118 MAGIC_PREFIX = shell.name+'.magic_'
119 MAGIC_ESCAPE = shell.ESC_MAGIC
119 MAGIC_ESCAPE = shell.ESC_MAGIC
120 if profile is None:
120 if profile is None:
121 self.magic_prun = self.profile_missing_notice
121 self.magic_prun = self.profile_missing_notice
122
122
123 def profile_missing_notice(self, *args, **kwargs):
123 def profile_missing_notice(self, *args, **kwargs):
124 error("""\
124 error("""\
125 The profile module could not be found. If you are a Debian user,
125 The profile module could not be found. If you are a Debian user,
126 it has been removed from the standard Debian package because of its non-free
126 it has been removed from the standard Debian package because of its non-free
127 license. To use profiling, please install"python2.3-profiler" from non-free.""")
127 license. To use profiling, please install"python2.3-profiler" from non-free.""")
128
128
129 def default_option(self,fn,optstr):
129 def default_option(self,fn,optstr):
130 """Make an entry in the options_table for fn, with value optstr"""
130 """Make an entry in the options_table for fn, with value optstr"""
131
131
132 if fn not in self.lsmagic():
132 if fn not in self.lsmagic():
133 error("%s is not a magic function" % fn)
133 error("%s is not a magic function" % fn)
134 self.options_table[fn] = optstr
134 self.options_table[fn] = optstr
135
135
136 def lsmagic(self):
136 def lsmagic(self):
137 """Return a list of currently available magic functions.
137 """Return a list of currently available magic functions.
138
138
139 Gives a list of the bare names after mangling (['ls','cd', ...], not
139 Gives a list of the bare names after mangling (['ls','cd', ...], not
140 ['magic_ls','magic_cd',...]"""
140 ['magic_ls','magic_cd',...]"""
141
141
142 # FIXME. This needs a cleanup, in the way the magics list is built.
142 # FIXME. This needs a cleanup, in the way the magics list is built.
143
143
144 # magics in class definition
144 # magics in class definition
145 class_magic = lambda fn: fn.startswith('magic_') and \
145 class_magic = lambda fn: fn.startswith('magic_') and \
146 callable(Magic.__dict__[fn])
146 callable(Magic.__dict__[fn])
147 # in instance namespace (run-time user additions)
147 # in instance namespace (run-time user additions)
148 inst_magic = lambda fn: fn.startswith('magic_') and \
148 inst_magic = lambda fn: fn.startswith('magic_') and \
149 callable(self.__dict__[fn])
149 callable(self.__dict__[fn])
150 # and bound magics by user (so they can access self):
150 # and bound magics by user (so they can access self):
151 inst_bound_magic = lambda fn: fn.startswith('magic_') and \
151 inst_bound_magic = lambda fn: fn.startswith('magic_') and \
152 callable(self.__class__.__dict__[fn])
152 callable(self.__class__.__dict__[fn])
153 magics = filter(class_magic,Magic.__dict__.keys()) + \
153 magics = filter(class_magic,Magic.__dict__.keys()) + \
154 filter(inst_magic,self.__dict__.keys()) + \
154 filter(inst_magic,self.__dict__.keys()) + \
155 filter(inst_bound_magic,self.__class__.__dict__.keys())
155 filter(inst_bound_magic,self.__class__.__dict__.keys())
156 out = []
156 out = []
157 for fn in magics:
157 for fn in magics:
158 out.append(fn.replace('magic_','',1))
158 out.append(fn.replace('magic_','',1))
159 out.sort()
159 out.sort()
160 return out
160 return out
161
161
162 def set_shell(self,shell):
162 def set_shell(self,shell):
163 self.shell = shell
163 self.shell = shell
164 self.alias_table = shell.alias_table
164 self.alias_table = shell.alias_table
165
165
166 def extract_input_slices(self,slices):
166 def extract_input_slices(self,slices):
167 """Return as a string a set of input history slices.
167 """Return as a string a set of input history slices.
168
168
169 The set of slices is given as a list of strings (like ['1','4:8','9'],
169 The set of slices is given as a list of strings (like ['1','4:8','9'],
170 since this function is for use by magic functions which get their
170 since this function is for use by magic functions which get their
171 arguments as strings."""
171 arguments as strings."""
172
172
173 cmds = []
173 cmds = []
174 for chunk in slices:
174 for chunk in slices:
175 if ':' in chunk:
175 if ':' in chunk:
176 ini,fin = map(int,chunk.split(':'))
176 ini,fin = map(int,chunk.split(':'))
177 else:
177 else:
178 ini = int(chunk)
178 ini = int(chunk)
179 fin = ini+1
179 fin = ini+1
180 cmds.append(self.shell.input_hist[ini:fin])
180 cmds.append(self.shell.input_hist[ini:fin])
181 return cmds
181 return cmds
182
182
183 def _ofind(self,oname):
183 def _ofind(self,oname):
184 """Find an object in the available namespaces.
184 """Find an object in the available namespaces.
185
185
186 self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic
186 self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic
187
187
188 Has special code to detect magic functions.
188 Has special code to detect magic functions.
189 """
189 """
190
190
191 oname = oname.strip()
191 oname = oname.strip()
192
192
193 # Namespaces to search in:
193 # Namespaces to search in:
194 user_ns = self.shell.user_ns
194 user_ns = self.shell.user_ns
195 internal_ns = self.shell.internal_ns
195 internal_ns = self.shell.internal_ns
196 builtin_ns = __builtin__.__dict__
196 builtin_ns = __builtin__.__dict__
197 alias_ns = self.shell.alias_table
197 alias_ns = self.shell.alias_table
198
198
199 # Put them in a list. The order is important so that we find things in
199 # Put them in a list. The order is important so that we find things in
200 # the same order that Python finds them.
200 # the same order that Python finds them.
201 namespaces = [ ('Interactive',user_ns),
201 namespaces = [ ('Interactive',user_ns),
202 ('IPython internal',internal_ns),
202 ('IPython internal',internal_ns),
203 ('Python builtin',builtin_ns),
203 ('Python builtin',builtin_ns),
204 ('Alias',alias_ns),
204 ('Alias',alias_ns),
205 ]
205 ]
206
206
207 # initialize results to 'null'
207 # initialize results to 'null'
208 found = 0; obj = None; ospace = None; ds = None;
208 found = 0; obj = None; ospace = None; ds = None;
209 ismagic = 0; isalias = 0
209 ismagic = 0; isalias = 0
210
210
211 # Look for the given name by splitting it in parts. If the head is
211 # Look for the given name by splitting it in parts. If the head is
212 # found, then we look for all the remaining parts as members, and only
212 # found, then we look for all the remaining parts as members, and only
213 # declare success if we can find them all.
213 # declare success if we can find them all.
214 oname_parts = oname.split('.')
214 oname_parts = oname.split('.')
215 oname_head, oname_rest = oname_parts[0],oname_parts[1:]
215 oname_head, oname_rest = oname_parts[0],oname_parts[1:]
216 for nsname,ns in namespaces:
216 for nsname,ns in namespaces:
217 try:
217 try:
218 obj = ns[oname_head]
218 obj = ns[oname_head]
219 except KeyError:
219 except KeyError:
220 continue
220 continue
221 else:
221 else:
222 for part in oname_rest:
222 for part in oname_rest:
223 try:
223 try:
224 obj = getattr(obj,part)
224 obj = getattr(obj,part)
225 except:
225 except:
226 # Blanket except b/c some badly implemented objects
226 # Blanket except b/c some badly implemented objects
227 # allow __getattr__ to raise exceptions other than
227 # allow __getattr__ to raise exceptions other than
228 # AttributeError, which then crashes IPython.
228 # AttributeError, which then crashes IPython.
229 break
229 break
230 else:
230 else:
231 # If we finish the for loop (no break), we got all members
231 # If we finish the for loop (no break), we got all members
232 found = 1
232 found = 1
233 ospace = nsname
233 ospace = nsname
234 if ns == alias_ns:
234 if ns == alias_ns:
235 isalias = 1
235 isalias = 1
236 break # namespace loop
236 break # namespace loop
237
237
238 # Try to see if it's magic
238 # Try to see if it's magic
239 if not found:
239 if not found:
240 if oname.startswith(self.shell.ESC_MAGIC):
240 if oname.startswith(self.shell.ESC_MAGIC):
241 oname = oname[1:]
241 oname = oname[1:]
242 obj = getattr(self,'magic_'+oname,None)
242 obj = getattr(self,'magic_'+oname,None)
243 if obj is not None:
243 if obj is not None:
244 found = 1
244 found = 1
245 ospace = 'IPython internal'
245 ospace = 'IPython internal'
246 ismagic = 1
246 ismagic = 1
247
247
248 # Last try: special-case some literals like '', [], {}, etc:
248 # Last try: special-case some literals like '', [], {}, etc:
249 if not found and oname_head in ["''",'""','[]','{}','()']:
249 if not found and oname_head in ["''",'""','[]','{}','()']:
250 obj = eval(oname_head)
250 obj = eval(oname_head)
251 found = 1
251 found = 1
252 ospace = 'Interactive'
252 ospace = 'Interactive'
253
253
254 return {'found':found, 'obj':obj, 'namespace':ospace,
254 return {'found':found, 'obj':obj, 'namespace':ospace,
255 'ismagic':ismagic, 'isalias':isalias}
255 'ismagic':ismagic, 'isalias':isalias}
256
256
257 def arg_err(self,func):
257 def arg_err(self,func):
258 """Print docstring if incorrect arguments were passed"""
258 """Print docstring if incorrect arguments were passed"""
259 print 'Error in arguments:'
259 print 'Error in arguments:'
260 print OInspect.getdoc(func)
260 print OInspect.getdoc(func)
261
261
262
262
263 def format_latex(self,str):
263 def format_latex(self,str):
264 """Format a string for latex inclusion."""
264 """Format a string for latex inclusion."""
265
265
266 # Characters that need to be escaped for latex:
266 # Characters that need to be escaped for latex:
267 escape_re = re.compile(r'(%|_|\$)',re.MULTILINE)
267 escape_re = re.compile(r'(%|_|\$)',re.MULTILINE)
268 # Magic command names as headers:
268 # Magic command names as headers:
269 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
269 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
270 re.MULTILINE)
270 re.MULTILINE)
271 # Magic commands
271 # Magic commands
272 cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC,
272 cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC,
273 re.MULTILINE)
273 re.MULTILINE)
274 # Paragraph continue
274 # Paragraph continue
275 par_re = re.compile(r'\\$',re.MULTILINE)
275 par_re = re.compile(r'\\$',re.MULTILINE)
276
276
277 str = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',str)
277 str = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',str)
278 str = cmd_re.sub(r'\\texttt{\g<cmd>}',str)
278 str = cmd_re.sub(r'\\texttt{\g<cmd>}',str)
279 str = par_re.sub(r'\\\\',str)
279 str = par_re.sub(r'\\\\',str)
280 str = escape_re.sub(r'\\\1',str)
280 str = escape_re.sub(r'\\\1',str)
281 return str
281 return str
282
282
283 def format_screen(self,str):
283 def format_screen(self,str):
284 """Format a string for screen printing.
284 """Format a string for screen printing.
285
285
286 This removes some latex-type format codes."""
286 This removes some latex-type format codes."""
287 # Paragraph continue
287 # Paragraph continue
288 par_re = re.compile(r'\\$',re.MULTILINE)
288 par_re = re.compile(r'\\$',re.MULTILINE)
289 str = par_re.sub('',str)
289 str = par_re.sub('',str)
290 return str
290 return str
291
291
292 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
292 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
293 """Parse options passed to an argument string.
293 """Parse options passed to an argument string.
294
294
295 The interface is similar to that of getopt(), but it returns back a
295 The interface is similar to that of getopt(), but it returns back a
296 Struct with the options as keys and the stripped argument string still
296 Struct with the options as keys and the stripped argument string still
297 as a string.
297 as a string.
298
298
299 arg_str is quoted as a true sys.argv vector by calling on the fly a
299 arg_str is quoted as a true sys.argv vector by calling on the fly a
300 python process in a subshell. This allows us to easily expand
300 python process in a subshell. This allows us to easily expand
301 variables, glob files, quote arguments, etc, with all the power and
301 variables, glob files, quote arguments, etc, with all the power and
302 correctness of the underlying system shell.
302 correctness of the underlying system shell.
303
303
304 Options:
304 Options:
305 -mode: default 'string'. If given as 'list', the argument string is
305 -mode: default 'string'. If given as 'list', the argument string is
306 returned as a list (split on whitespace) instead of a string.
306 returned as a list (split on whitespace) instead of a string.
307
307
308 -list_all: put all option values in lists. Normally only options
308 -list_all: put all option values in lists. Normally only options
309 appearing more than once are put in a list."""
309 appearing more than once are put in a list."""
310
310
311 # inject default options at the beginning of the input line
311 # inject default options at the beginning of the input line
312 caller = sys._getframe(1).f_code.co_name.replace('magic_','')
312 caller = sys._getframe(1).f_code.co_name.replace('magic_','')
313 arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str)
313 arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str)
314
314
315 mode = kw.get('mode','string')
315 mode = kw.get('mode','string')
316 if mode not in ['string','list']:
316 if mode not in ['string','list']:
317 raise ValueError,'incorrect mode given: %s' % mode
317 raise ValueError,'incorrect mode given: %s' % mode
318 # Get options
318 # Get options
319 list_all = kw.get('list_all',0)
319 list_all = kw.get('list_all',0)
320
320
321 # Check if we have more than one argument to warrant extra processing:
321 # Check if we have more than one argument to warrant extra processing:
322 odict = {} # Dictionary with options
322 odict = {} # Dictionary with options
323 args = arg_str.split()
323 args = arg_str.split()
324 if len(args) >= 1:
324 if len(args) >= 1:
325 # If the list of inputs only has 0 or 1 thing in it, there's no
325 # If the list of inputs only has 0 or 1 thing in it, there's no
326 # need to look for options
326 # need to look for options
327 argv = shlex_split(arg_str)
327 argv = shlex_split(arg_str)
328 # Do regular option processing
328 # Do regular option processing
329 opts,args = getopt(argv,opt_str,*long_opts)
329 opts,args = getopt(argv,opt_str,*long_opts)
330 for o,a in opts:
330 for o,a in opts:
331 if o.startswith('--'):
331 if o.startswith('--'):
332 o = o[2:]
332 o = o[2:]
333 else:
333 else:
334 o = o[1:]
334 o = o[1:]
335 try:
335 try:
336 odict[o].append(a)
336 odict[o].append(a)
337 except AttributeError:
337 except AttributeError:
338 odict[o] = [odict[o],a]
338 odict[o] = [odict[o],a]
339 except KeyError:
339 except KeyError:
340 if list_all:
340 if list_all:
341 odict[o] = [a]
341 odict[o] = [a]
342 else:
342 else:
343 odict[o] = a
343 odict[o] = a
344
344
345 # Prepare opts,args for return
345 # Prepare opts,args for return
346 opts = Struct(odict)
346 opts = Struct(odict)
347 if mode == 'string':
347 if mode == 'string':
348 args = ' '.join(args)
348 args = ' '.join(args)
349
349
350 return opts,args
350 return opts,args
351
351
352 #......................................................................
352 #......................................................................
353 # And now the actual magic functions
353 # And now the actual magic functions
354
354
355 # Functions for IPython shell work (vars,funcs, config, etc)
355 # Functions for IPython shell work (vars,funcs, config, etc)
356 def magic_lsmagic(self, parameter_s = ''):
356 def magic_lsmagic(self, parameter_s = ''):
357 """List currently available magic functions."""
357 """List currently available magic functions."""
358 mesc = self.shell.ESC_MAGIC
358 mesc = self.shell.ESC_MAGIC
359 print 'Available magic functions:\n'+mesc+\
359 print 'Available magic functions:\n'+mesc+\
360 (' '+mesc).join(self.lsmagic())
360 (' '+mesc).join(self.lsmagic())
361 print '\n' + Magic.auto_status[self.shell.rc.automagic]
361 print '\n' + Magic.auto_status[self.shell.rc.automagic]
362 return None
362 return None
363
363
364 def magic_magic(self, parameter_s = ''):
364 def magic_magic(self, parameter_s = ''):
365 """Print information about the magic function system."""
365 """Print information about the magic function system."""
366
366
367 mode = ''
367 mode = ''
368 try:
368 try:
369 if parameter_s.split()[0] == '-latex':
369 if parameter_s.split()[0] == '-latex':
370 mode = 'latex'
370 mode = 'latex'
371 except:
371 except:
372 pass
372 pass
373
373
374 magic_docs = []
374 magic_docs = []
375 for fname in self.lsmagic():
375 for fname in self.lsmagic():
376 mname = 'magic_' + fname
376 mname = 'magic_' + fname
377 for space in (Magic,self,self.__class__):
377 for space in (Magic,self,self.__class__):
378 try:
378 try:
379 fn = space.__dict__[mname]
379 fn = space.__dict__[mname]
380 except KeyError:
380 except KeyError:
381 pass
381 pass
382 else:
382 else:
383 break
383 break
384 magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC,
384 magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC,
385 fname,fn.__doc__))
385 fname,fn.__doc__))
386 magic_docs = ''.join(magic_docs)
386 magic_docs = ''.join(magic_docs)
387
387
388 if mode == 'latex':
388 if mode == 'latex':
389 print self.format_latex(magic_docs)
389 print self.format_latex(magic_docs)
390 return
390 return
391 else:
391 else:
392 magic_docs = self.format_screen(magic_docs)
392 magic_docs = self.format_screen(magic_docs)
393
393
394 outmsg = """
394 outmsg = """
395 IPython's 'magic' functions
395 IPython's 'magic' functions
396 ===========================
396 ===========================
397
397
398 The magic function system provides a series of functions which allow you to
398 The magic function system provides a series of functions which allow you to
399 control the behavior of IPython itself, plus a lot of system-type
399 control the behavior of IPython itself, plus a lot of system-type
400 features. All these functions are prefixed with a % character, but parameters
400 features. All these functions are prefixed with a % character, but parameters
401 are given without parentheses or quotes.
401 are given without parentheses or quotes.
402
402
403 NOTE: If you have 'automagic' enabled (via the command line option or with the
403 NOTE: If you have 'automagic' enabled (via the command line option or with the
404 %automagic function), you don't need to type in the % explicitly. By default,
404 %automagic function), you don't need to type in the % explicitly. By default,
405 IPython ships with automagic on, so you should only rarely need the % escape.
405 IPython ships with automagic on, so you should only rarely need the % escape.
406
406
407 Example: typing '%cd mydir' (without the quotes) changes you working directory
407 Example: typing '%cd mydir' (without the quotes) changes you working directory
408 to 'mydir', if it exists.
408 to 'mydir', if it exists.
409
409
410 You can define your own magic functions to extend the system. See the supplied
410 You can define your own magic functions to extend the system. See the supplied
411 ipythonrc and example-magic.py files for details (in your ipython
411 ipythonrc and example-magic.py files for details (in your ipython
412 configuration directory, typically $HOME/.ipython/).
412 configuration directory, typically $HOME/.ipython/).
413
413
414 You can also define your own aliased names for magic functions. In your
414 You can also define your own aliased names for magic functions. In your
415 ipythonrc file, placing a line like:
415 ipythonrc file, placing a line like:
416
416
417 execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
417 execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
418
418
419 will define %pf as a new name for %profile.
419 will define %pf as a new name for %profile.
420
420
421 You can also call magics in code using the ipmagic() function, which IPython
421 You can also call magics in code using the ipmagic() function, which IPython
422 automatically adds to the builtin namespace. Type 'ipmagic?' for details.
422 automatically adds to the builtin namespace. Type 'ipmagic?' for details.
423
423
424 For a list of the available magic functions, use %lsmagic. For a description
424 For a list of the available magic functions, use %lsmagic. For a description
425 of any of them, type %magic_name?, e.g. '%cd?'.
425 of any of them, type %magic_name?, e.g. '%cd?'.
426
426
427 Currently the magic system has the following functions:\n"""
427 Currently the magic system has the following functions:\n"""
428
428
429 mesc = self.shell.ESC_MAGIC
429 mesc = self.shell.ESC_MAGIC
430 outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):"
430 outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):"
431 "\n\n%s%s\n\n%s" % (outmsg,
431 "\n\n%s%s\n\n%s" % (outmsg,
432 magic_docs,mesc,mesc,
432 magic_docs,mesc,mesc,
433 (' '+mesc).join(self.lsmagic()),
433 (' '+mesc).join(self.lsmagic()),
434 Magic.auto_status[self.shell.rc.automagic] ) )
434 Magic.auto_status[self.shell.rc.automagic] ) )
435
435
436 page(outmsg,screen_lines=self.shell.rc.screen_length)
436 page(outmsg,screen_lines=self.shell.rc.screen_length)
437
437
438 def magic_automagic(self, parameter_s = ''):
438 def magic_automagic(self, parameter_s = ''):
439 """Make magic functions callable without having to type the initial %.
439 """Make magic functions callable without having to type the initial %.
440
440
441 Toggles on/off (when off, you must call it as %automagic, of
441 Toggles on/off (when off, you must call it as %automagic, of
442 course). Note that magic functions have lowest priority, so if there's
442 course). Note that magic functions have lowest priority, so if there's
443 a variable whose name collides with that of a magic fn, automagic
443 a variable whose name collides with that of a magic fn, automagic
444 won't work for that function (you get the variable instead). However,
444 won't work for that function (you get the variable instead). However,
445 if you delete the variable (del var), the previously shadowed magic
445 if you delete the variable (del var), the previously shadowed magic
446 function becomes visible to automagic again."""
446 function becomes visible to automagic again."""
447
447
448 rc = self.shell.rc
448 rc = self.shell.rc
449 rc.automagic = not rc.automagic
449 rc.automagic = not rc.automagic
450 print '\n' + Magic.auto_status[rc.automagic]
450 print '\n' + Magic.auto_status[rc.automagic]
451
451
452 def magic_autocall(self, parameter_s = ''):
452 def magic_autocall(self, parameter_s = ''):
453 """Make functions callable without having to type parentheses.
453 """Make functions callable without having to type parentheses.
454
454
455 This toggles the autocall command line option on and off."""
455 This toggles the autocall command line option on and off."""
456
456
457 rc = self.shell.rc
457 rc = self.shell.rc
458 rc.autocall = not rc.autocall
458 rc.autocall = not rc.autocall
459 print "Automatic calling is:",['OFF','ON'][rc.autocall]
459 print "Automatic calling is:",['OFF','ON'][rc.autocall]
460
460
461 def magic_autoindent(self, parameter_s = ''):
461 def magic_autoindent(self, parameter_s = ''):
462 """Toggle autoindent on/off (if available)."""
462 """Toggle autoindent on/off (if available)."""
463
463
464 self.shell.set_autoindent()
464 self.shell.set_autoindent()
465 print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent]
465 print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent]
466
466
467 def magic_system_verbose(self, parameter_s = ''):
467 def magic_system_verbose(self, parameter_s = ''):
468 """Toggle verbose printing of system calls on/off."""
468 """Toggle verbose printing of system calls on/off."""
469
469
470 self.shell.rc_set_toggle('system_verbose')
470 self.shell.rc_set_toggle('system_verbose')
471 print "System verbose printing is:",\
471 print "System verbose printing is:",\
472 ['OFF','ON'][self.shell.rc.system_verbose]
472 ['OFF','ON'][self.shell.rc.system_verbose]
473
473
474 def magic_history(self, parameter_s = ''):
474 def magic_history(self, parameter_s = ''):
475 """Print input history (_i<n> variables), with most recent last.
475 """Print input history (_i<n> variables), with most recent last.
476
476
477 %history [-n] -> print at most 40 inputs (some may be multi-line)\\
477 %history [-n] -> print at most 40 inputs (some may be multi-line)\\
478 %history [-n] n -> print at most n inputs\\
478 %history [-n] n -> print at most n inputs\\
479 %history [-n] n1 n2 -> print inputs between n1 and n2 (n2 not included)\\
479 %history [-n] n1 n2 -> print inputs between n1 and n2 (n2 not included)\\
480
480
481 Each input's number <n> is shown, and is accessible as the
481 Each input's number <n> is shown, and is accessible as the
482 automatically generated variable _i<n>. Multi-line statements are
482 automatically generated variable _i<n>. Multi-line statements are
483 printed starting at a new line for easy copy/paste.
483 printed starting at a new line for easy copy/paste.
484
484
485 If option -n is used, input numbers are not printed. This is useful if
485 If option -n is used, input numbers are not printed. This is useful if
486 you want to get a printout of many lines which can be directly pasted
486 you want to get a printout of many lines which can be directly pasted
487 into a text editor.
487 into a text editor.
488
488
489 This feature is only available if numbered prompts are in use."""
489 This feature is only available if numbered prompts are in use."""
490
490
491 if not self.do_full_cache:
491 if not self.do_full_cache:
492 print 'This feature is only available if numbered prompts are in use.'
492 print 'This feature is only available if numbered prompts are in use.'
493 return
493 return
494 opts,args = self.parse_options(parameter_s,'n',mode='list')
494 opts,args = self.parse_options(parameter_s,'n',mode='list')
495
495
496 default_length = 40
496 default_length = 40
497 if len(args) == 0:
497 if len(args) == 0:
498 final = self.outputcache.prompt_count
498 final = self.outputcache.prompt_count
499 init = max(1,final-default_length)
499 init = max(1,final-default_length)
500 elif len(args) == 1:
500 elif len(args) == 1:
501 final = self.outputcache.prompt_count
501 final = self.outputcache.prompt_count
502 init = max(1,final-int(args[0]))
502 init = max(1,final-int(args[0]))
503 elif len(args) == 2:
503 elif len(args) == 2:
504 init,final = map(int,args)
504 init,final = map(int,args)
505 else:
505 else:
506 warn('%hist takes 0, 1 or 2 arguments separated by spaces.')
506 warn('%hist takes 0, 1 or 2 arguments separated by spaces.')
507 print self.magic_hist.__doc__
507 print self.magic_hist.__doc__
508 return
508 return
509 width = len(str(final))
509 width = len(str(final))
510 line_sep = ['','\n']
510 line_sep = ['','\n']
511 input_hist = self.shell.input_hist
511 input_hist = self.shell.input_hist
512 print_nums = not opts.has_key('n')
512 print_nums = not opts.has_key('n')
513 for in_num in range(init,final):
513 for in_num in range(init,final):
514 inline = input_hist[in_num]
514 inline = input_hist[in_num]
515 multiline = inline.count('\n') > 1
515 multiline = inline.count('\n') > 1
516 if print_nums:
516 if print_nums:
517 print str(in_num).ljust(width)+':'+ line_sep[multiline],
517 print str(in_num).ljust(width)+':'+ line_sep[multiline],
518 if inline.startswith('#'+self.shell.ESC_MAGIC) or \
518 if inline.startswith('#'+self.shell.ESC_MAGIC) or \
519 inline.startswith('#!'):
519 inline.startswith('#!'):
520 print inline[1:],
520 print inline[1:],
521 else:
521 else:
522 print inline,
522 print inline,
523
523
524 def magic_hist(self, parameter_s=''):
524 def magic_hist(self, parameter_s=''):
525 """Alternate name for %history."""
525 """Alternate name for %history."""
526 return self.magic_history(parameter_s)
526 return self.magic_history(parameter_s)
527
527
528 def magic_p(self, parameter_s=''):
528 def magic_p(self, parameter_s=''):
529 """Just a short alias for Python's 'print'."""
529 """Just a short alias for Python's 'print'."""
530 exec 'print ' + parameter_s in self.shell.user_ns
530 exec 'print ' + parameter_s in self.shell.user_ns
531
531
532 def magic_r(self, parameter_s=''):
532 def magic_r(self, parameter_s=''):
533 """Repeat previous input.
533 """Repeat previous input.
534
534
535 If given an argument, repeats the previous command which starts with
535 If given an argument, repeats the previous command which starts with
536 the same string, otherwise it just repeats the previous input.
536 the same string, otherwise it just repeats the previous input.
537
537
538 Shell escaped commands (with ! as first character) are not recognized
538 Shell escaped commands (with ! as first character) are not recognized
539 by this system, only pure python code and magic commands.
539 by this system, only pure python code and magic commands.
540 """
540 """
541
541
542 start = parameter_s.strip()
542 start = parameter_s.strip()
543 esc_magic = self.shell.ESC_MAGIC
543 esc_magic = self.shell.ESC_MAGIC
544 # Identify magic commands even if automagic is on (which means
544 # Identify magic commands even if automagic is on (which means
545 # the in-memory version is different from that typed by the user).
545 # the in-memory version is different from that typed by the user).
546 if self.shell.rc.automagic:
546 if self.shell.rc.automagic:
547 start_magic = esc_magic+start
547 start_magic = esc_magic+start
548 else:
548 else:
549 start_magic = start
549 start_magic = start
550 # Look through the input history in reverse
550 # Look through the input history in reverse
551 for n in range(len(self.shell.input_hist)-2,0,-1):
551 for n in range(len(self.shell.input_hist)-2,0,-1):
552 input = self.shell.input_hist[n]
552 input = self.shell.input_hist[n]
553 # skip plain 'r' lines so we don't recurse to infinity
553 # skip plain 'r' lines so we don't recurse to infinity
554 if input != 'ipmagic("r")\n' and \
554 if input != 'ipmagic("r")\n' and \
555 (input.startswith(start) or input.startswith(start_magic)):
555 (input.startswith(start) or input.startswith(start_magic)):
556 #print 'match',`input` # dbg
556 #print 'match',`input` # dbg
557 if input.startswith(esc_magic):
557 if input.startswith(esc_magic):
558 input = magic2python(input)
558 input = magic2python(input)
559 #print 'modified',`input` # dbg
559 #print 'modified',`input` # dbg
560 print 'Executing:',input,
560 print 'Executing:',input,
561 exec input in self.shell.user_ns
561 exec input in self.shell.user_ns
562 return
562 return
563 print 'No previous input matching `%s` found.' % start
563 print 'No previous input matching `%s` found.' % start
564
564
565 def magic_page(self, parameter_s=''):
565 def magic_page(self, parameter_s=''):
566 """Pretty print the object and display it through a pager.
566 """Pretty print the object and display it through a pager.
567
567
568 If no parameter is given, use _ (last output)."""
568 If no parameter is given, use _ (last output)."""
569 # After a function contributed by Olivier Aubert, slightly modified.
569 # After a function contributed by Olivier Aubert, slightly modified.
570
570
571 oname = parameter_s and parameter_s or '_'
571 oname = parameter_s and parameter_s or '_'
572 info = self._ofind(oname)
572 info = self._ofind(oname)
573 if info['found']:
573 if info['found']:
574 page(pformat(info['obj']))
574 page(pformat(info['obj']))
575 else:
575 else:
576 print 'Object `%s` not found' % oname
576 print 'Object `%s` not found' % oname
577
577
578 def magic_profile(self, parameter_s=''):
578 def magic_profile(self, parameter_s=''):
579 """Print your currently active IPyhton profile."""
579 """Print your currently active IPyhton profile."""
580 if self.shell.rc.profile:
580 if self.shell.rc.profile:
581 printpl('Current IPython profile: $self.shell.rc.profile.')
581 printpl('Current IPython profile: $self.shell.rc.profile.')
582 else:
582 else:
583 print 'No profile active.'
583 print 'No profile active.'
584
584
585 def _inspect(self,meth,oname,**kw):
585 def _inspect(self,meth,oname,**kw):
586 """Generic interface to the inspector system.
586 """Generic interface to the inspector system.
587
587
588 This function is meant to be called by pdef, pdoc & friends."""
588 This function is meant to be called by pdef, pdoc & friends."""
589
589
590 oname = oname.strip()
590 oname = oname.strip()
591 info = Struct(self._ofind(oname))
591 info = Struct(self._ofind(oname))
592 if info.found:
592 if info.found:
593 pmethod = getattr(self.shell.inspector,meth)
593 pmethod = getattr(self.shell.inspector,meth)
594 formatter = info.ismagic and self.format_screen or None
594 formatter = info.ismagic and self.format_screen or None
595 if meth == 'pdoc':
595 if meth == 'pdoc':
596 pmethod(info.obj,oname,formatter)
596 pmethod(info.obj,oname,formatter)
597 elif meth == 'pinfo':
597 elif meth == 'pinfo':
598 pmethod(info.obj,oname,formatter,info,**kw)
598 pmethod(info.obj,oname,formatter,info,**kw)
599 else:
599 else:
600 pmethod(info.obj,oname)
600 pmethod(info.obj,oname)
601 else:
601 else:
602 print 'Object `%s` not found.' % oname
602 print 'Object `%s` not found.' % oname
603 return 'not found' # so callers can take other action
603 return 'not found' # so callers can take other action
604
604
605 def magic_pdef(self, parameter_s=''):
605 def magic_pdef(self, parameter_s=''):
606 """Print the definition header for any callable object.
606 """Print the definition header for any callable object.
607
607
608 If the object is a class, print the constructor information."""
608 If the object is a class, print the constructor information."""
609 self._inspect('pdef',parameter_s)
609 self._inspect('pdef',parameter_s)
610
610
611 def magic_pdoc(self, parameter_s=''):
611 def magic_pdoc(self, parameter_s=''):
612 """Print the docstring for an object.
612 """Print the docstring for an object.
613
613
614 If the given object is a class, it will print both the class and the
614 If the given object is a class, it will print both the class and the
615 constructor docstrings."""
615 constructor docstrings."""
616 self._inspect('pdoc',parameter_s)
616 self._inspect('pdoc',parameter_s)
617
617
618 def magic_psource(self, parameter_s=''):
618 def magic_psource(self, parameter_s=''):
619 """Print (or run through pager) the source code for an object."""
619 """Print (or run through pager) the source code for an object."""
620 self._inspect('psource',parameter_s)
620 self._inspect('psource',parameter_s)
621
621
622 def magic_pfile(self, parameter_s=''):
622 def magic_pfile(self, parameter_s=''):
623 """Print (or run through pager) the file where an object is defined.
623 """Print (or run through pager) the file where an object is defined.
624
624
625 The file opens at the line where the object definition begins. IPython
625 The file opens at the line where the object definition begins. IPython
626 will honor the environment variable PAGER if set, and otherwise will
626 will honor the environment variable PAGER if set, and otherwise will
627 do its best to print the file in a convenient form.
627 do its best to print the file in a convenient form.
628
628
629 If the given argument is not an object currently defined, IPython will
629 If the given argument is not an object currently defined, IPython will
630 try to interpret it as a filename (automatically adding a .py extension
630 try to interpret it as a filename (automatically adding a .py extension
631 if needed). You can thus use %pfile as a syntax highlighting code
631 if needed). You can thus use %pfile as a syntax highlighting code
632 viewer."""
632 viewer."""
633
633
634 # first interpret argument as an object name
634 # first interpret argument as an object name
635 out = self._inspect('pfile',parameter_s)
635 out = self._inspect('pfile',parameter_s)
636 # if not, try the input as a filename
636 # if not, try the input as a filename
637 if out == 'not found':
637 if out == 'not found':
638 try:
638 try:
639 filename = get_py_filename(parameter_s)
639 filename = get_py_filename(parameter_s)
640 except IOError,msg:
640 except IOError,msg:
641 print msg
641 print msg
642 return
642 return
643 page(self.shell.inspector.format(file(filename).read()))
643 page(self.shell.inspector.format(file(filename).read()))
644
644
645 def magic_pinfo(self, parameter_s=''):
645 def magic_pinfo(self, parameter_s=''):
646 """Provide detailed information about an object.
646 """Provide detailed information about an object.
647
647
648 '%pinfo object' is just a synonym for object? or ?object."""
648 '%pinfo object' is just a synonym for object? or ?object."""
649
649
650 #print 'pinfo par: <%s>' % parameter_s # dbg
650 #print 'pinfo par: <%s>' % parameter_s # dbg
651
651
652 # detail_level: 0 -> obj? , 1 -> obj??
652 # detail_level: 0 -> obj? , 1 -> obj??
653 detail_level = 0
653 detail_level = 0
654 # We need to detect if we got called as 'pinfo pinfo foo', which can
654 # We need to detect if we got called as 'pinfo pinfo foo', which can
655 # happen if the user types 'pinfo foo?' at the cmd line.
655 # happen if the user types 'pinfo foo?' at the cmd line.
656 pinfo,qmark1,oname,qmark2 = \
656 pinfo,qmark1,oname,qmark2 = \
657 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
657 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
658 if pinfo or qmark1 or qmark2:
658 if pinfo or qmark1 or qmark2:
659 detail_level = 1
659 detail_level = 1
660 if "*" in oname:
660 if "*" in oname:
661 self.magic_psearch(oname)
661 self.magic_psearch(oname)
662 else:
662 else:
663 self._inspect('pinfo',oname,detail_level=detail_level)
663 self._inspect('pinfo',oname,detail_level=detail_level)
664
664
665 def magic_psearch(self, parameter_s=''):
665 def magic_psearch(self, parameter_s=''):
666 """Search for object in namespaces by wildcard.
666 """Search for object in namespaces by wildcard.
667
667
668 %psearch PATTERN [OBJECT TYPE] [-NAMESPACE]* [+NAMESPACE]* [-a] [-c]
668 %psearch PATTERN [OBJECT TYPE] [-NAMESPACE]* [+NAMESPACE]* [-a] [-c]
669
669
670 Note: ? can be used as a synonym for %psearch, at the beginning or at
670 Note: ? can be used as a synonym for %psearch, at the beginning or at
671 the end: both a*? and ?a* are equivalent to '%psearch a*'.
671 the end: both a*? and ?a* are equivalent to '%psearch a*'.
672
672
673 PATTERN
673 PATTERN
674
674
675 where PATTERN is a string containing * as a wildcard similar to its
675 where PATTERN is a string containing * as a wildcard similar to its
676 use in a shell. The pattern is matched in all namespaces on the
676 use in a shell. The pattern is matched in all namespaces on the
677 search path. By default objects starting with a single _ are not
677 search path. By default objects starting with a single _ are not
678 matched, many IPython generated objects have a single underscore. The
678 matched, many IPython generated objects have a single underscore. The
679 default is case insensitive matching. Matching is also done on the
679 default is case insensitive matching. Matching is also done on the
680 attributes of objects and not only on the objects in a module.
680 attributes of objects and not only on the objects in a module.
681
681
682 [OBJECT TYPE]
682 [OBJECT TYPE]
683 Is the name of a python type from the types module. The name is given
683 Is the name of a python type from the types module. The name is given
684 in lowercase without the ending type, ex. StringType is written
684 in lowercase without the ending type, ex. StringType is written
685 string. By adding a type here only objects matching the given type are
685 string. By adding a type here only objects matching the given type are
686 matched. Using all here makes the pattern match all types (this is the
686 matched. Using all here makes the pattern match all types (this is the
687 default).
687 default).
688
688
689 [-NAMESPACE]* [+NAMESPACE]*
689 [-NAMESPACE]* [+NAMESPACE]*
690 The possible namespaces are builtin, user, internal, alias. Where
690 The possible namespaces are builtin, user, internal, alias. Where
691 builtin and user are default. Builtin contains the python module
691 builtin and user are default. Builtin contains the python module
692 builtin, user contains all imported namespaces, alias only contain the
692 builtin, user contains all imported namespaces, alias only contain the
693 shell aliases and no python objects, internal contains objects used by
693 shell aliases and no python objects, internal contains objects used by
694 IPython. The namespaces on the search path are removed by -namespace
694 IPython. The namespaces on the search path are removed by -namespace
695 and added by +namespace.
695 and added by +namespace.
696
696
697 [-a] makes the pattern match even objects with a single underscore.
697 [-a] makes the pattern match even objects with a single underscore.
698 [-c] makes the pattern case sensitive.
698 [-c] makes the pattern case sensitive.
699
699
700 Examples:
700 Examples:
701
701
702 %psearch a* list objects beginning with an a
702 %psearch a* list objects beginning with an a
703 %psearch a* function list all functions beginning with an a
703 %psearch a* function list all functions beginning with an a
704 %psearch re.e* list objects beginning with an e in module re
704 %psearch re.e* list objects beginning with an e in module re
705 %psearch r*.e* list objects that starts with e in modules starting in r
705 %psearch r*.e* list objects that starts with e in modules starting in r
706 %psearch r*.* string list all strings in modules beginning with r
706 %psearch r*.* string list all strings in modules beginning with r
707
707
708 Case sensitve search:
708 Case sensitve search:
709
709
710 %psearch a* -c list all object beginning with lower case a
710 %psearch a* -c list all object beginning with lower case a
711
711
712 Show objects beginning with a single _:
712 Show objects beginning with a single _:
713
713
714 %psearch _* -a list objects beginning with underscore"""
714 %psearch _* -a list objects beginning with underscore"""
715
715
716 self.shell.inspector.psearch(parameter_s,shell=self.shell)
716 self.shell.inspector.psearch(parameter_s,shell=self.shell)
717
717
718 def magic_who_ls(self, parameter_s=''):
718 def magic_who_ls(self, parameter_s=''):
719 """Return a sorted list of all interactive variables.
719 """Return a sorted list of all interactive variables.
720
720
721 If arguments are given, only variables of types matching these
721 If arguments are given, only variables of types matching these
722 arguments are returned."""
722 arguments are returned."""
723
723
724 user_ns = self.shell.user_ns
724 user_ns = self.shell.user_ns
725 out = []
725 out = []
726 typelist = parameter_s.split()
726 typelist = parameter_s.split()
727 for i in self.shell.user_ns.keys():
727 for i in self.shell.user_ns.keys():
728 if not (i.startswith('_') or i.startswith('_i')) \
728 if not (i.startswith('_') or i.startswith('_i')) \
729 and not (self.internal_ns.has_key(i) or
729 and not (self.internal_ns.has_key(i) or
730 self.user_config_ns.has_key(i)):
730 self.user_config_ns.has_key(i)):
731 if typelist:
731 if typelist:
732 if type(user_ns[i]).__name__ in typelist:
732 if type(user_ns[i]).__name__ in typelist:
733 out.append(i)
733 out.append(i)
734 else:
734 else:
735 out.append(i)
735 out.append(i)
736 out.sort()
736 out.sort()
737 return out
737 return out
738
738
739 def magic_who(self, parameter_s=''):
739 def magic_who(self, parameter_s=''):
740 """Print all interactive variables, with some minimal formatting.
740 """Print all interactive variables, with some minimal formatting.
741
741
742 If any arguments are given, only variables whose type matches one of
742 If any arguments are given, only variables whose type matches one of
743 these are printed. For example:
743 these are printed. For example:
744
744
745 %who function str
745 %who function str
746
746
747 will only list functions and strings, excluding all other types of
747 will only list functions and strings, excluding all other types of
748 variables. To find the proper type names, simply use type(var) at a
748 variables. To find the proper type names, simply use type(var) at a
749 command line to see how python prints type names. For example:
749 command line to see how python prints type names. For example:
750
750
751 In [1]: type('hello')\\
751 In [1]: type('hello')\\
752 Out[1]: <type 'str'>
752 Out[1]: <type 'str'>
753
753
754 indicates that the type name for strings is 'str'.
754 indicates that the type name for strings is 'str'.
755
755
756 %who always excludes executed names loaded through your configuration
756 %who always excludes executed names loaded through your configuration
757 file and things which are internal to IPython.
757 file and things which are internal to IPython.
758
758
759 This is deliberate, as typically you may load many modules and the
759 This is deliberate, as typically you may load many modules and the
760 purpose of %who is to show you only what you've manually defined."""
760 purpose of %who is to show you only what you've manually defined."""
761
761
762 varlist = self.magic_who_ls(parameter_s)
762 varlist = self.magic_who_ls(parameter_s)
763 if not varlist:
763 if not varlist:
764 print 'Interactive namespace is empty.'
764 print 'Interactive namespace is empty.'
765 return
765 return
766
766
767 # if we have variables, move on...
767 # if we have variables, move on...
768
768
769 # stupid flushing problem: when prompts have no separators, stdout is
769 # stupid flushing problem: when prompts have no separators, stdout is
770 # getting lost. I'm starting to think this is a python bug. I'm having
770 # getting lost. I'm starting to think this is a python bug. I'm having
771 # to force a flush with a print because even a sys.stdout.flush
771 # to force a flush with a print because even a sys.stdout.flush
772 # doesn't seem to do anything!
772 # doesn't seem to do anything!
773
773
774 count = 0
774 count = 0
775 for i in varlist:
775 for i in varlist:
776 print i+'\t',
776 print i+'\t',
777 count += 1
777 count += 1
778 if count > 8:
778 if count > 8:
779 count = 0
779 count = 0
780 print
780 print
781 sys.stdout.flush() # FIXME. Why the hell isn't this flushing???
781 sys.stdout.flush() # FIXME. Why the hell isn't this flushing???
782
782
783 print # well, this does force a flush at the expense of an extra \n
783 print # well, this does force a flush at the expense of an extra \n
784
784
785 def magic_whos(self, parameter_s=''):
785 def magic_whos(self, parameter_s=''):
786 """Like %who, but gives some extra information about each variable.
786 """Like %who, but gives some extra information about each variable.
787
787
788 The same type filtering of %who can be applied here.
788 The same type filtering of %who can be applied here.
789
789
790 For all variables, the type is printed. Additionally it prints:
790 For all variables, the type is printed. Additionally it prints:
791
791
792 - For {},[],(): their length.
792 - For {},[],(): their length.
793
793
794 - For Numeric arrays, a summary with shape, number of elements,
794 - For Numeric arrays, a summary with shape, number of elements,
795 typecode and size in memory.
795 typecode and size in memory.
796
796
797 - Everything else: a string representation, snipping their middle if
797 - Everything else: a string representation, snipping their middle if
798 too long."""
798 too long."""
799
799
800 varnames = self.magic_who_ls(parameter_s)
800 varnames = self.magic_who_ls(parameter_s)
801 if not varnames:
801 if not varnames:
802 print 'Interactive namespace is empty.'
802 print 'Interactive namespace is empty.'
803 return
803 return
804
804
805 # if we have variables, move on...
805 # if we have variables, move on...
806
806
807 # for these types, show len() instead of data:
807 # for these types, show len() instead of data:
808 seq_types = [types.DictType,types.ListType,types.TupleType]
808 seq_types = [types.DictType,types.ListType,types.TupleType]
809
809
810 # for Numeric arrays, display summary info
810 # for Numeric arrays, display summary info
811 try:
811 try:
812 import Numeric
812 import Numeric
813 except ImportError:
813 except ImportError:
814 array_type = None
814 array_type = None
815 else:
815 else:
816 array_type = Numeric.ArrayType.__name__
816 array_type = Numeric.ArrayType.__name__
817
817
818 # Find all variable names and types so we can figure out column sizes
818 # Find all variable names and types so we can figure out column sizes
819 get_vars = lambda i: self.locals[i]
819 get_vars = lambda i: self.shell.user_ns[i]
820 type_name = lambda v: type(v).__name__
820 type_name = lambda v: type(v).__name__
821 varlist = map(get_vars,varnames)
821 varlist = map(get_vars,varnames)
822 typelist = map(type_name,varlist)
822 typelist = map(type_name,varlist)
823 # column labels and # of spaces as separator
823 # column labels and # of spaces as separator
824 varlabel = 'Variable'
824 varlabel = 'Variable'
825 typelabel = 'Type'
825 typelabel = 'Type'
826 datalabel = 'Data/Info'
826 datalabel = 'Data/Info'
827 colsep = 3
827 colsep = 3
828 # variable format strings
828 # variable format strings
829 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
829 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
830 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
830 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
831 aformat = "%s: %s elems, type `%s`, %s bytes"
831 aformat = "%s: %s elems, type `%s`, %s bytes"
832 # find the size of the columns to format the output nicely
832 # find the size of the columns to format the output nicely
833 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
833 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
834 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
834 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
835 # table header
835 # table header
836 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
836 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
837 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
837 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
838 # and the table itself
838 # and the table itself
839 kb = 1024
839 kb = 1024
840 Mb = 1048576 # kb**2
840 Mb = 1048576 # kb**2
841 for vname,var,vtype in zip(varnames,varlist,typelist):
841 for vname,var,vtype in zip(varnames,varlist,typelist):
842 print itpl(vformat),
842 print itpl(vformat),
843 if vtype in seq_types:
843 if vtype in seq_types:
844 print len(var)
844 print len(var)
845 elif vtype==array_type:
845 elif vtype==array_type:
846 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
846 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
847 vsize = Numeric.size(var)
847 vsize = Numeric.size(var)
848 vbytes = vsize*var.itemsize()
848 vbytes = vsize*var.itemsize()
849 if vbytes < 100000:
849 if vbytes < 100000:
850 print aformat % (vshape,vsize,var.typecode(),vbytes)
850 print aformat % (vshape,vsize,var.typecode(),vbytes)
851 else:
851 else:
852 print aformat % (vshape,vsize,var.typecode(),vbytes),
852 print aformat % (vshape,vsize,var.typecode(),vbytes),
853 if vbytes < Mb:
853 if vbytes < Mb:
854 print '(%s kb)' % (vbytes/kb,)
854 print '(%s kb)' % (vbytes/kb,)
855 else:
855 else:
856 print '(%s Mb)' % (vbytes/Mb,)
856 print '(%s Mb)' % (vbytes/Mb,)
857 else:
857 else:
858 vstr = str(var)
858 vstr = str(var)
859 if len(vstr) < 50:
859 if len(vstr) < 50:
860 print vstr
860 print vstr
861 else:
861 else:
862 printpl(vfmt_short)
862 printpl(vfmt_short)
863
863
864 def magic_reset(self, parameter_s=''):
864 def magic_reset(self, parameter_s=''):
865 """Resets the namespace by removing all names defined by the user.
865 """Resets the namespace by removing all names defined by the user.
866
866
867 Input/Output history are left around in case you need them."""
867 Input/Output history are left around in case you need them."""
868
868
869 ans = raw_input(
869 ans = raw_input(
870 "Once deleted, variables cannot be recovered. Proceed (y/n)? ")
870 "Once deleted, variables cannot be recovered. Proceed (y/n)? ")
871 if not ans.lower() == 'y':
871 if not ans.lower() == 'y':
872 print 'Nothing done.'
872 print 'Nothing done.'
873 return
873 return
874 user_ns = self.shell.user_ns
874 for i in self.magic_who_ls():
875 for i in self.magic_who_ls():
875 del(self.locals[i])
876 del(user_ns[i])
876
877
877 def magic_config(self,parameter_s=''):
878 def magic_config(self,parameter_s=''):
878 """Show IPython's internal configuration."""
879 """Show IPython's internal configuration."""
879
880
880 page('Current configuration structure:\n'+
881 page('Current configuration structure:\n'+
881 pformat(self.shell.rc.dict()))
882 pformat(self.shell.rc.dict()))
882
883
883 def magic_logstart(self,parameter_s=''):
884 def magic_logstart(self,parameter_s=''):
884 """Start logging anywhere in a session.
885 """Start logging anywhere in a session.
885
886
886 %logstart [log_name [log_mode]]
887 %logstart [log_name [log_mode]]
887
888
888 If no name is given, it defaults to a file named 'ipython.log' in your
889 If no name is given, it defaults to a file named 'ipython.log' in your
889 current directory, in 'rotate' mode (see below).
890 current directory, in 'rotate' mode (see below).
890
891
891 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
892 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
892 history up to that point and then continues logging.
893 history up to that point and then continues logging.
893
894
894 %logstart takes a second optional parameter: logging mode. This can be one
895 %logstart takes a second optional parameter: logging mode. This can be one
895 of (note that the modes are given unquoted):\\
896 of (note that the modes are given unquoted):\\
896 over: overwrite existing log.\\
897 over: overwrite existing log.\\
897 backup: rename (if exists) to name~ and start name.\\
898 backup: rename (if exists) to name~ and start name.\\
898 append: well, that says it.\\
899 append: well, that says it.\\
899 rotate: create rotating logs name.1~, name.2~, etc.
900 rotate: create rotating logs name.1~, name.2~, etc.
900 """
901 """
901
902
902 #FIXME. This function should all be moved to the Logger class.
903 #FIXME. This function should all be moved to the Logger class.
903
904
904 valid_modes = qw('over backup append rotate')
905 valid_modes = qw('over backup append rotate')
905 if self.LOG:
906 if self.LOG:
906 print 'Logging is already in place. Logfile:',self.LOG
907 print 'Logging is already in place. Logfile:',self.LOG
907 return
908 return
908
909
909 par = parameter_s.strip()
910 par = parameter_s.strip()
910 if not par:
911 if not par:
911 logname = self.LOGDEF
912 logname = self.LOGDEF
912 logmode = 'rotate' # use rotate for the auto-generated logs
913 logmode = 'rotate' # use rotate for the auto-generated logs
913 else:
914 else:
914 try:
915 try:
915 logname,logmode = par.split()
916 logname,logmode = par.split()
916 except:
917 except:
917 try:
918 try:
918 logname = par
919 logname = par
919 logmode = 'backup'
920 logmode = 'backup'
920 except:
921 except:
921 warn('Usage: %log [log_name [log_mode]]')
922 warn('Usage: %log [log_name [log_mode]]')
922 return
923 return
923 if not logmode in valid_modes:
924 if not logmode in valid_modes:
924 warn('Logging NOT activated.\n'
925 warn('Logging NOT activated.\n'
925 'Usage: %log [log_name [log_mode]]\n'
926 'Usage: %log [log_name [log_mode]]\n'
926 'Valid modes: '+str(valid_modes))
927 'Valid modes: '+str(valid_modes))
927 return
928 return
928
929
929 # If we made it this far, I think we're ok:
930 # If we made it this far, I think we're ok:
930 print 'Activating auto-logging.'
931 print 'Activating auto-logging.'
931 print 'Current session state plus future input saved to:',logname
932 print 'Current session state plus future input saved to:',logname
932 print 'Logging mode: ',logmode
933 print 'Logging mode: ',logmode
933 # put logname into rc struct as if it had been called on the command line,
934 # put logname into rc struct as if it had been called on the command line,
934 # so it ends up saved in the log header
935 # so it ends up saved in the log header
935 # Save it in case we need to restore it...
936 # Save it in case we need to restore it...
936 old_logfile = self.shell.rc.opts.get('logfile','')
937 old_logfile = self.shell.rc.opts.get('logfile','')
937 logname = os.path.expanduser(logname)
938 logname = os.path.expanduser(logname)
938 self.shell.rc.opts.logfile = logname
939 self.shell.rc.opts.logfile = logname
939 self.LOGMODE = logmode # FIXME: this should be set through a function.
940 self.LOGMODE = logmode # FIXME: this should be set through a function.
940 try:
941 try:
941 header = str(self.LOGHEAD)
942 header = str(self.LOGHEAD)
942 self.create_log(header,logname)
943 self.create_log(header,logname)
943 self.logstart(header,logname)
944 self.logstart(header,logname)
944 except:
945 except:
945 self.LOG = '' # we are NOT logging, something went wrong
946 self.LOG = '' # we are NOT logging, something went wrong
946 self.shell.rc.opts.logfile = old_logfile
947 self.shell.rc.opts.logfile = old_logfile
947 warn("Couldn't start log: "+str(sys.exc_info()[1]))
948 warn("Couldn't start log: "+str(sys.exc_info()[1]))
948 else: # log input history up to this point
949 else: # log input history up to this point
949 self.logfile.write(self.shell.user_ns['_ih'][1:])
950 self.logfile.write(self.shell.user_ns['_ih'][1:])
950 self.logfile.flush()
951 self.logfile.flush()
951
952
952 def magic_logoff(self,parameter_s=''):
953 def magic_logoff(self,parameter_s=''):
953 """Temporarily stop logging.
954 """Temporarily stop logging.
954
955
955 You must have previously started logging."""
956 You must have previously started logging."""
956 self.switch_log(0)
957 self.switch_log(0)
957
958
958 def magic_logon(self,parameter_s=''):
959 def magic_logon(self,parameter_s=''):
959 """Restart logging.
960 """Restart logging.
960
961
961 This function is for restarting logging which you've temporarily
962 This function is for restarting logging which you've temporarily
962 stopped with %logoff. For starting logging for the first time, you
963 stopped with %logoff. For starting logging for the first time, you
963 must use the %logstart function, which allows you to specify an
964 must use the %logstart function, which allows you to specify an
964 optional log filename."""
965 optional log filename."""
965
966
966 self.switch_log(1)
967 self.switch_log(1)
967
968
968 def magic_logstate(self,parameter_s=''):
969 def magic_logstate(self,parameter_s=''):
969 """Print the status of the logging system."""
970 """Print the status of the logging system."""
970
971
971 self.logstate()
972 self.logstate()
972
973
973 def magic_pdb(self, parameter_s=''):
974 def magic_pdb(self, parameter_s=''):
974 """Control the calling of the pdb interactive debugger.
975 """Control the calling of the pdb interactive debugger.
975
976
976 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
977 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
977 argument it works as a toggle.
978 argument it works as a toggle.
978
979
979 When an exception is triggered, IPython can optionally call the
980 When an exception is triggered, IPython can optionally call the
980 interactive pdb debugger after the traceback printout. %pdb toggles
981 interactive pdb debugger after the traceback printout. %pdb toggles
981 this feature on and off."""
982 this feature on and off."""
982
983
983 par = parameter_s.strip().lower()
984 par = parameter_s.strip().lower()
984
985
985 if par:
986 if par:
986 try:
987 try:
987 pdb = {'off':0,'0':0,'on':1,'1':1}[par]
988 pdb = {'off':0,'0':0,'on':1,'1':1}[par]
988 except KeyError:
989 except KeyError:
989 print 'Incorrect argument. Use on/1, off/0 or nothing for a toggle.'
990 print 'Incorrect argument. Use on/1, off/0 or nothing for a toggle.'
990 return
991 return
991 else:
992 else:
992 self.shell.InteractiveTB.call_pdb = pdb
993 self.shell.InteractiveTB.call_pdb = pdb
993 else:
994 else:
994 self.shell.InteractiveTB.call_pdb = 1 - self.shell.InteractiveTB.call_pdb
995 self.shell.InteractiveTB.call_pdb = 1 - self.shell.InteractiveTB.call_pdb
995 print 'Automatic pdb calling has been turned',\
996 print 'Automatic pdb calling has been turned',\
996 on_off(self.shell.InteractiveTB.call_pdb)
997 on_off(self.shell.InteractiveTB.call_pdb)
997
998
998
999
999 def magic_prun(self, parameter_s ='',user_mode=1,
1000 def magic_prun(self, parameter_s ='',user_mode=1,
1000 opts=None,arg_lst=None,prog_ns=None):
1001 opts=None,arg_lst=None,prog_ns=None):
1001
1002
1002 """Run a statement through the python code profiler.
1003 """Run a statement through the python code profiler.
1003
1004
1004 Usage:\\
1005 Usage:\\
1005 %prun [options] statement
1006 %prun [options] statement
1006
1007
1007 The given statement (which doesn't require quote marks) is run via the
1008 The given statement (which doesn't require quote marks) is run via the
1008 python profiler in a manner similar to the profile.run() function.
1009 python profiler in a manner similar to the profile.run() function.
1009 Namespaces are internally managed to work correctly; profile.run
1010 Namespaces are internally managed to work correctly; profile.run
1010 cannot be used in IPython because it makes certain assumptions about
1011 cannot be used in IPython because it makes certain assumptions about
1011 namespaces which do not hold under IPython.
1012 namespaces which do not hold under IPython.
1012
1013
1013 Options:
1014 Options:
1014
1015
1015 -l <limit>: you can place restrictions on what or how much of the
1016 -l <limit>: you can place restrictions on what or how much of the
1016 profile gets printed. The limit value can be:
1017 profile gets printed. The limit value can be:
1017
1018
1018 * A string: only information for function names containing this string
1019 * A string: only information for function names containing this string
1019 is printed.
1020 is printed.
1020
1021
1021 * An integer: only these many lines are printed.
1022 * An integer: only these many lines are printed.
1022
1023
1023 * A float (between 0 and 1): this fraction of the report is printed
1024 * A float (between 0 and 1): this fraction of the report is printed
1024 (for example, use a limit of 0.4 to see the topmost 40% only).
1025 (for example, use a limit of 0.4 to see the topmost 40% only).
1025
1026
1026 You can combine several limits with repeated use of the option. For
1027 You can combine several limits with repeated use of the option. For
1027 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1028 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1028 information about class constructors.
1029 information about class constructors.
1029
1030
1030 -r: return the pstats.Stats object generated by the profiling. This
1031 -r: return the pstats.Stats object generated by the profiling. This
1031 object has all the information about the profile in it, and you can
1032 object has all the information about the profile in it, and you can
1032 later use it for further analysis or in other functions.
1033 later use it for further analysis or in other functions.
1033
1034
1034 Since magic functions have a particular form of calling which prevents
1035 Since magic functions have a particular form of calling which prevents
1035 you from writing something like:\\
1036 you from writing something like:\\
1036 In [1]: p = %prun -r print 4 # invalid!\\
1037 In [1]: p = %prun -r print 4 # invalid!\\
1037 you must instead use IPython's automatic variables to assign this:\\
1038 you must instead use IPython's automatic variables to assign this:\\
1038 In [1]: %prun -r print 4 \\
1039 In [1]: %prun -r print 4 \\
1039 Out[1]: <pstats.Stats instance at 0x8222cec>\\
1040 Out[1]: <pstats.Stats instance at 0x8222cec>\\
1040 In [2]: stats = _
1041 In [2]: stats = _
1041
1042
1042 If you really need to assign this value via an explicit function call,
1043 If you really need to assign this value via an explicit function call,
1043 you can always tap directly into the true name of the magic function
1044 you can always tap directly into the true name of the magic function
1044 by using the ipmagic function (which IPython automatically adds to the
1045 by using the ipmagic function (which IPython automatically adds to the
1045 builtins):\\
1046 builtins):\\
1046 In [3]: stats = ipmagic('prun','-r print 4')
1047 In [3]: stats = ipmagic('prun','-r print 4')
1047
1048
1048 You can type ipmagic? for more details on ipmagic.
1049 You can type ipmagic? for more details on ipmagic.
1049
1050
1050 -s <key>: sort profile by given key. You can provide more than one key
1051 -s <key>: sort profile by given key. You can provide more than one key
1051 by using the option several times: '-s key1 -s key2 -s key3...'. The
1052 by using the option several times: '-s key1 -s key2 -s key3...'. The
1052 default sorting key is 'time'.
1053 default sorting key is 'time'.
1053
1054
1054 The following is copied verbatim from the profile documentation
1055 The following is copied verbatim from the profile documentation
1055 referenced below:
1056 referenced below:
1056
1057
1057 When more than one key is provided, additional keys are used as
1058 When more than one key is provided, additional keys are used as
1058 secondary criteria when the there is equality in all keys selected
1059 secondary criteria when the there is equality in all keys selected
1059 before them.
1060 before them.
1060
1061
1061 Abbreviations can be used for any key names, as long as the
1062 Abbreviations can be used for any key names, as long as the
1062 abbreviation is unambiguous. The following are the keys currently
1063 abbreviation is unambiguous. The following are the keys currently
1063 defined:
1064 defined:
1064
1065
1065 Valid Arg Meaning\\
1066 Valid Arg Meaning\\
1066 "calls" call count\\
1067 "calls" call count\\
1067 "cumulative" cumulative time\\
1068 "cumulative" cumulative time\\
1068 "file" file name\\
1069 "file" file name\\
1069 "module" file name\\
1070 "module" file name\\
1070 "pcalls" primitive call count\\
1071 "pcalls" primitive call count\\
1071 "line" line number\\
1072 "line" line number\\
1072 "name" function name\\
1073 "name" function name\\
1073 "nfl" name/file/line\\
1074 "nfl" name/file/line\\
1074 "stdname" standard name\\
1075 "stdname" standard name\\
1075 "time" internal time
1076 "time" internal time
1076
1077
1077 Note that all sorts on statistics are in descending order (placing
1078 Note that all sorts on statistics are in descending order (placing
1078 most time consuming items first), where as name, file, and line number
1079 most time consuming items first), where as name, file, and line number
1079 searches are in ascending order (i.e., alphabetical). The subtle
1080 searches are in ascending order (i.e., alphabetical). The subtle
1080 distinction between "nfl" and "stdname" is that the standard name is a
1081 distinction between "nfl" and "stdname" is that the standard name is a
1081 sort of the name as printed, which means that the embedded line
1082 sort of the name as printed, which means that the embedded line
1082 numbers get compared in an odd way. For example, lines 3, 20, and 40
1083 numbers get compared in an odd way. For example, lines 3, 20, and 40
1083 would (if the file names were the same) appear in the string order
1084 would (if the file names were the same) appear in the string order
1084 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1085 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1085 line numbers. In fact, sort_stats("nfl") is the same as
1086 line numbers. In fact, sort_stats("nfl") is the same as
1086 sort_stats("name", "file", "line").
1087 sort_stats("name", "file", "line").
1087
1088
1088 -T <filename>: save profile results as shown on screen to a text
1089 -T <filename>: save profile results as shown on screen to a text
1089 file. The profile is still shown on screen.
1090 file. The profile is still shown on screen.
1090
1091
1091 -D <filename>: save (via dump_stats) profile statistics to given
1092 -D <filename>: save (via dump_stats) profile statistics to given
1092 filename. This data is in a format understod by the pstats module, and
1093 filename. This data is in a format understod by the pstats module, and
1093 is generated by a call to the dump_stats() method of profile
1094 is generated by a call to the dump_stats() method of profile
1094 objects. The profile is still shown on screen.
1095 objects. The profile is still shown on screen.
1095
1096
1096 If you want to run complete programs under the profiler's control, use
1097 If you want to run complete programs under the profiler's control, use
1097 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1098 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1098 contains profiler specific options as described here.
1099 contains profiler specific options as described here.
1099
1100
1100 You can read the complete documentation for the profile module with:\\
1101 You can read the complete documentation for the profile module with:\\
1101 In [1]: import profile; profile.help() """
1102 In [1]: import profile; profile.help() """
1102
1103
1103 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1104 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1104 # protect user quote marks
1105 # protect user quote marks
1105 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1106 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1106
1107
1107 if user_mode: # regular user call
1108 if user_mode: # regular user call
1108 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1109 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1109 list_all=1)
1110 list_all=1)
1110 namespace = self.shell.user_ns
1111 namespace = self.shell.user_ns
1111 else: # called to run a program by %run -p
1112 else: # called to run a program by %run -p
1112 try:
1113 try:
1113 filename = get_py_filename(arg_lst[0])
1114 filename = get_py_filename(arg_lst[0])
1114 except IOError,msg:
1115 except IOError,msg:
1115 error(msg)
1116 error(msg)
1116 return
1117 return
1117
1118
1118 arg_str = 'execfile(filename,prog_ns)'
1119 arg_str = 'execfile(filename,prog_ns)'
1119 namespace = locals()
1120 namespace = locals()
1120
1121
1121 opts.merge(opts_def)
1122 opts.merge(opts_def)
1122
1123
1123 prof = profile.Profile()
1124 prof = profile.Profile()
1124 try:
1125 try:
1125 prof = prof.runctx(arg_str,namespace,namespace)
1126 prof = prof.runctx(arg_str,namespace,namespace)
1126 sys_exit = ''
1127 sys_exit = ''
1127 except SystemExit:
1128 except SystemExit:
1128 sys_exit = """*** SystemExit exception caught in code being profiled."""
1129 sys_exit = """*** SystemExit exception caught in code being profiled."""
1129
1130
1130 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1131 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1131
1132
1132 lims = opts.l
1133 lims = opts.l
1133 if lims:
1134 if lims:
1134 lims = [] # rebuild lims with ints/floats/strings
1135 lims = [] # rebuild lims with ints/floats/strings
1135 for lim in opts.l:
1136 for lim in opts.l:
1136 try:
1137 try:
1137 lims.append(int(lim))
1138 lims.append(int(lim))
1138 except ValueError:
1139 except ValueError:
1139 try:
1140 try:
1140 lims.append(float(lim))
1141 lims.append(float(lim))
1141 except ValueError:
1142 except ValueError:
1142 lims.append(lim)
1143 lims.append(lim)
1143
1144
1144 # trap output
1145 # trap output
1145 sys_stdout = sys.stdout
1146 sys_stdout = sys.stdout
1146 stdout_trap = StringIO()
1147 stdout_trap = StringIO()
1147 try:
1148 try:
1148 sys.stdout = stdout_trap
1149 sys.stdout = stdout_trap
1149 stats.print_stats(*lims)
1150 stats.print_stats(*lims)
1150 finally:
1151 finally:
1151 sys.stdout = sys_stdout
1152 sys.stdout = sys_stdout
1152 output = stdout_trap.getvalue()
1153 output = stdout_trap.getvalue()
1153 output = output.rstrip()
1154 output = output.rstrip()
1154
1155
1155 page(output,screen_lines=self.shell.rc.screen_length)
1156 page(output,screen_lines=self.shell.rc.screen_length)
1156 print sys_exit,
1157 print sys_exit,
1157
1158
1158 dump_file = opts.D[0]
1159 dump_file = opts.D[0]
1159 text_file = opts.T[0]
1160 text_file = opts.T[0]
1160 if dump_file:
1161 if dump_file:
1161 prof.dump_stats(dump_file)
1162 prof.dump_stats(dump_file)
1162 print '\n*** Profile stats marshalled to file',\
1163 print '\n*** Profile stats marshalled to file',\
1163 `dump_file`+'.',sys_exit
1164 `dump_file`+'.',sys_exit
1164 if text_file:
1165 if text_file:
1165 file(text_file,'w').write(output)
1166 file(text_file,'w').write(output)
1166 print '\n*** Profile printout saved to text file',\
1167 print '\n*** Profile printout saved to text file',\
1167 `text_file`+'.',sys_exit
1168 `text_file`+'.',sys_exit
1168
1169
1169 if opts.has_key('r'):
1170 if opts.has_key('r'):
1170 return stats
1171 return stats
1171 else:
1172 else:
1172 return None
1173 return None
1173
1174
1174 def magic_run(self, parameter_s ='',runner=None):
1175 def magic_run(self, parameter_s ='',runner=None):
1175 """Run the named file inside IPython as a program.
1176 """Run the named file inside IPython as a program.
1176
1177
1177 Usage:\\
1178 Usage:\\
1178 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1179 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1179
1180
1180 Parameters after the filename are passed as command-line arguments to
1181 Parameters after the filename are passed as command-line arguments to
1181 the program (put in sys.argv). Then, control returns to IPython's
1182 the program (put in sys.argv). Then, control returns to IPython's
1182 prompt.
1183 prompt.
1183
1184
1184 This is similar to running at a system prompt:\\
1185 This is similar to running at a system prompt:\\
1185 $ python file args\\
1186 $ python file args\\
1186 but with the advantage of giving you IPython's tracebacks, and of
1187 but with the advantage of giving you IPython's tracebacks, and of
1187 loading all variables into your interactive namespace for further use
1188 loading all variables into your interactive namespace for further use
1188 (unless -p is used, see below).
1189 (unless -p is used, see below).
1189
1190
1190 The file is executed in a namespace initially consisting only of
1191 The file is executed in a namespace initially consisting only of
1191 __name__=='__main__' and sys.argv constructed as indicated. It thus
1192 __name__=='__main__' and sys.argv constructed as indicated. It thus
1192 sees its environment as if it were being run as a stand-alone
1193 sees its environment as if it were being run as a stand-alone
1193 program. But after execution, the IPython interactive namespace gets
1194 program. But after execution, the IPython interactive namespace gets
1194 updated with all variables defined in the program (except for __name__
1195 updated with all variables defined in the program (except for __name__
1195 and sys.argv). This allows for very convenient loading of code for
1196 and sys.argv). This allows for very convenient loading of code for
1196 interactive work, while giving each program a 'clean sheet' to run in.
1197 interactive work, while giving each program a 'clean sheet' to run in.
1197
1198
1198 Options:
1199 Options:
1199
1200
1200 -n: __name__ is NOT set to '__main__', but to the running file's name
1201 -n: __name__ is NOT set to '__main__', but to the running file's name
1201 without extension (as python does under import). This allows running
1202 without extension (as python does under import). This allows running
1202 scripts and reloading the definitions in them without calling code
1203 scripts and reloading the definitions in them without calling code
1203 protected by an ' if __name__ == "__main__" ' clause.
1204 protected by an ' if __name__ == "__main__" ' clause.
1204
1205
1205 -i: run the file in IPython's namespace instead of an empty one. This
1206 -i: run the file in IPython's namespace instead of an empty one. This
1206 is useful if you are experimenting with code written in a text editor
1207 is useful if you are experimenting with code written in a text editor
1207 which depends on variables defined interactively.
1208 which depends on variables defined interactively.
1208
1209
1209 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1210 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1210 being run. This is particularly useful if IPython is being used to
1211 being run. This is particularly useful if IPython is being used to
1211 run unittests, which always exit with a sys.exit() call. In such
1212 run unittests, which always exit with a sys.exit() call. In such
1212 cases you are interested in the output of the test results, not in
1213 cases you are interested in the output of the test results, not in
1213 seeing a traceback of the unittest module.
1214 seeing a traceback of the unittest module.
1214
1215
1215 -t: print timing information at the end of the run. IPython will give
1216 -t: print timing information at the end of the run. IPython will give
1216 you an estimated CPU time consumption for your script, which under
1217 you an estimated CPU time consumption for your script, which under
1217 Unix uses the resource module to avoid the wraparound problems of
1218 Unix uses the resource module to avoid the wraparound problems of
1218 time.clock(). Under Unix, an estimate of time spent on system tasks
1219 time.clock(). Under Unix, an estimate of time spent on system tasks
1219 is also given (for Windows platforms this is reported as 0.0).
1220 is also given (for Windows platforms this is reported as 0.0).
1220
1221
1221 If -t is given, an additional -N<N> option can be given, where <N>
1222 If -t is given, an additional -N<N> option can be given, where <N>
1222 must be an integer indicating how many times you want the script to
1223 must be an integer indicating how many times you want the script to
1223 run. The final timing report will include total and per run results.
1224 run. The final timing report will include total and per run results.
1224
1225
1225 For example (testing the script uniq_stable.py):
1226 For example (testing the script uniq_stable.py):
1226
1227
1227 In [1]: run -t uniq_stable
1228 In [1]: run -t uniq_stable
1228
1229
1229 IPython CPU timings (estimated):\\
1230 IPython CPU timings (estimated):\\
1230 User : 0.19597 s.\\
1231 User : 0.19597 s.\\
1231 System: 0.0 s.\\
1232 System: 0.0 s.\\
1232
1233
1233 In [2]: run -t -N5 uniq_stable
1234 In [2]: run -t -N5 uniq_stable
1234
1235
1235 IPython CPU timings (estimated):\\
1236 IPython CPU timings (estimated):\\
1236 Total runs performed: 5\\
1237 Total runs performed: 5\\
1237 Times : Total Per run\\
1238 Times : Total Per run\\
1238 User : 0.910862 s, 0.1821724 s.\\
1239 User : 0.910862 s, 0.1821724 s.\\
1239 System: 0.0 s, 0.0 s.
1240 System: 0.0 s, 0.0 s.
1240
1241
1241 -d: run your program under the control of pdb, the Python debugger.
1242 -d: run your program under the control of pdb, the Python debugger.
1242 This allows you to execute your program step by step, watch variables,
1243 This allows you to execute your program step by step, watch variables,
1243 etc. Internally, what IPython does is similar to calling:
1244 etc. Internally, what IPython does is similar to calling:
1244
1245
1245 pdb.run('execfile("YOURFILENAME")')
1246 pdb.run('execfile("YOURFILENAME")')
1246
1247
1247 with a breakpoint set on line 1 of your file. You can change the line
1248 with a breakpoint set on line 1 of your file. You can change the line
1248 number for this automatic breakpoint to be <N> by using the -bN option
1249 number for this automatic breakpoint to be <N> by using the -bN option
1249 (where N must be an integer). For example:
1250 (where N must be an integer). For example:
1250
1251
1251 %run -d -b40 myscript
1252 %run -d -b40 myscript
1252
1253
1253 will set the first breakpoint at line 40 in myscript.py. Note that
1254 will set the first breakpoint at line 40 in myscript.py. Note that
1254 the first breakpoint must be set on a line which actually does
1255 the first breakpoint must be set on a line which actually does
1255 something (not a comment or docstring) for it to stop execution.
1256 something (not a comment or docstring) for it to stop execution.
1256
1257
1257 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1258 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1258 first enter 'c' (without qoutes) to start execution up to the first
1259 first enter 'c' (without qoutes) to start execution up to the first
1259 breakpoint.
1260 breakpoint.
1260
1261
1261 Entering 'help' gives information about the use of the debugger. You
1262 Entering 'help' gives information about the use of the debugger. You
1262 can easily see pdb's full documentation with "import pdb;pdb.help()"
1263 can easily see pdb's full documentation with "import pdb;pdb.help()"
1263 at a prompt.
1264 at a prompt.
1264
1265
1265 -p: run program under the control of the Python profiler module (which
1266 -p: run program under the control of the Python profiler module (which
1266 prints a detailed report of execution times, function calls, etc).
1267 prints a detailed report of execution times, function calls, etc).
1267
1268
1268 You can pass other options after -p which affect the behavior of the
1269 You can pass other options after -p which affect the behavior of the
1269 profiler itself. See the docs for %prun for details.
1270 profiler itself. See the docs for %prun for details.
1270
1271
1271 In this mode, the program's variables do NOT propagate back to the
1272 In this mode, the program's variables do NOT propagate back to the
1272 IPython interactive namespace (because they remain in the namespace
1273 IPython interactive namespace (because they remain in the namespace
1273 where the profiler executes them).
1274 where the profiler executes them).
1274
1275
1275 Internally this triggers a call to %prun, see its documentation for
1276 Internally this triggers a call to %prun, see its documentation for
1276 details on the options available specifically for profiling."""
1277 details on the options available specifically for profiling."""
1277
1278
1278 # get arguments and set sys.argv for program to be run.
1279 # get arguments and set sys.argv for program to be run.
1279 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1280 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1280 mode='list',list_all=1)
1281 mode='list',list_all=1)
1281
1282
1282 try:
1283 try:
1283 filename = get_py_filename(arg_lst[0])
1284 filename = get_py_filename(arg_lst[0])
1284 except IndexError:
1285 except IndexError:
1285 warn('you must provide at least a filename.')
1286 warn('you must provide at least a filename.')
1286 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1287 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1287 return
1288 return
1288 except IOError,msg:
1289 except IOError,msg:
1289 error(msg)
1290 error(msg)
1290 return
1291 return
1291
1292
1292 # Control the response to exit() calls made by the script being run
1293 # Control the response to exit() calls made by the script being run
1293 exit_ignore = opts.has_key('e')
1294 exit_ignore = opts.has_key('e')
1294
1295
1295 # Make sure that the running script gets a proper sys.argv as if it
1296 # Make sure that the running script gets a proper sys.argv as if it
1296 # were run from a system shell.
1297 # were run from a system shell.
1297 save_argv = sys.argv # save it for later restoring
1298 save_argv = sys.argv # save it for later restoring
1298 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1299 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1299
1300
1300 if opts.has_key('i'):
1301 if opts.has_key('i'):
1301 prog_ns = self.shell.user_ns
1302 prog_ns = self.shell.user_ns
1302 __name__save = self.shell.user_ns['__name__']
1303 __name__save = self.shell.user_ns['__name__']
1303 prog_ns['__name__'] = '__main__'
1304 prog_ns['__name__'] = '__main__'
1304 else:
1305 else:
1305 if opts.has_key('n'):
1306 if opts.has_key('n'):
1306 name = os.path.splitext(os.path.basename(filename))[0]
1307 name = os.path.splitext(os.path.basename(filename))[0]
1307 else:
1308 else:
1308 name = '__main__'
1309 name = '__main__'
1309 prog_ns = {'__name__':name}
1310 prog_ns = {'__name__':name}
1310
1311
1311 # pickle fix. See iplib for an explanation
1312 # pickle fix. See iplib for an explanation
1312 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1313 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1313
1314
1314 stats = None
1315 stats = None
1315 try:
1316 try:
1316 if opts.has_key('p'):
1317 if opts.has_key('p'):
1317 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1318 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1318 else:
1319 else:
1319 if opts.has_key('d'):
1320 if opts.has_key('d'):
1320 deb = pdb.Pdb()
1321 deb = pdb.Pdb()
1321 # reset Breakpoint state, which is moronically kept
1322 # reset Breakpoint state, which is moronically kept
1322 # in a class
1323 # in a class
1323 bdb.Breakpoint.next = 1
1324 bdb.Breakpoint.next = 1
1324 bdb.Breakpoint.bplist = {}
1325 bdb.Breakpoint.bplist = {}
1325 bdb.Breakpoint.bpbynumber = [None]
1326 bdb.Breakpoint.bpbynumber = [None]
1326 # Set an initial breakpoint to stop execution
1327 # Set an initial breakpoint to stop execution
1327 maxtries = 10
1328 maxtries = 10
1328 bp = int(opts.get('b',[1])[0])
1329 bp = int(opts.get('b',[1])[0])
1329 checkline = deb.checkline(filename,bp)
1330 checkline = deb.checkline(filename,bp)
1330 if not checkline:
1331 if not checkline:
1331 for bp in range(bp+1,bp+maxtries+1):
1332 for bp in range(bp+1,bp+maxtries+1):
1332 if deb.checkline(filename,bp):
1333 if deb.checkline(filename,bp):
1333 break
1334 break
1334 else:
1335 else:
1335 msg = ("\nI failed to find a valid line to set "
1336 msg = ("\nI failed to find a valid line to set "
1336 "a breakpoint\n"
1337 "a breakpoint\n"
1337 "after trying up to line: %s.\n"
1338 "after trying up to line: %s.\n"
1338 "Please set a valid breakpoint manually "
1339 "Please set a valid breakpoint manually "
1339 "with the -b option." % bp)
1340 "with the -b option." % bp)
1340 error(msg)
1341 error(msg)
1341 return
1342 return
1342 # if we find a good linenumber, set the breakpoint
1343 # if we find a good linenumber, set the breakpoint
1343 deb.do_break('%s:%s' % (filename,bp))
1344 deb.do_break('%s:%s' % (filename,bp))
1344 # Start file run
1345 # Start file run
1345 print "NOTE: Enter 'c' at the",
1346 print "NOTE: Enter 'c' at the",
1346 print "(Pdb) prompt to start your script."
1347 print "(Pdb) prompt to start your script."
1347 deb.run('execfile("%s")' % filename,prog_ns)
1348 deb.run('execfile("%s")' % filename,prog_ns)
1348 else:
1349 else:
1349 if runner is None:
1350 if runner is None:
1350 runner = self.shell.safe_execfile
1351 runner = self.shell.safe_execfile
1351 if opts.has_key('t'):
1352 if opts.has_key('t'):
1352 try:
1353 try:
1353 nruns = int(opts['N'][0])
1354 nruns = int(opts['N'][0])
1354 if nruns < 1:
1355 if nruns < 1:
1355 error('Number of runs must be >=1')
1356 error('Number of runs must be >=1')
1356 return
1357 return
1357 except (KeyError):
1358 except (KeyError):
1358 nruns = 1
1359 nruns = 1
1359 if nruns == 1:
1360 if nruns == 1:
1360 t0 = clock2()
1361 t0 = clock2()
1361 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1362 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1362 t1 = clock2()
1363 t1 = clock2()
1363 t_usr = t1[0]-t0[0]
1364 t_usr = t1[0]-t0[0]
1364 t_sys = t1[1]-t1[1]
1365 t_sys = t1[1]-t1[1]
1365 print "\nIPython CPU timings (estimated):"
1366 print "\nIPython CPU timings (estimated):"
1366 print " User : %10s s." % t_usr
1367 print " User : %10s s." % t_usr
1367 print " System: %10s s." % t_sys
1368 print " System: %10s s." % t_sys
1368 else:
1369 else:
1369 runs = range(nruns)
1370 runs = range(nruns)
1370 t0 = clock2()
1371 t0 = clock2()
1371 for nr in runs:
1372 for nr in runs:
1372 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1373 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1373 t1 = clock2()
1374 t1 = clock2()
1374 t_usr = t1[0]-t0[0]
1375 t_usr = t1[0]-t0[0]
1375 t_sys = t1[1]-t1[1]
1376 t_sys = t1[1]-t1[1]
1376 print "\nIPython CPU timings (estimated):"
1377 print "\nIPython CPU timings (estimated):"
1377 print "Total runs performed:",nruns
1378 print "Total runs performed:",nruns
1378 print " Times : %10s %10s" % ('Total','Per run')
1379 print " Times : %10s %10s" % ('Total','Per run')
1379 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1380 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1380 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1381 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1381
1382
1382 else:
1383 else:
1383 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1384 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1384 if opts.has_key('i'):
1385 if opts.has_key('i'):
1385 self.shell.user_ns['__name__'] = __name__save
1386 self.shell.user_ns['__name__'] = __name__save
1386 else:
1387 else:
1387 # update IPython interactive namespace
1388 # update IPython interactive namespace
1388 del prog_ns['__name__']
1389 del prog_ns['__name__']
1389 self.shell.user_ns.update(prog_ns)
1390 self.shell.user_ns.update(prog_ns)
1390 finally:
1391 finally:
1391 sys.argv = save_argv
1392 sys.argv = save_argv
1392 return stats
1393 return stats
1393
1394
1394 def magic_runlog(self, parameter_s =''):
1395 def magic_runlog(self, parameter_s =''):
1395 """Run files as logs.
1396 """Run files as logs.
1396
1397
1397 Usage:\\
1398 Usage:\\
1398 %runlog file1 file2 ...
1399 %runlog file1 file2 ...
1399
1400
1400 Run the named files (treating them as log files) in sequence inside
1401 Run the named files (treating them as log files) in sequence inside
1401 the interpreter, and return to the prompt. This is much slower than
1402 the interpreter, and return to the prompt. This is much slower than
1402 %run because each line is executed in a try/except block, but it
1403 %run because each line is executed in a try/except block, but it
1403 allows running files with syntax errors in them.
1404 allows running files with syntax errors in them.
1404
1405
1405 Normally IPython will guess when a file is one of its own logfiles, so
1406 Normally IPython will guess when a file is one of its own logfiles, so
1406 you can typically use %run even for logs. This shorthand allows you to
1407 you can typically use %run even for logs. This shorthand allows you to
1407 force any file to be treated as a log file."""
1408 force any file to be treated as a log file."""
1408
1409
1409 for f in parameter_s.split():
1410 for f in parameter_s.split():
1410 self.shell.safe_execfile(f,self.shell.user_ns,
1411 self.shell.safe_execfile(f,self.shell.user_ns,
1411 self.shell.user_ns,islog=1)
1412 self.shell.user_ns,islog=1)
1412
1413
1413 def magic_time(self,parameter_s = ''):
1414 def magic_time(self,parameter_s = ''):
1414 """Time execution of a Python statement or expression.
1415 """Time execution of a Python statement or expression.
1415
1416
1416 The CPU and wall clock times are printed, and the value of the
1417 The CPU and wall clock times are printed, and the value of the
1417 expression (if any) is returned. Note that under Win32, system time
1418 expression (if any) is returned. Note that under Win32, system time
1418 is always reported as 0, since it can not be measured.
1419 is always reported as 0, since it can not be measured.
1419
1420
1420 This function provides very basic timing functionality. In Python
1421 This function provides very basic timing functionality. In Python
1421 2.3, the timeit module offers more control and sophistication, but for
1422 2.3, the timeit module offers more control and sophistication, but for
1422 now IPython supports Python 2.2, so we can not rely on timeit being
1423 now IPython supports Python 2.2, so we can not rely on timeit being
1423 present.
1424 present.
1424
1425
1425 Some examples:
1426 Some examples:
1426
1427
1427 In [1]: time 2**128
1428 In [1]: time 2**128
1428 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1429 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1429 Wall time: 0.00
1430 Wall time: 0.00
1430 Out[1]: 340282366920938463463374607431768211456L
1431 Out[1]: 340282366920938463463374607431768211456L
1431
1432
1432 In [2]: n = 1000000
1433 In [2]: n = 1000000
1433
1434
1434 In [3]: time sum(range(n))
1435 In [3]: time sum(range(n))
1435 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1436 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1436 Wall time: 1.37
1437 Wall time: 1.37
1437 Out[3]: 499999500000L
1438 Out[3]: 499999500000L
1438
1439
1439 In [4]: time print 'hello world'
1440 In [4]: time print 'hello world'
1440 hello world
1441 hello world
1441 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1442 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1442 Wall time: 0.00
1443 Wall time: 0.00
1443 """
1444 """
1444
1445
1445 # fail immediately if the given expression can't be compiled
1446 # fail immediately if the given expression can't be compiled
1446 try:
1447 try:
1447 mode = 'eval'
1448 mode = 'eval'
1448 code = compile(parameter_s,'<timed eval>',mode)
1449 code = compile(parameter_s,'<timed eval>',mode)
1449 except SyntaxError:
1450 except SyntaxError:
1450 mode = 'exec'
1451 mode = 'exec'
1451 code = compile(parameter_s,'<timed exec>',mode)
1452 code = compile(parameter_s,'<timed exec>',mode)
1452 # skew measurement as little as possible
1453 # skew measurement as little as possible
1453 glob = self.shell.user_ns
1454 glob = self.shell.user_ns
1454 clk = clock2
1455 clk = clock2
1455 wtime = time.time
1456 wtime = time.time
1456 # time execution
1457 # time execution
1457 wall_st = wtime()
1458 wall_st = wtime()
1458 if mode=='eval':
1459 if mode=='eval':
1459 st = clk()
1460 st = clk()
1460 out = eval(code,glob)
1461 out = eval(code,glob)
1461 end = clk()
1462 end = clk()
1462 else:
1463 else:
1463 st = clk()
1464 st = clk()
1464 exec code in glob
1465 exec code in glob
1465 end = clk()
1466 end = clk()
1466 out = None
1467 out = None
1467 wall_end = wtime()
1468 wall_end = wtime()
1468 # Compute actual times and report
1469 # Compute actual times and report
1469 wall_time = wall_end-wall_st
1470 wall_time = wall_end-wall_st
1470 cpu_user = end[0]-st[0]
1471 cpu_user = end[0]-st[0]
1471 cpu_sys = end[1]-st[1]
1472 cpu_sys = end[1]-st[1]
1472 cpu_tot = cpu_user+cpu_sys
1473 cpu_tot = cpu_user+cpu_sys
1473 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1474 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1474 (cpu_user,cpu_sys,cpu_tot)
1475 (cpu_user,cpu_sys,cpu_tot)
1475 print "Wall time: %.2f" % wall_time
1476 print "Wall time: %.2f" % wall_time
1476 return out
1477 return out
1477
1478
1478 def magic_macro(self,parameter_s = ''):
1479 def magic_macro(self,parameter_s = ''):
1479 """Define a set of input lines as a macro for future re-execution.
1480 """Define a set of input lines as a macro for future re-execution.
1480
1481
1481 Usage:\\
1482 Usage:\\
1482 %macro name n1:n2 n3:n4 ... n5 .. n6 ...
1483 %macro name n1:n2 n3:n4 ... n5 .. n6 ...
1483
1484
1484 This will define a global variable called `name` which is a string
1485 This will define a global variable called `name` which is a string
1485 made of joining the slices and lines you specify (n1,n2,... numbers
1486 made of joining the slices and lines you specify (n1,n2,... numbers
1486 above) from your input history into a single string. This variable
1487 above) from your input history into a single string. This variable
1487 acts like an automatic function which re-executes those lines as if
1488 acts like an automatic function which re-executes those lines as if
1488 you had typed them. You just type 'name' at the prompt and the code
1489 you had typed them. You just type 'name' at the prompt and the code
1489 executes.
1490 executes.
1490
1491
1491 Note that the slices use the standard Python slicing notation (5:8
1492 Note that the slices use the standard Python slicing notation (5:8
1492 means include lines numbered 5,6,7).
1493 means include lines numbered 5,6,7).
1493
1494
1494 For example, if your history contains (%hist prints it):
1495 For example, if your history contains (%hist prints it):
1495
1496
1496 44: x=1\\
1497 44: x=1\\
1497 45: y=3\\
1498 45: y=3\\
1498 46: z=x+y\\
1499 46: z=x+y\\
1499 47: print x\\
1500 47: print x\\
1500 48: a=5\\
1501 48: a=5\\
1501 49: print 'x',x,'y',y\\
1502 49: print 'x',x,'y',y\\
1502
1503
1503 you can create a macro with lines 44 through 47 (included) and line 49
1504 you can create a macro with lines 44 through 47 (included) and line 49
1504 called my_macro with:
1505 called my_macro with:
1505
1506
1506 In [51]: %macro my_macro 44:48 49
1507 In [51]: %macro my_macro 44:48 49
1507
1508
1508 Now, typing `my_macro` (without quotes) will re-execute all this code
1509 Now, typing `my_macro` (without quotes) will re-execute all this code
1509 in one pass.
1510 in one pass.
1510
1511
1511 You don't need to give the line-numbers in order, and any given line
1512 You don't need to give the line-numbers in order, and any given line
1512 number can appear multiple times. You can assemble macros with any
1513 number can appear multiple times. You can assemble macros with any
1513 lines from your input history in any order.
1514 lines from your input history in any order.
1514
1515
1515 The macro is a simple object which holds its value in an attribute,
1516 The macro is a simple object which holds its value in an attribute,
1516 but IPython's display system checks for macros and executes them as
1517 but IPython's display system checks for macros and executes them as
1517 code instead of printing them when you type their name.
1518 code instead of printing them when you type their name.
1518
1519
1519 You can view a macro's contents by explicitly printing it with:
1520 You can view a macro's contents by explicitly printing it with:
1520
1521
1521 'print macro_name'.
1522 'print macro_name'.
1522
1523
1523 For one-off cases which DON'T contain magic function calls in them you
1524 For one-off cases which DON'T contain magic function calls in them you
1524 can obtain similar results by explicitly executing slices from your
1525 can obtain similar results by explicitly executing slices from your
1525 input history with:
1526 input history with:
1526
1527
1527 In [60]: exec In[44:48]+In[49]"""
1528 In [60]: exec In[44:48]+In[49]"""
1528
1529
1529 args = parameter_s.split()
1530 args = parameter_s.split()
1530 name,ranges = args[0], args[1:]
1531 name,ranges = args[0], args[1:]
1531 #print 'rng',ranges # dbg
1532 #print 'rng',ranges # dbg
1532 cmds = self.extract_input_slices(ranges)
1533 cmds = self.extract_input_slices(ranges)
1533 macro = Macro(cmds)
1534 macro = Macro(cmds)
1534 self.shell.user_ns.update({name:macro})
1535 self.shell.user_ns.update({name:macro})
1535 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1536 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1536 print 'Macro contents:'
1537 print 'Macro contents:'
1537 print str(macro).rstrip(),
1538 print str(macro).rstrip(),
1538
1539
1539 def magic_save(self,parameter_s = ''):
1540 def magic_save(self,parameter_s = ''):
1540 """Save a set of lines to a given filename.
1541 """Save a set of lines to a given filename.
1541
1542
1542 Usage:\\
1543 Usage:\\
1543 %save filename n1:n2 n3:n4 ... n5 .. n6 ...
1544 %save filename n1:n2 n3:n4 ... n5 .. n6 ...
1544
1545
1545 This function uses the same syntax as %macro for line extraction, but
1546 This function uses the same syntax as %macro for line extraction, but
1546 instead of creating a macro it saves the resulting string to the
1547 instead of creating a macro it saves the resulting string to the
1547 filename you specify.
1548 filename you specify.
1548
1549
1549 It adds a '.py' extension to the file if you don't do so yourself, and
1550 It adds a '.py' extension to the file if you don't do so yourself, and
1550 it asks for confirmation before overwriting existing files."""
1551 it asks for confirmation before overwriting existing files."""
1551
1552
1552 args = parameter_s.split()
1553 args = parameter_s.split()
1553 fname,ranges = args[0], args[1:]
1554 fname,ranges = args[0], args[1:]
1554 if not fname.endswith('.py'):
1555 if not fname.endswith('.py'):
1555 fname += '.py'
1556 fname += '.py'
1556 if os.path.isfile(fname):
1557 if os.path.isfile(fname):
1557 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1558 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1558 if ans.lower() not in ['y','yes']:
1559 if ans.lower() not in ['y','yes']:
1559 print 'Operation cancelled.'
1560 print 'Operation cancelled.'
1560 return
1561 return
1561 cmds = ''.join(self.extract_input_slices(ranges))
1562 cmds = ''.join(self.extract_input_slices(ranges))
1562 f = file(fname,'w')
1563 f = file(fname,'w')
1563 f.write(cmds)
1564 f.write(cmds)
1564 f.close()
1565 f.close()
1565 print 'The following commands were written to file `%s`:' % fname
1566 print 'The following commands were written to file `%s`:' % fname
1566 print cmds
1567 print cmds
1567
1568
1568 def magic_ed(self,parameter_s = ''):
1569 def magic_ed(self,parameter_s = ''):
1569 """Alias to %edit."""
1570 """Alias to %edit."""
1570 return self.magic_edit(parameter_s)
1571 return self.magic_edit(parameter_s)
1571
1572
1572 def magic_edit(self,parameter_s = '',last_call=['','']):
1573 def magic_edit(self,parameter_s = '',last_call=['','']):
1573 """Bring up an editor and execute the resulting code.
1574 """Bring up an editor and execute the resulting code.
1574
1575
1575 Usage:
1576 Usage:
1576 %edit [options] [args]
1577 %edit [options] [args]
1577
1578
1578 %edit runs IPython's editor hook. The default version of this hook is
1579 %edit runs IPython's editor hook. The default version of this hook is
1579 set to call the __IPYTHON__.rc.editor command. This is read from your
1580 set to call the __IPYTHON__.rc.editor command. This is read from your
1580 environment variable $EDITOR. If this isn't found, it will default to
1581 environment variable $EDITOR. If this isn't found, it will default to
1581 vi under Linux/Unix and to notepad under Windows. See the end of this
1582 vi under Linux/Unix and to notepad under Windows. See the end of this
1582 docstring for how to change the editor hook.
1583 docstring for how to change the editor hook.
1583
1584
1584 You can also set the value of this editor via the command line option
1585 You can also set the value of this editor via the command line option
1585 '-editor' or in your ipythonrc file. This is useful if you wish to use
1586 '-editor' or in your ipythonrc file. This is useful if you wish to use
1586 specifically for IPython an editor different from your typical default
1587 specifically for IPython an editor different from your typical default
1587 (and for Windows users who typically don't set environment variables).
1588 (and for Windows users who typically don't set environment variables).
1588
1589
1589 This command allows you to conveniently edit multi-line code right in
1590 This command allows you to conveniently edit multi-line code right in
1590 your IPython session.
1591 your IPython session.
1591
1592
1592 If called without arguments, %edit opens up an empty editor with a
1593 If called without arguments, %edit opens up an empty editor with a
1593 temporary file and will execute the contents of this file when you
1594 temporary file and will execute the contents of this file when you
1594 close it (don't forget to save it!).
1595 close it (don't forget to save it!).
1595
1596
1596 Options:
1597 Options:
1597
1598
1598 -p: this will call the editor with the same data as the previous time
1599 -p: this will call the editor with the same data as the previous time
1599 it was used, regardless of how long ago (in your current session) it
1600 it was used, regardless of how long ago (in your current session) it
1600 was.
1601 was.
1601
1602
1602 -x: do not execute the edited code immediately upon exit. This is
1603 -x: do not execute the edited code immediately upon exit. This is
1603 mainly useful if you are editing programs which need to be called with
1604 mainly useful if you are editing programs which need to be called with
1604 command line arguments, which you can then do using %run.
1605 command line arguments, which you can then do using %run.
1605
1606
1606 Arguments:
1607 Arguments:
1607
1608
1608 If arguments are given, the following possibilites exist:
1609 If arguments are given, the following possibilites exist:
1609
1610
1610 - The arguments are numbers or pairs of colon-separated numbers (like
1611 - The arguments are numbers or pairs of colon-separated numbers (like
1611 1 4:8 9). These are interpreted as lines of previous input to be
1612 1 4:8 9). These are interpreted as lines of previous input to be
1612 loaded into the editor. The syntax is the same of the %macro command.
1613 loaded into the editor. The syntax is the same of the %macro command.
1613
1614
1614 - If the argument doesn't start with a number, it is evaluated as a
1615 - If the argument doesn't start with a number, it is evaluated as a
1615 variable and its contents loaded into the editor. You can thus edit
1616 variable and its contents loaded into the editor. You can thus edit
1616 any string which contains python code (including the result of
1617 any string which contains python code (including the result of
1617 previous edits).
1618 previous edits).
1618
1619
1619 - If the argument is the name of an object (other than a string),
1620 - If the argument is the name of an object (other than a string),
1620 IPython will try to locate the file where it was defined and open the
1621 IPython will try to locate the file where it was defined and open the
1621 editor at the point where it is defined. You can use `%edit function`
1622 editor at the point where it is defined. You can use `%edit function`
1622 to load an editor exactly at the point where 'function' is defined,
1623 to load an editor exactly at the point where 'function' is defined,
1623 edit it and have the file be executed automatically.
1624 edit it and have the file be executed automatically.
1624
1625
1625 Note: opening at an exact line is only supported under Unix, and some
1626 Note: opening at an exact line is only supported under Unix, and some
1626 editors (like kedit and gedit up to Gnome 2.8) do not understand the
1627 editors (like kedit and gedit up to Gnome 2.8) do not understand the
1627 '+NUMBER' parameter necessary for this feature. Good editors like
1628 '+NUMBER' parameter necessary for this feature. Good editors like
1628 (X)Emacs, vi, jed, pico and joe all do.
1629 (X)Emacs, vi, jed, pico and joe all do.
1629
1630
1630 - If the argument is not found as a variable, IPython will look for a
1631 - If the argument is not found as a variable, IPython will look for a
1631 file with that name (adding .py if necessary) and load it into the
1632 file with that name (adding .py if necessary) and load it into the
1632 editor. It will execute its contents with execfile() when you exit,
1633 editor. It will execute its contents with execfile() when you exit,
1633 loading any code in the file into your interactive namespace.
1634 loading any code in the file into your interactive namespace.
1634
1635
1635 After executing your code, %edit will return as output the code you
1636 After executing your code, %edit will return as output the code you
1636 typed in the editor (except when it was an existing file). This way
1637 typed in the editor (except when it was an existing file). This way
1637 you can reload the code in further invocations of %edit as a variable,
1638 you can reload the code in further invocations of %edit as a variable,
1638 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
1639 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
1639 the output.
1640 the output.
1640
1641
1641 Note that %edit is also available through the alias %ed.
1642 Note that %edit is also available through the alias %ed.
1642
1643
1643 This is an example of creating a simple function inside the editor and
1644 This is an example of creating a simple function inside the editor and
1644 then modifying it. First, start up the editor:
1645 then modifying it. First, start up the editor:
1645
1646
1646 In [1]: ed\\
1647 In [1]: ed\\
1647 Editing... done. Executing edited code...\\
1648 Editing... done. Executing edited code...\\
1648 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
1649 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
1649
1650
1650 We can then call the function foo():
1651 We can then call the function foo():
1651
1652
1652 In [2]: foo()\\
1653 In [2]: foo()\\
1653 foo() was defined in an editing session
1654 foo() was defined in an editing session
1654
1655
1655 Now we edit foo. IPython automatically loads the editor with the
1656 Now we edit foo. IPython automatically loads the editor with the
1656 (temporary) file where foo() was previously defined:
1657 (temporary) file where foo() was previously defined:
1657
1658
1658 In [3]: ed foo\\
1659 In [3]: ed foo\\
1659 Editing... done. Executing edited code...
1660 Editing... done. Executing edited code...
1660
1661
1661 And if we call foo() again we get the modified version:
1662 And if we call foo() again we get the modified version:
1662
1663
1663 In [4]: foo()\\
1664 In [4]: foo()\\
1664 foo() has now been changed!
1665 foo() has now been changed!
1665
1666
1666 Here is an example of how to edit a code snippet successive
1667 Here is an example of how to edit a code snippet successive
1667 times. First we call the editor:
1668 times. First we call the editor:
1668
1669
1669 In [8]: ed\\
1670 In [8]: ed\\
1670 Editing... done. Executing edited code...\\
1671 Editing... done. Executing edited code...\\
1671 hello\\
1672 hello\\
1672 Out[8]: "print 'hello'\\n"
1673 Out[8]: "print 'hello'\\n"
1673
1674
1674 Now we call it again with the previous output (stored in _):
1675 Now we call it again with the previous output (stored in _):
1675
1676
1676 In [9]: ed _\\
1677 In [9]: ed _\\
1677 Editing... done. Executing edited code...\\
1678 Editing... done. Executing edited code...\\
1678 hello world\\
1679 hello world\\
1679 Out[9]: "print 'hello world'\\n"
1680 Out[9]: "print 'hello world'\\n"
1680
1681
1681 Now we call it with the output #8 (stored in _8, also as Out[8]):
1682 Now we call it with the output #8 (stored in _8, also as Out[8]):
1682
1683
1683 In [10]: ed _8\\
1684 In [10]: ed _8\\
1684 Editing... done. Executing edited code...\\
1685 Editing... done. Executing edited code...\\
1685 hello again\\
1686 hello again\\
1686 Out[10]: "print 'hello again'\\n"
1687 Out[10]: "print 'hello again'\\n"
1687
1688
1688
1689
1689 Changing the default editor hook:
1690 Changing the default editor hook:
1690
1691
1691 If you wish to write your own editor hook, you can put it in a
1692 If you wish to write your own editor hook, you can put it in a
1692 configuration file which you load at startup time. The default hook
1693 configuration file which you load at startup time. The default hook
1693 is defined in the IPython.hooks module, and you can use that as a
1694 is defined in the IPython.hooks module, and you can use that as a
1694 starting example for further modifications. That file also has
1695 starting example for further modifications. That file also has
1695 general instructions on how to set a new hook for use once you've
1696 general instructions on how to set a new hook for use once you've
1696 defined it."""
1697 defined it."""
1697
1698
1698 # FIXME: This function has become a convoluted mess. It needs a
1699 # FIXME: This function has become a convoluted mess. It needs a
1699 # ground-up rewrite with clean, simple logic.
1700 # ground-up rewrite with clean, simple logic.
1700
1701
1701 def make_filename(arg):
1702 def make_filename(arg):
1702 "Make a filename from the given args"
1703 "Make a filename from the given args"
1703 try:
1704 try:
1704 filename = get_py_filename(arg)
1705 filename = get_py_filename(arg)
1705 except IOError:
1706 except IOError:
1706 if args.endswith('.py'):
1707 if args.endswith('.py'):
1707 filename = arg
1708 filename = arg
1708 else:
1709 else:
1709 filename = None
1710 filename = None
1710 return filename
1711 return filename
1711
1712
1712 # custom exceptions
1713 # custom exceptions
1713 class DataIsObject(Exception): pass
1714 class DataIsObject(Exception): pass
1714
1715
1715 opts,args = self.parse_options(parameter_s,'px')
1716 opts,args = self.parse_options(parameter_s,'px')
1716
1717
1717 # Default line number value
1718 # Default line number value
1718 lineno = None
1719 lineno = None
1719 if opts.has_key('p'):
1720 if opts.has_key('p'):
1720 args = '_%s' % last_call[0]
1721 args = '_%s' % last_call[0]
1721 if not self.shell.user_ns.has_key(args):
1722 if not self.shell.user_ns.has_key(args):
1722 args = last_call[1]
1723 args = last_call[1]
1723
1724
1724 # use last_call to remember the state of the previous call, but don't
1725 # use last_call to remember the state of the previous call, but don't
1725 # let it be clobbered by successive '-p' calls.
1726 # let it be clobbered by successive '-p' calls.
1726 try:
1727 try:
1727 last_call[0] = self.shell.outputcache.prompt_count
1728 last_call[0] = self.shell.outputcache.prompt_count
1728 if not opts.has_key('p'):
1729 if not opts.has_key('p'):
1729 last_call[1] = parameter_s
1730 last_call[1] = parameter_s
1730 except:
1731 except:
1731 pass
1732 pass
1732
1733
1733 # by default this is done with temp files, except when the given
1734 # by default this is done with temp files, except when the given
1734 # arg is a filename
1735 # arg is a filename
1735 use_temp = 1
1736 use_temp = 1
1736
1737
1737 if re.match(r'\d',args):
1738 if re.match(r'\d',args):
1738 # Mode where user specifies ranges of lines, like in %macro.
1739 # Mode where user specifies ranges of lines, like in %macro.
1739 # This means that you can't edit files whose names begin with
1740 # This means that you can't edit files whose names begin with
1740 # numbers this way. Tough.
1741 # numbers this way. Tough.
1741 ranges = args.split()
1742 ranges = args.split()
1742 data = ''.join(self.extract_input_slices(ranges))
1743 data = ''.join(self.extract_input_slices(ranges))
1743 elif args.endswith('.py'):
1744 elif args.endswith('.py'):
1744 filename = make_filename(args)
1745 filename = make_filename(args)
1745 data = ''
1746 data = ''
1746 use_temp = 0
1747 use_temp = 0
1747 elif args:
1748 elif args:
1748 try:
1749 try:
1749 # Load the parameter given as a variable. If not a string,
1750 # Load the parameter given as a variable. If not a string,
1750 # process it as an object instead (below)
1751 # process it as an object instead (below)
1751
1752
1752 #print '*** args',args,'type',type(args) # dbg
1753 #print '*** args',args,'type',type(args) # dbg
1753 data = eval(args,self.shell.user_ns)
1754 data = eval(args,self.shell.user_ns)
1754 if not type(data) in StringTypes:
1755 if not type(data) in StringTypes:
1755 raise DataIsObject
1756 raise DataIsObject
1756 except (NameError,SyntaxError):
1757 except (NameError,SyntaxError):
1757 # given argument is not a variable, try as a filename
1758 # given argument is not a variable, try as a filename
1758 filename = make_filename(args)
1759 filename = make_filename(args)
1759 if filename is None:
1760 if filename is None:
1760 warn("Argument given (%s) can't be found as a variable "
1761 warn("Argument given (%s) can't be found as a variable "
1761 "or as a filename." % args)
1762 "or as a filename." % args)
1762 return
1763 return
1763 data = ''
1764 data = ''
1764 use_temp = 0
1765 use_temp = 0
1765 except DataIsObject:
1766 except DataIsObject:
1766 # For objects, try to edit the file where they are defined
1767 # For objects, try to edit the file where they are defined
1767 try:
1768 try:
1768 filename = inspect.getabsfile(data)
1769 filename = inspect.getabsfile(data)
1769 datafile = 1
1770 datafile = 1
1770 except TypeError:
1771 except TypeError:
1771 filename = make_filename(args)
1772 filename = make_filename(args)
1772 datafile = 1
1773 datafile = 1
1773 warn('Could not find file where `%s` is defined.\n'
1774 warn('Could not find file where `%s` is defined.\n'
1774 'Opening a file named `%s`' % (args,filename))
1775 'Opening a file named `%s`' % (args,filename))
1775 # Now, make sure we can actually read the source (if it was in
1776 # Now, make sure we can actually read the source (if it was in
1776 # a temp file it's gone by now).
1777 # a temp file it's gone by now).
1777 if datafile:
1778 if datafile:
1778 try:
1779 try:
1779 lineno = inspect.getsourcelines(data)[1]
1780 lineno = inspect.getsourcelines(data)[1]
1780 except IOError:
1781 except IOError:
1781 filename = make_filename(args)
1782 filename = make_filename(args)
1782 if filename is None:
1783 if filename is None:
1783 warn('The file `%s` where `%s` was defined cannot '
1784 warn('The file `%s` where `%s` was defined cannot '
1784 'be read.' % (filename,data))
1785 'be read.' % (filename,data))
1785 return
1786 return
1786 use_temp = 0
1787 use_temp = 0
1787 else:
1788 else:
1788 data = ''
1789 data = ''
1789
1790
1790 if use_temp:
1791 if use_temp:
1791 filename = tempfile.mktemp('.py')
1792 filename = tempfile.mktemp('.py')
1792 self.shell.tempfiles.append(filename)
1793 self.shell.tempfiles.append(filename)
1793
1794
1794 if data and use_temp:
1795 if data and use_temp:
1795 tmp_file = open(filename,'w')
1796 tmp_file = open(filename,'w')
1796 tmp_file.write(data)
1797 tmp_file.write(data)
1797 tmp_file.close()
1798 tmp_file.close()
1798
1799
1799 # do actual editing here
1800 # do actual editing here
1800 print 'Editing...',
1801 print 'Editing...',
1801 sys.stdout.flush()
1802 sys.stdout.flush()
1802 self.shell.hooks.editor(filename,lineno)
1803 self.shell.hooks.editor(filename,lineno)
1803 if opts.has_key('x'): # -x prevents actual execution
1804 if opts.has_key('x'): # -x prevents actual execution
1804 print
1805 print
1805 else:
1806 else:
1806 print 'done. Executing edited code...'
1807 print 'done. Executing edited code...'
1807 try:
1808 try:
1808 execfile(filename,self.shell.user_ns)
1809 execfile(filename,self.shell.user_ns)
1809 except IOError,msg:
1810 except IOError,msg:
1810 if msg.filename == filename:
1811 if msg.filename == filename:
1811 warn('File not found. Did you forget to save?')
1812 warn('File not found. Did you forget to save?')
1812 return
1813 return
1813 else:
1814 else:
1814 self.shell.showtraceback()
1815 self.shell.showtraceback()
1815 except:
1816 except:
1816 self.shell.showtraceback()
1817 self.shell.showtraceback()
1817 if use_temp:
1818 if use_temp:
1818 contents = open(filename).read()
1819 contents = open(filename).read()
1819 return contents
1820 return contents
1820
1821
1821 def magic_xmode(self,parameter_s = ''):
1822 def magic_xmode(self,parameter_s = ''):
1822 """Switch modes for the exception handlers.
1823 """Switch modes for the exception handlers.
1823
1824
1824 Valid modes: Plain, Context and Verbose.
1825 Valid modes: Plain, Context and Verbose.
1825
1826
1826 If called without arguments, acts as a toggle."""
1827 If called without arguments, acts as a toggle."""
1827
1828
1828 new_mode = parameter_s.strip().capitalize()
1829 new_mode = parameter_s.strip().capitalize()
1829 try:
1830 try:
1830 self.InteractiveTB.set_mode(mode = new_mode)
1831 self.InteractiveTB.set_mode(mode = new_mode)
1831 print 'Exception reporting mode:',self.InteractiveTB.mode
1832 print 'Exception reporting mode:',self.InteractiveTB.mode
1832 except:
1833 except:
1833 warn('Error changing exception modes.\n' + str(sys.exc_info()[1]))
1834 warn('Error changing exception modes.\n' + str(sys.exc_info()[1]))
1834
1835
1835 def magic_colors(self,parameter_s = ''):
1836 def magic_colors(self,parameter_s = ''):
1836 """Switch color scheme for prompts, info system and exception handlers.
1837 """Switch color scheme for prompts, info system and exception handlers.
1837
1838
1838 Currently implemented schemes: NoColor, Linux, LightBG.
1839 Currently implemented schemes: NoColor, Linux, LightBG.
1839
1840
1840 Color scheme names are not case-sensitive."""
1841 Color scheme names are not case-sensitive."""
1841
1842
1842 new_scheme = parameter_s.strip()
1843 new_scheme = parameter_s.strip()
1843 if not new_scheme:
1844 if not new_scheme:
1844 print 'You must specify a color scheme.'
1845 print 'You must specify a color scheme.'
1845 return
1846 return
1846 # Under Windows, check for Gary Bishop's readline, which is necessary
1847 # Under Windows, check for Gary Bishop's readline, which is necessary
1847 # for ANSI coloring
1848 # for ANSI coloring
1848 if os.name in ['nt','dos']:
1849 if os.name in ['nt','dos']:
1849 try:
1850 try:
1850 import readline
1851 import readline
1851 except ImportError:
1852 except ImportError:
1852 has_readline = 0
1853 has_readline = 0
1853 else:
1854 else:
1854 try:
1855 try:
1855 readline.GetOutputFile()
1856 readline.GetOutputFile()
1856 except AttributeError:
1857 except AttributeError:
1857 has_readline = 0
1858 has_readline = 0
1858 else:
1859 else:
1859 has_readline = 1
1860 has_readline = 1
1860 if not has_readline:
1861 if not has_readline:
1861 msg = """\
1862 msg = """\
1862 Proper color support under MS Windows requires Gary Bishop's readline library.
1863 Proper color support under MS Windows requires Gary Bishop's readline library.
1863 You can find it at:
1864 You can find it at:
1864 http://sourceforge.net/projects/uncpythontools
1865 http://sourceforge.net/projects/uncpythontools
1865 Gary's readline needs the ctypes module, from:
1866 Gary's readline needs the ctypes module, from:
1866 http://starship.python.net/crew/theller/ctypes
1867 http://starship.python.net/crew/theller/ctypes
1867
1868
1868 Defaulting color scheme to 'NoColor'"""
1869 Defaulting color scheme to 'NoColor'"""
1869 new_scheme = 'NoColor'
1870 new_scheme = 'NoColor'
1870 warn(msg)
1871 warn(msg)
1871
1872
1872 # Set prompt colors
1873 # Set prompt colors
1873 try:
1874 try:
1874 self.shell.outputcache.set_colors(new_scheme)
1875 self.shell.outputcache.set_colors(new_scheme)
1875 except:
1876 except:
1876 warn('Error changing prompt color schemes.\n'
1877 warn('Error changing prompt color schemes.\n'
1877 + str(sys.exc_info()[1]))
1878 + str(sys.exc_info()[1]))
1878 else:
1879 else:
1879 self.shell.rc.colors = \
1880 self.shell.rc.colors = \
1880 self.shell.outputcache.color_table.active_scheme_name
1881 self.shell.outputcache.color_table.active_scheme_name
1881 # Set exception colors
1882 # Set exception colors
1882 try:
1883 try:
1883 self.shell.InteractiveTB.set_colors(scheme = new_scheme)
1884 self.shell.InteractiveTB.set_colors(scheme = new_scheme)
1884 self.shell.SyntaxTB.set_colors(scheme = new_scheme)
1885 self.shell.SyntaxTB.set_colors(scheme = new_scheme)
1885 except:
1886 except:
1886 warn('Error changing exception color schemes.\n'
1887 warn('Error changing exception color schemes.\n'
1887 + str(sys.exc_info()[1]))
1888 + str(sys.exc_info()[1]))
1888 # Set info (for 'object?') colors
1889 # Set info (for 'object?') colors
1889 if self.shell.rc.color_info:
1890 if self.shell.rc.color_info:
1890 try:
1891 try:
1891 self.shell.inspector.set_active_scheme(new_scheme)
1892 self.shell.inspector.set_active_scheme(new_scheme)
1892 except:
1893 except:
1893 warn('Error changing object inspector color schemes.\n'
1894 warn('Error changing object inspector color schemes.\n'
1894 + str(sys.exc_info()[1]))
1895 + str(sys.exc_info()[1]))
1895 else:
1896 else:
1896 self.shell.inspector.set_active_scheme('NoColor')
1897 self.shell.inspector.set_active_scheme('NoColor')
1897
1898
1898 def magic_color_info(self,parameter_s = ''):
1899 def magic_color_info(self,parameter_s = ''):
1899 """Toggle color_info.
1900 """Toggle color_info.
1900
1901
1901 The color_info configuration parameter controls whether colors are
1902 The color_info configuration parameter controls whether colors are
1902 used for displaying object details (by things like %psource, %pfile or
1903 used for displaying object details (by things like %psource, %pfile or
1903 the '?' system). This function toggles this value with each call.
1904 the '?' system). This function toggles this value with each call.
1904
1905
1905 Note that unless you have a fairly recent pager (less works better
1906 Note that unless you have a fairly recent pager (less works better
1906 than more) in your system, using colored object information displays
1907 than more) in your system, using colored object information displays
1907 will not work properly. Test it and see."""
1908 will not work properly. Test it and see."""
1908
1909
1909 self.shell.rc.color_info = 1 - self.shell.rc.color_info
1910 self.shell.rc.color_info = 1 - self.shell.rc.color_info
1910 self.magic_colors(self.shell.rc.colors)
1911 self.magic_colors(self.shell.rc.colors)
1911 print 'Object introspection functions have now coloring:',
1912 print 'Object introspection functions have now coloring:',
1912 print ['OFF','ON'][self.shell.rc.color_info]
1913 print ['OFF','ON'][self.shell.rc.color_info]
1913
1914
1914 def magic_Pprint(self, parameter_s=''):
1915 def magic_Pprint(self, parameter_s=''):
1915 """Toggle pretty printing on/off."""
1916 """Toggle pretty printing on/off."""
1916
1917
1917 self.shell.outputcache.Pprint = 1 - self.shell.outputcache.Pprint
1918 self.shell.outputcache.Pprint = 1 - self.shell.outputcache.Pprint
1918 print 'Pretty printing has been turned', \
1919 print 'Pretty printing has been turned', \
1919 ['OFF','ON'][self.shell.outputcache.Pprint]
1920 ['OFF','ON'][self.shell.outputcache.Pprint]
1920
1921
1921 def magic_Exit(self, parameter_s=''):
1922 def magic_Exit(self, parameter_s=''):
1922 """Exit IPython without confirmation."""
1923 """Exit IPython without confirmation."""
1923
1924
1924 self.shell.exit_now = True
1925 self.shell.exit_now = True
1925
1926
1926 def magic_Quit(self, parameter_s=''):
1927 def magic_Quit(self, parameter_s=''):
1927 """Exit IPython without confirmation (like %Exit)."""
1928 """Exit IPython without confirmation (like %Exit)."""
1928
1929
1929 self.shell.exit_now = True
1930 self.shell.exit_now = True
1930
1931
1931 #......................................................................
1932 #......................................................................
1932 # Functions to implement unix shell-type things
1933 # Functions to implement unix shell-type things
1933
1934
1934 def magic_alias(self, parameter_s = ''):
1935 def magic_alias(self, parameter_s = ''):
1935 """Define an alias for a system command.
1936 """Define an alias for a system command.
1936
1937
1937 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
1938 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
1938
1939
1939 Then, typing 'alias_name params' will execute the system command 'cmd
1940 Then, typing 'alias_name params' will execute the system command 'cmd
1940 params' (from your underlying operating system).
1941 params' (from your underlying operating system).
1941
1942
1942 Aliases have lower precedence than magic functions and Python normal
1943 Aliases have lower precedence than magic functions and Python normal
1943 variables, so if 'foo' is both a Python variable and an alias, the
1944 variables, so if 'foo' is both a Python variable and an alias, the
1944 alias can not be executed until 'del foo' removes the Python variable.
1945 alias can not be executed until 'del foo' removes the Python variable.
1945
1946
1946 You can use the %l specifier in an alias definition to represent the
1947 You can use the %l specifier in an alias definition to represent the
1947 whole line when the alias is called. For example:
1948 whole line when the alias is called. For example:
1948
1949
1949 In [2]: alias all echo "Input in brackets: <%l>"\\
1950 In [2]: alias all echo "Input in brackets: <%l>"\\
1950 In [3]: all hello world\\
1951 In [3]: all hello world\\
1951 Input in brackets: <hello world>
1952 Input in brackets: <hello world>
1952
1953
1953 You can also define aliases with parameters using %s specifiers (one
1954 You can also define aliases with parameters using %s specifiers (one
1954 per parameter):
1955 per parameter):
1955
1956
1956 In [1]: alias parts echo first %s second %s\\
1957 In [1]: alias parts echo first %s second %s\\
1957 In [2]: %parts A B\\
1958 In [2]: %parts A B\\
1958 first A second B\\
1959 first A second B\\
1959 In [3]: %parts A\\
1960 In [3]: %parts A\\
1960 Incorrect number of arguments: 2 expected.\\
1961 Incorrect number of arguments: 2 expected.\\
1961 parts is an alias to: 'echo first %s second %s'
1962 parts is an alias to: 'echo first %s second %s'
1962
1963
1963 Note that %l and %s are mutually exclusive. You can only use one or
1964 Note that %l and %s are mutually exclusive. You can only use one or
1964 the other in your aliases.
1965 the other in your aliases.
1965
1966
1966 Aliases expand Python variables just like system calls using ! or !!
1967 Aliases expand Python variables just like system calls using ! or !!
1967 do: all expressions prefixed with '$' get expanded. For details of
1968 do: all expressions prefixed with '$' get expanded. For details of
1968 the semantic rules, see PEP-215:
1969 the semantic rules, see PEP-215:
1969 http://www.python.org/peps/pep-0215.html. This is the library used by
1970 http://www.python.org/peps/pep-0215.html. This is the library used by
1970 IPython for variable expansion. If you want to access a true shell
1971 IPython for variable expansion. If you want to access a true shell
1971 variable, an extra $ is necessary to prevent its expansion by IPython:
1972 variable, an extra $ is necessary to prevent its expansion by IPython:
1972
1973
1973 In [6]: alias show echo\\
1974 In [6]: alias show echo\\
1974 In [7]: PATH='A Python string'\\
1975 In [7]: PATH='A Python string'\\
1975 In [8]: show $PATH\\
1976 In [8]: show $PATH\\
1976 A Python string\\
1977 A Python string\\
1977 In [9]: show $$PATH\\
1978 In [9]: show $$PATH\\
1978 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1979 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1979
1980
1980 You can use the alias facility to acess all of $PATH. See the %rehash
1981 You can use the alias facility to acess all of $PATH. See the %rehash
1981 and %rehashx functions, which automatically create aliases for the
1982 and %rehashx functions, which automatically create aliases for the
1982 contents of your $PATH.
1983 contents of your $PATH.
1983
1984
1984 If called with no parameters, %alias prints the current alias table."""
1985 If called with no parameters, %alias prints the current alias table."""
1985
1986
1986 par = parameter_s.strip()
1987 par = parameter_s.strip()
1987 if not par:
1988 if not par:
1988 if self.shell.rc.automagic:
1989 if self.shell.rc.automagic:
1989 prechar = ''
1990 prechar = ''
1990 else:
1991 else:
1991 prechar = self.shell.ESC_MAGIC
1992 prechar = self.shell.ESC_MAGIC
1992 print 'Alias\t\tSystem Command\n'+'-'*30
1993 print 'Alias\t\tSystem Command\n'+'-'*30
1993 atab = self.shell.alias_table
1994 atab = self.shell.alias_table
1994 aliases = atab.keys()
1995 aliases = atab.keys()
1995 aliases.sort()
1996 aliases.sort()
1996 for alias in aliases:
1997 for alias in aliases:
1997 print prechar+alias+'\t\t'+atab[alias][1]
1998 print prechar+alias+'\t\t'+atab[alias][1]
1998 print '-'*30+'\nTotal number of aliases:',len(aliases)
1999 print '-'*30+'\nTotal number of aliases:',len(aliases)
1999 return
2000 return
2000 try:
2001 try:
2001 alias,cmd = par.split(None,1)
2002 alias,cmd = par.split(None,1)
2002 except:
2003 except:
2003 print OInspect.getdoc(self.magic_alias)
2004 print OInspect.getdoc(self.magic_alias)
2004 else:
2005 else:
2005 nargs = cmd.count('%s')
2006 nargs = cmd.count('%s')
2006 if nargs>0 and cmd.find('%l')>=0:
2007 if nargs>0 and cmd.find('%l')>=0:
2007 error('The %s and %l specifiers are mutually exclusive '
2008 error('The %s and %l specifiers are mutually exclusive '
2008 'in alias definitions.')
2009 'in alias definitions.')
2009 else: # all looks OK
2010 else: # all looks OK
2010 self.shell.alias_table[alias] = (nargs,cmd)
2011 self.shell.alias_table[alias] = (nargs,cmd)
2011 self.shell.alias_table_validate(verbose=1)
2012 self.shell.alias_table_validate(verbose=1)
2012 # end magic_alias
2013 # end magic_alias
2013
2014
2014 def magic_unalias(self, parameter_s = ''):
2015 def magic_unalias(self, parameter_s = ''):
2015 """Remove an alias"""
2016 """Remove an alias"""
2016
2017
2017 aname = parameter_s.strip()
2018 aname = parameter_s.strip()
2018 if aname in self.shell.alias_table:
2019 if aname in self.shell.alias_table:
2019 del self.shell.alias_table[aname]
2020 del self.shell.alias_table[aname]
2020
2021
2021 def magic_rehash(self, parameter_s = ''):
2022 def magic_rehash(self, parameter_s = ''):
2022 """Update the alias table with all entries in $PATH.
2023 """Update the alias table with all entries in $PATH.
2023
2024
2024 This version does no checks on execute permissions or whether the
2025 This version does no checks on execute permissions or whether the
2025 contents of $PATH are truly files (instead of directories or something
2026 contents of $PATH are truly files (instead of directories or something
2026 else). For such a safer (but slower) version, use %rehashx."""
2027 else). For such a safer (but slower) version, use %rehashx."""
2027
2028
2028 # This function (and rehashx) manipulate the alias_table directly
2029 # This function (and rehashx) manipulate the alias_table directly
2029 # rather than calling magic_alias, for speed reasons. A rehash on a
2030 # rather than calling magic_alias, for speed reasons. A rehash on a
2030 # typical Linux box involves several thousand entries, so efficiency
2031 # typical Linux box involves several thousand entries, so efficiency
2031 # here is a top concern.
2032 # here is a top concern.
2032
2033
2033 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2034 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2034 alias_table = self.shell.alias_table
2035 alias_table = self.shell.alias_table
2035 for pdir in path:
2036 for pdir in path:
2036 for ff in os.listdir(pdir):
2037 for ff in os.listdir(pdir):
2037 # each entry in the alias table must be (N,name), where
2038 # each entry in the alias table must be (N,name), where
2038 # N is the number of positional arguments of the alias.
2039 # N is the number of positional arguments of the alias.
2039 alias_table[ff] = (0,ff)
2040 alias_table[ff] = (0,ff)
2040 # Make sure the alias table doesn't contain keywords or builtins
2041 # Make sure the alias table doesn't contain keywords or builtins
2041 self.shell.alias_table_validate()
2042 self.shell.alias_table_validate()
2042 # Call again init_auto_alias() so we get 'rm -i' and other modified
2043 # Call again init_auto_alias() so we get 'rm -i' and other modified
2043 # aliases since %rehash will probably clobber them
2044 # aliases since %rehash will probably clobber them
2044 self.shell.init_auto_alias()
2045 self.shell.init_auto_alias()
2045
2046
2046 def magic_rehashx(self, parameter_s = ''):
2047 def magic_rehashx(self, parameter_s = ''):
2047 """Update the alias table with all executable files in $PATH.
2048 """Update the alias table with all executable files in $PATH.
2048
2049
2049 This version explicitly checks that every entry in $PATH is a file
2050 This version explicitly checks that every entry in $PATH is a file
2050 with execute access (os.X_OK), so it is much slower than %rehash.
2051 with execute access (os.X_OK), so it is much slower than %rehash.
2051
2052
2052 Under Windows, it checks executability as a match agains a
2053 Under Windows, it checks executability as a match agains a
2053 '|'-separated string of extensions, stored in the IPython config
2054 '|'-separated string of extensions, stored in the IPython config
2054 variable win_exec_ext. This defaults to 'exe|com|bat'. """
2055 variable win_exec_ext. This defaults to 'exe|com|bat'. """
2055
2056
2056 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2057 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2057 alias_table = self.shell.alias_table
2058 alias_table = self.shell.alias_table
2058
2059
2059 if os.name == 'posix':
2060 if os.name == 'posix':
2060 isexec = lambda fname:os.path.isfile(fname) and \
2061 isexec = lambda fname:os.path.isfile(fname) and \
2061 os.access(fname,os.X_OK)
2062 os.access(fname,os.X_OK)
2062 else:
2063 else:
2063
2064
2064 try:
2065 try:
2065 winext = os.environ['pathext'].replace(';','|').replace('.','')
2066 winext = os.environ['pathext'].replace(';','|').replace('.','')
2066 except KeyError:
2067 except KeyError:
2067 winext = 'exe|com|bat'
2068 winext = 'exe|com|bat'
2068
2069
2069 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2070 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2070 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2071 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2071 savedir = os.getcwd()
2072 savedir = os.getcwd()
2072 try:
2073 try:
2073 # write the whole loop for posix/Windows so we don't have an if in
2074 # write the whole loop for posix/Windows so we don't have an if in
2074 # the innermost part
2075 # the innermost part
2075 if os.name == 'posix':
2076 if os.name == 'posix':
2076 for pdir in path:
2077 for pdir in path:
2077 os.chdir(pdir)
2078 os.chdir(pdir)
2078 for ff in os.listdir(pdir):
2079 for ff in os.listdir(pdir):
2079 if isexec(ff):
2080 if isexec(ff):
2080 # each entry in the alias table must be (N,name),
2081 # each entry in the alias table must be (N,name),
2081 # where N is the number of positional arguments of the
2082 # where N is the number of positional arguments of the
2082 # alias.
2083 # alias.
2083 alias_table[ff] = (0,ff)
2084 alias_table[ff] = (0,ff)
2084 else:
2085 else:
2085 for pdir in path:
2086 for pdir in path:
2086 os.chdir(pdir)
2087 os.chdir(pdir)
2087 for ff in os.listdir(pdir):
2088 for ff in os.listdir(pdir):
2088 if isexec(ff):
2089 if isexec(ff):
2089 alias_table[execre.sub(r'\1',ff)] = (0,ff)
2090 alias_table[execre.sub(r'\1',ff)] = (0,ff)
2090 # Make sure the alias table doesn't contain keywords or builtins
2091 # Make sure the alias table doesn't contain keywords or builtins
2091 self.shell.alias_table_validate()
2092 self.shell.alias_table_validate()
2092 # Call again init_auto_alias() so we get 'rm -i' and other
2093 # Call again init_auto_alias() so we get 'rm -i' and other
2093 # modified aliases since %rehashx will probably clobber them
2094 # modified aliases since %rehashx will probably clobber them
2094 self.shell.init_auto_alias()
2095 self.shell.init_auto_alias()
2095 finally:
2096 finally:
2096 os.chdir(savedir)
2097 os.chdir(savedir)
2097
2098
2098 def magic_pwd(self, parameter_s = ''):
2099 def magic_pwd(self, parameter_s = ''):
2099 """Return the current working directory path."""
2100 """Return the current working directory path."""
2100 return os.getcwd()
2101 return os.getcwd()
2101
2102
2102 def magic_cd(self, parameter_s=''):
2103 def magic_cd(self, parameter_s=''):
2103 """Change the current working directory.
2104 """Change the current working directory.
2104
2105
2105 This command automatically maintains an internal list of directories
2106 This command automatically maintains an internal list of directories
2106 you visit during your IPython session, in the variable _dh. The
2107 you visit during your IPython session, in the variable _dh. The
2107 command %dhist shows this history nicely formatted.
2108 command %dhist shows this history nicely formatted.
2108
2109
2109 Usage:
2110 Usage:
2110
2111
2111 cd 'dir': changes to directory 'dir'.
2112 cd 'dir': changes to directory 'dir'.
2112
2113
2113 cd -: changes to the last visited directory.
2114 cd -: changes to the last visited directory.
2114
2115
2115 cd -<n>: changes to the n-th directory in the directory history.
2116 cd -<n>: changes to the n-th directory in the directory history.
2116
2117
2117 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2118 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2118 (note: cd <bookmark_name> is enough if there is no
2119 (note: cd <bookmark_name> is enough if there is no
2119 directory <bookmark_name>, but a bookmark with the name exists.)
2120 directory <bookmark_name>, but a bookmark with the name exists.)
2120
2121
2121 Options:
2122 Options:
2122
2123
2123 -q: quiet. Do not print the working directory after the cd command is
2124 -q: quiet. Do not print the working directory after the cd command is
2124 executed. By default IPython's cd command does print this directory,
2125 executed. By default IPython's cd command does print this directory,
2125 since the default prompts do not display path information.
2126 since the default prompts do not display path information.
2126
2127
2127 Note that !cd doesn't work for this purpose because the shell where
2128 Note that !cd doesn't work for this purpose because the shell where
2128 !command runs is immediately discarded after executing 'command'."""
2129 !command runs is immediately discarded after executing 'command'."""
2129
2130
2130 parameter_s = parameter_s.strip()
2131 parameter_s = parameter_s.strip()
2131 bkms = self.shell.persist.get("bookmarks",{})
2132 bkms = self.shell.persist.get("bookmarks",{})
2132
2133
2133 numcd = re.match(r'(-)(\d+)$',parameter_s)
2134 numcd = re.match(r'(-)(\d+)$',parameter_s)
2134 # jump in directory history by number
2135 # jump in directory history by number
2135 if numcd:
2136 if numcd:
2136 nn = int(numcd.group(2))
2137 nn = int(numcd.group(2))
2137 try:
2138 try:
2138 ps = self.shell.user_ns['_dh'][nn]
2139 ps = self.shell.user_ns['_dh'][nn]
2139 except IndexError:
2140 except IndexError:
2140 print 'The requested directory does not exist in history.'
2141 print 'The requested directory does not exist in history.'
2141 return
2142 return
2142 else:
2143 else:
2143 opts = {}
2144 opts = {}
2144 else:
2145 else:
2145 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2146 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2146 # jump to previous
2147 # jump to previous
2147 if ps == '-':
2148 if ps == '-':
2148 try:
2149 try:
2149 ps = self.shell.user_ns['_dh'][-2]
2150 ps = self.shell.user_ns['_dh'][-2]
2150 except IndexError:
2151 except IndexError:
2151 print 'No previous directory to change to.'
2152 print 'No previous directory to change to.'
2152 return
2153 return
2153 # jump to bookmark
2154 # jump to bookmark
2154 elif opts.has_key('b') or (bkms.has_key(ps) and not os.path.isdir(ps)):
2155 elif opts.has_key('b') or (bkms.has_key(ps) and not os.path.isdir(ps)):
2155 if bkms.has_key(ps):
2156 if bkms.has_key(ps):
2156 target = bkms[ps]
2157 target = bkms[ps]
2157 print '(bookmark:%s) -> %s' % (ps,target)
2158 print '(bookmark:%s) -> %s' % (ps,target)
2158 ps = target
2159 ps = target
2159 else:
2160 else:
2160 if bkms:
2161 if bkms:
2161 error("Bookmark '%s' not found. "
2162 error("Bookmark '%s' not found. "
2162 "Use '%bookmark -l' to see your bookmarks." % ps)
2163 "Use '%bookmark -l' to see your bookmarks." % ps)
2163 else:
2164 else:
2164 print "Bookmarks not set - use %bookmark <bookmarkname>"
2165 print "Bookmarks not set - use %bookmark <bookmarkname>"
2165 return
2166 return
2166
2167
2167 # at this point ps should point to the target dir
2168 # at this point ps should point to the target dir
2168 if ps:
2169 if ps:
2169 try:
2170 try:
2170 os.chdir(os.path.expanduser(ps))
2171 os.chdir(os.path.expanduser(ps))
2171 except OSError:
2172 except OSError:
2172 print sys.exc_info()[1]
2173 print sys.exc_info()[1]
2173 else:
2174 else:
2174 self.shell.user_ns['_dh'].append(os.getcwd())
2175 self.shell.user_ns['_dh'].append(os.getcwd())
2175 else:
2176 else:
2176 os.chdir(self.home_dir)
2177 os.chdir(self.home_dir)
2177 self.shell.user_ns['_dh'].append(os.getcwd())
2178 self.shell.user_ns['_dh'].append(os.getcwd())
2178 if not 'q' in opts:
2179 if not 'q' in opts:
2179 print self.shell.user_ns['_dh'][-1]
2180 print self.shell.user_ns['_dh'][-1]
2180
2181
2181 def magic_dhist(self, parameter_s=''):
2182 def magic_dhist(self, parameter_s=''):
2182 """Print your history of visited directories.
2183 """Print your history of visited directories.
2183
2184
2184 %dhist -> print full history\\
2185 %dhist -> print full history\\
2185 %dhist n -> print last n entries only\\
2186 %dhist n -> print last n entries only\\
2186 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2187 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2187
2188
2188 This history is automatically maintained by the %cd command, and
2189 This history is automatically maintained by the %cd command, and
2189 always available as the global list variable _dh. You can use %cd -<n>
2190 always available as the global list variable _dh. You can use %cd -<n>
2190 to go to directory number <n>."""
2191 to go to directory number <n>."""
2191
2192
2192 dh = self.shell.user_ns['_dh']
2193 dh = self.shell.user_ns['_dh']
2193 if parameter_s:
2194 if parameter_s:
2194 try:
2195 try:
2195 args = map(int,parameter_s.split())
2196 args = map(int,parameter_s.split())
2196 except:
2197 except:
2197 self.arg_err(Magic.magic_dhist)
2198 self.arg_err(Magic.magic_dhist)
2198 return
2199 return
2199 if len(args) == 1:
2200 if len(args) == 1:
2200 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2201 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2201 elif len(args) == 2:
2202 elif len(args) == 2:
2202 ini,fin = args
2203 ini,fin = args
2203 else:
2204 else:
2204 self.arg_err(Magic.magic_dhist)
2205 self.arg_err(Magic.magic_dhist)
2205 return
2206 return
2206 else:
2207 else:
2207 ini,fin = 0,len(dh)
2208 ini,fin = 0,len(dh)
2208 nlprint(dh,
2209 nlprint(dh,
2209 header = 'Directory history (kept in _dh)',
2210 header = 'Directory history (kept in _dh)',
2210 start=ini,stop=fin)
2211 start=ini,stop=fin)
2211
2212
2212 def magic_env(self, parameter_s=''):
2213 def magic_env(self, parameter_s=''):
2213 """List environment variables."""
2214 """List environment variables."""
2214
2215
2215 # environ is an instance of UserDict
2216 # environ is an instance of UserDict
2216 return os.environ.data
2217 return os.environ.data
2217
2218
2218 def magic_pushd(self, parameter_s=''):
2219 def magic_pushd(self, parameter_s=''):
2219 """Place the current dir on stack and change directory.
2220 """Place the current dir on stack and change directory.
2220
2221
2221 Usage:\\
2222 Usage:\\
2222 %pushd ['dirname']
2223 %pushd ['dirname']
2223
2224
2224 %pushd with no arguments does a %pushd to your home directory.
2225 %pushd with no arguments does a %pushd to your home directory.
2225 """
2226 """
2226 if parameter_s == '': parameter_s = '~'
2227 if parameter_s == '': parameter_s = '~'
2227 if len(self.dir_stack)>0 and os.path.expanduser(parameter_s) != \
2228 if len(self.dir_stack)>0 and os.path.expanduser(parameter_s) != \
2228 os.path.expanduser(self.dir_stack[0]):
2229 os.path.expanduser(self.dir_stack[0]):
2229 try:
2230 try:
2230 self.magic_cd(parameter_s)
2231 self.magic_cd(parameter_s)
2231 self.dir_stack.insert(0,os.getcwd().replace(self.home_dir,'~'))
2232 self.dir_stack.insert(0,os.getcwd().replace(self.home_dir,'~'))
2232 self.magic_dirs()
2233 self.magic_dirs()
2233 except:
2234 except:
2234 print 'Invalid directory'
2235 print 'Invalid directory'
2235 else:
2236 else:
2236 print 'You are already there!'
2237 print 'You are already there!'
2237
2238
2238 def magic_popd(self, parameter_s=''):
2239 def magic_popd(self, parameter_s=''):
2239 """Change to directory popped off the top of the stack.
2240 """Change to directory popped off the top of the stack.
2240 """
2241 """
2241 if len (self.dir_stack) > 1:
2242 if len (self.dir_stack) > 1:
2242 self.dir_stack.pop(0)
2243 self.dir_stack.pop(0)
2243 self.magic_cd(self.dir_stack[0])
2244 self.magic_cd(self.dir_stack[0])
2244 print self.dir_stack[0]
2245 print self.dir_stack[0]
2245 else:
2246 else:
2246 print "You can't remove the starting directory from the stack:",\
2247 print "You can't remove the starting directory from the stack:",\
2247 self.dir_stack
2248 self.dir_stack
2248
2249
2249 def magic_dirs(self, parameter_s=''):
2250 def magic_dirs(self, parameter_s=''):
2250 """Return the current directory stack."""
2251 """Return the current directory stack."""
2251
2252
2252 return self.dir_stack[:]
2253 return self.dir_stack[:]
2253
2254
2254 def magic_sc(self, parameter_s=''):
2255 def magic_sc(self, parameter_s=''):
2255 """Shell capture - execute a shell command and capture its output.
2256 """Shell capture - execute a shell command and capture its output.
2256
2257
2257 %sc [options] varname=command
2258 %sc [options] varname=command
2258
2259
2259 IPython will run the given command using commands.getoutput(), and
2260 IPython will run the given command using commands.getoutput(), and
2260 will then update the user's interactive namespace with a variable
2261 will then update the user's interactive namespace with a variable
2261 called varname, containing the value of the call. Your command can
2262 called varname, containing the value of the call. Your command can
2262 contain shell wildcards, pipes, etc.
2263 contain shell wildcards, pipes, etc.
2263
2264
2264 The '=' sign in the syntax is mandatory, and the variable name you
2265 The '=' sign in the syntax is mandatory, and the variable name you
2265 supply must follow Python's standard conventions for valid names.
2266 supply must follow Python's standard conventions for valid names.
2266
2267
2267 Options:
2268 Options:
2268
2269
2269 -l: list output. Split the output on newlines into a list before
2270 -l: list output. Split the output on newlines into a list before
2270 assigning it to the given variable. By default the output is stored
2271 assigning it to the given variable. By default the output is stored
2271 as a single string.
2272 as a single string.
2272
2273
2273 -v: verbose. Print the contents of the variable.
2274 -v: verbose. Print the contents of the variable.
2274
2275
2275 In most cases you should not need to split as a list, because the
2276 In most cases you should not need to split as a list, because the
2276 returned value is a special type of string which can automatically
2277 returned value is a special type of string which can automatically
2277 provide its contents either as a list (split on newlines) or as a
2278 provide its contents either as a list (split on newlines) or as a
2278 space-separated string. These are convenient, respectively, either
2279 space-separated string. These are convenient, respectively, either
2279 for sequential processing or to be passed to a shell command.
2280 for sequential processing or to be passed to a shell command.
2280
2281
2281 For example:
2282 For example:
2282
2283
2283 # Capture into variable a
2284 # Capture into variable a
2284 In [9]: sc a=ls *py
2285 In [9]: sc a=ls *py
2285
2286
2286 # a is a string with embedded newlines
2287 # a is a string with embedded newlines
2287 In [10]: a
2288 In [10]: a
2288 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2289 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2289
2290
2290 # which can be seen as a list:
2291 # which can be seen as a list:
2291 In [11]: a.l
2292 In [11]: a.l
2292 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2293 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2293
2294
2294 # or as a whitespace-separated string:
2295 # or as a whitespace-separated string:
2295 In [12]: a.s
2296 In [12]: a.s
2296 Out[12]: 'setup.py win32_manual_post_install.py'
2297 Out[12]: 'setup.py win32_manual_post_install.py'
2297
2298
2298 # a.s is useful to pass as a single command line:
2299 # a.s is useful to pass as a single command line:
2299 In [13]: !wc -l $a.s
2300 In [13]: !wc -l $a.s
2300 146 setup.py
2301 146 setup.py
2301 130 win32_manual_post_install.py
2302 130 win32_manual_post_install.py
2302 276 total
2303 276 total
2303
2304
2304 # while the list form is useful to loop over:
2305 # while the list form is useful to loop over:
2305 In [14]: for f in a.l:
2306 In [14]: for f in a.l:
2306 ....: !wc -l $f
2307 ....: !wc -l $f
2307 ....:
2308 ....:
2308 146 setup.py
2309 146 setup.py
2309 130 win32_manual_post_install.py
2310 130 win32_manual_post_install.py
2310
2311
2311 Similiarly, the lists returned by the -l option are also special, in
2312 Similiarly, the lists returned by the -l option are also special, in
2312 the sense that you can equally invoke the .s attribute on them to
2313 the sense that you can equally invoke the .s attribute on them to
2313 automatically get a whitespace-separated string from their contents:
2314 automatically get a whitespace-separated string from their contents:
2314
2315
2315 In [1]: sc -l b=ls *py
2316 In [1]: sc -l b=ls *py
2316
2317
2317 In [2]: b
2318 In [2]: b
2318 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2319 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2319
2320
2320 In [3]: b.s
2321 In [3]: b.s
2321 Out[3]: 'setup.py win32_manual_post_install.py'
2322 Out[3]: 'setup.py win32_manual_post_install.py'
2322
2323
2323 In summary, both the lists and strings used for ouptut capture have
2324 In summary, both the lists and strings used for ouptut capture have
2324 the following special attributes:
2325 the following special attributes:
2325
2326
2326 .l (or .list) : value as list.
2327 .l (or .list) : value as list.
2327 .n (or .nlstr): value as newline-separated string.
2328 .n (or .nlstr): value as newline-separated string.
2328 .s (or .spstr): value as space-separated string.
2329 .s (or .spstr): value as space-separated string.
2329 """
2330 """
2330
2331
2331 opts,args = self.parse_options(parameter_s,'lv')
2332 opts,args = self.parse_options(parameter_s,'lv')
2332 # Try to get a variable name and command to run
2333 # Try to get a variable name and command to run
2333 try:
2334 try:
2334 # the variable name must be obtained from the parse_options
2335 # the variable name must be obtained from the parse_options
2335 # output, which uses shlex.split to strip options out.
2336 # output, which uses shlex.split to strip options out.
2336 var,_ = args.split('=',1)
2337 var,_ = args.split('=',1)
2337 var = var.strip()
2338 var = var.strip()
2338 # But the the command has to be extracted from the original input
2339 # But the the command has to be extracted from the original input
2339 # parameter_s, not on what parse_options returns, to avoid the
2340 # parameter_s, not on what parse_options returns, to avoid the
2340 # quote stripping which shlex.split performs on it.
2341 # quote stripping which shlex.split performs on it.
2341 _,cmd = parameter_s.split('=',1)
2342 _,cmd = parameter_s.split('=',1)
2342 except ValueError:
2343 except ValueError:
2343 var,cmd = '',''
2344 var,cmd = '',''
2344 if not var:
2345 if not var:
2345 error('you must specify a variable to assign the command to.')
2346 error('you must specify a variable to assign the command to.')
2346 return
2347 return
2347 # If all looks ok, proceed
2348 # If all looks ok, proceed
2348 out,err = self.shell.getoutputerror(cmd)
2349 out,err = self.shell.getoutputerror(cmd)
2349 if err:
2350 if err:
2350 print >> Term.cerr,err
2351 print >> Term.cerr,err
2351 if opts.has_key('l'):
2352 if opts.has_key('l'):
2352 out = SList(out.split('\n'))
2353 out = SList(out.split('\n'))
2353 else:
2354 else:
2354 out = LSString(out)
2355 out = LSString(out)
2355 if opts.has_key('v'):
2356 if opts.has_key('v'):
2356 print '%s ==\n%s' % (var,pformat(out))
2357 print '%s ==\n%s' % (var,pformat(out))
2357 self.shell.user_ns.update({var:out})
2358 self.shell.user_ns.update({var:out})
2358
2359
2359 def magic_sx(self, parameter_s=''):
2360 def magic_sx(self, parameter_s=''):
2360 """Shell execute - run a shell command and capture its output.
2361 """Shell execute - run a shell command and capture its output.
2361
2362
2362 %sx command
2363 %sx command
2363
2364
2364 IPython will run the given command using commands.getoutput(), and
2365 IPython will run the given command using commands.getoutput(), and
2365 return the result formatted as a list (split on '\\n'). Since the
2366 return the result formatted as a list (split on '\\n'). Since the
2366 output is _returned_, it will be stored in ipython's regular output
2367 output is _returned_, it will be stored in ipython's regular output
2367 cache Out[N] and in the '_N' automatic variables.
2368 cache Out[N] and in the '_N' automatic variables.
2368
2369
2369 Notes:
2370 Notes:
2370
2371
2371 1) If an input line begins with '!!', then %sx is automatically
2372 1) If an input line begins with '!!', then %sx is automatically
2372 invoked. That is, while:
2373 invoked. That is, while:
2373 !ls
2374 !ls
2374 causes ipython to simply issue system('ls'), typing
2375 causes ipython to simply issue system('ls'), typing
2375 !!ls
2376 !!ls
2376 is a shorthand equivalent to:
2377 is a shorthand equivalent to:
2377 %sx ls
2378 %sx ls
2378
2379
2379 2) %sx differs from %sc in that %sx automatically splits into a list,
2380 2) %sx differs from %sc in that %sx automatically splits into a list,
2380 like '%sc -l'. The reason for this is to make it as easy as possible
2381 like '%sc -l'. The reason for this is to make it as easy as possible
2381 to process line-oriented shell output via further python commands.
2382 to process line-oriented shell output via further python commands.
2382 %sc is meant to provide much finer control, but requires more
2383 %sc is meant to provide much finer control, but requires more
2383 typing.
2384 typing.
2384
2385
2385 3) Just like %sc -l, this is a list with special attributes:
2386 3) Just like %sc -l, this is a list with special attributes:
2386
2387
2387 .l (or .list) : value as list.
2388 .l (or .list) : value as list.
2388 .n (or .nlstr): value as newline-separated string.
2389 .n (or .nlstr): value as newline-separated string.
2389 .s (or .spstr): value as whitespace-separated string.
2390 .s (or .spstr): value as whitespace-separated string.
2390
2391
2391 This is very useful when trying to use such lists as arguments to
2392 This is very useful when trying to use such lists as arguments to
2392 system commands."""
2393 system commands."""
2393
2394
2394 if parameter_s:
2395 if parameter_s:
2395 out,err = self.shell.getoutputerror(parameter_s)
2396 out,err = self.shell.getoutputerror(parameter_s)
2396 if err:
2397 if err:
2397 print >> Term.cerr,err
2398 print >> Term.cerr,err
2398 return SList(out.split('\n'))
2399 return SList(out.split('\n'))
2399
2400
2400 def magic_bg(self, parameter_s=''):
2401 def magic_bg(self, parameter_s=''):
2401 """Run a job in the background, in a separate thread.
2402 """Run a job in the background, in a separate thread.
2402
2403
2403 For example,
2404 For example,
2404
2405
2405 %bg myfunc(x,y,z=1)
2406 %bg myfunc(x,y,z=1)
2406
2407
2407 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2408 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2408 execution starts, a message will be printed indicating the job
2409 execution starts, a message will be printed indicating the job
2409 number. If your job number is 5, you can use
2410 number. If your job number is 5, you can use
2410
2411
2411 myvar = jobs.result(5) or myvar = jobs[5].result
2412 myvar = jobs.result(5) or myvar = jobs[5].result
2412
2413
2413 to assign this result to variable 'myvar'.
2414 to assign this result to variable 'myvar'.
2414
2415
2415 IPython has a job manager, accessible via the 'jobs' object. You can
2416 IPython has a job manager, accessible via the 'jobs' object. You can
2416 type jobs? to get more information about it, and use jobs.<TAB> to see
2417 type jobs? to get more information about it, and use jobs.<TAB> to see
2417 its attributes. All attributes not starting with an underscore are
2418 its attributes. All attributes not starting with an underscore are
2418 meant for public use.
2419 meant for public use.
2419
2420
2420 In particular, look at the jobs.new() method, which is used to create
2421 In particular, look at the jobs.new() method, which is used to create
2421 new jobs. This magic %bg function is just a convenience wrapper
2422 new jobs. This magic %bg function is just a convenience wrapper
2422 around jobs.new(), for expression-based jobs. If you want to create a
2423 around jobs.new(), for expression-based jobs. If you want to create a
2423 new job with an explicit function object and arguments, you must call
2424 new job with an explicit function object and arguments, you must call
2424 jobs.new() directly.
2425 jobs.new() directly.
2425
2426
2426 The jobs.new docstring also describes in detail several important
2427 The jobs.new docstring also describes in detail several important
2427 caveats associated with a thread-based model for background job
2428 caveats associated with a thread-based model for background job
2428 execution. Type jobs.new? for details.
2429 execution. Type jobs.new? for details.
2429
2430
2430 You can check the status of all jobs with jobs.status().
2431 You can check the status of all jobs with jobs.status().
2431
2432
2432 The jobs variable is set by IPython into the Python builtin namespace.
2433 The jobs variable is set by IPython into the Python builtin namespace.
2433 If you ever declare a variable named 'jobs', you will shadow this
2434 If you ever declare a variable named 'jobs', you will shadow this
2434 name. You can either delete your global jobs variable to regain
2435 name. You can either delete your global jobs variable to regain
2435 access to the job manager, or make a new name and assign it manually
2436 access to the job manager, or make a new name and assign it manually
2436 to the manager (stored in IPython's namespace). For example, to
2437 to the manager (stored in IPython's namespace). For example, to
2437 assign the job manager to the Jobs name, use:
2438 assign the job manager to the Jobs name, use:
2438
2439
2439 Jobs = __builtins__.jobs"""
2440 Jobs = __builtins__.jobs"""
2440
2441
2441 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2442 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2442
2443
2443 def magic_bookmark(self, parameter_s=''):
2444 def magic_bookmark(self, parameter_s=''):
2444 """Manage IPython's bookmark system.
2445 """Manage IPython's bookmark system.
2445
2446
2446 %bookmark <name> - set bookmark to current dir
2447 %bookmark <name> - set bookmark to current dir
2447 %bookmark <name> <dir> - set bookmark to <dir>
2448 %bookmark <name> <dir> - set bookmark to <dir>
2448 %bookmark -l - list all bookmarks
2449 %bookmark -l - list all bookmarks
2449 %bookmark -d <name> - remove bookmark
2450 %bookmark -d <name> - remove bookmark
2450 %bookmark -r - remove all bookmarks
2451 %bookmark -r - remove all bookmarks
2451
2452
2452 You can later on access a bookmarked folder with:
2453 You can later on access a bookmarked folder with:
2453 %cd -b <name>
2454 %cd -b <name>
2454 or simply '%cd <name>' if there is no directory called <name> AND
2455 or simply '%cd <name>' if there is no directory called <name> AND
2455 there is such a bookmark defined.
2456 there is such a bookmark defined.
2456
2457
2457 Your bookmarks persist through IPython sessions, but they are
2458 Your bookmarks persist through IPython sessions, but they are
2458 associated with each profile."""
2459 associated with each profile."""
2459
2460
2460 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2461 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2461 if len(args) > 2:
2462 if len(args) > 2:
2462 error('You can only give at most two arguments')
2463 error('You can only give at most two arguments')
2463 return
2464 return
2464
2465
2465 bkms = self.shell.persist.get('bookmarks',{})
2466 bkms = self.shell.persist.get('bookmarks',{})
2466
2467
2467 if opts.has_key('d'):
2468 if opts.has_key('d'):
2468 try:
2469 try:
2469 todel = args[0]
2470 todel = args[0]
2470 except IndexError:
2471 except IndexError:
2471 error('You must provide a bookmark to delete')
2472 error('You must provide a bookmark to delete')
2472 else:
2473 else:
2473 try:
2474 try:
2474 del bkms[todel]
2475 del bkms[todel]
2475 except:
2476 except:
2476 error("Can't delete bookmark '%s'" % todel)
2477 error("Can't delete bookmark '%s'" % todel)
2477 elif opts.has_key('r'):
2478 elif opts.has_key('r'):
2478 bkms = {}
2479 bkms = {}
2479 elif opts.has_key('l'):
2480 elif opts.has_key('l'):
2480 bks = bkms.keys()
2481 bks = bkms.keys()
2481 bks.sort()
2482 bks.sort()
2482 if bks:
2483 if bks:
2483 size = max(map(len,bks))
2484 size = max(map(len,bks))
2484 else:
2485 else:
2485 size = 0
2486 size = 0
2486 fmt = '%-'+str(size)+'s -> %s'
2487 fmt = '%-'+str(size)+'s -> %s'
2487 print 'Current bookmarks:'
2488 print 'Current bookmarks:'
2488 for bk in bks:
2489 for bk in bks:
2489 print fmt % (bk,bkms[bk])
2490 print fmt % (bk,bkms[bk])
2490 else:
2491 else:
2491 if not args:
2492 if not args:
2492 error("You must specify the bookmark name")
2493 error("You must specify the bookmark name")
2493 elif len(args)==1:
2494 elif len(args)==1:
2494 bkms[args[0]] = os.getcwd()
2495 bkms[args[0]] = os.getcwd()
2495 elif len(args)==2:
2496 elif len(args)==2:
2496 bkms[args[0]] = args[1]
2497 bkms[args[0]] = args[1]
2497 self.persist['bookmarks'] = bkms
2498 self.persist['bookmarks'] = bkms
2498
2499
2499 def magic_pycat(self, parameter_s=''):
2500 def magic_pycat(self, parameter_s=''):
2500 """Show a syntax-highlighted file through a pager.
2501 """Show a syntax-highlighted file through a pager.
2501
2502
2502 This magic is similar to the cat utility, but it will assume the file
2503 This magic is similar to the cat utility, but it will assume the file
2503 to be Python source and will show it with syntax highlighting. """
2504 to be Python source and will show it with syntax highlighting. """
2504
2505
2505 filename = get_py_filename(parameter_s)
2506 filename = get_py_filename(parameter_s)
2506 page(self.shell.colorize(file_read(filename)),
2507 page(self.shell.colorize(file_read(filename)),
2507 screen_lines=self.shell.rc.screen_length)
2508 screen_lines=self.shell.rc.screen_length)
2508
2509
2509 # end Magic
2510 # end Magic
@@ -1,442 +1,442 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """Tools for inspecting Python objects.
2 """Tools for inspecting Python objects.
3
3
4 Uses syntax highlighting for presenting the various information elements.
4 Uses syntax highlighting for presenting the various information elements.
5
5
6 Similar in spirit to the inspect module, but all calls take a name argument to
6 Similar in spirit to the inspect module, but all calls take a name argument to
7 reference the name under which an object is being read.
7 reference the name under which an object is being read.
8
8
9 $Id: OInspect.py 919 2005-10-15 07:57:05Z fperez $
9 $Id: OInspect.py 922 2005-11-13 10:21:08Z fperez $
10 """
10 """
11
11
12 #*****************************************************************************
12 #*****************************************************************************
13 # Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu>
13 # Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu>
14 #
14 #
15 # Distributed under the terms of the BSD License. The full license is in
15 # Distributed under the terms of the BSD License. The full license is in
16 # the file COPYING, distributed as part of this software.
16 # the file COPYING, distributed as part of this software.
17 #*****************************************************************************
17 #*****************************************************************************
18
18
19 from IPython import Release
19 from IPython import Release
20 __author__ = '%s <%s>' % Release.authors['Fernando']
20 __author__ = '%s <%s>' % Release.authors['Fernando']
21 __license__ = Release.license
21 __license__ = Release.license
22
22
23 __all__ = ['Inspector','InspectColors']
23 __all__ = ['Inspector','InspectColors']
24
24
25 # stdlib modules
25 # stdlib modules
26 import inspect,linecache,types,StringIO,string
26 import inspect,linecache,types,StringIO,string
27
27
28 # IPython's own
28 # IPython's own
29 from IPython import PyColorize
29 from IPython import PyColorize
30 from IPython.Itpl import itpl
30 from IPython.Itpl import itpl
31 from IPython.wildcard import choose_namespaces,list_namespace
31 from IPython.wildcard import choose_namespaces,list_namespace
32 from IPython.genutils import page,indent,Term
32 from IPython.genutils import page,indent,Term
33 from IPython.ColorANSI import *
33 from IPython.ColorANSI import *
34
34
35 #****************************************************************************
35 #****************************************************************************
36 # Builtin color schemes
36 # Builtin color schemes
37
37
38 Colors = TermColors # just a shorthand
38 Colors = TermColors # just a shorthand
39
39
40 # Build a few color schemes
40 # Build a few color schemes
41 NoColor = ColorScheme(
41 NoColor = ColorScheme(
42 'NoColor',{
42 'NoColor',{
43 'header' : Colors.NoColor,
43 'header' : Colors.NoColor,
44 'normal' : Colors.NoColor # color off (usu. Colors.Normal)
44 'normal' : Colors.NoColor # color off (usu. Colors.Normal)
45 } )
45 } )
46
46
47 LinuxColors = ColorScheme(
47 LinuxColors = ColorScheme(
48 'Linux',{
48 'Linux',{
49 'header' : Colors.LightRed,
49 'header' : Colors.LightRed,
50 'normal' : Colors.Normal # color off (usu. Colors.Normal)
50 'normal' : Colors.Normal # color off (usu. Colors.Normal)
51 } )
51 } )
52
52
53 LightBGColors = ColorScheme(
53 LightBGColors = ColorScheme(
54 'LightBG',{
54 'LightBG',{
55 'header' : Colors.Red,
55 'header' : Colors.Red,
56 'normal' : Colors.Normal # color off (usu. Colors.Normal)
56 'normal' : Colors.Normal # color off (usu. Colors.Normal)
57 } )
57 } )
58
58
59 # Build table of color schemes (needed by the parser)
59 # Build table of color schemes (needed by the parser)
60 InspectColors = ColorSchemeTable([NoColor,LinuxColors,LightBGColors],
60 InspectColors = ColorSchemeTable([NoColor,LinuxColors,LightBGColors],
61 'Linux')
61 'Linux')
62
62
63 #****************************************************************************
63 #****************************************************************************
64 # Auxiliary functions
64 # Auxiliary functions
65 def getdoc(obj):
65 def getdoc(obj):
66 """Stable wrapper around inspect.getdoc.
66 """Stable wrapper around inspect.getdoc.
67
67
68 This can't crash because of attribute problems.
68 This can't crash because of attribute problems.
69
69
70 It also attempts to call a getdoc() method on the given object. This
70 It also attempts to call a getdoc() method on the given object. This
71 allows objects which provide their docstrings via non-standard mechanisms
71 allows objects which provide their docstrings via non-standard mechanisms
72 (like Pyro proxies) to still be inspected by ipython's ? system."""
72 (like Pyro proxies) to still be inspected by ipython's ? system."""
73
73
74 ds = None # default return value
74 ds = None # default return value
75 try:
75 try:
76 ds = inspect.getdoc(obj)
76 ds = inspect.getdoc(obj)
77 except:
77 except:
78 # Harden against an inspect failure, which can occur with
78 # Harden against an inspect failure, which can occur with
79 # SWIG-wrapped extensions.
79 # SWIG-wrapped extensions.
80 pass
80 pass
81 # Allow objects to offer customized documentation via a getdoc method:
81 # Allow objects to offer customized documentation via a getdoc method:
82 try:
82 try:
83 ds2 = obj.getdoc()
83 ds2 = obj.getdoc()
84 except:
84 except:
85 pass
85 pass
86 else:
86 else:
87 # if we get extra info, we add it to the normal docstring.
87 # if we get extra info, we add it to the normal docstring.
88 if ds is None:
88 if ds is None:
89 ds = ds2
89 ds = ds2
90 else:
90 else:
91 ds = '%s\n%s' % (ds,ds2)
91 ds = '%s\n%s' % (ds,ds2)
92 return ds
92 return ds
93
93
94 #****************************************************************************
94 #****************************************************************************
95 # Class definitions
95 # Class definitions
96
96
97 class myStringIO(StringIO.StringIO):
97 class myStringIO(StringIO.StringIO):
98 """Adds a writeln method to normal StringIO."""
98 """Adds a writeln method to normal StringIO."""
99 def writeln(self,*arg,**kw):
99 def writeln(self,*arg,**kw):
100 """Does a write() and then a write('\n')"""
100 """Does a write() and then a write('\n')"""
101 self.write(*arg,**kw)
101 self.write(*arg,**kw)
102 self.write('\n')
102 self.write('\n')
103
103
104 class Inspector:
104 class Inspector:
105 def __init__(self,color_table,code_color_table,scheme):
105 def __init__(self,color_table,code_color_table,scheme):
106 self.color_table = color_table
106 self.color_table = color_table
107 self.parser = PyColorize.Parser(code_color_table,out='str')
107 self.parser = PyColorize.Parser(code_color_table,out='str')
108 self.format = self.parser.format
108 self.format = self.parser.format
109 self.set_active_scheme(scheme)
109 self.set_active_scheme(scheme)
110
110
111 def __getargspec(self,obj):
111 def __getargspec(self,obj):
112 """Get the names and default values of a function's arguments.
112 """Get the names and default values of a function's arguments.
113
113
114 A tuple of four things is returned: (args, varargs, varkw, defaults).
114 A tuple of four things is returned: (args, varargs, varkw, defaults).
115 'args' is a list of the argument names (it may contain nested lists).
115 'args' is a list of the argument names (it may contain nested lists).
116 'varargs' and 'varkw' are the names of the * and ** arguments or None.
116 'varargs' and 'varkw' are the names of the * and ** arguments or None.
117 'defaults' is an n-tuple of the default values of the last n arguments.
117 'defaults' is an n-tuple of the default values of the last n arguments.
118
118
119 Modified version of inspect.getargspec from the Python Standard
119 Modified version of inspect.getargspec from the Python Standard
120 Library."""
120 Library."""
121
121
122 if inspect.isfunction(obj):
122 if inspect.isfunction(obj):
123 func_obj = obj
123 func_obj = obj
124 elif inspect.ismethod(obj):
124 elif inspect.ismethod(obj):
125 func_obj = obj.im_func
125 func_obj = obj.im_func
126 else:
126 else:
127 raise TypeError, 'arg is not a Python function'
127 raise TypeError, 'arg is not a Python function'
128 args, varargs, varkw = inspect.getargs(func_obj.func_code)
128 args, varargs, varkw = inspect.getargs(func_obj.func_code)
129 return args, varargs, varkw, func_obj.func_defaults
129 return args, varargs, varkw, func_obj.func_defaults
130
130
131 def __getdef(self,obj,oname=''):
131 def __getdef(self,obj,oname=''):
132 """Return the definition header for any callable object.
132 """Return the definition header for any callable object.
133
133
134 If any exception is generated, None is returned instead and the
134 If any exception is generated, None is returned instead and the
135 exception is suppressed."""
135 exception is suppressed."""
136
136
137 try:
137 try:
138 return oname + inspect.formatargspec(*self.__getargspec(obj))
138 return oname + inspect.formatargspec(*self.__getargspec(obj))
139 except:
139 except:
140 return None
140 return None
141
141
142 def __head(self,h):
142 def __head(self,h):
143 """Return a header string with proper colors."""
143 """Return a header string with proper colors."""
144 return '%s%s%s' % (self.color_table.active_colors.header,h,
144 return '%s%s%s' % (self.color_table.active_colors.header,h,
145 self.color_table.active_colors.normal)
145 self.color_table.active_colors.normal)
146
146
147 def set_active_scheme(self,scheme):
147 def set_active_scheme(self,scheme):
148 self.color_table.set_active_scheme(scheme)
148 self.color_table.set_active_scheme(scheme)
149 self.parser.color_table.set_active_scheme(scheme)
149 self.parser.color_table.set_active_scheme(scheme)
150
150
151 def noinfo(self,msg,oname):
151 def noinfo(self,msg,oname):
152 """Generic message when no information is found."""
152 """Generic message when no information is found."""
153 print 'No %s found' % msg,
153 print 'No %s found' % msg,
154 if oname:
154 if oname:
155 print 'for %s' % oname
155 print 'for %s' % oname
156 else:
156 else:
157 print
157 print
158
158
159 def pdef(self,obj,oname=''):
159 def pdef(self,obj,oname=''):
160 """Print the definition header for any callable object.
160 """Print the definition header for any callable object.
161
161
162 If the object is a class, print the constructor information."""
162 If the object is a class, print the constructor information."""
163
163
164 if not callable(obj):
164 if not callable(obj):
165 print 'Object is not callable.'
165 print 'Object is not callable.'
166 return
166 return
167
167
168 header = ''
168 header = ''
169 if type(obj) is types.ClassType:
169 if type(obj) is types.ClassType:
170 header = self.__head('Class constructor information:\n')
170 header = self.__head('Class constructor information:\n')
171 obj = obj.__init__
171 obj = obj.__init__
172 elif type(obj) is types.InstanceType:
172 elif type(obj) is types.InstanceType:
173 obj = obj.__call__
173 obj = obj.__call__
174
174
175 output = self.__getdef(obj,oname)
175 output = self.__getdef(obj,oname)
176 if output is None:
176 if output is None:
177 self.noinfo('definition header',oname)
177 self.noinfo('definition header',oname)
178 else:
178 else:
179 print >>Term.cout, header,self.format(output),
179 print >>Term.cout, header,self.format(output),
180
180
181 def pdoc(self,obj,oname='',formatter = None):
181 def pdoc(self,obj,oname='',formatter = None):
182 """Print the docstring for any object.
182 """Print the docstring for any object.
183
183
184 Optional:
184 Optional:
185 -formatter: a function to run the docstring through for specially
185 -formatter: a function to run the docstring through for specially
186 formatted docstrings."""
186 formatted docstrings."""
187
187
188 head = self.__head # so that itpl can find it even if private
188 head = self.__head # so that itpl can find it even if private
189 ds = getdoc(obj)
189 ds = getdoc(obj)
190 if formatter:
190 if formatter:
191 ds = formatter(ds)
191 ds = formatter(ds)
192 if type(obj) is types.ClassType:
192 if type(obj) is types.ClassType:
193 init_ds = getdoc(obj.__init__)
193 init_ds = getdoc(obj.__init__)
194 output = itpl('$head("Class Docstring:")\n'
194 output = itpl('$head("Class Docstring:")\n'
195 '$indent(ds)\n'
195 '$indent(ds)\n'
196 '$head("Constructor Docstring"):\n'
196 '$head("Constructor Docstring"):\n'
197 '$indent(init_ds)')
197 '$indent(init_ds)')
198 elif type(obj) is types.InstanceType and hasattr(obj,'__call__'):
198 elif type(obj) is types.InstanceType and hasattr(obj,'__call__'):
199 call_ds = getdoc(obj.__call__)
199 call_ds = getdoc(obj.__call__)
200 if call_ds:
200 if call_ds:
201 output = itpl('$head("Class Docstring:")\n$indent(ds)\n'
201 output = itpl('$head("Class Docstring:")\n$indent(ds)\n'
202 '$head("Calling Docstring:")\n$indent(call_ds)')
202 '$head("Calling Docstring:")\n$indent(call_ds)')
203 else:
203 else:
204 output = ds
204 output = ds
205 else:
205 else:
206 output = ds
206 output = ds
207 if output is None:
207 if output is None:
208 self.noinfo('documentation',oname)
208 self.noinfo('documentation',oname)
209 return
209 return
210 page(output)
210 page(output)
211
211
212 def psource(self,obj,oname=''):
212 def psource(self,obj,oname=''):
213 """Print the source code for an object."""
213 """Print the source code for an object."""
214
214
215 # Flush the source cache because inspect can return out-of-date source
215 # Flush the source cache because inspect can return out-of-date source
216 linecache.checkcache()
216 linecache.checkcache()
217 try:
217 try:
218 src = inspect.getsource(obj)
218 src = inspect.getsource(obj)
219 except:
219 except:
220 self.noinfo('source',oname)
220 self.noinfo('source',oname)
221 else:
221 else:
222 page(self.format(src))
222 page(self.format(src))
223
223
224 def pfile(self,obj,oname=''):
224 def pfile(self,obj,oname=''):
225 """Show the whole file where an object was defined."""
225 """Show the whole file where an object was defined."""
226 try:
226 try:
227 sourcelines,lineno = inspect.getsourcelines(obj)
227 sourcelines,lineno = inspect.getsourcelines(obj)
228 except:
228 except:
229 self.noinfo('file',oname)
229 self.noinfo('file',oname)
230 else:
230 else:
231 # run contents of file through pager starting at line
231 # run contents of file through pager starting at line
232 # where the object is defined
232 # where the object is defined
233 page(self.format(open(inspect.getabsfile(obj)).read()),lineno)
233 page(self.format(open(inspect.getabsfile(obj)).read()),lineno)
234
234
235 def pinfo(self,obj,oname='',formatter=None,info=None,detail_level=0):
235 def pinfo(self,obj,oname='',formatter=None,info=None,detail_level=0):
236 """Show detailed information about an object.
236 """Show detailed information about an object.
237
237
238 Optional arguments:
238 Optional arguments:
239
239
240 - oname: name of the variable pointing to the object.
240 - oname: name of the variable pointing to the object.
241
241
242 - formatter: special formatter for docstrings (see pdoc)
242 - formatter: special formatter for docstrings (see pdoc)
243
243
244 - info: a structure with some information fields which may have been
244 - info: a structure with some information fields which may have been
245 precomputed already.
245 precomputed already.
246
246
247 - detail_level: if set to 1, more information is given.
247 - detail_level: if set to 1, more information is given.
248 """
248 """
249
249
250 obj_type = type(obj)
250 obj_type = type(obj)
251
251
252 header = self.__head
252 header = self.__head
253 if info is None:
253 if info is None:
254 ismagic = 0
254 ismagic = 0
255 isalias = 0
255 isalias = 0
256 ospace = ''
256 ospace = ''
257 else:
257 else:
258 ismagic = info.ismagic
258 ismagic = info.ismagic
259 isalias = info.isalias
259 isalias = info.isalias
260 ospace = info.namespace
260 ospace = info.namespace
261 # Get docstring, special-casing aliases:
261 # Get docstring, special-casing aliases:
262 if isalias:
262 if isalias:
263 ds = "Alias to the system command:\n %s" % obj[1]
263 ds = "Alias to the system command:\n %s" % obj[1]
264 else:
264 else:
265 ds = getdoc(obj)
265 ds = getdoc(obj)
266 if formatter is not None:
266 if formatter is not None:
267 ds = formatter(ds)
267 ds = formatter(ds)
268
268
269 # store output in a list which gets joined with \n at the end.
269 # store output in a list which gets joined with \n at the end.
270 out = myStringIO()
270 out = myStringIO()
271
271
272 string_max = 200 # max size of strings to show (snipped if longer)
272 string_max = 200 # max size of strings to show (snipped if longer)
273 shalf = int((string_max -5)/2)
273 shalf = int((string_max -5)/2)
274
274
275 if ismagic:
275 if ismagic:
276 obj_type_name = 'Magic function'
276 obj_type_name = 'Magic function'
277 elif isalias:
277 elif isalias:
278 obj_type_name = 'System alias'
278 obj_type_name = 'System alias'
279 else:
279 else:
280 obj_type_name = obj_type.__name__
280 obj_type_name = obj_type.__name__
281 out.writeln(header('Type:\t\t')+obj_type_name)
281 out.writeln(header('Type:\t\t')+obj_type_name)
282
282
283 try:
283 try:
284 bclass = obj.__class__
284 bclass = obj.__class__
285 out.writeln(header('Base Class:\t')+str(bclass))
285 out.writeln(header('Base Class:\t')+str(bclass))
286 except: pass
286 except: pass
287
287
288 # String form, but snip if too long in ? form (full in ??)
288 # String form, but snip if too long in ? form (full in ??)
289 try:
289 try:
290 ostr = str(obj)
290 ostr = str(obj)
291 str_head = 'String Form:'
291 str_head = 'String Form:'
292 if not detail_level and len(ostr)>string_max:
292 if not detail_level and len(ostr)>string_max:
293 ostr = ostr[:shalf] + ' <...> ' + ostr[-shalf:]
293 ostr = ostr[:shalf] + ' <...> ' + ostr[-shalf:]
294 ostr = ("\n" + " " * len(str_head.expandtabs())).\
294 ostr = ("\n" + " " * len(str_head.expandtabs())).\
295 join(map(string.strip,ostr.split("\n")))
295 join(map(string.strip,ostr.split("\n")))
296 if ostr.find('\n') > -1:
296 if ostr.find('\n') > -1:
297 # Print multi-line strings starting at the next line.
297 # Print multi-line strings starting at the next line.
298 str_sep = '\n'
298 str_sep = '\n'
299 else:
299 else:
300 str_sep = '\t'
300 str_sep = '\t'
301 out.writeln("%s%s%s" % (header(str_head),str_sep,ostr))
301 out.writeln("%s%s%s" % (header(str_head),str_sep,ostr))
302 except:
302 except:
303 pass
303 pass
304
304
305 if ospace:
305 if ospace:
306 out.writeln(header('Namespace:\t')+ospace)
306 out.writeln(header('Namespace:\t')+ospace)
307
307
308 # Length (for strings and lists)
308 # Length (for strings and lists)
309 try:
309 try:
310 length = str(len(obj))
310 length = str(len(obj))
311 out.writeln(header('Length:\t\t')+length)
311 out.writeln(header('Length:\t\t')+length)
312 except: pass
312 except: pass
313
313
314 # Filename where object was defined
314 # Filename where object was defined
315 try:
315 try:
316 file = inspect.getabsfile(obj)
316 file = inspect.getabsfile(obj)
317 if file.endswith('<string>'):
317 if file.endswith('<string>'):
318 file = 'Dynamically generated function. No source code available.'
318 file = 'Dynamically generated function. No source code available.'
319 out.writeln(header('File:\t\t')+file)
319 out.writeln(header('File:\t\t')+file)
320 except: pass
320 except: pass
321
321
322 # reconstruct the function definition and print it:
322 # reconstruct the function definition and print it:
323 defln = self.__getdef(obj,oname)
323 defln = self.__getdef(obj,oname)
324 if defln:
324 if defln:
325 out.write(header('Definition:\t')+self.format(defln))
325 out.write(header('Definition:\t')+self.format(defln))
326
326
327 # Docstrings only in detail 0 mode, since source contains them (we
327 # Docstrings only in detail 0 mode, since source contains them (we
328 # avoid repetitions). If source fails, we add them back, see below.
328 # avoid repetitions). If source fails, we add them back, see below.
329 if ds and detail_level == 0:
329 if ds and detail_level == 0:
330 out.writeln(header('Docstring:\n') + indent(ds))
330 out.writeln(header('Docstring:\n') + indent(ds))
331
331
332 # Original source code for any callable
332 # Original source code for any callable
333 if detail_level:
333 if detail_level:
334 # Flush the source cache because inspect can return out-of-date source
334 # Flush the source cache because inspect can return out-of-date source
335 linecache.checkcache()
335 linecache.checkcache()
336 try:
336 try:
337 source = self.format(inspect.getsource(obj))
337 source = self.format(inspect.getsource(obj))
338 out.write(header('Source:\n')+source.rstrip())
338 out.write(header('Source:\n')+source.rstrip())
339 except:
339 except:
340 if ds:
340 if ds:
341 out.writeln(header('Docstring:\n') + indent(ds))
341 out.writeln(header('Docstring:\n') + indent(ds))
342
342
343 # Constructor docstring for classes
343 # Constructor docstring for classes
344 if obj_type is types.ClassType:
344 if obj_type is types.ClassType:
345 # reconstruct the function definition and print it:
345 # reconstruct the function definition and print it:
346 try:
346 try:
347 obj_init = obj.__init__
347 obj_init = obj.__init__
348 except AttributeError:
348 except AttributeError:
349 init_def = init_ds = None
349 init_def = init_ds = None
350 else:
350 else:
351 init_def = self.__getdef(obj_init,oname)
351 init_def = self.__getdef(obj_init,oname)
352 init_ds = getdoc(obj_init)
352 init_ds = getdoc(obj_init)
353
353
354 if init_def or init_ds:
354 if init_def or init_ds:
355 out.writeln(header('\nConstructor information:'))
355 out.writeln(header('\nConstructor information:'))
356 if init_def:
356 if init_def:
357 out.write(header('Definition:\t')+ self.format(init_def))
357 out.write(header('Definition:\t')+ self.format(init_def))
358 if init_ds:
358 if init_ds:
359 out.writeln(header('Docstring:\n') + indent(init_ds))
359 out.writeln(header('Docstring:\n') + indent(init_ds))
360 # and class docstring for instances:
360 # and class docstring for instances:
361 elif obj_type is types.InstanceType:
361 elif obj_type is types.InstanceType:
362
362
363 # First, check whether the instance docstring is identical to the
363 # First, check whether the instance docstring is identical to the
364 # class one, and print it separately if they don't coincide. In
364 # class one, and print it separately if they don't coincide. In
365 # most cases they will, but it's nice to print all the info for
365 # most cases they will, but it's nice to print all the info for
366 # objects which use instance-customized docstrings.
366 # objects which use instance-customized docstrings.
367 if ds:
367 if ds:
368 class_ds = getdoc(obj.__class__)
368 class_ds = getdoc(obj.__class__)
369 if class_ds and ds != class_ds:
369 if class_ds and ds != class_ds:
370 out.writeln(header('Class Docstring:\n') +
370 out.writeln(header('Class Docstring:\n') +
371 indent(class_ds))
371 indent(class_ds))
372
372
373 # Next, try to show constructor docstrings
373 # Next, try to show constructor docstrings
374 try:
374 try:
375 init_ds = getdoc(obj.__init__)
375 init_ds = getdoc(obj.__init__)
376 except AttributeError:
376 except AttributeError:
377 init_ds = None
377 init_ds = None
378 if init_ds:
378 if init_ds:
379 out.writeln(header('Constructor Docstring:\n') +
379 out.writeln(header('Constructor Docstring:\n') +
380 indent(init_ds))
380 indent(init_ds))
381
381
382 # Call form docstring for callable instances
382 # Call form docstring for callable instances
383 if hasattr(obj,'__call__'):
383 if hasattr(obj,'__call__'):
384 out.writeln(header('Callable:\t')+'Yes')
384 out.writeln(header('Callable:\t')+'Yes')
385 call_def = self.__getdef(obj.__call__,oname)
385 call_def = self.__getdef(obj.__call__,oname)
386 if call_def is None:
386 if call_def is None:
387 out.write(header('Call def:\t')+
387 out.write(header('Call def:\t')+
388 'Calling definition not available.')
388 'Calling definition not available.')
389 else:
389 else:
390 out.write(header('Call def:\t')+self.format(call_def))
390 out.write(header('Call def:\t')+self.format(call_def))
391 call_ds = getdoc(obj.__call__)
391 call_ds = getdoc(obj.__call__)
392 if call_ds:
392 if call_ds:
393 out.writeln(header('Call docstring:\n') + indent(call_ds))
393 out.writeln(header('Call docstring:\n') + indent(call_ds))
394
394
395 # Finally send to printer/pager
395 # Finally send to printer/pager
396 output = out.getvalue()
396 output = out.getvalue()
397 if output:
397 if output:
398 page(output)
398 page(output)
399 # end pinfo
399 # end pinfo
400
400
401 def psearch(self,oname='',formatter = None,shell=None):
401 def psearch(self,oname='',formatter=None,shell=None):
402 """Search namespaces with wildcards for objects.
402 """Search namespaces with wildcards for objects.
403
403
404 Optional arguments:
404 Optional arguments:
405
405
406 - oname: rest of the commandline containging pattern and options
406 - oname: rest of the commandline containging pattern and options.
407
407
408 - formatter: Not used
408 - formatter: Not used.
409
409
410 - shell: The shell object from the Magic class. Needed to
410 - shell: The shell object from the Magic class. Needed to access
411 access the namespaces
411 the namespaces.
412
412 """
413 """
413 option_list = ['-c','-a']
414 option_list=["-c","-a"]
414 cmds = oname.split()
415 import pdb
415 filter = ''
416 # pdb.set_trace()
416 type_pattern = 'all'
417 cmds=oname.split()
417 options = [x for x in cmds if x in option_list]
418 filter=""
418 ignorecase = '-c' not in options
419 type_pattern="all"
419 showhidden = '-a' in options
420 ns_cmds=[]
420 ns_cmds = [x for x in cmds if x[0] in '-+' and x not in option_list]
421 options=[x for x in cmds if x in option_list]
421 cmds = [x for x in cmds if x[0] not in '-+']
422 ignorecase="-c" not in options
422 len_cmds = len(cmds)
423 showhidden="-a" in options
423 if len_cmds == 1:
424 ns_cmds=[x for x in cmds if x[0] in "-+" and x not in option_list]
424 filter = cmds[0].strip()
425 cmds=[x for x in cmds if x[0] not in "-+"]
425 elif len_cmds == 2:
426 if len(cmds)>2: #assume we want to choose name spaces.
426 filter,type_pattern = cmds
427 #Rather poor design forces the use of a typepattern in order to choose name spaces
427 elif len_cmds>2:
428 cmds=cmds[:2]
428 # assume we want to choose name spaces. Rather poor design forces
429 if len(cmds)==2:
429 #the use of a typepattern in order to choose name spaces
430 filter,type_pattern=cmds
430 cmds = cmds[:2]
431 elif len(cmds)==1:
431
432 filter=cmds[0].strip()
432 do_list = choose_namespaces(shell,ns_cmds)
433
433
434 do_list=choose_namespaces(shell,ns_cmds)
434 search_result = []
435
435 for ns in do_list:
436 search_result=[]
436 tmp_res = list(list_namespace(ns,type_pattern,filter,
437 for ns in do_list:
437 ignorecase=ignorecase,
438 tmp_res=list(list_namespace(ns,type_pattern,filter,ignorecase=ignorecase,showhidden=showhidden))
438 showhidden=showhidden))
439 search_result.extend(tmp_res)
439 search_result.extend(tmp_res)
440 search_result.sort()
440 search_result.sort()
441
441
442 page("\n".join(search_result))
442 page('\n'.join(search_result))
@@ -1,157 +1,156 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """Support for wildcard pattern matching in object inspection.
2 """Support for wildcard pattern matching in object inspection.
3
3
4 $Id: OInspect.py 608 2005-07-06 17:52:32Z fperez $
4 $Id: OInspect.py 608 2005-07-06 17:52:32Z fperez $
5 """
5 """
6
6
7 #*****************************************************************************
7 #*****************************************************************************
8 # Copyright (C) 2005 JΓΆrgen Stenarson <jorgen.stenarson@bostream.nu>
8 # Copyright (C) 2005 JΓΆrgen Stenarson <jorgen.stenarson@bostream.nu>
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 from IPython import Release
14 from IPython import Release
15 __author__ = "JΓΆrgen Stenarson <jorgen.stenarson@bostream.nu>"
15 __author__ = "JΓΆrgen Stenarson <jorgen.stenarson@bostream.nu>"
16 __license__ = Release.license
16 __license__ = Release.license
17
17
18 import __builtin__
18 import __builtin__
19 import types
19 import types
20 import re
20 import re
21 import pprint
21 import pprint
22 import exceptions
22 import exceptions
23 import pdb
23 import pdb
24 import IPython.genutils as genutils
24 import IPython.genutils as genutils
25
25
26 def create_typestr2type_dicts(dont_include_in_type2type2str=["lambda"]):
26 def create_typestr2type_dicts(dont_include_in_type2type2str=["lambda"]):
27 """Return dictionaries mapping lower case typename to type objects, from
27 """Return dictionaries mapping lower case typename to type objects, from
28 the types package, and vice versa."""
28 the types package, and vice versa."""
29 typenamelist=[]
29 typenamelist=[]
30 for tname in dir(types):
30 for tname in dir(types):
31 if tname[-4:]=="Type":
31 if tname[-4:]=="Type":
32 typenamelist.append(tname)
32 typenamelist.append(tname)
33 typestr2type={}
33 typestr2type={}
34 type2typestr={}
34 type2typestr={}
35 for tname in typenamelist:
35 for tname in typenamelist:
36 name=tname[:-4].lower()
36 name=tname[:-4].lower()
37 obj=getattr(types,tname)
37 obj=getattr(types,tname)
38 typestr2type[name]=getattr(types,tname)
38 typestr2type[name]=getattr(types,tname)
39 if name in dont_include_in_type2type2str:
39 if name in dont_include_in_type2type2str:
40 type2typestr[obj]=name
40 type2typestr[obj]=name
41 return typestr2type,type2typestr
41 return typestr2type,type2typestr
42
42
43 typestr2type,type2typestr=create_typestr2type_dicts()
43 typestr2type,type2typestr=create_typestr2type_dicts()
44
44
45 def is_type(obj,typestr_or_type):
45 def is_type(obj,typestr_or_type):
46 """is_type(obj,typestr_or_type) verifies if obj is of a certain type or
46 """is_type(obj,typestr_or_type) verifies if obj is of a certain type or
47 group of types takes strings as parameters of the for 'tuple'<->TupleType
47 group of types takes strings as parameters of the for 'tuple'<->TupleType
48 'all' matches all types. TODO: Should be extended for choosing more than
48 'all' matches all types. TODO: Should be extended for choosing more than
49 one type
49 one type
50 """
50 """
51 if typestr_or_type=="all":
51 if typestr_or_type=="all":
52 return True
52 return True
53 if type(typestr_or_type)==types.TypeType:
53 if type(typestr_or_type)==types.TypeType:
54 test_type=typestr_or_type
54 test_type=typestr_or_type
55 else:
55 else:
56 test_type=typestr2type.get(typestr_or_type,False)
56 test_type=typestr2type.get(typestr_or_type,False)
57 if test_type:
57 if test_type:
58 return isinstance(obj,test_type)
58 return isinstance(obj,test_type)
59 else:
59 else:
60 return False
60 return False
61
61
62 def show_hidden(str,showhidden=False):
62 def show_hidden(str,showhidden=False):
63 """Return true for strings starting with single _ if showhidden is true."""
63 """Return true for strings starting with single _ if showhidden is true."""
64 return showhidden or str.startswith("__") or not str.startswith("_")
64 return showhidden or str.startswith("__") or not str.startswith("_")
65
65
66
66
67 class NameSpace(object):
67 class NameSpace(object):
68 """NameSpace holds the dictionary for a namespace and implements filtering
68 """NameSpace holds the dictionary for a namespace and implements filtering
69 on name and types"""
69 on name and types"""
70 def __init__(self,obj,namepattern="*",typepattern="all",ignorecase=True,
70 def __init__(self,obj,namepattern="*",typepattern="all",ignorecase=True,
71 showhidden=True):
71 showhidden=True):
72 self.showhidden=showhidden #Hide names beginning with single _
72 self.showhidden = showhidden #Hide names beginning with single _
73 self.object=obj
73 self.object = obj
74 self.namepattern=namepattern
74 self.namepattern = namepattern
75 self.typepattern=typepattern
75 self.typepattern = typepattern
76 self.ignorecase=ignorecase
76 self.ignorecase = ignorecase
77 if type(obj)==type(dict()):
77
78 self._ns=obj
78 # We should only match EXACT dicts here, so DON'T use isinstance()
79 if type(obj) == types.DictType:
80 self._ns = obj
79 else:
81 else:
80 try:
82 self._ns = dict([(key,getattr(obj,key)) for key in dir(obj)
81 self._ns=self.object.__dict__
83 if isinstance(key, basestring)])
82 except exceptions.AttributeError:
83 self._ns=dict([(key,getattr(self.object,key))
84 for key in dir(self.object)])
85
84
86 def get_ns(self):
85 def get_ns(self):
87 """Return name space dictionary with objects matching type and name patterns."""
86 """Return name space dictionary with objects matching type and name patterns."""
88 return self.filter(self.namepattern,self.typepattern)
87 return self.filter(self.namepattern,self.typepattern)
89 ns=property(get_ns)
88 ns=property(get_ns)
90
89
91 def get_ns_names(self):
90 def get_ns_names(self):
92 """Return list of object names in namespace that match the patterns."""
91 """Return list of object names in namespace that match the patterns."""
93 return self.ns.keys()
92 return self.ns.keys()
94 ns_names=property(get_ns_names,doc="List of objects in name space that "
93 ns_names=property(get_ns_names,doc="List of objects in name space that "
95 "match the type and name patterns.")
94 "match the type and name patterns.")
96
95
97 def filter(self,namepattern,typepattern):
96 def filter(self,namepattern,typepattern):
98 """Return dictionary of filtered namespace."""
97 """Return dictionary of filtered namespace."""
99 def glob_filter(lista,namepattern,hidehidden,ignorecase):
98 def glob_filter(lista,namepattern,hidehidden,ignorecase):
100 """Return list of elements in lista that match pattern."""
99 """Return list of elements in lista that match pattern."""
101 pattern=namepattern.replace("*",".*")
100 pattern=namepattern.replace("*",".*")
102 if ignorecase:
101 if ignorecase:
103 reg=re.compile(pattern+"$",re.I)
102 reg=re.compile(pattern+"$",re.I)
104 else:
103 else:
105 reg=re.compile(pattern+"$")
104 reg=re.compile(pattern+"$")
106 result=[x for x in lista if reg.match(x) and show_hidden(x,hidehidden)]
105 result=[x for x in lista if reg.match(x) and show_hidden(x,hidehidden)]
107 return result
106 return result
108 ns=self._ns
107 ns=self._ns
109 #Filter namespace by the namepattern
108 #Filter namespace by the namepattern
110 all=[(x,ns[x]) for x in glob_filter(ns.keys(),namepattern,
109 all=[(x,ns[x]) for x in glob_filter(ns.keys(),namepattern,
111 self.showhidden,self.ignorecase)]
110 self.showhidden,self.ignorecase)]
112 #Filter namespace by typepattern
111 #Filter namespace by typepattern
113 all=[(key,obj) for key,obj in all if is_type(obj,typepattern)]
112 all=[(key,obj) for key,obj in all if is_type(obj,typepattern)]
114 all=dict(all)
113 all=dict(all)
115 return all
114 return all
116
115
117 #TODO: Implement dictionary like access to filtered name space?
116 #TODO: Implement dictionary like access to filtered name space?
118
117
119 def list_namespace(namespace,typepattern,filter,ignorecase=False,showhidden=False):
118 def list_namespace(namespace,typepattern,filter,ignorecase=False,showhidden=False):
120 """Return dictionary of all objects in namespace that matches typepattern
119 """Return dictionary of all objects in namespace that matches typepattern
121 and filter."""
120 and filter."""
122 patternlist=filter.split(".")
121 patternlist=filter.split(".")
123 if len(patternlist)==1:
122 if len(patternlist)==1:
124 ns=NameSpace(namespace,namepattern=patternlist[0],typepattern=typepattern,
123 ns=NameSpace(namespace,namepattern=patternlist[0],typepattern=typepattern,
125 ignorecase=ignorecase,showhidden=showhidden)
124 ignorecase=ignorecase,showhidden=showhidden)
126 return ns.ns
125 return ns.ns
127 if len(patternlist)>1:
126 if len(patternlist)>1:
128 #This is where we can change if all objects should be searched or only moduleas
127 #This is where we can change if all objects should be searched or only moduleas
129 #Just change the typepattern to module to search only modules
128 #Just change the typepattern to module to search only modules
130 ns=NameSpace(namespace,
129 ns=NameSpace(namespace,
131 namepattern=patternlist[0],
130 namepattern=patternlist[0],
132 typepattern="all",ignorecase=ignorecase,showhidden=showhidden)
131 typepattern="all",ignorecase=ignorecase,showhidden=showhidden)
133 res={}
132 res={}
134 nsdict=ns.ns
133 nsdict=ns.ns
135 for name,obj in nsdict.iteritems():
134 for name,obj in nsdict.iteritems():
136 ns=list_namespace(obj,typepattern,".".join(patternlist[1:]),
135 ns=list_namespace(obj,typepattern,".".join(patternlist[1:]),
137 ignorecase=ignorecase,showhidden=showhidden)
136 ignorecase=ignorecase,showhidden=showhidden)
138 for inner_name,inner_obj in ns.iteritems():
137 for inner_name,inner_obj in ns.iteritems():
139 res["%s.%s"%(name,inner_name)]=inner_obj
138 res["%s.%s"%(name,inner_name)]=inner_obj
140 return res
139 return res
141
140
142 def choose_namespaces(shell,cmds):
141 def choose_namespaces(shell,cmds):
143 """Returns a list of namespaces modified by arguments."""
142 """Returns a list of namespaces modified by arguments."""
144 nslist=genutils.mkdict(user=shell.user_ns,internal=shell.internal_ns,
143 nslist=genutils.mkdict(user=shell.user_ns,internal=shell.internal_ns,
145 builtin=__builtin__.__dict__,alias=shell.alias_table)
144 builtin=__builtin__.__dict__,alias=shell.alias_table)
146 default_list=["user","builtin"] # Should this list be a user option??
145 default_list=["user","builtin"] # Should this list be a user option??
147 for cmd in cmds:
146 for cmd in cmds:
148 if cmd[0]=="-": #remove from defaultlist
147 if cmd[0]=="-": #remove from defaultlist
149 if cmd[1:] in default_list:
148 if cmd[1:] in default_list:
150 default_list.remove(cmd[1:])
149 default_list.remove(cmd[1:])
151 elif cmd[0]=="+":
150 elif cmd[0]=="+":
152 if cmd[1:] not in default_list and cmd[1:]in nslist:
151 if cmd[1:] not in default_list and cmd[1:]in nslist:
153 default_list.append(cmd[1:])
152 default_list.append(cmd[1:])
154 else:
153 else:
155 if cmd in nslist:
154 if cmd in nslist:
156 default_list.append(cmd[1:])
155 default_list.append(cmd[1:])
157 return [nslist[x] for x in default_list]
156 return [nslist[x] for x in default_list]
@@ -1,4443 +1,4449 b''
1 2005-11-13 <Fernando.Perez@colorado.edu>
2
3 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
4 attributes in wildcard searches for subclasses. Modified version
5 of a patch by Jorgen.
6
1 2005-11-12 <Fernando.Perez@colorado.edu>
7 2005-11-12 <Fernando.Perez@colorado.edu>
2
8
3 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
9 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
4 embedded instances. I added a user_global_ns attribute to the
10 embedded instances. I added a user_global_ns attribute to the
5 InteractiveShell class to handle this.
11 InteractiveShell class to handle this.
6
12
7 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
13 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
8
14
9 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
15 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
10 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
16 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
11 (reported under win32, but may happen also in other platforms).
17 (reported under win32, but may happen also in other platforms).
12 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
18 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
13
19
14 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
20 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
15
21
16 * IPython/Magic.py (magic_psearch): new support for wildcard
22 * IPython/Magic.py (magic_psearch): new support for wildcard
17 patterns. Now, typing ?a*b will list all names which begin with a
23 patterns. Now, typing ?a*b will list all names which begin with a
18 and end in b, for example. The %psearch magic has full
24 and end in b, for example. The %psearch magic has full
19 docstrings. Many thanks to JΓΆrgen Stenarson
25 docstrings. Many thanks to JΓΆrgen Stenarson
20 <jorgen.stenarson-AT-bostream.nu>, author of the patches
26 <jorgen.stenarson-AT-bostream.nu>, author of the patches
21 implementing this functionality.
27 implementing this functionality.
22
28
23 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
29 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
24
30
25 * Manual: fixed long-standing annoyance of double-dashes (as in
31 * Manual: fixed long-standing annoyance of double-dashes (as in
26 --prefix=~, for example) being stripped in the HTML version. This
32 --prefix=~, for example) being stripped in the HTML version. This
27 is a latex2html bug, but a workaround was provided. Many thanks
33 is a latex2html bug, but a workaround was provided. Many thanks
28 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
34 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
29 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
35 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
30 rolling. This seemingly small issue had tripped a number of users
36 rolling. This seemingly small issue had tripped a number of users
31 when first installing, so I'm glad to see it gone.
37 when first installing, so I'm glad to see it gone.
32
38
33 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
39 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
34
40
35 * IPython/Extensions/numeric_formats.py: fix missing import,
41 * IPython/Extensions/numeric_formats.py: fix missing import,
36 reported by Stephen Walton.
42 reported by Stephen Walton.
37
43
38 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
44 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
39
45
40 * IPython/demo.py: finish demo module, fully documented now.
46 * IPython/demo.py: finish demo module, fully documented now.
41
47
42 * IPython/genutils.py (file_read): simple little utility to read a
48 * IPython/genutils.py (file_read): simple little utility to read a
43 file and ensure it's closed afterwards.
49 file and ensure it's closed afterwards.
44
50
45 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
51 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
46
52
47 * IPython/demo.py (Demo.__init__): added support for individually
53 * IPython/demo.py (Demo.__init__): added support for individually
48 tagging blocks for automatic execution.
54 tagging blocks for automatic execution.
49
55
50 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
56 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
51 syntax-highlighted python sources, requested by John.
57 syntax-highlighted python sources, requested by John.
52
58
53 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
59 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
54
60
55 * IPython/demo.py (Demo.again): fix bug where again() blocks after
61 * IPython/demo.py (Demo.again): fix bug where again() blocks after
56 finishing.
62 finishing.
57
63
58 * IPython/genutils.py (shlex_split): moved from Magic to here,
64 * IPython/genutils.py (shlex_split): moved from Magic to here,
59 where all 2.2 compatibility stuff lives. I needed it for demo.py.
65 where all 2.2 compatibility stuff lives. I needed it for demo.py.
60
66
61 * IPython/demo.py (Demo.__init__): added support for silent
67 * IPython/demo.py (Demo.__init__): added support for silent
62 blocks, improved marks as regexps, docstrings written.
68 blocks, improved marks as regexps, docstrings written.
63 (Demo.__init__): better docstring, added support for sys.argv.
69 (Demo.__init__): better docstring, added support for sys.argv.
64
70
65 * IPython/genutils.py (marquee): little utility used by the demo
71 * IPython/genutils.py (marquee): little utility used by the demo
66 code, handy in general.
72 code, handy in general.
67
73
68 * IPython/demo.py (Demo.__init__): new class for interactive
74 * IPython/demo.py (Demo.__init__): new class for interactive
69 demos. Not documented yet, I just wrote it in a hurry for
75 demos. Not documented yet, I just wrote it in a hurry for
70 scipy'05. Will docstring later.
76 scipy'05. Will docstring later.
71
77
72 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
78 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
73
79
74 * IPython/Shell.py (sigint_handler): Drastic simplification which
80 * IPython/Shell.py (sigint_handler): Drastic simplification which
75 also seems to make Ctrl-C work correctly across threads! This is
81 also seems to make Ctrl-C work correctly across threads! This is
76 so simple, that I can't beleive I'd missed it before. Needs more
82 so simple, that I can't beleive I'd missed it before. Needs more
77 testing, though.
83 testing, though.
78 (KBINT): Never mind, revert changes. I'm sure I'd tried something
84 (KBINT): Never mind, revert changes. I'm sure I'd tried something
79 like this before...
85 like this before...
80
86
81 * IPython/genutils.py (get_home_dir): add protection against
87 * IPython/genutils.py (get_home_dir): add protection against
82 non-dirs in win32 registry.
88 non-dirs in win32 registry.
83
89
84 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
90 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
85 bug where dict was mutated while iterating (pysh crash).
91 bug where dict was mutated while iterating (pysh crash).
86
92
87 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
93 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
88
94
89 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
95 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
90 spurious newlines added by this routine. After a report by
96 spurious newlines added by this routine. After a report by
91 F. Mantegazza.
97 F. Mantegazza.
92
98
93 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
99 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
94
100
95 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
101 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
96 calls. These were a leftover from the GTK 1.x days, and can cause
102 calls. These were a leftover from the GTK 1.x days, and can cause
97 problems in certain cases (after a report by John Hunter).
103 problems in certain cases (after a report by John Hunter).
98
104
99 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
105 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
100 os.getcwd() fails at init time. Thanks to patch from David Remahl
106 os.getcwd() fails at init time. Thanks to patch from David Remahl
101 <chmod007-AT-mac.com>.
107 <chmod007-AT-mac.com>.
102 (InteractiveShell.__init__): prevent certain special magics from
108 (InteractiveShell.__init__): prevent certain special magics from
103 being shadowed by aliases. Closes
109 being shadowed by aliases. Closes
104 http://www.scipy.net/roundup/ipython/issue41.
110 http://www.scipy.net/roundup/ipython/issue41.
105
111
106 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
112 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
107
113
108 * IPython/iplib.py (InteractiveShell.complete): Added new
114 * IPython/iplib.py (InteractiveShell.complete): Added new
109 top-level completion method to expose the completion mechanism
115 top-level completion method to expose the completion mechanism
110 beyond readline-based environments.
116 beyond readline-based environments.
111
117
112 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
118 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
113
119
114 * tools/ipsvnc (svnversion): fix svnversion capture.
120 * tools/ipsvnc (svnversion): fix svnversion capture.
115
121
116 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
122 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
117 attribute to self, which was missing. Before, it was set by a
123 attribute to self, which was missing. Before, it was set by a
118 routine which in certain cases wasn't being called, so the
124 routine which in certain cases wasn't being called, so the
119 instance could end up missing the attribute. This caused a crash.
125 instance could end up missing the attribute. This caused a crash.
120 Closes http://www.scipy.net/roundup/ipython/issue40.
126 Closes http://www.scipy.net/roundup/ipython/issue40.
121
127
122 2005-08-16 Fernando Perez <fperez@colorado.edu>
128 2005-08-16 Fernando Perez <fperez@colorado.edu>
123
129
124 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
130 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
125 contains non-string attribute. Closes
131 contains non-string attribute. Closes
126 http://www.scipy.net/roundup/ipython/issue38.
132 http://www.scipy.net/roundup/ipython/issue38.
127
133
128 2005-08-14 Fernando Perez <fperez@colorado.edu>
134 2005-08-14 Fernando Perez <fperez@colorado.edu>
129
135
130 * tools/ipsvnc: Minor improvements, to add changeset info.
136 * tools/ipsvnc: Minor improvements, to add changeset info.
131
137
132 2005-08-12 Fernando Perez <fperez@colorado.edu>
138 2005-08-12 Fernando Perez <fperez@colorado.edu>
133
139
134 * IPython/iplib.py (runsource): remove self.code_to_run_src
140 * IPython/iplib.py (runsource): remove self.code_to_run_src
135 attribute. I realized this is nothing more than
141 attribute. I realized this is nothing more than
136 '\n'.join(self.buffer), and having the same data in two different
142 '\n'.join(self.buffer), and having the same data in two different
137 places is just asking for synchronization bugs. This may impact
143 places is just asking for synchronization bugs. This may impact
138 people who have custom exception handlers, so I need to warn
144 people who have custom exception handlers, so I need to warn
139 ipython-dev about it (F. Mantegazza may use them).
145 ipython-dev about it (F. Mantegazza may use them).
140
146
141 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
147 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
142
148
143 * IPython/genutils.py: fix 2.2 compatibility (generators)
149 * IPython/genutils.py: fix 2.2 compatibility (generators)
144
150
145 2005-07-18 Fernando Perez <fperez@colorado.edu>
151 2005-07-18 Fernando Perez <fperez@colorado.edu>
146
152
147 * IPython/genutils.py (get_home_dir): fix to help users with
153 * IPython/genutils.py (get_home_dir): fix to help users with
148 invalid $HOME under win32.
154 invalid $HOME under win32.
149
155
150 2005-07-17 Fernando Perez <fperez@colorado.edu>
156 2005-07-17 Fernando Perez <fperez@colorado.edu>
151
157
152 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
158 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
153 some old hacks and clean up a bit other routines; code should be
159 some old hacks and clean up a bit other routines; code should be
154 simpler and a bit faster.
160 simpler and a bit faster.
155
161
156 * IPython/iplib.py (interact): removed some last-resort attempts
162 * IPython/iplib.py (interact): removed some last-resort attempts
157 to survive broken stdout/stderr. That code was only making it
163 to survive broken stdout/stderr. That code was only making it
158 harder to abstract out the i/o (necessary for gui integration),
164 harder to abstract out the i/o (necessary for gui integration),
159 and the crashes it could prevent were extremely rare in practice
165 and the crashes it could prevent were extremely rare in practice
160 (besides being fully user-induced in a pretty violent manner).
166 (besides being fully user-induced in a pretty violent manner).
161
167
162 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
168 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
163 Nothing major yet, but the code is simpler to read; this should
169 Nothing major yet, but the code is simpler to read; this should
164 make it easier to do more serious modifications in the future.
170 make it easier to do more serious modifications in the future.
165
171
166 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
172 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
167 which broke in .15 (thanks to a report by Ville).
173 which broke in .15 (thanks to a report by Ville).
168
174
169 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
175 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
170 be quite correct, I know next to nothing about unicode). This
176 be quite correct, I know next to nothing about unicode). This
171 will allow unicode strings to be used in prompts, amongst other
177 will allow unicode strings to be used in prompts, amongst other
172 cases. It also will prevent ipython from crashing when unicode
178 cases. It also will prevent ipython from crashing when unicode
173 shows up unexpectedly in many places. If ascii encoding fails, we
179 shows up unexpectedly in many places. If ascii encoding fails, we
174 assume utf_8. Currently the encoding is not a user-visible
180 assume utf_8. Currently the encoding is not a user-visible
175 setting, though it could be made so if there is demand for it.
181 setting, though it could be made so if there is demand for it.
176
182
177 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
183 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
178
184
179 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
185 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
180
186
181 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
187 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
182
188
183 * IPython/genutils.py: Add 2.2 compatibility here, so all other
189 * IPython/genutils.py: Add 2.2 compatibility here, so all other
184 code can work transparently for 2.2/2.3.
190 code can work transparently for 2.2/2.3.
185
191
186 2005-07-16 Fernando Perez <fperez@colorado.edu>
192 2005-07-16 Fernando Perez <fperez@colorado.edu>
187
193
188 * IPython/ultraTB.py (ExceptionColors): Make a global variable
194 * IPython/ultraTB.py (ExceptionColors): Make a global variable
189 out of the color scheme table used for coloring exception
195 out of the color scheme table used for coloring exception
190 tracebacks. This allows user code to add new schemes at runtime.
196 tracebacks. This allows user code to add new schemes at runtime.
191 This is a minimally modified version of the patch at
197 This is a minimally modified version of the patch at
192 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
198 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
193 for the contribution.
199 for the contribution.
194
200
195 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
201 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
196 slightly modified version of the patch in
202 slightly modified version of the patch in
197 http://www.scipy.net/roundup/ipython/issue34, which also allows me
203 http://www.scipy.net/roundup/ipython/issue34, which also allows me
198 to remove the previous try/except solution (which was costlier).
204 to remove the previous try/except solution (which was costlier).
199 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
205 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
200
206
201 2005-06-08 Fernando Perez <fperez@colorado.edu>
207 2005-06-08 Fernando Perez <fperez@colorado.edu>
202
208
203 * IPython/iplib.py (write/write_err): Add methods to abstract all
209 * IPython/iplib.py (write/write_err): Add methods to abstract all
204 I/O a bit more.
210 I/O a bit more.
205
211
206 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
212 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
207 warning, reported by Aric Hagberg, fix by JD Hunter.
213 warning, reported by Aric Hagberg, fix by JD Hunter.
208
214
209 2005-06-02 *** Released version 0.6.15
215 2005-06-02 *** Released version 0.6.15
210
216
211 2005-06-01 Fernando Perez <fperez@colorado.edu>
217 2005-06-01 Fernando Perez <fperez@colorado.edu>
212
218
213 * IPython/iplib.py (MagicCompleter.file_matches): Fix
219 * IPython/iplib.py (MagicCompleter.file_matches): Fix
214 tab-completion of filenames within open-quoted strings. Note that
220 tab-completion of filenames within open-quoted strings. Note that
215 this requires that in ~/.ipython/ipythonrc, users change the
221 this requires that in ~/.ipython/ipythonrc, users change the
216 readline delimiters configuration to read:
222 readline delimiters configuration to read:
217
223
218 readline_remove_delims -/~
224 readline_remove_delims -/~
219
225
220
226
221 2005-05-31 *** Released version 0.6.14
227 2005-05-31 *** Released version 0.6.14
222
228
223 2005-05-29 Fernando Perez <fperez@colorado.edu>
229 2005-05-29 Fernando Perez <fperez@colorado.edu>
224
230
225 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
231 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
226 with files not on the filesystem. Reported by Eliyahu Sandler
232 with files not on the filesystem. Reported by Eliyahu Sandler
227 <eli@gondolin.net>
233 <eli@gondolin.net>
228
234
229 2005-05-22 Fernando Perez <fperez@colorado.edu>
235 2005-05-22 Fernando Perez <fperez@colorado.edu>
230
236
231 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
237 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
232 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
238 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
233
239
234 2005-05-19 Fernando Perez <fperez@colorado.edu>
240 2005-05-19 Fernando Perez <fperez@colorado.edu>
235
241
236 * IPython/iplib.py (safe_execfile): close a file which could be
242 * IPython/iplib.py (safe_execfile): close a file which could be
237 left open (causing problems in win32, which locks open files).
243 left open (causing problems in win32, which locks open files).
238 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
244 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
239
245
240 2005-05-18 Fernando Perez <fperez@colorado.edu>
246 2005-05-18 Fernando Perez <fperez@colorado.edu>
241
247
242 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
248 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
243 keyword arguments correctly to safe_execfile().
249 keyword arguments correctly to safe_execfile().
244
250
245 2005-05-13 Fernando Perez <fperez@colorado.edu>
251 2005-05-13 Fernando Perez <fperez@colorado.edu>
246
252
247 * ipython.1: Added info about Qt to manpage, and threads warning
253 * ipython.1: Added info about Qt to manpage, and threads warning
248 to usage page (invoked with --help).
254 to usage page (invoked with --help).
249
255
250 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
256 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
251 new matcher (it goes at the end of the priority list) to do
257 new matcher (it goes at the end of the priority list) to do
252 tab-completion on named function arguments. Submitted by George
258 tab-completion on named function arguments. Submitted by George
253 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
259 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
254 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
260 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
255 for more details.
261 for more details.
256
262
257 * IPython/Magic.py (magic_run): Added new -e flag to ignore
263 * IPython/Magic.py (magic_run): Added new -e flag to ignore
258 SystemExit exceptions in the script being run. Thanks to a report
264 SystemExit exceptions in the script being run. Thanks to a report
259 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
265 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
260 producing very annoying behavior when running unit tests.
266 producing very annoying behavior when running unit tests.
261
267
262 2005-05-12 Fernando Perez <fperez@colorado.edu>
268 2005-05-12 Fernando Perez <fperez@colorado.edu>
263
269
264 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
270 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
265 which I'd broken (again) due to a changed regexp. In the process,
271 which I'd broken (again) due to a changed regexp. In the process,
266 added ';' as an escape to auto-quote the whole line without
272 added ';' as an escape to auto-quote the whole line without
267 splitting its arguments. Thanks to a report by Jerry McRae
273 splitting its arguments. Thanks to a report by Jerry McRae
268 <qrs0xyc02-AT-sneakemail.com>.
274 <qrs0xyc02-AT-sneakemail.com>.
269
275
270 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
276 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
271 possible crashes caused by a TokenError. Reported by Ed Schofield
277 possible crashes caused by a TokenError. Reported by Ed Schofield
272 <schofield-AT-ftw.at>.
278 <schofield-AT-ftw.at>.
273
279
274 2005-05-06 Fernando Perez <fperez@colorado.edu>
280 2005-05-06 Fernando Perez <fperez@colorado.edu>
275
281
276 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
282 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
277
283
278 2005-04-29 Fernando Perez <fperez@colorado.edu>
284 2005-04-29 Fernando Perez <fperez@colorado.edu>
279
285
280 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
286 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
281 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
287 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
282 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
288 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
283 which provides support for Qt interactive usage (similar to the
289 which provides support for Qt interactive usage (similar to the
284 existing one for WX and GTK). This had been often requested.
290 existing one for WX and GTK). This had been often requested.
285
291
286 2005-04-14 *** Released version 0.6.13
292 2005-04-14 *** Released version 0.6.13
287
293
288 2005-04-08 Fernando Perez <fperez@colorado.edu>
294 2005-04-08 Fernando Perez <fperez@colorado.edu>
289
295
290 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
296 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
291 from _ofind, which gets called on almost every input line. Now,
297 from _ofind, which gets called on almost every input line. Now,
292 we only try to get docstrings if they are actually going to be
298 we only try to get docstrings if they are actually going to be
293 used (the overhead of fetching unnecessary docstrings can be
299 used (the overhead of fetching unnecessary docstrings can be
294 noticeable for certain objects, such as Pyro proxies).
300 noticeable for certain objects, such as Pyro proxies).
295
301
296 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
302 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
297 for completers. For some reason I had been passing them the state
303 for completers. For some reason I had been passing them the state
298 variable, which completers never actually need, and was in
304 variable, which completers never actually need, and was in
299 conflict with the rlcompleter API. Custom completers ONLY need to
305 conflict with the rlcompleter API. Custom completers ONLY need to
300 take the text parameter.
306 take the text parameter.
301
307
302 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
308 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
303 work correctly in pysh. I've also moved all the logic which used
309 work correctly in pysh. I've also moved all the logic which used
304 to be in pysh.py here, which will prevent problems with future
310 to be in pysh.py here, which will prevent problems with future
305 upgrades. However, this time I must warn users to update their
311 upgrades. However, this time I must warn users to update their
306 pysh profile to include the line
312 pysh profile to include the line
307
313
308 import_all IPython.Extensions.InterpreterExec
314 import_all IPython.Extensions.InterpreterExec
309
315
310 because otherwise things won't work for them. They MUST also
316 because otherwise things won't work for them. They MUST also
311 delete pysh.py and the line
317 delete pysh.py and the line
312
318
313 execfile pysh.py
319 execfile pysh.py
314
320
315 from their ipythonrc-pysh.
321 from their ipythonrc-pysh.
316
322
317 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
323 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
318 robust in the face of objects whose dir() returns non-strings
324 robust in the face of objects whose dir() returns non-strings
319 (which it shouldn't, but some broken libs like ITK do). Thanks to
325 (which it shouldn't, but some broken libs like ITK do). Thanks to
320 a patch by John Hunter (implemented differently, though). Also
326 a patch by John Hunter (implemented differently, though). Also
321 minor improvements by using .extend instead of + on lists.
327 minor improvements by using .extend instead of + on lists.
322
328
323 * pysh.py:
329 * pysh.py:
324
330
325 2005-04-06 Fernando Perez <fperez@colorado.edu>
331 2005-04-06 Fernando Perez <fperez@colorado.edu>
326
332
327 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
333 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
328 by default, so that all users benefit from it. Those who don't
334 by default, so that all users benefit from it. Those who don't
329 want it can still turn it off.
335 want it can still turn it off.
330
336
331 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
337 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
332 config file, I'd forgotten about this, so users were getting it
338 config file, I'd forgotten about this, so users were getting it
333 off by default.
339 off by default.
334
340
335 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
341 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
336 consistency. Now magics can be called in multiline statements,
342 consistency. Now magics can be called in multiline statements,
337 and python variables can be expanded in magic calls via $var.
343 and python variables can be expanded in magic calls via $var.
338 This makes the magic system behave just like aliases or !system
344 This makes the magic system behave just like aliases or !system
339 calls.
345 calls.
340
346
341 2005-03-28 Fernando Perez <fperez@colorado.edu>
347 2005-03-28 Fernando Perez <fperez@colorado.edu>
342
348
343 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
349 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
344 expensive string additions for building command. Add support for
350 expensive string additions for building command. Add support for
345 trailing ';' when autocall is used.
351 trailing ';' when autocall is used.
346
352
347 2005-03-26 Fernando Perez <fperez@colorado.edu>
353 2005-03-26 Fernando Perez <fperez@colorado.edu>
348
354
349 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
355 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
350 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
356 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
351 ipython.el robust against prompts with any number of spaces
357 ipython.el robust against prompts with any number of spaces
352 (including 0) after the ':' character.
358 (including 0) after the ':' character.
353
359
354 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
360 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
355 continuation prompt, which misled users to think the line was
361 continuation prompt, which misled users to think the line was
356 already indented. Closes debian Bug#300847, reported to me by
362 already indented. Closes debian Bug#300847, reported to me by
357 Norbert Tretkowski <tretkowski-AT-inittab.de>.
363 Norbert Tretkowski <tretkowski-AT-inittab.de>.
358
364
359 2005-03-23 Fernando Perez <fperez@colorado.edu>
365 2005-03-23 Fernando Perez <fperez@colorado.edu>
360
366
361 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
367 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
362 properly aligned if they have embedded newlines.
368 properly aligned if they have embedded newlines.
363
369
364 * IPython/iplib.py (runlines): Add a public method to expose
370 * IPython/iplib.py (runlines): Add a public method to expose
365 IPython's code execution machinery, so that users can run strings
371 IPython's code execution machinery, so that users can run strings
366 as if they had been typed at the prompt interactively.
372 as if they had been typed at the prompt interactively.
367 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
373 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
368 methods which can call the system shell, but with python variable
374 methods which can call the system shell, but with python variable
369 expansion. The three such methods are: __IPYTHON__.system,
375 expansion. The three such methods are: __IPYTHON__.system,
370 .getoutput and .getoutputerror. These need to be documented in a
376 .getoutput and .getoutputerror. These need to be documented in a
371 'public API' section (to be written) of the manual.
377 'public API' section (to be written) of the manual.
372
378
373 2005-03-20 Fernando Perez <fperez@colorado.edu>
379 2005-03-20 Fernando Perez <fperez@colorado.edu>
374
380
375 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
381 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
376 for custom exception handling. This is quite powerful, and it
382 for custom exception handling. This is quite powerful, and it
377 allows for user-installable exception handlers which can trap
383 allows for user-installable exception handlers which can trap
378 custom exceptions at runtime and treat them separately from
384 custom exceptions at runtime and treat them separately from
379 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
385 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
380 Mantegazza <mantegazza-AT-ill.fr>.
386 Mantegazza <mantegazza-AT-ill.fr>.
381 (InteractiveShell.set_custom_completer): public API function to
387 (InteractiveShell.set_custom_completer): public API function to
382 add new completers at runtime.
388 add new completers at runtime.
383
389
384 2005-03-19 Fernando Perez <fperez@colorado.edu>
390 2005-03-19 Fernando Perez <fperez@colorado.edu>
385
391
386 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
392 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
387 allow objects which provide their docstrings via non-standard
393 allow objects which provide their docstrings via non-standard
388 mechanisms (like Pyro proxies) to still be inspected by ipython's
394 mechanisms (like Pyro proxies) to still be inspected by ipython's
389 ? system.
395 ? system.
390
396
391 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
397 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
392 automatic capture system. I tried quite hard to make it work
398 automatic capture system. I tried quite hard to make it work
393 reliably, and simply failed. I tried many combinations with the
399 reliably, and simply failed. I tried many combinations with the
394 subprocess module, but eventually nothing worked in all needed
400 subprocess module, but eventually nothing worked in all needed
395 cases (not blocking stdin for the child, duplicating stdout
401 cases (not blocking stdin for the child, duplicating stdout
396 without blocking, etc). The new %sc/%sx still do capture to these
402 without blocking, etc). The new %sc/%sx still do capture to these
397 magical list/string objects which make shell use much more
403 magical list/string objects which make shell use much more
398 conveninent, so not all is lost.
404 conveninent, so not all is lost.
399
405
400 XXX - FIX MANUAL for the change above!
406 XXX - FIX MANUAL for the change above!
401
407
402 (runsource): I copied code.py's runsource() into ipython to modify
408 (runsource): I copied code.py's runsource() into ipython to modify
403 it a bit. Now the code object and source to be executed are
409 it a bit. Now the code object and source to be executed are
404 stored in ipython. This makes this info accessible to third-party
410 stored in ipython. This makes this info accessible to third-party
405 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
411 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
406 Mantegazza <mantegazza-AT-ill.fr>.
412 Mantegazza <mantegazza-AT-ill.fr>.
407
413
408 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
414 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
409 history-search via readline (like C-p/C-n). I'd wanted this for a
415 history-search via readline (like C-p/C-n). I'd wanted this for a
410 long time, but only recently found out how to do it. For users
416 long time, but only recently found out how to do it. For users
411 who already have their ipythonrc files made and want this, just
417 who already have their ipythonrc files made and want this, just
412 add:
418 add:
413
419
414 readline_parse_and_bind "\e[A": history-search-backward
420 readline_parse_and_bind "\e[A": history-search-backward
415 readline_parse_and_bind "\e[B": history-search-forward
421 readline_parse_and_bind "\e[B": history-search-forward
416
422
417 2005-03-18 Fernando Perez <fperez@colorado.edu>
423 2005-03-18 Fernando Perez <fperez@colorado.edu>
418
424
419 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
425 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
420 LSString and SList classes which allow transparent conversions
426 LSString and SList classes which allow transparent conversions
421 between list mode and whitespace-separated string.
427 between list mode and whitespace-separated string.
422 (magic_r): Fix recursion problem in %r.
428 (magic_r): Fix recursion problem in %r.
423
429
424 * IPython/genutils.py (LSString): New class to be used for
430 * IPython/genutils.py (LSString): New class to be used for
425 automatic storage of the results of all alias/system calls in _o
431 automatic storage of the results of all alias/system calls in _o
426 and _e (stdout/err). These provide a .l/.list attribute which
432 and _e (stdout/err). These provide a .l/.list attribute which
427 does automatic splitting on newlines. This means that for most
433 does automatic splitting on newlines. This means that for most
428 uses, you'll never need to do capturing of output with %sc/%sx
434 uses, you'll never need to do capturing of output with %sc/%sx
429 anymore, since ipython keeps this always done for you. Note that
435 anymore, since ipython keeps this always done for you. Note that
430 only the LAST results are stored, the _o/e variables are
436 only the LAST results are stored, the _o/e variables are
431 overwritten on each call. If you need to save their contents
437 overwritten on each call. If you need to save their contents
432 further, simply bind them to any other name.
438 further, simply bind them to any other name.
433
439
434 2005-03-17 Fernando Perez <fperez@colorado.edu>
440 2005-03-17 Fernando Perez <fperez@colorado.edu>
435
441
436 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
442 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
437 prompt namespace handling.
443 prompt namespace handling.
438
444
439 2005-03-16 Fernando Perez <fperez@colorado.edu>
445 2005-03-16 Fernando Perez <fperez@colorado.edu>
440
446
441 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
447 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
442 classic prompts to be '>>> ' (final space was missing, and it
448 classic prompts to be '>>> ' (final space was missing, and it
443 trips the emacs python mode).
449 trips the emacs python mode).
444 (BasePrompt.__str__): Added safe support for dynamic prompt
450 (BasePrompt.__str__): Added safe support for dynamic prompt
445 strings. Now you can set your prompt string to be '$x', and the
451 strings. Now you can set your prompt string to be '$x', and the
446 value of x will be printed from your interactive namespace. The
452 value of x will be printed from your interactive namespace. The
447 interpolation syntax includes the full Itpl support, so
453 interpolation syntax includes the full Itpl support, so
448 ${foo()+x+bar()} is a valid prompt string now, and the function
454 ${foo()+x+bar()} is a valid prompt string now, and the function
449 calls will be made at runtime.
455 calls will be made at runtime.
450
456
451 2005-03-15 Fernando Perez <fperez@colorado.edu>
457 2005-03-15 Fernando Perez <fperez@colorado.edu>
452
458
453 * IPython/Magic.py (magic_history): renamed %hist to %history, to
459 * IPython/Magic.py (magic_history): renamed %hist to %history, to
454 avoid name clashes in pylab. %hist still works, it just forwards
460 avoid name clashes in pylab. %hist still works, it just forwards
455 the call to %history.
461 the call to %history.
456
462
457 2005-03-02 *** Released version 0.6.12
463 2005-03-02 *** Released version 0.6.12
458
464
459 2005-03-02 Fernando Perez <fperez@colorado.edu>
465 2005-03-02 Fernando Perez <fperez@colorado.edu>
460
466
461 * IPython/iplib.py (handle_magic): log magic calls properly as
467 * IPython/iplib.py (handle_magic): log magic calls properly as
462 ipmagic() function calls.
468 ipmagic() function calls.
463
469
464 * IPython/Magic.py (magic_time): Improved %time to support
470 * IPython/Magic.py (magic_time): Improved %time to support
465 statements and provide wall-clock as well as CPU time.
471 statements and provide wall-clock as well as CPU time.
466
472
467 2005-02-27 Fernando Perez <fperez@colorado.edu>
473 2005-02-27 Fernando Perez <fperez@colorado.edu>
468
474
469 * IPython/hooks.py: New hooks module, to expose user-modifiable
475 * IPython/hooks.py: New hooks module, to expose user-modifiable
470 IPython functionality in a clean manner. For now only the editor
476 IPython functionality in a clean manner. For now only the editor
471 hook is actually written, and other thigns which I intend to turn
477 hook is actually written, and other thigns which I intend to turn
472 into proper hooks aren't yet there. The display and prefilter
478 into proper hooks aren't yet there. The display and prefilter
473 stuff, for example, should be hooks. But at least now the
479 stuff, for example, should be hooks. But at least now the
474 framework is in place, and the rest can be moved here with more
480 framework is in place, and the rest can be moved here with more
475 time later. IPython had had a .hooks variable for a long time for
481 time later. IPython had had a .hooks variable for a long time for
476 this purpose, but I'd never actually used it for anything.
482 this purpose, but I'd never actually used it for anything.
477
483
478 2005-02-26 Fernando Perez <fperez@colorado.edu>
484 2005-02-26 Fernando Perez <fperez@colorado.edu>
479
485
480 * IPython/ipmaker.py (make_IPython): make the default ipython
486 * IPython/ipmaker.py (make_IPython): make the default ipython
481 directory be called _ipython under win32, to follow more the
487 directory be called _ipython under win32, to follow more the
482 naming peculiarities of that platform (where buggy software like
488 naming peculiarities of that platform (where buggy software like
483 Visual Sourcesafe breaks with .named directories). Reported by
489 Visual Sourcesafe breaks with .named directories). Reported by
484 Ville Vainio.
490 Ville Vainio.
485
491
486 2005-02-23 Fernando Perez <fperez@colorado.edu>
492 2005-02-23 Fernando Perez <fperez@colorado.edu>
487
493
488 * IPython/iplib.py (InteractiveShell.__init__): removed a few
494 * IPython/iplib.py (InteractiveShell.__init__): removed a few
489 auto_aliases for win32 which were causing problems. Users can
495 auto_aliases for win32 which were causing problems. Users can
490 define the ones they personally like.
496 define the ones they personally like.
491
497
492 2005-02-21 Fernando Perez <fperez@colorado.edu>
498 2005-02-21 Fernando Perez <fperez@colorado.edu>
493
499
494 * IPython/Magic.py (magic_time): new magic to time execution of
500 * IPython/Magic.py (magic_time): new magic to time execution of
495 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
501 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
496
502
497 2005-02-19 Fernando Perez <fperez@colorado.edu>
503 2005-02-19 Fernando Perez <fperez@colorado.edu>
498
504
499 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
505 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
500 into keys (for prompts, for example).
506 into keys (for prompts, for example).
501
507
502 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
508 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
503 prompts in case users want them. This introduces a small behavior
509 prompts in case users want them. This introduces a small behavior
504 change: ipython does not automatically add a space to all prompts
510 change: ipython does not automatically add a space to all prompts
505 anymore. To get the old prompts with a space, users should add it
511 anymore. To get the old prompts with a space, users should add it
506 manually to their ipythonrc file, so for example prompt_in1 should
512 manually to their ipythonrc file, so for example prompt_in1 should
507 now read 'In [\#]: ' instead of 'In [\#]:'.
513 now read 'In [\#]: ' instead of 'In [\#]:'.
508 (BasePrompt.__init__): New option prompts_pad_left (only in rc
514 (BasePrompt.__init__): New option prompts_pad_left (only in rc
509 file) to control left-padding of secondary prompts.
515 file) to control left-padding of secondary prompts.
510
516
511 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
517 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
512 the profiler can't be imported. Fix for Debian, which removed
518 the profiler can't be imported. Fix for Debian, which removed
513 profile.py because of License issues. I applied a slightly
519 profile.py because of License issues. I applied a slightly
514 modified version of the original Debian patch at
520 modified version of the original Debian patch at
515 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
521 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
516
522
517 2005-02-17 Fernando Perez <fperez@colorado.edu>
523 2005-02-17 Fernando Perez <fperez@colorado.edu>
518
524
519 * IPython/genutils.py (native_line_ends): Fix bug which would
525 * IPython/genutils.py (native_line_ends): Fix bug which would
520 cause improper line-ends under win32 b/c I was not opening files
526 cause improper line-ends under win32 b/c I was not opening files
521 in binary mode. Bug report and fix thanks to Ville.
527 in binary mode. Bug report and fix thanks to Ville.
522
528
523 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
529 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
524 trying to catch spurious foo[1] autocalls. My fix actually broke
530 trying to catch spurious foo[1] autocalls. My fix actually broke
525 ',/' autoquote/call with explicit escape (bad regexp).
531 ',/' autoquote/call with explicit escape (bad regexp).
526
532
527 2005-02-15 *** Released version 0.6.11
533 2005-02-15 *** Released version 0.6.11
528
534
529 2005-02-14 Fernando Perez <fperez@colorado.edu>
535 2005-02-14 Fernando Perez <fperez@colorado.edu>
530
536
531 * IPython/background_jobs.py: New background job management
537 * IPython/background_jobs.py: New background job management
532 subsystem. This is implemented via a new set of classes, and
538 subsystem. This is implemented via a new set of classes, and
533 IPython now provides a builtin 'jobs' object for background job
539 IPython now provides a builtin 'jobs' object for background job
534 execution. A convenience %bg magic serves as a lightweight
540 execution. A convenience %bg magic serves as a lightweight
535 frontend for starting the more common type of calls. This was
541 frontend for starting the more common type of calls. This was
536 inspired by discussions with B. Granger and the BackgroundCommand
542 inspired by discussions with B. Granger and the BackgroundCommand
537 class described in the book Python Scripting for Computational
543 class described in the book Python Scripting for Computational
538 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
544 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
539 (although ultimately no code from this text was used, as IPython's
545 (although ultimately no code from this text was used, as IPython's
540 system is a separate implementation).
546 system is a separate implementation).
541
547
542 * IPython/iplib.py (MagicCompleter.python_matches): add new option
548 * IPython/iplib.py (MagicCompleter.python_matches): add new option
543 to control the completion of single/double underscore names
549 to control the completion of single/double underscore names
544 separately. As documented in the example ipytonrc file, the
550 separately. As documented in the example ipytonrc file, the
545 readline_omit__names variable can now be set to 2, to omit even
551 readline_omit__names variable can now be set to 2, to omit even
546 single underscore names. Thanks to a patch by Brian Wong
552 single underscore names. Thanks to a patch by Brian Wong
547 <BrianWong-AT-AirgoNetworks.Com>.
553 <BrianWong-AT-AirgoNetworks.Com>.
548 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
554 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
549 be autocalled as foo([1]) if foo were callable. A problem for
555 be autocalled as foo([1]) if foo were callable. A problem for
550 things which are both callable and implement __getitem__.
556 things which are both callable and implement __getitem__.
551 (init_readline): Fix autoindentation for win32. Thanks to a patch
557 (init_readline): Fix autoindentation for win32. Thanks to a patch
552 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
558 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
553
559
554 2005-02-12 Fernando Perez <fperez@colorado.edu>
560 2005-02-12 Fernando Perez <fperez@colorado.edu>
555
561
556 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
562 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
557 which I had written long ago to sort out user error messages which
563 which I had written long ago to sort out user error messages which
558 may occur during startup. This seemed like a good idea initially,
564 may occur during startup. This seemed like a good idea initially,
559 but it has proven a disaster in retrospect. I don't want to
565 but it has proven a disaster in retrospect. I don't want to
560 change much code for now, so my fix is to set the internal 'debug'
566 change much code for now, so my fix is to set the internal 'debug'
561 flag to true everywhere, whose only job was precisely to control
567 flag to true everywhere, whose only job was precisely to control
562 this subsystem. This closes issue 28 (as well as avoiding all
568 this subsystem. This closes issue 28 (as well as avoiding all
563 sorts of strange hangups which occur from time to time).
569 sorts of strange hangups which occur from time to time).
564
570
565 2005-02-07 Fernando Perez <fperez@colorado.edu>
571 2005-02-07 Fernando Perez <fperez@colorado.edu>
566
572
567 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
573 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
568 previous call produced a syntax error.
574 previous call produced a syntax error.
569
575
570 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
576 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
571 classes without constructor.
577 classes without constructor.
572
578
573 2005-02-06 Fernando Perez <fperez@colorado.edu>
579 2005-02-06 Fernando Perez <fperez@colorado.edu>
574
580
575 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
581 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
576 completions with the results of each matcher, so we return results
582 completions with the results of each matcher, so we return results
577 to the user from all namespaces. This breaks with ipython
583 to the user from all namespaces. This breaks with ipython
578 tradition, but I think it's a nicer behavior. Now you get all
584 tradition, but I think it's a nicer behavior. Now you get all
579 possible completions listed, from all possible namespaces (python,
585 possible completions listed, from all possible namespaces (python,
580 filesystem, magics...) After a request by John Hunter
586 filesystem, magics...) After a request by John Hunter
581 <jdhunter-AT-nitace.bsd.uchicago.edu>.
587 <jdhunter-AT-nitace.bsd.uchicago.edu>.
582
588
583 2005-02-05 Fernando Perez <fperez@colorado.edu>
589 2005-02-05 Fernando Perez <fperez@colorado.edu>
584
590
585 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
591 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
586 the call had quote characters in it (the quotes were stripped).
592 the call had quote characters in it (the quotes were stripped).
587
593
588 2005-01-31 Fernando Perez <fperez@colorado.edu>
594 2005-01-31 Fernando Perez <fperez@colorado.edu>
589
595
590 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
596 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
591 Itpl.itpl() to make the code more robust against psyco
597 Itpl.itpl() to make the code more robust against psyco
592 optimizations.
598 optimizations.
593
599
594 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
600 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
595 of causing an exception. Quicker, cleaner.
601 of causing an exception. Quicker, cleaner.
596
602
597 2005-01-28 Fernando Perez <fperez@colorado.edu>
603 2005-01-28 Fernando Perez <fperez@colorado.edu>
598
604
599 * scripts/ipython_win_post_install.py (install): hardcode
605 * scripts/ipython_win_post_install.py (install): hardcode
600 sys.prefix+'python.exe' as the executable path. It turns out that
606 sys.prefix+'python.exe' as the executable path. It turns out that
601 during the post-installation run, sys.executable resolves to the
607 during the post-installation run, sys.executable resolves to the
602 name of the binary installer! I should report this as a distutils
608 name of the binary installer! I should report this as a distutils
603 bug, I think. I updated the .10 release with this tiny fix, to
609 bug, I think. I updated the .10 release with this tiny fix, to
604 avoid annoying the lists further.
610 avoid annoying the lists further.
605
611
606 2005-01-27 *** Released version 0.6.10
612 2005-01-27 *** Released version 0.6.10
607
613
608 2005-01-27 Fernando Perez <fperez@colorado.edu>
614 2005-01-27 Fernando Perez <fperez@colorado.edu>
609
615
610 * IPython/numutils.py (norm): Added 'inf' as optional name for
616 * IPython/numutils.py (norm): Added 'inf' as optional name for
611 L-infinity norm, included references to mathworld.com for vector
617 L-infinity norm, included references to mathworld.com for vector
612 norm definitions.
618 norm definitions.
613 (amin/amax): added amin/amax for array min/max. Similar to what
619 (amin/amax): added amin/amax for array min/max. Similar to what
614 pylab ships with after the recent reorganization of names.
620 pylab ships with after the recent reorganization of names.
615 (spike/spike_odd): removed deprecated spike/spike_odd functions.
621 (spike/spike_odd): removed deprecated spike/spike_odd functions.
616
622
617 * ipython.el: committed Alex's recent fixes and improvements.
623 * ipython.el: committed Alex's recent fixes and improvements.
618 Tested with python-mode from CVS, and it looks excellent. Since
624 Tested with python-mode from CVS, and it looks excellent. Since
619 python-mode hasn't released anything in a while, I'm temporarily
625 python-mode hasn't released anything in a while, I'm temporarily
620 putting a copy of today's CVS (v 4.70) of python-mode in:
626 putting a copy of today's CVS (v 4.70) of python-mode in:
621 http://ipython.scipy.org/tmp/python-mode.el
627 http://ipython.scipy.org/tmp/python-mode.el
622
628
623 * scripts/ipython_win_post_install.py (install): Win32 fix to use
629 * scripts/ipython_win_post_install.py (install): Win32 fix to use
624 sys.executable for the executable name, instead of assuming it's
630 sys.executable for the executable name, instead of assuming it's
625 called 'python.exe' (the post-installer would have produced broken
631 called 'python.exe' (the post-installer would have produced broken
626 setups on systems with a differently named python binary).
632 setups on systems with a differently named python binary).
627
633
628 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
634 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
629 references to os.linesep, to make the code more
635 references to os.linesep, to make the code more
630 platform-independent. This is also part of the win32 coloring
636 platform-independent. This is also part of the win32 coloring
631 fixes.
637 fixes.
632
638
633 * IPython/genutils.py (page_dumb): Remove attempts to chop long
639 * IPython/genutils.py (page_dumb): Remove attempts to chop long
634 lines, which actually cause coloring bugs because the length of
640 lines, which actually cause coloring bugs because the length of
635 the line is very difficult to correctly compute with embedded
641 the line is very difficult to correctly compute with embedded
636 escapes. This was the source of all the coloring problems under
642 escapes. This was the source of all the coloring problems under
637 Win32. I think that _finally_, Win32 users have a properly
643 Win32. I think that _finally_, Win32 users have a properly
638 working ipython in all respects. This would never have happened
644 working ipython in all respects. This would never have happened
639 if not for Gary Bishop and Viktor Ransmayr's great help and work.
645 if not for Gary Bishop and Viktor Ransmayr's great help and work.
640
646
641 2005-01-26 *** Released version 0.6.9
647 2005-01-26 *** Released version 0.6.9
642
648
643 2005-01-25 Fernando Perez <fperez@colorado.edu>
649 2005-01-25 Fernando Perez <fperez@colorado.edu>
644
650
645 * setup.py: finally, we have a true Windows installer, thanks to
651 * setup.py: finally, we have a true Windows installer, thanks to
646 the excellent work of Viktor Ransmayr
652 the excellent work of Viktor Ransmayr
647 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
653 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
648 Windows users. The setup routine is quite a bit cleaner thanks to
654 Windows users. The setup routine is quite a bit cleaner thanks to
649 this, and the post-install script uses the proper functions to
655 this, and the post-install script uses the proper functions to
650 allow a clean de-installation using the standard Windows Control
656 allow a clean de-installation using the standard Windows Control
651 Panel.
657 Panel.
652
658
653 * IPython/genutils.py (get_home_dir): changed to use the $HOME
659 * IPython/genutils.py (get_home_dir): changed to use the $HOME
654 environment variable under all OSes (including win32) if
660 environment variable under all OSes (including win32) if
655 available. This will give consistency to win32 users who have set
661 available. This will give consistency to win32 users who have set
656 this variable for any reason. If os.environ['HOME'] fails, the
662 this variable for any reason. If os.environ['HOME'] fails, the
657 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
663 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
658
664
659 2005-01-24 Fernando Perez <fperez@colorado.edu>
665 2005-01-24 Fernando Perez <fperez@colorado.edu>
660
666
661 * IPython/numutils.py (empty_like): add empty_like(), similar to
667 * IPython/numutils.py (empty_like): add empty_like(), similar to
662 zeros_like() but taking advantage of the new empty() Numeric routine.
668 zeros_like() but taking advantage of the new empty() Numeric routine.
663
669
664 2005-01-23 *** Released version 0.6.8
670 2005-01-23 *** Released version 0.6.8
665
671
666 2005-01-22 Fernando Perez <fperez@colorado.edu>
672 2005-01-22 Fernando Perez <fperez@colorado.edu>
667
673
668 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
674 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
669 automatic show() calls. After discussing things with JDH, it
675 automatic show() calls. After discussing things with JDH, it
670 turns out there are too many corner cases where this can go wrong.
676 turns out there are too many corner cases where this can go wrong.
671 It's best not to try to be 'too smart', and simply have ipython
677 It's best not to try to be 'too smart', and simply have ipython
672 reproduce as much as possible the default behavior of a normal
678 reproduce as much as possible the default behavior of a normal
673 python shell.
679 python shell.
674
680
675 * IPython/iplib.py (InteractiveShell.__init__): Modified the
681 * IPython/iplib.py (InteractiveShell.__init__): Modified the
676 line-splitting regexp and _prefilter() to avoid calling getattr()
682 line-splitting regexp and _prefilter() to avoid calling getattr()
677 on assignments. This closes
683 on assignments. This closes
678 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
684 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
679 readline uses getattr(), so a simple <TAB> keypress is still
685 readline uses getattr(), so a simple <TAB> keypress is still
680 enough to trigger getattr() calls on an object.
686 enough to trigger getattr() calls on an object.
681
687
682 2005-01-21 Fernando Perez <fperez@colorado.edu>
688 2005-01-21 Fernando Perez <fperez@colorado.edu>
683
689
684 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
690 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
685 docstring under pylab so it doesn't mask the original.
691 docstring under pylab so it doesn't mask the original.
686
692
687 2005-01-21 *** Released version 0.6.7
693 2005-01-21 *** Released version 0.6.7
688
694
689 2005-01-21 Fernando Perez <fperez@colorado.edu>
695 2005-01-21 Fernando Perez <fperez@colorado.edu>
690
696
691 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
697 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
692 signal handling for win32 users in multithreaded mode.
698 signal handling for win32 users in multithreaded mode.
693
699
694 2005-01-17 Fernando Perez <fperez@colorado.edu>
700 2005-01-17 Fernando Perez <fperez@colorado.edu>
695
701
696 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
702 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
697 instances with no __init__. After a crash report by Norbert Nemec
703 instances with no __init__. After a crash report by Norbert Nemec
698 <Norbert-AT-nemec-online.de>.
704 <Norbert-AT-nemec-online.de>.
699
705
700 2005-01-14 Fernando Perez <fperez@colorado.edu>
706 2005-01-14 Fernando Perez <fperez@colorado.edu>
701
707
702 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
708 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
703 names for verbose exceptions, when multiple dotted names and the
709 names for verbose exceptions, when multiple dotted names and the
704 'parent' object were present on the same line.
710 'parent' object were present on the same line.
705
711
706 2005-01-11 Fernando Perez <fperez@colorado.edu>
712 2005-01-11 Fernando Perez <fperez@colorado.edu>
707
713
708 * IPython/genutils.py (flag_calls): new utility to trap and flag
714 * IPython/genutils.py (flag_calls): new utility to trap and flag
709 calls in functions. I need it to clean up matplotlib support.
715 calls in functions. I need it to clean up matplotlib support.
710 Also removed some deprecated code in genutils.
716 Also removed some deprecated code in genutils.
711
717
712 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
718 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
713 that matplotlib scripts called with %run, which don't call show()
719 that matplotlib scripts called with %run, which don't call show()
714 themselves, still have their plotting windows open.
720 themselves, still have their plotting windows open.
715
721
716 2005-01-05 Fernando Perez <fperez@colorado.edu>
722 2005-01-05 Fernando Perez <fperez@colorado.edu>
717
723
718 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
724 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
719 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
725 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
720
726
721 2004-12-19 Fernando Perez <fperez@colorado.edu>
727 2004-12-19 Fernando Perez <fperez@colorado.edu>
722
728
723 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
729 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
724 parent_runcode, which was an eyesore. The same result can be
730 parent_runcode, which was an eyesore. The same result can be
725 obtained with Python's regular superclass mechanisms.
731 obtained with Python's regular superclass mechanisms.
726
732
727 2004-12-17 Fernando Perez <fperez@colorado.edu>
733 2004-12-17 Fernando Perez <fperez@colorado.edu>
728
734
729 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
735 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
730 reported by Prabhu.
736 reported by Prabhu.
731 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
737 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
732 sys.stderr) instead of explicitly calling sys.stderr. This helps
738 sys.stderr) instead of explicitly calling sys.stderr. This helps
733 maintain our I/O abstractions clean, for future GUI embeddings.
739 maintain our I/O abstractions clean, for future GUI embeddings.
734
740
735 * IPython/genutils.py (info): added new utility for sys.stderr
741 * IPython/genutils.py (info): added new utility for sys.stderr
736 unified info message handling (thin wrapper around warn()).
742 unified info message handling (thin wrapper around warn()).
737
743
738 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
744 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
739 composite (dotted) names on verbose exceptions.
745 composite (dotted) names on verbose exceptions.
740 (VerboseTB.nullrepr): harden against another kind of errors which
746 (VerboseTB.nullrepr): harden against another kind of errors which
741 Python's inspect module can trigger, and which were crashing
747 Python's inspect module can trigger, and which were crashing
742 IPython. Thanks to a report by Marco Lombardi
748 IPython. Thanks to a report by Marco Lombardi
743 <mlombard-AT-ma010192.hq.eso.org>.
749 <mlombard-AT-ma010192.hq.eso.org>.
744
750
745 2004-12-13 *** Released version 0.6.6
751 2004-12-13 *** Released version 0.6.6
746
752
747 2004-12-12 Fernando Perez <fperez@colorado.edu>
753 2004-12-12 Fernando Perez <fperez@colorado.edu>
748
754
749 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
755 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
750 generated by pygtk upon initialization if it was built without
756 generated by pygtk upon initialization if it was built without
751 threads (for matplotlib users). After a crash reported by
757 threads (for matplotlib users). After a crash reported by
752 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
758 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
753
759
754 * IPython/ipmaker.py (make_IPython): fix small bug in the
760 * IPython/ipmaker.py (make_IPython): fix small bug in the
755 import_some parameter for multiple imports.
761 import_some parameter for multiple imports.
756
762
757 * IPython/iplib.py (ipmagic): simplified the interface of
763 * IPython/iplib.py (ipmagic): simplified the interface of
758 ipmagic() to take a single string argument, just as it would be
764 ipmagic() to take a single string argument, just as it would be
759 typed at the IPython cmd line.
765 typed at the IPython cmd line.
760 (ipalias): Added new ipalias() with an interface identical to
766 (ipalias): Added new ipalias() with an interface identical to
761 ipmagic(). This completes exposing a pure python interface to the
767 ipmagic(). This completes exposing a pure python interface to the
762 alias and magic system, which can be used in loops or more complex
768 alias and magic system, which can be used in loops or more complex
763 code where IPython's automatic line mangling is not active.
769 code where IPython's automatic line mangling is not active.
764
770
765 * IPython/genutils.py (timing): changed interface of timing to
771 * IPython/genutils.py (timing): changed interface of timing to
766 simply run code once, which is the most common case. timings()
772 simply run code once, which is the most common case. timings()
767 remains unchanged, for the cases where you want multiple runs.
773 remains unchanged, for the cases where you want multiple runs.
768
774
769 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
775 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
770 bug where Python2.2 crashes with exec'ing code which does not end
776 bug where Python2.2 crashes with exec'ing code which does not end
771 in a single newline. Python 2.3 is OK, so I hadn't noticed this
777 in a single newline. Python 2.3 is OK, so I hadn't noticed this
772 before.
778 before.
773
779
774 2004-12-10 Fernando Perez <fperez@colorado.edu>
780 2004-12-10 Fernando Perez <fperez@colorado.edu>
775
781
776 * IPython/Magic.py (Magic.magic_prun): changed name of option from
782 * IPython/Magic.py (Magic.magic_prun): changed name of option from
777 -t to -T, to accomodate the new -t flag in %run (the %run and
783 -t to -T, to accomodate the new -t flag in %run (the %run and
778 %prun options are kind of intermixed, and it's not easy to change
784 %prun options are kind of intermixed, and it's not easy to change
779 this with the limitations of python's getopt).
785 this with the limitations of python's getopt).
780
786
781 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
787 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
782 the execution of scripts. It's not as fine-tuned as timeit.py,
788 the execution of scripts. It's not as fine-tuned as timeit.py,
783 but it works from inside ipython (and under 2.2, which lacks
789 but it works from inside ipython (and under 2.2, which lacks
784 timeit.py). Optionally a number of runs > 1 can be given for
790 timeit.py). Optionally a number of runs > 1 can be given for
785 timing very short-running code.
791 timing very short-running code.
786
792
787 * IPython/genutils.py (uniq_stable): new routine which returns a
793 * IPython/genutils.py (uniq_stable): new routine which returns a
788 list of unique elements in any iterable, but in stable order of
794 list of unique elements in any iterable, but in stable order of
789 appearance. I needed this for the ultraTB fixes, and it's a handy
795 appearance. I needed this for the ultraTB fixes, and it's a handy
790 utility.
796 utility.
791
797
792 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
798 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
793 dotted names in Verbose exceptions. This had been broken since
799 dotted names in Verbose exceptions. This had been broken since
794 the very start, now x.y will properly be printed in a Verbose
800 the very start, now x.y will properly be printed in a Verbose
795 traceback, instead of x being shown and y appearing always as an
801 traceback, instead of x being shown and y appearing always as an
796 'undefined global'. Getting this to work was a bit tricky,
802 'undefined global'. Getting this to work was a bit tricky,
797 because by default python tokenizers are stateless. Saved by
803 because by default python tokenizers are stateless. Saved by
798 python's ability to easily add a bit of state to an arbitrary
804 python's ability to easily add a bit of state to an arbitrary
799 function (without needing to build a full-blown callable object).
805 function (without needing to build a full-blown callable object).
800
806
801 Also big cleanup of this code, which had horrendous runtime
807 Also big cleanup of this code, which had horrendous runtime
802 lookups of zillions of attributes for colorization. Moved all
808 lookups of zillions of attributes for colorization. Moved all
803 this code into a few templates, which make it cleaner and quicker.
809 this code into a few templates, which make it cleaner and quicker.
804
810
805 Printout quality was also improved for Verbose exceptions: one
811 Printout quality was also improved for Verbose exceptions: one
806 variable per line, and memory addresses are printed (this can be
812 variable per line, and memory addresses are printed (this can be
807 quite handy in nasty debugging situations, which is what Verbose
813 quite handy in nasty debugging situations, which is what Verbose
808 is for).
814 is for).
809
815
810 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
816 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
811 the command line as scripts to be loaded by embedded instances.
817 the command line as scripts to be loaded by embedded instances.
812 Doing so has the potential for an infinite recursion if there are
818 Doing so has the potential for an infinite recursion if there are
813 exceptions thrown in the process. This fixes a strange crash
819 exceptions thrown in the process. This fixes a strange crash
814 reported by Philippe MULLER <muller-AT-irit.fr>.
820 reported by Philippe MULLER <muller-AT-irit.fr>.
815
821
816 2004-12-09 Fernando Perez <fperez@colorado.edu>
822 2004-12-09 Fernando Perez <fperez@colorado.edu>
817
823
818 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
824 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
819 to reflect new names in matplotlib, which now expose the
825 to reflect new names in matplotlib, which now expose the
820 matlab-compatible interface via a pylab module instead of the
826 matlab-compatible interface via a pylab module instead of the
821 'matlab' name. The new code is backwards compatible, so users of
827 'matlab' name. The new code is backwards compatible, so users of
822 all matplotlib versions are OK. Patch by J. Hunter.
828 all matplotlib versions are OK. Patch by J. Hunter.
823
829
824 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
830 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
825 of __init__ docstrings for instances (class docstrings are already
831 of __init__ docstrings for instances (class docstrings are already
826 automatically printed). Instances with customized docstrings
832 automatically printed). Instances with customized docstrings
827 (indep. of the class) are also recognized and all 3 separate
833 (indep. of the class) are also recognized and all 3 separate
828 docstrings are printed (instance, class, constructor). After some
834 docstrings are printed (instance, class, constructor). After some
829 comments/suggestions by J. Hunter.
835 comments/suggestions by J. Hunter.
830
836
831 2004-12-05 Fernando Perez <fperez@colorado.edu>
837 2004-12-05 Fernando Perez <fperez@colorado.edu>
832
838
833 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
839 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
834 warnings when tab-completion fails and triggers an exception.
840 warnings when tab-completion fails and triggers an exception.
835
841
836 2004-12-03 Fernando Perez <fperez@colorado.edu>
842 2004-12-03 Fernando Perez <fperez@colorado.edu>
837
843
838 * IPython/Magic.py (magic_prun): Fix bug where an exception would
844 * IPython/Magic.py (magic_prun): Fix bug where an exception would
839 be triggered when using 'run -p'. An incorrect option flag was
845 be triggered when using 'run -p'. An incorrect option flag was
840 being set ('d' instead of 'D').
846 being set ('d' instead of 'D').
841 (manpage): fix missing escaped \- sign.
847 (manpage): fix missing escaped \- sign.
842
848
843 2004-11-30 *** Released version 0.6.5
849 2004-11-30 *** Released version 0.6.5
844
850
845 2004-11-30 Fernando Perez <fperez@colorado.edu>
851 2004-11-30 Fernando Perez <fperez@colorado.edu>
846
852
847 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
853 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
848 setting with -d option.
854 setting with -d option.
849
855
850 * setup.py (docfiles): Fix problem where the doc glob I was using
856 * setup.py (docfiles): Fix problem where the doc glob I was using
851 was COMPLETELY BROKEN. It was giving the right files by pure
857 was COMPLETELY BROKEN. It was giving the right files by pure
852 accident, but failed once I tried to include ipython.el. Note:
858 accident, but failed once I tried to include ipython.el. Note:
853 glob() does NOT allow you to do exclusion on multiple endings!
859 glob() does NOT allow you to do exclusion on multiple endings!
854
860
855 2004-11-29 Fernando Perez <fperez@colorado.edu>
861 2004-11-29 Fernando Perez <fperez@colorado.edu>
856
862
857 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
863 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
858 the manpage as the source. Better formatting & consistency.
864 the manpage as the source. Better formatting & consistency.
859
865
860 * IPython/Magic.py (magic_run): Added new -d option, to run
866 * IPython/Magic.py (magic_run): Added new -d option, to run
861 scripts under the control of the python pdb debugger. Note that
867 scripts under the control of the python pdb debugger. Note that
862 this required changing the %prun option -d to -D, to avoid a clash
868 this required changing the %prun option -d to -D, to avoid a clash
863 (since %run must pass options to %prun, and getopt is too dumb to
869 (since %run must pass options to %prun, and getopt is too dumb to
864 handle options with string values with embedded spaces). Thanks
870 handle options with string values with embedded spaces). Thanks
865 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
871 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
866 (magic_who_ls): added type matching to %who and %whos, so that one
872 (magic_who_ls): added type matching to %who and %whos, so that one
867 can filter their output to only include variables of certain
873 can filter their output to only include variables of certain
868 types. Another suggestion by Matthew.
874 types. Another suggestion by Matthew.
869 (magic_whos): Added memory summaries in kb and Mb for arrays.
875 (magic_whos): Added memory summaries in kb and Mb for arrays.
870 (magic_who): Improve formatting (break lines every 9 vars).
876 (magic_who): Improve formatting (break lines every 9 vars).
871
877
872 2004-11-28 Fernando Perez <fperez@colorado.edu>
878 2004-11-28 Fernando Perez <fperez@colorado.edu>
873
879
874 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
880 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
875 cache when empty lines were present.
881 cache when empty lines were present.
876
882
877 2004-11-24 Fernando Perez <fperez@colorado.edu>
883 2004-11-24 Fernando Perez <fperez@colorado.edu>
878
884
879 * IPython/usage.py (__doc__): document the re-activated threading
885 * IPython/usage.py (__doc__): document the re-activated threading
880 options for WX and GTK.
886 options for WX and GTK.
881
887
882 2004-11-23 Fernando Perez <fperez@colorado.edu>
888 2004-11-23 Fernando Perez <fperez@colorado.edu>
883
889
884 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
890 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
885 the -wthread and -gthread options, along with a new -tk one to try
891 the -wthread and -gthread options, along with a new -tk one to try
886 and coordinate Tk threading with wx/gtk. The tk support is very
892 and coordinate Tk threading with wx/gtk. The tk support is very
887 platform dependent, since it seems to require Tcl and Tk to be
893 platform dependent, since it seems to require Tcl and Tk to be
888 built with threads (Fedora1/2 appears NOT to have it, but in
894 built with threads (Fedora1/2 appears NOT to have it, but in
889 Prabhu's Debian boxes it works OK). But even with some Tk
895 Prabhu's Debian boxes it works OK). But even with some Tk
890 limitations, this is a great improvement.
896 limitations, this is a great improvement.
891
897
892 * IPython/Prompts.py (prompt_specials_color): Added \t for time
898 * IPython/Prompts.py (prompt_specials_color): Added \t for time
893 info in user prompts. Patch by Prabhu.
899 info in user prompts. Patch by Prabhu.
894
900
895 2004-11-18 Fernando Perez <fperez@colorado.edu>
901 2004-11-18 Fernando Perez <fperez@colorado.edu>
896
902
897 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
903 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
898 EOFErrors and bail, to avoid infinite loops if a non-terminating
904 EOFErrors and bail, to avoid infinite loops if a non-terminating
899 file is fed into ipython. Patch submitted in issue 19 by user,
905 file is fed into ipython. Patch submitted in issue 19 by user,
900 many thanks.
906 many thanks.
901
907
902 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
908 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
903 autoquote/parens in continuation prompts, which can cause lots of
909 autoquote/parens in continuation prompts, which can cause lots of
904 problems. Closes roundup issue 20.
910 problems. Closes roundup issue 20.
905
911
906 2004-11-17 Fernando Perez <fperez@colorado.edu>
912 2004-11-17 Fernando Perez <fperez@colorado.edu>
907
913
908 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
914 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
909 reported as debian bug #280505. I'm not sure my local changelog
915 reported as debian bug #280505. I'm not sure my local changelog
910 entry has the proper debian format (Jack?).
916 entry has the proper debian format (Jack?).
911
917
912 2004-11-08 *** Released version 0.6.4
918 2004-11-08 *** Released version 0.6.4
913
919
914 2004-11-08 Fernando Perez <fperez@colorado.edu>
920 2004-11-08 Fernando Perez <fperez@colorado.edu>
915
921
916 * IPython/iplib.py (init_readline): Fix exit message for Windows
922 * IPython/iplib.py (init_readline): Fix exit message for Windows
917 when readline is active. Thanks to a report by Eric Jones
923 when readline is active. Thanks to a report by Eric Jones
918 <eric-AT-enthought.com>.
924 <eric-AT-enthought.com>.
919
925
920 2004-11-07 Fernando Perez <fperez@colorado.edu>
926 2004-11-07 Fernando Perez <fperez@colorado.edu>
921
927
922 * IPython/genutils.py (page): Add a trap for OSError exceptions,
928 * IPython/genutils.py (page): Add a trap for OSError exceptions,
923 sometimes seen by win2k/cygwin users.
929 sometimes seen by win2k/cygwin users.
924
930
925 2004-11-06 Fernando Perez <fperez@colorado.edu>
931 2004-11-06 Fernando Perez <fperez@colorado.edu>
926
932
927 * IPython/iplib.py (interact): Change the handling of %Exit from
933 * IPython/iplib.py (interact): Change the handling of %Exit from
928 trying to propagate a SystemExit to an internal ipython flag.
934 trying to propagate a SystemExit to an internal ipython flag.
929 This is less elegant than using Python's exception mechanism, but
935 This is less elegant than using Python's exception mechanism, but
930 I can't get that to work reliably with threads, so under -pylab
936 I can't get that to work reliably with threads, so under -pylab
931 %Exit was hanging IPython. Cross-thread exception handling is
937 %Exit was hanging IPython. Cross-thread exception handling is
932 really a bitch. Thaks to a bug report by Stephen Walton
938 really a bitch. Thaks to a bug report by Stephen Walton
933 <stephen.walton-AT-csun.edu>.
939 <stephen.walton-AT-csun.edu>.
934
940
935 2004-11-04 Fernando Perez <fperez@colorado.edu>
941 2004-11-04 Fernando Perez <fperez@colorado.edu>
936
942
937 * IPython/iplib.py (raw_input_original): store a pointer to the
943 * IPython/iplib.py (raw_input_original): store a pointer to the
938 true raw_input to harden against code which can modify it
944 true raw_input to harden against code which can modify it
939 (wx.py.PyShell does this and would otherwise crash ipython).
945 (wx.py.PyShell does this and would otherwise crash ipython).
940 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
946 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
941
947
942 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
948 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
943 Ctrl-C problem, which does not mess up the input line.
949 Ctrl-C problem, which does not mess up the input line.
944
950
945 2004-11-03 Fernando Perez <fperez@colorado.edu>
951 2004-11-03 Fernando Perez <fperez@colorado.edu>
946
952
947 * IPython/Release.py: Changed licensing to BSD, in all files.
953 * IPython/Release.py: Changed licensing to BSD, in all files.
948 (name): lowercase name for tarball/RPM release.
954 (name): lowercase name for tarball/RPM release.
949
955
950 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
956 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
951 use throughout ipython.
957 use throughout ipython.
952
958
953 * IPython/Magic.py (Magic._ofind): Switch to using the new
959 * IPython/Magic.py (Magic._ofind): Switch to using the new
954 OInspect.getdoc() function.
960 OInspect.getdoc() function.
955
961
956 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
962 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
957 of the line currently being canceled via Ctrl-C. It's extremely
963 of the line currently being canceled via Ctrl-C. It's extremely
958 ugly, but I don't know how to do it better (the problem is one of
964 ugly, but I don't know how to do it better (the problem is one of
959 handling cross-thread exceptions).
965 handling cross-thread exceptions).
960
966
961 2004-10-28 Fernando Perez <fperez@colorado.edu>
967 2004-10-28 Fernando Perez <fperez@colorado.edu>
962
968
963 * IPython/Shell.py (signal_handler): add signal handlers to trap
969 * IPython/Shell.py (signal_handler): add signal handlers to trap
964 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
970 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
965 report by Francesc Alted.
971 report by Francesc Alted.
966
972
967 2004-10-21 Fernando Perez <fperez@colorado.edu>
973 2004-10-21 Fernando Perez <fperez@colorado.edu>
968
974
969 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
975 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
970 to % for pysh syntax extensions.
976 to % for pysh syntax extensions.
971
977
972 2004-10-09 Fernando Perez <fperez@colorado.edu>
978 2004-10-09 Fernando Perez <fperez@colorado.edu>
973
979
974 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
980 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
975 arrays to print a more useful summary, without calling str(arr).
981 arrays to print a more useful summary, without calling str(arr).
976 This avoids the problem of extremely lengthy computations which
982 This avoids the problem of extremely lengthy computations which
977 occur if arr is large, and appear to the user as a system lockup
983 occur if arr is large, and appear to the user as a system lockup
978 with 100% cpu activity. After a suggestion by Kristian Sandberg
984 with 100% cpu activity. After a suggestion by Kristian Sandberg
979 <Kristian.Sandberg@colorado.edu>.
985 <Kristian.Sandberg@colorado.edu>.
980 (Magic.__init__): fix bug in global magic escapes not being
986 (Magic.__init__): fix bug in global magic escapes not being
981 correctly set.
987 correctly set.
982
988
983 2004-10-08 Fernando Perez <fperez@colorado.edu>
989 2004-10-08 Fernando Perez <fperez@colorado.edu>
984
990
985 * IPython/Magic.py (__license__): change to absolute imports of
991 * IPython/Magic.py (__license__): change to absolute imports of
986 ipython's own internal packages, to start adapting to the absolute
992 ipython's own internal packages, to start adapting to the absolute
987 import requirement of PEP-328.
993 import requirement of PEP-328.
988
994
989 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
995 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
990 files, and standardize author/license marks through the Release
996 files, and standardize author/license marks through the Release
991 module instead of having per/file stuff (except for files with
997 module instead of having per/file stuff (except for files with
992 particular licenses, like the MIT/PSF-licensed codes).
998 particular licenses, like the MIT/PSF-licensed codes).
993
999
994 * IPython/Debugger.py: remove dead code for python 2.1
1000 * IPython/Debugger.py: remove dead code for python 2.1
995
1001
996 2004-10-04 Fernando Perez <fperez@colorado.edu>
1002 2004-10-04 Fernando Perez <fperez@colorado.edu>
997
1003
998 * IPython/iplib.py (ipmagic): New function for accessing magics
1004 * IPython/iplib.py (ipmagic): New function for accessing magics
999 via a normal python function call.
1005 via a normal python function call.
1000
1006
1001 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
1007 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
1002 from '@' to '%', to accomodate the new @decorator syntax of python
1008 from '@' to '%', to accomodate the new @decorator syntax of python
1003 2.4.
1009 2.4.
1004
1010
1005 2004-09-29 Fernando Perez <fperez@colorado.edu>
1011 2004-09-29 Fernando Perez <fperez@colorado.edu>
1006
1012
1007 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
1013 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
1008 matplotlib.use to prevent running scripts which try to switch
1014 matplotlib.use to prevent running scripts which try to switch
1009 interactive backends from within ipython. This will just crash
1015 interactive backends from within ipython. This will just crash
1010 the python interpreter, so we can't allow it (but a detailed error
1016 the python interpreter, so we can't allow it (but a detailed error
1011 is given to the user).
1017 is given to the user).
1012
1018
1013 2004-09-28 Fernando Perez <fperez@colorado.edu>
1019 2004-09-28 Fernando Perez <fperez@colorado.edu>
1014
1020
1015 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
1021 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
1016 matplotlib-related fixes so that using @run with non-matplotlib
1022 matplotlib-related fixes so that using @run with non-matplotlib
1017 scripts doesn't pop up spurious plot windows. This requires
1023 scripts doesn't pop up spurious plot windows. This requires
1018 matplotlib >= 0.63, where I had to make some changes as well.
1024 matplotlib >= 0.63, where I had to make some changes as well.
1019
1025
1020 * IPython/ipmaker.py (make_IPython): update version requirement to
1026 * IPython/ipmaker.py (make_IPython): update version requirement to
1021 python 2.2.
1027 python 2.2.
1022
1028
1023 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
1029 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
1024 banner arg for embedded customization.
1030 banner arg for embedded customization.
1025
1031
1026 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
1032 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
1027 explicit uses of __IP as the IPython's instance name. Now things
1033 explicit uses of __IP as the IPython's instance name. Now things
1028 are properly handled via the shell.name value. The actual code
1034 are properly handled via the shell.name value. The actual code
1029 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
1035 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
1030 is much better than before. I'll clean things completely when the
1036 is much better than before. I'll clean things completely when the
1031 magic stuff gets a real overhaul.
1037 magic stuff gets a real overhaul.
1032
1038
1033 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
1039 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
1034 minor changes to debian dir.
1040 minor changes to debian dir.
1035
1041
1036 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
1042 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
1037 pointer to the shell itself in the interactive namespace even when
1043 pointer to the shell itself in the interactive namespace even when
1038 a user-supplied dict is provided. This is needed for embedding
1044 a user-supplied dict is provided. This is needed for embedding
1039 purposes (found by tests with Michel Sanner).
1045 purposes (found by tests with Michel Sanner).
1040
1046
1041 2004-09-27 Fernando Perez <fperez@colorado.edu>
1047 2004-09-27 Fernando Perez <fperez@colorado.edu>
1042
1048
1043 * IPython/UserConfig/ipythonrc: remove []{} from
1049 * IPython/UserConfig/ipythonrc: remove []{} from
1044 readline_remove_delims, so that things like [modname.<TAB> do
1050 readline_remove_delims, so that things like [modname.<TAB> do
1045 proper completion. This disables [].TAB, but that's a less common
1051 proper completion. This disables [].TAB, but that's a less common
1046 case than module names in list comprehensions, for example.
1052 case than module names in list comprehensions, for example.
1047 Thanks to a report by Andrea Riciputi.
1053 Thanks to a report by Andrea Riciputi.
1048
1054
1049 2004-09-09 Fernando Perez <fperez@colorado.edu>
1055 2004-09-09 Fernando Perez <fperez@colorado.edu>
1050
1056
1051 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1057 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1052 blocking problems in win32 and osx. Fix by John.
1058 blocking problems in win32 and osx. Fix by John.
1053
1059
1054 2004-09-08 Fernando Perez <fperez@colorado.edu>
1060 2004-09-08 Fernando Perez <fperez@colorado.edu>
1055
1061
1056 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1062 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1057 for Win32 and OSX. Fix by John Hunter.
1063 for Win32 and OSX. Fix by John Hunter.
1058
1064
1059 2004-08-30 *** Released version 0.6.3
1065 2004-08-30 *** Released version 0.6.3
1060
1066
1061 2004-08-30 Fernando Perez <fperez@colorado.edu>
1067 2004-08-30 Fernando Perez <fperez@colorado.edu>
1062
1068
1063 * setup.py (isfile): Add manpages to list of dependent files to be
1069 * setup.py (isfile): Add manpages to list of dependent files to be
1064 updated.
1070 updated.
1065
1071
1066 2004-08-27 Fernando Perez <fperez@colorado.edu>
1072 2004-08-27 Fernando Perez <fperez@colorado.edu>
1067
1073
1068 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1074 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1069 for now. They don't really work with standalone WX/GTK code
1075 for now. They don't really work with standalone WX/GTK code
1070 (though matplotlib IS working fine with both of those backends).
1076 (though matplotlib IS working fine with both of those backends).
1071 This will neeed much more testing. I disabled most things with
1077 This will neeed much more testing. I disabled most things with
1072 comments, so turning it back on later should be pretty easy.
1078 comments, so turning it back on later should be pretty easy.
1073
1079
1074 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1080 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1075 autocalling of expressions like r'foo', by modifying the line
1081 autocalling of expressions like r'foo', by modifying the line
1076 split regexp. Closes
1082 split regexp. Closes
1077 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1083 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1078 Riley <ipythonbugs-AT-sabi.net>.
1084 Riley <ipythonbugs-AT-sabi.net>.
1079 (InteractiveShell.mainloop): honor --nobanner with banner
1085 (InteractiveShell.mainloop): honor --nobanner with banner
1080 extensions.
1086 extensions.
1081
1087
1082 * IPython/Shell.py: Significant refactoring of all classes, so
1088 * IPython/Shell.py: Significant refactoring of all classes, so
1083 that we can really support ALL matplotlib backends and threading
1089 that we can really support ALL matplotlib backends and threading
1084 models (John spotted a bug with Tk which required this). Now we
1090 models (John spotted a bug with Tk which required this). Now we
1085 should support single-threaded, WX-threads and GTK-threads, both
1091 should support single-threaded, WX-threads and GTK-threads, both
1086 for generic code and for matplotlib.
1092 for generic code and for matplotlib.
1087
1093
1088 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1094 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1089 -pylab, to simplify things for users. Will also remove the pylab
1095 -pylab, to simplify things for users. Will also remove the pylab
1090 profile, since now all of matplotlib configuration is directly
1096 profile, since now all of matplotlib configuration is directly
1091 handled here. This also reduces startup time.
1097 handled here. This also reduces startup time.
1092
1098
1093 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1099 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1094 shell wasn't being correctly called. Also in IPShellWX.
1100 shell wasn't being correctly called. Also in IPShellWX.
1095
1101
1096 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1102 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1097 fine-tune banner.
1103 fine-tune banner.
1098
1104
1099 * IPython/numutils.py (spike): Deprecate these spike functions,
1105 * IPython/numutils.py (spike): Deprecate these spike functions,
1100 delete (long deprecated) gnuplot_exec handler.
1106 delete (long deprecated) gnuplot_exec handler.
1101
1107
1102 2004-08-26 Fernando Perez <fperez@colorado.edu>
1108 2004-08-26 Fernando Perez <fperez@colorado.edu>
1103
1109
1104 * ipython.1: Update for threading options, plus some others which
1110 * ipython.1: Update for threading options, plus some others which
1105 were missing.
1111 were missing.
1106
1112
1107 * IPython/ipmaker.py (__call__): Added -wthread option for
1113 * IPython/ipmaker.py (__call__): Added -wthread option for
1108 wxpython thread handling. Make sure threading options are only
1114 wxpython thread handling. Make sure threading options are only
1109 valid at the command line.
1115 valid at the command line.
1110
1116
1111 * scripts/ipython: moved shell selection into a factory function
1117 * scripts/ipython: moved shell selection into a factory function
1112 in Shell.py, to keep the starter script to a minimum.
1118 in Shell.py, to keep the starter script to a minimum.
1113
1119
1114 2004-08-25 Fernando Perez <fperez@colorado.edu>
1120 2004-08-25 Fernando Perez <fperez@colorado.edu>
1115
1121
1116 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1122 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1117 John. Along with some recent changes he made to matplotlib, the
1123 John. Along with some recent changes he made to matplotlib, the
1118 next versions of both systems should work very well together.
1124 next versions of both systems should work very well together.
1119
1125
1120 2004-08-24 Fernando Perez <fperez@colorado.edu>
1126 2004-08-24 Fernando Perez <fperez@colorado.edu>
1121
1127
1122 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1128 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1123 tried to switch the profiling to using hotshot, but I'm getting
1129 tried to switch the profiling to using hotshot, but I'm getting
1124 strange errors from prof.runctx() there. I may be misreading the
1130 strange errors from prof.runctx() there. I may be misreading the
1125 docs, but it looks weird. For now the profiling code will
1131 docs, but it looks weird. For now the profiling code will
1126 continue to use the standard profiler.
1132 continue to use the standard profiler.
1127
1133
1128 2004-08-23 Fernando Perez <fperez@colorado.edu>
1134 2004-08-23 Fernando Perez <fperez@colorado.edu>
1129
1135
1130 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1136 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1131 threaded shell, by John Hunter. It's not quite ready yet, but
1137 threaded shell, by John Hunter. It's not quite ready yet, but
1132 close.
1138 close.
1133
1139
1134 2004-08-22 Fernando Perez <fperez@colorado.edu>
1140 2004-08-22 Fernando Perez <fperez@colorado.edu>
1135
1141
1136 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1142 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1137 in Magic and ultraTB.
1143 in Magic and ultraTB.
1138
1144
1139 * ipython.1: document threading options in manpage.
1145 * ipython.1: document threading options in manpage.
1140
1146
1141 * scripts/ipython: Changed name of -thread option to -gthread,
1147 * scripts/ipython: Changed name of -thread option to -gthread,
1142 since this is GTK specific. I want to leave the door open for a
1148 since this is GTK specific. I want to leave the door open for a
1143 -wthread option for WX, which will most likely be necessary. This
1149 -wthread option for WX, which will most likely be necessary. This
1144 change affects usage and ipmaker as well.
1150 change affects usage and ipmaker as well.
1145
1151
1146 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1152 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1147 handle the matplotlib shell issues. Code by John Hunter
1153 handle the matplotlib shell issues. Code by John Hunter
1148 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1154 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1149 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1155 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1150 broken (and disabled for end users) for now, but it puts the
1156 broken (and disabled for end users) for now, but it puts the
1151 infrastructure in place.
1157 infrastructure in place.
1152
1158
1153 2004-08-21 Fernando Perez <fperez@colorado.edu>
1159 2004-08-21 Fernando Perez <fperez@colorado.edu>
1154
1160
1155 * ipythonrc-pylab: Add matplotlib support.
1161 * ipythonrc-pylab: Add matplotlib support.
1156
1162
1157 * matplotlib_config.py: new files for matplotlib support, part of
1163 * matplotlib_config.py: new files for matplotlib support, part of
1158 the pylab profile.
1164 the pylab profile.
1159
1165
1160 * IPython/usage.py (__doc__): documented the threading options.
1166 * IPython/usage.py (__doc__): documented the threading options.
1161
1167
1162 2004-08-20 Fernando Perez <fperez@colorado.edu>
1168 2004-08-20 Fernando Perez <fperez@colorado.edu>
1163
1169
1164 * ipython: Modified the main calling routine to handle the -thread
1170 * ipython: Modified the main calling routine to handle the -thread
1165 and -mpthread options. This needs to be done as a top-level hack,
1171 and -mpthread options. This needs to be done as a top-level hack,
1166 because it determines which class to instantiate for IPython
1172 because it determines which class to instantiate for IPython
1167 itself.
1173 itself.
1168
1174
1169 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1175 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1170 classes to support multithreaded GTK operation without blocking,
1176 classes to support multithreaded GTK operation without blocking,
1171 and matplotlib with all backends. This is a lot of still very
1177 and matplotlib with all backends. This is a lot of still very
1172 experimental code, and threads are tricky. So it may still have a
1178 experimental code, and threads are tricky. So it may still have a
1173 few rough edges... This code owes a lot to
1179 few rough edges... This code owes a lot to
1174 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1180 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1175 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1181 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1176 to John Hunter for all the matplotlib work.
1182 to John Hunter for all the matplotlib work.
1177
1183
1178 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1184 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1179 options for gtk thread and matplotlib support.
1185 options for gtk thread and matplotlib support.
1180
1186
1181 2004-08-16 Fernando Perez <fperez@colorado.edu>
1187 2004-08-16 Fernando Perez <fperez@colorado.edu>
1182
1188
1183 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1189 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1184 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1190 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1185 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1191 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1186
1192
1187 2004-08-11 Fernando Perez <fperez@colorado.edu>
1193 2004-08-11 Fernando Perez <fperez@colorado.edu>
1188
1194
1189 * setup.py (isfile): Fix build so documentation gets updated for
1195 * setup.py (isfile): Fix build so documentation gets updated for
1190 rpms (it was only done for .tgz builds).
1196 rpms (it was only done for .tgz builds).
1191
1197
1192 2004-08-10 Fernando Perez <fperez@colorado.edu>
1198 2004-08-10 Fernando Perez <fperez@colorado.edu>
1193
1199
1194 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1200 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1195
1201
1196 * iplib.py : Silence syntax error exceptions in tab-completion.
1202 * iplib.py : Silence syntax error exceptions in tab-completion.
1197
1203
1198 2004-08-05 Fernando Perez <fperez@colorado.edu>
1204 2004-08-05 Fernando Perez <fperez@colorado.edu>
1199
1205
1200 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1206 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1201 'color off' mark for continuation prompts. This was causing long
1207 'color off' mark for continuation prompts. This was causing long
1202 continuation lines to mis-wrap.
1208 continuation lines to mis-wrap.
1203
1209
1204 2004-08-01 Fernando Perez <fperez@colorado.edu>
1210 2004-08-01 Fernando Perez <fperez@colorado.edu>
1205
1211
1206 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1212 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1207 for building ipython to be a parameter. All this is necessary
1213 for building ipython to be a parameter. All this is necessary
1208 right now to have a multithreaded version, but this insane
1214 right now to have a multithreaded version, but this insane
1209 non-design will be cleaned up soon. For now, it's a hack that
1215 non-design will be cleaned up soon. For now, it's a hack that
1210 works.
1216 works.
1211
1217
1212 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1218 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1213 args in various places. No bugs so far, but it's a dangerous
1219 args in various places. No bugs so far, but it's a dangerous
1214 practice.
1220 practice.
1215
1221
1216 2004-07-31 Fernando Perez <fperez@colorado.edu>
1222 2004-07-31 Fernando Perez <fperez@colorado.edu>
1217
1223
1218 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1224 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1219 fix completion of files with dots in their names under most
1225 fix completion of files with dots in their names under most
1220 profiles (pysh was OK because the completion order is different).
1226 profiles (pysh was OK because the completion order is different).
1221
1227
1222 2004-07-27 Fernando Perez <fperez@colorado.edu>
1228 2004-07-27 Fernando Perez <fperez@colorado.edu>
1223
1229
1224 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1230 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1225 keywords manually, b/c the one in keyword.py was removed in python
1231 keywords manually, b/c the one in keyword.py was removed in python
1226 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1232 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1227 This is NOT a bug under python 2.3 and earlier.
1233 This is NOT a bug under python 2.3 and earlier.
1228
1234
1229 2004-07-26 Fernando Perez <fperez@colorado.edu>
1235 2004-07-26 Fernando Perez <fperez@colorado.edu>
1230
1236
1231 * IPython/ultraTB.py (VerboseTB.text): Add another
1237 * IPython/ultraTB.py (VerboseTB.text): Add another
1232 linecache.checkcache() call to try to prevent inspect.py from
1238 linecache.checkcache() call to try to prevent inspect.py from
1233 crashing under python 2.3. I think this fixes
1239 crashing under python 2.3. I think this fixes
1234 http://www.scipy.net/roundup/ipython/issue17.
1240 http://www.scipy.net/roundup/ipython/issue17.
1235
1241
1236 2004-07-26 *** Released version 0.6.2
1242 2004-07-26 *** Released version 0.6.2
1237
1243
1238 2004-07-26 Fernando Perez <fperez@colorado.edu>
1244 2004-07-26 Fernando Perez <fperez@colorado.edu>
1239
1245
1240 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1246 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1241 fail for any number.
1247 fail for any number.
1242 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1248 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1243 empty bookmarks.
1249 empty bookmarks.
1244
1250
1245 2004-07-26 *** Released version 0.6.1
1251 2004-07-26 *** Released version 0.6.1
1246
1252
1247 2004-07-26 Fernando Perez <fperez@colorado.edu>
1253 2004-07-26 Fernando Perez <fperez@colorado.edu>
1248
1254
1249 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1255 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1250
1256
1251 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1257 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1252 escaping '()[]{}' in filenames.
1258 escaping '()[]{}' in filenames.
1253
1259
1254 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1260 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1255 Python 2.2 users who lack a proper shlex.split.
1261 Python 2.2 users who lack a proper shlex.split.
1256
1262
1257 2004-07-19 Fernando Perez <fperez@colorado.edu>
1263 2004-07-19 Fernando Perez <fperez@colorado.edu>
1258
1264
1259 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1265 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1260 for reading readline's init file. I follow the normal chain:
1266 for reading readline's init file. I follow the normal chain:
1261 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1267 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1262 report by Mike Heeter. This closes
1268 report by Mike Heeter. This closes
1263 http://www.scipy.net/roundup/ipython/issue16.
1269 http://www.scipy.net/roundup/ipython/issue16.
1264
1270
1265 2004-07-18 Fernando Perez <fperez@colorado.edu>
1271 2004-07-18 Fernando Perez <fperez@colorado.edu>
1266
1272
1267 * IPython/iplib.py (__init__): Add better handling of '\' under
1273 * IPython/iplib.py (__init__): Add better handling of '\' under
1268 Win32 for filenames. After a patch by Ville.
1274 Win32 for filenames. After a patch by Ville.
1269
1275
1270 2004-07-17 Fernando Perez <fperez@colorado.edu>
1276 2004-07-17 Fernando Perez <fperez@colorado.edu>
1271
1277
1272 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1278 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1273 autocalling would be triggered for 'foo is bar' if foo is
1279 autocalling would be triggered for 'foo is bar' if foo is
1274 callable. I also cleaned up the autocall detection code to use a
1280 callable. I also cleaned up the autocall detection code to use a
1275 regexp, which is faster. Bug reported by Alexander Schmolck.
1281 regexp, which is faster. Bug reported by Alexander Schmolck.
1276
1282
1277 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1283 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1278 '?' in them would confuse the help system. Reported by Alex
1284 '?' in them would confuse the help system. Reported by Alex
1279 Schmolck.
1285 Schmolck.
1280
1286
1281 2004-07-16 Fernando Perez <fperez@colorado.edu>
1287 2004-07-16 Fernando Perez <fperez@colorado.edu>
1282
1288
1283 * IPython/GnuplotInteractive.py (__all__): added plot2.
1289 * IPython/GnuplotInteractive.py (__all__): added plot2.
1284
1290
1285 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1291 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1286 plotting dictionaries, lists or tuples of 1d arrays.
1292 plotting dictionaries, lists or tuples of 1d arrays.
1287
1293
1288 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1294 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1289 optimizations.
1295 optimizations.
1290
1296
1291 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1297 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1292 the information which was there from Janko's original IPP code:
1298 the information which was there from Janko's original IPP code:
1293
1299
1294 03.05.99 20:53 porto.ifm.uni-kiel.de
1300 03.05.99 20:53 porto.ifm.uni-kiel.de
1295 --Started changelog.
1301 --Started changelog.
1296 --make clear do what it say it does
1302 --make clear do what it say it does
1297 --added pretty output of lines from inputcache
1303 --added pretty output of lines from inputcache
1298 --Made Logger a mixin class, simplifies handling of switches
1304 --Made Logger a mixin class, simplifies handling of switches
1299 --Added own completer class. .string<TAB> expands to last history
1305 --Added own completer class. .string<TAB> expands to last history
1300 line which starts with string. The new expansion is also present
1306 line which starts with string. The new expansion is also present
1301 with Ctrl-r from the readline library. But this shows, who this
1307 with Ctrl-r from the readline library. But this shows, who this
1302 can be done for other cases.
1308 can be done for other cases.
1303 --Added convention that all shell functions should accept a
1309 --Added convention that all shell functions should accept a
1304 parameter_string This opens the door for different behaviour for
1310 parameter_string This opens the door for different behaviour for
1305 each function. @cd is a good example of this.
1311 each function. @cd is a good example of this.
1306
1312
1307 04.05.99 12:12 porto.ifm.uni-kiel.de
1313 04.05.99 12:12 porto.ifm.uni-kiel.de
1308 --added logfile rotation
1314 --added logfile rotation
1309 --added new mainloop method which freezes first the namespace
1315 --added new mainloop method which freezes first the namespace
1310
1316
1311 07.05.99 21:24 porto.ifm.uni-kiel.de
1317 07.05.99 21:24 porto.ifm.uni-kiel.de
1312 --added the docreader classes. Now there is a help system.
1318 --added the docreader classes. Now there is a help system.
1313 -This is only a first try. Currently it's not easy to put new
1319 -This is only a first try. Currently it's not easy to put new
1314 stuff in the indices. But this is the way to go. Info would be
1320 stuff in the indices. But this is the way to go. Info would be
1315 better, but HTML is every where and not everybody has an info
1321 better, but HTML is every where and not everybody has an info
1316 system installed and it's not so easy to change html-docs to info.
1322 system installed and it's not so easy to change html-docs to info.
1317 --added global logfile option
1323 --added global logfile option
1318 --there is now a hook for object inspection method pinfo needs to
1324 --there is now a hook for object inspection method pinfo needs to
1319 be provided for this. Can be reached by two '??'.
1325 be provided for this. Can be reached by two '??'.
1320
1326
1321 08.05.99 20:51 porto.ifm.uni-kiel.de
1327 08.05.99 20:51 porto.ifm.uni-kiel.de
1322 --added a README
1328 --added a README
1323 --bug in rc file. Something has changed so functions in the rc
1329 --bug in rc file. Something has changed so functions in the rc
1324 file need to reference the shell and not self. Not clear if it's a
1330 file need to reference the shell and not self. Not clear if it's a
1325 bug or feature.
1331 bug or feature.
1326 --changed rc file for new behavior
1332 --changed rc file for new behavior
1327
1333
1328 2004-07-15 Fernando Perez <fperez@colorado.edu>
1334 2004-07-15 Fernando Perez <fperez@colorado.edu>
1329
1335
1330 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1336 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1331 cache was falling out of sync in bizarre manners when multi-line
1337 cache was falling out of sync in bizarre manners when multi-line
1332 input was present. Minor optimizations and cleanup.
1338 input was present. Minor optimizations and cleanup.
1333
1339
1334 (Logger): Remove old Changelog info for cleanup. This is the
1340 (Logger): Remove old Changelog info for cleanup. This is the
1335 information which was there from Janko's original code:
1341 information which was there from Janko's original code:
1336
1342
1337 Changes to Logger: - made the default log filename a parameter
1343 Changes to Logger: - made the default log filename a parameter
1338
1344
1339 - put a check for lines beginning with !@? in log(). Needed
1345 - put a check for lines beginning with !@? in log(). Needed
1340 (even if the handlers properly log their lines) for mid-session
1346 (even if the handlers properly log their lines) for mid-session
1341 logging activation to work properly. Without this, lines logged
1347 logging activation to work properly. Without this, lines logged
1342 in mid session, which get read from the cache, would end up
1348 in mid session, which get read from the cache, would end up
1343 'bare' (with !@? in the open) in the log. Now they are caught
1349 'bare' (with !@? in the open) in the log. Now they are caught
1344 and prepended with a #.
1350 and prepended with a #.
1345
1351
1346 * IPython/iplib.py (InteractiveShell.init_readline): added check
1352 * IPython/iplib.py (InteractiveShell.init_readline): added check
1347 in case MagicCompleter fails to be defined, so we don't crash.
1353 in case MagicCompleter fails to be defined, so we don't crash.
1348
1354
1349 2004-07-13 Fernando Perez <fperez@colorado.edu>
1355 2004-07-13 Fernando Perez <fperez@colorado.edu>
1350
1356
1351 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1357 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1352 of EPS if the requested filename ends in '.eps'.
1358 of EPS if the requested filename ends in '.eps'.
1353
1359
1354 2004-07-04 Fernando Perez <fperez@colorado.edu>
1360 2004-07-04 Fernando Perez <fperez@colorado.edu>
1355
1361
1356 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1362 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1357 escaping of quotes when calling the shell.
1363 escaping of quotes when calling the shell.
1358
1364
1359 2004-07-02 Fernando Perez <fperez@colorado.edu>
1365 2004-07-02 Fernando Perez <fperez@colorado.edu>
1360
1366
1361 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1367 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1362 gettext not working because we were clobbering '_'. Fixes
1368 gettext not working because we were clobbering '_'. Fixes
1363 http://www.scipy.net/roundup/ipython/issue6.
1369 http://www.scipy.net/roundup/ipython/issue6.
1364
1370
1365 2004-07-01 Fernando Perez <fperez@colorado.edu>
1371 2004-07-01 Fernando Perez <fperez@colorado.edu>
1366
1372
1367 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1373 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1368 into @cd. Patch by Ville.
1374 into @cd. Patch by Ville.
1369
1375
1370 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1376 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1371 new function to store things after ipmaker runs. Patch by Ville.
1377 new function to store things after ipmaker runs. Patch by Ville.
1372 Eventually this will go away once ipmaker is removed and the class
1378 Eventually this will go away once ipmaker is removed and the class
1373 gets cleaned up, but for now it's ok. Key functionality here is
1379 gets cleaned up, but for now it's ok. Key functionality here is
1374 the addition of the persistent storage mechanism, a dict for
1380 the addition of the persistent storage mechanism, a dict for
1375 keeping data across sessions (for now just bookmarks, but more can
1381 keeping data across sessions (for now just bookmarks, but more can
1376 be implemented later).
1382 be implemented later).
1377
1383
1378 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
1384 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
1379 persistent across sections. Patch by Ville, I modified it
1385 persistent across sections. Patch by Ville, I modified it
1380 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
1386 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
1381 added a '-l' option to list all bookmarks.
1387 added a '-l' option to list all bookmarks.
1382
1388
1383 * IPython/iplib.py (InteractiveShell.atexit_operations): new
1389 * IPython/iplib.py (InteractiveShell.atexit_operations): new
1384 center for cleanup. Registered with atexit.register(). I moved
1390 center for cleanup. Registered with atexit.register(). I moved
1385 here the old exit_cleanup(). After a patch by Ville.
1391 here the old exit_cleanup(). After a patch by Ville.
1386
1392
1387 * IPython/Magic.py (get_py_filename): added '~' to the accepted
1393 * IPython/Magic.py (get_py_filename): added '~' to the accepted
1388 characters in the hacked shlex_split for python 2.2.
1394 characters in the hacked shlex_split for python 2.2.
1389
1395
1390 * IPython/iplib.py (file_matches): more fixes to filenames with
1396 * IPython/iplib.py (file_matches): more fixes to filenames with
1391 whitespace in them. It's not perfect, but limitations in python's
1397 whitespace in them. It's not perfect, but limitations in python's
1392 readline make it impossible to go further.
1398 readline make it impossible to go further.
1393
1399
1394 2004-06-29 Fernando Perez <fperez@colorado.edu>
1400 2004-06-29 Fernando Perez <fperez@colorado.edu>
1395
1401
1396 * IPython/iplib.py (file_matches): escape whitespace correctly in
1402 * IPython/iplib.py (file_matches): escape whitespace correctly in
1397 filename completions. Bug reported by Ville.
1403 filename completions. Bug reported by Ville.
1398
1404
1399 2004-06-28 Fernando Perez <fperez@colorado.edu>
1405 2004-06-28 Fernando Perez <fperez@colorado.edu>
1400
1406
1401 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
1407 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
1402 the history file will be called 'history-PROFNAME' (or just
1408 the history file will be called 'history-PROFNAME' (or just
1403 'history' if no profile is loaded). I was getting annoyed at
1409 'history' if no profile is loaded). I was getting annoyed at
1404 getting my Numerical work history clobbered by pysh sessions.
1410 getting my Numerical work history clobbered by pysh sessions.
1405
1411
1406 * IPython/iplib.py (InteractiveShell.__init__): Internal
1412 * IPython/iplib.py (InteractiveShell.__init__): Internal
1407 getoutputerror() function so that we can honor the system_verbose
1413 getoutputerror() function so that we can honor the system_verbose
1408 flag for _all_ system calls. I also added escaping of #
1414 flag for _all_ system calls. I also added escaping of #
1409 characters here to avoid confusing Itpl.
1415 characters here to avoid confusing Itpl.
1410
1416
1411 * IPython/Magic.py (shlex_split): removed call to shell in
1417 * IPython/Magic.py (shlex_split): removed call to shell in
1412 parse_options and replaced it with shlex.split(). The annoying
1418 parse_options and replaced it with shlex.split(). The annoying
1413 part was that in Python 2.2, shlex.split() doesn't exist, so I had
1419 part was that in Python 2.2, shlex.split() doesn't exist, so I had
1414 to backport it from 2.3, with several frail hacks (the shlex
1420 to backport it from 2.3, with several frail hacks (the shlex
1415 module is rather limited in 2.2). Thanks to a suggestion by Ville
1421 module is rather limited in 2.2). Thanks to a suggestion by Ville
1416 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
1422 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
1417 problem.
1423 problem.
1418
1424
1419 (Magic.magic_system_verbose): new toggle to print the actual
1425 (Magic.magic_system_verbose): new toggle to print the actual
1420 system calls made by ipython. Mainly for debugging purposes.
1426 system calls made by ipython. Mainly for debugging purposes.
1421
1427
1422 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
1428 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
1423 doesn't support persistence. Reported (and fix suggested) by
1429 doesn't support persistence. Reported (and fix suggested) by
1424 Travis Caldwell <travis_caldwell2000@yahoo.com>.
1430 Travis Caldwell <travis_caldwell2000@yahoo.com>.
1425
1431
1426 2004-06-26 Fernando Perez <fperez@colorado.edu>
1432 2004-06-26 Fernando Perez <fperez@colorado.edu>
1427
1433
1428 * IPython/Logger.py (Logger.log): fix to handle correctly empty
1434 * IPython/Logger.py (Logger.log): fix to handle correctly empty
1429 continue prompts.
1435 continue prompts.
1430
1436
1431 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
1437 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
1432 function (basically a big docstring) and a few more things here to
1438 function (basically a big docstring) and a few more things here to
1433 speedup startup. pysh.py is now very lightweight. We want because
1439 speedup startup. pysh.py is now very lightweight. We want because
1434 it gets execfile'd, while InterpreterExec gets imported, so
1440 it gets execfile'd, while InterpreterExec gets imported, so
1435 byte-compilation saves time.
1441 byte-compilation saves time.
1436
1442
1437 2004-06-25 Fernando Perez <fperez@colorado.edu>
1443 2004-06-25 Fernando Perez <fperez@colorado.edu>
1438
1444
1439 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
1445 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
1440 -NUM', which was recently broken.
1446 -NUM', which was recently broken.
1441
1447
1442 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
1448 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
1443 in multi-line input (but not !!, which doesn't make sense there).
1449 in multi-line input (but not !!, which doesn't make sense there).
1444
1450
1445 * IPython/UserConfig/ipythonrc: made autoindent on by default.
1451 * IPython/UserConfig/ipythonrc: made autoindent on by default.
1446 It's just too useful, and people can turn it off in the less
1452 It's just too useful, and people can turn it off in the less
1447 common cases where it's a problem.
1453 common cases where it's a problem.
1448
1454
1449 2004-06-24 Fernando Perez <fperez@colorado.edu>
1455 2004-06-24 Fernando Perez <fperez@colorado.edu>
1450
1456
1451 * IPython/iplib.py (InteractiveShell._prefilter): big change -
1457 * IPython/iplib.py (InteractiveShell._prefilter): big change -
1452 special syntaxes (like alias calling) is now allied in multi-line
1458 special syntaxes (like alias calling) is now allied in multi-line
1453 input. This is still _very_ experimental, but it's necessary for
1459 input. This is still _very_ experimental, but it's necessary for
1454 efficient shell usage combining python looping syntax with system
1460 efficient shell usage combining python looping syntax with system
1455 calls. For now it's restricted to aliases, I don't think it
1461 calls. For now it's restricted to aliases, I don't think it
1456 really even makes sense to have this for magics.
1462 really even makes sense to have this for magics.
1457
1463
1458 2004-06-23 Fernando Perez <fperez@colorado.edu>
1464 2004-06-23 Fernando Perez <fperez@colorado.edu>
1459
1465
1460 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
1466 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
1461 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
1467 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
1462
1468
1463 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
1469 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
1464 extensions under Windows (after code sent by Gary Bishop). The
1470 extensions under Windows (after code sent by Gary Bishop). The
1465 extensions considered 'executable' are stored in IPython's rc
1471 extensions considered 'executable' are stored in IPython's rc
1466 structure as win_exec_ext.
1472 structure as win_exec_ext.
1467
1473
1468 * IPython/genutils.py (shell): new function, like system() but
1474 * IPython/genutils.py (shell): new function, like system() but
1469 without return value. Very useful for interactive shell work.
1475 without return value. Very useful for interactive shell work.
1470
1476
1471 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
1477 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
1472 delete aliases.
1478 delete aliases.
1473
1479
1474 * IPython/iplib.py (InteractiveShell.alias_table_update): make
1480 * IPython/iplib.py (InteractiveShell.alias_table_update): make
1475 sure that the alias table doesn't contain python keywords.
1481 sure that the alias table doesn't contain python keywords.
1476
1482
1477 2004-06-21 Fernando Perez <fperez@colorado.edu>
1483 2004-06-21 Fernando Perez <fperez@colorado.edu>
1478
1484
1479 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
1485 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
1480 non-existent items are found in $PATH. Reported by Thorsten.
1486 non-existent items are found in $PATH. Reported by Thorsten.
1481
1487
1482 2004-06-20 Fernando Perez <fperez@colorado.edu>
1488 2004-06-20 Fernando Perez <fperez@colorado.edu>
1483
1489
1484 * IPython/iplib.py (complete): modified the completer so that the
1490 * IPython/iplib.py (complete): modified the completer so that the
1485 order of priorities can be easily changed at runtime.
1491 order of priorities can be easily changed at runtime.
1486
1492
1487 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
1493 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
1488 Modified to auto-execute all lines beginning with '~', '/' or '.'.
1494 Modified to auto-execute all lines beginning with '~', '/' or '.'.
1489
1495
1490 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
1496 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
1491 expand Python variables prepended with $ in all system calls. The
1497 expand Python variables prepended with $ in all system calls. The
1492 same was done to InteractiveShell.handle_shell_escape. Now all
1498 same was done to InteractiveShell.handle_shell_escape. Now all
1493 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
1499 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
1494 expansion of python variables and expressions according to the
1500 expansion of python variables and expressions according to the
1495 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
1501 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
1496
1502
1497 Though PEP-215 has been rejected, a similar (but simpler) one
1503 Though PEP-215 has been rejected, a similar (but simpler) one
1498 seems like it will go into Python 2.4, PEP-292 -
1504 seems like it will go into Python 2.4, PEP-292 -
1499 http://www.python.org/peps/pep-0292.html.
1505 http://www.python.org/peps/pep-0292.html.
1500
1506
1501 I'll keep the full syntax of PEP-215, since IPython has since the
1507 I'll keep the full syntax of PEP-215, since IPython has since the
1502 start used Ka-Ping Yee's reference implementation discussed there
1508 start used Ka-Ping Yee's reference implementation discussed there
1503 (Itpl), and I actually like the powerful semantics it offers.
1509 (Itpl), and I actually like the powerful semantics it offers.
1504
1510
1505 In order to access normal shell variables, the $ has to be escaped
1511 In order to access normal shell variables, the $ has to be escaped
1506 via an extra $. For example:
1512 via an extra $. For example:
1507
1513
1508 In [7]: PATH='a python variable'
1514 In [7]: PATH='a python variable'
1509
1515
1510 In [8]: !echo $PATH
1516 In [8]: !echo $PATH
1511 a python variable
1517 a python variable
1512
1518
1513 In [9]: !echo $$PATH
1519 In [9]: !echo $$PATH
1514 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1520 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1515
1521
1516 (Magic.parse_options): escape $ so the shell doesn't evaluate
1522 (Magic.parse_options): escape $ so the shell doesn't evaluate
1517 things prematurely.
1523 things prematurely.
1518
1524
1519 * IPython/iplib.py (InteractiveShell.call_alias): added the
1525 * IPython/iplib.py (InteractiveShell.call_alias): added the
1520 ability for aliases to expand python variables via $.
1526 ability for aliases to expand python variables via $.
1521
1527
1522 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
1528 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
1523 system, now there's a @rehash/@rehashx pair of magics. These work
1529 system, now there's a @rehash/@rehashx pair of magics. These work
1524 like the csh rehash command, and can be invoked at any time. They
1530 like the csh rehash command, and can be invoked at any time. They
1525 build a table of aliases to everything in the user's $PATH
1531 build a table of aliases to everything in the user's $PATH
1526 (@rehash uses everything, @rehashx is slower but only adds
1532 (@rehash uses everything, @rehashx is slower but only adds
1527 executable files). With this, the pysh.py-based shell profile can
1533 executable files). With this, the pysh.py-based shell profile can
1528 now simply call rehash upon startup, and full access to all
1534 now simply call rehash upon startup, and full access to all
1529 programs in the user's path is obtained.
1535 programs in the user's path is obtained.
1530
1536
1531 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
1537 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
1532 functionality is now fully in place. I removed the old dynamic
1538 functionality is now fully in place. I removed the old dynamic
1533 code generation based approach, in favor of a much lighter one
1539 code generation based approach, in favor of a much lighter one
1534 based on a simple dict. The advantage is that this allows me to
1540 based on a simple dict. The advantage is that this allows me to
1535 now have thousands of aliases with negligible cost (unthinkable
1541 now have thousands of aliases with negligible cost (unthinkable
1536 with the old system).
1542 with the old system).
1537
1543
1538 2004-06-19 Fernando Perez <fperez@colorado.edu>
1544 2004-06-19 Fernando Perez <fperez@colorado.edu>
1539
1545
1540 * IPython/iplib.py (__init__): extended MagicCompleter class to
1546 * IPython/iplib.py (__init__): extended MagicCompleter class to
1541 also complete (last in priority) on user aliases.
1547 also complete (last in priority) on user aliases.
1542
1548
1543 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
1549 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
1544 call to eval.
1550 call to eval.
1545 (ItplNS.__init__): Added a new class which functions like Itpl,
1551 (ItplNS.__init__): Added a new class which functions like Itpl,
1546 but allows configuring the namespace for the evaluation to occur
1552 but allows configuring the namespace for the evaluation to occur
1547 in.
1553 in.
1548
1554
1549 2004-06-18 Fernando Perez <fperez@colorado.edu>
1555 2004-06-18 Fernando Perez <fperez@colorado.edu>
1550
1556
1551 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
1557 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
1552 better message when 'exit' or 'quit' are typed (a common newbie
1558 better message when 'exit' or 'quit' are typed (a common newbie
1553 confusion).
1559 confusion).
1554
1560
1555 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
1561 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
1556 check for Windows users.
1562 check for Windows users.
1557
1563
1558 * IPython/iplib.py (InteractiveShell.user_setup): removed
1564 * IPython/iplib.py (InteractiveShell.user_setup): removed
1559 disabling of colors for Windows. I'll test at runtime and issue a
1565 disabling of colors for Windows. I'll test at runtime and issue a
1560 warning if Gary's readline isn't found, as to nudge users to
1566 warning if Gary's readline isn't found, as to nudge users to
1561 download it.
1567 download it.
1562
1568
1563 2004-06-16 Fernando Perez <fperez@colorado.edu>
1569 2004-06-16 Fernando Perez <fperez@colorado.edu>
1564
1570
1565 * IPython/genutils.py (Stream.__init__): changed to print errors
1571 * IPython/genutils.py (Stream.__init__): changed to print errors
1566 to sys.stderr. I had a circular dependency here. Now it's
1572 to sys.stderr. I had a circular dependency here. Now it's
1567 possible to run ipython as IDLE's shell (consider this pre-alpha,
1573 possible to run ipython as IDLE's shell (consider this pre-alpha,
1568 since true stdout things end up in the starting terminal instead
1574 since true stdout things end up in the starting terminal instead
1569 of IDLE's out).
1575 of IDLE's out).
1570
1576
1571 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
1577 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
1572 users who haven't # updated their prompt_in2 definitions. Remove
1578 users who haven't # updated their prompt_in2 definitions. Remove
1573 eventually.
1579 eventually.
1574 (multiple_replace): added credit to original ASPN recipe.
1580 (multiple_replace): added credit to original ASPN recipe.
1575
1581
1576 2004-06-15 Fernando Perez <fperez@colorado.edu>
1582 2004-06-15 Fernando Perez <fperez@colorado.edu>
1577
1583
1578 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
1584 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
1579 list of auto-defined aliases.
1585 list of auto-defined aliases.
1580
1586
1581 2004-06-13 Fernando Perez <fperez@colorado.edu>
1587 2004-06-13 Fernando Perez <fperez@colorado.edu>
1582
1588
1583 * setup.py (scriptfiles): Don't trigger win_post_install unless an
1589 * setup.py (scriptfiles): Don't trigger win_post_install unless an
1584 install was really requested (so setup.py can be used for other
1590 install was really requested (so setup.py can be used for other
1585 things under Windows).
1591 things under Windows).
1586
1592
1587 2004-06-10 Fernando Perez <fperez@colorado.edu>
1593 2004-06-10 Fernando Perez <fperez@colorado.edu>
1588
1594
1589 * IPython/Logger.py (Logger.create_log): Manually remove any old
1595 * IPython/Logger.py (Logger.create_log): Manually remove any old
1590 backup, since os.remove may fail under Windows. Fixes bug
1596 backup, since os.remove may fail under Windows. Fixes bug
1591 reported by Thorsten.
1597 reported by Thorsten.
1592
1598
1593 2004-06-09 Fernando Perez <fperez@colorado.edu>
1599 2004-06-09 Fernando Perez <fperez@colorado.edu>
1594
1600
1595 * examples/example-embed.py: fixed all references to %n (replaced
1601 * examples/example-embed.py: fixed all references to %n (replaced
1596 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
1602 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
1597 for all examples and the manual as well.
1603 for all examples and the manual as well.
1598
1604
1599 2004-06-08 Fernando Perez <fperez@colorado.edu>
1605 2004-06-08 Fernando Perez <fperez@colorado.edu>
1600
1606
1601 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
1607 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
1602 alignment and color management. All 3 prompt subsystems now
1608 alignment and color management. All 3 prompt subsystems now
1603 inherit from BasePrompt.
1609 inherit from BasePrompt.
1604
1610
1605 * tools/release: updates for windows installer build and tag rpms
1611 * tools/release: updates for windows installer build and tag rpms
1606 with python version (since paths are fixed).
1612 with python version (since paths are fixed).
1607
1613
1608 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
1614 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
1609 which will become eventually obsolete. Also fixed the default
1615 which will become eventually obsolete. Also fixed the default
1610 prompt_in2 to use \D, so at least new users start with the correct
1616 prompt_in2 to use \D, so at least new users start with the correct
1611 defaults.
1617 defaults.
1612 WARNING: Users with existing ipythonrc files will need to apply
1618 WARNING: Users with existing ipythonrc files will need to apply
1613 this fix manually!
1619 this fix manually!
1614
1620
1615 * setup.py: make windows installer (.exe). This is finally the
1621 * setup.py: make windows installer (.exe). This is finally the
1616 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
1622 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
1617 which I hadn't included because it required Python 2.3 (or recent
1623 which I hadn't included because it required Python 2.3 (or recent
1618 distutils).
1624 distutils).
1619
1625
1620 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
1626 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
1621 usage of new '\D' escape.
1627 usage of new '\D' escape.
1622
1628
1623 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
1629 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
1624 lacks os.getuid())
1630 lacks os.getuid())
1625 (CachedOutput.set_colors): Added the ability to turn coloring
1631 (CachedOutput.set_colors): Added the ability to turn coloring
1626 on/off with @colors even for manually defined prompt colors. It
1632 on/off with @colors even for manually defined prompt colors. It
1627 uses a nasty global, but it works safely and via the generic color
1633 uses a nasty global, but it works safely and via the generic color
1628 handling mechanism.
1634 handling mechanism.
1629 (Prompt2.__init__): Introduced new escape '\D' for continuation
1635 (Prompt2.__init__): Introduced new escape '\D' for continuation
1630 prompts. It represents the counter ('\#') as dots.
1636 prompts. It represents the counter ('\#') as dots.
1631 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
1637 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
1632 need to update their ipythonrc files and replace '%n' with '\D' in
1638 need to update their ipythonrc files and replace '%n' with '\D' in
1633 their prompt_in2 settings everywhere. Sorry, but there's
1639 their prompt_in2 settings everywhere. Sorry, but there's
1634 otherwise no clean way to get all prompts to properly align. The
1640 otherwise no clean way to get all prompts to properly align. The
1635 ipythonrc shipped with IPython has been updated.
1641 ipythonrc shipped with IPython has been updated.
1636
1642
1637 2004-06-07 Fernando Perez <fperez@colorado.edu>
1643 2004-06-07 Fernando Perez <fperez@colorado.edu>
1638
1644
1639 * setup.py (isfile): Pass local_icons option to latex2html, so the
1645 * setup.py (isfile): Pass local_icons option to latex2html, so the
1640 resulting HTML file is self-contained. Thanks to
1646 resulting HTML file is self-contained. Thanks to
1641 dryice-AT-liu.com.cn for the tip.
1647 dryice-AT-liu.com.cn for the tip.
1642
1648
1643 * pysh.py: I created a new profile 'shell', which implements a
1649 * pysh.py: I created a new profile 'shell', which implements a
1644 _rudimentary_ IPython-based shell. This is in NO WAY a realy
1650 _rudimentary_ IPython-based shell. This is in NO WAY a realy
1645 system shell, nor will it become one anytime soon. It's mainly
1651 system shell, nor will it become one anytime soon. It's mainly
1646 meant to illustrate the use of the new flexible bash-like prompts.
1652 meant to illustrate the use of the new flexible bash-like prompts.
1647 I guess it could be used by hardy souls for true shell management,
1653 I guess it could be used by hardy souls for true shell management,
1648 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
1654 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
1649 profile. This uses the InterpreterExec extension provided by
1655 profile. This uses the InterpreterExec extension provided by
1650 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
1656 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
1651
1657
1652 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
1658 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
1653 auto-align itself with the length of the previous input prompt
1659 auto-align itself with the length of the previous input prompt
1654 (taking into account the invisible color escapes).
1660 (taking into account the invisible color escapes).
1655 (CachedOutput.__init__): Large restructuring of this class. Now
1661 (CachedOutput.__init__): Large restructuring of this class. Now
1656 all three prompts (primary1, primary2, output) are proper objects,
1662 all three prompts (primary1, primary2, output) are proper objects,
1657 managed by the 'parent' CachedOutput class. The code is still a
1663 managed by the 'parent' CachedOutput class. The code is still a
1658 bit hackish (all prompts share state via a pointer to the cache),
1664 bit hackish (all prompts share state via a pointer to the cache),
1659 but it's overall far cleaner than before.
1665 but it's overall far cleaner than before.
1660
1666
1661 * IPython/genutils.py (getoutputerror): modified to add verbose,
1667 * IPython/genutils.py (getoutputerror): modified to add verbose,
1662 debug and header options. This makes the interface of all getout*
1668 debug and header options. This makes the interface of all getout*
1663 functions uniform.
1669 functions uniform.
1664 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
1670 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
1665
1671
1666 * IPython/Magic.py (Magic.default_option): added a function to
1672 * IPython/Magic.py (Magic.default_option): added a function to
1667 allow registering default options for any magic command. This
1673 allow registering default options for any magic command. This
1668 makes it easy to have profiles which customize the magics globally
1674 makes it easy to have profiles which customize the magics globally
1669 for a certain use. The values set through this function are
1675 for a certain use. The values set through this function are
1670 picked up by the parse_options() method, which all magics should
1676 picked up by the parse_options() method, which all magics should
1671 use to parse their options.
1677 use to parse their options.
1672
1678
1673 * IPython/genutils.py (warn): modified the warnings framework to
1679 * IPython/genutils.py (warn): modified the warnings framework to
1674 use the Term I/O class. I'm trying to slowly unify all of
1680 use the Term I/O class. I'm trying to slowly unify all of
1675 IPython's I/O operations to pass through Term.
1681 IPython's I/O operations to pass through Term.
1676
1682
1677 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
1683 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
1678 the secondary prompt to correctly match the length of the primary
1684 the secondary prompt to correctly match the length of the primary
1679 one for any prompt. Now multi-line code will properly line up
1685 one for any prompt. Now multi-line code will properly line up
1680 even for path dependent prompts, such as the new ones available
1686 even for path dependent prompts, such as the new ones available
1681 via the prompt_specials.
1687 via the prompt_specials.
1682
1688
1683 2004-06-06 Fernando Perez <fperez@colorado.edu>
1689 2004-06-06 Fernando Perez <fperez@colorado.edu>
1684
1690
1685 * IPython/Prompts.py (prompt_specials): Added the ability to have
1691 * IPython/Prompts.py (prompt_specials): Added the ability to have
1686 bash-like special sequences in the prompts, which get
1692 bash-like special sequences in the prompts, which get
1687 automatically expanded. Things like hostname, current working
1693 automatically expanded. Things like hostname, current working
1688 directory and username are implemented already, but it's easy to
1694 directory and username are implemented already, but it's easy to
1689 add more in the future. Thanks to a patch by W.J. van der Laan
1695 add more in the future. Thanks to a patch by W.J. van der Laan
1690 <gnufnork-AT-hetdigitalegat.nl>
1696 <gnufnork-AT-hetdigitalegat.nl>
1691 (prompt_specials): Added color support for prompt strings, so
1697 (prompt_specials): Added color support for prompt strings, so
1692 users can define arbitrary color setups for their prompts.
1698 users can define arbitrary color setups for their prompts.
1693
1699
1694 2004-06-05 Fernando Perez <fperez@colorado.edu>
1700 2004-06-05 Fernando Perez <fperez@colorado.edu>
1695
1701
1696 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
1702 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
1697 code to load Gary Bishop's readline and configure it
1703 code to load Gary Bishop's readline and configure it
1698 automatically. Thanks to Gary for help on this.
1704 automatically. Thanks to Gary for help on this.
1699
1705
1700 2004-06-01 Fernando Perez <fperez@colorado.edu>
1706 2004-06-01 Fernando Perez <fperez@colorado.edu>
1701
1707
1702 * IPython/Logger.py (Logger.create_log): fix bug for logging
1708 * IPython/Logger.py (Logger.create_log): fix bug for logging
1703 with no filename (previous fix was incomplete).
1709 with no filename (previous fix was incomplete).
1704
1710
1705 2004-05-25 Fernando Perez <fperez@colorado.edu>
1711 2004-05-25 Fernando Perez <fperez@colorado.edu>
1706
1712
1707 * IPython/Magic.py (Magic.parse_options): fix bug where naked
1713 * IPython/Magic.py (Magic.parse_options): fix bug where naked
1708 parens would get passed to the shell.
1714 parens would get passed to the shell.
1709
1715
1710 2004-05-20 Fernando Perez <fperez@colorado.edu>
1716 2004-05-20 Fernando Perez <fperez@colorado.edu>
1711
1717
1712 * IPython/Magic.py (Magic.magic_prun): changed default profile
1718 * IPython/Magic.py (Magic.magic_prun): changed default profile
1713 sort order to 'time' (the more common profiling need).
1719 sort order to 'time' (the more common profiling need).
1714
1720
1715 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
1721 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
1716 so that source code shown is guaranteed in sync with the file on
1722 so that source code shown is guaranteed in sync with the file on
1717 disk (also changed in psource). Similar fix to the one for
1723 disk (also changed in psource). Similar fix to the one for
1718 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
1724 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
1719 <yann.ledu-AT-noos.fr>.
1725 <yann.ledu-AT-noos.fr>.
1720
1726
1721 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
1727 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
1722 with a single option would not be correctly parsed. Closes
1728 with a single option would not be correctly parsed. Closes
1723 http://www.scipy.net/roundup/ipython/issue14. This bug had been
1729 http://www.scipy.net/roundup/ipython/issue14. This bug had been
1724 introduced in 0.6.0 (on 2004-05-06).
1730 introduced in 0.6.0 (on 2004-05-06).
1725
1731
1726 2004-05-13 *** Released version 0.6.0
1732 2004-05-13 *** Released version 0.6.0
1727
1733
1728 2004-05-13 Fernando Perez <fperez@colorado.edu>
1734 2004-05-13 Fernando Perez <fperez@colorado.edu>
1729
1735
1730 * debian/: Added debian/ directory to CVS, so that debian support
1736 * debian/: Added debian/ directory to CVS, so that debian support
1731 is publicly accessible. The debian package is maintained by Jack
1737 is publicly accessible. The debian package is maintained by Jack
1732 Moffit <jack-AT-xiph.org>.
1738 Moffit <jack-AT-xiph.org>.
1733
1739
1734 * Documentation: included the notes about an ipython-based system
1740 * Documentation: included the notes about an ipython-based system
1735 shell (the hypothetical 'pysh') into the new_design.pdf document,
1741 shell (the hypothetical 'pysh') into the new_design.pdf document,
1736 so that these ideas get distributed to users along with the
1742 so that these ideas get distributed to users along with the
1737 official documentation.
1743 official documentation.
1738
1744
1739 2004-05-10 Fernando Perez <fperez@colorado.edu>
1745 2004-05-10 Fernando Perez <fperez@colorado.edu>
1740
1746
1741 * IPython/Logger.py (Logger.create_log): fix recently introduced
1747 * IPython/Logger.py (Logger.create_log): fix recently introduced
1742 bug (misindented line) where logstart would fail when not given an
1748 bug (misindented line) where logstart would fail when not given an
1743 explicit filename.
1749 explicit filename.
1744
1750
1745 2004-05-09 Fernando Perez <fperez@colorado.edu>
1751 2004-05-09 Fernando Perez <fperez@colorado.edu>
1746
1752
1747 * IPython/Magic.py (Magic.parse_options): skip system call when
1753 * IPython/Magic.py (Magic.parse_options): skip system call when
1748 there are no options to look for. Faster, cleaner for the common
1754 there are no options to look for. Faster, cleaner for the common
1749 case.
1755 case.
1750
1756
1751 * Documentation: many updates to the manual: describing Windows
1757 * Documentation: many updates to the manual: describing Windows
1752 support better, Gnuplot updates, credits, misc small stuff. Also
1758 support better, Gnuplot updates, credits, misc small stuff. Also
1753 updated the new_design doc a bit.
1759 updated the new_design doc a bit.
1754
1760
1755 2004-05-06 *** Released version 0.6.0.rc1
1761 2004-05-06 *** Released version 0.6.0.rc1
1756
1762
1757 2004-05-06 Fernando Perez <fperez@colorado.edu>
1763 2004-05-06 Fernando Perez <fperez@colorado.edu>
1758
1764
1759 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
1765 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
1760 operations to use the vastly more efficient list/''.join() method.
1766 operations to use the vastly more efficient list/''.join() method.
1761 (FormattedTB.text): Fix
1767 (FormattedTB.text): Fix
1762 http://www.scipy.net/roundup/ipython/issue12 - exception source
1768 http://www.scipy.net/roundup/ipython/issue12 - exception source
1763 extract not updated after reload. Thanks to Mike Salib
1769 extract not updated after reload. Thanks to Mike Salib
1764 <msalib-AT-mit.edu> for pinning the source of the problem.
1770 <msalib-AT-mit.edu> for pinning the source of the problem.
1765 Fortunately, the solution works inside ipython and doesn't require
1771 Fortunately, the solution works inside ipython and doesn't require
1766 any changes to python proper.
1772 any changes to python proper.
1767
1773
1768 * IPython/Magic.py (Magic.parse_options): Improved to process the
1774 * IPython/Magic.py (Magic.parse_options): Improved to process the
1769 argument list as a true shell would (by actually using the
1775 argument list as a true shell would (by actually using the
1770 underlying system shell). This way, all @magics automatically get
1776 underlying system shell). This way, all @magics automatically get
1771 shell expansion for variables. Thanks to a comment by Alex
1777 shell expansion for variables. Thanks to a comment by Alex
1772 Schmolck.
1778 Schmolck.
1773
1779
1774 2004-04-04 Fernando Perez <fperez@colorado.edu>
1780 2004-04-04 Fernando Perez <fperez@colorado.edu>
1775
1781
1776 * IPython/iplib.py (InteractiveShell.interact): Added a special
1782 * IPython/iplib.py (InteractiveShell.interact): Added a special
1777 trap for a debugger quit exception, which is basically impossible
1783 trap for a debugger quit exception, which is basically impossible
1778 to handle by normal mechanisms, given what pdb does to the stack.
1784 to handle by normal mechanisms, given what pdb does to the stack.
1779 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
1785 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
1780
1786
1781 2004-04-03 Fernando Perez <fperez@colorado.edu>
1787 2004-04-03 Fernando Perez <fperez@colorado.edu>
1782
1788
1783 * IPython/genutils.py (Term): Standardized the names of the Term
1789 * IPython/genutils.py (Term): Standardized the names of the Term
1784 class streams to cin/cout/cerr, following C++ naming conventions
1790 class streams to cin/cout/cerr, following C++ naming conventions
1785 (I can't use in/out/err because 'in' is not a valid attribute
1791 (I can't use in/out/err because 'in' is not a valid attribute
1786 name).
1792 name).
1787
1793
1788 * IPython/iplib.py (InteractiveShell.interact): don't increment
1794 * IPython/iplib.py (InteractiveShell.interact): don't increment
1789 the prompt if there's no user input. By Daniel 'Dang' Griffith
1795 the prompt if there's no user input. By Daniel 'Dang' Griffith
1790 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
1796 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
1791 Francois Pinard.
1797 Francois Pinard.
1792
1798
1793 2004-04-02 Fernando Perez <fperez@colorado.edu>
1799 2004-04-02 Fernando Perez <fperez@colorado.edu>
1794
1800
1795 * IPython/genutils.py (Stream.__init__): Modified to survive at
1801 * IPython/genutils.py (Stream.__init__): Modified to survive at
1796 least importing in contexts where stdin/out/err aren't true file
1802 least importing in contexts where stdin/out/err aren't true file
1797 objects, such as PyCrust (they lack fileno() and mode). However,
1803 objects, such as PyCrust (they lack fileno() and mode). However,
1798 the recovery facilities which rely on these things existing will
1804 the recovery facilities which rely on these things existing will
1799 not work.
1805 not work.
1800
1806
1801 2004-04-01 Fernando Perez <fperez@colorado.edu>
1807 2004-04-01 Fernando Perez <fperez@colorado.edu>
1802
1808
1803 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
1809 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
1804 use the new getoutputerror() function, so it properly
1810 use the new getoutputerror() function, so it properly
1805 distinguishes stdout/err.
1811 distinguishes stdout/err.
1806
1812
1807 * IPython/genutils.py (getoutputerror): added a function to
1813 * IPython/genutils.py (getoutputerror): added a function to
1808 capture separately the standard output and error of a command.
1814 capture separately the standard output and error of a command.
1809 After a comment from dang on the mailing lists. This code is
1815 After a comment from dang on the mailing lists. This code is
1810 basically a modified version of commands.getstatusoutput(), from
1816 basically a modified version of commands.getstatusoutput(), from
1811 the standard library.
1817 the standard library.
1812
1818
1813 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
1819 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
1814 '!!' as a special syntax (shorthand) to access @sx.
1820 '!!' as a special syntax (shorthand) to access @sx.
1815
1821
1816 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
1822 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
1817 command and return its output as a list split on '\n'.
1823 command and return its output as a list split on '\n'.
1818
1824
1819 2004-03-31 Fernando Perez <fperez@colorado.edu>
1825 2004-03-31 Fernando Perez <fperez@colorado.edu>
1820
1826
1821 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
1827 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
1822 method to dictionaries used as FakeModule instances if they lack
1828 method to dictionaries used as FakeModule instances if they lack
1823 it. At least pydoc in python2.3 breaks for runtime-defined
1829 it. At least pydoc in python2.3 breaks for runtime-defined
1824 functions without this hack. At some point I need to _really_
1830 functions without this hack. At some point I need to _really_
1825 understand what FakeModule is doing, because it's a gross hack.
1831 understand what FakeModule is doing, because it's a gross hack.
1826 But it solves Arnd's problem for now...
1832 But it solves Arnd's problem for now...
1827
1833
1828 2004-02-27 Fernando Perez <fperez@colorado.edu>
1834 2004-02-27 Fernando Perez <fperez@colorado.edu>
1829
1835
1830 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
1836 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
1831 mode would behave erratically. Also increased the number of
1837 mode would behave erratically. Also increased the number of
1832 possible logs in rotate mod to 999. Thanks to Rod Holland
1838 possible logs in rotate mod to 999. Thanks to Rod Holland
1833 <rhh@StructureLABS.com> for the report and fixes.
1839 <rhh@StructureLABS.com> for the report and fixes.
1834
1840
1835 2004-02-26 Fernando Perez <fperez@colorado.edu>
1841 2004-02-26 Fernando Perez <fperez@colorado.edu>
1836
1842
1837 * IPython/genutils.py (page): Check that the curses module really
1843 * IPython/genutils.py (page): Check that the curses module really
1838 has the initscr attribute before trying to use it. For some
1844 has the initscr attribute before trying to use it. For some
1839 reason, the Solaris curses module is missing this. I think this
1845 reason, the Solaris curses module is missing this. I think this
1840 should be considered a Solaris python bug, but I'm not sure.
1846 should be considered a Solaris python bug, but I'm not sure.
1841
1847
1842 2004-01-17 Fernando Perez <fperez@colorado.edu>
1848 2004-01-17 Fernando Perez <fperez@colorado.edu>
1843
1849
1844 * IPython/genutils.py (Stream.__init__): Changes to try to make
1850 * IPython/genutils.py (Stream.__init__): Changes to try to make
1845 ipython robust against stdin/out/err being closed by the user.
1851 ipython robust against stdin/out/err being closed by the user.
1846 This is 'user error' (and blocks a normal python session, at least
1852 This is 'user error' (and blocks a normal python session, at least
1847 the stdout case). However, Ipython should be able to survive such
1853 the stdout case). However, Ipython should be able to survive such
1848 instances of abuse as gracefully as possible. To simplify the
1854 instances of abuse as gracefully as possible. To simplify the
1849 coding and maintain compatibility with Gary Bishop's Term
1855 coding and maintain compatibility with Gary Bishop's Term
1850 contributions, I've made use of classmethods for this. I think
1856 contributions, I've made use of classmethods for this. I think
1851 this introduces a dependency on python 2.2.
1857 this introduces a dependency on python 2.2.
1852
1858
1853 2004-01-13 Fernando Perez <fperez@colorado.edu>
1859 2004-01-13 Fernando Perez <fperez@colorado.edu>
1854
1860
1855 * IPython/numutils.py (exp_safe): simplified the code a bit and
1861 * IPython/numutils.py (exp_safe): simplified the code a bit and
1856 removed the need for importing the kinds module altogether.
1862 removed the need for importing the kinds module altogether.
1857
1863
1858 2004-01-06 Fernando Perez <fperez@colorado.edu>
1864 2004-01-06 Fernando Perez <fperez@colorado.edu>
1859
1865
1860 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
1866 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
1861 a magic function instead, after some community feedback. No
1867 a magic function instead, after some community feedback. No
1862 special syntax will exist for it, but its name is deliberately
1868 special syntax will exist for it, but its name is deliberately
1863 very short.
1869 very short.
1864
1870
1865 2003-12-20 Fernando Perez <fperez@colorado.edu>
1871 2003-12-20 Fernando Perez <fperez@colorado.edu>
1866
1872
1867 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
1873 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
1868 new functionality, to automagically assign the result of a shell
1874 new functionality, to automagically assign the result of a shell
1869 command to a variable. I'll solicit some community feedback on
1875 command to a variable. I'll solicit some community feedback on
1870 this before making it permanent.
1876 this before making it permanent.
1871
1877
1872 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
1878 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
1873 requested about callables for which inspect couldn't obtain a
1879 requested about callables for which inspect couldn't obtain a
1874 proper argspec. Thanks to a crash report sent by Etienne
1880 proper argspec. Thanks to a crash report sent by Etienne
1875 Posthumus <etienne-AT-apple01.cs.vu.nl>.
1881 Posthumus <etienne-AT-apple01.cs.vu.nl>.
1876
1882
1877 2003-12-09 Fernando Perez <fperez@colorado.edu>
1883 2003-12-09 Fernando Perez <fperez@colorado.edu>
1878
1884
1879 * IPython/genutils.py (page): patch for the pager to work across
1885 * IPython/genutils.py (page): patch for the pager to work across
1880 various versions of Windows. By Gary Bishop.
1886 various versions of Windows. By Gary Bishop.
1881
1887
1882 2003-12-04 Fernando Perez <fperez@colorado.edu>
1888 2003-12-04 Fernando Perez <fperez@colorado.edu>
1883
1889
1884 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
1890 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
1885 Gnuplot.py version 1.7, whose internal names changed quite a bit.
1891 Gnuplot.py version 1.7, whose internal names changed quite a bit.
1886 While I tested this and it looks ok, there may still be corner
1892 While I tested this and it looks ok, there may still be corner
1887 cases I've missed.
1893 cases I've missed.
1888
1894
1889 2003-12-01 Fernando Perez <fperez@colorado.edu>
1895 2003-12-01 Fernando Perez <fperez@colorado.edu>
1890
1896
1891 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
1897 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
1892 where a line like 'p,q=1,2' would fail because the automagic
1898 where a line like 'p,q=1,2' would fail because the automagic
1893 system would be triggered for @p.
1899 system would be triggered for @p.
1894
1900
1895 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
1901 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
1896 cleanups, code unmodified.
1902 cleanups, code unmodified.
1897
1903
1898 * IPython/genutils.py (Term): added a class for IPython to handle
1904 * IPython/genutils.py (Term): added a class for IPython to handle
1899 output. In most cases it will just be a proxy for stdout/err, but
1905 output. In most cases it will just be a proxy for stdout/err, but
1900 having this allows modifications to be made for some platforms,
1906 having this allows modifications to be made for some platforms,
1901 such as handling color escapes under Windows. All of this code
1907 such as handling color escapes under Windows. All of this code
1902 was contributed by Gary Bishop, with minor modifications by me.
1908 was contributed by Gary Bishop, with minor modifications by me.
1903 The actual changes affect many files.
1909 The actual changes affect many files.
1904
1910
1905 2003-11-30 Fernando Perez <fperez@colorado.edu>
1911 2003-11-30 Fernando Perez <fperez@colorado.edu>
1906
1912
1907 * IPython/iplib.py (file_matches): new completion code, courtesy
1913 * IPython/iplib.py (file_matches): new completion code, courtesy
1908 of Jeff Collins. This enables filename completion again under
1914 of Jeff Collins. This enables filename completion again under
1909 python 2.3, which disabled it at the C level.
1915 python 2.3, which disabled it at the C level.
1910
1916
1911 2003-11-11 Fernando Perez <fperez@colorado.edu>
1917 2003-11-11 Fernando Perez <fperez@colorado.edu>
1912
1918
1913 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
1919 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
1914 for Numeric.array(map(...)), but often convenient.
1920 for Numeric.array(map(...)), but often convenient.
1915
1921
1916 2003-11-05 Fernando Perez <fperez@colorado.edu>
1922 2003-11-05 Fernando Perez <fperez@colorado.edu>
1917
1923
1918 * IPython/numutils.py (frange): Changed a call from int() to
1924 * IPython/numutils.py (frange): Changed a call from int() to
1919 int(round()) to prevent a problem reported with arange() in the
1925 int(round()) to prevent a problem reported with arange() in the
1920 numpy list.
1926 numpy list.
1921
1927
1922 2003-10-06 Fernando Perez <fperez@colorado.edu>
1928 2003-10-06 Fernando Perez <fperez@colorado.edu>
1923
1929
1924 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
1930 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
1925 prevent crashes if sys lacks an argv attribute (it happens with
1931 prevent crashes if sys lacks an argv attribute (it happens with
1926 embedded interpreters which build a bare-bones sys module).
1932 embedded interpreters which build a bare-bones sys module).
1927 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
1933 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
1928
1934
1929 2003-09-24 Fernando Perez <fperez@colorado.edu>
1935 2003-09-24 Fernando Perez <fperez@colorado.edu>
1930
1936
1931 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
1937 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
1932 to protect against poorly written user objects where __getattr__
1938 to protect against poorly written user objects where __getattr__
1933 raises exceptions other than AttributeError. Thanks to a bug
1939 raises exceptions other than AttributeError. Thanks to a bug
1934 report by Oliver Sander <osander-AT-gmx.de>.
1940 report by Oliver Sander <osander-AT-gmx.de>.
1935
1941
1936 * IPython/FakeModule.py (FakeModule.__repr__): this method was
1942 * IPython/FakeModule.py (FakeModule.__repr__): this method was
1937 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
1943 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
1938
1944
1939 2003-09-09 Fernando Perez <fperez@colorado.edu>
1945 2003-09-09 Fernando Perez <fperez@colorado.edu>
1940
1946
1941 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1947 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1942 unpacking a list whith a callable as first element would
1948 unpacking a list whith a callable as first element would
1943 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
1949 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
1944 Collins.
1950 Collins.
1945
1951
1946 2003-08-25 *** Released version 0.5.0
1952 2003-08-25 *** Released version 0.5.0
1947
1953
1948 2003-08-22 Fernando Perez <fperez@colorado.edu>
1954 2003-08-22 Fernando Perez <fperez@colorado.edu>
1949
1955
1950 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
1956 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
1951 improperly defined user exceptions. Thanks to feedback from Mark
1957 improperly defined user exceptions. Thanks to feedback from Mark
1952 Russell <mrussell-AT-verio.net>.
1958 Russell <mrussell-AT-verio.net>.
1953
1959
1954 2003-08-20 Fernando Perez <fperez@colorado.edu>
1960 2003-08-20 Fernando Perez <fperez@colorado.edu>
1955
1961
1956 * IPython/OInspect.py (Inspector.pinfo): changed String Form
1962 * IPython/OInspect.py (Inspector.pinfo): changed String Form
1957 printing so that it would print multi-line string forms starting
1963 printing so that it would print multi-line string forms starting
1958 with a new line. This way the formatting is better respected for
1964 with a new line. This way the formatting is better respected for
1959 objects which work hard to make nice string forms.
1965 objects which work hard to make nice string forms.
1960
1966
1961 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
1967 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
1962 autocall would overtake data access for objects with both
1968 autocall would overtake data access for objects with both
1963 __getitem__ and __call__.
1969 __getitem__ and __call__.
1964
1970
1965 2003-08-19 *** Released version 0.5.0-rc1
1971 2003-08-19 *** Released version 0.5.0-rc1
1966
1972
1967 2003-08-19 Fernando Perez <fperez@colorado.edu>
1973 2003-08-19 Fernando Perez <fperez@colorado.edu>
1968
1974
1969 * IPython/deep_reload.py (load_tail): single tiny change here
1975 * IPython/deep_reload.py (load_tail): single tiny change here
1970 seems to fix the long-standing bug of dreload() failing to work
1976 seems to fix the long-standing bug of dreload() failing to work
1971 for dotted names. But this module is pretty tricky, so I may have
1977 for dotted names. But this module is pretty tricky, so I may have
1972 missed some subtlety. Needs more testing!.
1978 missed some subtlety. Needs more testing!.
1973
1979
1974 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
1980 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
1975 exceptions which have badly implemented __str__ methods.
1981 exceptions which have badly implemented __str__ methods.
1976 (VerboseTB.text): harden against inspect.getinnerframes crashing,
1982 (VerboseTB.text): harden against inspect.getinnerframes crashing,
1977 which I've been getting reports about from Python 2.3 users. I
1983 which I've been getting reports about from Python 2.3 users. I
1978 wish I had a simple test case to reproduce the problem, so I could
1984 wish I had a simple test case to reproduce the problem, so I could
1979 either write a cleaner workaround or file a bug report if
1985 either write a cleaner workaround or file a bug report if
1980 necessary.
1986 necessary.
1981
1987
1982 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
1988 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
1983 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
1989 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
1984 a bug report by Tjabo Kloppenburg.
1990 a bug report by Tjabo Kloppenburg.
1985
1991
1986 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
1992 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
1987 crashes. Wrapped the pdb call in a blanket try/except, since pdb
1993 crashes. Wrapped the pdb call in a blanket try/except, since pdb
1988 seems rather unstable. Thanks to a bug report by Tjabo
1994 seems rather unstable. Thanks to a bug report by Tjabo
1989 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
1995 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
1990
1996
1991 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
1997 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
1992 this out soon because of the critical fixes in the inner loop for
1998 this out soon because of the critical fixes in the inner loop for
1993 generators.
1999 generators.
1994
2000
1995 * IPython/Magic.py (Magic.getargspec): removed. This (and
2001 * IPython/Magic.py (Magic.getargspec): removed. This (and
1996 _get_def) have been obsoleted by OInspect for a long time, I
2002 _get_def) have been obsoleted by OInspect for a long time, I
1997 hadn't noticed that they were dead code.
2003 hadn't noticed that they were dead code.
1998 (Magic._ofind): restored _ofind functionality for a few literals
2004 (Magic._ofind): restored _ofind functionality for a few literals
1999 (those in ["''",'""','[]','{}','()']). But it won't work anymore
2005 (those in ["''",'""','[]','{}','()']). But it won't work anymore
2000 for things like "hello".capitalize?, since that would require a
2006 for things like "hello".capitalize?, since that would require a
2001 potentially dangerous eval() again.
2007 potentially dangerous eval() again.
2002
2008
2003 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
2009 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
2004 logic a bit more to clean up the escapes handling and minimize the
2010 logic a bit more to clean up the escapes handling and minimize the
2005 use of _ofind to only necessary cases. The interactive 'feel' of
2011 use of _ofind to only necessary cases. The interactive 'feel' of
2006 IPython should have improved quite a bit with the changes in
2012 IPython should have improved quite a bit with the changes in
2007 _prefilter and _ofind (besides being far safer than before).
2013 _prefilter and _ofind (besides being far safer than before).
2008
2014
2009 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
2015 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
2010 obscure, never reported). Edit would fail to find the object to
2016 obscure, never reported). Edit would fail to find the object to
2011 edit under some circumstances.
2017 edit under some circumstances.
2012 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
2018 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
2013 which were causing double-calling of generators. Those eval calls
2019 which were causing double-calling of generators. Those eval calls
2014 were _very_ dangerous, since code with side effects could be
2020 were _very_ dangerous, since code with side effects could be
2015 triggered. As they say, 'eval is evil'... These were the
2021 triggered. As they say, 'eval is evil'... These were the
2016 nastiest evals in IPython. Besides, _ofind is now far simpler,
2022 nastiest evals in IPython. Besides, _ofind is now far simpler,
2017 and it should also be quite a bit faster. Its use of inspect is
2023 and it should also be quite a bit faster. Its use of inspect is
2018 also safer, so perhaps some of the inspect-related crashes I've
2024 also safer, so perhaps some of the inspect-related crashes I've
2019 seen lately with Python 2.3 might be taken care of. That will
2025 seen lately with Python 2.3 might be taken care of. That will
2020 need more testing.
2026 need more testing.
2021
2027
2022 2003-08-17 Fernando Perez <fperez@colorado.edu>
2028 2003-08-17 Fernando Perez <fperez@colorado.edu>
2023
2029
2024 * IPython/iplib.py (InteractiveShell._prefilter): significant
2030 * IPython/iplib.py (InteractiveShell._prefilter): significant
2025 simplifications to the logic for handling user escapes. Faster
2031 simplifications to the logic for handling user escapes. Faster
2026 and simpler code.
2032 and simpler code.
2027
2033
2028 2003-08-14 Fernando Perez <fperez@colorado.edu>
2034 2003-08-14 Fernando Perez <fperez@colorado.edu>
2029
2035
2030 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
2036 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
2031 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
2037 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
2032 but it should be quite a bit faster. And the recursive version
2038 but it should be quite a bit faster. And the recursive version
2033 generated O(log N) intermediate storage for all rank>1 arrays,
2039 generated O(log N) intermediate storage for all rank>1 arrays,
2034 even if they were contiguous.
2040 even if they were contiguous.
2035 (l1norm): Added this function.
2041 (l1norm): Added this function.
2036 (norm): Added this function for arbitrary norms (including
2042 (norm): Added this function for arbitrary norms (including
2037 l-infinity). l1 and l2 are still special cases for convenience
2043 l-infinity). l1 and l2 are still special cases for convenience
2038 and speed.
2044 and speed.
2039
2045
2040 2003-08-03 Fernando Perez <fperez@colorado.edu>
2046 2003-08-03 Fernando Perez <fperez@colorado.edu>
2041
2047
2042 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
2048 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
2043 exceptions, which now raise PendingDeprecationWarnings in Python
2049 exceptions, which now raise PendingDeprecationWarnings in Python
2044 2.3. There were some in Magic and some in Gnuplot2.
2050 2.3. There were some in Magic and some in Gnuplot2.
2045
2051
2046 2003-06-30 Fernando Perez <fperez@colorado.edu>
2052 2003-06-30 Fernando Perez <fperez@colorado.edu>
2047
2053
2048 * IPython/genutils.py (page): modified to call curses only for
2054 * IPython/genutils.py (page): modified to call curses only for
2049 terminals where TERM=='xterm'. After problems under many other
2055 terminals where TERM=='xterm'. After problems under many other
2050 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2056 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2051
2057
2052 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2058 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2053 would be triggered when readline was absent. This was just an old
2059 would be triggered when readline was absent. This was just an old
2054 debugging statement I'd forgotten to take out.
2060 debugging statement I'd forgotten to take out.
2055
2061
2056 2003-06-20 Fernando Perez <fperez@colorado.edu>
2062 2003-06-20 Fernando Perez <fperez@colorado.edu>
2057
2063
2058 * IPython/genutils.py (clock): modified to return only user time
2064 * IPython/genutils.py (clock): modified to return only user time
2059 (not counting system time), after a discussion on scipy. While
2065 (not counting system time), after a discussion on scipy. While
2060 system time may be a useful quantity occasionally, it may much
2066 system time may be a useful quantity occasionally, it may much
2061 more easily be skewed by occasional swapping or other similar
2067 more easily be skewed by occasional swapping or other similar
2062 activity.
2068 activity.
2063
2069
2064 2003-06-05 Fernando Perez <fperez@colorado.edu>
2070 2003-06-05 Fernando Perez <fperez@colorado.edu>
2065
2071
2066 * IPython/numutils.py (identity): new function, for building
2072 * IPython/numutils.py (identity): new function, for building
2067 arbitrary rank Kronecker deltas (mostly backwards compatible with
2073 arbitrary rank Kronecker deltas (mostly backwards compatible with
2068 Numeric.identity)
2074 Numeric.identity)
2069
2075
2070 2003-06-03 Fernando Perez <fperez@colorado.edu>
2076 2003-06-03 Fernando Perez <fperez@colorado.edu>
2071
2077
2072 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2078 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2073 arguments passed to magics with spaces, to allow trailing '\' to
2079 arguments passed to magics with spaces, to allow trailing '\' to
2074 work normally (mainly for Windows users).
2080 work normally (mainly for Windows users).
2075
2081
2076 2003-05-29 Fernando Perez <fperez@colorado.edu>
2082 2003-05-29 Fernando Perez <fperez@colorado.edu>
2077
2083
2078 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2084 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2079 instead of pydoc.help. This fixes a bizarre behavior where
2085 instead of pydoc.help. This fixes a bizarre behavior where
2080 printing '%s' % locals() would trigger the help system. Now
2086 printing '%s' % locals() would trigger the help system. Now
2081 ipython behaves like normal python does.
2087 ipython behaves like normal python does.
2082
2088
2083 Note that if one does 'from pydoc import help', the bizarre
2089 Note that if one does 'from pydoc import help', the bizarre
2084 behavior returns, but this will also happen in normal python, so
2090 behavior returns, but this will also happen in normal python, so
2085 it's not an ipython bug anymore (it has to do with how pydoc.help
2091 it's not an ipython bug anymore (it has to do with how pydoc.help
2086 is implemented).
2092 is implemented).
2087
2093
2088 2003-05-22 Fernando Perez <fperez@colorado.edu>
2094 2003-05-22 Fernando Perez <fperez@colorado.edu>
2089
2095
2090 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2096 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2091 return [] instead of None when nothing matches, also match to end
2097 return [] instead of None when nothing matches, also match to end
2092 of line. Patch by Gary Bishop.
2098 of line. Patch by Gary Bishop.
2093
2099
2094 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2100 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2095 protection as before, for files passed on the command line. This
2101 protection as before, for files passed on the command line. This
2096 prevents the CrashHandler from kicking in if user files call into
2102 prevents the CrashHandler from kicking in if user files call into
2097 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2103 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2098 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2104 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2099
2105
2100 2003-05-20 *** Released version 0.4.0
2106 2003-05-20 *** Released version 0.4.0
2101
2107
2102 2003-05-20 Fernando Perez <fperez@colorado.edu>
2108 2003-05-20 Fernando Perez <fperez@colorado.edu>
2103
2109
2104 * setup.py: added support for manpages. It's a bit hackish b/c of
2110 * setup.py: added support for manpages. It's a bit hackish b/c of
2105 a bug in the way the bdist_rpm distutils target handles gzipped
2111 a bug in the way the bdist_rpm distutils target handles gzipped
2106 manpages, but it works. After a patch by Jack.
2112 manpages, but it works. After a patch by Jack.
2107
2113
2108 2003-05-19 Fernando Perez <fperez@colorado.edu>
2114 2003-05-19 Fernando Perez <fperez@colorado.edu>
2109
2115
2110 * IPython/numutils.py: added a mockup of the kinds module, since
2116 * IPython/numutils.py: added a mockup of the kinds module, since
2111 it was recently removed from Numeric. This way, numutils will
2117 it was recently removed from Numeric. This way, numutils will
2112 work for all users even if they are missing kinds.
2118 work for all users even if they are missing kinds.
2113
2119
2114 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2120 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2115 failure, which can occur with SWIG-wrapped extensions. After a
2121 failure, which can occur with SWIG-wrapped extensions. After a
2116 crash report from Prabhu.
2122 crash report from Prabhu.
2117
2123
2118 2003-05-16 Fernando Perez <fperez@colorado.edu>
2124 2003-05-16 Fernando Perez <fperez@colorado.edu>
2119
2125
2120 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2126 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2121 protect ipython from user code which may call directly
2127 protect ipython from user code which may call directly
2122 sys.excepthook (this looks like an ipython crash to the user, even
2128 sys.excepthook (this looks like an ipython crash to the user, even
2123 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2129 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2124 This is especially important to help users of WxWindows, but may
2130 This is especially important to help users of WxWindows, but may
2125 also be useful in other cases.
2131 also be useful in other cases.
2126
2132
2127 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2133 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2128 an optional tb_offset to be specified, and to preserve exception
2134 an optional tb_offset to be specified, and to preserve exception
2129 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2135 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2130
2136
2131 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2137 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2132
2138
2133 2003-05-15 Fernando Perez <fperez@colorado.edu>
2139 2003-05-15 Fernando Perez <fperez@colorado.edu>
2134
2140
2135 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2141 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2136 installing for a new user under Windows.
2142 installing for a new user under Windows.
2137
2143
2138 2003-05-12 Fernando Perez <fperez@colorado.edu>
2144 2003-05-12 Fernando Perez <fperez@colorado.edu>
2139
2145
2140 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2146 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2141 handler for Emacs comint-based lines. Currently it doesn't do
2147 handler for Emacs comint-based lines. Currently it doesn't do
2142 much (but importantly, it doesn't update the history cache). In
2148 much (but importantly, it doesn't update the history cache). In
2143 the future it may be expanded if Alex needs more functionality
2149 the future it may be expanded if Alex needs more functionality
2144 there.
2150 there.
2145
2151
2146 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2152 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2147 info to crash reports.
2153 info to crash reports.
2148
2154
2149 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2155 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2150 just like Python's -c. Also fixed crash with invalid -color
2156 just like Python's -c. Also fixed crash with invalid -color
2151 option value at startup. Thanks to Will French
2157 option value at startup. Thanks to Will French
2152 <wfrench-AT-bestweb.net> for the bug report.
2158 <wfrench-AT-bestweb.net> for the bug report.
2153
2159
2154 2003-05-09 Fernando Perez <fperez@colorado.edu>
2160 2003-05-09 Fernando Perez <fperez@colorado.edu>
2155
2161
2156 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2162 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2157 to EvalDict (it's a mapping, after all) and simplified its code
2163 to EvalDict (it's a mapping, after all) and simplified its code
2158 quite a bit, after a nice discussion on c.l.py where Gustavo
2164 quite a bit, after a nice discussion on c.l.py where Gustavo
2159 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
2165 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
2160
2166
2161 2003-04-30 Fernando Perez <fperez@colorado.edu>
2167 2003-04-30 Fernando Perez <fperez@colorado.edu>
2162
2168
2163 * IPython/genutils.py (timings_out): modified it to reduce its
2169 * IPython/genutils.py (timings_out): modified it to reduce its
2164 overhead in the common reps==1 case.
2170 overhead in the common reps==1 case.
2165
2171
2166 2003-04-29 Fernando Perez <fperez@colorado.edu>
2172 2003-04-29 Fernando Perez <fperez@colorado.edu>
2167
2173
2168 * IPython/genutils.py (timings_out): Modified to use the resource
2174 * IPython/genutils.py (timings_out): Modified to use the resource
2169 module, which avoids the wraparound problems of time.clock().
2175 module, which avoids the wraparound problems of time.clock().
2170
2176
2171 2003-04-17 *** Released version 0.2.15pre4
2177 2003-04-17 *** Released version 0.2.15pre4
2172
2178
2173 2003-04-17 Fernando Perez <fperez@colorado.edu>
2179 2003-04-17 Fernando Perez <fperez@colorado.edu>
2174
2180
2175 * setup.py (scriptfiles): Split windows-specific stuff over to a
2181 * setup.py (scriptfiles): Split windows-specific stuff over to a
2176 separate file, in an attempt to have a Windows GUI installer.
2182 separate file, in an attempt to have a Windows GUI installer.
2177 That didn't work, but part of the groundwork is done.
2183 That didn't work, but part of the groundwork is done.
2178
2184
2179 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2185 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2180 indent/unindent with 4 spaces. Particularly useful in combination
2186 indent/unindent with 4 spaces. Particularly useful in combination
2181 with the new auto-indent option.
2187 with the new auto-indent option.
2182
2188
2183 2003-04-16 Fernando Perez <fperez@colorado.edu>
2189 2003-04-16 Fernando Perez <fperez@colorado.edu>
2184
2190
2185 * IPython/Magic.py: various replacements of self.rc for
2191 * IPython/Magic.py: various replacements of self.rc for
2186 self.shell.rc. A lot more remains to be done to fully disentangle
2192 self.shell.rc. A lot more remains to be done to fully disentangle
2187 this class from the main Shell class.
2193 this class from the main Shell class.
2188
2194
2189 * IPython/GnuplotRuntime.py: added checks for mouse support so
2195 * IPython/GnuplotRuntime.py: added checks for mouse support so
2190 that we don't try to enable it if the current gnuplot doesn't
2196 that we don't try to enable it if the current gnuplot doesn't
2191 really support it. Also added checks so that we don't try to
2197 really support it. Also added checks so that we don't try to
2192 enable persist under Windows (where Gnuplot doesn't recognize the
2198 enable persist under Windows (where Gnuplot doesn't recognize the
2193 option).
2199 option).
2194
2200
2195 * IPython/iplib.py (InteractiveShell.interact): Added optional
2201 * IPython/iplib.py (InteractiveShell.interact): Added optional
2196 auto-indenting code, after a patch by King C. Shu
2202 auto-indenting code, after a patch by King C. Shu
2197 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2203 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2198 get along well with pasting indented code. If I ever figure out
2204 get along well with pasting indented code. If I ever figure out
2199 how to make that part go well, it will become on by default.
2205 how to make that part go well, it will become on by default.
2200
2206
2201 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2207 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2202 crash ipython if there was an unmatched '%' in the user's prompt
2208 crash ipython if there was an unmatched '%' in the user's prompt
2203 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2209 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2204
2210
2205 * IPython/iplib.py (InteractiveShell.interact): removed the
2211 * IPython/iplib.py (InteractiveShell.interact): removed the
2206 ability to ask the user whether he wants to crash or not at the
2212 ability to ask the user whether he wants to crash or not at the
2207 'last line' exception handler. Calling functions at that point
2213 'last line' exception handler. Calling functions at that point
2208 changes the stack, and the error reports would have incorrect
2214 changes the stack, and the error reports would have incorrect
2209 tracebacks.
2215 tracebacks.
2210
2216
2211 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2217 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2212 pass through a peger a pretty-printed form of any object. After a
2218 pass through a peger a pretty-printed form of any object. After a
2213 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2219 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2214
2220
2215 2003-04-14 Fernando Perez <fperez@colorado.edu>
2221 2003-04-14 Fernando Perez <fperez@colorado.edu>
2216
2222
2217 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2223 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2218 all files in ~ would be modified at first install (instead of
2224 all files in ~ would be modified at first install (instead of
2219 ~/.ipython). This could be potentially disastrous, as the
2225 ~/.ipython). This could be potentially disastrous, as the
2220 modification (make line-endings native) could damage binary files.
2226 modification (make line-endings native) could damage binary files.
2221
2227
2222 2003-04-10 Fernando Perez <fperez@colorado.edu>
2228 2003-04-10 Fernando Perez <fperez@colorado.edu>
2223
2229
2224 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2230 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2225 handle only lines which are invalid python. This now means that
2231 handle only lines which are invalid python. This now means that
2226 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2232 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2227 for the bug report.
2233 for the bug report.
2228
2234
2229 2003-04-01 Fernando Perez <fperez@colorado.edu>
2235 2003-04-01 Fernando Perez <fperez@colorado.edu>
2230
2236
2231 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2237 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2232 where failing to set sys.last_traceback would crash pdb.pm().
2238 where failing to set sys.last_traceback would crash pdb.pm().
2233 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2239 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2234 report.
2240 report.
2235
2241
2236 2003-03-25 Fernando Perez <fperez@colorado.edu>
2242 2003-03-25 Fernando Perez <fperez@colorado.edu>
2237
2243
2238 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2244 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2239 before printing it (it had a lot of spurious blank lines at the
2245 before printing it (it had a lot of spurious blank lines at the
2240 end).
2246 end).
2241
2247
2242 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2248 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2243 output would be sent 21 times! Obviously people don't use this
2249 output would be sent 21 times! Obviously people don't use this
2244 too often, or I would have heard about it.
2250 too often, or I would have heard about it.
2245
2251
2246 2003-03-24 Fernando Perez <fperez@colorado.edu>
2252 2003-03-24 Fernando Perez <fperez@colorado.edu>
2247
2253
2248 * setup.py (scriptfiles): renamed the data_files parameter from
2254 * setup.py (scriptfiles): renamed the data_files parameter from
2249 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2255 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2250 for the patch.
2256 for the patch.
2251
2257
2252 2003-03-20 Fernando Perez <fperez@colorado.edu>
2258 2003-03-20 Fernando Perez <fperez@colorado.edu>
2253
2259
2254 * IPython/genutils.py (error): added error() and fatal()
2260 * IPython/genutils.py (error): added error() and fatal()
2255 functions.
2261 functions.
2256
2262
2257 2003-03-18 *** Released version 0.2.15pre3
2263 2003-03-18 *** Released version 0.2.15pre3
2258
2264
2259 2003-03-18 Fernando Perez <fperez@colorado.edu>
2265 2003-03-18 Fernando Perez <fperez@colorado.edu>
2260
2266
2261 * setupext/install_data_ext.py
2267 * setupext/install_data_ext.py
2262 (install_data_ext.initialize_options): Class contributed by Jack
2268 (install_data_ext.initialize_options): Class contributed by Jack
2263 Moffit for fixing the old distutils hack. He is sending this to
2269 Moffit for fixing the old distutils hack. He is sending this to
2264 the distutils folks so in the future we may not need it as a
2270 the distutils folks so in the future we may not need it as a
2265 private fix.
2271 private fix.
2266
2272
2267 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2273 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2268 changes for Debian packaging. See his patch for full details.
2274 changes for Debian packaging. See his patch for full details.
2269 The old distutils hack of making the ipythonrc* files carry a
2275 The old distutils hack of making the ipythonrc* files carry a
2270 bogus .py extension is gone, at last. Examples were moved to a
2276 bogus .py extension is gone, at last. Examples were moved to a
2271 separate subdir under doc/, and the separate executable scripts
2277 separate subdir under doc/, and the separate executable scripts
2272 now live in their own directory. Overall a great cleanup. The
2278 now live in their own directory. Overall a great cleanup. The
2273 manual was updated to use the new files, and setup.py has been
2279 manual was updated to use the new files, and setup.py has been
2274 fixed for this setup.
2280 fixed for this setup.
2275
2281
2276 * IPython/PyColorize.py (Parser.usage): made non-executable and
2282 * IPython/PyColorize.py (Parser.usage): made non-executable and
2277 created a pycolor wrapper around it to be included as a script.
2283 created a pycolor wrapper around it to be included as a script.
2278
2284
2279 2003-03-12 *** Released version 0.2.15pre2
2285 2003-03-12 *** Released version 0.2.15pre2
2280
2286
2281 2003-03-12 Fernando Perez <fperez@colorado.edu>
2287 2003-03-12 Fernando Perez <fperez@colorado.edu>
2282
2288
2283 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2289 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2284 long-standing problem with garbage characters in some terminals.
2290 long-standing problem with garbage characters in some terminals.
2285 The issue was really that the \001 and \002 escapes must _only_ be
2291 The issue was really that the \001 and \002 escapes must _only_ be
2286 passed to input prompts (which call readline), but _never_ to
2292 passed to input prompts (which call readline), but _never_ to
2287 normal text to be printed on screen. I changed ColorANSI to have
2293 normal text to be printed on screen. I changed ColorANSI to have
2288 two classes: TermColors and InputTermColors, each with the
2294 two classes: TermColors and InputTermColors, each with the
2289 appropriate escapes for input prompts or normal text. The code in
2295 appropriate escapes for input prompts or normal text. The code in
2290 Prompts.py got slightly more complicated, but this very old and
2296 Prompts.py got slightly more complicated, but this very old and
2291 annoying bug is finally fixed.
2297 annoying bug is finally fixed.
2292
2298
2293 All the credit for nailing down the real origin of this problem
2299 All the credit for nailing down the real origin of this problem
2294 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2300 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2295 *Many* thanks to him for spending quite a bit of effort on this.
2301 *Many* thanks to him for spending quite a bit of effort on this.
2296
2302
2297 2003-03-05 *** Released version 0.2.15pre1
2303 2003-03-05 *** Released version 0.2.15pre1
2298
2304
2299 2003-03-03 Fernando Perez <fperez@colorado.edu>
2305 2003-03-03 Fernando Perez <fperez@colorado.edu>
2300
2306
2301 * IPython/FakeModule.py: Moved the former _FakeModule to a
2307 * IPython/FakeModule.py: Moved the former _FakeModule to a
2302 separate file, because it's also needed by Magic (to fix a similar
2308 separate file, because it's also needed by Magic (to fix a similar
2303 pickle-related issue in @run).
2309 pickle-related issue in @run).
2304
2310
2305 2003-03-02 Fernando Perez <fperez@colorado.edu>
2311 2003-03-02 Fernando Perez <fperez@colorado.edu>
2306
2312
2307 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2313 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2308 the autocall option at runtime.
2314 the autocall option at runtime.
2309 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2315 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2310 across Magic.py to start separating Magic from InteractiveShell.
2316 across Magic.py to start separating Magic from InteractiveShell.
2311 (Magic._ofind): Fixed to return proper namespace for dotted
2317 (Magic._ofind): Fixed to return proper namespace for dotted
2312 names. Before, a dotted name would always return 'not currently
2318 names. Before, a dotted name would always return 'not currently
2313 defined', because it would find the 'parent'. s.x would be found,
2319 defined', because it would find the 'parent'. s.x would be found,
2314 but since 'x' isn't defined by itself, it would get confused.
2320 but since 'x' isn't defined by itself, it would get confused.
2315 (Magic.magic_run): Fixed pickling problems reported by Ralf
2321 (Magic.magic_run): Fixed pickling problems reported by Ralf
2316 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2322 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2317 that I'd used when Mike Heeter reported similar issues at the
2323 that I'd used when Mike Heeter reported similar issues at the
2318 top-level, but now for @run. It boils down to injecting the
2324 top-level, but now for @run. It boils down to injecting the
2319 namespace where code is being executed with something that looks
2325 namespace where code is being executed with something that looks
2320 enough like a module to fool pickle.dump(). Since a pickle stores
2326 enough like a module to fool pickle.dump(). Since a pickle stores
2321 a named reference to the importing module, we need this for
2327 a named reference to the importing module, we need this for
2322 pickles to save something sensible.
2328 pickles to save something sensible.
2323
2329
2324 * IPython/ipmaker.py (make_IPython): added an autocall option.
2330 * IPython/ipmaker.py (make_IPython): added an autocall option.
2325
2331
2326 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2332 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2327 the auto-eval code. Now autocalling is an option, and the code is
2333 the auto-eval code. Now autocalling is an option, and the code is
2328 also vastly safer. There is no more eval() involved at all.
2334 also vastly safer. There is no more eval() involved at all.
2329
2335
2330 2003-03-01 Fernando Perez <fperez@colorado.edu>
2336 2003-03-01 Fernando Perez <fperez@colorado.edu>
2331
2337
2332 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2338 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2333 dict with named keys instead of a tuple.
2339 dict with named keys instead of a tuple.
2334
2340
2335 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2341 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2336
2342
2337 * setup.py (make_shortcut): Fixed message about directories
2343 * setup.py (make_shortcut): Fixed message about directories
2338 created during Windows installation (the directories were ok, just
2344 created during Windows installation (the directories were ok, just
2339 the printed message was misleading). Thanks to Chris Liechti
2345 the printed message was misleading). Thanks to Chris Liechti
2340 <cliechti-AT-gmx.net> for the heads up.
2346 <cliechti-AT-gmx.net> for the heads up.
2341
2347
2342 2003-02-21 Fernando Perez <fperez@colorado.edu>
2348 2003-02-21 Fernando Perez <fperez@colorado.edu>
2343
2349
2344 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2350 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2345 of ValueError exception when checking for auto-execution. This
2351 of ValueError exception when checking for auto-execution. This
2346 one is raised by things like Numeric arrays arr.flat when the
2352 one is raised by things like Numeric arrays arr.flat when the
2347 array is non-contiguous.
2353 array is non-contiguous.
2348
2354
2349 2003-01-31 Fernando Perez <fperez@colorado.edu>
2355 2003-01-31 Fernando Perez <fperez@colorado.edu>
2350
2356
2351 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2357 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2352 not return any value at all (even though the command would get
2358 not return any value at all (even though the command would get
2353 executed).
2359 executed).
2354 (xsys): Flush stdout right after printing the command to ensure
2360 (xsys): Flush stdout right after printing the command to ensure
2355 proper ordering of commands and command output in the total
2361 proper ordering of commands and command output in the total
2356 output.
2362 output.
2357 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2363 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2358 system/getoutput as defaults. The old ones are kept for
2364 system/getoutput as defaults. The old ones are kept for
2359 compatibility reasons, so no code which uses this library needs
2365 compatibility reasons, so no code which uses this library needs
2360 changing.
2366 changing.
2361
2367
2362 2003-01-27 *** Released version 0.2.14
2368 2003-01-27 *** Released version 0.2.14
2363
2369
2364 2003-01-25 Fernando Perez <fperez@colorado.edu>
2370 2003-01-25 Fernando Perez <fperez@colorado.edu>
2365
2371
2366 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2372 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2367 functions defined in previous edit sessions could not be re-edited
2373 functions defined in previous edit sessions could not be re-edited
2368 (because the temp files were immediately removed). Now temp files
2374 (because the temp files were immediately removed). Now temp files
2369 are removed only at IPython's exit.
2375 are removed only at IPython's exit.
2370 (Magic.magic_run): Improved @run to perform shell-like expansions
2376 (Magic.magic_run): Improved @run to perform shell-like expansions
2371 on its arguments (~users and $VARS). With this, @run becomes more
2377 on its arguments (~users and $VARS). With this, @run becomes more
2372 like a normal command-line.
2378 like a normal command-line.
2373
2379
2374 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2380 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2375 bugs related to embedding and cleaned up that code. A fairly
2381 bugs related to embedding and cleaned up that code. A fairly
2376 important one was the impossibility to access the global namespace
2382 important one was the impossibility to access the global namespace
2377 through the embedded IPython (only local variables were visible).
2383 through the embedded IPython (only local variables were visible).
2378
2384
2379 2003-01-14 Fernando Perez <fperez@colorado.edu>
2385 2003-01-14 Fernando Perez <fperez@colorado.edu>
2380
2386
2381 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
2387 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
2382 auto-calling to be a bit more conservative. Now it doesn't get
2388 auto-calling to be a bit more conservative. Now it doesn't get
2383 triggered if any of '!=()<>' are in the rest of the input line, to
2389 triggered if any of '!=()<>' are in the rest of the input line, to
2384 allow comparing callables. Thanks to Alex for the heads up.
2390 allow comparing callables. Thanks to Alex for the heads up.
2385
2391
2386 2003-01-07 Fernando Perez <fperez@colorado.edu>
2392 2003-01-07 Fernando Perez <fperez@colorado.edu>
2387
2393
2388 * IPython/genutils.py (page): fixed estimation of the number of
2394 * IPython/genutils.py (page): fixed estimation of the number of
2389 lines in a string to be paged to simply count newlines. This
2395 lines in a string to be paged to simply count newlines. This
2390 prevents over-guessing due to embedded escape sequences. A better
2396 prevents over-guessing due to embedded escape sequences. A better
2391 long-term solution would involve stripping out the control chars
2397 long-term solution would involve stripping out the control chars
2392 for the count, but it's potentially so expensive I just don't
2398 for the count, but it's potentially so expensive I just don't
2393 think it's worth doing.
2399 think it's worth doing.
2394
2400
2395 2002-12-19 *** Released version 0.2.14pre50
2401 2002-12-19 *** Released version 0.2.14pre50
2396
2402
2397 2002-12-19 Fernando Perez <fperez@colorado.edu>
2403 2002-12-19 Fernando Perez <fperez@colorado.edu>
2398
2404
2399 * tools/release (version): Changed release scripts to inform
2405 * tools/release (version): Changed release scripts to inform
2400 Andrea and build a NEWS file with a list of recent changes.
2406 Andrea and build a NEWS file with a list of recent changes.
2401
2407
2402 * IPython/ColorANSI.py (__all__): changed terminal detection
2408 * IPython/ColorANSI.py (__all__): changed terminal detection
2403 code. Seems to work better for xterms without breaking
2409 code. Seems to work better for xterms without breaking
2404 konsole. Will need more testing to determine if WinXP and Mac OSX
2410 konsole. Will need more testing to determine if WinXP and Mac OSX
2405 also work ok.
2411 also work ok.
2406
2412
2407 2002-12-18 *** Released version 0.2.14pre49
2413 2002-12-18 *** Released version 0.2.14pre49
2408
2414
2409 2002-12-18 Fernando Perez <fperez@colorado.edu>
2415 2002-12-18 Fernando Perez <fperez@colorado.edu>
2410
2416
2411 * Docs: added new info about Mac OSX, from Andrea.
2417 * Docs: added new info about Mac OSX, from Andrea.
2412
2418
2413 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
2419 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
2414 allow direct plotting of python strings whose format is the same
2420 allow direct plotting of python strings whose format is the same
2415 of gnuplot data files.
2421 of gnuplot data files.
2416
2422
2417 2002-12-16 Fernando Perez <fperez@colorado.edu>
2423 2002-12-16 Fernando Perez <fperez@colorado.edu>
2418
2424
2419 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
2425 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
2420 value of exit question to be acknowledged.
2426 value of exit question to be acknowledged.
2421
2427
2422 2002-12-03 Fernando Perez <fperez@colorado.edu>
2428 2002-12-03 Fernando Perez <fperez@colorado.edu>
2423
2429
2424 * IPython/ipmaker.py: removed generators, which had been added
2430 * IPython/ipmaker.py: removed generators, which had been added
2425 by mistake in an earlier debugging run. This was causing trouble
2431 by mistake in an earlier debugging run. This was causing trouble
2426 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
2432 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
2427 for pointing this out.
2433 for pointing this out.
2428
2434
2429 2002-11-17 Fernando Perez <fperez@colorado.edu>
2435 2002-11-17 Fernando Perez <fperez@colorado.edu>
2430
2436
2431 * Manual: updated the Gnuplot section.
2437 * Manual: updated the Gnuplot section.
2432
2438
2433 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
2439 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
2434 a much better split of what goes in Runtime and what goes in
2440 a much better split of what goes in Runtime and what goes in
2435 Interactive.
2441 Interactive.
2436
2442
2437 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
2443 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
2438 being imported from iplib.
2444 being imported from iplib.
2439
2445
2440 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
2446 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
2441 for command-passing. Now the global Gnuplot instance is called
2447 for command-passing. Now the global Gnuplot instance is called
2442 'gp' instead of 'g', which was really a far too fragile and
2448 'gp' instead of 'g', which was really a far too fragile and
2443 common name.
2449 common name.
2444
2450
2445 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
2451 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
2446 bounding boxes generated by Gnuplot for square plots.
2452 bounding boxes generated by Gnuplot for square plots.
2447
2453
2448 * IPython/genutils.py (popkey): new function added. I should
2454 * IPython/genutils.py (popkey): new function added. I should
2449 suggest this on c.l.py as a dict method, it seems useful.
2455 suggest this on c.l.py as a dict method, it seems useful.
2450
2456
2451 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
2457 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
2452 to transparently handle PostScript generation. MUCH better than
2458 to transparently handle PostScript generation. MUCH better than
2453 the previous plot_eps/replot_eps (which I removed now). The code
2459 the previous plot_eps/replot_eps (which I removed now). The code
2454 is also fairly clean and well documented now (including
2460 is also fairly clean and well documented now (including
2455 docstrings).
2461 docstrings).
2456
2462
2457 2002-11-13 Fernando Perez <fperez@colorado.edu>
2463 2002-11-13 Fernando Perez <fperez@colorado.edu>
2458
2464
2459 * IPython/Magic.py (Magic.magic_edit): fixed docstring
2465 * IPython/Magic.py (Magic.magic_edit): fixed docstring
2460 (inconsistent with options).
2466 (inconsistent with options).
2461
2467
2462 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
2468 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
2463 manually disabled, I don't know why. Fixed it.
2469 manually disabled, I don't know why. Fixed it.
2464 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
2470 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
2465 eps output.
2471 eps output.
2466
2472
2467 2002-11-12 Fernando Perez <fperez@colorado.edu>
2473 2002-11-12 Fernando Perez <fperez@colorado.edu>
2468
2474
2469 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
2475 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
2470 don't propagate up to caller. Fixes crash reported by François
2476 don't propagate up to caller. Fixes crash reported by François
2471 Pinard.
2477 Pinard.
2472
2478
2473 2002-11-09 Fernando Perez <fperez@colorado.edu>
2479 2002-11-09 Fernando Perez <fperez@colorado.edu>
2474
2480
2475 * IPython/ipmaker.py (make_IPython): fixed problem with writing
2481 * IPython/ipmaker.py (make_IPython): fixed problem with writing
2476 history file for new users.
2482 history file for new users.
2477 (make_IPython): fixed bug where initial install would leave the
2483 (make_IPython): fixed bug where initial install would leave the
2478 user running in the .ipython dir.
2484 user running in the .ipython dir.
2479 (make_IPython): fixed bug where config dir .ipython would be
2485 (make_IPython): fixed bug where config dir .ipython would be
2480 created regardless of the given -ipythondir option. Thanks to Cory
2486 created regardless of the given -ipythondir option. Thanks to Cory
2481 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
2487 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
2482
2488
2483 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
2489 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
2484 type confirmations. Will need to use it in all of IPython's code
2490 type confirmations. Will need to use it in all of IPython's code
2485 consistently.
2491 consistently.
2486
2492
2487 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
2493 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
2488 context to print 31 lines instead of the default 5. This will make
2494 context to print 31 lines instead of the default 5. This will make
2489 the crash reports extremely detailed in case the problem is in
2495 the crash reports extremely detailed in case the problem is in
2490 libraries I don't have access to.
2496 libraries I don't have access to.
2491
2497
2492 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
2498 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
2493 line of defense' code to still crash, but giving users fair
2499 line of defense' code to still crash, but giving users fair
2494 warning. I don't want internal errors to go unreported: if there's
2500 warning. I don't want internal errors to go unreported: if there's
2495 an internal problem, IPython should crash and generate a full
2501 an internal problem, IPython should crash and generate a full
2496 report.
2502 report.
2497
2503
2498 2002-11-08 Fernando Perez <fperez@colorado.edu>
2504 2002-11-08 Fernando Perez <fperez@colorado.edu>
2499
2505
2500 * IPython/iplib.py (InteractiveShell.interact): added code to trap
2506 * IPython/iplib.py (InteractiveShell.interact): added code to trap
2501 otherwise uncaught exceptions which can appear if people set
2507 otherwise uncaught exceptions which can appear if people set
2502 sys.stdout to something badly broken. Thanks to a crash report
2508 sys.stdout to something badly broken. Thanks to a crash report
2503 from henni-AT-mail.brainbot.com.
2509 from henni-AT-mail.brainbot.com.
2504
2510
2505 2002-11-04 Fernando Perez <fperez@colorado.edu>
2511 2002-11-04 Fernando Perez <fperez@colorado.edu>
2506
2512
2507 * IPython/iplib.py (InteractiveShell.interact): added
2513 * IPython/iplib.py (InteractiveShell.interact): added
2508 __IPYTHON__active to the builtins. It's a flag which goes on when
2514 __IPYTHON__active to the builtins. It's a flag which goes on when
2509 the interaction starts and goes off again when it stops. This
2515 the interaction starts and goes off again when it stops. This
2510 allows embedding code to detect being inside IPython. Before this
2516 allows embedding code to detect being inside IPython. Before this
2511 was done via __IPYTHON__, but that only shows that an IPython
2517 was done via __IPYTHON__, but that only shows that an IPython
2512 instance has been created.
2518 instance has been created.
2513
2519
2514 * IPython/Magic.py (Magic.magic_env): I realized that in a
2520 * IPython/Magic.py (Magic.magic_env): I realized that in a
2515 UserDict, instance.data holds the data as a normal dict. So I
2521 UserDict, instance.data holds the data as a normal dict. So I
2516 modified @env to return os.environ.data instead of rebuilding a
2522 modified @env to return os.environ.data instead of rebuilding a
2517 dict by hand.
2523 dict by hand.
2518
2524
2519 2002-11-02 Fernando Perez <fperez@colorado.edu>
2525 2002-11-02 Fernando Perez <fperez@colorado.edu>
2520
2526
2521 * IPython/genutils.py (warn): changed so that level 1 prints no
2527 * IPython/genutils.py (warn): changed so that level 1 prints no
2522 header. Level 2 is now the default (with 'WARNING' header, as
2528 header. Level 2 is now the default (with 'WARNING' header, as
2523 before). I think I tracked all places where changes were needed in
2529 before). I think I tracked all places where changes were needed in
2524 IPython, but outside code using the old level numbering may have
2530 IPython, but outside code using the old level numbering may have
2525 broken.
2531 broken.
2526
2532
2527 * IPython/iplib.py (InteractiveShell.runcode): added this to
2533 * IPython/iplib.py (InteractiveShell.runcode): added this to
2528 handle the tracebacks in SystemExit traps correctly. The previous
2534 handle the tracebacks in SystemExit traps correctly. The previous
2529 code (through interact) was printing more of the stack than
2535 code (through interact) was printing more of the stack than
2530 necessary, showing IPython internal code to the user.
2536 necessary, showing IPython internal code to the user.
2531
2537
2532 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
2538 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
2533 default. Now that the default at the confirmation prompt is yes,
2539 default. Now that the default at the confirmation prompt is yes,
2534 it's not so intrusive. François' argument that ipython sessions
2540 it's not so intrusive. François' argument that ipython sessions
2535 tend to be complex enough not to lose them from an accidental C-d,
2541 tend to be complex enough not to lose them from an accidental C-d,
2536 is a valid one.
2542 is a valid one.
2537
2543
2538 * IPython/iplib.py (InteractiveShell.interact): added a
2544 * IPython/iplib.py (InteractiveShell.interact): added a
2539 showtraceback() call to the SystemExit trap, and modified the exit
2545 showtraceback() call to the SystemExit trap, and modified the exit
2540 confirmation to have yes as the default.
2546 confirmation to have yes as the default.
2541
2547
2542 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
2548 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
2543 this file. It's been gone from the code for a long time, this was
2549 this file. It's been gone from the code for a long time, this was
2544 simply leftover junk.
2550 simply leftover junk.
2545
2551
2546 2002-11-01 Fernando Perez <fperez@colorado.edu>
2552 2002-11-01 Fernando Perez <fperez@colorado.edu>
2547
2553
2548 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
2554 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
2549 added. If set, IPython now traps EOF and asks for
2555 added. If set, IPython now traps EOF and asks for
2550 confirmation. After a request by François Pinard.
2556 confirmation. After a request by François Pinard.
2551
2557
2552 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
2558 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
2553 of @abort, and with a new (better) mechanism for handling the
2559 of @abort, and with a new (better) mechanism for handling the
2554 exceptions.
2560 exceptions.
2555
2561
2556 2002-10-27 Fernando Perez <fperez@colorado.edu>
2562 2002-10-27 Fernando Perez <fperez@colorado.edu>
2557
2563
2558 * IPython/usage.py (__doc__): updated the --help information and
2564 * IPython/usage.py (__doc__): updated the --help information and
2559 the ipythonrc file to indicate that -log generates
2565 the ipythonrc file to indicate that -log generates
2560 ./ipython.log. Also fixed the corresponding info in @logstart.
2566 ./ipython.log. Also fixed the corresponding info in @logstart.
2561 This and several other fixes in the manuals thanks to reports by
2567 This and several other fixes in the manuals thanks to reports by
2562 François Pinard <pinard-AT-iro.umontreal.ca>.
2568 François Pinard <pinard-AT-iro.umontreal.ca>.
2563
2569
2564 * IPython/Logger.py (Logger.switch_log): Fixed error message to
2570 * IPython/Logger.py (Logger.switch_log): Fixed error message to
2565 refer to @logstart (instead of @log, which doesn't exist).
2571 refer to @logstart (instead of @log, which doesn't exist).
2566
2572
2567 * IPython/iplib.py (InteractiveShell._prefilter): fixed
2573 * IPython/iplib.py (InteractiveShell._prefilter): fixed
2568 AttributeError crash. Thanks to Christopher Armstrong
2574 AttributeError crash. Thanks to Christopher Armstrong
2569 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
2575 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
2570 introduced recently (in 0.2.14pre37) with the fix to the eval
2576 introduced recently (in 0.2.14pre37) with the fix to the eval
2571 problem mentioned below.
2577 problem mentioned below.
2572
2578
2573 2002-10-17 Fernando Perez <fperez@colorado.edu>
2579 2002-10-17 Fernando Perez <fperez@colorado.edu>
2574
2580
2575 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
2581 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
2576 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
2582 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
2577
2583
2578 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
2584 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
2579 this function to fix a problem reported by Alex Schmolck. He saw
2585 this function to fix a problem reported by Alex Schmolck. He saw
2580 it with list comprehensions and generators, which were getting
2586 it with list comprehensions and generators, which were getting
2581 called twice. The real problem was an 'eval' call in testing for
2587 called twice. The real problem was an 'eval' call in testing for
2582 automagic which was evaluating the input line silently.
2588 automagic which was evaluating the input line silently.
2583
2589
2584 This is a potentially very nasty bug, if the input has side
2590 This is a potentially very nasty bug, if the input has side
2585 effects which must not be repeated. The code is much cleaner now,
2591 effects which must not be repeated. The code is much cleaner now,
2586 without any blanket 'except' left and with a regexp test for
2592 without any blanket 'except' left and with a regexp test for
2587 actual function names.
2593 actual function names.
2588
2594
2589 But an eval remains, which I'm not fully comfortable with. I just
2595 But an eval remains, which I'm not fully comfortable with. I just
2590 don't know how to find out if an expression could be a callable in
2596 don't know how to find out if an expression could be a callable in
2591 the user's namespace without doing an eval on the string. However
2597 the user's namespace without doing an eval on the string. However
2592 that string is now much more strictly checked so that no code
2598 that string is now much more strictly checked so that no code
2593 slips by, so the eval should only happen for things that can
2599 slips by, so the eval should only happen for things that can
2594 really be only function/method names.
2600 really be only function/method names.
2595
2601
2596 2002-10-15 Fernando Perez <fperez@colorado.edu>
2602 2002-10-15 Fernando Perez <fperez@colorado.edu>
2597
2603
2598 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
2604 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
2599 OSX information to main manual, removed README_Mac_OSX file from
2605 OSX information to main manual, removed README_Mac_OSX file from
2600 distribution. Also updated credits for recent additions.
2606 distribution. Also updated credits for recent additions.
2601
2607
2602 2002-10-10 Fernando Perez <fperez@colorado.edu>
2608 2002-10-10 Fernando Perez <fperez@colorado.edu>
2603
2609
2604 * README_Mac_OSX: Added a README for Mac OSX users for fixing
2610 * README_Mac_OSX: Added a README for Mac OSX users for fixing
2605 terminal-related issues. Many thanks to Andrea Riciputi
2611 terminal-related issues. Many thanks to Andrea Riciputi
2606 <andrea.riciputi-AT-libero.it> for writing it.
2612 <andrea.riciputi-AT-libero.it> for writing it.
2607
2613
2608 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
2614 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
2609 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2615 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2610
2616
2611 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
2617 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
2612 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
2618 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
2613 <syver-en-AT-online.no> who both submitted patches for this problem.
2619 <syver-en-AT-online.no> who both submitted patches for this problem.
2614
2620
2615 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
2621 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
2616 global embedding to make sure that things don't overwrite user
2622 global embedding to make sure that things don't overwrite user
2617 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
2623 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
2618
2624
2619 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
2625 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
2620 compatibility. Thanks to Hayden Callow
2626 compatibility. Thanks to Hayden Callow
2621 <h.callow-AT-elec.canterbury.ac.nz>
2627 <h.callow-AT-elec.canterbury.ac.nz>
2622
2628
2623 2002-10-04 Fernando Perez <fperez@colorado.edu>
2629 2002-10-04 Fernando Perez <fperez@colorado.edu>
2624
2630
2625 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
2631 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
2626 Gnuplot.File objects.
2632 Gnuplot.File objects.
2627
2633
2628 2002-07-23 Fernando Perez <fperez@colorado.edu>
2634 2002-07-23 Fernando Perez <fperez@colorado.edu>
2629
2635
2630 * IPython/genutils.py (timing): Added timings() and timing() for
2636 * IPython/genutils.py (timing): Added timings() and timing() for
2631 quick access to the most commonly needed data, the execution
2637 quick access to the most commonly needed data, the execution
2632 times. Old timing() renamed to timings_out().
2638 times. Old timing() renamed to timings_out().
2633
2639
2634 2002-07-18 Fernando Perez <fperez@colorado.edu>
2640 2002-07-18 Fernando Perez <fperez@colorado.edu>
2635
2641
2636 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
2642 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
2637 bug with nested instances disrupting the parent's tab completion.
2643 bug with nested instances disrupting the parent's tab completion.
2638
2644
2639 * IPython/iplib.py (all_completions): Added Alex Schmolck's
2645 * IPython/iplib.py (all_completions): Added Alex Schmolck's
2640 all_completions code to begin the emacs integration.
2646 all_completions code to begin the emacs integration.
2641
2647
2642 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
2648 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
2643 argument to allow titling individual arrays when plotting.
2649 argument to allow titling individual arrays when plotting.
2644
2650
2645 2002-07-15 Fernando Perez <fperez@colorado.edu>
2651 2002-07-15 Fernando Perez <fperez@colorado.edu>
2646
2652
2647 * setup.py (make_shortcut): changed to retrieve the value of
2653 * setup.py (make_shortcut): changed to retrieve the value of
2648 'Program Files' directory from the registry (this value changes in
2654 'Program Files' directory from the registry (this value changes in
2649 non-english versions of Windows). Thanks to Thomas Fanslau
2655 non-english versions of Windows). Thanks to Thomas Fanslau
2650 <tfanslau-AT-gmx.de> for the report.
2656 <tfanslau-AT-gmx.de> for the report.
2651
2657
2652 2002-07-10 Fernando Perez <fperez@colorado.edu>
2658 2002-07-10 Fernando Perez <fperez@colorado.edu>
2653
2659
2654 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
2660 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
2655 a bug in pdb, which crashes if a line with only whitespace is
2661 a bug in pdb, which crashes if a line with only whitespace is
2656 entered. Bug report submitted to sourceforge.
2662 entered. Bug report submitted to sourceforge.
2657
2663
2658 2002-07-09 Fernando Perez <fperez@colorado.edu>
2664 2002-07-09 Fernando Perez <fperez@colorado.edu>
2659
2665
2660 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
2666 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
2661 reporting exceptions (it's a bug in inspect.py, I just set a
2667 reporting exceptions (it's a bug in inspect.py, I just set a
2662 workaround).
2668 workaround).
2663
2669
2664 2002-07-08 Fernando Perez <fperez@colorado.edu>
2670 2002-07-08 Fernando Perez <fperez@colorado.edu>
2665
2671
2666 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
2672 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
2667 __IPYTHON__ in __builtins__ to show up in user_ns.
2673 __IPYTHON__ in __builtins__ to show up in user_ns.
2668
2674
2669 2002-07-03 Fernando Perez <fperez@colorado.edu>
2675 2002-07-03 Fernando Perez <fperez@colorado.edu>
2670
2676
2671 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
2677 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
2672 name from @gp_set_instance to @gp_set_default.
2678 name from @gp_set_instance to @gp_set_default.
2673
2679
2674 * IPython/ipmaker.py (make_IPython): default editor value set to
2680 * IPython/ipmaker.py (make_IPython): default editor value set to
2675 '0' (a string), to match the rc file. Otherwise will crash when
2681 '0' (a string), to match the rc file. Otherwise will crash when
2676 .strip() is called on it.
2682 .strip() is called on it.
2677
2683
2678
2684
2679 2002-06-28 Fernando Perez <fperez@colorado.edu>
2685 2002-06-28 Fernando Perez <fperez@colorado.edu>
2680
2686
2681 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
2687 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
2682 of files in current directory when a file is executed via
2688 of files in current directory when a file is executed via
2683 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
2689 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
2684
2690
2685 * setup.py (manfiles): fix for rpm builds, submitted by RA
2691 * setup.py (manfiles): fix for rpm builds, submitted by RA
2686 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
2692 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
2687
2693
2688 * IPython/ipmaker.py (make_IPython): fixed lookup of default
2694 * IPython/ipmaker.py (make_IPython): fixed lookup of default
2689 editor when set to '0'. Problem was, '0' evaluates to True (it's a
2695 editor when set to '0'. Problem was, '0' evaluates to True (it's a
2690 string!). A. Schmolck caught this one.
2696 string!). A. Schmolck caught this one.
2691
2697
2692 2002-06-27 Fernando Perez <fperez@colorado.edu>
2698 2002-06-27 Fernando Perez <fperez@colorado.edu>
2693
2699
2694 * IPython/ipmaker.py (make_IPython): fixed bug when running user
2700 * IPython/ipmaker.py (make_IPython): fixed bug when running user
2695 defined files at the cmd line. __name__ wasn't being set to
2701 defined files at the cmd line. __name__ wasn't being set to
2696 __main__.
2702 __main__.
2697
2703
2698 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
2704 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
2699 regular lists and tuples besides Numeric arrays.
2705 regular lists and tuples besides Numeric arrays.
2700
2706
2701 * IPython/Prompts.py (CachedOutput.__call__): Added output
2707 * IPython/Prompts.py (CachedOutput.__call__): Added output
2702 supression for input ending with ';'. Similar to Mathematica and
2708 supression for input ending with ';'. Similar to Mathematica and
2703 Matlab. The _* vars and Out[] list are still updated, just like
2709 Matlab. The _* vars and Out[] list are still updated, just like
2704 Mathematica behaves.
2710 Mathematica behaves.
2705
2711
2706 2002-06-25 Fernando Perez <fperez@colorado.edu>
2712 2002-06-25 Fernando Perez <fperez@colorado.edu>
2707
2713
2708 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
2714 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
2709 .ini extensions for profiels under Windows.
2715 .ini extensions for profiels under Windows.
2710
2716
2711 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
2717 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
2712 string form. Fix contributed by Alexander Schmolck
2718 string form. Fix contributed by Alexander Schmolck
2713 <a.schmolck-AT-gmx.net>
2719 <a.schmolck-AT-gmx.net>
2714
2720
2715 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
2721 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
2716 pre-configured Gnuplot instance.
2722 pre-configured Gnuplot instance.
2717
2723
2718 2002-06-21 Fernando Perez <fperez@colorado.edu>
2724 2002-06-21 Fernando Perez <fperez@colorado.edu>
2719
2725
2720 * IPython/numutils.py (exp_safe): new function, works around the
2726 * IPython/numutils.py (exp_safe): new function, works around the
2721 underflow problems in Numeric.
2727 underflow problems in Numeric.
2722 (log2): New fn. Safe log in base 2: returns exact integer answer
2728 (log2): New fn. Safe log in base 2: returns exact integer answer
2723 for exact integer powers of 2.
2729 for exact integer powers of 2.
2724
2730
2725 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
2731 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
2726 properly.
2732 properly.
2727
2733
2728 2002-06-20 Fernando Perez <fperez@colorado.edu>
2734 2002-06-20 Fernando Perez <fperez@colorado.edu>
2729
2735
2730 * IPython/genutils.py (timing): new function like
2736 * IPython/genutils.py (timing): new function like
2731 Mathematica's. Similar to time_test, but returns more info.
2737 Mathematica's. Similar to time_test, but returns more info.
2732
2738
2733 2002-06-18 Fernando Perez <fperez@colorado.edu>
2739 2002-06-18 Fernando Perez <fperez@colorado.edu>
2734
2740
2735 * IPython/Magic.py (Magic.magic_save): modified @save and @r
2741 * IPython/Magic.py (Magic.magic_save): modified @save and @r
2736 according to Mike Heeter's suggestions.
2742 according to Mike Heeter's suggestions.
2737
2743
2738 2002-06-16 Fernando Perez <fperez@colorado.edu>
2744 2002-06-16 Fernando Perez <fperez@colorado.edu>
2739
2745
2740 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
2746 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
2741 system. GnuplotMagic is gone as a user-directory option. New files
2747 system. GnuplotMagic is gone as a user-directory option. New files
2742 make it easier to use all the gnuplot stuff both from external
2748 make it easier to use all the gnuplot stuff both from external
2743 programs as well as from IPython. Had to rewrite part of
2749 programs as well as from IPython. Had to rewrite part of
2744 hardcopy() b/c of a strange bug: often the ps files simply don't
2750 hardcopy() b/c of a strange bug: often the ps files simply don't
2745 get created, and require a repeat of the command (often several
2751 get created, and require a repeat of the command (often several
2746 times).
2752 times).
2747
2753
2748 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
2754 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
2749 resolve output channel at call time, so that if sys.stderr has
2755 resolve output channel at call time, so that if sys.stderr has
2750 been redirected by user this gets honored.
2756 been redirected by user this gets honored.
2751
2757
2752 2002-06-13 Fernando Perez <fperez@colorado.edu>
2758 2002-06-13 Fernando Perez <fperez@colorado.edu>
2753
2759
2754 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
2760 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
2755 IPShell. Kept a copy with the old names to avoid breaking people's
2761 IPShell. Kept a copy with the old names to avoid breaking people's
2756 embedded code.
2762 embedded code.
2757
2763
2758 * IPython/ipython: simplified it to the bare minimum after
2764 * IPython/ipython: simplified it to the bare minimum after
2759 Holger's suggestions. Added info about how to use it in
2765 Holger's suggestions. Added info about how to use it in
2760 PYTHONSTARTUP.
2766 PYTHONSTARTUP.
2761
2767
2762 * IPython/Shell.py (IPythonShell): changed the options passing
2768 * IPython/Shell.py (IPythonShell): changed the options passing
2763 from a string with funky %s replacements to a straight list. Maybe
2769 from a string with funky %s replacements to a straight list. Maybe
2764 a bit more typing, but it follows sys.argv conventions, so there's
2770 a bit more typing, but it follows sys.argv conventions, so there's
2765 less special-casing to remember.
2771 less special-casing to remember.
2766
2772
2767 2002-06-12 Fernando Perez <fperez@colorado.edu>
2773 2002-06-12 Fernando Perez <fperez@colorado.edu>
2768
2774
2769 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
2775 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
2770 command. Thanks to a suggestion by Mike Heeter.
2776 command. Thanks to a suggestion by Mike Heeter.
2771 (Magic.magic_pfile): added behavior to look at filenames if given
2777 (Magic.magic_pfile): added behavior to look at filenames if given
2772 arg is not a defined object.
2778 arg is not a defined object.
2773 (Magic.magic_save): New @save function to save code snippets. Also
2779 (Magic.magic_save): New @save function to save code snippets. Also
2774 a Mike Heeter idea.
2780 a Mike Heeter idea.
2775
2781
2776 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
2782 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
2777 plot() and replot(). Much more convenient now, especially for
2783 plot() and replot(). Much more convenient now, especially for
2778 interactive use.
2784 interactive use.
2779
2785
2780 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
2786 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
2781 filenames.
2787 filenames.
2782
2788
2783 2002-06-02 Fernando Perez <fperez@colorado.edu>
2789 2002-06-02 Fernando Perez <fperez@colorado.edu>
2784
2790
2785 * IPython/Struct.py (Struct.__init__): modified to admit
2791 * IPython/Struct.py (Struct.__init__): modified to admit
2786 initialization via another struct.
2792 initialization via another struct.
2787
2793
2788 * IPython/genutils.py (SystemExec.__init__): New stateful
2794 * IPython/genutils.py (SystemExec.__init__): New stateful
2789 interface to xsys and bq. Useful for writing system scripts.
2795 interface to xsys and bq. Useful for writing system scripts.
2790
2796
2791 2002-05-30 Fernando Perez <fperez@colorado.edu>
2797 2002-05-30 Fernando Perez <fperez@colorado.edu>
2792
2798
2793 * MANIFEST.in: Changed docfile selection to exclude all the lyx
2799 * MANIFEST.in: Changed docfile selection to exclude all the lyx
2794 documents. This will make the user download smaller (it's getting
2800 documents. This will make the user download smaller (it's getting
2795 too big).
2801 too big).
2796
2802
2797 2002-05-29 Fernando Perez <fperez@colorado.edu>
2803 2002-05-29 Fernando Perez <fperez@colorado.edu>
2798
2804
2799 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
2805 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
2800 fix problems with shelve and pickle. Seems to work, but I don't
2806 fix problems with shelve and pickle. Seems to work, but I don't
2801 know if corner cases break it. Thanks to Mike Heeter
2807 know if corner cases break it. Thanks to Mike Heeter
2802 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
2808 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
2803
2809
2804 2002-05-24 Fernando Perez <fperez@colorado.edu>
2810 2002-05-24 Fernando Perez <fperez@colorado.edu>
2805
2811
2806 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
2812 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
2807 macros having broken.
2813 macros having broken.
2808
2814
2809 2002-05-21 Fernando Perez <fperez@colorado.edu>
2815 2002-05-21 Fernando Perez <fperez@colorado.edu>
2810
2816
2811 * IPython/Magic.py (Magic.magic_logstart): fixed recently
2817 * IPython/Magic.py (Magic.magic_logstart): fixed recently
2812 introduced logging bug: all history before logging started was
2818 introduced logging bug: all history before logging started was
2813 being written one character per line! This came from the redesign
2819 being written one character per line! This came from the redesign
2814 of the input history as a special list which slices to strings,
2820 of the input history as a special list which slices to strings,
2815 not to lists.
2821 not to lists.
2816
2822
2817 2002-05-20 Fernando Perez <fperez@colorado.edu>
2823 2002-05-20 Fernando Perez <fperez@colorado.edu>
2818
2824
2819 * IPython/Prompts.py (CachedOutput.__init__): made the color table
2825 * IPython/Prompts.py (CachedOutput.__init__): made the color table
2820 be an attribute of all classes in this module. The design of these
2826 be an attribute of all classes in this module. The design of these
2821 classes needs some serious overhauling.
2827 classes needs some serious overhauling.
2822
2828
2823 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
2829 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
2824 which was ignoring '_' in option names.
2830 which was ignoring '_' in option names.
2825
2831
2826 * IPython/ultraTB.py (FormattedTB.__init__): Changed
2832 * IPython/ultraTB.py (FormattedTB.__init__): Changed
2827 'Verbose_novars' to 'Context' and made it the new default. It's a
2833 'Verbose_novars' to 'Context' and made it the new default. It's a
2828 bit more readable and also safer than verbose.
2834 bit more readable and also safer than verbose.
2829
2835
2830 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
2836 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
2831 triple-quoted strings.
2837 triple-quoted strings.
2832
2838
2833 * IPython/OInspect.py (__all__): new module exposing the object
2839 * IPython/OInspect.py (__all__): new module exposing the object
2834 introspection facilities. Now the corresponding magics are dummy
2840 introspection facilities. Now the corresponding magics are dummy
2835 wrappers around this. Having this module will make it much easier
2841 wrappers around this. Having this module will make it much easier
2836 to put these functions into our modified pdb.
2842 to put these functions into our modified pdb.
2837 This new object inspector system uses the new colorizing module,
2843 This new object inspector system uses the new colorizing module,
2838 so source code and other things are nicely syntax highlighted.
2844 so source code and other things are nicely syntax highlighted.
2839
2845
2840 2002-05-18 Fernando Perez <fperez@colorado.edu>
2846 2002-05-18 Fernando Perez <fperez@colorado.edu>
2841
2847
2842 * IPython/ColorANSI.py: Split the coloring tools into a separate
2848 * IPython/ColorANSI.py: Split the coloring tools into a separate
2843 module so I can use them in other code easier (they were part of
2849 module so I can use them in other code easier (they were part of
2844 ultraTB).
2850 ultraTB).
2845
2851
2846 2002-05-17 Fernando Perez <fperez@colorado.edu>
2852 2002-05-17 Fernando Perez <fperez@colorado.edu>
2847
2853
2848 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
2854 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
2849 fixed it to set the global 'g' also to the called instance, as
2855 fixed it to set the global 'g' also to the called instance, as
2850 long as 'g' was still a gnuplot instance (so it doesn't overwrite
2856 long as 'g' was still a gnuplot instance (so it doesn't overwrite
2851 user's 'g' variables).
2857 user's 'g' variables).
2852
2858
2853 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
2859 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
2854 global variables (aliases to _ih,_oh) so that users which expect
2860 global variables (aliases to _ih,_oh) so that users which expect
2855 In[5] or Out[7] to work aren't unpleasantly surprised.
2861 In[5] or Out[7] to work aren't unpleasantly surprised.
2856 (InputList.__getslice__): new class to allow executing slices of
2862 (InputList.__getslice__): new class to allow executing slices of
2857 input history directly. Very simple class, complements the use of
2863 input history directly. Very simple class, complements the use of
2858 macros.
2864 macros.
2859
2865
2860 2002-05-16 Fernando Perez <fperez@colorado.edu>
2866 2002-05-16 Fernando Perez <fperez@colorado.edu>
2861
2867
2862 * setup.py (docdirbase): make doc directory be just doc/IPython
2868 * setup.py (docdirbase): make doc directory be just doc/IPython
2863 without version numbers, it will reduce clutter for users.
2869 without version numbers, it will reduce clutter for users.
2864
2870
2865 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
2871 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
2866 execfile call to prevent possible memory leak. See for details:
2872 execfile call to prevent possible memory leak. See for details:
2867 http://mail.python.org/pipermail/python-list/2002-February/088476.html
2873 http://mail.python.org/pipermail/python-list/2002-February/088476.html
2868
2874
2869 2002-05-15 Fernando Perez <fperez@colorado.edu>
2875 2002-05-15 Fernando Perez <fperez@colorado.edu>
2870
2876
2871 * IPython/Magic.py (Magic.magic_psource): made the object
2877 * IPython/Magic.py (Magic.magic_psource): made the object
2872 introspection names be more standard: pdoc, pdef, pfile and
2878 introspection names be more standard: pdoc, pdef, pfile and
2873 psource. They all print/page their output, and it makes
2879 psource. They all print/page their output, and it makes
2874 remembering them easier. Kept old names for compatibility as
2880 remembering them easier. Kept old names for compatibility as
2875 aliases.
2881 aliases.
2876
2882
2877 2002-05-14 Fernando Perez <fperez@colorado.edu>
2883 2002-05-14 Fernando Perez <fperez@colorado.edu>
2878
2884
2879 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
2885 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
2880 what the mouse problem was. The trick is to use gnuplot with temp
2886 what the mouse problem was. The trick is to use gnuplot with temp
2881 files and NOT with pipes (for data communication), because having
2887 files and NOT with pipes (for data communication), because having
2882 both pipes and the mouse on is bad news.
2888 both pipes and the mouse on is bad news.
2883
2889
2884 2002-05-13 Fernando Perez <fperez@colorado.edu>
2890 2002-05-13 Fernando Perez <fperez@colorado.edu>
2885
2891
2886 * IPython/Magic.py (Magic._ofind): fixed namespace order search
2892 * IPython/Magic.py (Magic._ofind): fixed namespace order search
2887 bug. Information would be reported about builtins even when
2893 bug. Information would be reported about builtins even when
2888 user-defined functions overrode them.
2894 user-defined functions overrode them.
2889
2895
2890 2002-05-11 Fernando Perez <fperez@colorado.edu>
2896 2002-05-11 Fernando Perez <fperez@colorado.edu>
2891
2897
2892 * IPython/__init__.py (__all__): removed FlexCompleter from
2898 * IPython/__init__.py (__all__): removed FlexCompleter from
2893 __all__ so that things don't fail in platforms without readline.
2899 __all__ so that things don't fail in platforms without readline.
2894
2900
2895 2002-05-10 Fernando Perez <fperez@colorado.edu>
2901 2002-05-10 Fernando Perez <fperez@colorado.edu>
2896
2902
2897 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
2903 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
2898 it requires Numeric, effectively making Numeric a dependency for
2904 it requires Numeric, effectively making Numeric a dependency for
2899 IPython.
2905 IPython.
2900
2906
2901 * Released 0.2.13
2907 * Released 0.2.13
2902
2908
2903 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
2909 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
2904 profiler interface. Now all the major options from the profiler
2910 profiler interface. Now all the major options from the profiler
2905 module are directly supported in IPython, both for single
2911 module are directly supported in IPython, both for single
2906 expressions (@prun) and for full programs (@run -p).
2912 expressions (@prun) and for full programs (@run -p).
2907
2913
2908 2002-05-09 Fernando Perez <fperez@colorado.edu>
2914 2002-05-09 Fernando Perez <fperez@colorado.edu>
2909
2915
2910 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
2916 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
2911 magic properly formatted for screen.
2917 magic properly formatted for screen.
2912
2918
2913 * setup.py (make_shortcut): Changed things to put pdf version in
2919 * setup.py (make_shortcut): Changed things to put pdf version in
2914 doc/ instead of doc/manual (had to change lyxport a bit).
2920 doc/ instead of doc/manual (had to change lyxport a bit).
2915
2921
2916 * IPython/Magic.py (Profile.string_stats): made profile runs go
2922 * IPython/Magic.py (Profile.string_stats): made profile runs go
2917 through pager (they are long and a pager allows searching, saving,
2923 through pager (they are long and a pager allows searching, saving,
2918 etc.)
2924 etc.)
2919
2925
2920 2002-05-08 Fernando Perez <fperez@colorado.edu>
2926 2002-05-08 Fernando Perez <fperez@colorado.edu>
2921
2927
2922 * Released 0.2.12
2928 * Released 0.2.12
2923
2929
2924 2002-05-06 Fernando Perez <fperez@colorado.edu>
2930 2002-05-06 Fernando Perez <fperez@colorado.edu>
2925
2931
2926 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
2932 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
2927 introduced); 'hist n1 n2' was broken.
2933 introduced); 'hist n1 n2' was broken.
2928 (Magic.magic_pdb): added optional on/off arguments to @pdb
2934 (Magic.magic_pdb): added optional on/off arguments to @pdb
2929 (Magic.magic_run): added option -i to @run, which executes code in
2935 (Magic.magic_run): added option -i to @run, which executes code in
2930 the IPython namespace instead of a clean one. Also added @irun as
2936 the IPython namespace instead of a clean one. Also added @irun as
2931 an alias to @run -i.
2937 an alias to @run -i.
2932
2938
2933 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
2939 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
2934 fixed (it didn't really do anything, the namespaces were wrong).
2940 fixed (it didn't really do anything, the namespaces were wrong).
2935
2941
2936 * IPython/Debugger.py (__init__): Added workaround for python 2.1
2942 * IPython/Debugger.py (__init__): Added workaround for python 2.1
2937
2943
2938 * IPython/__init__.py (__all__): Fixed package namespace, now
2944 * IPython/__init__.py (__all__): Fixed package namespace, now
2939 'import IPython' does give access to IPython.<all> as
2945 'import IPython' does give access to IPython.<all> as
2940 expected. Also renamed __release__ to Release.
2946 expected. Also renamed __release__ to Release.
2941
2947
2942 * IPython/Debugger.py (__license__): created new Pdb class which
2948 * IPython/Debugger.py (__license__): created new Pdb class which
2943 functions like a drop-in for the normal pdb.Pdb but does NOT
2949 functions like a drop-in for the normal pdb.Pdb but does NOT
2944 import readline by default. This way it doesn't muck up IPython's
2950 import readline by default. This way it doesn't muck up IPython's
2945 readline handling, and now tab-completion finally works in the
2951 readline handling, and now tab-completion finally works in the
2946 debugger -- sort of. It completes things globally visible, but the
2952 debugger -- sort of. It completes things globally visible, but the
2947 completer doesn't track the stack as pdb walks it. That's a bit
2953 completer doesn't track the stack as pdb walks it. That's a bit
2948 tricky, and I'll have to implement it later.
2954 tricky, and I'll have to implement it later.
2949
2955
2950 2002-05-05 Fernando Perez <fperez@colorado.edu>
2956 2002-05-05 Fernando Perez <fperez@colorado.edu>
2951
2957
2952 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
2958 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
2953 magic docstrings when printed via ? (explicit \'s were being
2959 magic docstrings when printed via ? (explicit \'s were being
2954 printed).
2960 printed).
2955
2961
2956 * IPython/ipmaker.py (make_IPython): fixed namespace
2962 * IPython/ipmaker.py (make_IPython): fixed namespace
2957 identification bug. Now variables loaded via logs or command-line
2963 identification bug. Now variables loaded via logs or command-line
2958 files are recognized in the interactive namespace by @who.
2964 files are recognized in the interactive namespace by @who.
2959
2965
2960 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
2966 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
2961 log replay system stemming from the string form of Structs.
2967 log replay system stemming from the string form of Structs.
2962
2968
2963 * IPython/Magic.py (Macro.__init__): improved macros to properly
2969 * IPython/Magic.py (Macro.__init__): improved macros to properly
2964 handle magic commands in them.
2970 handle magic commands in them.
2965 (Magic.magic_logstart): usernames are now expanded so 'logstart
2971 (Magic.magic_logstart): usernames are now expanded so 'logstart
2966 ~/mylog' now works.
2972 ~/mylog' now works.
2967
2973
2968 * IPython/iplib.py (complete): fixed bug where paths starting with
2974 * IPython/iplib.py (complete): fixed bug where paths starting with
2969 '/' would be completed as magic names.
2975 '/' would be completed as magic names.
2970
2976
2971 2002-05-04 Fernando Perez <fperez@colorado.edu>
2977 2002-05-04 Fernando Perez <fperez@colorado.edu>
2972
2978
2973 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
2979 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
2974 allow running full programs under the profiler's control.
2980 allow running full programs under the profiler's control.
2975
2981
2976 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
2982 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
2977 mode to report exceptions verbosely but without formatting
2983 mode to report exceptions verbosely but without formatting
2978 variables. This addresses the issue of ipython 'freezing' (it's
2984 variables. This addresses the issue of ipython 'freezing' (it's
2979 not frozen, but caught in an expensive formatting loop) when huge
2985 not frozen, but caught in an expensive formatting loop) when huge
2980 variables are in the context of an exception.
2986 variables are in the context of an exception.
2981 (VerboseTB.text): Added '--->' markers at line where exception was
2987 (VerboseTB.text): Added '--->' markers at line where exception was
2982 triggered. Much clearer to read, especially in NoColor modes.
2988 triggered. Much clearer to read, especially in NoColor modes.
2983
2989
2984 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
2990 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
2985 implemented in reverse when changing to the new parse_options().
2991 implemented in reverse when changing to the new parse_options().
2986
2992
2987 2002-05-03 Fernando Perez <fperez@colorado.edu>
2993 2002-05-03 Fernando Perez <fperez@colorado.edu>
2988
2994
2989 * IPython/Magic.py (Magic.parse_options): new function so that
2995 * IPython/Magic.py (Magic.parse_options): new function so that
2990 magics can parse options easier.
2996 magics can parse options easier.
2991 (Magic.magic_prun): new function similar to profile.run(),
2997 (Magic.magic_prun): new function similar to profile.run(),
2992 suggested by Chris Hart.
2998 suggested by Chris Hart.
2993 (Magic.magic_cd): fixed behavior so that it only changes if
2999 (Magic.magic_cd): fixed behavior so that it only changes if
2994 directory actually is in history.
3000 directory actually is in history.
2995
3001
2996 * IPython/usage.py (__doc__): added information about potential
3002 * IPython/usage.py (__doc__): added information about potential
2997 slowness of Verbose exception mode when there are huge data
3003 slowness of Verbose exception mode when there are huge data
2998 structures to be formatted (thanks to Archie Paulson).
3004 structures to be formatted (thanks to Archie Paulson).
2999
3005
3000 * IPython/ipmaker.py (make_IPython): Changed default logging
3006 * IPython/ipmaker.py (make_IPython): Changed default logging
3001 (when simply called with -log) to use curr_dir/ipython.log in
3007 (when simply called with -log) to use curr_dir/ipython.log in
3002 rotate mode. Fixed crash which was occuring with -log before
3008 rotate mode. Fixed crash which was occuring with -log before
3003 (thanks to Jim Boyle).
3009 (thanks to Jim Boyle).
3004
3010
3005 2002-05-01 Fernando Perez <fperez@colorado.edu>
3011 2002-05-01 Fernando Perez <fperez@colorado.edu>
3006
3012
3007 * Released 0.2.11 for these fixes (mainly the ultraTB one which
3013 * Released 0.2.11 for these fixes (mainly the ultraTB one which
3008 was nasty -- though somewhat of a corner case).
3014 was nasty -- though somewhat of a corner case).
3009
3015
3010 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
3016 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
3011 text (was a bug).
3017 text (was a bug).
3012
3018
3013 2002-04-30 Fernando Perez <fperez@colorado.edu>
3019 2002-04-30 Fernando Perez <fperez@colorado.edu>
3014
3020
3015 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
3021 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
3016 a print after ^D or ^C from the user so that the In[] prompt
3022 a print after ^D or ^C from the user so that the In[] prompt
3017 doesn't over-run the gnuplot one.
3023 doesn't over-run the gnuplot one.
3018
3024
3019 2002-04-29 Fernando Perez <fperez@colorado.edu>
3025 2002-04-29 Fernando Perez <fperez@colorado.edu>
3020
3026
3021 * Released 0.2.10
3027 * Released 0.2.10
3022
3028
3023 * IPython/__release__.py (version): get date dynamically.
3029 * IPython/__release__.py (version): get date dynamically.
3024
3030
3025 * Misc. documentation updates thanks to Arnd's comments. Also ran
3031 * Misc. documentation updates thanks to Arnd's comments. Also ran
3026 a full spellcheck on the manual (hadn't been done in a while).
3032 a full spellcheck on the manual (hadn't been done in a while).
3027
3033
3028 2002-04-27 Fernando Perez <fperez@colorado.edu>
3034 2002-04-27 Fernando Perez <fperez@colorado.edu>
3029
3035
3030 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
3036 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
3031 starting a log in mid-session would reset the input history list.
3037 starting a log in mid-session would reset the input history list.
3032
3038
3033 2002-04-26 Fernando Perez <fperez@colorado.edu>
3039 2002-04-26 Fernando Perez <fperez@colorado.edu>
3034
3040
3035 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
3041 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
3036 all files were being included in an update. Now anything in
3042 all files were being included in an update. Now anything in
3037 UserConfig that matches [A-Za-z]*.py will go (this excludes
3043 UserConfig that matches [A-Za-z]*.py will go (this excludes
3038 __init__.py)
3044 __init__.py)
3039
3045
3040 2002-04-25 Fernando Perez <fperez@colorado.edu>
3046 2002-04-25 Fernando Perez <fperez@colorado.edu>
3041
3047
3042 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
3048 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
3043 to __builtins__ so that any form of embedded or imported code can
3049 to __builtins__ so that any form of embedded or imported code can
3044 test for being inside IPython.
3050 test for being inside IPython.
3045
3051
3046 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3052 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3047 changed to GnuplotMagic because it's now an importable module,
3053 changed to GnuplotMagic because it's now an importable module,
3048 this makes the name follow that of the standard Gnuplot module.
3054 this makes the name follow that of the standard Gnuplot module.
3049 GnuplotMagic can now be loaded at any time in mid-session.
3055 GnuplotMagic can now be loaded at any time in mid-session.
3050
3056
3051 2002-04-24 Fernando Perez <fperez@colorado.edu>
3057 2002-04-24 Fernando Perez <fperez@colorado.edu>
3052
3058
3053 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3059 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3054 the globals (IPython has its own namespace) and the
3060 the globals (IPython has its own namespace) and the
3055 PhysicalQuantity stuff is much better anyway.
3061 PhysicalQuantity stuff is much better anyway.
3056
3062
3057 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3063 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3058 embedding example to standard user directory for
3064 embedding example to standard user directory for
3059 distribution. Also put it in the manual.
3065 distribution. Also put it in the manual.
3060
3066
3061 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3067 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3062 instance as first argument (so it doesn't rely on some obscure
3068 instance as first argument (so it doesn't rely on some obscure
3063 hidden global).
3069 hidden global).
3064
3070
3065 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3071 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3066 delimiters. While it prevents ().TAB from working, it allows
3072 delimiters. While it prevents ().TAB from working, it allows
3067 completions in open (... expressions. This is by far a more common
3073 completions in open (... expressions. This is by far a more common
3068 case.
3074 case.
3069
3075
3070 2002-04-23 Fernando Perez <fperez@colorado.edu>
3076 2002-04-23 Fernando Perez <fperez@colorado.edu>
3071
3077
3072 * IPython/Extensions/InterpreterPasteInput.py: new
3078 * IPython/Extensions/InterpreterPasteInput.py: new
3073 syntax-processing module for pasting lines with >>> or ... at the
3079 syntax-processing module for pasting lines with >>> or ... at the
3074 start.
3080 start.
3075
3081
3076 * IPython/Extensions/PhysicalQ_Interactive.py
3082 * IPython/Extensions/PhysicalQ_Interactive.py
3077 (PhysicalQuantityInteractive.__int__): fixed to work with either
3083 (PhysicalQuantityInteractive.__int__): fixed to work with either
3078 Numeric or math.
3084 Numeric or math.
3079
3085
3080 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3086 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3081 provided profiles. Now we have:
3087 provided profiles. Now we have:
3082 -math -> math module as * and cmath with its own namespace.
3088 -math -> math module as * and cmath with its own namespace.
3083 -numeric -> Numeric as *, plus gnuplot & grace
3089 -numeric -> Numeric as *, plus gnuplot & grace
3084 -physics -> same as before
3090 -physics -> same as before
3085
3091
3086 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3092 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3087 user-defined magics wouldn't be found by @magic if they were
3093 user-defined magics wouldn't be found by @magic if they were
3088 defined as class methods. Also cleaned up the namespace search
3094 defined as class methods. Also cleaned up the namespace search
3089 logic and the string building (to use %s instead of many repeated
3095 logic and the string building (to use %s instead of many repeated
3090 string adds).
3096 string adds).
3091
3097
3092 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3098 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3093 of user-defined magics to operate with class methods (cleaner, in
3099 of user-defined magics to operate with class methods (cleaner, in
3094 line with the gnuplot code).
3100 line with the gnuplot code).
3095
3101
3096 2002-04-22 Fernando Perez <fperez@colorado.edu>
3102 2002-04-22 Fernando Perez <fperez@colorado.edu>
3097
3103
3098 * setup.py: updated dependency list so that manual is updated when
3104 * setup.py: updated dependency list so that manual is updated when
3099 all included files change.
3105 all included files change.
3100
3106
3101 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3107 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3102 the delimiter removal option (the fix is ugly right now).
3108 the delimiter removal option (the fix is ugly right now).
3103
3109
3104 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3110 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3105 all of the math profile (quicker loading, no conflict between
3111 all of the math profile (quicker loading, no conflict between
3106 g-9.8 and g-gnuplot).
3112 g-9.8 and g-gnuplot).
3107
3113
3108 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3114 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3109 name of post-mortem files to IPython_crash_report.txt.
3115 name of post-mortem files to IPython_crash_report.txt.
3110
3116
3111 * Cleanup/update of the docs. Added all the new readline info and
3117 * Cleanup/update of the docs. Added all the new readline info and
3112 formatted all lists as 'real lists'.
3118 formatted all lists as 'real lists'.
3113
3119
3114 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3120 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3115 tab-completion options, since the full readline parse_and_bind is
3121 tab-completion options, since the full readline parse_and_bind is
3116 now accessible.
3122 now accessible.
3117
3123
3118 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3124 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3119 handling of readline options. Now users can specify any string to
3125 handling of readline options. Now users can specify any string to
3120 be passed to parse_and_bind(), as well as the delimiters to be
3126 be passed to parse_and_bind(), as well as the delimiters to be
3121 removed.
3127 removed.
3122 (InteractiveShell.__init__): Added __name__ to the global
3128 (InteractiveShell.__init__): Added __name__ to the global
3123 namespace so that things like Itpl which rely on its existence
3129 namespace so that things like Itpl which rely on its existence
3124 don't crash.
3130 don't crash.
3125 (InteractiveShell._prefilter): Defined the default with a _ so
3131 (InteractiveShell._prefilter): Defined the default with a _ so
3126 that prefilter() is easier to override, while the default one
3132 that prefilter() is easier to override, while the default one
3127 remains available.
3133 remains available.
3128
3134
3129 2002-04-18 Fernando Perez <fperez@colorado.edu>
3135 2002-04-18 Fernando Perez <fperez@colorado.edu>
3130
3136
3131 * Added information about pdb in the docs.
3137 * Added information about pdb in the docs.
3132
3138
3133 2002-04-17 Fernando Perez <fperez@colorado.edu>
3139 2002-04-17 Fernando Perez <fperez@colorado.edu>
3134
3140
3135 * IPython/ipmaker.py (make_IPython): added rc_override option to
3141 * IPython/ipmaker.py (make_IPython): added rc_override option to
3136 allow passing config options at creation time which may override
3142 allow passing config options at creation time which may override
3137 anything set in the config files or command line. This is
3143 anything set in the config files or command line. This is
3138 particularly useful for configuring embedded instances.
3144 particularly useful for configuring embedded instances.
3139
3145
3140 2002-04-15 Fernando Perez <fperez@colorado.edu>
3146 2002-04-15 Fernando Perez <fperez@colorado.edu>
3141
3147
3142 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3148 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3143 crash embedded instances because of the input cache falling out of
3149 crash embedded instances because of the input cache falling out of
3144 sync with the output counter.
3150 sync with the output counter.
3145
3151
3146 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3152 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3147 mode which calls pdb after an uncaught exception in IPython itself.
3153 mode which calls pdb after an uncaught exception in IPython itself.
3148
3154
3149 2002-04-14 Fernando Perez <fperez@colorado.edu>
3155 2002-04-14 Fernando Perez <fperez@colorado.edu>
3150
3156
3151 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3157 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3152 readline, fix it back after each call.
3158 readline, fix it back after each call.
3153
3159
3154 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3160 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3155 method to force all access via __call__(), which guarantees that
3161 method to force all access via __call__(), which guarantees that
3156 traceback references are properly deleted.
3162 traceback references are properly deleted.
3157
3163
3158 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3164 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3159 improve printing when pprint is in use.
3165 improve printing when pprint is in use.
3160
3166
3161 2002-04-13 Fernando Perez <fperez@colorado.edu>
3167 2002-04-13 Fernando Perez <fperez@colorado.edu>
3162
3168
3163 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3169 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3164 exceptions aren't caught anymore. If the user triggers one, he
3170 exceptions aren't caught anymore. If the user triggers one, he
3165 should know why he's doing it and it should go all the way up,
3171 should know why he's doing it and it should go all the way up,
3166 just like any other exception. So now @abort will fully kill the
3172 just like any other exception. So now @abort will fully kill the
3167 embedded interpreter and the embedding code (unless that happens
3173 embedded interpreter and the embedding code (unless that happens
3168 to catch SystemExit).
3174 to catch SystemExit).
3169
3175
3170 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3176 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3171 and a debugger() method to invoke the interactive pdb debugger
3177 and a debugger() method to invoke the interactive pdb debugger
3172 after printing exception information. Also added the corresponding
3178 after printing exception information. Also added the corresponding
3173 -pdb option and @pdb magic to control this feature, and updated
3179 -pdb option and @pdb magic to control this feature, and updated
3174 the docs. After a suggestion from Christopher Hart
3180 the docs. After a suggestion from Christopher Hart
3175 (hart-AT-caltech.edu).
3181 (hart-AT-caltech.edu).
3176
3182
3177 2002-04-12 Fernando Perez <fperez@colorado.edu>
3183 2002-04-12 Fernando Perez <fperez@colorado.edu>
3178
3184
3179 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3185 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3180 the exception handlers defined by the user (not the CrashHandler)
3186 the exception handlers defined by the user (not the CrashHandler)
3181 so that user exceptions don't trigger an ipython bug report.
3187 so that user exceptions don't trigger an ipython bug report.
3182
3188
3183 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3189 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3184 configurable (it should have always been so).
3190 configurable (it should have always been so).
3185
3191
3186 2002-03-26 Fernando Perez <fperez@colorado.edu>
3192 2002-03-26 Fernando Perez <fperez@colorado.edu>
3187
3193
3188 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3194 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3189 and there to fix embedding namespace issues. This should all be
3195 and there to fix embedding namespace issues. This should all be
3190 done in a more elegant way.
3196 done in a more elegant way.
3191
3197
3192 2002-03-25 Fernando Perez <fperez@colorado.edu>
3198 2002-03-25 Fernando Perez <fperez@colorado.edu>
3193
3199
3194 * IPython/genutils.py (get_home_dir): Try to make it work under
3200 * IPython/genutils.py (get_home_dir): Try to make it work under
3195 win9x also.
3201 win9x also.
3196
3202
3197 2002-03-20 Fernando Perez <fperez@colorado.edu>
3203 2002-03-20 Fernando Perez <fperez@colorado.edu>
3198
3204
3199 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3205 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3200 sys.displayhook untouched upon __init__.
3206 sys.displayhook untouched upon __init__.
3201
3207
3202 2002-03-19 Fernando Perez <fperez@colorado.edu>
3208 2002-03-19 Fernando Perez <fperez@colorado.edu>
3203
3209
3204 * Released 0.2.9 (for embedding bug, basically).
3210 * Released 0.2.9 (for embedding bug, basically).
3205
3211
3206 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3212 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3207 exceptions so that enclosing shell's state can be restored.
3213 exceptions so that enclosing shell's state can be restored.
3208
3214
3209 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3215 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3210 naming conventions in the .ipython/ dir.
3216 naming conventions in the .ipython/ dir.
3211
3217
3212 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3218 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3213 from delimiters list so filenames with - in them get expanded.
3219 from delimiters list so filenames with - in them get expanded.
3214
3220
3215 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3221 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3216 sys.displayhook not being properly restored after an embedded call.
3222 sys.displayhook not being properly restored after an embedded call.
3217
3223
3218 2002-03-18 Fernando Perez <fperez@colorado.edu>
3224 2002-03-18 Fernando Perez <fperez@colorado.edu>
3219
3225
3220 * Released 0.2.8
3226 * Released 0.2.8
3221
3227
3222 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3228 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3223 some files weren't being included in a -upgrade.
3229 some files weren't being included in a -upgrade.
3224 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3230 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3225 on' so that the first tab completes.
3231 on' so that the first tab completes.
3226 (InteractiveShell.handle_magic): fixed bug with spaces around
3232 (InteractiveShell.handle_magic): fixed bug with spaces around
3227 quotes breaking many magic commands.
3233 quotes breaking many magic commands.
3228
3234
3229 * setup.py: added note about ignoring the syntax error messages at
3235 * setup.py: added note about ignoring the syntax error messages at
3230 installation.
3236 installation.
3231
3237
3232 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3238 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3233 streamlining the gnuplot interface, now there's only one magic @gp.
3239 streamlining the gnuplot interface, now there's only one magic @gp.
3234
3240
3235 2002-03-17 Fernando Perez <fperez@colorado.edu>
3241 2002-03-17 Fernando Perez <fperez@colorado.edu>
3236
3242
3237 * IPython/UserConfig/magic_gnuplot.py: new name for the
3243 * IPython/UserConfig/magic_gnuplot.py: new name for the
3238 example-magic_pm.py file. Much enhanced system, now with a shell
3244 example-magic_pm.py file. Much enhanced system, now with a shell
3239 for communicating directly with gnuplot, one command at a time.
3245 for communicating directly with gnuplot, one command at a time.
3240
3246
3241 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3247 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3242 setting __name__=='__main__'.
3248 setting __name__=='__main__'.
3243
3249
3244 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3250 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3245 mini-shell for accessing gnuplot from inside ipython. Should
3251 mini-shell for accessing gnuplot from inside ipython. Should
3246 extend it later for grace access too. Inspired by Arnd's
3252 extend it later for grace access too. Inspired by Arnd's
3247 suggestion.
3253 suggestion.
3248
3254
3249 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3255 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3250 calling magic functions with () in their arguments. Thanks to Arnd
3256 calling magic functions with () in their arguments. Thanks to Arnd
3251 Baecker for pointing this to me.
3257 Baecker for pointing this to me.
3252
3258
3253 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3259 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3254 infinitely for integer or complex arrays (only worked with floats).
3260 infinitely for integer or complex arrays (only worked with floats).
3255
3261
3256 2002-03-16 Fernando Perez <fperez@colorado.edu>
3262 2002-03-16 Fernando Perez <fperez@colorado.edu>
3257
3263
3258 * setup.py: Merged setup and setup_windows into a single script
3264 * setup.py: Merged setup and setup_windows into a single script
3259 which properly handles things for windows users.
3265 which properly handles things for windows users.
3260
3266
3261 2002-03-15 Fernando Perez <fperez@colorado.edu>
3267 2002-03-15 Fernando Perez <fperez@colorado.edu>
3262
3268
3263 * Big change to the manual: now the magics are all automatically
3269 * Big change to the manual: now the magics are all automatically
3264 documented. This information is generated from their docstrings
3270 documented. This information is generated from their docstrings
3265 and put in a latex file included by the manual lyx file. This way
3271 and put in a latex file included by the manual lyx file. This way
3266 we get always up to date information for the magics. The manual
3272 we get always up to date information for the magics. The manual
3267 now also has proper version information, also auto-synced.
3273 now also has proper version information, also auto-synced.
3268
3274
3269 For this to work, an undocumented --magic_docstrings option was added.
3275 For this to work, an undocumented --magic_docstrings option was added.
3270
3276
3271 2002-03-13 Fernando Perez <fperez@colorado.edu>
3277 2002-03-13 Fernando Perez <fperez@colorado.edu>
3272
3278
3273 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3279 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3274 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3280 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3275
3281
3276 2002-03-12 Fernando Perez <fperez@colorado.edu>
3282 2002-03-12 Fernando Perez <fperez@colorado.edu>
3277
3283
3278 * IPython/ultraTB.py (TermColors): changed color escapes again to
3284 * IPython/ultraTB.py (TermColors): changed color escapes again to
3279 fix the (old, reintroduced) line-wrapping bug. Basically, if
3285 fix the (old, reintroduced) line-wrapping bug. Basically, if
3280 \001..\002 aren't given in the color escapes, lines get wrapped
3286 \001..\002 aren't given in the color escapes, lines get wrapped
3281 weirdly. But giving those screws up old xterms and emacs terms. So
3287 weirdly. But giving those screws up old xterms and emacs terms. So
3282 I added some logic for emacs terms to be ok, but I can't identify old
3288 I added some logic for emacs terms to be ok, but I can't identify old
3283 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3289 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3284
3290
3285 2002-03-10 Fernando Perez <fperez@colorado.edu>
3291 2002-03-10 Fernando Perez <fperez@colorado.edu>
3286
3292
3287 * IPython/usage.py (__doc__): Various documentation cleanups and
3293 * IPython/usage.py (__doc__): Various documentation cleanups and
3288 updates, both in usage docstrings and in the manual.
3294 updates, both in usage docstrings and in the manual.
3289
3295
3290 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3296 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3291 handling of caching. Set minimum acceptabe value for having a
3297 handling of caching. Set minimum acceptabe value for having a
3292 cache at 20 values.
3298 cache at 20 values.
3293
3299
3294 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3300 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3295 install_first_time function to a method, renamed it and added an
3301 install_first_time function to a method, renamed it and added an
3296 'upgrade' mode. Now people can update their config directory with
3302 'upgrade' mode. Now people can update their config directory with
3297 a simple command line switch (-upgrade, also new).
3303 a simple command line switch (-upgrade, also new).
3298
3304
3299 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3305 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3300 @file (convenient for automagic users under Python >= 2.2).
3306 @file (convenient for automagic users under Python >= 2.2).
3301 Removed @files (it seemed more like a plural than an abbrev. of
3307 Removed @files (it seemed more like a plural than an abbrev. of
3302 'file show').
3308 'file show').
3303
3309
3304 * IPython/iplib.py (install_first_time): Fixed crash if there were
3310 * IPython/iplib.py (install_first_time): Fixed crash if there were
3305 backup files ('~') in .ipython/ install directory.
3311 backup files ('~') in .ipython/ install directory.
3306
3312
3307 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3313 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3308 system. Things look fine, but these changes are fairly
3314 system. Things look fine, but these changes are fairly
3309 intrusive. Test them for a few days.
3315 intrusive. Test them for a few days.
3310
3316
3311 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3317 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3312 the prompts system. Now all in/out prompt strings are user
3318 the prompts system. Now all in/out prompt strings are user
3313 controllable. This is particularly useful for embedding, as one
3319 controllable. This is particularly useful for embedding, as one
3314 can tag embedded instances with particular prompts.
3320 can tag embedded instances with particular prompts.
3315
3321
3316 Also removed global use of sys.ps1/2, which now allows nested
3322 Also removed global use of sys.ps1/2, which now allows nested
3317 embeddings without any problems. Added command-line options for
3323 embeddings without any problems. Added command-line options for
3318 the prompt strings.
3324 the prompt strings.
3319
3325
3320 2002-03-08 Fernando Perez <fperez@colorado.edu>
3326 2002-03-08 Fernando Perez <fperez@colorado.edu>
3321
3327
3322 * IPython/UserConfig/example-embed-short.py (ipshell): added
3328 * IPython/UserConfig/example-embed-short.py (ipshell): added
3323 example file with the bare minimum code for embedding.
3329 example file with the bare minimum code for embedding.
3324
3330
3325 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3331 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3326 functionality for the embeddable shell to be activated/deactivated
3332 functionality for the embeddable shell to be activated/deactivated
3327 either globally or at each call.
3333 either globally or at each call.
3328
3334
3329 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3335 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3330 rewriting the prompt with '--->' for auto-inputs with proper
3336 rewriting the prompt with '--->' for auto-inputs with proper
3331 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3337 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3332 this is handled by the prompts class itself, as it should.
3338 this is handled by the prompts class itself, as it should.
3333
3339
3334 2002-03-05 Fernando Perez <fperez@colorado.edu>
3340 2002-03-05 Fernando Perez <fperez@colorado.edu>
3335
3341
3336 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3342 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3337 @logstart to avoid name clashes with the math log function.
3343 @logstart to avoid name clashes with the math log function.
3338
3344
3339 * Big updates to X/Emacs section of the manual.
3345 * Big updates to X/Emacs section of the manual.
3340
3346
3341 * Removed ipython_emacs. Milan explained to me how to pass
3347 * Removed ipython_emacs. Milan explained to me how to pass
3342 arguments to ipython through Emacs. Some day I'm going to end up
3348 arguments to ipython through Emacs. Some day I'm going to end up
3343 learning some lisp...
3349 learning some lisp...
3344
3350
3345 2002-03-04 Fernando Perez <fperez@colorado.edu>
3351 2002-03-04 Fernando Perez <fperez@colorado.edu>
3346
3352
3347 * IPython/ipython_emacs: Created script to be used as the
3353 * IPython/ipython_emacs: Created script to be used as the
3348 py-python-command Emacs variable so we can pass IPython
3354 py-python-command Emacs variable so we can pass IPython
3349 parameters. I can't figure out how to tell Emacs directly to pass
3355 parameters. I can't figure out how to tell Emacs directly to pass
3350 parameters to IPython, so a dummy shell script will do it.
3356 parameters to IPython, so a dummy shell script will do it.
3351
3357
3352 Other enhancements made for things to work better under Emacs'
3358 Other enhancements made for things to work better under Emacs'
3353 various types of terminals. Many thanks to Milan Zamazal
3359 various types of terminals. Many thanks to Milan Zamazal
3354 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3360 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3355
3361
3356 2002-03-01 Fernando Perez <fperez@colorado.edu>
3362 2002-03-01 Fernando Perez <fperez@colorado.edu>
3357
3363
3358 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3364 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3359 that loading of readline is now optional. This gives better
3365 that loading of readline is now optional. This gives better
3360 control to emacs users.
3366 control to emacs users.
3361
3367
3362 * IPython/ultraTB.py (__date__): Modified color escape sequences
3368 * IPython/ultraTB.py (__date__): Modified color escape sequences
3363 and now things work fine under xterm and in Emacs' term buffers
3369 and now things work fine under xterm and in Emacs' term buffers
3364 (though not shell ones). Well, in emacs you get colors, but all
3370 (though not shell ones). Well, in emacs you get colors, but all
3365 seem to be 'light' colors (no difference between dark and light
3371 seem to be 'light' colors (no difference between dark and light
3366 ones). But the garbage chars are gone, and also in xterms. It
3372 ones). But the garbage chars are gone, and also in xterms. It
3367 seems that now I'm using 'cleaner' ansi sequences.
3373 seems that now I'm using 'cleaner' ansi sequences.
3368
3374
3369 2002-02-21 Fernando Perez <fperez@colorado.edu>
3375 2002-02-21 Fernando Perez <fperez@colorado.edu>
3370
3376
3371 * Released 0.2.7 (mainly to publish the scoping fix).
3377 * Released 0.2.7 (mainly to publish the scoping fix).
3372
3378
3373 * IPython/Logger.py (Logger.logstate): added. A corresponding
3379 * IPython/Logger.py (Logger.logstate): added. A corresponding
3374 @logstate magic was created.
3380 @logstate magic was created.
3375
3381
3376 * IPython/Magic.py: fixed nested scoping problem under Python
3382 * IPython/Magic.py: fixed nested scoping problem under Python
3377 2.1.x (automagic wasn't working).
3383 2.1.x (automagic wasn't working).
3378
3384
3379 2002-02-20 Fernando Perez <fperez@colorado.edu>
3385 2002-02-20 Fernando Perez <fperez@colorado.edu>
3380
3386
3381 * Released 0.2.6.
3387 * Released 0.2.6.
3382
3388
3383 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
3389 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
3384 option so that logs can come out without any headers at all.
3390 option so that logs can come out without any headers at all.
3385
3391
3386 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
3392 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
3387 SciPy.
3393 SciPy.
3388
3394
3389 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
3395 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
3390 that embedded IPython calls don't require vars() to be explicitly
3396 that embedded IPython calls don't require vars() to be explicitly
3391 passed. Now they are extracted from the caller's frame (code
3397 passed. Now they are extracted from the caller's frame (code
3392 snatched from Eric Jones' weave). Added better documentation to
3398 snatched from Eric Jones' weave). Added better documentation to
3393 the section on embedding and the example file.
3399 the section on embedding and the example file.
3394
3400
3395 * IPython/genutils.py (page): Changed so that under emacs, it just
3401 * IPython/genutils.py (page): Changed so that under emacs, it just
3396 prints the string. You can then page up and down in the emacs
3402 prints the string. You can then page up and down in the emacs
3397 buffer itself. This is how the builtin help() works.
3403 buffer itself. This is how the builtin help() works.
3398
3404
3399 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
3405 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
3400 macro scoping: macros need to be executed in the user's namespace
3406 macro scoping: macros need to be executed in the user's namespace
3401 to work as if they had been typed by the user.
3407 to work as if they had been typed by the user.
3402
3408
3403 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
3409 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
3404 execute automatically (no need to type 'exec...'). They then
3410 execute automatically (no need to type 'exec...'). They then
3405 behave like 'true macros'. The printing system was also modified
3411 behave like 'true macros'. The printing system was also modified
3406 for this to work.
3412 for this to work.
3407
3413
3408 2002-02-19 Fernando Perez <fperez@colorado.edu>
3414 2002-02-19 Fernando Perez <fperez@colorado.edu>
3409
3415
3410 * IPython/genutils.py (page_file): new function for paging files
3416 * IPython/genutils.py (page_file): new function for paging files
3411 in an OS-independent way. Also necessary for file viewing to work
3417 in an OS-independent way. Also necessary for file viewing to work
3412 well inside Emacs buffers.
3418 well inside Emacs buffers.
3413 (page): Added checks for being in an emacs buffer.
3419 (page): Added checks for being in an emacs buffer.
3414 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
3420 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
3415 same bug in iplib.
3421 same bug in iplib.
3416
3422
3417 2002-02-18 Fernando Perez <fperez@colorado.edu>
3423 2002-02-18 Fernando Perez <fperez@colorado.edu>
3418
3424
3419 * IPython/iplib.py (InteractiveShell.init_readline): modified use
3425 * IPython/iplib.py (InteractiveShell.init_readline): modified use
3420 of readline so that IPython can work inside an Emacs buffer.
3426 of readline so that IPython can work inside an Emacs buffer.
3421
3427
3422 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
3428 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
3423 method signatures (they weren't really bugs, but it looks cleaner
3429 method signatures (they weren't really bugs, but it looks cleaner
3424 and keeps PyChecker happy).
3430 and keeps PyChecker happy).
3425
3431
3426 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
3432 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
3427 for implementing various user-defined hooks. Currently only
3433 for implementing various user-defined hooks. Currently only
3428 display is done.
3434 display is done.
3429
3435
3430 * IPython/Prompts.py (CachedOutput._display): changed display
3436 * IPython/Prompts.py (CachedOutput._display): changed display
3431 functions so that they can be dynamically changed by users easily.
3437 functions so that they can be dynamically changed by users easily.
3432
3438
3433 * IPython/Extensions/numeric_formats.py (num_display): added an
3439 * IPython/Extensions/numeric_formats.py (num_display): added an
3434 extension for printing NumPy arrays in flexible manners. It
3440 extension for printing NumPy arrays in flexible manners. It
3435 doesn't do anything yet, but all the structure is in
3441 doesn't do anything yet, but all the structure is in
3436 place. Ultimately the plan is to implement output format control
3442 place. Ultimately the plan is to implement output format control
3437 like in Octave.
3443 like in Octave.
3438
3444
3439 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
3445 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
3440 methods are found at run-time by all the automatic machinery.
3446 methods are found at run-time by all the automatic machinery.
3441
3447
3442 2002-02-17 Fernando Perez <fperez@colorado.edu>
3448 2002-02-17 Fernando Perez <fperez@colorado.edu>
3443
3449
3444 * setup_Windows.py (make_shortcut): documented. Cleaned up the
3450 * setup_Windows.py (make_shortcut): documented. Cleaned up the
3445 whole file a little.
3451 whole file a little.
3446
3452
3447 * ToDo: closed this document. Now there's a new_design.lyx
3453 * ToDo: closed this document. Now there's a new_design.lyx
3448 document for all new ideas. Added making a pdf of it for the
3454 document for all new ideas. Added making a pdf of it for the
3449 end-user distro.
3455 end-user distro.
3450
3456
3451 * IPython/Logger.py (Logger.switch_log): Created this to replace
3457 * IPython/Logger.py (Logger.switch_log): Created this to replace
3452 logon() and logoff(). It also fixes a nasty crash reported by
3458 logon() and logoff(). It also fixes a nasty crash reported by
3453 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
3459 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
3454
3460
3455 * IPython/iplib.py (complete): got auto-completion to work with
3461 * IPython/iplib.py (complete): got auto-completion to work with
3456 automagic (I had wanted this for a long time).
3462 automagic (I had wanted this for a long time).
3457
3463
3458 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
3464 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
3459 to @file, since file() is now a builtin and clashes with automagic
3465 to @file, since file() is now a builtin and clashes with automagic
3460 for @file.
3466 for @file.
3461
3467
3462 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
3468 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
3463 of this was previously in iplib, which had grown to more than 2000
3469 of this was previously in iplib, which had grown to more than 2000
3464 lines, way too long. No new functionality, but it makes managing
3470 lines, way too long. No new functionality, but it makes managing
3465 the code a bit easier.
3471 the code a bit easier.
3466
3472
3467 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
3473 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
3468 information to crash reports.
3474 information to crash reports.
3469
3475
3470 2002-02-12 Fernando Perez <fperez@colorado.edu>
3476 2002-02-12 Fernando Perez <fperez@colorado.edu>
3471
3477
3472 * Released 0.2.5.
3478 * Released 0.2.5.
3473
3479
3474 2002-02-11 Fernando Perez <fperez@colorado.edu>
3480 2002-02-11 Fernando Perez <fperez@colorado.edu>
3475
3481
3476 * Wrote a relatively complete Windows installer. It puts
3482 * Wrote a relatively complete Windows installer. It puts
3477 everything in place, creates Start Menu entries and fixes the
3483 everything in place, creates Start Menu entries and fixes the
3478 color issues. Nothing fancy, but it works.
3484 color issues. Nothing fancy, but it works.
3479
3485
3480 2002-02-10 Fernando Perez <fperez@colorado.edu>
3486 2002-02-10 Fernando Perez <fperez@colorado.edu>
3481
3487
3482 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
3488 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
3483 os.path.expanduser() call so that we can type @run ~/myfile.py and
3489 os.path.expanduser() call so that we can type @run ~/myfile.py and
3484 have thigs work as expected.
3490 have thigs work as expected.
3485
3491
3486 * IPython/genutils.py (page): fixed exception handling so things
3492 * IPython/genutils.py (page): fixed exception handling so things
3487 work both in Unix and Windows correctly. Quitting a pager triggers
3493 work both in Unix and Windows correctly. Quitting a pager triggers
3488 an IOError/broken pipe in Unix, and in windows not finding a pager
3494 an IOError/broken pipe in Unix, and in windows not finding a pager
3489 is also an IOError, so I had to actually look at the return value
3495 is also an IOError, so I had to actually look at the return value
3490 of the exception, not just the exception itself. Should be ok now.
3496 of the exception, not just the exception itself. Should be ok now.
3491
3497
3492 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
3498 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
3493 modified to allow case-insensitive color scheme changes.
3499 modified to allow case-insensitive color scheme changes.
3494
3500
3495 2002-02-09 Fernando Perez <fperez@colorado.edu>
3501 2002-02-09 Fernando Perez <fperez@colorado.edu>
3496
3502
3497 * IPython/genutils.py (native_line_ends): new function to leave
3503 * IPython/genutils.py (native_line_ends): new function to leave
3498 user config files with os-native line-endings.
3504 user config files with os-native line-endings.
3499
3505
3500 * README and manual updates.
3506 * README and manual updates.
3501
3507
3502 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
3508 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
3503 instead of StringType to catch Unicode strings.
3509 instead of StringType to catch Unicode strings.
3504
3510
3505 * IPython/genutils.py (filefind): fixed bug for paths with
3511 * IPython/genutils.py (filefind): fixed bug for paths with
3506 embedded spaces (very common in Windows).
3512 embedded spaces (very common in Windows).
3507
3513
3508 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
3514 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
3509 files under Windows, so that they get automatically associated
3515 files under Windows, so that they get automatically associated
3510 with a text editor. Windows makes it a pain to handle
3516 with a text editor. Windows makes it a pain to handle
3511 extension-less files.
3517 extension-less files.
3512
3518
3513 * IPython/iplib.py (InteractiveShell.init_readline): Made the
3519 * IPython/iplib.py (InteractiveShell.init_readline): Made the
3514 warning about readline only occur for Posix. In Windows there's no
3520 warning about readline only occur for Posix. In Windows there's no
3515 way to get readline, so why bother with the warning.
3521 way to get readline, so why bother with the warning.
3516
3522
3517 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
3523 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
3518 for __str__ instead of dir(self), since dir() changed in 2.2.
3524 for __str__ instead of dir(self), since dir() changed in 2.2.
3519
3525
3520 * Ported to Windows! Tested on XP, I suspect it should work fine
3526 * Ported to Windows! Tested on XP, I suspect it should work fine
3521 on NT/2000, but I don't think it will work on 98 et al. That
3527 on NT/2000, but I don't think it will work on 98 et al. That
3522 series of Windows is such a piece of junk anyway that I won't try
3528 series of Windows is such a piece of junk anyway that I won't try
3523 porting it there. The XP port was straightforward, showed a few
3529 porting it there. The XP port was straightforward, showed a few
3524 bugs here and there (fixed all), in particular some string
3530 bugs here and there (fixed all), in particular some string
3525 handling stuff which required considering Unicode strings (which
3531 handling stuff which required considering Unicode strings (which
3526 Windows uses). This is good, but hasn't been too tested :) No
3532 Windows uses). This is good, but hasn't been too tested :) No
3527 fancy installer yet, I'll put a note in the manual so people at
3533 fancy installer yet, I'll put a note in the manual so people at
3528 least make manually a shortcut.
3534 least make manually a shortcut.
3529
3535
3530 * IPython/iplib.py (Magic.magic_colors): Unified the color options
3536 * IPython/iplib.py (Magic.magic_colors): Unified the color options
3531 into a single one, "colors". This now controls both prompt and
3537 into a single one, "colors". This now controls both prompt and
3532 exception color schemes, and can be changed both at startup
3538 exception color schemes, and can be changed both at startup
3533 (either via command-line switches or via ipythonrc files) and at
3539 (either via command-line switches or via ipythonrc files) and at
3534 runtime, with @colors.
3540 runtime, with @colors.
3535 (Magic.magic_run): renamed @prun to @run and removed the old
3541 (Magic.magic_run): renamed @prun to @run and removed the old
3536 @run. The two were too similar to warrant keeping both.
3542 @run. The two were too similar to warrant keeping both.
3537
3543
3538 2002-02-03 Fernando Perez <fperez@colorado.edu>
3544 2002-02-03 Fernando Perez <fperez@colorado.edu>
3539
3545
3540 * IPython/iplib.py (install_first_time): Added comment on how to
3546 * IPython/iplib.py (install_first_time): Added comment on how to
3541 configure the color options for first-time users. Put a <return>
3547 configure the color options for first-time users. Put a <return>
3542 request at the end so that small-terminal users get a chance to
3548 request at the end so that small-terminal users get a chance to
3543 read the startup info.
3549 read the startup info.
3544
3550
3545 2002-01-23 Fernando Perez <fperez@colorado.edu>
3551 2002-01-23 Fernando Perez <fperez@colorado.edu>
3546
3552
3547 * IPython/iplib.py (CachedOutput.update): Changed output memory
3553 * IPython/iplib.py (CachedOutput.update): Changed output memory
3548 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
3554 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
3549 input history we still use _i. Did this b/c these variable are
3555 input history we still use _i. Did this b/c these variable are
3550 very commonly used in interactive work, so the less we need to
3556 very commonly used in interactive work, so the less we need to
3551 type the better off we are.
3557 type the better off we are.
3552 (Magic.magic_prun): updated @prun to better handle the namespaces
3558 (Magic.magic_prun): updated @prun to better handle the namespaces
3553 the file will run in, including a fix for __name__ not being set
3559 the file will run in, including a fix for __name__ not being set
3554 before.
3560 before.
3555
3561
3556 2002-01-20 Fernando Perez <fperez@colorado.edu>
3562 2002-01-20 Fernando Perez <fperez@colorado.edu>
3557
3563
3558 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
3564 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
3559 extra garbage for Python 2.2. Need to look more carefully into
3565 extra garbage for Python 2.2. Need to look more carefully into
3560 this later.
3566 this later.
3561
3567
3562 2002-01-19 Fernando Perez <fperez@colorado.edu>
3568 2002-01-19 Fernando Perez <fperez@colorado.edu>
3563
3569
3564 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
3570 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
3565 display SyntaxError exceptions properly formatted when they occur
3571 display SyntaxError exceptions properly formatted when they occur
3566 (they can be triggered by imported code).
3572 (they can be triggered by imported code).
3567
3573
3568 2002-01-18 Fernando Perez <fperez@colorado.edu>
3574 2002-01-18 Fernando Perez <fperez@colorado.edu>
3569
3575
3570 * IPython/iplib.py (InteractiveShell.safe_execfile): now
3576 * IPython/iplib.py (InteractiveShell.safe_execfile): now
3571 SyntaxError exceptions are reported nicely formatted, instead of
3577 SyntaxError exceptions are reported nicely formatted, instead of
3572 spitting out only offset information as before.
3578 spitting out only offset information as before.
3573 (Magic.magic_prun): Added the @prun function for executing
3579 (Magic.magic_prun): Added the @prun function for executing
3574 programs with command line args inside IPython.
3580 programs with command line args inside IPython.
3575
3581
3576 2002-01-16 Fernando Perez <fperez@colorado.edu>
3582 2002-01-16 Fernando Perez <fperez@colorado.edu>
3577
3583
3578 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
3584 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
3579 to *not* include the last item given in a range. This brings their
3585 to *not* include the last item given in a range. This brings their
3580 behavior in line with Python's slicing:
3586 behavior in line with Python's slicing:
3581 a[n1:n2] -> a[n1]...a[n2-1]
3587 a[n1:n2] -> a[n1]...a[n2-1]
3582 It may be a bit less convenient, but I prefer to stick to Python's
3588 It may be a bit less convenient, but I prefer to stick to Python's
3583 conventions *everywhere*, so users never have to wonder.
3589 conventions *everywhere*, so users never have to wonder.
3584 (Magic.magic_macro): Added @macro function to ease the creation of
3590 (Magic.magic_macro): Added @macro function to ease the creation of
3585 macros.
3591 macros.
3586
3592
3587 2002-01-05 Fernando Perez <fperez@colorado.edu>
3593 2002-01-05 Fernando Perez <fperez@colorado.edu>
3588
3594
3589 * Released 0.2.4.
3595 * Released 0.2.4.
3590
3596
3591 * IPython/iplib.py (Magic.magic_pdef):
3597 * IPython/iplib.py (Magic.magic_pdef):
3592 (InteractiveShell.safe_execfile): report magic lines and error
3598 (InteractiveShell.safe_execfile): report magic lines and error
3593 lines without line numbers so one can easily copy/paste them for
3599 lines without line numbers so one can easily copy/paste them for
3594 re-execution.
3600 re-execution.
3595
3601
3596 * Updated manual with recent changes.
3602 * Updated manual with recent changes.
3597
3603
3598 * IPython/iplib.py (Magic.magic_oinfo): added constructor
3604 * IPython/iplib.py (Magic.magic_oinfo): added constructor
3599 docstring printing when class? is called. Very handy for knowing
3605 docstring printing when class? is called. Very handy for knowing
3600 how to create class instances (as long as __init__ is well
3606 how to create class instances (as long as __init__ is well
3601 documented, of course :)
3607 documented, of course :)
3602 (Magic.magic_doc): print both class and constructor docstrings.
3608 (Magic.magic_doc): print both class and constructor docstrings.
3603 (Magic.magic_pdef): give constructor info if passed a class and
3609 (Magic.magic_pdef): give constructor info if passed a class and
3604 __call__ info for callable object instances.
3610 __call__ info for callable object instances.
3605
3611
3606 2002-01-04 Fernando Perez <fperez@colorado.edu>
3612 2002-01-04 Fernando Perez <fperez@colorado.edu>
3607
3613
3608 * Made deep_reload() off by default. It doesn't always work
3614 * Made deep_reload() off by default. It doesn't always work
3609 exactly as intended, so it's probably safer to have it off. It's
3615 exactly as intended, so it's probably safer to have it off. It's
3610 still available as dreload() anyway, so nothing is lost.
3616 still available as dreload() anyway, so nothing is lost.
3611
3617
3612 2002-01-02 Fernando Perez <fperez@colorado.edu>
3618 2002-01-02 Fernando Perez <fperez@colorado.edu>
3613
3619
3614 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
3620 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
3615 so I wanted an updated release).
3621 so I wanted an updated release).
3616
3622
3617 2001-12-27 Fernando Perez <fperez@colorado.edu>
3623 2001-12-27 Fernando Perez <fperez@colorado.edu>
3618
3624
3619 * IPython/iplib.py (InteractiveShell.interact): Added the original
3625 * IPython/iplib.py (InteractiveShell.interact): Added the original
3620 code from 'code.py' for this module in order to change the
3626 code from 'code.py' for this module in order to change the
3621 handling of a KeyboardInterrupt. This was necessary b/c otherwise
3627 handling of a KeyboardInterrupt. This was necessary b/c otherwise
3622 the history cache would break when the user hit Ctrl-C, and
3628 the history cache would break when the user hit Ctrl-C, and
3623 interact() offers no way to add any hooks to it.
3629 interact() offers no way to add any hooks to it.
3624
3630
3625 2001-12-23 Fernando Perez <fperez@colorado.edu>
3631 2001-12-23 Fernando Perez <fperez@colorado.edu>
3626
3632
3627 * setup.py: added check for 'MANIFEST' before trying to remove
3633 * setup.py: added check for 'MANIFEST' before trying to remove
3628 it. Thanks to Sean Reifschneider.
3634 it. Thanks to Sean Reifschneider.
3629
3635
3630 2001-12-22 Fernando Perez <fperez@colorado.edu>
3636 2001-12-22 Fernando Perez <fperez@colorado.edu>
3631
3637
3632 * Released 0.2.2.
3638 * Released 0.2.2.
3633
3639
3634 * Finished (reasonably) writing the manual. Later will add the
3640 * Finished (reasonably) writing the manual. Later will add the
3635 python-standard navigation stylesheets, but for the time being
3641 python-standard navigation stylesheets, but for the time being
3636 it's fairly complete. Distribution will include html and pdf
3642 it's fairly complete. Distribution will include html and pdf
3637 versions.
3643 versions.
3638
3644
3639 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
3645 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
3640 (MayaVi author).
3646 (MayaVi author).
3641
3647
3642 2001-12-21 Fernando Perez <fperez@colorado.edu>
3648 2001-12-21 Fernando Perez <fperez@colorado.edu>
3643
3649
3644 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
3650 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
3645 good public release, I think (with the manual and the distutils
3651 good public release, I think (with the manual and the distutils
3646 installer). The manual can use some work, but that can go
3652 installer). The manual can use some work, but that can go
3647 slowly. Otherwise I think it's quite nice for end users. Next
3653 slowly. Otherwise I think it's quite nice for end users. Next
3648 summer, rewrite the guts of it...
3654 summer, rewrite the guts of it...
3649
3655
3650 * Changed format of ipythonrc files to use whitespace as the
3656 * Changed format of ipythonrc files to use whitespace as the
3651 separator instead of an explicit '='. Cleaner.
3657 separator instead of an explicit '='. Cleaner.
3652
3658
3653 2001-12-20 Fernando Perez <fperez@colorado.edu>
3659 2001-12-20 Fernando Perez <fperez@colorado.edu>
3654
3660
3655 * Started a manual in LyX. For now it's just a quick merge of the
3661 * Started a manual in LyX. For now it's just a quick merge of the
3656 various internal docstrings and READMEs. Later it may grow into a
3662 various internal docstrings and READMEs. Later it may grow into a
3657 nice, full-blown manual.
3663 nice, full-blown manual.
3658
3664
3659 * Set up a distutils based installer. Installation should now be
3665 * Set up a distutils based installer. Installation should now be
3660 trivially simple for end-users.
3666 trivially simple for end-users.
3661
3667
3662 2001-12-11 Fernando Perez <fperez@colorado.edu>
3668 2001-12-11 Fernando Perez <fperez@colorado.edu>
3663
3669
3664 * Released 0.2.0. First public release, announced it at
3670 * Released 0.2.0. First public release, announced it at
3665 comp.lang.python. From now on, just bugfixes...
3671 comp.lang.python. From now on, just bugfixes...
3666
3672
3667 * Went through all the files, set copyright/license notices and
3673 * Went through all the files, set copyright/license notices and
3668 cleaned up things. Ready for release.
3674 cleaned up things. Ready for release.
3669
3675
3670 2001-12-10 Fernando Perez <fperez@colorado.edu>
3676 2001-12-10 Fernando Perez <fperez@colorado.edu>
3671
3677
3672 * Changed the first-time installer not to use tarfiles. It's more
3678 * Changed the first-time installer not to use tarfiles. It's more
3673 robust now and less unix-dependent. Also makes it easier for
3679 robust now and less unix-dependent. Also makes it easier for
3674 people to later upgrade versions.
3680 people to later upgrade versions.
3675
3681
3676 * Changed @exit to @abort to reflect the fact that it's pretty
3682 * Changed @exit to @abort to reflect the fact that it's pretty
3677 brutal (a sys.exit()). The difference between @abort and Ctrl-D
3683 brutal (a sys.exit()). The difference between @abort and Ctrl-D
3678 becomes significant only when IPyhton is embedded: in that case,
3684 becomes significant only when IPyhton is embedded: in that case,
3679 C-D closes IPython only, but @abort kills the enclosing program
3685 C-D closes IPython only, but @abort kills the enclosing program
3680 too (unless it had called IPython inside a try catching
3686 too (unless it had called IPython inside a try catching
3681 SystemExit).
3687 SystemExit).
3682
3688
3683 * Created Shell module which exposes the actuall IPython Shell
3689 * Created Shell module which exposes the actuall IPython Shell
3684 classes, currently the normal and the embeddable one. This at
3690 classes, currently the normal and the embeddable one. This at
3685 least offers a stable interface we won't need to change when
3691 least offers a stable interface we won't need to change when
3686 (later) the internals are rewritten. That rewrite will be confined
3692 (later) the internals are rewritten. That rewrite will be confined
3687 to iplib and ipmaker, but the Shell interface should remain as is.
3693 to iplib and ipmaker, but the Shell interface should remain as is.
3688
3694
3689 * Added embed module which offers an embeddable IPShell object,
3695 * Added embed module which offers an embeddable IPShell object,
3690 useful to fire up IPython *inside* a running program. Great for
3696 useful to fire up IPython *inside* a running program. Great for
3691 debugging or dynamical data analysis.
3697 debugging or dynamical data analysis.
3692
3698
3693 2001-12-08 Fernando Perez <fperez@colorado.edu>
3699 2001-12-08 Fernando Perez <fperez@colorado.edu>
3694
3700
3695 * Fixed small bug preventing seeing info from methods of defined
3701 * Fixed small bug preventing seeing info from methods of defined
3696 objects (incorrect namespace in _ofind()).
3702 objects (incorrect namespace in _ofind()).
3697
3703
3698 * Documentation cleanup. Moved the main usage docstrings to a
3704 * Documentation cleanup. Moved the main usage docstrings to a
3699 separate file, usage.py (cleaner to maintain, and hopefully in the
3705 separate file, usage.py (cleaner to maintain, and hopefully in the
3700 future some perlpod-like way of producing interactive, man and
3706 future some perlpod-like way of producing interactive, man and
3701 html docs out of it will be found).
3707 html docs out of it will be found).
3702
3708
3703 * Added @profile to see your profile at any time.
3709 * Added @profile to see your profile at any time.
3704
3710
3705 * Added @p as an alias for 'print'. It's especially convenient if
3711 * Added @p as an alias for 'print'. It's especially convenient if
3706 using automagic ('p x' prints x).
3712 using automagic ('p x' prints x).
3707
3713
3708 * Small cleanups and fixes after a pychecker run.
3714 * Small cleanups and fixes after a pychecker run.
3709
3715
3710 * Changed the @cd command to handle @cd - and @cd -<n> for
3716 * Changed the @cd command to handle @cd - and @cd -<n> for
3711 visiting any directory in _dh.
3717 visiting any directory in _dh.
3712
3718
3713 * Introduced _dh, a history of visited directories. @dhist prints
3719 * Introduced _dh, a history of visited directories. @dhist prints
3714 it out with numbers.
3720 it out with numbers.
3715
3721
3716 2001-12-07 Fernando Perez <fperez@colorado.edu>
3722 2001-12-07 Fernando Perez <fperez@colorado.edu>
3717
3723
3718 * Released 0.1.22
3724 * Released 0.1.22
3719
3725
3720 * Made initialization a bit more robust against invalid color
3726 * Made initialization a bit more robust against invalid color
3721 options in user input (exit, not traceback-crash).
3727 options in user input (exit, not traceback-crash).
3722
3728
3723 * Changed the bug crash reporter to write the report only in the
3729 * Changed the bug crash reporter to write the report only in the
3724 user's .ipython directory. That way IPython won't litter people's
3730 user's .ipython directory. That way IPython won't litter people's
3725 hard disks with crash files all over the place. Also print on
3731 hard disks with crash files all over the place. Also print on
3726 screen the necessary mail command.
3732 screen the necessary mail command.
3727
3733
3728 * With the new ultraTB, implemented LightBG color scheme for light
3734 * With the new ultraTB, implemented LightBG color scheme for light
3729 background terminals. A lot of people like white backgrounds, so I
3735 background terminals. A lot of people like white backgrounds, so I
3730 guess we should at least give them something readable.
3736 guess we should at least give them something readable.
3731
3737
3732 2001-12-06 Fernando Perez <fperez@colorado.edu>
3738 2001-12-06 Fernando Perez <fperez@colorado.edu>
3733
3739
3734 * Modified the structure of ultraTB. Now there's a proper class
3740 * Modified the structure of ultraTB. Now there's a proper class
3735 for tables of color schemes which allow adding schemes easily and
3741 for tables of color schemes which allow adding schemes easily and
3736 switching the active scheme without creating a new instance every
3742 switching the active scheme without creating a new instance every
3737 time (which was ridiculous). The syntax for creating new schemes
3743 time (which was ridiculous). The syntax for creating new schemes
3738 is also cleaner. I think ultraTB is finally done, with a clean
3744 is also cleaner. I think ultraTB is finally done, with a clean
3739 class structure. Names are also much cleaner (now there's proper
3745 class structure. Names are also much cleaner (now there's proper
3740 color tables, no need for every variable to also have 'color' in
3746 color tables, no need for every variable to also have 'color' in
3741 its name).
3747 its name).
3742
3748
3743 * Broke down genutils into separate files. Now genutils only
3749 * Broke down genutils into separate files. Now genutils only
3744 contains utility functions, and classes have been moved to their
3750 contains utility functions, and classes have been moved to their
3745 own files (they had enough independent functionality to warrant
3751 own files (they had enough independent functionality to warrant
3746 it): ConfigLoader, OutputTrap, Struct.
3752 it): ConfigLoader, OutputTrap, Struct.
3747
3753
3748 2001-12-05 Fernando Perez <fperez@colorado.edu>
3754 2001-12-05 Fernando Perez <fperez@colorado.edu>
3749
3755
3750 * IPython turns 21! Released version 0.1.21, as a candidate for
3756 * IPython turns 21! Released version 0.1.21, as a candidate for
3751 public consumption. If all goes well, release in a few days.
3757 public consumption. If all goes well, release in a few days.
3752
3758
3753 * Fixed path bug (files in Extensions/ directory wouldn't be found
3759 * Fixed path bug (files in Extensions/ directory wouldn't be found
3754 unless IPython/ was explicitly in sys.path).
3760 unless IPython/ was explicitly in sys.path).
3755
3761
3756 * Extended the FlexCompleter class as MagicCompleter to allow
3762 * Extended the FlexCompleter class as MagicCompleter to allow
3757 completion of @-starting lines.
3763 completion of @-starting lines.
3758
3764
3759 * Created __release__.py file as a central repository for release
3765 * Created __release__.py file as a central repository for release
3760 info that other files can read from.
3766 info that other files can read from.
3761
3767
3762 * Fixed small bug in logging: when logging was turned on in
3768 * Fixed small bug in logging: when logging was turned on in
3763 mid-session, old lines with special meanings (!@?) were being
3769 mid-session, old lines with special meanings (!@?) were being
3764 logged without the prepended comment, which is necessary since
3770 logged without the prepended comment, which is necessary since
3765 they are not truly valid python syntax. This should make session
3771 they are not truly valid python syntax. This should make session
3766 restores produce less errors.
3772 restores produce less errors.
3767
3773
3768 * The namespace cleanup forced me to make a FlexCompleter class
3774 * The namespace cleanup forced me to make a FlexCompleter class
3769 which is nothing but a ripoff of rlcompleter, but with selectable
3775 which is nothing but a ripoff of rlcompleter, but with selectable
3770 namespace (rlcompleter only works in __main__.__dict__). I'll try
3776 namespace (rlcompleter only works in __main__.__dict__). I'll try
3771 to submit a note to the authors to see if this change can be
3777 to submit a note to the authors to see if this change can be
3772 incorporated in future rlcompleter releases (Dec.6: done)
3778 incorporated in future rlcompleter releases (Dec.6: done)
3773
3779
3774 * More fixes to namespace handling. It was a mess! Now all
3780 * More fixes to namespace handling. It was a mess! Now all
3775 explicit references to __main__.__dict__ are gone (except when
3781 explicit references to __main__.__dict__ are gone (except when
3776 really needed) and everything is handled through the namespace
3782 really needed) and everything is handled through the namespace
3777 dicts in the IPython instance. We seem to be getting somewhere
3783 dicts in the IPython instance. We seem to be getting somewhere
3778 with this, finally...
3784 with this, finally...
3779
3785
3780 * Small documentation updates.
3786 * Small documentation updates.
3781
3787
3782 * Created the Extensions directory under IPython (with an
3788 * Created the Extensions directory under IPython (with an
3783 __init__.py). Put the PhysicalQ stuff there. This directory should
3789 __init__.py). Put the PhysicalQ stuff there. This directory should
3784 be used for all special-purpose extensions.
3790 be used for all special-purpose extensions.
3785
3791
3786 * File renaming:
3792 * File renaming:
3787 ipythonlib --> ipmaker
3793 ipythonlib --> ipmaker
3788 ipplib --> iplib
3794 ipplib --> iplib
3789 This makes a bit more sense in terms of what these files actually do.
3795 This makes a bit more sense in terms of what these files actually do.
3790
3796
3791 * Moved all the classes and functions in ipythonlib to ipplib, so
3797 * Moved all the classes and functions in ipythonlib to ipplib, so
3792 now ipythonlib only has make_IPython(). This will ease up its
3798 now ipythonlib only has make_IPython(). This will ease up its
3793 splitting in smaller functional chunks later.
3799 splitting in smaller functional chunks later.
3794
3800
3795 * Cleaned up (done, I think) output of @whos. Better column
3801 * Cleaned up (done, I think) output of @whos. Better column
3796 formatting, and now shows str(var) for as much as it can, which is
3802 formatting, and now shows str(var) for as much as it can, which is
3797 typically what one gets with a 'print var'.
3803 typically what one gets with a 'print var'.
3798
3804
3799 2001-12-04 Fernando Perez <fperez@colorado.edu>
3805 2001-12-04 Fernando Perez <fperez@colorado.edu>
3800
3806
3801 * Fixed namespace problems. Now builtin/IPyhton/user names get
3807 * Fixed namespace problems. Now builtin/IPyhton/user names get
3802 properly reported in their namespace. Internal namespace handling
3808 properly reported in their namespace. Internal namespace handling
3803 is finally getting decent (not perfect yet, but much better than
3809 is finally getting decent (not perfect yet, but much better than
3804 the ad-hoc mess we had).
3810 the ad-hoc mess we had).
3805
3811
3806 * Removed -exit option. If people just want to run a python
3812 * Removed -exit option. If people just want to run a python
3807 script, that's what the normal interpreter is for. Less
3813 script, that's what the normal interpreter is for. Less
3808 unnecessary options, less chances for bugs.
3814 unnecessary options, less chances for bugs.
3809
3815
3810 * Added a crash handler which generates a complete post-mortem if
3816 * Added a crash handler which generates a complete post-mortem if
3811 IPython crashes. This will help a lot in tracking bugs down the
3817 IPython crashes. This will help a lot in tracking bugs down the
3812 road.
3818 road.
3813
3819
3814 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
3820 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
3815 which were boud to functions being reassigned would bypass the
3821 which were boud to functions being reassigned would bypass the
3816 logger, breaking the sync of _il with the prompt counter. This
3822 logger, breaking the sync of _il with the prompt counter. This
3817 would then crash IPython later when a new line was logged.
3823 would then crash IPython later when a new line was logged.
3818
3824
3819 2001-12-02 Fernando Perez <fperez@colorado.edu>
3825 2001-12-02 Fernando Perez <fperez@colorado.edu>
3820
3826
3821 * Made IPython a package. This means people don't have to clutter
3827 * Made IPython a package. This means people don't have to clutter
3822 their sys.path with yet another directory. Changed the INSTALL
3828 their sys.path with yet another directory. Changed the INSTALL
3823 file accordingly.
3829 file accordingly.
3824
3830
3825 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
3831 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
3826 sorts its output (so @who shows it sorted) and @whos formats the
3832 sorts its output (so @who shows it sorted) and @whos formats the
3827 table according to the width of the first column. Nicer, easier to
3833 table according to the width of the first column. Nicer, easier to
3828 read. Todo: write a generic table_format() which takes a list of
3834 read. Todo: write a generic table_format() which takes a list of
3829 lists and prints it nicely formatted, with optional row/column
3835 lists and prints it nicely formatted, with optional row/column
3830 separators and proper padding and justification.
3836 separators and proper padding and justification.
3831
3837
3832 * Released 0.1.20
3838 * Released 0.1.20
3833
3839
3834 * Fixed bug in @log which would reverse the inputcache list (a
3840 * Fixed bug in @log which would reverse the inputcache list (a
3835 copy operation was missing).
3841 copy operation was missing).
3836
3842
3837 * Code cleanup. @config was changed to use page(). Better, since
3843 * Code cleanup. @config was changed to use page(). Better, since
3838 its output is always quite long.
3844 its output is always quite long.
3839
3845
3840 * Itpl is back as a dependency. I was having too many problems
3846 * Itpl is back as a dependency. I was having too many problems
3841 getting the parametric aliases to work reliably, and it's just
3847 getting the parametric aliases to work reliably, and it's just
3842 easier to code weird string operations with it than playing %()s
3848 easier to code weird string operations with it than playing %()s
3843 games. It's only ~6k, so I don't think it's too big a deal.
3849 games. It's only ~6k, so I don't think it's too big a deal.
3844
3850
3845 * Found (and fixed) a very nasty bug with history. !lines weren't
3851 * Found (and fixed) a very nasty bug with history. !lines weren't
3846 getting cached, and the out of sync caches would crash
3852 getting cached, and the out of sync caches would crash
3847 IPython. Fixed it by reorganizing the prefilter/handlers/logger
3853 IPython. Fixed it by reorganizing the prefilter/handlers/logger
3848 division of labor a bit better. Bug fixed, cleaner structure.
3854 division of labor a bit better. Bug fixed, cleaner structure.
3849
3855
3850 2001-12-01 Fernando Perez <fperez@colorado.edu>
3856 2001-12-01 Fernando Perez <fperez@colorado.edu>
3851
3857
3852 * Released 0.1.19
3858 * Released 0.1.19
3853
3859
3854 * Added option -n to @hist to prevent line number printing. Much
3860 * Added option -n to @hist to prevent line number printing. Much
3855 easier to copy/paste code this way.
3861 easier to copy/paste code this way.
3856
3862
3857 * Created global _il to hold the input list. Allows easy
3863 * Created global _il to hold the input list. Allows easy
3858 re-execution of blocks of code by slicing it (inspired by Janko's
3864 re-execution of blocks of code by slicing it (inspired by Janko's
3859 comment on 'macros').
3865 comment on 'macros').
3860
3866
3861 * Small fixes and doc updates.
3867 * Small fixes and doc updates.
3862
3868
3863 * Rewrote @history function (was @h). Renamed it to @hist, @h is
3869 * Rewrote @history function (was @h). Renamed it to @hist, @h is
3864 much too fragile with automagic. Handles properly multi-line
3870 much too fragile with automagic. Handles properly multi-line
3865 statements and takes parameters.
3871 statements and takes parameters.
3866
3872
3867 2001-11-30 Fernando Perez <fperez@colorado.edu>
3873 2001-11-30 Fernando Perez <fperez@colorado.edu>
3868
3874
3869 * Version 0.1.18 released.
3875 * Version 0.1.18 released.
3870
3876
3871 * Fixed nasty namespace bug in initial module imports.
3877 * Fixed nasty namespace bug in initial module imports.
3872
3878
3873 * Added copyright/license notes to all code files (except
3879 * Added copyright/license notes to all code files (except
3874 DPyGetOpt). For the time being, LGPL. That could change.
3880 DPyGetOpt). For the time being, LGPL. That could change.
3875
3881
3876 * Rewrote a much nicer README, updated INSTALL, cleaned up
3882 * Rewrote a much nicer README, updated INSTALL, cleaned up
3877 ipythonrc-* samples.
3883 ipythonrc-* samples.
3878
3884
3879 * Overall code/documentation cleanup. Basically ready for
3885 * Overall code/documentation cleanup. Basically ready for
3880 release. Only remaining thing: licence decision (LGPL?).
3886 release. Only remaining thing: licence decision (LGPL?).
3881
3887
3882 * Converted load_config to a class, ConfigLoader. Now recursion
3888 * Converted load_config to a class, ConfigLoader. Now recursion
3883 control is better organized. Doesn't include the same file twice.
3889 control is better organized. Doesn't include the same file twice.
3884
3890
3885 2001-11-29 Fernando Perez <fperez@colorado.edu>
3891 2001-11-29 Fernando Perez <fperez@colorado.edu>
3886
3892
3887 * Got input history working. Changed output history variables from
3893 * Got input history working. Changed output history variables from
3888 _p to _o so that _i is for input and _o for output. Just cleaner
3894 _p to _o so that _i is for input and _o for output. Just cleaner
3889 convention.
3895 convention.
3890
3896
3891 * Implemented parametric aliases. This pretty much allows the
3897 * Implemented parametric aliases. This pretty much allows the
3892 alias system to offer full-blown shell convenience, I think.
3898 alias system to offer full-blown shell convenience, I think.
3893
3899
3894 * Version 0.1.17 released, 0.1.18 opened.
3900 * Version 0.1.17 released, 0.1.18 opened.
3895
3901
3896 * dot_ipython/ipythonrc (alias): added documentation.
3902 * dot_ipython/ipythonrc (alias): added documentation.
3897 (xcolor): Fixed small bug (xcolors -> xcolor)
3903 (xcolor): Fixed small bug (xcolors -> xcolor)
3898
3904
3899 * Changed the alias system. Now alias is a magic command to define
3905 * Changed the alias system. Now alias is a magic command to define
3900 aliases just like the shell. Rationale: the builtin magics should
3906 aliases just like the shell. Rationale: the builtin magics should
3901 be there for things deeply connected to IPython's
3907 be there for things deeply connected to IPython's
3902 architecture. And this is a much lighter system for what I think
3908 architecture. And this is a much lighter system for what I think
3903 is the really important feature: allowing users to define quickly
3909 is the really important feature: allowing users to define quickly
3904 magics that will do shell things for them, so they can customize
3910 magics that will do shell things for them, so they can customize
3905 IPython easily to match their work habits. If someone is really
3911 IPython easily to match their work habits. If someone is really
3906 desperate to have another name for a builtin alias, they can
3912 desperate to have another name for a builtin alias, they can
3907 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
3913 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
3908 works.
3914 works.
3909
3915
3910 2001-11-28 Fernando Perez <fperez@colorado.edu>
3916 2001-11-28 Fernando Perez <fperez@colorado.edu>
3911
3917
3912 * Changed @file so that it opens the source file at the proper
3918 * Changed @file so that it opens the source file at the proper
3913 line. Since it uses less, if your EDITOR environment is
3919 line. Since it uses less, if your EDITOR environment is
3914 configured, typing v will immediately open your editor of choice
3920 configured, typing v will immediately open your editor of choice
3915 right at the line where the object is defined. Not as quick as
3921 right at the line where the object is defined. Not as quick as
3916 having a direct @edit command, but for all intents and purposes it
3922 having a direct @edit command, but for all intents and purposes it
3917 works. And I don't have to worry about writing @edit to deal with
3923 works. And I don't have to worry about writing @edit to deal with
3918 all the editors, less does that.
3924 all the editors, less does that.
3919
3925
3920 * Version 0.1.16 released, 0.1.17 opened.
3926 * Version 0.1.16 released, 0.1.17 opened.
3921
3927
3922 * Fixed some nasty bugs in the page/page_dumb combo that could
3928 * Fixed some nasty bugs in the page/page_dumb combo that could
3923 crash IPython.
3929 crash IPython.
3924
3930
3925 2001-11-27 Fernando Perez <fperez@colorado.edu>
3931 2001-11-27 Fernando Perez <fperez@colorado.edu>
3926
3932
3927 * Version 0.1.15 released, 0.1.16 opened.
3933 * Version 0.1.15 released, 0.1.16 opened.
3928
3934
3929 * Finally got ? and ?? to work for undefined things: now it's
3935 * Finally got ? and ?? to work for undefined things: now it's
3930 possible to type {}.get? and get information about the get method
3936 possible to type {}.get? and get information about the get method
3931 of dicts, or os.path? even if only os is defined (so technically
3937 of dicts, or os.path? even if only os is defined (so technically
3932 os.path isn't). Works at any level. For example, after import os,
3938 os.path isn't). Works at any level. For example, after import os,
3933 os?, os.path?, os.path.abspath? all work. This is great, took some
3939 os?, os.path?, os.path.abspath? all work. This is great, took some
3934 work in _ofind.
3940 work in _ofind.
3935
3941
3936 * Fixed more bugs with logging. The sanest way to do it was to add
3942 * Fixed more bugs with logging. The sanest way to do it was to add
3937 to @log a 'mode' parameter. Killed two in one shot (this mode
3943 to @log a 'mode' parameter. Killed two in one shot (this mode
3938 option was a request of Janko's). I think it's finally clean
3944 option was a request of Janko's). I think it's finally clean
3939 (famous last words).
3945 (famous last words).
3940
3946
3941 * Added a page_dumb() pager which does a decent job of paging on
3947 * Added a page_dumb() pager which does a decent job of paging on
3942 screen, if better things (like less) aren't available. One less
3948 screen, if better things (like less) aren't available. One less
3943 unix dependency (someday maybe somebody will port this to
3949 unix dependency (someday maybe somebody will port this to
3944 windows).
3950 windows).
3945
3951
3946 * Fixed problem in magic_log: would lock of logging out if log
3952 * Fixed problem in magic_log: would lock of logging out if log
3947 creation failed (because it would still think it had succeeded).
3953 creation failed (because it would still think it had succeeded).
3948
3954
3949 * Improved the page() function using curses to auto-detect screen
3955 * Improved the page() function using curses to auto-detect screen
3950 size. Now it can make a much better decision on whether to print
3956 size. Now it can make a much better decision on whether to print
3951 or page a string. Option screen_length was modified: a value 0
3957 or page a string. Option screen_length was modified: a value 0
3952 means auto-detect, and that's the default now.
3958 means auto-detect, and that's the default now.
3953
3959
3954 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
3960 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
3955 go out. I'll test it for a few days, then talk to Janko about
3961 go out. I'll test it for a few days, then talk to Janko about
3956 licences and announce it.
3962 licences and announce it.
3957
3963
3958 * Fixed the length of the auto-generated ---> prompt which appears
3964 * Fixed the length of the auto-generated ---> prompt which appears
3959 for auto-parens and auto-quotes. Getting this right isn't trivial,
3965 for auto-parens and auto-quotes. Getting this right isn't trivial,
3960 with all the color escapes, different prompt types and optional
3966 with all the color escapes, different prompt types and optional
3961 separators. But it seems to be working in all the combinations.
3967 separators. But it seems to be working in all the combinations.
3962
3968
3963 2001-11-26 Fernando Perez <fperez@colorado.edu>
3969 2001-11-26 Fernando Perez <fperez@colorado.edu>
3964
3970
3965 * Wrote a regexp filter to get option types from the option names
3971 * Wrote a regexp filter to get option types from the option names
3966 string. This eliminates the need to manually keep two duplicate
3972 string. This eliminates the need to manually keep two duplicate
3967 lists.
3973 lists.
3968
3974
3969 * Removed the unneeded check_option_names. Now options are handled
3975 * Removed the unneeded check_option_names. Now options are handled
3970 in a much saner manner and it's easy to visually check that things
3976 in a much saner manner and it's easy to visually check that things
3971 are ok.
3977 are ok.
3972
3978
3973 * Updated version numbers on all files I modified to carry a
3979 * Updated version numbers on all files I modified to carry a
3974 notice so Janko and Nathan have clear version markers.
3980 notice so Janko and Nathan have clear version markers.
3975
3981
3976 * Updated docstring for ultraTB with my changes. I should send
3982 * Updated docstring for ultraTB with my changes. I should send
3977 this to Nathan.
3983 this to Nathan.
3978
3984
3979 * Lots of small fixes. Ran everything through pychecker again.
3985 * Lots of small fixes. Ran everything through pychecker again.
3980
3986
3981 * Made loading of deep_reload an cmd line option. If it's not too
3987 * Made loading of deep_reload an cmd line option. If it's not too
3982 kosher, now people can just disable it. With -nodeep_reload it's
3988 kosher, now people can just disable it. With -nodeep_reload it's
3983 still available as dreload(), it just won't overwrite reload().
3989 still available as dreload(), it just won't overwrite reload().
3984
3990
3985 * Moved many options to the no| form (-opt and -noopt
3991 * Moved many options to the no| form (-opt and -noopt
3986 accepted). Cleaner.
3992 accepted). Cleaner.
3987
3993
3988 * Changed magic_log so that if called with no parameters, it uses
3994 * Changed magic_log so that if called with no parameters, it uses
3989 'rotate' mode. That way auto-generated logs aren't automatically
3995 'rotate' mode. That way auto-generated logs aren't automatically
3990 over-written. For normal logs, now a backup is made if it exists
3996 over-written. For normal logs, now a backup is made if it exists
3991 (only 1 level of backups). A new 'backup' mode was added to the
3997 (only 1 level of backups). A new 'backup' mode was added to the
3992 Logger class to support this. This was a request by Janko.
3998 Logger class to support this. This was a request by Janko.
3993
3999
3994 * Added @logoff/@logon to stop/restart an active log.
4000 * Added @logoff/@logon to stop/restart an active log.
3995
4001
3996 * Fixed a lot of bugs in log saving/replay. It was pretty
4002 * Fixed a lot of bugs in log saving/replay. It was pretty
3997 broken. Now special lines (!@,/) appear properly in the command
4003 broken. Now special lines (!@,/) appear properly in the command
3998 history after a log replay.
4004 history after a log replay.
3999
4005
4000 * Tried and failed to implement full session saving via pickle. My
4006 * Tried and failed to implement full session saving via pickle. My
4001 idea was to pickle __main__.__dict__, but modules can't be
4007 idea was to pickle __main__.__dict__, but modules can't be
4002 pickled. This would be a better alternative to replaying logs, but
4008 pickled. This would be a better alternative to replaying logs, but
4003 seems quite tricky to get to work. Changed -session to be called
4009 seems quite tricky to get to work. Changed -session to be called
4004 -logplay, which more accurately reflects what it does. And if we
4010 -logplay, which more accurately reflects what it does. And if we
4005 ever get real session saving working, -session is now available.
4011 ever get real session saving working, -session is now available.
4006
4012
4007 * Implemented color schemes for prompts also. As for tracebacks,
4013 * Implemented color schemes for prompts also. As for tracebacks,
4008 currently only NoColor and Linux are supported. But now the
4014 currently only NoColor and Linux are supported. But now the
4009 infrastructure is in place, based on a generic ColorScheme
4015 infrastructure is in place, based on a generic ColorScheme
4010 class. So writing and activating new schemes both for the prompts
4016 class. So writing and activating new schemes both for the prompts
4011 and the tracebacks should be straightforward.
4017 and the tracebacks should be straightforward.
4012
4018
4013 * Version 0.1.13 released, 0.1.14 opened.
4019 * Version 0.1.13 released, 0.1.14 opened.
4014
4020
4015 * Changed handling of options for output cache. Now counter is
4021 * Changed handling of options for output cache. Now counter is
4016 hardwired starting at 1 and one specifies the maximum number of
4022 hardwired starting at 1 and one specifies the maximum number of
4017 entries *in the outcache* (not the max prompt counter). This is
4023 entries *in the outcache* (not the max prompt counter). This is
4018 much better, since many statements won't increase the cache
4024 much better, since many statements won't increase the cache
4019 count. It also eliminated some confusing options, now there's only
4025 count. It also eliminated some confusing options, now there's only
4020 one: cache_size.
4026 one: cache_size.
4021
4027
4022 * Added 'alias' magic function and magic_alias option in the
4028 * Added 'alias' magic function and magic_alias option in the
4023 ipythonrc file. Now the user can easily define whatever names he
4029 ipythonrc file. Now the user can easily define whatever names he
4024 wants for the magic functions without having to play weird
4030 wants for the magic functions without having to play weird
4025 namespace games. This gives IPython a real shell-like feel.
4031 namespace games. This gives IPython a real shell-like feel.
4026
4032
4027 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
4033 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
4028 @ or not).
4034 @ or not).
4029
4035
4030 This was one of the last remaining 'visible' bugs (that I know
4036 This was one of the last remaining 'visible' bugs (that I know
4031 of). I think if I can clean up the session loading so it works
4037 of). I think if I can clean up the session loading so it works
4032 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
4038 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
4033 about licensing).
4039 about licensing).
4034
4040
4035 2001-11-25 Fernando Perez <fperez@colorado.edu>
4041 2001-11-25 Fernando Perez <fperez@colorado.edu>
4036
4042
4037 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
4043 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
4038 there's a cleaner distinction between what ? and ?? show.
4044 there's a cleaner distinction between what ? and ?? show.
4039
4045
4040 * Added screen_length option. Now the user can define his own
4046 * Added screen_length option. Now the user can define his own
4041 screen size for page() operations.
4047 screen size for page() operations.
4042
4048
4043 * Implemented magic shell-like functions with automatic code
4049 * Implemented magic shell-like functions with automatic code
4044 generation. Now adding another function is just a matter of adding
4050 generation. Now adding another function is just a matter of adding
4045 an entry to a dict, and the function is dynamically generated at
4051 an entry to a dict, and the function is dynamically generated at
4046 run-time. Python has some really cool features!
4052 run-time. Python has some really cool features!
4047
4053
4048 * Renamed many options to cleanup conventions a little. Now all
4054 * Renamed many options to cleanup conventions a little. Now all
4049 are lowercase, and only underscores where needed. Also in the code
4055 are lowercase, and only underscores where needed. Also in the code
4050 option name tables are clearer.
4056 option name tables are clearer.
4051
4057
4052 * Changed prompts a little. Now input is 'In [n]:' instead of
4058 * Changed prompts a little. Now input is 'In [n]:' instead of
4053 'In[n]:='. This allows it the numbers to be aligned with the
4059 'In[n]:='. This allows it the numbers to be aligned with the
4054 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4060 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4055 Python (it was a Mathematica thing). The '...' continuation prompt
4061 Python (it was a Mathematica thing). The '...' continuation prompt
4056 was also changed a little to align better.
4062 was also changed a little to align better.
4057
4063
4058 * Fixed bug when flushing output cache. Not all _p<n> variables
4064 * Fixed bug when flushing output cache. Not all _p<n> variables
4059 exist, so their deletion needs to be wrapped in a try:
4065 exist, so their deletion needs to be wrapped in a try:
4060
4066
4061 * Figured out how to properly use inspect.formatargspec() (it
4067 * Figured out how to properly use inspect.formatargspec() (it
4062 requires the args preceded by *). So I removed all the code from
4068 requires the args preceded by *). So I removed all the code from
4063 _get_pdef in Magic, which was just replicating that.
4069 _get_pdef in Magic, which was just replicating that.
4064
4070
4065 * Added test to prefilter to allow redefining magic function names
4071 * Added test to prefilter to allow redefining magic function names
4066 as variables. This is ok, since the @ form is always available,
4072 as variables. This is ok, since the @ form is always available,
4067 but whe should allow the user to define a variable called 'ls' if
4073 but whe should allow the user to define a variable called 'ls' if
4068 he needs it.
4074 he needs it.
4069
4075
4070 * Moved the ToDo information from README into a separate ToDo.
4076 * Moved the ToDo information from README into a separate ToDo.
4071
4077
4072 * General code cleanup and small bugfixes. I think it's close to a
4078 * General code cleanup and small bugfixes. I think it's close to a
4073 state where it can be released, obviously with a big 'beta'
4079 state where it can be released, obviously with a big 'beta'
4074 warning on it.
4080 warning on it.
4075
4081
4076 * Got the magic function split to work. Now all magics are defined
4082 * Got the magic function split to work. Now all magics are defined
4077 in a separate class. It just organizes things a bit, and now
4083 in a separate class. It just organizes things a bit, and now
4078 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4084 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4079 was too long).
4085 was too long).
4080
4086
4081 * Changed @clear to @reset to avoid potential confusions with
4087 * Changed @clear to @reset to avoid potential confusions with
4082 the shell command clear. Also renamed @cl to @clear, which does
4088 the shell command clear. Also renamed @cl to @clear, which does
4083 exactly what people expect it to from their shell experience.
4089 exactly what people expect it to from their shell experience.
4084
4090
4085 Added a check to the @reset command (since it's so
4091 Added a check to the @reset command (since it's so
4086 destructive, it's probably a good idea to ask for confirmation).
4092 destructive, it's probably a good idea to ask for confirmation).
4087 But now reset only works for full namespace resetting. Since the
4093 But now reset only works for full namespace resetting. Since the
4088 del keyword is already there for deleting a few specific
4094 del keyword is already there for deleting a few specific
4089 variables, I don't see the point of having a redundant magic
4095 variables, I don't see the point of having a redundant magic
4090 function for the same task.
4096 function for the same task.
4091
4097
4092 2001-11-24 Fernando Perez <fperez@colorado.edu>
4098 2001-11-24 Fernando Perez <fperez@colorado.edu>
4093
4099
4094 * Updated the builtin docs (esp. the ? ones).
4100 * Updated the builtin docs (esp. the ? ones).
4095
4101
4096 * Ran all the code through pychecker. Not terribly impressed with
4102 * Ran all the code through pychecker. Not terribly impressed with
4097 it: lots of spurious warnings and didn't really find anything of
4103 it: lots of spurious warnings and didn't really find anything of
4098 substance (just a few modules being imported and not used).
4104 substance (just a few modules being imported and not used).
4099
4105
4100 * Implemented the new ultraTB functionality into IPython. New
4106 * Implemented the new ultraTB functionality into IPython. New
4101 option: xcolors. This chooses color scheme. xmode now only selects
4107 option: xcolors. This chooses color scheme. xmode now only selects
4102 between Plain and Verbose. Better orthogonality.
4108 between Plain and Verbose. Better orthogonality.
4103
4109
4104 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4110 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4105 mode and color scheme for the exception handlers. Now it's
4111 mode and color scheme for the exception handlers. Now it's
4106 possible to have the verbose traceback with no coloring.
4112 possible to have the verbose traceback with no coloring.
4107
4113
4108 2001-11-23 Fernando Perez <fperez@colorado.edu>
4114 2001-11-23 Fernando Perez <fperez@colorado.edu>
4109
4115
4110 * Version 0.1.12 released, 0.1.13 opened.
4116 * Version 0.1.12 released, 0.1.13 opened.
4111
4117
4112 * Removed option to set auto-quote and auto-paren escapes by
4118 * Removed option to set auto-quote and auto-paren escapes by
4113 user. The chances of breaking valid syntax are just too high. If
4119 user. The chances of breaking valid syntax are just too high. If
4114 someone *really* wants, they can always dig into the code.
4120 someone *really* wants, they can always dig into the code.
4115
4121
4116 * Made prompt separators configurable.
4122 * Made prompt separators configurable.
4117
4123
4118 2001-11-22 Fernando Perez <fperez@colorado.edu>
4124 2001-11-22 Fernando Perez <fperez@colorado.edu>
4119
4125
4120 * Small bugfixes in many places.
4126 * Small bugfixes in many places.
4121
4127
4122 * Removed the MyCompleter class from ipplib. It seemed redundant
4128 * Removed the MyCompleter class from ipplib. It seemed redundant
4123 with the C-p,C-n history search functionality. Less code to
4129 with the C-p,C-n history search functionality. Less code to
4124 maintain.
4130 maintain.
4125
4131
4126 * Moved all the original ipython.py code into ipythonlib.py. Right
4132 * Moved all the original ipython.py code into ipythonlib.py. Right
4127 now it's just one big dump into a function called make_IPython, so
4133 now it's just one big dump into a function called make_IPython, so
4128 no real modularity has been gained. But at least it makes the
4134 no real modularity has been gained. But at least it makes the
4129 wrapper script tiny, and since ipythonlib is a module, it gets
4135 wrapper script tiny, and since ipythonlib is a module, it gets
4130 compiled and startup is much faster.
4136 compiled and startup is much faster.
4131
4137
4132 This is a reasobably 'deep' change, so we should test it for a
4138 This is a reasobably 'deep' change, so we should test it for a
4133 while without messing too much more with the code.
4139 while without messing too much more with the code.
4134
4140
4135 2001-11-21 Fernando Perez <fperez@colorado.edu>
4141 2001-11-21 Fernando Perez <fperez@colorado.edu>
4136
4142
4137 * Version 0.1.11 released, 0.1.12 opened for further work.
4143 * Version 0.1.11 released, 0.1.12 opened for further work.
4138
4144
4139 * Removed dependency on Itpl. It was only needed in one place. It
4145 * Removed dependency on Itpl. It was only needed in one place. It
4140 would be nice if this became part of python, though. It makes life
4146 would be nice if this became part of python, though. It makes life
4141 *a lot* easier in some cases.
4147 *a lot* easier in some cases.
4142
4148
4143 * Simplified the prefilter code a bit. Now all handlers are
4149 * Simplified the prefilter code a bit. Now all handlers are
4144 expected to explicitly return a value (at least a blank string).
4150 expected to explicitly return a value (at least a blank string).
4145
4151
4146 * Heavy edits in ipplib. Removed the help system altogether. Now
4152 * Heavy edits in ipplib. Removed the help system altogether. Now
4147 obj?/?? is used for inspecting objects, a magic @doc prints
4153 obj?/?? is used for inspecting objects, a magic @doc prints
4148 docstrings, and full-blown Python help is accessed via the 'help'
4154 docstrings, and full-blown Python help is accessed via the 'help'
4149 keyword. This cleans up a lot of code (less to maintain) and does
4155 keyword. This cleans up a lot of code (less to maintain) and does
4150 the job. Since 'help' is now a standard Python component, might as
4156 the job. Since 'help' is now a standard Python component, might as
4151 well use it and remove duplicate functionality.
4157 well use it and remove duplicate functionality.
4152
4158
4153 Also removed the option to use ipplib as a standalone program. By
4159 Also removed the option to use ipplib as a standalone program. By
4154 now it's too dependent on other parts of IPython to function alone.
4160 now it's too dependent on other parts of IPython to function alone.
4155
4161
4156 * Fixed bug in genutils.pager. It would crash if the pager was
4162 * Fixed bug in genutils.pager. It would crash if the pager was
4157 exited immediately after opening (broken pipe).
4163 exited immediately after opening (broken pipe).
4158
4164
4159 * Trimmed down the VerboseTB reporting a little. The header is
4165 * Trimmed down the VerboseTB reporting a little. The header is
4160 much shorter now and the repeated exception arguments at the end
4166 much shorter now and the repeated exception arguments at the end
4161 have been removed. For interactive use the old header seemed a bit
4167 have been removed. For interactive use the old header seemed a bit
4162 excessive.
4168 excessive.
4163
4169
4164 * Fixed small bug in output of @whos for variables with multi-word
4170 * Fixed small bug in output of @whos for variables with multi-word
4165 types (only first word was displayed).
4171 types (only first word was displayed).
4166
4172
4167 2001-11-17 Fernando Perez <fperez@colorado.edu>
4173 2001-11-17 Fernando Perez <fperez@colorado.edu>
4168
4174
4169 * Version 0.1.10 released, 0.1.11 opened for further work.
4175 * Version 0.1.10 released, 0.1.11 opened for further work.
4170
4176
4171 * Modified dirs and friends. dirs now *returns* the stack (not
4177 * Modified dirs and friends. dirs now *returns* the stack (not
4172 prints), so one can manipulate it as a variable. Convenient to
4178 prints), so one can manipulate it as a variable. Convenient to
4173 travel along many directories.
4179 travel along many directories.
4174
4180
4175 * Fixed bug in magic_pdef: would only work with functions with
4181 * Fixed bug in magic_pdef: would only work with functions with
4176 arguments with default values.
4182 arguments with default values.
4177
4183
4178 2001-11-14 Fernando Perez <fperez@colorado.edu>
4184 2001-11-14 Fernando Perez <fperez@colorado.edu>
4179
4185
4180 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4186 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4181 example with IPython. Various other minor fixes and cleanups.
4187 example with IPython. Various other minor fixes and cleanups.
4182
4188
4183 * Version 0.1.9 released, 0.1.10 opened for further work.
4189 * Version 0.1.9 released, 0.1.10 opened for further work.
4184
4190
4185 * Added sys.path to the list of directories searched in the
4191 * Added sys.path to the list of directories searched in the
4186 execfile= option. It used to be the current directory and the
4192 execfile= option. It used to be the current directory and the
4187 user's IPYTHONDIR only.
4193 user's IPYTHONDIR only.
4188
4194
4189 2001-11-13 Fernando Perez <fperez@colorado.edu>
4195 2001-11-13 Fernando Perez <fperez@colorado.edu>
4190
4196
4191 * Reinstated the raw_input/prefilter separation that Janko had
4197 * Reinstated the raw_input/prefilter separation that Janko had
4192 initially. This gives a more convenient setup for extending the
4198 initially. This gives a more convenient setup for extending the
4193 pre-processor from the outside: raw_input always gets a string,
4199 pre-processor from the outside: raw_input always gets a string,
4194 and prefilter has to process it. We can then redefine prefilter
4200 and prefilter has to process it. We can then redefine prefilter
4195 from the outside and implement extensions for special
4201 from the outside and implement extensions for special
4196 purposes.
4202 purposes.
4197
4203
4198 Today I got one for inputting PhysicalQuantity objects
4204 Today I got one for inputting PhysicalQuantity objects
4199 (from Scientific) without needing any function calls at
4205 (from Scientific) without needing any function calls at
4200 all. Extremely convenient, and it's all done as a user-level
4206 all. Extremely convenient, and it's all done as a user-level
4201 extension (no IPython code was touched). Now instead of:
4207 extension (no IPython code was touched). Now instead of:
4202 a = PhysicalQuantity(4.2,'m/s**2')
4208 a = PhysicalQuantity(4.2,'m/s**2')
4203 one can simply say
4209 one can simply say
4204 a = 4.2 m/s**2
4210 a = 4.2 m/s**2
4205 or even
4211 or even
4206 a = 4.2 m/s^2
4212 a = 4.2 m/s^2
4207
4213
4208 I use this, but it's also a proof of concept: IPython really is
4214 I use this, but it's also a proof of concept: IPython really is
4209 fully user-extensible, even at the level of the parsing of the
4215 fully user-extensible, even at the level of the parsing of the
4210 command line. It's not trivial, but it's perfectly doable.
4216 command line. It's not trivial, but it's perfectly doable.
4211
4217
4212 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4218 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4213 the problem of modules being loaded in the inverse order in which
4219 the problem of modules being loaded in the inverse order in which
4214 they were defined in
4220 they were defined in
4215
4221
4216 * Version 0.1.8 released, 0.1.9 opened for further work.
4222 * Version 0.1.8 released, 0.1.9 opened for further work.
4217
4223
4218 * Added magics pdef, source and file. They respectively show the
4224 * Added magics pdef, source and file. They respectively show the
4219 definition line ('prototype' in C), source code and full python
4225 definition line ('prototype' in C), source code and full python
4220 file for any callable object. The object inspector oinfo uses
4226 file for any callable object. The object inspector oinfo uses
4221 these to show the same information.
4227 these to show the same information.
4222
4228
4223 * Version 0.1.7 released, 0.1.8 opened for further work.
4229 * Version 0.1.7 released, 0.1.8 opened for further work.
4224
4230
4225 * Separated all the magic functions into a class called Magic. The
4231 * Separated all the magic functions into a class called Magic. The
4226 InteractiveShell class was becoming too big for Xemacs to handle
4232 InteractiveShell class was becoming too big for Xemacs to handle
4227 (de-indenting a line would lock it up for 10 seconds while it
4233 (de-indenting a line would lock it up for 10 seconds while it
4228 backtracked on the whole class!)
4234 backtracked on the whole class!)
4229
4235
4230 FIXME: didn't work. It can be done, but right now namespaces are
4236 FIXME: didn't work. It can be done, but right now namespaces are
4231 all messed up. Do it later (reverted it for now, so at least
4237 all messed up. Do it later (reverted it for now, so at least
4232 everything works as before).
4238 everything works as before).
4233
4239
4234 * Got the object introspection system (magic_oinfo) working! I
4240 * Got the object introspection system (magic_oinfo) working! I
4235 think this is pretty much ready for release to Janko, so he can
4241 think this is pretty much ready for release to Janko, so he can
4236 test it for a while and then announce it. Pretty much 100% of what
4242 test it for a while and then announce it. Pretty much 100% of what
4237 I wanted for the 'phase 1' release is ready. Happy, tired.
4243 I wanted for the 'phase 1' release is ready. Happy, tired.
4238
4244
4239 2001-11-12 Fernando Perez <fperez@colorado.edu>
4245 2001-11-12 Fernando Perez <fperez@colorado.edu>
4240
4246
4241 * Version 0.1.6 released, 0.1.7 opened for further work.
4247 * Version 0.1.6 released, 0.1.7 opened for further work.
4242
4248
4243 * Fixed bug in printing: it used to test for truth before
4249 * Fixed bug in printing: it used to test for truth before
4244 printing, so 0 wouldn't print. Now checks for None.
4250 printing, so 0 wouldn't print. Now checks for None.
4245
4251
4246 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4252 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4247 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4253 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4248 reaches by hand into the outputcache. Think of a better way to do
4254 reaches by hand into the outputcache. Think of a better way to do
4249 this later.
4255 this later.
4250
4256
4251 * Various small fixes thanks to Nathan's comments.
4257 * Various small fixes thanks to Nathan's comments.
4252
4258
4253 * Changed magic_pprint to magic_Pprint. This way it doesn't
4259 * Changed magic_pprint to magic_Pprint. This way it doesn't
4254 collide with pprint() and the name is consistent with the command
4260 collide with pprint() and the name is consistent with the command
4255 line option.
4261 line option.
4256
4262
4257 * Changed prompt counter behavior to be fully like
4263 * Changed prompt counter behavior to be fully like
4258 Mathematica's. That is, even input that doesn't return a result
4264 Mathematica's. That is, even input that doesn't return a result
4259 raises the prompt counter. The old behavior was kind of confusing
4265 raises the prompt counter. The old behavior was kind of confusing
4260 (getting the same prompt number several times if the operation
4266 (getting the same prompt number several times if the operation
4261 didn't return a result).
4267 didn't return a result).
4262
4268
4263 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4269 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4264
4270
4265 * Fixed -Classic mode (wasn't working anymore).
4271 * Fixed -Classic mode (wasn't working anymore).
4266
4272
4267 * Added colored prompts using Nathan's new code. Colors are
4273 * Added colored prompts using Nathan's new code. Colors are
4268 currently hardwired, they can be user-configurable. For
4274 currently hardwired, they can be user-configurable. For
4269 developers, they can be chosen in file ipythonlib.py, at the
4275 developers, they can be chosen in file ipythonlib.py, at the
4270 beginning of the CachedOutput class def.
4276 beginning of the CachedOutput class def.
4271
4277
4272 2001-11-11 Fernando Perez <fperez@colorado.edu>
4278 2001-11-11 Fernando Perez <fperez@colorado.edu>
4273
4279
4274 * Version 0.1.5 released, 0.1.6 opened for further work.
4280 * Version 0.1.5 released, 0.1.6 opened for further work.
4275
4281
4276 * Changed magic_env to *return* the environment as a dict (not to
4282 * Changed magic_env to *return* the environment as a dict (not to
4277 print it). This way it prints, but it can also be processed.
4283 print it). This way it prints, but it can also be processed.
4278
4284
4279 * Added Verbose exception reporting to interactive
4285 * Added Verbose exception reporting to interactive
4280 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4286 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4281 traceback. Had to make some changes to the ultraTB file. This is
4287 traceback. Had to make some changes to the ultraTB file. This is
4282 probably the last 'big' thing in my mental todo list. This ties
4288 probably the last 'big' thing in my mental todo list. This ties
4283 in with the next entry:
4289 in with the next entry:
4284
4290
4285 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4291 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4286 has to specify is Plain, Color or Verbose for all exception
4292 has to specify is Plain, Color or Verbose for all exception
4287 handling.
4293 handling.
4288
4294
4289 * Removed ShellServices option. All this can really be done via
4295 * Removed ShellServices option. All this can really be done via
4290 the magic system. It's easier to extend, cleaner and has automatic
4296 the magic system. It's easier to extend, cleaner and has automatic
4291 namespace protection and documentation.
4297 namespace protection and documentation.
4292
4298
4293 2001-11-09 Fernando Perez <fperez@colorado.edu>
4299 2001-11-09 Fernando Perez <fperez@colorado.edu>
4294
4300
4295 * Fixed bug in output cache flushing (missing parameter to
4301 * Fixed bug in output cache flushing (missing parameter to
4296 __init__). Other small bugs fixed (found using pychecker).
4302 __init__). Other small bugs fixed (found using pychecker).
4297
4303
4298 * Version 0.1.4 opened for bugfixing.
4304 * Version 0.1.4 opened for bugfixing.
4299
4305
4300 2001-11-07 Fernando Perez <fperez@colorado.edu>
4306 2001-11-07 Fernando Perez <fperez@colorado.edu>
4301
4307
4302 * Version 0.1.3 released, mainly because of the raw_input bug.
4308 * Version 0.1.3 released, mainly because of the raw_input bug.
4303
4309
4304 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4310 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4305 and when testing for whether things were callable, a call could
4311 and when testing for whether things were callable, a call could
4306 actually be made to certain functions. They would get called again
4312 actually be made to certain functions. They would get called again
4307 once 'really' executed, with a resulting double call. A disaster
4313 once 'really' executed, with a resulting double call. A disaster
4308 in many cases (list.reverse() would never work!).
4314 in many cases (list.reverse() would never work!).
4309
4315
4310 * Removed prefilter() function, moved its code to raw_input (which
4316 * Removed prefilter() function, moved its code to raw_input (which
4311 after all was just a near-empty caller for prefilter). This saves
4317 after all was just a near-empty caller for prefilter). This saves
4312 a function call on every prompt, and simplifies the class a tiny bit.
4318 a function call on every prompt, and simplifies the class a tiny bit.
4313
4319
4314 * Fix _ip to __ip name in magic example file.
4320 * Fix _ip to __ip name in magic example file.
4315
4321
4316 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4322 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4317 work with non-gnu versions of tar.
4323 work with non-gnu versions of tar.
4318
4324
4319 2001-11-06 Fernando Perez <fperez@colorado.edu>
4325 2001-11-06 Fernando Perez <fperez@colorado.edu>
4320
4326
4321 * Version 0.1.2. Just to keep track of the recent changes.
4327 * Version 0.1.2. Just to keep track of the recent changes.
4322
4328
4323 * Fixed nasty bug in output prompt routine. It used to check 'if
4329 * Fixed nasty bug in output prompt routine. It used to check 'if
4324 arg != None...'. Problem is, this fails if arg implements a
4330 arg != None...'. Problem is, this fails if arg implements a
4325 special comparison (__cmp__) which disallows comparing to
4331 special comparison (__cmp__) which disallows comparing to
4326 None. Found it when trying to use the PhysicalQuantity module from
4332 None. Found it when trying to use the PhysicalQuantity module from
4327 ScientificPython.
4333 ScientificPython.
4328
4334
4329 2001-11-05 Fernando Perez <fperez@colorado.edu>
4335 2001-11-05 Fernando Perez <fperez@colorado.edu>
4330
4336
4331 * Also added dirs. Now the pushd/popd/dirs family functions
4337 * Also added dirs. Now the pushd/popd/dirs family functions
4332 basically like the shell, with the added convenience of going home
4338 basically like the shell, with the added convenience of going home
4333 when called with no args.
4339 when called with no args.
4334
4340
4335 * pushd/popd slightly modified to mimic shell behavior more
4341 * pushd/popd slightly modified to mimic shell behavior more
4336 closely.
4342 closely.
4337
4343
4338 * Added env,pushd,popd from ShellServices as magic functions. I
4344 * Added env,pushd,popd from ShellServices as magic functions. I
4339 think the cleanest will be to port all desired functions from
4345 think the cleanest will be to port all desired functions from
4340 ShellServices as magics and remove ShellServices altogether. This
4346 ShellServices as magics and remove ShellServices altogether. This
4341 will provide a single, clean way of adding functionality
4347 will provide a single, clean way of adding functionality
4342 (shell-type or otherwise) to IP.
4348 (shell-type or otherwise) to IP.
4343
4349
4344 2001-11-04 Fernando Perez <fperez@colorado.edu>
4350 2001-11-04 Fernando Perez <fperez@colorado.edu>
4345
4351
4346 * Added .ipython/ directory to sys.path. This way users can keep
4352 * Added .ipython/ directory to sys.path. This way users can keep
4347 customizations there and access them via import.
4353 customizations there and access them via import.
4348
4354
4349 2001-11-03 Fernando Perez <fperez@colorado.edu>
4355 2001-11-03 Fernando Perez <fperez@colorado.edu>
4350
4356
4351 * Opened version 0.1.1 for new changes.
4357 * Opened version 0.1.1 for new changes.
4352
4358
4353 * Changed version number to 0.1.0: first 'public' release, sent to
4359 * Changed version number to 0.1.0: first 'public' release, sent to
4354 Nathan and Janko.
4360 Nathan and Janko.
4355
4361
4356 * Lots of small fixes and tweaks.
4362 * Lots of small fixes and tweaks.
4357
4363
4358 * Minor changes to whos format. Now strings are shown, snipped if
4364 * Minor changes to whos format. Now strings are shown, snipped if
4359 too long.
4365 too long.
4360
4366
4361 * Changed ShellServices to work on __main__ so they show up in @who
4367 * Changed ShellServices to work on __main__ so they show up in @who
4362
4368
4363 * Help also works with ? at the end of a line:
4369 * Help also works with ? at the end of a line:
4364 ?sin and sin?
4370 ?sin and sin?
4365 both produce the same effect. This is nice, as often I use the
4371 both produce the same effect. This is nice, as often I use the
4366 tab-complete to find the name of a method, but I used to then have
4372 tab-complete to find the name of a method, but I used to then have
4367 to go to the beginning of the line to put a ? if I wanted more
4373 to go to the beginning of the line to put a ? if I wanted more
4368 info. Now I can just add the ? and hit return. Convenient.
4374 info. Now I can just add the ? and hit return. Convenient.
4369
4375
4370 2001-11-02 Fernando Perez <fperez@colorado.edu>
4376 2001-11-02 Fernando Perez <fperez@colorado.edu>
4371
4377
4372 * Python version check (>=2.1) added.
4378 * Python version check (>=2.1) added.
4373
4379
4374 * Added LazyPython documentation. At this point the docs are quite
4380 * Added LazyPython documentation. At this point the docs are quite
4375 a mess. A cleanup is in order.
4381 a mess. A cleanup is in order.
4376
4382
4377 * Auto-installer created. For some bizarre reason, the zipfiles
4383 * Auto-installer created. For some bizarre reason, the zipfiles
4378 module isn't working on my system. So I made a tar version
4384 module isn't working on my system. So I made a tar version
4379 (hopefully the command line options in various systems won't kill
4385 (hopefully the command line options in various systems won't kill
4380 me).
4386 me).
4381
4387
4382 * Fixes to Struct in genutils. Now all dictionary-like methods are
4388 * Fixes to Struct in genutils. Now all dictionary-like methods are
4383 protected (reasonably).
4389 protected (reasonably).
4384
4390
4385 * Added pager function to genutils and changed ? to print usage
4391 * Added pager function to genutils and changed ? to print usage
4386 note through it (it was too long).
4392 note through it (it was too long).
4387
4393
4388 * Added the LazyPython functionality. Works great! I changed the
4394 * Added the LazyPython functionality. Works great! I changed the
4389 auto-quote escape to ';', it's on home row and next to '. But
4395 auto-quote escape to ';', it's on home row and next to '. But
4390 both auto-quote and auto-paren (still /) escapes are command-line
4396 both auto-quote and auto-paren (still /) escapes are command-line
4391 parameters.
4397 parameters.
4392
4398
4393
4399
4394 2001-11-01 Fernando Perez <fperez@colorado.edu>
4400 2001-11-01 Fernando Perez <fperez@colorado.edu>
4395
4401
4396 * Version changed to 0.0.7. Fairly large change: configuration now
4402 * Version changed to 0.0.7. Fairly large change: configuration now
4397 is all stored in a directory, by default .ipython. There, all
4403 is all stored in a directory, by default .ipython. There, all
4398 config files have normal looking names (not .names)
4404 config files have normal looking names (not .names)
4399
4405
4400 * Version 0.0.6 Released first to Lucas and Archie as a test
4406 * Version 0.0.6 Released first to Lucas and Archie as a test
4401 run. Since it's the first 'semi-public' release, change version to
4407 run. Since it's the first 'semi-public' release, change version to
4402 > 0.0.6 for any changes now.
4408 > 0.0.6 for any changes now.
4403
4409
4404 * Stuff I had put in the ipplib.py changelog:
4410 * Stuff I had put in the ipplib.py changelog:
4405
4411
4406 Changes to InteractiveShell:
4412 Changes to InteractiveShell:
4407
4413
4408 - Made the usage message a parameter.
4414 - Made the usage message a parameter.
4409
4415
4410 - Require the name of the shell variable to be given. It's a bit
4416 - Require the name of the shell variable to be given. It's a bit
4411 of a hack, but allows the name 'shell' not to be hardwire in the
4417 of a hack, but allows the name 'shell' not to be hardwire in the
4412 magic (@) handler, which is problematic b/c it requires
4418 magic (@) handler, which is problematic b/c it requires
4413 polluting the global namespace with 'shell'. This in turn is
4419 polluting the global namespace with 'shell'. This in turn is
4414 fragile: if a user redefines a variable called shell, things
4420 fragile: if a user redefines a variable called shell, things
4415 break.
4421 break.
4416
4422
4417 - magic @: all functions available through @ need to be defined
4423 - magic @: all functions available through @ need to be defined
4418 as magic_<name>, even though they can be called simply as
4424 as magic_<name>, even though they can be called simply as
4419 @<name>. This allows the special command @magic to gather
4425 @<name>. This allows the special command @magic to gather
4420 information automatically about all existing magic functions,
4426 information automatically about all existing magic functions,
4421 even if they are run-time user extensions, by parsing the shell
4427 even if they are run-time user extensions, by parsing the shell
4422 instance __dict__ looking for special magic_ names.
4428 instance __dict__ looking for special magic_ names.
4423
4429
4424 - mainloop: added *two* local namespace parameters. This allows
4430 - mainloop: added *two* local namespace parameters. This allows
4425 the class to differentiate between parameters which were there
4431 the class to differentiate between parameters which were there
4426 before and after command line initialization was processed. This
4432 before and after command line initialization was processed. This
4427 way, later @who can show things loaded at startup by the
4433 way, later @who can show things loaded at startup by the
4428 user. This trick was necessary to make session saving/reloading
4434 user. This trick was necessary to make session saving/reloading
4429 really work: ideally after saving/exiting/reloading a session,
4435 really work: ideally after saving/exiting/reloading a session,
4430 *everythin* should look the same, including the output of @who. I
4436 *everythin* should look the same, including the output of @who. I
4431 was only able to make this work with this double namespace
4437 was only able to make this work with this double namespace
4432 trick.
4438 trick.
4433
4439
4434 - added a header to the logfile which allows (almost) full
4440 - added a header to the logfile which allows (almost) full
4435 session restoring.
4441 session restoring.
4436
4442
4437 - prepend lines beginning with @ or !, with a and log
4443 - prepend lines beginning with @ or !, with a and log
4438 them. Why? !lines: may be useful to know what you did @lines:
4444 them. Why? !lines: may be useful to know what you did @lines:
4439 they may affect session state. So when restoring a session, at
4445 they may affect session state. So when restoring a session, at
4440 least inform the user of their presence. I couldn't quite get
4446 least inform the user of their presence. I couldn't quite get
4441 them to properly re-execute, but at least the user is warned.
4447 them to properly re-execute, but at least the user is warned.
4442
4448
4443 * Started ChangeLog.
4449 * Started ChangeLog.
General Comments 0
You need to be logged in to leave comments. Login now