##// END OF EJS Templates
Ready for 0.7.0 release!...
fperez -
Show More
@@ -1,2736 +1,2741 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 994 2006-01-08 08:29:44Z fperez $"""
4 $Id: Magic.py 1000 2006-01-10 08:06:04Z fperez $"""
5
5
6 #*****************************************************************************
6 #*****************************************************************************
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
8 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
8 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
9 #
9 #
10 # Distributed under the terms of the BSD License. The full license is in
10 # Distributed under the terms of the BSD License. The full license is in
11 # the file COPYING, distributed as part of this software.
11 # the file COPYING, distributed as part of this software.
12 #*****************************************************************************
12 #*****************************************************************************
13
13
14 #****************************************************************************
14 #****************************************************************************
15 # Modules and globals
15 # Modules and globals
16
16
17 from IPython import Release
17 from IPython import Release
18 __author__ = '%s <%s>\n%s <%s>' % \
18 __author__ = '%s <%s>\n%s <%s>' % \
19 ( Release.authors['Janko'] + Release.authors['Fernando'] )
19 ( Release.authors['Janko'] + Release.authors['Fernando'] )
20 __license__ = Release.license
20 __license__ = Release.license
21
21
22 # Python standard modules
22 # Python standard modules
23 import __builtin__
23 import __builtin__
24 import bdb
24 import bdb
25 import inspect
25 import inspect
26 import os
26 import os
27 import pdb
27 import pdb
28 import pydoc
28 import pydoc
29 import sys
29 import sys
30 import re
30 import re
31 import tempfile
31 import tempfile
32 import time
32 import time
33 import cPickle as pickle
33 import cPickle as pickle
34 from cStringIO import StringIO
34 from cStringIO import StringIO
35 from getopt import getopt
35 from getopt import getopt
36 from pprint import pprint, pformat
36 from pprint import pprint, pformat
37
37
38 # profile isn't bundled by default in Debian for license reasons
38 # profile isn't bundled by default in Debian for license reasons
39 try:
39 try:
40 import profile,pstats
40 import profile,pstats
41 except ImportError:
41 except ImportError:
42 profile = pstats = None
42 profile = pstats = None
43
43
44 # Homebrewed
44 # Homebrewed
45 from IPython import Debugger, OInspect, wildcard
45 from IPython import Debugger, OInspect, wildcard
46 from IPython.FakeModule import FakeModule
46 from IPython.FakeModule import FakeModule
47 from IPython.Itpl import Itpl, itpl, printpl,itplns
47 from IPython.Itpl import Itpl, itpl, printpl,itplns
48 from IPython.PyColorize import Parser
48 from IPython.PyColorize import Parser
49 from IPython.Struct import Struct
49 from IPython.Struct import Struct
50 from IPython.macro import Macro
50 from IPython.macro import Macro
51 from IPython.genutils import *
51 from IPython.genutils import *
52
52
53 #***************************************************************************
53 #***************************************************************************
54 # Utility functions
54 # Utility functions
55 def on_off(tag):
55 def on_off(tag):
56 """Return an ON/OFF string for a 1/0 input. Simple utility function."""
56 """Return an ON/OFF string for a 1/0 input. Simple utility function."""
57 return ['OFF','ON'][tag]
57 return ['OFF','ON'][tag]
58
58
59 class Bunch: pass
59 class Bunch: pass
60
60
61 #***************************************************************************
61 #***************************************************************************
62 # Main class implementing Magic functionality
62 # Main class implementing Magic functionality
63 class Magic:
63 class Magic:
64 """Magic functions for InteractiveShell.
64 """Magic functions for InteractiveShell.
65
65
66 Shell functions which can be reached as %function_name. All magic
66 Shell functions which can be reached as %function_name. All magic
67 functions should accept a string, which they can parse for their own
67 functions should accept a string, which they can parse for their own
68 needs. This can make some functions easier to type, eg `%cd ../`
68 needs. This can make some functions easier to type, eg `%cd ../`
69 vs. `%cd("../")`
69 vs. `%cd("../")`
70
70
71 ALL definitions MUST begin with the prefix magic_. The user won't need it
71 ALL definitions MUST begin with the prefix magic_. The user won't need it
72 at the command line, but it is is needed in the definition. """
72 at the command line, but it is is needed in the definition. """
73
73
74 # class globals
74 # class globals
75 auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.',
75 auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.',
76 'Automagic is ON, % prefix NOT needed for magic functions.']
76 'Automagic is ON, % prefix NOT needed for magic functions.']
77
77
78 #......................................................................
78 #......................................................................
79 # some utility functions
79 # some utility functions
80
80
81 def __init__(self,shell):
81 def __init__(self,shell):
82
82
83 self.options_table = {}
83 self.options_table = {}
84 if profile is None:
84 if profile is None:
85 self.magic_prun = self.profile_missing_notice
85 self.magic_prun = self.profile_missing_notice
86 self.shell = shell
86 self.shell = shell
87
87
88 # namespace for holding state we may need
88 # namespace for holding state we may need
89 self._magic_state = Bunch()
89 self._magic_state = Bunch()
90
90
91 def profile_missing_notice(self, *args, **kwargs):
91 def profile_missing_notice(self, *args, **kwargs):
92 error("""\
92 error("""\
93 The profile module could not be found. If you are a Debian user,
93 The profile module could not be found. If you are a Debian user,
94 it has been removed from the standard Debian package because of its non-free
94 it has been removed from the standard Debian package because of its non-free
95 license. To use profiling, please install"python2.3-profiler" from non-free.""")
95 license. To use profiling, please install"python2.3-profiler" from non-free.""")
96
96
97 def default_option(self,fn,optstr):
97 def default_option(self,fn,optstr):
98 """Make an entry in the options_table for fn, with value optstr"""
98 """Make an entry in the options_table for fn, with value optstr"""
99
99
100 if fn not in self.lsmagic():
100 if fn not in self.lsmagic():
101 error("%s is not a magic function" % fn)
101 error("%s is not a magic function" % fn)
102 self.options_table[fn] = optstr
102 self.options_table[fn] = optstr
103
103
104 def lsmagic(self):
104 def lsmagic(self):
105 """Return a list of currently available magic functions.
105 """Return a list of currently available magic functions.
106
106
107 Gives a list of the bare names after mangling (['ls','cd', ...], not
107 Gives a list of the bare names after mangling (['ls','cd', ...], not
108 ['magic_ls','magic_cd',...]"""
108 ['magic_ls','magic_cd',...]"""
109
109
110 # FIXME. This needs a cleanup, in the way the magics list is built.
110 # FIXME. This needs a cleanup, in the way the magics list is built.
111
111
112 # magics in class definition
112 # magics in class definition
113 class_magic = lambda fn: fn.startswith('magic_') and \
113 class_magic = lambda fn: fn.startswith('magic_') and \
114 callable(Magic.__dict__[fn])
114 callable(Magic.__dict__[fn])
115 # in instance namespace (run-time user additions)
115 # in instance namespace (run-time user additions)
116 inst_magic = lambda fn: fn.startswith('magic_') and \
116 inst_magic = lambda fn: fn.startswith('magic_') and \
117 callable(self.__dict__[fn])
117 callable(self.__dict__[fn])
118 # and bound magics by user (so they can access self):
118 # and bound magics by user (so they can access self):
119 inst_bound_magic = lambda fn: fn.startswith('magic_') and \
119 inst_bound_magic = lambda fn: fn.startswith('magic_') and \
120 callable(self.__class__.__dict__[fn])
120 callable(self.__class__.__dict__[fn])
121 magics = filter(class_magic,Magic.__dict__.keys()) + \
121 magics = filter(class_magic,Magic.__dict__.keys()) + \
122 filter(inst_magic,self.__dict__.keys()) + \
122 filter(inst_magic,self.__dict__.keys()) + \
123 filter(inst_bound_magic,self.__class__.__dict__.keys())
123 filter(inst_bound_magic,self.__class__.__dict__.keys())
124 out = []
124 out = []
125 for fn in magics:
125 for fn in magics:
126 out.append(fn.replace('magic_','',1))
126 out.append(fn.replace('magic_','',1))
127 out.sort()
127 out.sort()
128 return out
128 return out
129
129
130 def extract_input_slices(self,slices):
130 def extract_input_slices(self,slices):
131 """Return as a string a set of input history slices.
131 """Return as a string a set of input history slices.
132
132
133 The set of slices is given as a list of strings (like ['1','4:8','9'],
133 The set of slices is given as a list of strings (like ['1','4:8','9'],
134 since this function is for use by magic functions which get their
134 since this function is for use by magic functions which get their
135 arguments as strings.
135 arguments as strings.
136
136
137 Note that slices can be called with two notations:
137 Note that slices can be called with two notations:
138
138
139 N:M -> standard python form, means including items N...(M-1).
139 N:M -> standard python form, means including items N...(M-1).
140
140
141 N-M -> include items N..M (closed endpoint)."""
141 N-M -> include items N..M (closed endpoint)."""
142
142
143 cmds = []
143 cmds = []
144 for chunk in slices:
144 for chunk in slices:
145 if ':' in chunk:
145 if ':' in chunk:
146 ini,fin = map(int,chunk.split(':'))
146 ini,fin = map(int,chunk.split(':'))
147 elif '-' in chunk:
147 elif '-' in chunk:
148 ini,fin = map(int,chunk.split('-'))
148 ini,fin = map(int,chunk.split('-'))
149 fin += 1
149 fin += 1
150 else:
150 else:
151 ini = int(chunk)
151 ini = int(chunk)
152 fin = ini+1
152 fin = ini+1
153 cmds.append(self.shell.input_hist[ini:fin])
153 cmds.append(self.shell.input_hist[ini:fin])
154 return cmds
154 return cmds
155
155
156 def _ofind(self,oname):
156 def _ofind(self,oname):
157 """Find an object in the available namespaces.
157 """Find an object in the available namespaces.
158
158
159 self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic
159 self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic
160
160
161 Has special code to detect magic functions.
161 Has special code to detect magic functions.
162 """
162 """
163
163
164 oname = oname.strip()
164 oname = oname.strip()
165
165
166 # Namespaces to search in:
166 # Namespaces to search in:
167 user_ns = self.shell.user_ns
167 user_ns = self.shell.user_ns
168 internal_ns = self.shell.internal_ns
168 internal_ns = self.shell.internal_ns
169 builtin_ns = __builtin__.__dict__
169 builtin_ns = __builtin__.__dict__
170 alias_ns = self.shell.alias_table
170 alias_ns = self.shell.alias_table
171
171
172 # Put them in a list. The order is important so that we find things in
172 # Put them in a list. The order is important so that we find things in
173 # the same order that Python finds them.
173 # the same order that Python finds them.
174 namespaces = [ ('Interactive',user_ns),
174 namespaces = [ ('Interactive',user_ns),
175 ('IPython internal',internal_ns),
175 ('IPython internal',internal_ns),
176 ('Python builtin',builtin_ns),
176 ('Python builtin',builtin_ns),
177 ('Alias',alias_ns),
177 ('Alias',alias_ns),
178 ]
178 ]
179
179
180 # initialize results to 'null'
180 # initialize results to 'null'
181 found = 0; obj = None; ospace = None; ds = None;
181 found = 0; obj = None; ospace = None; ds = None;
182 ismagic = 0; isalias = 0
182 ismagic = 0; isalias = 0
183
183
184 # Look for the given name by splitting it in parts. If the head is
184 # Look for the given name by splitting it in parts. If the head is
185 # found, then we look for all the remaining parts as members, and only
185 # found, then we look for all the remaining parts as members, and only
186 # declare success if we can find them all.
186 # declare success if we can find them all.
187 oname_parts = oname.split('.')
187 oname_parts = oname.split('.')
188 oname_head, oname_rest = oname_parts[0],oname_parts[1:]
188 oname_head, oname_rest = oname_parts[0],oname_parts[1:]
189 for nsname,ns in namespaces:
189 for nsname,ns in namespaces:
190 try:
190 try:
191 obj = ns[oname_head]
191 obj = ns[oname_head]
192 except KeyError:
192 except KeyError:
193 continue
193 continue
194 else:
194 else:
195 for part in oname_rest:
195 for part in oname_rest:
196 try:
196 try:
197 obj = getattr(obj,part)
197 obj = getattr(obj,part)
198 except:
198 except:
199 # Blanket except b/c some badly implemented objects
199 # Blanket except b/c some badly implemented objects
200 # allow __getattr__ to raise exceptions other than
200 # allow __getattr__ to raise exceptions other than
201 # AttributeError, which then crashes IPython.
201 # AttributeError, which then crashes IPython.
202 break
202 break
203 else:
203 else:
204 # If we finish the for loop (no break), we got all members
204 # If we finish the for loop (no break), we got all members
205 found = 1
205 found = 1
206 ospace = nsname
206 ospace = nsname
207 if ns == alias_ns:
207 if ns == alias_ns:
208 isalias = 1
208 isalias = 1
209 break # namespace loop
209 break # namespace loop
210
210
211 # Try to see if it's magic
211 # Try to see if it's magic
212 if not found:
212 if not found:
213 if oname.startswith(self.shell.ESC_MAGIC):
213 if oname.startswith(self.shell.ESC_MAGIC):
214 oname = oname[1:]
214 oname = oname[1:]
215 obj = getattr(self,'magic_'+oname,None)
215 obj = getattr(self,'magic_'+oname,None)
216 if obj is not None:
216 if obj is not None:
217 found = 1
217 found = 1
218 ospace = 'IPython internal'
218 ospace = 'IPython internal'
219 ismagic = 1
219 ismagic = 1
220
220
221 # Last try: special-case some literals like '', [], {}, etc:
221 # Last try: special-case some literals like '', [], {}, etc:
222 if not found and oname_head in ["''",'""','[]','{}','()']:
222 if not found and oname_head in ["''",'""','[]','{}','()']:
223 obj = eval(oname_head)
223 obj = eval(oname_head)
224 found = 1
224 found = 1
225 ospace = 'Interactive'
225 ospace = 'Interactive'
226
226
227 return {'found':found, 'obj':obj, 'namespace':ospace,
227 return {'found':found, 'obj':obj, 'namespace':ospace,
228 'ismagic':ismagic, 'isalias':isalias}
228 'ismagic':ismagic, 'isalias':isalias}
229
229
230 def arg_err(self,func):
230 def arg_err(self,func):
231 """Print docstring if incorrect arguments were passed"""
231 """Print docstring if incorrect arguments were passed"""
232 print 'Error in arguments:'
232 print 'Error in arguments:'
233 print OInspect.getdoc(func)
233 print OInspect.getdoc(func)
234
234
235 def format_latex(self,strng):
235 def format_latex(self,strng):
236 """Format a string for latex inclusion."""
236 """Format a string for latex inclusion."""
237
237
238 # Characters that need to be escaped for latex:
238 # Characters that need to be escaped for latex:
239 escape_re = re.compile(r'(%|_|\$|#)',re.MULTILINE)
239 escape_re = re.compile(r'(%|_|\$|#)',re.MULTILINE)
240 # Magic command names as headers:
240 # Magic command names as headers:
241 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
241 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
242 re.MULTILINE)
242 re.MULTILINE)
243 # Magic commands
243 # Magic commands
244 cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC,
244 cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC,
245 re.MULTILINE)
245 re.MULTILINE)
246 # Paragraph continue
246 # Paragraph continue
247 par_re = re.compile(r'\\$',re.MULTILINE)
247 par_re = re.compile(r'\\$',re.MULTILINE)
248
248
249 # The "\n" symbol
249 # The "\n" symbol
250 newline_re = re.compile(r'\\n')
250 newline_re = re.compile(r'\\n')
251
251
252 # Now build the string for output:
252 # Now build the string for output:
253 strng = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',strng)
253 #strng = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',strng)
254 strng = cmd_name_re.sub(r'\n\\bigskip\n\\texttt{\\textbf{ \1}}:',
255 strng)
254 strng = cmd_re.sub(r'\\texttt{\g<cmd>}',strng)
256 strng = cmd_re.sub(r'\\texttt{\g<cmd>}',strng)
255 strng = par_re.sub(r'\\\\',strng)
257 strng = par_re.sub(r'\\\\',strng)
256 strng = escape_re.sub(r'\\\1',strng)
258 strng = escape_re.sub(r'\\\1',strng)
257 strng = newline_re.sub(r'\\textbackslash{}n',strng)
259 strng = newline_re.sub(r'\\textbackslash{}n',strng)
258 return strng
260 return strng
259
261
260 def format_screen(self,strng):
262 def format_screen(self,strng):
261 """Format a string for screen printing.
263 """Format a string for screen printing.
262
264
263 This removes some latex-type format codes."""
265 This removes some latex-type format codes."""
264 # Paragraph continue
266 # Paragraph continue
265 par_re = re.compile(r'\\$',re.MULTILINE)
267 par_re = re.compile(r'\\$',re.MULTILINE)
266 strng = par_re.sub('',strng)
268 strng = par_re.sub('',strng)
267 return strng
269 return strng
268
270
269 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
271 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
270 """Parse options passed to an argument string.
272 """Parse options passed to an argument string.
271
273
272 The interface is similar to that of getopt(), but it returns back a
274 The interface is similar to that of getopt(), but it returns back a
273 Struct with the options as keys and the stripped argument string still
275 Struct with the options as keys and the stripped argument string still
274 as a string.
276 as a string.
275
277
276 arg_str is quoted as a true sys.argv vector by using shlex.split.
278 arg_str is quoted as a true sys.argv vector by using shlex.split.
277 This allows us to easily expand variables, glob files, quote
279 This allows us to easily expand variables, glob files, quote
278 arguments, etc.
280 arguments, etc.
279
281
280 Options:
282 Options:
281 -mode: default 'string'. If given as 'list', the argument string is
283 -mode: default 'string'. If given as 'list', the argument string is
282 returned as a list (split on whitespace) instead of a string.
284 returned as a list (split on whitespace) instead of a string.
283
285
284 -list_all: put all option values in lists. Normally only options
286 -list_all: put all option values in lists. Normally only options
285 appearing more than once are put in a list."""
287 appearing more than once are put in a list."""
286
288
287 # inject default options at the beginning of the input line
289 # inject default options at the beginning of the input line
288 caller = sys._getframe(1).f_code.co_name.replace('magic_','')
290 caller = sys._getframe(1).f_code.co_name.replace('magic_','')
289 arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str)
291 arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str)
290
292
291 mode = kw.get('mode','string')
293 mode = kw.get('mode','string')
292 if mode not in ['string','list']:
294 if mode not in ['string','list']:
293 raise ValueError,'incorrect mode given: %s' % mode
295 raise ValueError,'incorrect mode given: %s' % mode
294 # Get options
296 # Get options
295 list_all = kw.get('list_all',0)
297 list_all = kw.get('list_all',0)
296
298
297 # Check if we have more than one argument to warrant extra processing:
299 # Check if we have more than one argument to warrant extra processing:
298 odict = {} # Dictionary with options
300 odict = {} # Dictionary with options
299 args = arg_str.split()
301 args = arg_str.split()
300 if len(args) >= 1:
302 if len(args) >= 1:
301 # If the list of inputs only has 0 or 1 thing in it, there's no
303 # If the list of inputs only has 0 or 1 thing in it, there's no
302 # need to look for options
304 # need to look for options
303 argv = shlex_split(arg_str)
305 argv = shlex_split(arg_str)
304 # Do regular option processing
306 # Do regular option processing
305 opts,args = getopt(argv,opt_str,*long_opts)
307 opts,args = getopt(argv,opt_str,*long_opts)
306 for o,a in opts:
308 for o,a in opts:
307 if o.startswith('--'):
309 if o.startswith('--'):
308 o = o[2:]
310 o = o[2:]
309 else:
311 else:
310 o = o[1:]
312 o = o[1:]
311 try:
313 try:
312 odict[o].append(a)
314 odict[o].append(a)
313 except AttributeError:
315 except AttributeError:
314 odict[o] = [odict[o],a]
316 odict[o] = [odict[o],a]
315 except KeyError:
317 except KeyError:
316 if list_all:
318 if list_all:
317 odict[o] = [a]
319 odict[o] = [a]
318 else:
320 else:
319 odict[o] = a
321 odict[o] = a
320
322
321 # Prepare opts,args for return
323 # Prepare opts,args for return
322 opts = Struct(odict)
324 opts = Struct(odict)
323 if mode == 'string':
325 if mode == 'string':
324 args = ' '.join(args)
326 args = ' '.join(args)
325
327
326 return opts,args
328 return opts,args
327
329
328 #......................................................................
330 #......................................................................
329 # And now the actual magic functions
331 # And now the actual magic functions
330
332
331 # Functions for IPython shell work (vars,funcs, config, etc)
333 # Functions for IPython shell work (vars,funcs, config, etc)
332 def magic_lsmagic(self, parameter_s = ''):
334 def magic_lsmagic(self, parameter_s = ''):
333 """List currently available magic functions."""
335 """List currently available magic functions."""
334 mesc = self.shell.ESC_MAGIC
336 mesc = self.shell.ESC_MAGIC
335 print 'Available magic functions:\n'+mesc+\
337 print 'Available magic functions:\n'+mesc+\
336 (' '+mesc).join(self.lsmagic())
338 (' '+mesc).join(self.lsmagic())
337 print '\n' + Magic.auto_status[self.shell.rc.automagic]
339 print '\n' + Magic.auto_status[self.shell.rc.automagic]
338 return None
340 return None
339
341
340 def magic_magic(self, parameter_s = ''):
342 def magic_magic(self, parameter_s = ''):
341 """Print information about the magic function system."""
343 """Print information about the magic function system."""
342
344
343 mode = ''
345 mode = ''
344 try:
346 try:
345 if parameter_s.split()[0] == '-latex':
347 if parameter_s.split()[0] == '-latex':
346 mode = 'latex'
348 mode = 'latex'
347 except:
349 except:
348 pass
350 pass
349
351
350 magic_docs = []
352 magic_docs = []
351 for fname in self.lsmagic():
353 for fname in self.lsmagic():
352 mname = 'magic_' + fname
354 mname = 'magic_' + fname
353 for space in (Magic,self,self.__class__):
355 for space in (Magic,self,self.__class__):
354 try:
356 try:
355 fn = space.__dict__[mname]
357 fn = space.__dict__[mname]
356 except KeyError:
358 except KeyError:
357 pass
359 pass
358 else:
360 else:
359 break
361 break
360 magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC,
362 magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC,
361 fname,fn.__doc__))
363 fname,fn.__doc__))
362 magic_docs = ''.join(magic_docs)
364 magic_docs = ''.join(magic_docs)
363
365
364 if mode == 'latex':
366 if mode == 'latex':
365 print self.format_latex(magic_docs)
367 print self.format_latex(magic_docs)
366 return
368 return
367 else:
369 else:
368 magic_docs = self.format_screen(magic_docs)
370 magic_docs = self.format_screen(magic_docs)
369
371
370 outmsg = """
372 outmsg = """
371 IPython's 'magic' functions
373 IPython's 'magic' functions
372 ===========================
374 ===========================
373
375
374 The magic function system provides a series of functions which allow you to
376 The magic function system provides a series of functions which allow you to
375 control the behavior of IPython itself, plus a lot of system-type
377 control the behavior of IPython itself, plus a lot of system-type
376 features. All these functions are prefixed with a % character, but parameters
378 features. All these functions are prefixed with a % character, but parameters
377 are given without parentheses or quotes.
379 are given without parentheses or quotes.
378
380
379 NOTE: If you have 'automagic' enabled (via the command line option or with the
381 NOTE: If you have 'automagic' enabled (via the command line option or with the
380 %automagic function), you don't need to type in the % explicitly. By default,
382 %automagic function), you don't need to type in the % explicitly. By default,
381 IPython ships with automagic on, so you should only rarely need the % escape.
383 IPython ships with automagic on, so you should only rarely need the % escape.
382
384
383 Example: typing '%cd mydir' (without the quotes) changes you working directory
385 Example: typing '%cd mydir' (without the quotes) changes you working directory
384 to 'mydir', if it exists.
386 to 'mydir', if it exists.
385
387
386 You can define your own magic functions to extend the system. See the supplied
388 You can define your own magic functions to extend the system. See the supplied
387 ipythonrc and example-magic.py files for details (in your ipython
389 ipythonrc and example-magic.py files for details (in your ipython
388 configuration directory, typically $HOME/.ipython/).
390 configuration directory, typically $HOME/.ipython/).
389
391
390 You can also define your own aliased names for magic functions. In your
392 You can also define your own aliased names for magic functions. In your
391 ipythonrc file, placing a line like:
393 ipythonrc file, placing a line like:
392
394
393 execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
395 execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
394
396
395 will define %pf as a new name for %profile.
397 will define %pf as a new name for %profile.
396
398
397 You can also call magics in code using the ipmagic() function, which IPython
399 You can also call magics in code using the ipmagic() function, which IPython
398 automatically adds to the builtin namespace. Type 'ipmagic?' for details.
400 automatically adds to the builtin namespace. Type 'ipmagic?' for details.
399
401
400 For a list of the available magic functions, use %lsmagic. For a description
402 For a list of the available magic functions, use %lsmagic. For a description
401 of any of them, type %magic_name?, e.g. '%cd?'.
403 of any of them, type %magic_name?, e.g. '%cd?'.
402
404
403 Currently the magic system has the following functions:\n"""
405 Currently the magic system has the following functions:\n"""
404
406
405 mesc = self.shell.ESC_MAGIC
407 mesc = self.shell.ESC_MAGIC
406 outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):"
408 outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):"
407 "\n\n%s%s\n\n%s" % (outmsg,
409 "\n\n%s%s\n\n%s" % (outmsg,
408 magic_docs,mesc,mesc,
410 magic_docs,mesc,mesc,
409 (' '+mesc).join(self.lsmagic()),
411 (' '+mesc).join(self.lsmagic()),
410 Magic.auto_status[self.shell.rc.automagic] ) )
412 Magic.auto_status[self.shell.rc.automagic] ) )
411
413
412 page(outmsg,screen_lines=self.shell.rc.screen_length)
414 page(outmsg,screen_lines=self.shell.rc.screen_length)
413
415
414 def magic_automagic(self, parameter_s = ''):
416 def magic_automagic(self, parameter_s = ''):
415 """Make magic functions callable without having to type the initial %.
417 """Make magic functions callable without having to type the initial %.
416
418
417 Toggles on/off (when off, you must call it as %automagic, of
419 Toggles on/off (when off, you must call it as %automagic, of
418 course). Note that magic functions have lowest priority, so if there's
420 course). Note that magic functions have lowest priority, so if there's
419 a variable whose name collides with that of a magic fn, automagic
421 a variable whose name collides with that of a magic fn, automagic
420 won't work for that function (you get the variable instead). However,
422 won't work for that function (you get the variable instead). However,
421 if you delete the variable (del var), the previously shadowed magic
423 if you delete the variable (del var), the previously shadowed magic
422 function becomes visible to automagic again."""
424 function becomes visible to automagic again."""
423
425
424 rc = self.shell.rc
426 rc = self.shell.rc
425 rc.automagic = not rc.automagic
427 rc.automagic = not rc.automagic
426 print '\n' + Magic.auto_status[rc.automagic]
428 print '\n' + Magic.auto_status[rc.automagic]
427
429
428 def magic_autocall(self, parameter_s = ''):
430 def magic_autocall(self, parameter_s = ''):
429 """Make functions callable without having to type parentheses.
431 """Make functions callable without having to type parentheses.
430
432
431 Usage:
433 Usage:
432
434
433 %autocall [mode]
435 %autocall [mode]
434
436
435 The mode can be one of: 0->Off, 1->Smart, 2->Full. If not given, the
437 The mode can be one of: 0->Off, 1->Smart, 2->Full. If not given, the
436 value is toggled on and off (remembering the previous state)."""
438 value is toggled on and off (remembering the previous state)."""
437
439
438 rc = self.shell.rc
440 rc = self.shell.rc
439
441
440 if parameter_s:
442 if parameter_s:
441 arg = int(parameter_s)
443 arg = int(parameter_s)
442 else:
444 else:
443 arg = 'toggle'
445 arg = 'toggle'
444
446
445 if not arg in (0,1,2,'toggle'):
447 if not arg in (0,1,2,'toggle'):
446 error('Valid modes: (0->Off, 1->Smart, 2->Full')
448 error('Valid modes: (0->Off, 1->Smart, 2->Full')
447 return
449 return
448
450
449 if arg in (0,1,2):
451 if arg in (0,1,2):
450 rc.autocall = arg
452 rc.autocall = arg
451 else: # toggle
453 else: # toggle
452 if rc.autocall:
454 if rc.autocall:
453 self._magic_state.autocall_save = rc.autocall
455 self._magic_state.autocall_save = rc.autocall
454 rc.autocall = 0
456 rc.autocall = 0
455 else:
457 else:
456 try:
458 try:
457 rc.autocall = self._magic_state.autocall_save
459 rc.autocall = self._magic_state.autocall_save
458 except AttributeError:
460 except AttributeError:
459 rc.autocall = self._magic_state.autocall_save = 1
461 rc.autocall = self._magic_state.autocall_save = 1
460
462
461 print "Automatic calling is:",['OFF','Smart','Full'][rc.autocall]
463 print "Automatic calling is:",['OFF','Smart','Full'][rc.autocall]
462
464
463 def magic_autoindent(self, parameter_s = ''):
465 def magic_autoindent(self, parameter_s = ''):
464 """Toggle autoindent on/off (if available)."""
466 """Toggle autoindent on/off (if available)."""
465
467
466 self.shell.set_autoindent()
468 self.shell.set_autoindent()
467 print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent]
469 print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent]
468
470
469 def magic_system_verbose(self, parameter_s = ''):
471 def magic_system_verbose(self, parameter_s = ''):
470 """Toggle verbose printing of system calls on/off."""
472 """Toggle verbose printing of system calls on/off."""
471
473
472 self.shell.rc_set_toggle('system_verbose')
474 self.shell.rc_set_toggle('system_verbose')
473 print "System verbose printing is:",\
475 print "System verbose printing is:",\
474 ['OFF','ON'][self.shell.rc.system_verbose]
476 ['OFF','ON'][self.shell.rc.system_verbose]
475
477
476 def magic_history(self, parameter_s = ''):
478 def magic_history(self, parameter_s = ''):
477 """Print input history (_i<n> variables), with most recent last.
479 """Print input history (_i<n> variables), with most recent last.
478
480
479 %history [-n] -> print at most 40 inputs (some may be multi-line)\\
481 %history [-n] -> print at most 40 inputs (some may be multi-line)\\
480 %history [-n] n -> print at most n inputs\\
482 %history [-n] n -> print at most n inputs\\
481 %history [-n] n1 n2 -> print inputs between n1 and n2 (n2 not included)\\
483 %history [-n] n1 n2 -> print inputs between n1 and n2 (n2 not included)\\
482
484
483 Each input's number <n> is shown, and is accessible as the
485 Each input's number <n> is shown, and is accessible as the
484 automatically generated variable _i<n>. Multi-line statements are
486 automatically generated variable _i<n>. Multi-line statements are
485 printed starting at a new line for easy copy/paste.
487 printed starting at a new line for easy copy/paste.
486
488
487 If option -n is used, input numbers are not printed. This is useful if
489 If option -n is used, input numbers are not printed. This is useful if
488 you want to get a printout of many lines which can be directly pasted
490 you want to get a printout of many lines which can be directly pasted
489 into a text editor.
491 into a text editor.
490
492
491 This feature is only available if numbered prompts are in use."""
493 This feature is only available if numbered prompts are in use."""
492
494
493 shell = self.shell
495 shell = self.shell
494 if not shell.outputcache.do_full_cache:
496 if not shell.outputcache.do_full_cache:
495 print 'This feature is only available if numbered prompts are in use.'
497 print 'This feature is only available if numbered prompts are in use.'
496 return
498 return
497 opts,args = self.parse_options(parameter_s,'n',mode='list')
499 opts,args = self.parse_options(parameter_s,'n',mode='list')
498
500
499 input_hist = shell.input_hist
501 input_hist = shell.input_hist
500 default_length = 40
502 default_length = 40
501 if len(args) == 0:
503 if len(args) == 0:
502 final = len(input_hist)
504 final = len(input_hist)
503 init = max(1,final-default_length)
505 init = max(1,final-default_length)
504 elif len(args) == 1:
506 elif len(args) == 1:
505 final = len(input_hist)
507 final = len(input_hist)
506 init = max(1,final-int(args[0]))
508 init = max(1,final-int(args[0]))
507 elif len(args) == 2:
509 elif len(args) == 2:
508 init,final = map(int,args)
510 init,final = map(int,args)
509 else:
511 else:
510 warn('%hist takes 0, 1 or 2 arguments separated by spaces.')
512 warn('%hist takes 0, 1 or 2 arguments separated by spaces.')
511 print self.magic_hist.__doc__
513 print self.magic_hist.__doc__
512 return
514 return
513 width = len(str(final))
515 width = len(str(final))
514 line_sep = ['','\n']
516 line_sep = ['','\n']
515 print_nums = not opts.has_key('n')
517 print_nums = not opts.has_key('n')
516 for in_num in range(init,final):
518 for in_num in range(init,final):
517 inline = input_hist[in_num]
519 inline = input_hist[in_num]
518 multiline = int(inline.count('\n') > 1)
520 multiline = int(inline.count('\n') > 1)
519 if print_nums:
521 if print_nums:
520 print '%s:%s' % (str(in_num).ljust(width),line_sep[multiline]),
522 print '%s:%s' % (str(in_num).ljust(width),line_sep[multiline]),
521 print inline,
523 print inline,
522
524
523 def magic_hist(self, parameter_s=''):
525 def magic_hist(self, parameter_s=''):
524 """Alternate name for %history."""
526 """Alternate name for %history."""
525 return self.magic_history(parameter_s)
527 return self.magic_history(parameter_s)
526
528
527 def magic_p(self, parameter_s=''):
529 def magic_p(self, parameter_s=''):
528 """Just a short alias for Python's 'print'."""
530 """Just a short alias for Python's 'print'."""
529 exec 'print ' + parameter_s in self.shell.user_ns
531 exec 'print ' + parameter_s in self.shell.user_ns
530
532
531 def magic_r(self, parameter_s=''):
533 def magic_r(self, parameter_s=''):
532 """Repeat previous input.
534 """Repeat previous input.
533
535
534 If given an argument, repeats the previous command which starts with
536 If given an argument, repeats the previous command which starts with
535 the same string, otherwise it just repeats the previous input.
537 the same string, otherwise it just repeats the previous input.
536
538
537 Shell escaped commands (with ! as first character) are not recognized
539 Shell escaped commands (with ! as first character) are not recognized
538 by this system, only pure python code and magic commands.
540 by this system, only pure python code and magic commands.
539 """
541 """
540
542
541 start = parameter_s.strip()
543 start = parameter_s.strip()
542 esc_magic = self.shell.ESC_MAGIC
544 esc_magic = self.shell.ESC_MAGIC
543 # Identify magic commands even if automagic is on (which means
545 # Identify magic commands even if automagic is on (which means
544 # the in-memory version is different from that typed by the user).
546 # the in-memory version is different from that typed by the user).
545 if self.shell.rc.automagic:
547 if self.shell.rc.automagic:
546 start_magic = esc_magic+start
548 start_magic = esc_magic+start
547 else:
549 else:
548 start_magic = start
550 start_magic = start
549 # Look through the input history in reverse
551 # Look through the input history in reverse
550 for n in range(len(self.shell.input_hist)-2,0,-1):
552 for n in range(len(self.shell.input_hist)-2,0,-1):
551 input = self.shell.input_hist[n]
553 input = self.shell.input_hist[n]
552 # skip plain 'r' lines so we don't recurse to infinity
554 # skip plain 'r' lines so we don't recurse to infinity
553 if input != 'ipmagic("r")\n' and \
555 if input != 'ipmagic("r")\n' and \
554 (input.startswith(start) or input.startswith(start_magic)):
556 (input.startswith(start) or input.startswith(start_magic)):
555 #print 'match',`input` # dbg
557 #print 'match',`input` # dbg
556 print 'Executing:',input,
558 print 'Executing:',input,
557 self.shell.runlines(input)
559 self.shell.runlines(input)
558 return
560 return
559 print 'No previous input matching `%s` found.' % start
561 print 'No previous input matching `%s` found.' % start
560
562
561 def magic_page(self, parameter_s=''):
563 def magic_page(self, parameter_s=''):
562 """Pretty print the object and display it through a pager.
564 """Pretty print the object and display it through a pager.
563
565
564 If no parameter is given, use _ (last output)."""
566 If no parameter is given, use _ (last output)."""
565 # After a function contributed by Olivier Aubert, slightly modified.
567 # After a function contributed by Olivier Aubert, slightly modified.
566
568
567 oname = parameter_s and parameter_s or '_'
569 oname = parameter_s and parameter_s or '_'
568 info = self._ofind(oname)
570 info = self._ofind(oname)
569 if info['found']:
571 if info['found']:
570 page(pformat(info['obj']))
572 page(pformat(info['obj']))
571 else:
573 else:
572 print 'Object `%s` not found' % oname
574 print 'Object `%s` not found' % oname
573
575
574 def magic_profile(self, parameter_s=''):
576 def magic_profile(self, parameter_s=''):
575 """Print your currently active IPyhton profile."""
577 """Print your currently active IPyhton profile."""
576 if self.shell.rc.profile:
578 if self.shell.rc.profile:
577 printpl('Current IPython profile: $self.shell.rc.profile.')
579 printpl('Current IPython profile: $self.shell.rc.profile.')
578 else:
580 else:
579 print 'No profile active.'
581 print 'No profile active.'
580
582
581 def _inspect(self,meth,oname,**kw):
583 def _inspect(self,meth,oname,**kw):
582 """Generic interface to the inspector system.
584 """Generic interface to the inspector system.
583
585
584 This function is meant to be called by pdef, pdoc & friends."""
586 This function is meant to be called by pdef, pdoc & friends."""
585
587
586 oname = oname.strip()
588 oname = oname.strip()
587 info = Struct(self._ofind(oname))
589 info = Struct(self._ofind(oname))
588 if info.found:
590 if info.found:
589 pmethod = getattr(self.shell.inspector,meth)
591 pmethod = getattr(self.shell.inspector,meth)
590 formatter = info.ismagic and self.format_screen or None
592 formatter = info.ismagic and self.format_screen or None
591 if meth == 'pdoc':
593 if meth == 'pdoc':
592 pmethod(info.obj,oname,formatter)
594 pmethod(info.obj,oname,formatter)
593 elif meth == 'pinfo':
595 elif meth == 'pinfo':
594 pmethod(info.obj,oname,formatter,info,**kw)
596 pmethod(info.obj,oname,formatter,info,**kw)
595 else:
597 else:
596 pmethod(info.obj,oname)
598 pmethod(info.obj,oname)
597 else:
599 else:
598 print 'Object `%s` not found.' % oname
600 print 'Object `%s` not found.' % oname
599 return 'not found' # so callers can take other action
601 return 'not found' # so callers can take other action
600
602
601 def magic_pdef(self, parameter_s=''):
603 def magic_pdef(self, parameter_s=''):
602 """Print the definition header for any callable object.
604 """Print the definition header for any callable object.
603
605
604 If the object is a class, print the constructor information."""
606 If the object is a class, print the constructor information."""
605 self._inspect('pdef',parameter_s)
607 self._inspect('pdef',parameter_s)
606
608
607 def magic_pdoc(self, parameter_s=''):
609 def magic_pdoc(self, parameter_s=''):
608 """Print the docstring for an object.
610 """Print the docstring for an object.
609
611
610 If the given object is a class, it will print both the class and the
612 If the given object is a class, it will print both the class and the
611 constructor docstrings."""
613 constructor docstrings."""
612 self._inspect('pdoc',parameter_s)
614 self._inspect('pdoc',parameter_s)
613
615
614 def magic_psource(self, parameter_s=''):
616 def magic_psource(self, parameter_s=''):
615 """Print (or run through pager) the source code for an object."""
617 """Print (or run through pager) the source code for an object."""
616 self._inspect('psource',parameter_s)
618 self._inspect('psource',parameter_s)
617
619
618 def magic_pfile(self, parameter_s=''):
620 def magic_pfile(self, parameter_s=''):
619 """Print (or run through pager) the file where an object is defined.
621 """Print (or run through pager) the file where an object is defined.
620
622
621 The file opens at the line where the object definition begins. IPython
623 The file opens at the line where the object definition begins. IPython
622 will honor the environment variable PAGER if set, and otherwise will
624 will honor the environment variable PAGER if set, and otherwise will
623 do its best to print the file in a convenient form.
625 do its best to print the file in a convenient form.
624
626
625 If the given argument is not an object currently defined, IPython will
627 If the given argument is not an object currently defined, IPython will
626 try to interpret it as a filename (automatically adding a .py extension
628 try to interpret it as a filename (automatically adding a .py extension
627 if needed). You can thus use %pfile as a syntax highlighting code
629 if needed). You can thus use %pfile as a syntax highlighting code
628 viewer."""
630 viewer."""
629
631
630 # first interpret argument as an object name
632 # first interpret argument as an object name
631 out = self._inspect('pfile',parameter_s)
633 out = self._inspect('pfile',parameter_s)
632 # if not, try the input as a filename
634 # if not, try the input as a filename
633 if out == 'not found':
635 if out == 'not found':
634 try:
636 try:
635 filename = get_py_filename(parameter_s)
637 filename = get_py_filename(parameter_s)
636 except IOError,msg:
638 except IOError,msg:
637 print msg
639 print msg
638 return
640 return
639 page(self.shell.inspector.format(file(filename).read()))
641 page(self.shell.inspector.format(file(filename).read()))
640
642
641 def magic_pinfo(self, parameter_s=''):
643 def magic_pinfo(self, parameter_s=''):
642 """Provide detailed information about an object.
644 """Provide detailed information about an object.
643
645
644 '%pinfo object' is just a synonym for object? or ?object."""
646 '%pinfo object' is just a synonym for object? or ?object."""
645
647
646 #print 'pinfo par: <%s>' % parameter_s # dbg
648 #print 'pinfo par: <%s>' % parameter_s # dbg
647
649
648 # detail_level: 0 -> obj? , 1 -> obj??
650 # detail_level: 0 -> obj? , 1 -> obj??
649 detail_level = 0
651 detail_level = 0
650 # We need to detect if we got called as 'pinfo pinfo foo', which can
652 # We need to detect if we got called as 'pinfo pinfo foo', which can
651 # happen if the user types 'pinfo foo?' at the cmd line.
653 # happen if the user types 'pinfo foo?' at the cmd line.
652 pinfo,qmark1,oname,qmark2 = \
654 pinfo,qmark1,oname,qmark2 = \
653 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
655 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
654 if pinfo or qmark1 or qmark2:
656 if pinfo or qmark1 or qmark2:
655 detail_level = 1
657 detail_level = 1
656 if "*" in oname:
658 if "*" in oname:
657 self.magic_psearch(oname)
659 self.magic_psearch(oname)
658 else:
660 else:
659 self._inspect('pinfo',oname,detail_level=detail_level)
661 self._inspect('pinfo',oname,detail_level=detail_level)
660
662
661 def magic_psearch(self, parameter_s=''):
663 def magic_psearch(self, parameter_s=''):
662 """Search for object in namespaces by wildcard.
664 """Search for object in namespaces by wildcard.
663
665
664 %psearch [options] PATTERN [OBJECT TYPE]
666 %psearch [options] PATTERN [OBJECT TYPE]
665
667
666 Note: ? can be used as a synonym for %psearch, at the beginning or at
668 Note: ? can be used as a synonym for %psearch, at the beginning or at
667 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
669 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
668 rest of the command line must be unchanged (options come first), so
670 rest of the command line must be unchanged (options come first), so
669 for example the following forms are equivalent
671 for example the following forms are equivalent
670
672
671 %psearch -i a* function
673 %psearch -i a* function
672 -i a* function?
674 -i a* function?
673 ?-i a* function
675 ?-i a* function
674
676
675 Arguments:
677 Arguments:
676
678
677 PATTERN
679 PATTERN
678
680
679 where PATTERN is a string containing * as a wildcard similar to its
681 where PATTERN is a string containing * as a wildcard similar to its
680 use in a shell. The pattern is matched in all namespaces on the
682 use in a shell. The pattern is matched in all namespaces on the
681 search path. By default objects starting with a single _ are not
683 search path. By default objects starting with a single _ are not
682 matched, many IPython generated objects have a single
684 matched, many IPython generated objects have a single
683 underscore. The default is case insensitive matching. Matching is
685 underscore. The default is case insensitive matching. Matching is
684 also done on the attributes of objects and not only on the objects
686 also done on the attributes of objects and not only on the objects
685 in a module.
687 in a module.
686
688
687 [OBJECT TYPE]
689 [OBJECT TYPE]
688
690
689 Is the name of a python type from the types module. The name is
691 Is the name of a python type from the types module. The name is
690 given in lowercase without the ending type, ex. StringType is
692 given in lowercase without the ending type, ex. StringType is
691 written string. By adding a type here only objects matching the
693 written string. By adding a type here only objects matching the
692 given type are matched. Using all here makes the pattern match all
694 given type are matched. Using all here makes the pattern match all
693 types (this is the default).
695 types (this is the default).
694
696
695 Options:
697 Options:
696
698
697 -a: makes the pattern match even objects whose names start with a
699 -a: makes the pattern match even objects whose names start with a
698 single underscore. These names are normally ommitted from the
700 single underscore. These names are normally ommitted from the
699 search.
701 search.
700
702
701 -i/-c: make the pattern case insensitive/sensitive. If neither of
703 -i/-c: make the pattern case insensitive/sensitive. If neither of
702 these options is given, the default is read from your ipythonrc
704 these options is given, the default is read from your ipythonrc
703 file. The option name which sets this value is
705 file. The option name which sets this value is
704 'wildcards_case_sensitive'. If this option is not specified in your
706 'wildcards_case_sensitive'. If this option is not specified in your
705 ipythonrc file, IPython's internal default is to do a case sensitive
707 ipythonrc file, IPython's internal default is to do a case sensitive
706 search.
708 search.
707
709
708 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
710 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
709 specifiy can be searched in any of the following namespaces:
711 specifiy can be searched in any of the following namespaces:
710 'builtin', 'user', 'user_global','internal', 'alias', where
712 'builtin', 'user', 'user_global','internal', 'alias', where
711 'builtin' and 'user' are the search defaults. Note that you should
713 'builtin' and 'user' are the search defaults. Note that you should
712 not use quotes when specifying namespaces.
714 not use quotes when specifying namespaces.
713
715
714 'Builtin' contains the python module builtin, 'user' contains all
716 'Builtin' contains the python module builtin, 'user' contains all
715 user data, 'alias' only contain the shell aliases and no python
717 user data, 'alias' only contain the shell aliases and no python
716 objects, 'internal' contains objects used by IPython. The
718 objects, 'internal' contains objects used by IPython. The
717 'user_global' namespace is only used by embedded IPython instances,
719 'user_global' namespace is only used by embedded IPython instances,
718 and it contains module-level globals. You can add namespaces to the
720 and it contains module-level globals. You can add namespaces to the
719 search with -s or exclude them with -e (these options can be given
721 search with -s or exclude them with -e (these options can be given
720 more than once).
722 more than once).
721
723
722 Examples:
724 Examples:
723
725
724 %psearch a* -> objects beginning with an a
726 %psearch a* -> objects beginning with an a
725 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
727 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
726 %psearch a* function -> all functions beginning with an a
728 %psearch a* function -> all functions beginning with an a
727 %psearch re.e* -> objects beginning with an e in module re
729 %psearch re.e* -> objects beginning with an e in module re
728 %psearch r*.e* -> objects that start with e in modules starting in r
730 %psearch r*.e* -> objects that start with e in modules starting in r
729 %psearch r*.* string -> all strings in modules beginning with r
731 %psearch r*.* string -> all strings in modules beginning with r
730
732
731 Case sensitve search:
733 Case sensitve search:
732
734
733 %psearch -c a* list all object beginning with lower case a
735 %psearch -c a* list all object beginning with lower case a
734
736
735 Show objects beginning with a single _:
737 Show objects beginning with a single _:
736
738
737 %psearch -a _* list objects beginning with a single underscore"""
739 %psearch -a _* list objects beginning with a single underscore"""
738
740
739 # default namespaces to be searched
741 # default namespaces to be searched
740 def_search = ['user','builtin']
742 def_search = ['user','builtin']
741
743
742 # Process options/args
744 # Process options/args
743 opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
745 opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
744 opt = opts.get
746 opt = opts.get
745 shell = self.shell
747 shell = self.shell
746 psearch = shell.inspector.psearch
748 psearch = shell.inspector.psearch
747
749
748 # select case options
750 # select case options
749 if opts.has_key('i'):
751 if opts.has_key('i'):
750 ignore_case = True
752 ignore_case = True
751 elif opts.has_key('c'):
753 elif opts.has_key('c'):
752 ignore_case = False
754 ignore_case = False
753 else:
755 else:
754 ignore_case = not shell.rc.wildcards_case_sensitive
756 ignore_case = not shell.rc.wildcards_case_sensitive
755
757
756 # Build list of namespaces to search from user options
758 # Build list of namespaces to search from user options
757 def_search.extend(opt('s',[]))
759 def_search.extend(opt('s',[]))
758 ns_exclude = ns_exclude=opt('e',[])
760 ns_exclude = ns_exclude=opt('e',[])
759 ns_search = [nm for nm in def_search if nm not in ns_exclude]
761 ns_search = [nm for nm in def_search if nm not in ns_exclude]
760
762
761 # Call the actual search
763 # Call the actual search
762 try:
764 try:
763 psearch(args,shell.ns_table,ns_search,
765 psearch(args,shell.ns_table,ns_search,
764 show_all=opt('a'),ignore_case=ignore_case)
766 show_all=opt('a'),ignore_case=ignore_case)
765 except:
767 except:
766 shell.showtraceback()
768 shell.showtraceback()
767
769
768 def magic_who_ls(self, parameter_s=''):
770 def magic_who_ls(self, parameter_s=''):
769 """Return a sorted list of all interactive variables.
771 """Return a sorted list of all interactive variables.
770
772
771 If arguments are given, only variables of types matching these
773 If arguments are given, only variables of types matching these
772 arguments are returned."""
774 arguments are returned."""
773
775
774 user_ns = self.shell.user_ns
776 user_ns = self.shell.user_ns
775 internal_ns = self.shell.internal_ns
777 internal_ns = self.shell.internal_ns
776 user_config_ns = self.shell.user_config_ns
778 user_config_ns = self.shell.user_config_ns
777 out = []
779 out = []
778 typelist = parameter_s.split()
780 typelist = parameter_s.split()
779
781
780 for i in user_ns:
782 for i in user_ns:
781 if not (i.startswith('_') or i.startswith('_i')) \
783 if not (i.startswith('_') or i.startswith('_i')) \
782 and not (i in internal_ns or i in user_config_ns):
784 and not (i in internal_ns or i in user_config_ns):
783 if typelist:
785 if typelist:
784 if type(user_ns[i]).__name__ in typelist:
786 if type(user_ns[i]).__name__ in typelist:
785 out.append(i)
787 out.append(i)
786 else:
788 else:
787 out.append(i)
789 out.append(i)
788 out.sort()
790 out.sort()
789 return out
791 return out
790
792
791 def magic_who(self, parameter_s=''):
793 def magic_who(self, parameter_s=''):
792 """Print all interactive variables, with some minimal formatting.
794 """Print all interactive variables, with some minimal formatting.
793
795
794 If any arguments are given, only variables whose type matches one of
796 If any arguments are given, only variables whose type matches one of
795 these are printed. For example:
797 these are printed. For example:
796
798
797 %who function str
799 %who function str
798
800
799 will only list functions and strings, excluding all other types of
801 will only list functions and strings, excluding all other types of
800 variables. To find the proper type names, simply use type(var) at a
802 variables. To find the proper type names, simply use type(var) at a
801 command line to see how python prints type names. For example:
803 command line to see how python prints type names. For example:
802
804
803 In [1]: type('hello')\\
805 In [1]: type('hello')\\
804 Out[1]: <type 'str'>
806 Out[1]: <type 'str'>
805
807
806 indicates that the type name for strings is 'str'.
808 indicates that the type name for strings is 'str'.
807
809
808 %who always excludes executed names loaded through your configuration
810 %who always excludes executed names loaded through your configuration
809 file and things which are internal to IPython.
811 file and things which are internal to IPython.
810
812
811 This is deliberate, as typically you may load many modules and the
813 This is deliberate, as typically you may load many modules and the
812 purpose of %who is to show you only what you've manually defined."""
814 purpose of %who is to show you only what you've manually defined."""
813
815
814 varlist = self.magic_who_ls(parameter_s)
816 varlist = self.magic_who_ls(parameter_s)
815 if not varlist:
817 if not varlist:
816 print 'Interactive namespace is empty.'
818 print 'Interactive namespace is empty.'
817 return
819 return
818
820
819 # if we have variables, move on...
821 # if we have variables, move on...
820
822
821 # stupid flushing problem: when prompts have no separators, stdout is
823 # stupid flushing problem: when prompts have no separators, stdout is
822 # getting lost. I'm starting to think this is a python bug. I'm having
824 # getting lost. I'm starting to think this is a python bug. I'm having
823 # to force a flush with a print because even a sys.stdout.flush
825 # to force a flush with a print because even a sys.stdout.flush
824 # doesn't seem to do anything!
826 # doesn't seem to do anything!
825
827
826 count = 0
828 count = 0
827 for i in varlist:
829 for i in varlist:
828 print i+'\t',
830 print i+'\t',
829 count += 1
831 count += 1
830 if count > 8:
832 if count > 8:
831 count = 0
833 count = 0
832 print
834 print
833 sys.stdout.flush() # FIXME. Why the hell isn't this flushing???
835 sys.stdout.flush() # FIXME. Why the hell isn't this flushing???
834
836
835 print # well, this does force a flush at the expense of an extra \n
837 print # well, this does force a flush at the expense of an extra \n
836
838
837 def magic_whos(self, parameter_s=''):
839 def magic_whos(self, parameter_s=''):
838 """Like %who, but gives some extra information about each variable.
840 """Like %who, but gives some extra information about each variable.
839
841
840 The same type filtering of %who can be applied here.
842 The same type filtering of %who can be applied here.
841
843
842 For all variables, the type is printed. Additionally it prints:
844 For all variables, the type is printed. Additionally it prints:
843
845
844 - For {},[],(): their length.
846 - For {},[],(): their length.
845
847
846 - For Numeric arrays, a summary with shape, number of elements,
848 - For Numeric arrays, a summary with shape, number of elements,
847 typecode and size in memory.
849 typecode and size in memory.
848
850
849 - Everything else: a string representation, snipping their middle if
851 - Everything else: a string representation, snipping their middle if
850 too long."""
852 too long."""
851
853
852 varnames = self.magic_who_ls(parameter_s)
854 varnames = self.magic_who_ls(parameter_s)
853 if not varnames:
855 if not varnames:
854 print 'Interactive namespace is empty.'
856 print 'Interactive namespace is empty.'
855 return
857 return
856
858
857 # if we have variables, move on...
859 # if we have variables, move on...
858
860
859 # for these types, show len() instead of data:
861 # for these types, show len() instead of data:
860 seq_types = [types.DictType,types.ListType,types.TupleType]
862 seq_types = [types.DictType,types.ListType,types.TupleType]
861
863
862 # for Numeric arrays, display summary info
864 # for Numeric arrays, display summary info
863 try:
865 try:
864 import Numeric
866 import Numeric
865 except ImportError:
867 except ImportError:
866 array_type = None
868 array_type = None
867 else:
869 else:
868 array_type = Numeric.ArrayType.__name__
870 array_type = Numeric.ArrayType.__name__
869
871
870 # Find all variable names and types so we can figure out column sizes
872 # Find all variable names and types so we can figure out column sizes
871 get_vars = lambda i: self.shell.user_ns[i]
873 get_vars = lambda i: self.shell.user_ns[i]
872 type_name = lambda v: type(v).__name__
874 type_name = lambda v: type(v).__name__
873 varlist = map(get_vars,varnames)
875 varlist = map(get_vars,varnames)
874
876
875 typelist = []
877 typelist = []
876 for vv in varlist:
878 for vv in varlist:
877 tt = type_name(vv)
879 tt = type_name(vv)
878 if tt=='instance':
880 if tt=='instance':
879 typelist.append(str(vv.__class__))
881 typelist.append(str(vv.__class__))
880 else:
882 else:
881 typelist.append(tt)
883 typelist.append(tt)
882
884
883 # column labels and # of spaces as separator
885 # column labels and # of spaces as separator
884 varlabel = 'Variable'
886 varlabel = 'Variable'
885 typelabel = 'Type'
887 typelabel = 'Type'
886 datalabel = 'Data/Info'
888 datalabel = 'Data/Info'
887 colsep = 3
889 colsep = 3
888 # variable format strings
890 # variable format strings
889 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
891 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
890 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
892 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
891 aformat = "%s: %s elems, type `%s`, %s bytes"
893 aformat = "%s: %s elems, type `%s`, %s bytes"
892 # find the size of the columns to format the output nicely
894 # find the size of the columns to format the output nicely
893 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
895 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
894 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
896 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
895 # table header
897 # table header
896 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
898 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
897 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
899 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
898 # and the table itself
900 # and the table itself
899 kb = 1024
901 kb = 1024
900 Mb = 1048576 # kb**2
902 Mb = 1048576 # kb**2
901 for vname,var,vtype in zip(varnames,varlist,typelist):
903 for vname,var,vtype in zip(varnames,varlist,typelist):
902 print itpl(vformat),
904 print itpl(vformat),
903 if vtype in seq_types:
905 if vtype in seq_types:
904 print len(var)
906 print len(var)
905 elif vtype==array_type:
907 elif vtype==array_type:
906 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
908 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
907 vsize = Numeric.size(var)
909 vsize = Numeric.size(var)
908 vbytes = vsize*var.itemsize()
910 vbytes = vsize*var.itemsize()
909 if vbytes < 100000:
911 if vbytes < 100000:
910 print aformat % (vshape,vsize,var.typecode(),vbytes)
912 print aformat % (vshape,vsize,var.typecode(),vbytes)
911 else:
913 else:
912 print aformat % (vshape,vsize,var.typecode(),vbytes),
914 print aformat % (vshape,vsize,var.typecode(),vbytes),
913 if vbytes < Mb:
915 if vbytes < Mb:
914 print '(%s kb)' % (vbytes/kb,)
916 print '(%s kb)' % (vbytes/kb,)
915 else:
917 else:
916 print '(%s Mb)' % (vbytes/Mb,)
918 print '(%s Mb)' % (vbytes/Mb,)
917 else:
919 else:
918 vstr = str(var).replace('\n','\\n')
920 vstr = str(var).replace('\n','\\n')
919 if len(vstr) < 50:
921 if len(vstr) < 50:
920 print vstr
922 print vstr
921 else:
923 else:
922 printpl(vfmt_short)
924 printpl(vfmt_short)
923
925
924 def magic_reset(self, parameter_s=''):
926 def magic_reset(self, parameter_s=''):
925 """Resets the namespace by removing all names defined by the user.
927 """Resets the namespace by removing all names defined by the user.
926
928
927 Input/Output history are left around in case you need them."""
929 Input/Output history are left around in case you need them."""
928
930
929 ans = raw_input(
931 ans = raw_input(
930 "Once deleted, variables cannot be recovered. Proceed (y/n)? ")
932 "Once deleted, variables cannot be recovered. Proceed (y/n)? ")
931 if not ans.lower() == 'y':
933 if not ans.lower() == 'y':
932 print 'Nothing done.'
934 print 'Nothing done.'
933 return
935 return
934 user_ns = self.shell.user_ns
936 user_ns = self.shell.user_ns
935 for i in self.magic_who_ls():
937 for i in self.magic_who_ls():
936 del(user_ns[i])
938 del(user_ns[i])
937
939
938 def magic_config(self,parameter_s=''):
940 def magic_config(self,parameter_s=''):
939 """Show IPython's internal configuration."""
941 """Show IPython's internal configuration."""
940
942
941 page('Current configuration structure:\n'+
943 page('Current configuration structure:\n'+
942 pformat(self.shell.rc.dict()))
944 pformat(self.shell.rc.dict()))
943
945
944 def magic_logstart(self,parameter_s=''):
946 def magic_logstart(self,parameter_s=''):
945 """Start logging anywhere in a session.
947 """Start logging anywhere in a session.
946
948
947 %logstart [-o|-t] [log_name [log_mode]]
949 %logstart [-o|-t] [log_name [log_mode]]
948
950
949 If no name is given, it defaults to a file named 'ipython_log.py' in your
951 If no name is given, it defaults to a file named 'ipython_log.py' in your
950 current directory, in 'rotate' mode (see below).
952 current directory, in 'rotate' mode (see below).
951
953
952 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
954 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
953 history up to that point and then continues logging.
955 history up to that point and then continues logging.
954
956
955 %logstart takes a second optional parameter: logging mode. This can be one
957 %logstart takes a second optional parameter: logging mode. This can be one
956 of (note that the modes are given unquoted):\\
958 of (note that the modes are given unquoted):\\
957 append: well, that says it.\\
959 append: well, that says it.\\
958 backup: rename (if exists) to name~ and start name.\\
960 backup: rename (if exists) to name~ and start name.\\
959 global: single logfile in your home dir, appended to.\\
961 global: single logfile in your home dir, appended to.\\
960 over : overwrite existing log.\\
962 over : overwrite existing log.\\
961 rotate: create rotating logs name.1~, name.2~, etc.
963 rotate: create rotating logs name.1~, name.2~, etc.
962
964
963 Options:
965 Options:
964
966
965 -o: log also IPython's output. In this mode, all commands which
967 -o: log also IPython's output. In this mode, all commands which
966 generate an Out[NN] prompt are recorded to the logfile, right after
968 generate an Out[NN] prompt are recorded to the logfile, right after
967 their corresponding input line. The output lines are always
969 their corresponding input line. The output lines are always
968 prepended with a '#[Out]# ' marker, so that the log remains valid
970 prepended with a '#[Out]# ' marker, so that the log remains valid
969 Python code.
971 Python code.
970
972
971 Since this marker is always the same, filtering only the output from
973 Since this marker is always the same, filtering only the output from
972 a log is very easy, using for example a simple awk call:
974 a log is very easy, using for example a simple awk call:
973
975
974 awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py
976 awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py
975
977
976 -t: put timestamps before each input line logged (these are put in
978 -t: put timestamps before each input line logged (these are put in
977 comments)."""
979 comments)."""
978
980
979 opts,par = self.parse_options(parameter_s,'ot')
981 opts,par = self.parse_options(parameter_s,'ot')
980 log_output = 'o' in opts
982 log_output = 'o' in opts
981 timestamp = 't' in opts
983 timestamp = 't' in opts
982
984
983 rc = self.shell.rc
985 rc = self.shell.rc
984 logger = self.shell.logger
986 logger = self.shell.logger
985
987
986 # if no args are given, the defaults set in the logger constructor by
988 # if no args are given, the defaults set in the logger constructor by
987 # ipytohn remain valid
989 # ipytohn remain valid
988 if par:
990 if par:
989 try:
991 try:
990 logfname,logmode = par.split()
992 logfname,logmode = par.split()
991 except:
993 except:
992 logfname = par
994 logfname = par
993 logmode = 'backup'
995 logmode = 'backup'
994 else:
996 else:
995 logfname = logger.logfname
997 logfname = logger.logfname
996 logmode = logger.logmode
998 logmode = logger.logmode
997 # put logfname into rc struct as if it had been called on the command
999 # put logfname into rc struct as if it had been called on the command
998 # line, so it ends up saved in the log header Save it in case we need
1000 # line, so it ends up saved in the log header Save it in case we need
999 # to restore it...
1001 # to restore it...
1000 old_logfile = rc.opts.get('logfile','')
1002 old_logfile = rc.opts.get('logfile','')
1001 if logfname:
1003 if logfname:
1002 logfname = os.path.expanduser(logfname)
1004 logfname = os.path.expanduser(logfname)
1003 rc.opts.logfile = logfname
1005 rc.opts.logfile = logfname
1004 loghead = self.shell.loghead_tpl % (rc.opts,rc.args)
1006 loghead = self.shell.loghead_tpl % (rc.opts,rc.args)
1005 try:
1007 try:
1006 started = logger.logstart(logfname,loghead,logmode,
1008 started = logger.logstart(logfname,loghead,logmode,
1007 log_output,timestamp)
1009 log_output,timestamp)
1008 except:
1010 except:
1009 rc.opts.logfile = old_logfile
1011 rc.opts.logfile = old_logfile
1010 warn("Couldn't start log: %s" % sys.exc_info()[1])
1012 warn("Couldn't start log: %s" % sys.exc_info()[1])
1011 else:
1013 else:
1012 # log input history up to this point, optionally interleaving
1014 # log input history up to this point, optionally interleaving
1013 # output if requested
1015 # output if requested
1014
1016
1015 if timestamp:
1017 if timestamp:
1016 # disable timestamping for the previous history, since we've
1018 # disable timestamping for the previous history, since we've
1017 # lost those already (no time machine here).
1019 # lost those already (no time machine here).
1018 logger.timestamp = False
1020 logger.timestamp = False
1019 if log_output:
1021 if log_output:
1020 log_write = logger.log_write
1022 log_write = logger.log_write
1021 input_hist = self.shell.input_hist
1023 input_hist = self.shell.input_hist
1022 output_hist = self.shell.output_hist
1024 output_hist = self.shell.output_hist
1023 for n in range(1,len(input_hist)-1):
1025 for n in range(1,len(input_hist)-1):
1024 log_write(input_hist[n].rstrip())
1026 log_write(input_hist[n].rstrip())
1025 if n in output_hist:
1027 if n in output_hist:
1026 log_write(repr(output_hist[n]),'output')
1028 log_write(repr(output_hist[n]),'output')
1027 else:
1029 else:
1028 logger.log_write(self.shell.input_hist[1:])
1030 logger.log_write(self.shell.input_hist[1:])
1029 if timestamp:
1031 if timestamp:
1030 # re-enable timestamping
1032 # re-enable timestamping
1031 logger.timestamp = True
1033 logger.timestamp = True
1032
1034
1033 print ('Activating auto-logging. '
1035 print ('Activating auto-logging. '
1034 'Current session state plus future input saved.')
1036 'Current session state plus future input saved.')
1035 logger.logstate()
1037 logger.logstate()
1036
1038
1037 def magic_logoff(self,parameter_s=''):
1039 def magic_logoff(self,parameter_s=''):
1038 """Temporarily stop logging.
1040 """Temporarily stop logging.
1039
1041
1040 You must have previously started logging."""
1042 You must have previously started logging."""
1041 self.shell.logger.switch_log(0)
1043 self.shell.logger.switch_log(0)
1042
1044
1043 def magic_logon(self,parameter_s=''):
1045 def magic_logon(self,parameter_s=''):
1044 """Restart logging.
1046 """Restart logging.
1045
1047
1046 This function is for restarting logging which you've temporarily
1048 This function is for restarting logging which you've temporarily
1047 stopped with %logoff. For starting logging for the first time, you
1049 stopped with %logoff. For starting logging for the first time, you
1048 must use the %logstart function, which allows you to specify an
1050 must use the %logstart function, which allows you to specify an
1049 optional log filename."""
1051 optional log filename."""
1050
1052
1051 self.shell.logger.switch_log(1)
1053 self.shell.logger.switch_log(1)
1052
1054
1053 def magic_logstate(self,parameter_s=''):
1055 def magic_logstate(self,parameter_s=''):
1054 """Print the status of the logging system."""
1056 """Print the status of the logging system."""
1055
1057
1056 self.shell.logger.logstate()
1058 self.shell.logger.logstate()
1057
1059
1058 def magic_pdb(self, parameter_s=''):
1060 def magic_pdb(self, parameter_s=''):
1059 """Control the calling of the pdb interactive debugger.
1061 """Control the calling of the pdb interactive debugger.
1060
1062
1061 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1063 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1062 argument it works as a toggle.
1064 argument it works as a toggle.
1063
1065
1064 When an exception is triggered, IPython can optionally call the
1066 When an exception is triggered, IPython can optionally call the
1065 interactive pdb debugger after the traceback printout. %pdb toggles
1067 interactive pdb debugger after the traceback printout. %pdb toggles
1066 this feature on and off."""
1068 this feature on and off."""
1067
1069
1068 par = parameter_s.strip().lower()
1070 par = parameter_s.strip().lower()
1069
1071
1070 if par:
1072 if par:
1071 try:
1073 try:
1072 new_pdb = {'off':0,'0':0,'on':1,'1':1}[par]
1074 new_pdb = {'off':0,'0':0,'on':1,'1':1}[par]
1073 except KeyError:
1075 except KeyError:
1074 print ('Incorrect argument. Use on/1, off/0, '
1076 print ('Incorrect argument. Use on/1, off/0, '
1075 'or nothing for a toggle.')
1077 'or nothing for a toggle.')
1076 return
1078 return
1077 else:
1079 else:
1078 # toggle
1080 # toggle
1079 new_pdb = not self.shell.InteractiveTB.call_pdb
1081 new_pdb = not self.shell.InteractiveTB.call_pdb
1080
1082
1081 # set on the shell
1083 # set on the shell
1082 self.shell.call_pdb = new_pdb
1084 self.shell.call_pdb = new_pdb
1083 print 'Automatic pdb calling has been turned',on_off(new_pdb)
1085 print 'Automatic pdb calling has been turned',on_off(new_pdb)
1084
1086
1085 def magic_prun(self, parameter_s ='',user_mode=1,
1087 def magic_prun(self, parameter_s ='',user_mode=1,
1086 opts=None,arg_lst=None,prog_ns=None):
1088 opts=None,arg_lst=None,prog_ns=None):
1087
1089
1088 """Run a statement through the python code profiler.
1090 """Run a statement through the python code profiler.
1089
1091
1090 Usage:\\
1092 Usage:\\
1091 %prun [options] statement
1093 %prun [options] statement
1092
1094
1093 The given statement (which doesn't require quote marks) is run via the
1095 The given statement (which doesn't require quote marks) is run via the
1094 python profiler in a manner similar to the profile.run() function.
1096 python profiler in a manner similar to the profile.run() function.
1095 Namespaces are internally managed to work correctly; profile.run
1097 Namespaces are internally managed to work correctly; profile.run
1096 cannot be used in IPython because it makes certain assumptions about
1098 cannot be used in IPython because it makes certain assumptions about
1097 namespaces which do not hold under IPython.
1099 namespaces which do not hold under IPython.
1098
1100
1099 Options:
1101 Options:
1100
1102
1101 -l <limit>: you can place restrictions on what or how much of the
1103 -l <limit>: you can place restrictions on what or how much of the
1102 profile gets printed. The limit value can be:
1104 profile gets printed. The limit value can be:
1103
1105
1104 * A string: only information for function names containing this string
1106 * A string: only information for function names containing this string
1105 is printed.
1107 is printed.
1106
1108
1107 * An integer: only these many lines are printed.
1109 * An integer: only these many lines are printed.
1108
1110
1109 * A float (between 0 and 1): this fraction of the report is printed
1111 * A float (between 0 and 1): this fraction of the report is printed
1110 (for example, use a limit of 0.4 to see the topmost 40% only).
1112 (for example, use a limit of 0.4 to see the topmost 40% only).
1111
1113
1112 You can combine several limits with repeated use of the option. For
1114 You can combine several limits with repeated use of the option. For
1113 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1115 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1114 information about class constructors.
1116 information about class constructors.
1115
1117
1116 -r: return the pstats.Stats object generated by the profiling. This
1118 -r: return the pstats.Stats object generated by the profiling. This
1117 object has all the information about the profile in it, and you can
1119 object has all the information about the profile in it, and you can
1118 later use it for further analysis or in other functions.
1120 later use it for further analysis or in other functions.
1119
1121
1120 Since magic functions have a particular form of calling which prevents
1122 Since magic functions have a particular form of calling which prevents
1121 you from writing something like:\\
1123 you from writing something like:\\
1122 In [1]: p = %prun -r print 4 # invalid!\\
1124 In [1]: p = %prun -r print 4 # invalid!\\
1123 you must instead use IPython's automatic variables to assign this:\\
1125 you must instead use IPython's automatic variables to assign this:\\
1124 In [1]: %prun -r print 4 \\
1126 In [1]: %prun -r print 4 \\
1125 Out[1]: <pstats.Stats instance at 0x8222cec>\\
1127 Out[1]: <pstats.Stats instance at 0x8222cec>\\
1126 In [2]: stats = _
1128 In [2]: stats = _
1127
1129
1128 If you really need to assign this value via an explicit function call,
1130 If you really need to assign this value via an explicit function call,
1129 you can always tap directly into the true name of the magic function
1131 you can always tap directly into the true name of the magic function
1130 by using the ipmagic function (which IPython automatically adds to the
1132 by using the ipmagic function (which IPython automatically adds to the
1131 builtins):\\
1133 builtins):\\
1132 In [3]: stats = ipmagic('prun','-r print 4')
1134 In [3]: stats = ipmagic('prun','-r print 4')
1133
1135
1134 You can type ipmagic? for more details on ipmagic.
1136 You can type ipmagic? for more details on ipmagic.
1135
1137
1136 -s <key>: sort profile by given key. You can provide more than one key
1138 -s <key>: sort profile by given key. You can provide more than one key
1137 by using the option several times: '-s key1 -s key2 -s key3...'. The
1139 by using the option several times: '-s key1 -s key2 -s key3...'. The
1138 default sorting key is 'time'.
1140 default sorting key is 'time'.
1139
1141
1140 The following is copied verbatim from the profile documentation
1142 The following is copied verbatim from the profile documentation
1141 referenced below:
1143 referenced below:
1142
1144
1143 When more than one key is provided, additional keys are used as
1145 When more than one key is provided, additional keys are used as
1144 secondary criteria when the there is equality in all keys selected
1146 secondary criteria when the there is equality in all keys selected
1145 before them.
1147 before them.
1146
1148
1147 Abbreviations can be used for any key names, as long as the
1149 Abbreviations can be used for any key names, as long as the
1148 abbreviation is unambiguous. The following are the keys currently
1150 abbreviation is unambiguous. The following are the keys currently
1149 defined:
1151 defined:
1150
1152
1151 Valid Arg Meaning\\
1153 Valid Arg Meaning\\
1152 "calls" call count\\
1154 "calls" call count\\
1153 "cumulative" cumulative time\\
1155 "cumulative" cumulative time\\
1154 "file" file name\\
1156 "file" file name\\
1155 "module" file name\\
1157 "module" file name\\
1156 "pcalls" primitive call count\\
1158 "pcalls" primitive call count\\
1157 "line" line number\\
1159 "line" line number\\
1158 "name" function name\\
1160 "name" function name\\
1159 "nfl" name/file/line\\
1161 "nfl" name/file/line\\
1160 "stdname" standard name\\
1162 "stdname" standard name\\
1161 "time" internal time
1163 "time" internal time
1162
1164
1163 Note that all sorts on statistics are in descending order (placing
1165 Note that all sorts on statistics are in descending order (placing
1164 most time consuming items first), where as name, file, and line number
1166 most time consuming items first), where as name, file, and line number
1165 searches are in ascending order (i.e., alphabetical). The subtle
1167 searches are in ascending order (i.e., alphabetical). The subtle
1166 distinction between "nfl" and "stdname" is that the standard name is a
1168 distinction between "nfl" and "stdname" is that the standard name is a
1167 sort of the name as printed, which means that the embedded line
1169 sort of the name as printed, which means that the embedded line
1168 numbers get compared in an odd way. For example, lines 3, 20, and 40
1170 numbers get compared in an odd way. For example, lines 3, 20, and 40
1169 would (if the file names were the same) appear in the string order
1171 would (if the file names were the same) appear in the string order
1170 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1172 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1171 line numbers. In fact, sort_stats("nfl") is the same as
1173 line numbers. In fact, sort_stats("nfl") is the same as
1172 sort_stats("name", "file", "line").
1174 sort_stats("name", "file", "line").
1173
1175
1174 -T <filename>: save profile results as shown on screen to a text
1176 -T <filename>: save profile results as shown on screen to a text
1175 file. The profile is still shown on screen.
1177 file. The profile is still shown on screen.
1176
1178
1177 -D <filename>: save (via dump_stats) profile statistics to given
1179 -D <filename>: save (via dump_stats) profile statistics to given
1178 filename. This data is in a format understod by the pstats module, and
1180 filename. This data is in a format understod by the pstats module, and
1179 is generated by a call to the dump_stats() method of profile
1181 is generated by a call to the dump_stats() method of profile
1180 objects. The profile is still shown on screen.
1182 objects. The profile is still shown on screen.
1181
1183
1182 If you want to run complete programs under the profiler's control, use
1184 If you want to run complete programs under the profiler's control, use
1183 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1185 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1184 contains profiler specific options as described here.
1186 contains profiler specific options as described here.
1185
1187
1186 You can read the complete documentation for the profile module with:\\
1188 You can read the complete documentation for the profile module with:\\
1187 In [1]: import profile; profile.help() """
1189 In [1]: import profile; profile.help() """
1188
1190
1189 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1191 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1190 # protect user quote marks
1192 # protect user quote marks
1191 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1193 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1192
1194
1193 if user_mode: # regular user call
1195 if user_mode: # regular user call
1194 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1196 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1195 list_all=1)
1197 list_all=1)
1196 namespace = self.shell.user_ns
1198 namespace = self.shell.user_ns
1197 else: # called to run a program by %run -p
1199 else: # called to run a program by %run -p
1198 try:
1200 try:
1199 filename = get_py_filename(arg_lst[0])
1201 filename = get_py_filename(arg_lst[0])
1200 except IOError,msg:
1202 except IOError,msg:
1201 error(msg)
1203 error(msg)
1202 return
1204 return
1203
1205
1204 arg_str = 'execfile(filename,prog_ns)'
1206 arg_str = 'execfile(filename,prog_ns)'
1205 namespace = locals()
1207 namespace = locals()
1206
1208
1207 opts.merge(opts_def)
1209 opts.merge(opts_def)
1208
1210
1209 prof = profile.Profile()
1211 prof = profile.Profile()
1210 try:
1212 try:
1211 prof = prof.runctx(arg_str,namespace,namespace)
1213 prof = prof.runctx(arg_str,namespace,namespace)
1212 sys_exit = ''
1214 sys_exit = ''
1213 except SystemExit:
1215 except SystemExit:
1214 sys_exit = """*** SystemExit exception caught in code being profiled."""
1216 sys_exit = """*** SystemExit exception caught in code being profiled."""
1215
1217
1216 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1218 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1217
1219
1218 lims = opts.l
1220 lims = opts.l
1219 if lims:
1221 if lims:
1220 lims = [] # rebuild lims with ints/floats/strings
1222 lims = [] # rebuild lims with ints/floats/strings
1221 for lim in opts.l:
1223 for lim in opts.l:
1222 try:
1224 try:
1223 lims.append(int(lim))
1225 lims.append(int(lim))
1224 except ValueError:
1226 except ValueError:
1225 try:
1227 try:
1226 lims.append(float(lim))
1228 lims.append(float(lim))
1227 except ValueError:
1229 except ValueError:
1228 lims.append(lim)
1230 lims.append(lim)
1229
1231
1230 # trap output
1232 # trap output
1231 sys_stdout = sys.stdout
1233 sys_stdout = sys.stdout
1232 stdout_trap = StringIO()
1234 stdout_trap = StringIO()
1233 try:
1235 try:
1234 sys.stdout = stdout_trap
1236 sys.stdout = stdout_trap
1235 stats.print_stats(*lims)
1237 stats.print_stats(*lims)
1236 finally:
1238 finally:
1237 sys.stdout = sys_stdout
1239 sys.stdout = sys_stdout
1238 output = stdout_trap.getvalue()
1240 output = stdout_trap.getvalue()
1239 output = output.rstrip()
1241 output = output.rstrip()
1240
1242
1241 page(output,screen_lines=self.shell.rc.screen_length)
1243 page(output,screen_lines=self.shell.rc.screen_length)
1242 print sys_exit,
1244 print sys_exit,
1243
1245
1244 dump_file = opts.D[0]
1246 dump_file = opts.D[0]
1245 text_file = opts.T[0]
1247 text_file = opts.T[0]
1246 if dump_file:
1248 if dump_file:
1247 prof.dump_stats(dump_file)
1249 prof.dump_stats(dump_file)
1248 print '\n*** Profile stats marshalled to file',\
1250 print '\n*** Profile stats marshalled to file',\
1249 `dump_file`+'.',sys_exit
1251 `dump_file`+'.',sys_exit
1250 if text_file:
1252 if text_file:
1251 file(text_file,'w').write(output)
1253 file(text_file,'w').write(output)
1252 print '\n*** Profile printout saved to text file',\
1254 print '\n*** Profile printout saved to text file',\
1253 `text_file`+'.',sys_exit
1255 `text_file`+'.',sys_exit
1254
1256
1255 if opts.has_key('r'):
1257 if opts.has_key('r'):
1256 return stats
1258 return stats
1257 else:
1259 else:
1258 return None
1260 return None
1259
1261
1260 def magic_run(self, parameter_s ='',runner=None):
1262 def magic_run(self, parameter_s ='',runner=None):
1261 """Run the named file inside IPython as a program.
1263 """Run the named file inside IPython as a program.
1262
1264
1263 Usage:\\
1265 Usage:\\
1264 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1266 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1265
1267
1266 Parameters after the filename are passed as command-line arguments to
1268 Parameters after the filename are passed as command-line arguments to
1267 the program (put in sys.argv). Then, control returns to IPython's
1269 the program (put in sys.argv). Then, control returns to IPython's
1268 prompt.
1270 prompt.
1269
1271
1270 This is similar to running at a system prompt:\\
1272 This is similar to running at a system prompt:\\
1271 $ python file args\\
1273 $ python file args\\
1272 but with the advantage of giving you IPython's tracebacks, and of
1274 but with the advantage of giving you IPython's tracebacks, and of
1273 loading all variables into your interactive namespace for further use
1275 loading all variables into your interactive namespace for further use
1274 (unless -p is used, see below).
1276 (unless -p is used, see below).
1275
1277
1276 The file is executed in a namespace initially consisting only of
1278 The file is executed in a namespace initially consisting only of
1277 __name__=='__main__' and sys.argv constructed as indicated. It thus
1279 __name__=='__main__' and sys.argv constructed as indicated. It thus
1278 sees its environment as if it were being run as a stand-alone
1280 sees its environment as if it were being run as a stand-alone
1279 program. But after execution, the IPython interactive namespace gets
1281 program. But after execution, the IPython interactive namespace gets
1280 updated with all variables defined in the program (except for __name__
1282 updated with all variables defined in the program (except for __name__
1281 and sys.argv). This allows for very convenient loading of code for
1283 and sys.argv). This allows for very convenient loading of code for
1282 interactive work, while giving each program a 'clean sheet' to run in.
1284 interactive work, while giving each program a 'clean sheet' to run in.
1283
1285
1284 Options:
1286 Options:
1285
1287
1286 -n: __name__ is NOT set to '__main__', but to the running file's name
1288 -n: __name__ is NOT set to '__main__', but to the running file's name
1287 without extension (as python does under import). This allows running
1289 without extension (as python does under import). This allows running
1288 scripts and reloading the definitions in them without calling code
1290 scripts and reloading the definitions in them without calling code
1289 protected by an ' if __name__ == "__main__" ' clause.
1291 protected by an ' if __name__ == "__main__" ' clause.
1290
1292
1291 -i: run the file in IPython's namespace instead of an empty one. This
1293 -i: run the file in IPython's namespace instead of an empty one. This
1292 is useful if you are experimenting with code written in a text editor
1294 is useful if you are experimenting with code written in a text editor
1293 which depends on variables defined interactively.
1295 which depends on variables defined interactively.
1294
1296
1295 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1297 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1296 being run. This is particularly useful if IPython is being used to
1298 being run. This is particularly useful if IPython is being used to
1297 run unittests, which always exit with a sys.exit() call. In such
1299 run unittests, which always exit with a sys.exit() call. In such
1298 cases you are interested in the output of the test results, not in
1300 cases you are interested in the output of the test results, not in
1299 seeing a traceback of the unittest module.
1301 seeing a traceback of the unittest module.
1300
1302
1301 -t: print timing information at the end of the run. IPython will give
1303 -t: print timing information at the end of the run. IPython will give
1302 you an estimated CPU time consumption for your script, which under
1304 you an estimated CPU time consumption for your script, which under
1303 Unix uses the resource module to avoid the wraparound problems of
1305 Unix uses the resource module to avoid the wraparound problems of
1304 time.clock(). Under Unix, an estimate of time spent on system tasks
1306 time.clock(). Under Unix, an estimate of time spent on system tasks
1305 is also given (for Windows platforms this is reported as 0.0).
1307 is also given (for Windows platforms this is reported as 0.0).
1306
1308
1307 If -t is given, an additional -N<N> option can be given, where <N>
1309 If -t is given, an additional -N<N> option can be given, where <N>
1308 must be an integer indicating how many times you want the script to
1310 must be an integer indicating how many times you want the script to
1309 run. The final timing report will include total and per run results.
1311 run. The final timing report will include total and per run results.
1310
1312
1311 For example (testing the script uniq_stable.py):
1313 For example (testing the script uniq_stable.py):
1312
1314
1313 In [1]: run -t uniq_stable
1315 In [1]: run -t uniq_stable
1314
1316
1315 IPython CPU timings (estimated):\\
1317 IPython CPU timings (estimated):\\
1316 User : 0.19597 s.\\
1318 User : 0.19597 s.\\
1317 System: 0.0 s.\\
1319 System: 0.0 s.\\
1318
1320
1319 In [2]: run -t -N5 uniq_stable
1321 In [2]: run -t -N5 uniq_stable
1320
1322
1321 IPython CPU timings (estimated):\\
1323 IPython CPU timings (estimated):\\
1322 Total runs performed: 5\\
1324 Total runs performed: 5\\
1323 Times : Total Per run\\
1325 Times : Total Per run\\
1324 User : 0.910862 s, 0.1821724 s.\\
1326 User : 0.910862 s, 0.1821724 s.\\
1325 System: 0.0 s, 0.0 s.
1327 System: 0.0 s, 0.0 s.
1326
1328
1327 -d: run your program under the control of pdb, the Python debugger.
1329 -d: run your program under the control of pdb, the Python debugger.
1328 This allows you to execute your program step by step, watch variables,
1330 This allows you to execute your program step by step, watch variables,
1329 etc. Internally, what IPython does is similar to calling:
1331 etc. Internally, what IPython does is similar to calling:
1330
1332
1331 pdb.run('execfile("YOURFILENAME")')
1333 pdb.run('execfile("YOURFILENAME")')
1332
1334
1333 with a breakpoint set on line 1 of your file. You can change the line
1335 with a breakpoint set on line 1 of your file. You can change the line
1334 number for this automatic breakpoint to be <N> by using the -bN option
1336 number for this automatic breakpoint to be <N> by using the -bN option
1335 (where N must be an integer). For example:
1337 (where N must be an integer). For example:
1336
1338
1337 %run -d -b40 myscript
1339 %run -d -b40 myscript
1338
1340
1339 will set the first breakpoint at line 40 in myscript.py. Note that
1341 will set the first breakpoint at line 40 in myscript.py. Note that
1340 the first breakpoint must be set on a line which actually does
1342 the first breakpoint must be set on a line which actually does
1341 something (not a comment or docstring) for it to stop execution.
1343 something (not a comment or docstring) for it to stop execution.
1342
1344
1343 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1345 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1344 first enter 'c' (without qoutes) to start execution up to the first
1346 first enter 'c' (without qoutes) to start execution up to the first
1345 breakpoint.
1347 breakpoint.
1346
1348
1347 Entering 'help' gives information about the use of the debugger. You
1349 Entering 'help' gives information about the use of the debugger. You
1348 can easily see pdb's full documentation with "import pdb;pdb.help()"
1350 can easily see pdb's full documentation with "import pdb;pdb.help()"
1349 at a prompt.
1351 at a prompt.
1350
1352
1351 -p: run program under the control of the Python profiler module (which
1353 -p: run program under the control of the Python profiler module (which
1352 prints a detailed report of execution times, function calls, etc).
1354 prints a detailed report of execution times, function calls, etc).
1353
1355
1354 You can pass other options after -p which affect the behavior of the
1356 You can pass other options after -p which affect the behavior of the
1355 profiler itself. See the docs for %prun for details.
1357 profiler itself. See the docs for %prun for details.
1356
1358
1357 In this mode, the program's variables do NOT propagate back to the
1359 In this mode, the program's variables do NOT propagate back to the
1358 IPython interactive namespace (because they remain in the namespace
1360 IPython interactive namespace (because they remain in the namespace
1359 where the profiler executes them).
1361 where the profiler executes them).
1360
1362
1361 Internally this triggers a call to %prun, see its documentation for
1363 Internally this triggers a call to %prun, see its documentation for
1362 details on the options available specifically for profiling."""
1364 details on the options available specifically for profiling."""
1363
1365
1364 # get arguments and set sys.argv for program to be run.
1366 # get arguments and set sys.argv for program to be run.
1365 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1367 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1366 mode='list',list_all=1)
1368 mode='list',list_all=1)
1367
1369
1368 try:
1370 try:
1369 filename = get_py_filename(arg_lst[0])
1371 filename = get_py_filename(arg_lst[0])
1370 except IndexError:
1372 except IndexError:
1371 warn('you must provide at least a filename.')
1373 warn('you must provide at least a filename.')
1372 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1374 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1373 return
1375 return
1374 except IOError,msg:
1376 except IOError,msg:
1375 error(msg)
1377 error(msg)
1376 return
1378 return
1377
1379
1378 # Control the response to exit() calls made by the script being run
1380 # Control the response to exit() calls made by the script being run
1379 exit_ignore = opts.has_key('e')
1381 exit_ignore = opts.has_key('e')
1380
1382
1381 # Make sure that the running script gets a proper sys.argv as if it
1383 # Make sure that the running script gets a proper sys.argv as if it
1382 # were run from a system shell.
1384 # were run from a system shell.
1383 save_argv = sys.argv # save it for later restoring
1385 save_argv = sys.argv # save it for later restoring
1384 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1386 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1385
1387
1386 if opts.has_key('i'):
1388 if opts.has_key('i'):
1387 prog_ns = self.shell.user_ns
1389 prog_ns = self.shell.user_ns
1388 __name__save = self.shell.user_ns['__name__']
1390 __name__save = self.shell.user_ns['__name__']
1389 prog_ns['__name__'] = '__main__'
1391 prog_ns['__name__'] = '__main__'
1390 else:
1392 else:
1391 if opts.has_key('n'):
1393 if opts.has_key('n'):
1392 name = os.path.splitext(os.path.basename(filename))[0]
1394 name = os.path.splitext(os.path.basename(filename))[0]
1393 else:
1395 else:
1394 name = '__main__'
1396 name = '__main__'
1395 prog_ns = {'__name__':name}
1397 prog_ns = {'__name__':name}
1396
1398
1397 # pickle fix. See iplib for an explanation. But we need to make sure
1399 # pickle fix. See iplib for an explanation. But we need to make sure
1398 # that, if we overwrite __main__, we replace it at the end
1400 # that, if we overwrite __main__, we replace it at the end
1399 if prog_ns['__name__'] == '__main__':
1401 if prog_ns['__name__'] == '__main__':
1400 restore_main = sys.modules['__main__']
1402 restore_main = sys.modules['__main__']
1401 else:
1403 else:
1402 restore_main = False
1404 restore_main = False
1403
1405
1404 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1406 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1405
1407
1406 stats = None
1408 stats = None
1407 try:
1409 try:
1408 if opts.has_key('p'):
1410 if opts.has_key('p'):
1409 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1411 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1410 else:
1412 else:
1411 if opts.has_key('d'):
1413 if opts.has_key('d'):
1412 deb = Debugger.Pdb(self.shell.rc.colors)
1414 deb = Debugger.Pdb(self.shell.rc.colors)
1413 # reset Breakpoint state, which is moronically kept
1415 # reset Breakpoint state, which is moronically kept
1414 # in a class
1416 # in a class
1415 bdb.Breakpoint.next = 1
1417 bdb.Breakpoint.next = 1
1416 bdb.Breakpoint.bplist = {}
1418 bdb.Breakpoint.bplist = {}
1417 bdb.Breakpoint.bpbynumber = [None]
1419 bdb.Breakpoint.bpbynumber = [None]
1418 # Set an initial breakpoint to stop execution
1420 # Set an initial breakpoint to stop execution
1419 maxtries = 10
1421 maxtries = 10
1420 bp = int(opts.get('b',[1])[0])
1422 bp = int(opts.get('b',[1])[0])
1421 checkline = deb.checkline(filename,bp)
1423 checkline = deb.checkline(filename,bp)
1422 if not checkline:
1424 if not checkline:
1423 for bp in range(bp+1,bp+maxtries+1):
1425 for bp in range(bp+1,bp+maxtries+1):
1424 if deb.checkline(filename,bp):
1426 if deb.checkline(filename,bp):
1425 break
1427 break
1426 else:
1428 else:
1427 msg = ("\nI failed to find a valid line to set "
1429 msg = ("\nI failed to find a valid line to set "
1428 "a breakpoint\n"
1430 "a breakpoint\n"
1429 "after trying up to line: %s.\n"
1431 "after trying up to line: %s.\n"
1430 "Please set a valid breakpoint manually "
1432 "Please set a valid breakpoint manually "
1431 "with the -b option." % bp)
1433 "with the -b option." % bp)
1432 error(msg)
1434 error(msg)
1433 return
1435 return
1434 # if we find a good linenumber, set the breakpoint
1436 # if we find a good linenumber, set the breakpoint
1435 deb.do_break('%s:%s' % (filename,bp))
1437 deb.do_break('%s:%s' % (filename,bp))
1436 # Start file run
1438 # Start file run
1437 print "NOTE: Enter 'c' at the",
1439 print "NOTE: Enter 'c' at the",
1438 print "ipdb> prompt to start your script."
1440 print "ipdb> prompt to start your script."
1439 try:
1441 try:
1440 deb.run('execfile("%s")' % filename,prog_ns)
1442 deb.run('execfile("%s")' % filename,prog_ns)
1441 except:
1443 except:
1442 etype, value, tb = sys.exc_info()
1444 etype, value, tb = sys.exc_info()
1443 # Skip three frames in the traceback: the %run one,
1445 # Skip three frames in the traceback: the %run one,
1444 # one inside bdb.py, and the command-line typed by the
1446 # one inside bdb.py, and the command-line typed by the
1445 # user (run by exec in pdb itself).
1447 # user (run by exec in pdb itself).
1446 self.shell.InteractiveTB(etype,value,tb,tb_offset=3)
1448 self.shell.InteractiveTB(etype,value,tb,tb_offset=3)
1447 else:
1449 else:
1448 if runner is None:
1450 if runner is None:
1449 runner = self.shell.safe_execfile
1451 runner = self.shell.safe_execfile
1450 if opts.has_key('t'):
1452 if opts.has_key('t'):
1451 try:
1453 try:
1452 nruns = int(opts['N'][0])
1454 nruns = int(opts['N'][0])
1453 if nruns < 1:
1455 if nruns < 1:
1454 error('Number of runs must be >=1')
1456 error('Number of runs must be >=1')
1455 return
1457 return
1456 except (KeyError):
1458 except (KeyError):
1457 nruns = 1
1459 nruns = 1
1458 if nruns == 1:
1460 if nruns == 1:
1459 t0 = clock2()
1461 t0 = clock2()
1460 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1462 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1461 t1 = clock2()
1463 t1 = clock2()
1462 t_usr = t1[0]-t0[0]
1464 t_usr = t1[0]-t0[0]
1463 t_sys = t1[1]-t1[1]
1465 t_sys = t1[1]-t1[1]
1464 print "\nIPython CPU timings (estimated):"
1466 print "\nIPython CPU timings (estimated):"
1465 print " User : %10s s." % t_usr
1467 print " User : %10s s." % t_usr
1466 print " System: %10s s." % t_sys
1468 print " System: %10s s." % t_sys
1467 else:
1469 else:
1468 runs = range(nruns)
1470 runs = range(nruns)
1469 t0 = clock2()
1471 t0 = clock2()
1470 for nr in runs:
1472 for nr in runs:
1471 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1473 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1472 t1 = clock2()
1474 t1 = clock2()
1473 t_usr = t1[0]-t0[0]
1475 t_usr = t1[0]-t0[0]
1474 t_sys = t1[1]-t1[1]
1476 t_sys = t1[1]-t1[1]
1475 print "\nIPython CPU timings (estimated):"
1477 print "\nIPython CPU timings (estimated):"
1476 print "Total runs performed:",nruns
1478 print "Total runs performed:",nruns
1477 print " Times : %10s %10s" % ('Total','Per run')
1479 print " Times : %10s %10s" % ('Total','Per run')
1478 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1480 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1479 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1481 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1480
1482
1481 else:
1483 else:
1482 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1484 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1483 if opts.has_key('i'):
1485 if opts.has_key('i'):
1484 self.shell.user_ns['__name__'] = __name__save
1486 self.shell.user_ns['__name__'] = __name__save
1485 else:
1487 else:
1486 # update IPython interactive namespace
1488 # update IPython interactive namespace
1487 del prog_ns['__name__']
1489 del prog_ns['__name__']
1488 self.shell.user_ns.update(prog_ns)
1490 self.shell.user_ns.update(prog_ns)
1489 finally:
1491 finally:
1490 sys.argv = save_argv
1492 sys.argv = save_argv
1491 if restore_main:
1493 if restore_main:
1492 sys.modules['__main__'] = restore_main
1494 sys.modules['__main__'] = restore_main
1493 return stats
1495 return stats
1494
1496
1495 def magic_runlog(self, parameter_s =''):
1497 def magic_runlog(self, parameter_s =''):
1496 """Run files as logs.
1498 """Run files as logs.
1497
1499
1498 Usage:\\
1500 Usage:\\
1499 %runlog file1 file2 ...
1501 %runlog file1 file2 ...
1500
1502
1501 Run the named files (treating them as log files) in sequence inside
1503 Run the named files (treating them as log files) in sequence inside
1502 the interpreter, and return to the prompt. This is much slower than
1504 the interpreter, and return to the prompt. This is much slower than
1503 %run because each line is executed in a try/except block, but it
1505 %run because each line is executed in a try/except block, but it
1504 allows running files with syntax errors in them.
1506 allows running files with syntax errors in them.
1505
1507
1506 Normally IPython will guess when a file is one of its own logfiles, so
1508 Normally IPython will guess when a file is one of its own logfiles, so
1507 you can typically use %run even for logs. This shorthand allows you to
1509 you can typically use %run even for logs. This shorthand allows you to
1508 force any file to be treated as a log file."""
1510 force any file to be treated as a log file."""
1509
1511
1510 for f in parameter_s.split():
1512 for f in parameter_s.split():
1511 self.shell.safe_execfile(f,self.shell.user_ns,
1513 self.shell.safe_execfile(f,self.shell.user_ns,
1512 self.shell.user_ns,islog=1)
1514 self.shell.user_ns,islog=1)
1513
1515
1514 def magic_time(self,parameter_s = ''):
1516 def magic_time(self,parameter_s = ''):
1515 """Time execution of a Python statement or expression.
1517 """Time execution of a Python statement or expression.
1516
1518
1517 The CPU and wall clock times are printed, and the value of the
1519 The CPU and wall clock times are printed, and the value of the
1518 expression (if any) is returned. Note that under Win32, system time
1520 expression (if any) is returned. Note that under Win32, system time
1519 is always reported as 0, since it can not be measured.
1521 is always reported as 0, since it can not be measured.
1520
1522
1521 This function provides very basic timing functionality. In Python
1523 This function provides very basic timing functionality. In Python
1522 2.3, the timeit module offers more control and sophistication, but for
1524 2.3, the timeit module offers more control and sophistication, but for
1523 now IPython supports Python 2.2, so we can not rely on timeit being
1525 now IPython supports Python 2.2, so we can not rely on timeit being
1524 present.
1526 present.
1525
1527
1526 Some examples:
1528 Some examples:
1527
1529
1528 In [1]: time 2**128
1530 In [1]: time 2**128
1529 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1531 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1530 Wall time: 0.00
1532 Wall time: 0.00
1531 Out[1]: 340282366920938463463374607431768211456L
1533 Out[1]: 340282366920938463463374607431768211456L
1532
1534
1533 In [2]: n = 1000000
1535 In [2]: n = 1000000
1534
1536
1535 In [3]: time sum(range(n))
1537 In [3]: time sum(range(n))
1536 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1538 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1537 Wall time: 1.37
1539 Wall time: 1.37
1538 Out[3]: 499999500000L
1540 Out[3]: 499999500000L
1539
1541
1540 In [4]: time print 'hello world'
1542 In [4]: time print 'hello world'
1541 hello world
1543 hello world
1542 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1544 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1543 Wall time: 0.00
1545 Wall time: 0.00
1544 """
1546 """
1545
1547
1546 # fail immediately if the given expression can't be compiled
1548 # fail immediately if the given expression can't be compiled
1547 try:
1549 try:
1548 mode = 'eval'
1550 mode = 'eval'
1549 code = compile(parameter_s,'<timed eval>',mode)
1551 code = compile(parameter_s,'<timed eval>',mode)
1550 except SyntaxError:
1552 except SyntaxError:
1551 mode = 'exec'
1553 mode = 'exec'
1552 code = compile(parameter_s,'<timed exec>',mode)
1554 code = compile(parameter_s,'<timed exec>',mode)
1553 # skew measurement as little as possible
1555 # skew measurement as little as possible
1554 glob = self.shell.user_ns
1556 glob = self.shell.user_ns
1555 clk = clock2
1557 clk = clock2
1556 wtime = time.time
1558 wtime = time.time
1557 # time execution
1559 # time execution
1558 wall_st = wtime()
1560 wall_st = wtime()
1559 if mode=='eval':
1561 if mode=='eval':
1560 st = clk()
1562 st = clk()
1561 out = eval(code,glob)
1563 out = eval(code,glob)
1562 end = clk()
1564 end = clk()
1563 else:
1565 else:
1564 st = clk()
1566 st = clk()
1565 exec code in glob
1567 exec code in glob
1566 end = clk()
1568 end = clk()
1567 out = None
1569 out = None
1568 wall_end = wtime()
1570 wall_end = wtime()
1569 # Compute actual times and report
1571 # Compute actual times and report
1570 wall_time = wall_end-wall_st
1572 wall_time = wall_end-wall_st
1571 cpu_user = end[0]-st[0]
1573 cpu_user = end[0]-st[0]
1572 cpu_sys = end[1]-st[1]
1574 cpu_sys = end[1]-st[1]
1573 cpu_tot = cpu_user+cpu_sys
1575 cpu_tot = cpu_user+cpu_sys
1574 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1576 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1575 (cpu_user,cpu_sys,cpu_tot)
1577 (cpu_user,cpu_sys,cpu_tot)
1576 print "Wall time: %.2f" % wall_time
1578 print "Wall time: %.2f" % wall_time
1577 return out
1579 return out
1578
1580
1579 def magic_macro(self,parameter_s = ''):
1581 def magic_macro(self,parameter_s = ''):
1580 """Define a set of input lines as a macro for future re-execution.
1582 """Define a set of input lines as a macro for future re-execution.
1581
1583
1582 Usage:\\
1584 Usage:\\
1583 %macro name n1-n2 n3-n4 ... n5 .. n6 ...
1585 %macro name n1-n2 n3-n4 ... n5 .. n6 ...
1584
1586
1585 This will define a global variable called `name` which is a string
1587 This will define a global variable called `name` which is a string
1586 made of joining the slices and lines you specify (n1,n2,... numbers
1588 made of joining the slices and lines you specify (n1,n2,... numbers
1587 above) from your input history into a single string. This variable
1589 above) from your input history into a single string. This variable
1588 acts like an automatic function which re-executes those lines as if
1590 acts like an automatic function which re-executes those lines as if
1589 you had typed them. You just type 'name' at the prompt and the code
1591 you had typed them. You just type 'name' at the prompt and the code
1590 executes.
1592 executes.
1591
1593
1592 The notation for indicating number ranges is: n1-n2 means 'use line
1594 The notation for indicating number ranges is: n1-n2 means 'use line
1593 numbers n1,...n2' (the endpoint is included). That is, '5-7' means
1595 numbers n1,...n2' (the endpoint is included). That is, '5-7' means
1594 using the lines numbered 5,6 and 7.
1596 using the lines numbered 5,6 and 7.
1595
1597
1596 Note: as a 'hidden' feature, you can also use traditional python slice
1598 Note: as a 'hidden' feature, you can also use traditional python slice
1597 notation, where N:M means numbers N through M-1.
1599 notation, where N:M means numbers N through M-1.
1598
1600
1599 For example, if your history contains (%hist prints it):
1601 For example, if your history contains (%hist prints it):
1600
1602
1601 44: x=1\\
1603 44: x=1\\
1602 45: y=3\\
1604 45: y=3\\
1603 46: z=x+y\\
1605 46: z=x+y\\
1604 47: print x\\
1606 47: print x\\
1605 48: a=5\\
1607 48: a=5\\
1606 49: print 'x',x,'y',y\\
1608 49: print 'x',x,'y',y\\
1607
1609
1608 you can create a macro with lines 44 through 47 (included) and line 49
1610 you can create a macro with lines 44 through 47 (included) and line 49
1609 called my_macro with:
1611 called my_macro with:
1610
1612
1611 In [51]: %macro my_macro 44-47 49
1613 In [51]: %macro my_macro 44-47 49
1612
1614
1613 Now, typing `my_macro` (without quotes) will re-execute all this code
1615 Now, typing `my_macro` (without quotes) will re-execute all this code
1614 in one pass.
1616 in one pass.
1615
1617
1616 You don't need to give the line-numbers in order, and any given line
1618 You don't need to give the line-numbers in order, and any given line
1617 number can appear multiple times. You can assemble macros with any
1619 number can appear multiple times. You can assemble macros with any
1618 lines from your input history in any order.
1620 lines from your input history in any order.
1619
1621
1620 The macro is a simple object which holds its value in an attribute,
1622 The macro is a simple object which holds its value in an attribute,
1621 but IPython's display system checks for macros and executes them as
1623 but IPython's display system checks for macros and executes them as
1622 code instead of printing them when you type their name.
1624 code instead of printing them when you type their name.
1623
1625
1624 You can view a macro's contents by explicitly printing it with:
1626 You can view a macro's contents by explicitly printing it with:
1625
1627
1626 'print macro_name'.
1628 'print macro_name'.
1627
1629
1628 For one-off cases which DON'T contain magic function calls in them you
1630 For one-off cases which DON'T contain magic function calls in them you
1629 can obtain similar results by explicitly executing slices from your
1631 can obtain similar results by explicitly executing slices from your
1630 input history with:
1632 input history with:
1631
1633
1632 In [60]: exec In[44:48]+In[49]"""
1634 In [60]: exec In[44:48]+In[49]"""
1633
1635
1634 args = parameter_s.split()
1636 args = parameter_s.split()
1635 name,ranges = args[0], args[1:]
1637 name,ranges = args[0], args[1:]
1636 #print 'rng',ranges # dbg
1638 #print 'rng',ranges # dbg
1637 lines = self.extract_input_slices(ranges)
1639 lines = self.extract_input_slices(ranges)
1638 macro = Macro(lines)
1640 macro = Macro(lines)
1639 self.shell.user_ns.update({name:macro})
1641 self.shell.user_ns.update({name:macro})
1640 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1642 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1641 print 'Macro contents:'
1643 print 'Macro contents:'
1642 print macro,
1644 print macro,
1643
1645
1644 def magic_save(self,parameter_s = ''):
1646 def magic_save(self,parameter_s = ''):
1645 """Save a set of lines to a given filename.
1647 """Save a set of lines to a given filename.
1646
1648
1647 Usage:\\
1649 Usage:\\
1648 %save filename n1-n2 n3-n4 ... n5 .. n6 ...
1650 %save filename n1-n2 n3-n4 ... n5 .. n6 ...
1649
1651
1650 This function uses the same syntax as %macro for line extraction, but
1652 This function uses the same syntax as %macro for line extraction, but
1651 instead of creating a macro it saves the resulting string to the
1653 instead of creating a macro it saves the resulting string to the
1652 filename you specify.
1654 filename you specify.
1653
1655
1654 It adds a '.py' extension to the file if you don't do so yourself, and
1656 It adds a '.py' extension to the file if you don't do so yourself, and
1655 it asks for confirmation before overwriting existing files."""
1657 it asks for confirmation before overwriting existing files."""
1656
1658
1657 args = parameter_s.split()
1659 args = parameter_s.split()
1658 fname,ranges = args[0], args[1:]
1660 fname,ranges = args[0], args[1:]
1659 if not fname.endswith('.py'):
1661 if not fname.endswith('.py'):
1660 fname += '.py'
1662 fname += '.py'
1661 if os.path.isfile(fname):
1663 if os.path.isfile(fname):
1662 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1664 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1663 if ans.lower() not in ['y','yes']:
1665 if ans.lower() not in ['y','yes']:
1664 print 'Operation cancelled.'
1666 print 'Operation cancelled.'
1665 return
1667 return
1666 cmds = ''.join(self.extract_input_slices(ranges))
1668 cmds = ''.join(self.extract_input_slices(ranges))
1667 f = file(fname,'w')
1669 f = file(fname,'w')
1668 f.write(cmds)
1670 f.write(cmds)
1669 f.close()
1671 f.close()
1670 print 'The following commands were written to file `%s`:' % fname
1672 print 'The following commands were written to file `%s`:' % fname
1671 print cmds
1673 print cmds
1672
1674
1673 def _edit_macro(self,mname,macro):
1675 def _edit_macro(self,mname,macro):
1674 """open an editor with the macro data in a file"""
1676 """open an editor with the macro data in a file"""
1675 filename = self.shell.mktempfile(macro.value)
1677 filename = self.shell.mktempfile(macro.value)
1676 self.shell.hooks.editor(filename)
1678 self.shell.hooks.editor(filename)
1677
1679
1678 # and make a new macro object, to replace the old one
1680 # and make a new macro object, to replace the old one
1679 mfile = open(filename)
1681 mfile = open(filename)
1680 mvalue = mfile.read()
1682 mvalue = mfile.read()
1681 mfile.close()
1683 mfile.close()
1682 self.shell.user_ns[mname] = Macro(mvalue)
1684 self.shell.user_ns[mname] = Macro(mvalue)
1683
1685
1684 def magic_ed(self,parameter_s=''):
1686 def magic_ed(self,parameter_s=''):
1685 """Alias to %edit."""
1687 """Alias to %edit."""
1686 return self.magic_edit(parameter_s)
1688 return self.magic_edit(parameter_s)
1687
1689
1688 def magic_edit(self,parameter_s='',last_call=['','']):
1690 def magic_edit(self,parameter_s='',last_call=['','']):
1689 """Bring up an editor and execute the resulting code.
1691 """Bring up an editor and execute the resulting code.
1690
1692
1691 Usage:
1693 Usage:
1692 %edit [options] [args]
1694 %edit [options] [args]
1693
1695
1694 %edit runs IPython's editor hook. The default version of this hook is
1696 %edit runs IPython's editor hook. The default version of this hook is
1695 set to call the __IPYTHON__.rc.editor command. This is read from your
1697 set to call the __IPYTHON__.rc.editor command. This is read from your
1696 environment variable $EDITOR. If this isn't found, it will default to
1698 environment variable $EDITOR. If this isn't found, it will default to
1697 vi under Linux/Unix and to notepad under Windows. See the end of this
1699 vi under Linux/Unix and to notepad under Windows. See the end of this
1698 docstring for how to change the editor hook.
1700 docstring for how to change the editor hook.
1699
1701
1700 You can also set the value of this editor via the command line option
1702 You can also set the value of this editor via the command line option
1701 '-editor' or in your ipythonrc file. This is useful if you wish to use
1703 '-editor' or in your ipythonrc file. This is useful if you wish to use
1702 specifically for IPython an editor different from your typical default
1704 specifically for IPython an editor different from your typical default
1703 (and for Windows users who typically don't set environment variables).
1705 (and for Windows users who typically don't set environment variables).
1704
1706
1705 This command allows you to conveniently edit multi-line code right in
1707 This command allows you to conveniently edit multi-line code right in
1706 your IPython session.
1708 your IPython session.
1707
1709
1708 If called without arguments, %edit opens up an empty editor with a
1710 If called without arguments, %edit opens up an empty editor with a
1709 temporary file and will execute the contents of this file when you
1711 temporary file and will execute the contents of this file when you
1710 close it (don't forget to save it!).
1712 close it (don't forget to save it!).
1711
1713
1714
1712 Options:
1715 Options:
1713
1716
1714 -p: this will call the editor with the same data as the previous time
1717 -p: this will call the editor with the same data as the previous time
1715 it was used, regardless of how long ago (in your current session) it
1718 it was used, regardless of how long ago (in your current session) it
1716 was.
1719 was.
1717
1720
1718 -x: do not execute the edited code immediately upon exit. This is
1721 -x: do not execute the edited code immediately upon exit. This is
1719 mainly useful if you are editing programs which need to be called with
1722 mainly useful if you are editing programs which need to be called with
1720 command line arguments, which you can then do using %run.
1723 command line arguments, which you can then do using %run.
1721
1724
1725
1722 Arguments:
1726 Arguments:
1723
1727
1724 If arguments are given, the following possibilites exist:
1728 If arguments are given, the following possibilites exist:
1725
1729
1726 - The arguments are numbers or pairs of colon-separated numbers (like
1730 - The arguments are numbers or pairs of colon-separated numbers (like
1727 1 4:8 9). These are interpreted as lines of previous input to be
1731 1 4:8 9). These are interpreted as lines of previous input to be
1728 loaded into the editor. The syntax is the same of the %macro command.
1732 loaded into the editor. The syntax is the same of the %macro command.
1729
1733
1730 - If the argument doesn't start with a number, it is evaluated as a
1734 - If the argument doesn't start with a number, it is evaluated as a
1731 variable and its contents loaded into the editor. You can thus edit
1735 variable and its contents loaded into the editor. You can thus edit
1732 any string which contains python code (including the result of
1736 any string which contains python code (including the result of
1733 previous edits).
1737 previous edits).
1734
1738
1735 - If the argument is the name of an object (other than a string),
1739 - If the argument is the name of an object (other than a string),
1736 IPython will try to locate the file where it was defined and open the
1740 IPython will try to locate the file where it was defined and open the
1737 editor at the point where it is defined. You can use `%edit function`
1741 editor at the point where it is defined. You can use `%edit function`
1738 to load an editor exactly at the point where 'function' is defined,
1742 to load an editor exactly at the point where 'function' is defined,
1739 edit it and have the file be executed automatically.
1743 edit it and have the file be executed automatically.
1740
1744
1741 If the object is a macro (see %macro for details), this opens up your
1745 If the object is a macro (see %macro for details), this opens up your
1742 specified editor with a temporary file containing the macro's data.
1746 specified editor with a temporary file containing the macro's data.
1743 Upon exit, the macro is reloaded with the contents of the file.
1747 Upon exit, the macro is reloaded with the contents of the file.
1744
1748
1745 Note: opening at an exact line is only supported under Unix, and some
1749 Note: opening at an exact line is only supported under Unix, and some
1746 editors (like kedit and gedit up to Gnome 2.8) do not understand the
1750 editors (like kedit and gedit up to Gnome 2.8) do not understand the
1747 '+NUMBER' parameter necessary for this feature. Good editors like
1751 '+NUMBER' parameter necessary for this feature. Good editors like
1748 (X)Emacs, vi, jed, pico and joe all do.
1752 (X)Emacs, vi, jed, pico and joe all do.
1749
1753
1750 - If the argument is not found as a variable, IPython will look for a
1754 - If the argument is not found as a variable, IPython will look for a
1751 file with that name (adding .py if necessary) and load it into the
1755 file with that name (adding .py if necessary) and load it into the
1752 editor. It will execute its contents with execfile() when you exit,
1756 editor. It will execute its contents with execfile() when you exit,
1753 loading any code in the file into your interactive namespace.
1757 loading any code in the file into your interactive namespace.
1754
1758
1755 After executing your code, %edit will return as output the code you
1759 After executing your code, %edit will return as output the code you
1756 typed in the editor (except when it was an existing file). This way
1760 typed in the editor (except when it was an existing file). This way
1757 you can reload the code in further invocations of %edit as a variable,
1761 you can reload the code in further invocations of %edit as a variable,
1758 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
1762 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
1759 the output.
1763 the output.
1760
1764
1761 Note that %edit is also available through the alias %ed.
1765 Note that %edit is also available through the alias %ed.
1762
1766
1763 This is an example of creating a simple function inside the editor and
1767 This is an example of creating a simple function inside the editor and
1764 then modifying it. First, start up the editor:
1768 then modifying it. First, start up the editor:
1765
1769
1766 In [1]: ed\\
1770 In [1]: ed\\
1767 Editing... done. Executing edited code...\\
1771 Editing... done. Executing edited code...\\
1768 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
1772 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
1769
1773
1770 We can then call the function foo():
1774 We can then call the function foo():
1771
1775
1772 In [2]: foo()\\
1776 In [2]: foo()\\
1773 foo() was defined in an editing session
1777 foo() was defined in an editing session
1774
1778
1775 Now we edit foo. IPython automatically loads the editor with the
1779 Now we edit foo. IPython automatically loads the editor with the
1776 (temporary) file where foo() was previously defined:
1780 (temporary) file where foo() was previously defined:
1777
1781
1778 In [3]: ed foo\\
1782 In [3]: ed foo\\
1779 Editing... done. Executing edited code...
1783 Editing... done. Executing edited code...
1780
1784
1781 And if we call foo() again we get the modified version:
1785 And if we call foo() again we get the modified version:
1782
1786
1783 In [4]: foo()\\
1787 In [4]: foo()\\
1784 foo() has now been changed!
1788 foo() has now been changed!
1785
1789
1786 Here is an example of how to edit a code snippet successive
1790 Here is an example of how to edit a code snippet successive
1787 times. First we call the editor:
1791 times. First we call the editor:
1788
1792
1789 In [8]: ed\\
1793 In [8]: ed\\
1790 Editing... done. Executing edited code...\\
1794 Editing... done. Executing edited code...\\
1791 hello\\
1795 hello\\
1792 Out[8]: "print 'hello'\\n"
1796 Out[8]: "print 'hello'\\n"
1793
1797
1794 Now we call it again with the previous output (stored in _):
1798 Now we call it again with the previous output (stored in _):
1795
1799
1796 In [9]: ed _\\
1800 In [9]: ed _\\
1797 Editing... done. Executing edited code...\\
1801 Editing... done. Executing edited code...\\
1798 hello world\\
1802 hello world\\
1799 Out[9]: "print 'hello world'\\n"
1803 Out[9]: "print 'hello world'\\n"
1800
1804
1801 Now we call it with the output #8 (stored in _8, also as Out[8]):
1805 Now we call it with the output #8 (stored in _8, also as Out[8]):
1802
1806
1803 In [10]: ed _8\\
1807 In [10]: ed _8\\
1804 Editing... done. Executing edited code...\\
1808 Editing... done. Executing edited code...\\
1805 hello again\\
1809 hello again\\
1806 Out[10]: "print 'hello again'\\n"
1810 Out[10]: "print 'hello again'\\n"
1807
1811
1808
1812
1809 Changing the default editor hook:
1813 Changing the default editor hook:
1810
1814
1811 If you wish to write your own editor hook, you can put it in a
1815 If you wish to write your own editor hook, you can put it in a
1812 configuration file which you load at startup time. The default hook
1816 configuration file which you load at startup time. The default hook
1813 is defined in the IPython.hooks module, and you can use that as a
1817 is defined in the IPython.hooks module, and you can use that as a
1814 starting example for further modifications. That file also has
1818 starting example for further modifications. That file also has
1815 general instructions on how to set a new hook for use once you've
1819 general instructions on how to set a new hook for use once you've
1816 defined it."""
1820 defined it."""
1817
1821
1818 # FIXME: This function has become a convoluted mess. It needs a
1822 # FIXME: This function has become a convoluted mess. It needs a
1819 # ground-up rewrite with clean, simple logic.
1823 # ground-up rewrite with clean, simple logic.
1820
1824
1821 def make_filename(arg):
1825 def make_filename(arg):
1822 "Make a filename from the given args"
1826 "Make a filename from the given args"
1823 try:
1827 try:
1824 filename = get_py_filename(arg)
1828 filename = get_py_filename(arg)
1825 except IOError:
1829 except IOError:
1826 if args.endswith('.py'):
1830 if args.endswith('.py'):
1827 filename = arg
1831 filename = arg
1828 else:
1832 else:
1829 filename = None
1833 filename = None
1830 return filename
1834 return filename
1831
1835
1832 # custom exceptions
1836 # custom exceptions
1833 class DataIsObject(Exception): pass
1837 class DataIsObject(Exception): pass
1834
1838
1835 opts,args = self.parse_options(parameter_s,'px')
1839 opts,args = self.parse_options(parameter_s,'px')
1836
1840
1837 # Default line number value
1841 # Default line number value
1838 lineno = None
1842 lineno = None
1839 if opts.has_key('p'):
1843 if opts.has_key('p'):
1840 args = '_%s' % last_call[0]
1844 args = '_%s' % last_call[0]
1841 if not self.shell.user_ns.has_key(args):
1845 if not self.shell.user_ns.has_key(args):
1842 args = last_call[1]
1846 args = last_call[1]
1843
1847
1844 # use last_call to remember the state of the previous call, but don't
1848 # use last_call to remember the state of the previous call, but don't
1845 # let it be clobbered by successive '-p' calls.
1849 # let it be clobbered by successive '-p' calls.
1846 try:
1850 try:
1847 last_call[0] = self.shell.outputcache.prompt_count
1851 last_call[0] = self.shell.outputcache.prompt_count
1848 if not opts.has_key('p'):
1852 if not opts.has_key('p'):
1849 last_call[1] = parameter_s
1853 last_call[1] = parameter_s
1850 except:
1854 except:
1851 pass
1855 pass
1852
1856
1853 # by default this is done with temp files, except when the given
1857 # by default this is done with temp files, except when the given
1854 # arg is a filename
1858 # arg is a filename
1855 use_temp = 1
1859 use_temp = 1
1856
1860
1857 if re.match(r'\d',args):
1861 if re.match(r'\d',args):
1858 # Mode where user specifies ranges of lines, like in %macro.
1862 # Mode where user specifies ranges of lines, like in %macro.
1859 # This means that you can't edit files whose names begin with
1863 # This means that you can't edit files whose names begin with
1860 # numbers this way. Tough.
1864 # numbers this way. Tough.
1861 ranges = args.split()
1865 ranges = args.split()
1862 data = ''.join(self.extract_input_slices(ranges))
1866 data = ''.join(self.extract_input_slices(ranges))
1863 elif args.endswith('.py'):
1867 elif args.endswith('.py'):
1864 filename = make_filename(args)
1868 filename = make_filename(args)
1865 data = ''
1869 data = ''
1866 use_temp = 0
1870 use_temp = 0
1867 elif args:
1871 elif args:
1868 try:
1872 try:
1869 # Load the parameter given as a variable. If not a string,
1873 # Load the parameter given as a variable. If not a string,
1870 # process it as an object instead (below)
1874 # process it as an object instead (below)
1871
1875
1872 #print '*** args',args,'type',type(args) # dbg
1876 #print '*** args',args,'type',type(args) # dbg
1873 data = eval(args,self.shell.user_ns)
1877 data = eval(args,self.shell.user_ns)
1874 if not type(data) in StringTypes:
1878 if not type(data) in StringTypes:
1875 raise DataIsObject
1879 raise DataIsObject
1876
1880
1877 except (NameError,SyntaxError):
1881 except (NameError,SyntaxError):
1878 # given argument is not a variable, try as a filename
1882 # given argument is not a variable, try as a filename
1879 filename = make_filename(args)
1883 filename = make_filename(args)
1880 if filename is None:
1884 if filename is None:
1881 warn("Argument given (%s) can't be found as a variable "
1885 warn("Argument given (%s) can't be found as a variable "
1882 "or as a filename." % args)
1886 "or as a filename." % args)
1883 return
1887 return
1884
1888
1885 data = ''
1889 data = ''
1886 use_temp = 0
1890 use_temp = 0
1887 except DataIsObject:
1891 except DataIsObject:
1888
1892
1889 # macros have a special edit function
1893 # macros have a special edit function
1890 if isinstance(data,Macro):
1894 if isinstance(data,Macro):
1891 self._edit_macro(args,data)
1895 self._edit_macro(args,data)
1892 return
1896 return
1893
1897
1894 # For objects, try to edit the file where they are defined
1898 # For objects, try to edit the file where they are defined
1895 try:
1899 try:
1896 filename = inspect.getabsfile(data)
1900 filename = inspect.getabsfile(data)
1897 datafile = 1
1901 datafile = 1
1898 except TypeError:
1902 except TypeError:
1899 filename = make_filename(args)
1903 filename = make_filename(args)
1900 datafile = 1
1904 datafile = 1
1901 warn('Could not find file where `%s` is defined.\n'
1905 warn('Could not find file where `%s` is defined.\n'
1902 'Opening a file named `%s`' % (args,filename))
1906 'Opening a file named `%s`' % (args,filename))
1903 # Now, make sure we can actually read the source (if it was in
1907 # Now, make sure we can actually read the source (if it was in
1904 # a temp file it's gone by now).
1908 # a temp file it's gone by now).
1905 if datafile:
1909 if datafile:
1906 try:
1910 try:
1907 lineno = inspect.getsourcelines(data)[1]
1911 lineno = inspect.getsourcelines(data)[1]
1908 except IOError:
1912 except IOError:
1909 filename = make_filename(args)
1913 filename = make_filename(args)
1910 if filename is None:
1914 if filename is None:
1911 warn('The file `%s` where `%s` was defined cannot '
1915 warn('The file `%s` where `%s` was defined cannot '
1912 'be read.' % (filename,data))
1916 'be read.' % (filename,data))
1913 return
1917 return
1914 use_temp = 0
1918 use_temp = 0
1915 else:
1919 else:
1916 data = ''
1920 data = ''
1917
1921
1918 if use_temp:
1922 if use_temp:
1919 filename = self.shell.mktempfile(data)
1923 filename = self.shell.mktempfile(data)
1924 print 'IPython will make a temporary file named:',filename
1920
1925
1921 # do actual editing here
1926 # do actual editing here
1922 print 'Editing...',
1927 print 'Editing...',
1923 sys.stdout.flush()
1928 sys.stdout.flush()
1924 self.shell.hooks.editor(filename,lineno)
1929 self.shell.hooks.editor(filename,lineno)
1925 if opts.has_key('x'): # -x prevents actual execution
1930 if opts.has_key('x'): # -x prevents actual execution
1926 print
1931 print
1927 else:
1932 else:
1928 print 'done. Executing edited code...'
1933 print 'done. Executing edited code...'
1929 try:
1934 try:
1930 self.shell.safe_execfile(filename,self.shell.user_ns)
1935 self.shell.safe_execfile(filename,self.shell.user_ns)
1931 except IOError,msg:
1936 except IOError,msg:
1932 if msg.filename == filename:
1937 if msg.filename == filename:
1933 warn('File not found. Did you forget to save?')
1938 warn('File not found. Did you forget to save?')
1934 return
1939 return
1935 else:
1940 else:
1936 self.shell.showtraceback()
1941 self.shell.showtraceback()
1937 except:
1942 except:
1938 self.shell.showtraceback()
1943 self.shell.showtraceback()
1939
1944
1940 def magic_xmode(self,parameter_s = ''):
1945 def magic_xmode(self,parameter_s = ''):
1941 """Switch modes for the exception handlers.
1946 """Switch modes for the exception handlers.
1942
1947
1943 Valid modes: Plain, Context and Verbose.
1948 Valid modes: Plain, Context and Verbose.
1944
1949
1945 If called without arguments, acts as a toggle."""
1950 If called without arguments, acts as a toggle."""
1946
1951
1947 def xmode_switch_err(name):
1952 def xmode_switch_err(name):
1948 warn('Error changing %s exception modes.\n%s' %
1953 warn('Error changing %s exception modes.\n%s' %
1949 (name,sys.exc_info()[1]))
1954 (name,sys.exc_info()[1]))
1950
1955
1951 shell = self.shell
1956 shell = self.shell
1952 new_mode = parameter_s.strip().capitalize()
1957 new_mode = parameter_s.strip().capitalize()
1953 try:
1958 try:
1954 shell.InteractiveTB.set_mode(mode=new_mode)
1959 shell.InteractiveTB.set_mode(mode=new_mode)
1955 print 'Exception reporting mode:',shell.InteractiveTB.mode
1960 print 'Exception reporting mode:',shell.InteractiveTB.mode
1956 except:
1961 except:
1957 xmode_switch_err('user')
1962 xmode_switch_err('user')
1958
1963
1959 # threaded shells use a special handler in sys.excepthook
1964 # threaded shells use a special handler in sys.excepthook
1960 if shell.isthreaded:
1965 if shell.isthreaded:
1961 try:
1966 try:
1962 shell.sys_excepthook.set_mode(mode=new_mode)
1967 shell.sys_excepthook.set_mode(mode=new_mode)
1963 except:
1968 except:
1964 xmode_switch_err('threaded')
1969 xmode_switch_err('threaded')
1965
1970
1966 def magic_colors(self,parameter_s = ''):
1971 def magic_colors(self,parameter_s = ''):
1967 """Switch color scheme for prompts, info system and exception handlers.
1972 """Switch color scheme for prompts, info system and exception handlers.
1968
1973
1969 Currently implemented schemes: NoColor, Linux, LightBG.
1974 Currently implemented schemes: NoColor, Linux, LightBG.
1970
1975
1971 Color scheme names are not case-sensitive."""
1976 Color scheme names are not case-sensitive."""
1972
1977
1973 def color_switch_err(name):
1978 def color_switch_err(name):
1974 warn('Error changing %s color schemes.\n%s' %
1979 warn('Error changing %s color schemes.\n%s' %
1975 (name,sys.exc_info()[1]))
1980 (name,sys.exc_info()[1]))
1976
1981
1977
1982
1978 new_scheme = parameter_s.strip()
1983 new_scheme = parameter_s.strip()
1979 if not new_scheme:
1984 if not new_scheme:
1980 print 'You must specify a color scheme.'
1985 print 'You must specify a color scheme.'
1981 return
1986 return
1982 # Under Windows, check for Gary Bishop's readline, which is necessary
1987 # Under Windows, check for Gary Bishop's readline, which is necessary
1983 # for ANSI coloring
1988 # for ANSI coloring
1984 if os.name in ['nt','dos']:
1989 if os.name in ['nt','dos']:
1985 try:
1990 try:
1986 import readline
1991 import readline
1987 except ImportError:
1992 except ImportError:
1988 has_readline = 0
1993 has_readline = 0
1989 else:
1994 else:
1990 try:
1995 try:
1991 readline.GetOutputFile()
1996 readline.GetOutputFile()
1992 except AttributeError:
1997 except AttributeError:
1993 has_readline = 0
1998 has_readline = 0
1994 else:
1999 else:
1995 has_readline = 1
2000 has_readline = 1
1996 if not has_readline:
2001 if not has_readline:
1997 msg = """\
2002 msg = """\
1998 Proper color support under MS Windows requires Gary Bishop's readline library.
2003 Proper color support under MS Windows requires Gary Bishop's readline library.
1999 You can find it at:
2004 You can find it at:
2000 http://sourceforge.net/projects/uncpythontools
2005 http://sourceforge.net/projects/uncpythontools
2001 Gary's readline needs the ctypes module, from:
2006 Gary's readline needs the ctypes module, from:
2002 http://starship.python.net/crew/theller/ctypes
2007 http://starship.python.net/crew/theller/ctypes
2003
2008
2004 Defaulting color scheme to 'NoColor'"""
2009 Defaulting color scheme to 'NoColor'"""
2005 new_scheme = 'NoColor'
2010 new_scheme = 'NoColor'
2006 warn(msg)
2011 warn(msg)
2007 # local shortcut
2012 # local shortcut
2008 shell = self.shell
2013 shell = self.shell
2009
2014
2010 # Set prompt colors
2015 # Set prompt colors
2011 try:
2016 try:
2012 shell.outputcache.set_colors(new_scheme)
2017 shell.outputcache.set_colors(new_scheme)
2013 except:
2018 except:
2014 color_switch_err('prompt')
2019 color_switch_err('prompt')
2015 else:
2020 else:
2016 shell.rc.colors = \
2021 shell.rc.colors = \
2017 shell.outputcache.color_table.active_scheme_name
2022 shell.outputcache.color_table.active_scheme_name
2018 # Set exception colors
2023 # Set exception colors
2019 try:
2024 try:
2020 shell.InteractiveTB.set_colors(scheme = new_scheme)
2025 shell.InteractiveTB.set_colors(scheme = new_scheme)
2021 shell.SyntaxTB.set_colors(scheme = new_scheme)
2026 shell.SyntaxTB.set_colors(scheme = new_scheme)
2022 except:
2027 except:
2023 color_switch_err('exception')
2028 color_switch_err('exception')
2024
2029
2025 # threaded shells use a verbose traceback in sys.excepthook
2030 # threaded shells use a verbose traceback in sys.excepthook
2026 if shell.isthreaded:
2031 if shell.isthreaded:
2027 try:
2032 try:
2028 shell.sys_excepthook.set_colors(scheme=new_scheme)
2033 shell.sys_excepthook.set_colors(scheme=new_scheme)
2029 except:
2034 except:
2030 color_switch_err('system exception handler')
2035 color_switch_err('system exception handler')
2031
2036
2032 # Set info (for 'object?') colors
2037 # Set info (for 'object?') colors
2033 if shell.rc.color_info:
2038 if shell.rc.color_info:
2034 try:
2039 try:
2035 shell.inspector.set_active_scheme(new_scheme)
2040 shell.inspector.set_active_scheme(new_scheme)
2036 except:
2041 except:
2037 color_switch_err('object inspector')
2042 color_switch_err('object inspector')
2038 else:
2043 else:
2039 shell.inspector.set_active_scheme('NoColor')
2044 shell.inspector.set_active_scheme('NoColor')
2040
2045
2041 def magic_color_info(self,parameter_s = ''):
2046 def magic_color_info(self,parameter_s = ''):
2042 """Toggle color_info.
2047 """Toggle color_info.
2043
2048
2044 The color_info configuration parameter controls whether colors are
2049 The color_info configuration parameter controls whether colors are
2045 used for displaying object details (by things like %psource, %pfile or
2050 used for displaying object details (by things like %psource, %pfile or
2046 the '?' system). This function toggles this value with each call.
2051 the '?' system). This function toggles this value with each call.
2047
2052
2048 Note that unless you have a fairly recent pager (less works better
2053 Note that unless you have a fairly recent pager (less works better
2049 than more) in your system, using colored object information displays
2054 than more) in your system, using colored object information displays
2050 will not work properly. Test it and see."""
2055 will not work properly. Test it and see."""
2051
2056
2052 self.shell.rc.color_info = 1 - self.shell.rc.color_info
2057 self.shell.rc.color_info = 1 - self.shell.rc.color_info
2053 self.magic_colors(self.shell.rc.colors)
2058 self.magic_colors(self.shell.rc.colors)
2054 print 'Object introspection functions have now coloring:',
2059 print 'Object introspection functions have now coloring:',
2055 print ['OFF','ON'][self.shell.rc.color_info]
2060 print ['OFF','ON'][self.shell.rc.color_info]
2056
2061
2057 def magic_Pprint(self, parameter_s=''):
2062 def magic_Pprint(self, parameter_s=''):
2058 """Toggle pretty printing on/off."""
2063 """Toggle pretty printing on/off."""
2059
2064
2060 self.shell.outputcache.Pprint = 1 - self.shell.outputcache.Pprint
2065 self.shell.outputcache.Pprint = 1 - self.shell.outputcache.Pprint
2061 print 'Pretty printing has been turned', \
2066 print 'Pretty printing has been turned', \
2062 ['OFF','ON'][self.shell.outputcache.Pprint]
2067 ['OFF','ON'][self.shell.outputcache.Pprint]
2063
2068
2064 def magic_exit(self, parameter_s=''):
2069 def magic_exit(self, parameter_s=''):
2065 """Exit IPython, confirming if configured to do so.
2070 """Exit IPython, confirming if configured to do so.
2066
2071
2067 You can configure whether IPython asks for confirmation upon exit by
2072 You can configure whether IPython asks for confirmation upon exit by
2068 setting the confirm_exit flag in the ipythonrc file."""
2073 setting the confirm_exit flag in the ipythonrc file."""
2069
2074
2070 self.shell.exit()
2075 self.shell.exit()
2071
2076
2072 def magic_quit(self, parameter_s=''):
2077 def magic_quit(self, parameter_s=''):
2073 """Exit IPython, confirming if configured to do so (like %exit)"""
2078 """Exit IPython, confirming if configured to do so (like %exit)"""
2074
2079
2075 self.shell.exit()
2080 self.shell.exit()
2076
2081
2077 def magic_Exit(self, parameter_s=''):
2082 def magic_Exit(self, parameter_s=''):
2078 """Exit IPython without confirmation."""
2083 """Exit IPython without confirmation."""
2079
2084
2080 self.shell.exit_now = True
2085 self.shell.exit_now = True
2081
2086
2082 def magic_Quit(self, parameter_s=''):
2087 def magic_Quit(self, parameter_s=''):
2083 """Exit IPython without confirmation (like %Exit)."""
2088 """Exit IPython without confirmation (like %Exit)."""
2084
2089
2085 self.shell.exit_now = True
2090 self.shell.exit_now = True
2086
2091
2087 #......................................................................
2092 #......................................................................
2088 # Functions to implement unix shell-type things
2093 # Functions to implement unix shell-type things
2089
2094
2090 def magic_alias(self, parameter_s = ''):
2095 def magic_alias(self, parameter_s = ''):
2091 """Define an alias for a system command.
2096 """Define an alias for a system command.
2092
2097
2093 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2098 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2094
2099
2095 Then, typing 'alias_name params' will execute the system command 'cmd
2100 Then, typing 'alias_name params' will execute the system command 'cmd
2096 params' (from your underlying operating system).
2101 params' (from your underlying operating system).
2097
2102
2098 Aliases have lower precedence than magic functions and Python normal
2103 Aliases have lower precedence than magic functions and Python normal
2099 variables, so if 'foo' is both a Python variable and an alias, the
2104 variables, so if 'foo' is both a Python variable and an alias, the
2100 alias can not be executed until 'del foo' removes the Python variable.
2105 alias can not be executed until 'del foo' removes the Python variable.
2101
2106
2102 You can use the %l specifier in an alias definition to represent the
2107 You can use the %l specifier in an alias definition to represent the
2103 whole line when the alias is called. For example:
2108 whole line when the alias is called. For example:
2104
2109
2105 In [2]: alias all echo "Input in brackets: <%l>"\\
2110 In [2]: alias all echo "Input in brackets: <%l>"\\
2106 In [3]: all hello world\\
2111 In [3]: all hello world\\
2107 Input in brackets: <hello world>
2112 Input in brackets: <hello world>
2108
2113
2109 You can also define aliases with parameters using %s specifiers (one
2114 You can also define aliases with parameters using %s specifiers (one
2110 per parameter):
2115 per parameter):
2111
2116
2112 In [1]: alias parts echo first %s second %s\\
2117 In [1]: alias parts echo first %s second %s\\
2113 In [2]: %parts A B\\
2118 In [2]: %parts A B\\
2114 first A second B\\
2119 first A second B\\
2115 In [3]: %parts A\\
2120 In [3]: %parts A\\
2116 Incorrect number of arguments: 2 expected.\\
2121 Incorrect number of arguments: 2 expected.\\
2117 parts is an alias to: 'echo first %s second %s'
2122 parts is an alias to: 'echo first %s second %s'
2118
2123
2119 Note that %l and %s are mutually exclusive. You can only use one or
2124 Note that %l and %s are mutually exclusive. You can only use one or
2120 the other in your aliases.
2125 the other in your aliases.
2121
2126
2122 Aliases expand Python variables just like system calls using ! or !!
2127 Aliases expand Python variables just like system calls using ! or !!
2123 do: all expressions prefixed with '$' get expanded. For details of
2128 do: all expressions prefixed with '$' get expanded. For details of
2124 the semantic rules, see PEP-215:
2129 the semantic rules, see PEP-215:
2125 http://www.python.org/peps/pep-0215.html. This is the library used by
2130 http://www.python.org/peps/pep-0215.html. This is the library used by
2126 IPython for variable expansion. If you want to access a true shell
2131 IPython for variable expansion. If you want to access a true shell
2127 variable, an extra $ is necessary to prevent its expansion by IPython:
2132 variable, an extra $ is necessary to prevent its expansion by IPython:
2128
2133
2129 In [6]: alias show echo\\
2134 In [6]: alias show echo\\
2130 In [7]: PATH='A Python string'\\
2135 In [7]: PATH='A Python string'\\
2131 In [8]: show $PATH\\
2136 In [8]: show $PATH\\
2132 A Python string\\
2137 A Python string\\
2133 In [9]: show $$PATH\\
2138 In [9]: show $$PATH\\
2134 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2139 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2135
2140
2136 You can use the alias facility to acess all of $PATH. See the %rehash
2141 You can use the alias facility to acess all of $PATH. See the %rehash
2137 and %rehashx functions, which automatically create aliases for the
2142 and %rehashx functions, which automatically create aliases for the
2138 contents of your $PATH.
2143 contents of your $PATH.
2139
2144
2140 If called with no parameters, %alias prints the current alias table."""
2145 If called with no parameters, %alias prints the current alias table."""
2141
2146
2142 par = parameter_s.strip()
2147 par = parameter_s.strip()
2143 if not par:
2148 if not par:
2144 if self.shell.rc.automagic:
2149 if self.shell.rc.automagic:
2145 prechar = ''
2150 prechar = ''
2146 else:
2151 else:
2147 prechar = self.shell.ESC_MAGIC
2152 prechar = self.shell.ESC_MAGIC
2148 print 'Alias\t\tSystem Command\n'+'-'*30
2153 print 'Alias\t\tSystem Command\n'+'-'*30
2149 atab = self.shell.alias_table
2154 atab = self.shell.alias_table
2150 aliases = atab.keys()
2155 aliases = atab.keys()
2151 aliases.sort()
2156 aliases.sort()
2152 for alias in aliases:
2157 for alias in aliases:
2153 print prechar+alias+'\t\t'+atab[alias][1]
2158 print prechar+alias+'\t\t'+atab[alias][1]
2154 print '-'*30+'\nTotal number of aliases:',len(aliases)
2159 print '-'*30+'\nTotal number of aliases:',len(aliases)
2155 return
2160 return
2156 try:
2161 try:
2157 alias,cmd = par.split(None,1)
2162 alias,cmd = par.split(None,1)
2158 except:
2163 except:
2159 print OInspect.getdoc(self.magic_alias)
2164 print OInspect.getdoc(self.magic_alias)
2160 else:
2165 else:
2161 nargs = cmd.count('%s')
2166 nargs = cmd.count('%s')
2162 if nargs>0 and cmd.find('%l')>=0:
2167 if nargs>0 and cmd.find('%l')>=0:
2163 error('The %s and %l specifiers are mutually exclusive '
2168 error('The %s and %l specifiers are mutually exclusive '
2164 'in alias definitions.')
2169 'in alias definitions.')
2165 else: # all looks OK
2170 else: # all looks OK
2166 self.shell.alias_table[alias] = (nargs,cmd)
2171 self.shell.alias_table[alias] = (nargs,cmd)
2167 self.shell.alias_table_validate(verbose=1)
2172 self.shell.alias_table_validate(verbose=1)
2168 # end magic_alias
2173 # end magic_alias
2169
2174
2170 def magic_unalias(self, parameter_s = ''):
2175 def magic_unalias(self, parameter_s = ''):
2171 """Remove an alias"""
2176 """Remove an alias"""
2172
2177
2173 aname = parameter_s.strip()
2178 aname = parameter_s.strip()
2174 if aname in self.shell.alias_table:
2179 if aname in self.shell.alias_table:
2175 del self.shell.alias_table[aname]
2180 del self.shell.alias_table[aname]
2176
2181
2177 def magic_rehash(self, parameter_s = ''):
2182 def magic_rehash(self, parameter_s = ''):
2178 """Update the alias table with all entries in $PATH.
2183 """Update the alias table with all entries in $PATH.
2179
2184
2180 This version does no checks on execute permissions or whether the
2185 This version does no checks on execute permissions or whether the
2181 contents of $PATH are truly files (instead of directories or something
2186 contents of $PATH are truly files (instead of directories or something
2182 else). For such a safer (but slower) version, use %rehashx."""
2187 else). For such a safer (but slower) version, use %rehashx."""
2183
2188
2184 # This function (and rehashx) manipulate the alias_table directly
2189 # This function (and rehashx) manipulate the alias_table directly
2185 # rather than calling magic_alias, for speed reasons. A rehash on a
2190 # rather than calling magic_alias, for speed reasons. A rehash on a
2186 # typical Linux box involves several thousand entries, so efficiency
2191 # typical Linux box involves several thousand entries, so efficiency
2187 # here is a top concern.
2192 # here is a top concern.
2188
2193
2189 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2194 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2190 alias_table = self.shell.alias_table
2195 alias_table = self.shell.alias_table
2191 for pdir in path:
2196 for pdir in path:
2192 for ff in os.listdir(pdir):
2197 for ff in os.listdir(pdir):
2193 # each entry in the alias table must be (N,name), where
2198 # each entry in the alias table must be (N,name), where
2194 # N is the number of positional arguments of the alias.
2199 # N is the number of positional arguments of the alias.
2195 alias_table[ff] = (0,ff)
2200 alias_table[ff] = (0,ff)
2196 # Make sure the alias table doesn't contain keywords or builtins
2201 # Make sure the alias table doesn't contain keywords or builtins
2197 self.shell.alias_table_validate()
2202 self.shell.alias_table_validate()
2198 # Call again init_auto_alias() so we get 'rm -i' and other modified
2203 # Call again init_auto_alias() so we get 'rm -i' and other modified
2199 # aliases since %rehash will probably clobber them
2204 # aliases since %rehash will probably clobber them
2200 self.shell.init_auto_alias()
2205 self.shell.init_auto_alias()
2201
2206
2202 def magic_rehashx(self, parameter_s = ''):
2207 def magic_rehashx(self, parameter_s = ''):
2203 """Update the alias table with all executable files in $PATH.
2208 """Update the alias table with all executable files in $PATH.
2204
2209
2205 This version explicitly checks that every entry in $PATH is a file
2210 This version explicitly checks that every entry in $PATH is a file
2206 with execute access (os.X_OK), so it is much slower than %rehash.
2211 with execute access (os.X_OK), so it is much slower than %rehash.
2207
2212
2208 Under Windows, it checks executability as a match agains a
2213 Under Windows, it checks executability as a match agains a
2209 '|'-separated string of extensions, stored in the IPython config
2214 '|'-separated string of extensions, stored in the IPython config
2210 variable win_exec_ext. This defaults to 'exe|com|bat'. """
2215 variable win_exec_ext. This defaults to 'exe|com|bat'. """
2211
2216
2212 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2217 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2213 alias_table = self.shell.alias_table
2218 alias_table = self.shell.alias_table
2214
2219
2215 if os.name == 'posix':
2220 if os.name == 'posix':
2216 isexec = lambda fname:os.path.isfile(fname) and \
2221 isexec = lambda fname:os.path.isfile(fname) and \
2217 os.access(fname,os.X_OK)
2222 os.access(fname,os.X_OK)
2218 else:
2223 else:
2219
2224
2220 try:
2225 try:
2221 winext = os.environ['pathext'].replace(';','|').replace('.','')
2226 winext = os.environ['pathext'].replace(';','|').replace('.','')
2222 except KeyError:
2227 except KeyError:
2223 winext = 'exe|com|bat'
2228 winext = 'exe|com|bat'
2224
2229
2225 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2230 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2226 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2231 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2227 savedir = os.getcwd()
2232 savedir = os.getcwd()
2228 try:
2233 try:
2229 # write the whole loop for posix/Windows so we don't have an if in
2234 # write the whole loop for posix/Windows so we don't have an if in
2230 # the innermost part
2235 # the innermost part
2231 if os.name == 'posix':
2236 if os.name == 'posix':
2232 for pdir in path:
2237 for pdir in path:
2233 os.chdir(pdir)
2238 os.chdir(pdir)
2234 for ff in os.listdir(pdir):
2239 for ff in os.listdir(pdir):
2235 if isexec(ff):
2240 if isexec(ff):
2236 # each entry in the alias table must be (N,name),
2241 # each entry in the alias table must be (N,name),
2237 # where N is the number of positional arguments of the
2242 # where N is the number of positional arguments of the
2238 # alias.
2243 # alias.
2239 alias_table[ff] = (0,ff)
2244 alias_table[ff] = (0,ff)
2240 else:
2245 else:
2241 for pdir in path:
2246 for pdir in path:
2242 os.chdir(pdir)
2247 os.chdir(pdir)
2243 for ff in os.listdir(pdir):
2248 for ff in os.listdir(pdir):
2244 if isexec(ff):
2249 if isexec(ff):
2245 alias_table[execre.sub(r'\1',ff)] = (0,ff)
2250 alias_table[execre.sub(r'\1',ff)] = (0,ff)
2246 # Make sure the alias table doesn't contain keywords or builtins
2251 # Make sure the alias table doesn't contain keywords or builtins
2247 self.shell.alias_table_validate()
2252 self.shell.alias_table_validate()
2248 # Call again init_auto_alias() so we get 'rm -i' and other
2253 # Call again init_auto_alias() so we get 'rm -i' and other
2249 # modified aliases since %rehashx will probably clobber them
2254 # modified aliases since %rehashx will probably clobber them
2250 self.shell.init_auto_alias()
2255 self.shell.init_auto_alias()
2251 finally:
2256 finally:
2252 os.chdir(savedir)
2257 os.chdir(savedir)
2253
2258
2254 def magic_pwd(self, parameter_s = ''):
2259 def magic_pwd(self, parameter_s = ''):
2255 """Return the current working directory path."""
2260 """Return the current working directory path."""
2256 return os.getcwd()
2261 return os.getcwd()
2257
2262
2258 def magic_cd(self, parameter_s=''):
2263 def magic_cd(self, parameter_s=''):
2259 """Change the current working directory.
2264 """Change the current working directory.
2260
2265
2261 This command automatically maintains an internal list of directories
2266 This command automatically maintains an internal list of directories
2262 you visit during your IPython session, in the variable _dh. The
2267 you visit during your IPython session, in the variable _dh. The
2263 command %dhist shows this history nicely formatted.
2268 command %dhist shows this history nicely formatted.
2264
2269
2265 Usage:
2270 Usage:
2266
2271
2267 cd 'dir': changes to directory 'dir'.
2272 cd 'dir': changes to directory 'dir'.
2268
2273
2269 cd -: changes to the last visited directory.
2274 cd -: changes to the last visited directory.
2270
2275
2271 cd -<n>: changes to the n-th directory in the directory history.
2276 cd -<n>: changes to the n-th directory in the directory history.
2272
2277
2273 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2278 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2274 (note: cd <bookmark_name> is enough if there is no
2279 (note: cd <bookmark_name> is enough if there is no
2275 directory <bookmark_name>, but a bookmark with the name exists.)
2280 directory <bookmark_name>, but a bookmark with the name exists.)
2276
2281
2277 Options:
2282 Options:
2278
2283
2279 -q: quiet. Do not print the working directory after the cd command is
2284 -q: quiet. Do not print the working directory after the cd command is
2280 executed. By default IPython's cd command does print this directory,
2285 executed. By default IPython's cd command does print this directory,
2281 since the default prompts do not display path information.
2286 since the default prompts do not display path information.
2282
2287
2283 Note that !cd doesn't work for this purpose because the shell where
2288 Note that !cd doesn't work for this purpose because the shell where
2284 !command runs is immediately discarded after executing 'command'."""
2289 !command runs is immediately discarded after executing 'command'."""
2285
2290
2286 parameter_s = parameter_s.strip()
2291 parameter_s = parameter_s.strip()
2287 bkms = self.shell.persist.get("bookmarks",{})
2292 bkms = self.shell.persist.get("bookmarks",{})
2288
2293
2289 numcd = re.match(r'(-)(\d+)$',parameter_s)
2294 numcd = re.match(r'(-)(\d+)$',parameter_s)
2290 # jump in directory history by number
2295 # jump in directory history by number
2291 if numcd:
2296 if numcd:
2292 nn = int(numcd.group(2))
2297 nn = int(numcd.group(2))
2293 try:
2298 try:
2294 ps = self.shell.user_ns['_dh'][nn]
2299 ps = self.shell.user_ns['_dh'][nn]
2295 except IndexError:
2300 except IndexError:
2296 print 'The requested directory does not exist in history.'
2301 print 'The requested directory does not exist in history.'
2297 return
2302 return
2298 else:
2303 else:
2299 opts = {}
2304 opts = {}
2300 else:
2305 else:
2301 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2306 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2302 # jump to previous
2307 # jump to previous
2303 if ps == '-':
2308 if ps == '-':
2304 try:
2309 try:
2305 ps = self.shell.user_ns['_dh'][-2]
2310 ps = self.shell.user_ns['_dh'][-2]
2306 except IndexError:
2311 except IndexError:
2307 print 'No previous directory to change to.'
2312 print 'No previous directory to change to.'
2308 return
2313 return
2309 # jump to bookmark
2314 # jump to bookmark
2310 elif opts.has_key('b') or (bkms.has_key(ps) and not os.path.isdir(ps)):
2315 elif opts.has_key('b') or (bkms.has_key(ps) and not os.path.isdir(ps)):
2311 if bkms.has_key(ps):
2316 if bkms.has_key(ps):
2312 target = bkms[ps]
2317 target = bkms[ps]
2313 print '(bookmark:%s) -> %s' % (ps,target)
2318 print '(bookmark:%s) -> %s' % (ps,target)
2314 ps = target
2319 ps = target
2315 else:
2320 else:
2316 if bkms:
2321 if bkms:
2317 error("Bookmark '%s' not found. "
2322 error("Bookmark '%s' not found. "
2318 "Use '%%bookmark -l' to see your bookmarks." % ps)
2323 "Use '%%bookmark -l' to see your bookmarks." % ps)
2319 else:
2324 else:
2320 print "Bookmarks not set - use %bookmark <bookmarkname>"
2325 print "Bookmarks not set - use %bookmark <bookmarkname>"
2321 return
2326 return
2322
2327
2323 # at this point ps should point to the target dir
2328 # at this point ps should point to the target dir
2324 if ps:
2329 if ps:
2325 try:
2330 try:
2326 os.chdir(os.path.expanduser(ps))
2331 os.chdir(os.path.expanduser(ps))
2327 except OSError:
2332 except OSError:
2328 print sys.exc_info()[1]
2333 print sys.exc_info()[1]
2329 else:
2334 else:
2330 self.shell.user_ns['_dh'].append(os.getcwd())
2335 self.shell.user_ns['_dh'].append(os.getcwd())
2331 else:
2336 else:
2332 os.chdir(self.shell.home_dir)
2337 os.chdir(self.shell.home_dir)
2333 self.shell.user_ns['_dh'].append(os.getcwd())
2338 self.shell.user_ns['_dh'].append(os.getcwd())
2334 if not 'q' in opts:
2339 if not 'q' in opts:
2335 print self.shell.user_ns['_dh'][-1]
2340 print self.shell.user_ns['_dh'][-1]
2336
2341
2337 def magic_dhist(self, parameter_s=''):
2342 def magic_dhist(self, parameter_s=''):
2338 """Print your history of visited directories.
2343 """Print your history of visited directories.
2339
2344
2340 %dhist -> print full history\\
2345 %dhist -> print full history\\
2341 %dhist n -> print last n entries only\\
2346 %dhist n -> print last n entries only\\
2342 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2347 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2343
2348
2344 This history is automatically maintained by the %cd command, and
2349 This history is automatically maintained by the %cd command, and
2345 always available as the global list variable _dh. You can use %cd -<n>
2350 always available as the global list variable _dh. You can use %cd -<n>
2346 to go to directory number <n>."""
2351 to go to directory number <n>."""
2347
2352
2348 dh = self.shell.user_ns['_dh']
2353 dh = self.shell.user_ns['_dh']
2349 if parameter_s:
2354 if parameter_s:
2350 try:
2355 try:
2351 args = map(int,parameter_s.split())
2356 args = map(int,parameter_s.split())
2352 except:
2357 except:
2353 self.arg_err(Magic.magic_dhist)
2358 self.arg_err(Magic.magic_dhist)
2354 return
2359 return
2355 if len(args) == 1:
2360 if len(args) == 1:
2356 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2361 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2357 elif len(args) == 2:
2362 elif len(args) == 2:
2358 ini,fin = args
2363 ini,fin = args
2359 else:
2364 else:
2360 self.arg_err(Magic.magic_dhist)
2365 self.arg_err(Magic.magic_dhist)
2361 return
2366 return
2362 else:
2367 else:
2363 ini,fin = 0,len(dh)
2368 ini,fin = 0,len(dh)
2364 nlprint(dh,
2369 nlprint(dh,
2365 header = 'Directory history (kept in _dh)',
2370 header = 'Directory history (kept in _dh)',
2366 start=ini,stop=fin)
2371 start=ini,stop=fin)
2367
2372
2368 def magic_env(self, parameter_s=''):
2373 def magic_env(self, parameter_s=''):
2369 """List environment variables."""
2374 """List environment variables."""
2370
2375
2371 return os.environ.data
2376 return os.environ.data
2372
2377
2373 def magic_pushd(self, parameter_s=''):
2378 def magic_pushd(self, parameter_s=''):
2374 """Place the current dir on stack and change directory.
2379 """Place the current dir on stack and change directory.
2375
2380
2376 Usage:\\
2381 Usage:\\
2377 %pushd ['dirname']
2382 %pushd ['dirname']
2378
2383
2379 %pushd with no arguments does a %pushd to your home directory.
2384 %pushd with no arguments does a %pushd to your home directory.
2380 """
2385 """
2381 if parameter_s == '': parameter_s = '~'
2386 if parameter_s == '': parameter_s = '~'
2382 dir_s = self.shell.dir_stack
2387 dir_s = self.shell.dir_stack
2383 if len(dir_s)>0 and os.path.expanduser(parameter_s) != \
2388 if len(dir_s)>0 and os.path.expanduser(parameter_s) != \
2384 os.path.expanduser(self.shell.dir_stack[0]):
2389 os.path.expanduser(self.shell.dir_stack[0]):
2385 try:
2390 try:
2386 self.magic_cd(parameter_s)
2391 self.magic_cd(parameter_s)
2387 dir_s.insert(0,os.getcwd().replace(self.home_dir,'~'))
2392 dir_s.insert(0,os.getcwd().replace(self.home_dir,'~'))
2388 self.magic_dirs()
2393 self.magic_dirs()
2389 except:
2394 except:
2390 print 'Invalid directory'
2395 print 'Invalid directory'
2391 else:
2396 else:
2392 print 'You are already there!'
2397 print 'You are already there!'
2393
2398
2394 def magic_popd(self, parameter_s=''):
2399 def magic_popd(self, parameter_s=''):
2395 """Change to directory popped off the top of the stack.
2400 """Change to directory popped off the top of the stack.
2396 """
2401 """
2397 if len (self.shell.dir_stack) > 1:
2402 if len (self.shell.dir_stack) > 1:
2398 self.shell.dir_stack.pop(0)
2403 self.shell.dir_stack.pop(0)
2399 self.magic_cd(self.shell.dir_stack[0])
2404 self.magic_cd(self.shell.dir_stack[0])
2400 print self.shell.dir_stack[0]
2405 print self.shell.dir_stack[0]
2401 else:
2406 else:
2402 print "You can't remove the starting directory from the stack:",\
2407 print "You can't remove the starting directory from the stack:",\
2403 self.shell.dir_stack
2408 self.shell.dir_stack
2404
2409
2405 def magic_dirs(self, parameter_s=''):
2410 def magic_dirs(self, parameter_s=''):
2406 """Return the current directory stack."""
2411 """Return the current directory stack."""
2407
2412
2408 return self.shell.dir_stack[:]
2413 return self.shell.dir_stack[:]
2409
2414
2410 def magic_sc(self, parameter_s=''):
2415 def magic_sc(self, parameter_s=''):
2411 """Shell capture - execute a shell command and capture its output.
2416 """Shell capture - execute a shell command and capture its output.
2412
2417
2413 %sc [options] varname=command
2418 %sc [options] varname=command
2414
2419
2415 IPython will run the given command using commands.getoutput(), and
2420 IPython will run the given command using commands.getoutput(), and
2416 will then update the user's interactive namespace with a variable
2421 will then update the user's interactive namespace with a variable
2417 called varname, containing the value of the call. Your command can
2422 called varname, containing the value of the call. Your command can
2418 contain shell wildcards, pipes, etc.
2423 contain shell wildcards, pipes, etc.
2419
2424
2420 The '=' sign in the syntax is mandatory, and the variable name you
2425 The '=' sign in the syntax is mandatory, and the variable name you
2421 supply must follow Python's standard conventions for valid names.
2426 supply must follow Python's standard conventions for valid names.
2422
2427
2423 Options:
2428 Options:
2424
2429
2425 -l: list output. Split the output on newlines into a list before
2430 -l: list output. Split the output on newlines into a list before
2426 assigning it to the given variable. By default the output is stored
2431 assigning it to the given variable. By default the output is stored
2427 as a single string.
2432 as a single string.
2428
2433
2429 -v: verbose. Print the contents of the variable.
2434 -v: verbose. Print the contents of the variable.
2430
2435
2431 In most cases you should not need to split as a list, because the
2436 In most cases you should not need to split as a list, because the
2432 returned value is a special type of string which can automatically
2437 returned value is a special type of string which can automatically
2433 provide its contents either as a list (split on newlines) or as a
2438 provide its contents either as a list (split on newlines) or as a
2434 space-separated string. These are convenient, respectively, either
2439 space-separated string. These are convenient, respectively, either
2435 for sequential processing or to be passed to a shell command.
2440 for sequential processing or to be passed to a shell command.
2436
2441
2437 For example:
2442 For example:
2438
2443
2439 # Capture into variable a
2444 # Capture into variable a
2440 In [9]: sc a=ls *py
2445 In [9]: sc a=ls *py
2441
2446
2442 # a is a string with embedded newlines
2447 # a is a string with embedded newlines
2443 In [10]: a
2448 In [10]: a
2444 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2449 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2445
2450
2446 # which can be seen as a list:
2451 # which can be seen as a list:
2447 In [11]: a.l
2452 In [11]: a.l
2448 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2453 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2449
2454
2450 # or as a whitespace-separated string:
2455 # or as a whitespace-separated string:
2451 In [12]: a.s
2456 In [12]: a.s
2452 Out[12]: 'setup.py win32_manual_post_install.py'
2457 Out[12]: 'setup.py win32_manual_post_install.py'
2453
2458
2454 # a.s is useful to pass as a single command line:
2459 # a.s is useful to pass as a single command line:
2455 In [13]: !wc -l $a.s
2460 In [13]: !wc -l $a.s
2456 146 setup.py
2461 146 setup.py
2457 130 win32_manual_post_install.py
2462 130 win32_manual_post_install.py
2458 276 total
2463 276 total
2459
2464
2460 # while the list form is useful to loop over:
2465 # while the list form is useful to loop over:
2461 In [14]: for f in a.l:
2466 In [14]: for f in a.l:
2462 ....: !wc -l $f
2467 ....: !wc -l $f
2463 ....:
2468 ....:
2464 146 setup.py
2469 146 setup.py
2465 130 win32_manual_post_install.py
2470 130 win32_manual_post_install.py
2466
2471
2467 Similiarly, the lists returned by the -l option are also special, in
2472 Similiarly, the lists returned by the -l option are also special, in
2468 the sense that you can equally invoke the .s attribute on them to
2473 the sense that you can equally invoke the .s attribute on them to
2469 automatically get a whitespace-separated string from their contents:
2474 automatically get a whitespace-separated string from their contents:
2470
2475
2471 In [1]: sc -l b=ls *py
2476 In [1]: sc -l b=ls *py
2472
2477
2473 In [2]: b
2478 In [2]: b
2474 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2479 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2475
2480
2476 In [3]: b.s
2481 In [3]: b.s
2477 Out[3]: 'setup.py win32_manual_post_install.py'
2482 Out[3]: 'setup.py win32_manual_post_install.py'
2478
2483
2479 In summary, both the lists and strings used for ouptut capture have
2484 In summary, both the lists and strings used for ouptut capture have
2480 the following special attributes:
2485 the following special attributes:
2481
2486
2482 .l (or .list) : value as list.
2487 .l (or .list) : value as list.
2483 .n (or .nlstr): value as newline-separated string.
2488 .n (or .nlstr): value as newline-separated string.
2484 .s (or .spstr): value as space-separated string.
2489 .s (or .spstr): value as space-separated string.
2485 """
2490 """
2486
2491
2487 opts,args = self.parse_options(parameter_s,'lv')
2492 opts,args = self.parse_options(parameter_s,'lv')
2488 # Try to get a variable name and command to run
2493 # Try to get a variable name and command to run
2489 try:
2494 try:
2490 # the variable name must be obtained from the parse_options
2495 # the variable name must be obtained from the parse_options
2491 # output, which uses shlex.split to strip options out.
2496 # output, which uses shlex.split to strip options out.
2492 var,_ = args.split('=',1)
2497 var,_ = args.split('=',1)
2493 var = var.strip()
2498 var = var.strip()
2494 # But the the command has to be extracted from the original input
2499 # But the the command has to be extracted from the original input
2495 # parameter_s, not on what parse_options returns, to avoid the
2500 # parameter_s, not on what parse_options returns, to avoid the
2496 # quote stripping which shlex.split performs on it.
2501 # quote stripping which shlex.split performs on it.
2497 _,cmd = parameter_s.split('=',1)
2502 _,cmd = parameter_s.split('=',1)
2498 except ValueError:
2503 except ValueError:
2499 var,cmd = '',''
2504 var,cmd = '',''
2500 if not var:
2505 if not var:
2501 error('you must specify a variable to assign the command to.')
2506 error('you must specify a variable to assign the command to.')
2502 return
2507 return
2503 # If all looks ok, proceed
2508 # If all looks ok, proceed
2504 out,err = self.shell.getoutputerror(cmd)
2509 out,err = self.shell.getoutputerror(cmd)
2505 if err:
2510 if err:
2506 print >> Term.cerr,err
2511 print >> Term.cerr,err
2507 if opts.has_key('l'):
2512 if opts.has_key('l'):
2508 out = SList(out.split('\n'))
2513 out = SList(out.split('\n'))
2509 else:
2514 else:
2510 out = LSString(out)
2515 out = LSString(out)
2511 if opts.has_key('v'):
2516 if opts.has_key('v'):
2512 print '%s ==\n%s' % (var,pformat(out))
2517 print '%s ==\n%s' % (var,pformat(out))
2513 self.shell.user_ns.update({var:out})
2518 self.shell.user_ns.update({var:out})
2514
2519
2515 def magic_sx(self, parameter_s=''):
2520 def magic_sx(self, parameter_s=''):
2516 """Shell execute - run a shell command and capture its output.
2521 """Shell execute - run a shell command and capture its output.
2517
2522
2518 %sx command
2523 %sx command
2519
2524
2520 IPython will run the given command using commands.getoutput(), and
2525 IPython will run the given command using commands.getoutput(), and
2521 return the result formatted as a list (split on '\\n'). Since the
2526 return the result formatted as a list (split on '\\n'). Since the
2522 output is _returned_, it will be stored in ipython's regular output
2527 output is _returned_, it will be stored in ipython's regular output
2523 cache Out[N] and in the '_N' automatic variables.
2528 cache Out[N] and in the '_N' automatic variables.
2524
2529
2525 Notes:
2530 Notes:
2526
2531
2527 1) If an input line begins with '!!', then %sx is automatically
2532 1) If an input line begins with '!!', then %sx is automatically
2528 invoked. That is, while:
2533 invoked. That is, while:
2529 !ls
2534 !ls
2530 causes ipython to simply issue system('ls'), typing
2535 causes ipython to simply issue system('ls'), typing
2531 !!ls
2536 !!ls
2532 is a shorthand equivalent to:
2537 is a shorthand equivalent to:
2533 %sx ls
2538 %sx ls
2534
2539
2535 2) %sx differs from %sc in that %sx automatically splits into a list,
2540 2) %sx differs from %sc in that %sx automatically splits into a list,
2536 like '%sc -l'. The reason for this is to make it as easy as possible
2541 like '%sc -l'. The reason for this is to make it as easy as possible
2537 to process line-oriented shell output via further python commands.
2542 to process line-oriented shell output via further python commands.
2538 %sc is meant to provide much finer control, but requires more
2543 %sc is meant to provide much finer control, but requires more
2539 typing.
2544 typing.
2540
2545
2541 3) Just like %sc -l, this is a list with special attributes:
2546 3) Just like %sc -l, this is a list with special attributes:
2542
2547
2543 .l (or .list) : value as list.
2548 .l (or .list) : value as list.
2544 .n (or .nlstr): value as newline-separated string.
2549 .n (or .nlstr): value as newline-separated string.
2545 .s (or .spstr): value as whitespace-separated string.
2550 .s (or .spstr): value as whitespace-separated string.
2546
2551
2547 This is very useful when trying to use such lists as arguments to
2552 This is very useful when trying to use such lists as arguments to
2548 system commands."""
2553 system commands."""
2549
2554
2550 if parameter_s:
2555 if parameter_s:
2551 out,err = self.shell.getoutputerror(parameter_s)
2556 out,err = self.shell.getoutputerror(parameter_s)
2552 if err:
2557 if err:
2553 print >> Term.cerr,err
2558 print >> Term.cerr,err
2554 return SList(out.split('\n'))
2559 return SList(out.split('\n'))
2555
2560
2556 def magic_bg(self, parameter_s=''):
2561 def magic_bg(self, parameter_s=''):
2557 """Run a job in the background, in a separate thread.
2562 """Run a job in the background, in a separate thread.
2558
2563
2559 For example,
2564 For example,
2560
2565
2561 %bg myfunc(x,y,z=1)
2566 %bg myfunc(x,y,z=1)
2562
2567
2563 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2568 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2564 execution starts, a message will be printed indicating the job
2569 execution starts, a message will be printed indicating the job
2565 number. If your job number is 5, you can use
2570 number. If your job number is 5, you can use
2566
2571
2567 myvar = jobs.result(5) or myvar = jobs[5].result
2572 myvar = jobs.result(5) or myvar = jobs[5].result
2568
2573
2569 to assign this result to variable 'myvar'.
2574 to assign this result to variable 'myvar'.
2570
2575
2571 IPython has a job manager, accessible via the 'jobs' object. You can
2576 IPython has a job manager, accessible via the 'jobs' object. You can
2572 type jobs? to get more information about it, and use jobs.<TAB> to see
2577 type jobs? to get more information about it, and use jobs.<TAB> to see
2573 its attributes. All attributes not starting with an underscore are
2578 its attributes. All attributes not starting with an underscore are
2574 meant for public use.
2579 meant for public use.
2575
2580
2576 In particular, look at the jobs.new() method, which is used to create
2581 In particular, look at the jobs.new() method, which is used to create
2577 new jobs. This magic %bg function is just a convenience wrapper
2582 new jobs. This magic %bg function is just a convenience wrapper
2578 around jobs.new(), for expression-based jobs. If you want to create a
2583 around jobs.new(), for expression-based jobs. If you want to create a
2579 new job with an explicit function object and arguments, you must call
2584 new job with an explicit function object and arguments, you must call
2580 jobs.new() directly.
2585 jobs.new() directly.
2581
2586
2582 The jobs.new docstring also describes in detail several important
2587 The jobs.new docstring also describes in detail several important
2583 caveats associated with a thread-based model for background job
2588 caveats associated with a thread-based model for background job
2584 execution. Type jobs.new? for details.
2589 execution. Type jobs.new? for details.
2585
2590
2586 You can check the status of all jobs with jobs.status().
2591 You can check the status of all jobs with jobs.status().
2587
2592
2588 The jobs variable is set by IPython into the Python builtin namespace.
2593 The jobs variable is set by IPython into the Python builtin namespace.
2589 If you ever declare a variable named 'jobs', you will shadow this
2594 If you ever declare a variable named 'jobs', you will shadow this
2590 name. You can either delete your global jobs variable to regain
2595 name. You can either delete your global jobs variable to regain
2591 access to the job manager, or make a new name and assign it manually
2596 access to the job manager, or make a new name and assign it manually
2592 to the manager (stored in IPython's namespace). For example, to
2597 to the manager (stored in IPython's namespace). For example, to
2593 assign the job manager to the Jobs name, use:
2598 assign the job manager to the Jobs name, use:
2594
2599
2595 Jobs = __builtins__.jobs"""
2600 Jobs = __builtins__.jobs"""
2596
2601
2597 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2602 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2598
2603
2599 def magic_store(self, parameter_s=''):
2604 def magic_store(self, parameter_s=''):
2600 """Lightweight persistence for python variables.
2605 """Lightweight persistence for python variables.
2601
2606
2602 Example:
2607 Example:
2603
2608
2604 ville@badger[~]|1> A = ['hello',10,'world']\\
2609 ville@badger[~]|1> A = ['hello',10,'world']\\
2605 ville@badger[~]|2> %store A\\
2610 ville@badger[~]|2> %store A\\
2606 ville@badger[~]|3> Exit
2611 ville@badger[~]|3> Exit
2607
2612
2608 (IPython session is closed and started again...)
2613 (IPython session is closed and started again...)
2609
2614
2610 ville@badger:~$ ipython -p pysh\\
2615 ville@badger:~$ ipython -p pysh\\
2611 ville@badger[~]|1> print A
2616 ville@badger[~]|1> print A
2612
2617
2613 ['hello', 10, 'world']
2618 ['hello', 10, 'world']
2614
2619
2615 Usage:
2620 Usage:
2616
2621
2617 %store - Show list of all variables and their current values\\
2622 %store - Show list of all variables and their current values\\
2618 %store <var> - Store the *current* value of the variable to disk\\
2623 %store <var> - Store the *current* value of the variable to disk\\
2619 %store -d <var> - Remove the variable and its value from storage\\
2624 %store -d <var> - Remove the variable and its value from storage\\
2620 %store -r - Remove all variables from storage
2625 %store -r - Remove all variables from storage
2621
2626
2622 It should be noted that if you change the value of a variable, you
2627 It should be noted that if you change the value of a variable, you
2623 need to %store it again if you want to persist the new value.
2628 need to %store it again if you want to persist the new value.
2624
2629
2625 Note also that the variables will need to be pickleable; most basic
2630 Note also that the variables will need to be pickleable; most basic
2626 python types can be safely %stored.
2631 python types can be safely %stored.
2627 """
2632 """
2628
2633
2629 opts,args = self.parse_options(parameter_s,'dr',mode='list')
2634 opts,args = self.parse_options(parameter_s,'dr',mode='list')
2630 # delete
2635 # delete
2631 if opts.has_key('d'):
2636 if opts.has_key('d'):
2632 try:
2637 try:
2633 todel = args[0]
2638 todel = args[0]
2634 except IndexError:
2639 except IndexError:
2635 error('You must provide the variable to forget')
2640 error('You must provide the variable to forget')
2636 else:
2641 else:
2637 try:
2642 try:
2638 del self.shell.persist['S:' + todel]
2643 del self.shell.persist['S:' + todel]
2639 except:
2644 except:
2640 error("Can't delete variable '%s'" % todel)
2645 error("Can't delete variable '%s'" % todel)
2641 # reset
2646 # reset
2642 elif opts.has_key('r'):
2647 elif opts.has_key('r'):
2643 for k in self.shell.persist.keys():
2648 for k in self.shell.persist.keys():
2644 if k.startswith('S:'):
2649 if k.startswith('S:'):
2645 del self.shell.persist[k]
2650 del self.shell.persist[k]
2646
2651
2647 # run without arguments -> list variables & values
2652 # run without arguments -> list variables & values
2648 elif not args:
2653 elif not args:
2649 vars = [v[2:] for v in self.shell.persist.keys()
2654 vars = [v[2:] for v in self.shell.persist.keys()
2650 if v.startswith('S:')]
2655 if v.startswith('S:')]
2651 vars.sort()
2656 vars.sort()
2652 if vars:
2657 if vars:
2653 size = max(map(len,vars))
2658 size = max(map(len,vars))
2654 else:
2659 else:
2655 size = 0
2660 size = 0
2656
2661
2657 print 'Stored variables and their in-memory values:'
2662 print 'Stored variables and their in-memory values:'
2658 fmt = '%-'+str(size)+'s -> %s'
2663 fmt = '%-'+str(size)+'s -> %s'
2659 get = self.shell.user_ns.get
2664 get = self.shell.user_ns.get
2660 for var in vars:
2665 for var in vars:
2661 # print 30 first characters from every var
2666 # print 30 first characters from every var
2662 print fmt % (var,repr(get(var,'<unavailable>'))[:50])
2667 print fmt % (var,repr(get(var,'<unavailable>'))[:50])
2663
2668
2664 # default action - store the variable
2669 # default action - store the variable
2665 else:
2670 else:
2666 pickled = pickle.dumps(self.shell.user_ns[args[0] ])
2671 pickled = pickle.dumps(self.shell.user_ns[args[0] ])
2667 self.shell.persist[ 'S:' + args[0] ] = pickled
2672 self.shell.persist[ 'S:' + args[0] ] = pickled
2668 print "Stored '%s' (%d bytes)" % (args[0], len(pickled))
2673 print "Stored '%s' (%d bytes)" % (args[0], len(pickled))
2669
2674
2670 def magic_bookmark(self, parameter_s=''):
2675 def magic_bookmark(self, parameter_s=''):
2671 """Manage IPython's bookmark system.
2676 """Manage IPython's bookmark system.
2672
2677
2673 %bookmark <name> - set bookmark to current dir
2678 %bookmark <name> - set bookmark to current dir
2674 %bookmark <name> <dir> - set bookmark to <dir>
2679 %bookmark <name> <dir> - set bookmark to <dir>
2675 %bookmark -l - list all bookmarks
2680 %bookmark -l - list all bookmarks
2676 %bookmark -d <name> - remove bookmark
2681 %bookmark -d <name> - remove bookmark
2677 %bookmark -r - remove all bookmarks
2682 %bookmark -r - remove all bookmarks
2678
2683
2679 You can later on access a bookmarked folder with:
2684 You can later on access a bookmarked folder with:
2680 %cd -b <name>
2685 %cd -b <name>
2681 or simply '%cd <name>' if there is no directory called <name> AND
2686 or simply '%cd <name>' if there is no directory called <name> AND
2682 there is such a bookmark defined.
2687 there is such a bookmark defined.
2683
2688
2684 Your bookmarks persist through IPython sessions, but they are
2689 Your bookmarks persist through IPython sessions, but they are
2685 associated with each profile."""
2690 associated with each profile."""
2686
2691
2687 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2692 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2688 if len(args) > 2:
2693 if len(args) > 2:
2689 error('You can only give at most two arguments')
2694 error('You can only give at most two arguments')
2690 return
2695 return
2691
2696
2692 bkms = self.shell.persist.get('bookmarks',{})
2697 bkms = self.shell.persist.get('bookmarks',{})
2693
2698
2694 if opts.has_key('d'):
2699 if opts.has_key('d'):
2695 try:
2700 try:
2696 todel = args[0]
2701 todel = args[0]
2697 except IndexError:
2702 except IndexError:
2698 error('You must provide a bookmark to delete')
2703 error('You must provide a bookmark to delete')
2699 else:
2704 else:
2700 try:
2705 try:
2701 del bkms[todel]
2706 del bkms[todel]
2702 except:
2707 except:
2703 error("Can't delete bookmark '%s'" % todel)
2708 error("Can't delete bookmark '%s'" % todel)
2704 elif opts.has_key('r'):
2709 elif opts.has_key('r'):
2705 bkms = {}
2710 bkms = {}
2706 elif opts.has_key('l'):
2711 elif opts.has_key('l'):
2707 bks = bkms.keys()
2712 bks = bkms.keys()
2708 bks.sort()
2713 bks.sort()
2709 if bks:
2714 if bks:
2710 size = max(map(len,bks))
2715 size = max(map(len,bks))
2711 else:
2716 else:
2712 size = 0
2717 size = 0
2713 fmt = '%-'+str(size)+'s -> %s'
2718 fmt = '%-'+str(size)+'s -> %s'
2714 print 'Current bookmarks:'
2719 print 'Current bookmarks:'
2715 for bk in bks:
2720 for bk in bks:
2716 print fmt % (bk,bkms[bk])
2721 print fmt % (bk,bkms[bk])
2717 else:
2722 else:
2718 if not args:
2723 if not args:
2719 error("You must specify the bookmark name")
2724 error("You must specify the bookmark name")
2720 elif len(args)==1:
2725 elif len(args)==1:
2721 bkms[args[0]] = os.getcwd()
2726 bkms[args[0]] = os.getcwd()
2722 elif len(args)==2:
2727 elif len(args)==2:
2723 bkms[args[0]] = args[1]
2728 bkms[args[0]] = args[1]
2724 self.shell.persist['bookmarks'] = bkms
2729 self.shell.persist['bookmarks'] = bkms
2725
2730
2726 def magic_pycat(self, parameter_s=''):
2731 def magic_pycat(self, parameter_s=''):
2727 """Show a syntax-highlighted file through a pager.
2732 """Show a syntax-highlighted file through a pager.
2728
2733
2729 This magic is similar to the cat utility, but it will assume the file
2734 This magic is similar to the cat utility, but it will assume the file
2730 to be Python source and will show it with syntax highlighting. """
2735 to be Python source and will show it with syntax highlighting. """
2731
2736
2732 filename = get_py_filename(parameter_s)
2737 filename = get_py_filename(parameter_s)
2733 page(self.shell.colorize(file_read(filename)),
2738 page(self.shell.colorize(file_read(filename)),
2734 screen_lines=self.shell.rc.screen_length)
2739 screen_lines=self.shell.rc.screen_length)
2735
2740
2736 # end Magic
2741 # end Magic
@@ -1,76 +1,76 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """Release data for the IPython project.
2 """Release data for the IPython project.
3
3
4 $Id: Release.py 994 2006-01-08 08:29:44Z fperez $"""
4 $Id: Release.py 1000 2006-01-10 08:06:04Z fperez $"""
5
5
6 #*****************************************************************************
6 #*****************************************************************************
7 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
7 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
8 #
8 #
9 # Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and Nathaniel Gray
9 # Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and Nathaniel Gray
10 # <n8gray@caltech.edu>
10 # <n8gray@caltech.edu>
11 #
11 #
12 # Distributed under the terms of the BSD License. The full license is in
12 # Distributed under the terms of the BSD License. The full license is in
13 # the file COPYING, distributed as part of this software.
13 # the file COPYING, distributed as part of this software.
14 #*****************************************************************************
14 #*****************************************************************************
15
15
16 # Name of the package for release purposes. This is the name which labels
16 # Name of the package for release purposes. This is the name which labels
17 # the tarballs and RPMs made by distutils, so it's best to lowercase it.
17 # the tarballs and RPMs made by distutils, so it's best to lowercase it.
18 name = 'ipython'
18 name = 'ipython'
19
19
20 # For versions with substrings (like 0.6.16.svn), use an extra . to separate
20 # For versions with substrings (like 0.6.16.svn), use an extra . to separate
21 # the new substring. We have to avoid using either dashes or underscores,
21 # the new substring. We have to avoid using either dashes or underscores,
22 # because bdist_rpm does not accept dashes (an RPM) convention, and
22 # because bdist_rpm does not accept dashes (an RPM) convention, and
23 # bdist_deb does not accept underscores (a Debian convention).
23 # bdist_deb does not accept underscores (a Debian convention).
24
24
25 version = '0.7.0.rc8'
25 version = '0.7.0'
26
26
27 revision = '$Revision: 994 $'
27 revision = '$Revision: 1000 $'
28
28
29 description = "An enhanced interactive Python shell."
29 description = "An enhanced interactive Python shell."
30
30
31 long_description = \
31 long_description = \
32 """
32 """
33 IPython provides a replacement for the interactive Python interpreter with
33 IPython provides a replacement for the interactive Python interpreter with
34 extra functionality.
34 extra functionality.
35
35
36 Main features:
36 Main features:
37
37
38 * Comprehensive object introspection.
38 * Comprehensive object introspection.
39
39
40 * Input history, persistent across sessions.
40 * Input history, persistent across sessions.
41
41
42 * Caching of output results during a session with automatically generated
42 * Caching of output results during a session with automatically generated
43 references.
43 references.
44
44
45 * Readline based name completion.
45 * Readline based name completion.
46
46
47 * Extensible system of 'magic' commands for controlling the environment and
47 * Extensible system of 'magic' commands for controlling the environment and
48 performing many tasks related either to IPython or the operating system.
48 performing many tasks related either to IPython or the operating system.
49
49
50 * Configuration system with easy switching between different setups (simpler
50 * Configuration system with easy switching between different setups (simpler
51 than changing $PYTHONSTARTUP environment variables every time).
51 than changing $PYTHONSTARTUP environment variables every time).
52
52
53 * Session logging and reloading.
53 * Session logging and reloading.
54
54
55 * Extensible syntax processing for special purpose situations.
55 * Extensible syntax processing for special purpose situations.
56
56
57 * Access to the system shell with user-extensible alias system.
57 * Access to the system shell with user-extensible alias system.
58
58
59 * Easily embeddable in other Python programs.
59 * Easily embeddable in other Python programs.
60
60
61 * Integrated access to the pdb debugger and the Python profiler. """
61 * Integrated access to the pdb debugger and the Python profiler. """
62
62
63 license = 'BSD'
63 license = 'BSD'
64
64
65 authors = {'Fernando' : ('Fernando Perez','fperez@colorado.edu'),
65 authors = {'Fernando' : ('Fernando Perez','fperez@colorado.edu'),
66 'Janko' : ('Janko Hauser','jhauser@zscout.de'),
66 'Janko' : ('Janko Hauser','jhauser@zscout.de'),
67 'Nathan' : ('Nathaniel Gray','n8gray@caltech.edu')
67 'Nathan' : ('Nathaniel Gray','n8gray@caltech.edu')
68 }
68 }
69
69
70 url = 'http://ipython.scipy.org'
70 url = 'http://ipython.scipy.org'
71
71
72 download_url = 'http://ipython.scipy.org/dist'
72 download_url = 'http://ipython.scipy.org/dist'
73
73
74 platforms = ['Linux','Mac OSX','Windows XP/2000/NT','Windows 95/98/ME']
74 platforms = ['Linux','Mac OSX','Windows XP/2000/NT','Windows 95/98/ME']
75
75
76 keywords = ['Interactive','Interpreter','Shell']
76 keywords = ['Interactive','Interpreter','Shell']
@@ -1,2165 +1,2165 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 IPython -- An enhanced Interactive Python
3 IPython -- An enhanced Interactive Python
4
4
5 Requires Python 2.1 or newer.
5 Requires Python 2.1 or newer.
6
6
7 This file contains all the classes and helper functions specific to IPython.
7 This file contains all the classes and helper functions specific to IPython.
8
8
9 $Id: iplib.py 995 2006-01-08 16:23:20Z fperez $
9 $Id: iplib.py 1000 2006-01-10 08:06:04Z fperez $
10 """
10 """
11
11
12 #*****************************************************************************
12 #*****************************************************************************
13 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
13 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
14 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
14 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
15 #
15 #
16 # Distributed under the terms of the BSD License. The full license is in
16 # Distributed under the terms of the BSD License. The full license is in
17 # the file COPYING, distributed as part of this software.
17 # the file COPYING, distributed as part of this software.
18 #
18 #
19 # Note: this code originally subclassed code.InteractiveConsole from the
19 # Note: this code originally subclassed code.InteractiveConsole from the
20 # Python standard library. Over time, all of that class has been copied
20 # Python standard library. Over time, all of that class has been copied
21 # verbatim here for modifications which could not be accomplished by
21 # verbatim here for modifications which could not be accomplished by
22 # subclassing. At this point, there are no dependencies at all on the code
22 # subclassing. At this point, there are no dependencies at all on the code
23 # module anymore (it is not even imported). The Python License (sec. 2)
23 # module anymore (it is not even imported). The Python License (sec. 2)
24 # allows for this, but it's always nice to acknowledge credit where credit is
24 # allows for this, but it's always nice to acknowledge credit where credit is
25 # due.
25 # due.
26 #*****************************************************************************
26 #*****************************************************************************
27
27
28 #****************************************************************************
28 #****************************************************************************
29 # Modules and globals
29 # Modules and globals
30
30
31 from __future__ import generators # for 2.2 backwards-compatibility
31 from __future__ import generators # for 2.2 backwards-compatibility
32
32
33 from IPython import Release
33 from IPython import Release
34 __author__ = '%s <%s>\n%s <%s>' % \
34 __author__ = '%s <%s>\n%s <%s>' % \
35 ( Release.authors['Janko'] + Release.authors['Fernando'] )
35 ( Release.authors['Janko'] + Release.authors['Fernando'] )
36 __license__ = Release.license
36 __license__ = Release.license
37 __version__ = Release.version
37 __version__ = Release.version
38
38
39 # Python standard modules
39 # Python standard modules
40 import __main__
40 import __main__
41 import __builtin__
41 import __builtin__
42 import StringIO
42 import StringIO
43 import bdb
43 import bdb
44 import cPickle as pickle
44 import cPickle as pickle
45 import codeop
45 import codeop
46 import exceptions
46 import exceptions
47 import glob
47 import glob
48 import inspect
48 import inspect
49 import keyword
49 import keyword
50 import new
50 import new
51 import os
51 import os
52 import pdb
52 import pdb
53 import pydoc
53 import pydoc
54 import re
54 import re
55 import shutil
55 import shutil
56 import string
56 import string
57 import sys
57 import sys
58 import tempfile
58 import tempfile
59 import traceback
59 import traceback
60 import types
60 import types
61
61
62 from pprint import pprint, pformat
62 from pprint import pprint, pformat
63
63
64 # IPython's own modules
64 # IPython's own modules
65 import IPython
65 import IPython
66 from IPython import OInspect,PyColorize,ultraTB
66 from IPython import OInspect,PyColorize,ultraTB
67 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
67 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
68 from IPython.FakeModule import FakeModule
68 from IPython.FakeModule import FakeModule
69 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
69 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
70 from IPython.Logger import Logger
70 from IPython.Logger import Logger
71 from IPython.Magic import Magic
71 from IPython.Magic import Magic
72 from IPython.Prompts import CachedOutput
72 from IPython.Prompts import CachedOutput
73 from IPython.Struct import Struct
73 from IPython.Struct import Struct
74 from IPython.background_jobs import BackgroundJobManager
74 from IPython.background_jobs import BackgroundJobManager
75 from IPython.usage import cmd_line_usage,interactive_usage
75 from IPython.usage import cmd_line_usage,interactive_usage
76 from IPython.genutils import *
76 from IPython.genutils import *
77
77
78 # Globals
78 # Globals
79
79
80 # store the builtin raw_input globally, and use this always, in case user code
80 # store the builtin raw_input globally, and use this always, in case user code
81 # overwrites it (like wx.py.PyShell does)
81 # overwrites it (like wx.py.PyShell does)
82 raw_input_original = raw_input
82 raw_input_original = raw_input
83
83
84 # compiled regexps for autoindent management
84 # compiled regexps for autoindent management
85 ini_spaces_re = re.compile(r'^(\s+)')
85 ini_spaces_re = re.compile(r'^(\s+)')
86 dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass')
86 dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass')
87
87
88
88
89 #****************************************************************************
89 #****************************************************************************
90 # Some utility function definitions
90 # Some utility function definitions
91
91
92 def softspace(file, newvalue):
92 def softspace(file, newvalue):
93 """Copied from code.py, to remove the dependency"""
93 """Copied from code.py, to remove the dependency"""
94 oldvalue = 0
94 oldvalue = 0
95 try:
95 try:
96 oldvalue = file.softspace
96 oldvalue = file.softspace
97 except AttributeError:
97 except AttributeError:
98 pass
98 pass
99 try:
99 try:
100 file.softspace = newvalue
100 file.softspace = newvalue
101 except (AttributeError, TypeError):
101 except (AttributeError, TypeError):
102 # "attribute-less object" or "read-only attributes"
102 # "attribute-less object" or "read-only attributes"
103 pass
103 pass
104 return oldvalue
104 return oldvalue
105
105
106
106
107 #****************************************************************************
107 #****************************************************************************
108 # Local use exceptions
108 # Local use exceptions
109 class SpaceInInput(exceptions.Exception): pass
109 class SpaceInInput(exceptions.Exception): pass
110
110
111
111
112 #****************************************************************************
112 #****************************************************************************
113 # Local use classes
113 # Local use classes
114 class Bunch: pass
114 class Bunch: pass
115
115
116 class Undefined: pass
116 class Undefined: pass
117
117
118 class InputList(list):
118 class InputList(list):
119 """Class to store user input.
119 """Class to store user input.
120
120
121 It's basically a list, but slices return a string instead of a list, thus
121 It's basically a list, but slices return a string instead of a list, thus
122 allowing things like (assuming 'In' is an instance):
122 allowing things like (assuming 'In' is an instance):
123
123
124 exec In[4:7]
124 exec In[4:7]
125
125
126 or
126 or
127
127
128 exec In[5:9] + In[14] + In[21:25]"""
128 exec In[5:9] + In[14] + In[21:25]"""
129
129
130 def __getslice__(self,i,j):
130 def __getslice__(self,i,j):
131 return ''.join(list.__getslice__(self,i,j))
131 return ''.join(list.__getslice__(self,i,j))
132
132
133 class SyntaxTB(ultraTB.ListTB):
133 class SyntaxTB(ultraTB.ListTB):
134 """Extension which holds some state: the last exception value"""
134 """Extension which holds some state: the last exception value"""
135
135
136 def __init__(self,color_scheme = 'NoColor'):
136 def __init__(self,color_scheme = 'NoColor'):
137 ultraTB.ListTB.__init__(self,color_scheme)
137 ultraTB.ListTB.__init__(self,color_scheme)
138 self.last_syntax_error = None
138 self.last_syntax_error = None
139
139
140 def __call__(self, etype, value, elist):
140 def __call__(self, etype, value, elist):
141 self.last_syntax_error = value
141 self.last_syntax_error = value
142 ultraTB.ListTB.__call__(self,etype,value,elist)
142 ultraTB.ListTB.__call__(self,etype,value,elist)
143
143
144 def clear_err_state(self):
144 def clear_err_state(self):
145 """Return the current error state and clear it"""
145 """Return the current error state and clear it"""
146 e = self.last_syntax_error
146 e = self.last_syntax_error
147 self.last_syntax_error = None
147 self.last_syntax_error = None
148 return e
148 return e
149
149
150 #****************************************************************************
150 #****************************************************************************
151 # Main IPython class
151 # Main IPython class
152
152
153 # FIXME: the Magic class is a mixin for now, and will unfortunately remain so
153 # FIXME: the Magic class is a mixin for now, and will unfortunately remain so
154 # until a full rewrite is made. I've cleaned all cross-class uses of
154 # until a full rewrite is made. I've cleaned all cross-class uses of
155 # attributes and methods, but too much user code out there relies on the
155 # attributes and methods, but too much user code out there relies on the
156 # equlity %foo == __IP.magic_foo, so I can't actually remove the mixin usage.
156 # equlity %foo == __IP.magic_foo, so I can't actually remove the mixin usage.
157 #
157 #
158 # But at least now, all the pieces have been separated and we could, in
158 # But at least now, all the pieces have been separated and we could, in
159 # principle, stop using the mixin. This will ease the transition to the
159 # principle, stop using the mixin. This will ease the transition to the
160 # chainsaw branch.
160 # chainsaw branch.
161
161
162 # For reference, the following is the list of 'self.foo' uses in the Magic
162 # For reference, the following is the list of 'self.foo' uses in the Magic
163 # class as of 2005-12-28. These are names we CAN'T use in the main ipython
163 # class as of 2005-12-28. These are names we CAN'T use in the main ipython
164 # class, to prevent clashes.
164 # class, to prevent clashes.
165
165
166 # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind',
166 # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind',
167 # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic',
167 # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic',
168 # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell',
168 # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell',
169 # 'self.value']
169 # 'self.value']
170
170
171 class InteractiveShell(object,Magic):
171 class InteractiveShell(object,Magic):
172 """An enhanced console for Python."""
172 """An enhanced console for Python."""
173
173
174 # class attribute to indicate whether the class supports threads or not.
174 # class attribute to indicate whether the class supports threads or not.
175 # Subclasses with thread support should override this as needed.
175 # Subclasses with thread support should override this as needed.
176 isthreaded = False
176 isthreaded = False
177
177
178 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
178 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
179 user_ns = None,user_global_ns=None,banner2='',
179 user_ns = None,user_global_ns=None,banner2='',
180 custom_exceptions=((),None),embedded=False):
180 custom_exceptions=((),None),embedded=False):
181
181
182 # some minimal strict typechecks. For some core data structures, I
182 # some minimal strict typechecks. For some core data structures, I
183 # want actual basic python types, not just anything that looks like
183 # want actual basic python types, not just anything that looks like
184 # one. This is especially true for namespaces.
184 # one. This is especially true for namespaces.
185 for ns in (user_ns,user_global_ns):
185 for ns in (user_ns,user_global_ns):
186 if ns is not None and type(ns) != types.DictType:
186 if ns is not None and type(ns) != types.DictType:
187 raise TypeError,'namespace must be a dictionary'
187 raise TypeError,'namespace must be a dictionary'
188
188
189 # Job manager (for jobs run as background threads)
189 # Job manager (for jobs run as background threads)
190 self.jobs = BackgroundJobManager()
190 self.jobs = BackgroundJobManager()
191
191
192 # track which builtins we add, so we can clean up later
192 # track which builtins we add, so we can clean up later
193 self.builtins_added = {}
193 self.builtins_added = {}
194 # This method will add the necessary builtins for operation, but
194 # This method will add the necessary builtins for operation, but
195 # tracking what it did via the builtins_added dict.
195 # tracking what it did via the builtins_added dict.
196 self.add_builtins()
196 self.add_builtins()
197
197
198 # Do the intuitively correct thing for quit/exit: we remove the
198 # Do the intuitively correct thing for quit/exit: we remove the
199 # builtins if they exist, and our own magics will deal with this
199 # builtins if they exist, and our own magics will deal with this
200 try:
200 try:
201 del __builtin__.exit, __builtin__.quit
201 del __builtin__.exit, __builtin__.quit
202 except AttributeError:
202 except AttributeError:
203 pass
203 pass
204
204
205 # Store the actual shell's name
205 # Store the actual shell's name
206 self.name = name
206 self.name = name
207
207
208 # We need to know whether the instance is meant for embedding, since
208 # We need to know whether the instance is meant for embedding, since
209 # global/local namespaces need to be handled differently in that case
209 # global/local namespaces need to be handled differently in that case
210 self.embedded = embedded
210 self.embedded = embedded
211
211
212 # command compiler
212 # command compiler
213 self.compile = codeop.CommandCompiler()
213 self.compile = codeop.CommandCompiler()
214
214
215 # User input buffer
215 # User input buffer
216 self.buffer = []
216 self.buffer = []
217
217
218 # Default name given in compilation of code
218 # Default name given in compilation of code
219 self.filename = '<ipython console>'
219 self.filename = '<ipython console>'
220
220
221 # Make an empty namespace, which extension writers can rely on both
221 # Make an empty namespace, which extension writers can rely on both
222 # existing and NEVER being used by ipython itself. This gives them a
222 # existing and NEVER being used by ipython itself. This gives them a
223 # convenient location for storing additional information and state
223 # convenient location for storing additional information and state
224 # their extensions may require, without fear of collisions with other
224 # their extensions may require, without fear of collisions with other
225 # ipython names that may develop later.
225 # ipython names that may develop later.
226 self.meta = Bunch()
226 self.meta = Bunch()
227
227
228 # Create the namespace where the user will operate. user_ns is
228 # Create the namespace where the user will operate. user_ns is
229 # normally the only one used, and it is passed to the exec calls as
229 # normally the only one used, and it is passed to the exec calls as
230 # the locals argument. But we do carry a user_global_ns namespace
230 # the locals argument. But we do carry a user_global_ns namespace
231 # given as the exec 'globals' argument, This is useful in embedding
231 # given as the exec 'globals' argument, This is useful in embedding
232 # situations where the ipython shell opens in a context where the
232 # situations where the ipython shell opens in a context where the
233 # distinction between locals and globals is meaningful.
233 # distinction between locals and globals is meaningful.
234
234
235 # FIXME. For some strange reason, __builtins__ is showing up at user
235 # FIXME. For some strange reason, __builtins__ is showing up at user
236 # level as a dict instead of a module. This is a manual fix, but I
236 # level as a dict instead of a module. This is a manual fix, but I
237 # should really track down where the problem is coming from. Alex
237 # should really track down where the problem is coming from. Alex
238 # Schmolck reported this problem first.
238 # Schmolck reported this problem first.
239
239
240 # A useful post by Alex Martelli on this topic:
240 # A useful post by Alex Martelli on this topic:
241 # Re: inconsistent value from __builtins__
241 # Re: inconsistent value from __builtins__
242 # Von: Alex Martelli <aleaxit@yahoo.com>
242 # Von: Alex Martelli <aleaxit@yahoo.com>
243 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
243 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
244 # Gruppen: comp.lang.python
244 # Gruppen: comp.lang.python
245
245
246 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
246 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
247 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
247 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
248 # > <type 'dict'>
248 # > <type 'dict'>
249 # > >>> print type(__builtins__)
249 # > >>> print type(__builtins__)
250 # > <type 'module'>
250 # > <type 'module'>
251 # > Is this difference in return value intentional?
251 # > Is this difference in return value intentional?
252
252
253 # Well, it's documented that '__builtins__' can be either a dictionary
253 # Well, it's documented that '__builtins__' can be either a dictionary
254 # or a module, and it's been that way for a long time. Whether it's
254 # or a module, and it's been that way for a long time. Whether it's
255 # intentional (or sensible), I don't know. In any case, the idea is
255 # intentional (or sensible), I don't know. In any case, the idea is
256 # that if you need to access the built-in namespace directly, you
256 # that if you need to access the built-in namespace directly, you
257 # should start with "import __builtin__" (note, no 's') which will
257 # should start with "import __builtin__" (note, no 's') which will
258 # definitely give you a module. Yeah, it's somewhat confusing:-(.
258 # definitely give you a module. Yeah, it's somewhat confusing:-(.
259
259
260 if user_ns is None:
260 if user_ns is None:
261 # Set __name__ to __main__ to better match the behavior of the
261 # Set __name__ to __main__ to better match the behavior of the
262 # normal interpreter.
262 # normal interpreter.
263 user_ns = {'__name__' :'__main__',
263 user_ns = {'__name__' :'__main__',
264 '__builtins__' : __builtin__,
264 '__builtins__' : __builtin__,
265 }
265 }
266
266
267 if user_global_ns is None:
267 if user_global_ns is None:
268 user_global_ns = {}
268 user_global_ns = {}
269
269
270 # Assign namespaces
270 # Assign namespaces
271 # This is the namespace where all normal user variables live
271 # This is the namespace where all normal user variables live
272 self.user_ns = user_ns
272 self.user_ns = user_ns
273 # Embedded instances require a separate namespace for globals.
273 # Embedded instances require a separate namespace for globals.
274 # Normally this one is unused by non-embedded instances.
274 # Normally this one is unused by non-embedded instances.
275 self.user_global_ns = user_global_ns
275 self.user_global_ns = user_global_ns
276 # A namespace to keep track of internal data structures to prevent
276 # A namespace to keep track of internal data structures to prevent
277 # them from cluttering user-visible stuff. Will be updated later
277 # them from cluttering user-visible stuff. Will be updated later
278 self.internal_ns = {}
278 self.internal_ns = {}
279
279
280 # Namespace of system aliases. Each entry in the alias
280 # Namespace of system aliases. Each entry in the alias
281 # table must be a 2-tuple of the form (N,name), where N is the number
281 # table must be a 2-tuple of the form (N,name), where N is the number
282 # of positional arguments of the alias.
282 # of positional arguments of the alias.
283 self.alias_table = {}
283 self.alias_table = {}
284
284
285 # A table holding all the namespaces IPython deals with, so that
285 # A table holding all the namespaces IPython deals with, so that
286 # introspection facilities can search easily.
286 # introspection facilities can search easily.
287 self.ns_table = {'user':user_ns,
287 self.ns_table = {'user':user_ns,
288 'user_global':user_global_ns,
288 'user_global':user_global_ns,
289 'alias':self.alias_table,
289 'alias':self.alias_table,
290 'internal':self.internal_ns,
290 'internal':self.internal_ns,
291 'builtin':__builtin__.__dict__
291 'builtin':__builtin__.__dict__
292 }
292 }
293
293
294 # The user namespace MUST have a pointer to the shell itself.
294 # The user namespace MUST have a pointer to the shell itself.
295 self.user_ns[name] = self
295 self.user_ns[name] = self
296
296
297 # We need to insert into sys.modules something that looks like a
297 # We need to insert into sys.modules something that looks like a
298 # module but which accesses the IPython namespace, for shelve and
298 # module but which accesses the IPython namespace, for shelve and
299 # pickle to work interactively. Normally they rely on getting
299 # pickle to work interactively. Normally they rely on getting
300 # everything out of __main__, but for embedding purposes each IPython
300 # everything out of __main__, but for embedding purposes each IPython
301 # instance has its own private namespace, so we can't go shoving
301 # instance has its own private namespace, so we can't go shoving
302 # everything into __main__.
302 # everything into __main__.
303
303
304 # note, however, that we should only do this for non-embedded
304 # note, however, that we should only do this for non-embedded
305 # ipythons, which really mimic the __main__.__dict__ with their own
305 # ipythons, which really mimic the __main__.__dict__ with their own
306 # namespace. Embedded instances, on the other hand, should not do
306 # namespace. Embedded instances, on the other hand, should not do
307 # this because they need to manage the user local/global namespaces
307 # this because they need to manage the user local/global namespaces
308 # only, but they live within a 'normal' __main__ (meaning, they
308 # only, but they live within a 'normal' __main__ (meaning, they
309 # shouldn't overtake the execution environment of the script they're
309 # shouldn't overtake the execution environment of the script they're
310 # embedded in).
310 # embedded in).
311
311
312 if not embedded:
312 if not embedded:
313 try:
313 try:
314 main_name = self.user_ns['__name__']
314 main_name = self.user_ns['__name__']
315 except KeyError:
315 except KeyError:
316 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
316 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
317 else:
317 else:
318 #print "pickle hack in place" # dbg
318 #print "pickle hack in place" # dbg
319 #print 'main_name:',main_name # dbg
319 #print 'main_name:',main_name # dbg
320 sys.modules[main_name] = FakeModule(self.user_ns)
320 sys.modules[main_name] = FakeModule(self.user_ns)
321
321
322 # List of input with multi-line handling.
322 # List of input with multi-line handling.
323 # Fill its zero entry, user counter starts at 1
323 # Fill its zero entry, user counter starts at 1
324 self.input_hist = InputList(['\n'])
324 self.input_hist = InputList(['\n'])
325
325
326 # list of visited directories
326 # list of visited directories
327 try:
327 try:
328 self.dir_hist = [os.getcwd()]
328 self.dir_hist = [os.getcwd()]
329 except IOError, e:
329 except IOError, e:
330 self.dir_hist = []
330 self.dir_hist = []
331
331
332 # dict of output history
332 # dict of output history
333 self.output_hist = {}
333 self.output_hist = {}
334
334
335 # dict of things NOT to alias (keywords, builtins and some magics)
335 # dict of things NOT to alias (keywords, builtins and some magics)
336 no_alias = {}
336 no_alias = {}
337 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
337 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
338 for key in keyword.kwlist + no_alias_magics:
338 for key in keyword.kwlist + no_alias_magics:
339 no_alias[key] = 1
339 no_alias[key] = 1
340 no_alias.update(__builtin__.__dict__)
340 no_alias.update(__builtin__.__dict__)
341 self.no_alias = no_alias
341 self.no_alias = no_alias
342
342
343 # make global variables for user access to these
343 # make global variables for user access to these
344 self.user_ns['_ih'] = self.input_hist
344 self.user_ns['_ih'] = self.input_hist
345 self.user_ns['_oh'] = self.output_hist
345 self.user_ns['_oh'] = self.output_hist
346 self.user_ns['_dh'] = self.dir_hist
346 self.user_ns['_dh'] = self.dir_hist
347
347
348 # user aliases to input and output histories
348 # user aliases to input and output histories
349 self.user_ns['In'] = self.input_hist
349 self.user_ns['In'] = self.input_hist
350 self.user_ns['Out'] = self.output_hist
350 self.user_ns['Out'] = self.output_hist
351
351
352 # Object variable to store code object waiting execution. This is
352 # Object variable to store code object waiting execution. This is
353 # used mainly by the multithreaded shells, but it can come in handy in
353 # used mainly by the multithreaded shells, but it can come in handy in
354 # other situations. No need to use a Queue here, since it's a single
354 # other situations. No need to use a Queue here, since it's a single
355 # item which gets cleared once run.
355 # item which gets cleared once run.
356 self.code_to_run = None
356 self.code_to_run = None
357
357
358 # escapes for automatic behavior on the command line
358 # escapes for automatic behavior on the command line
359 self.ESC_SHELL = '!'
359 self.ESC_SHELL = '!'
360 self.ESC_HELP = '?'
360 self.ESC_HELP = '?'
361 self.ESC_MAGIC = '%'
361 self.ESC_MAGIC = '%'
362 self.ESC_QUOTE = ','
362 self.ESC_QUOTE = ','
363 self.ESC_QUOTE2 = ';'
363 self.ESC_QUOTE2 = ';'
364 self.ESC_PAREN = '/'
364 self.ESC_PAREN = '/'
365
365
366 # And their associated handlers
366 # And their associated handlers
367 self.esc_handlers = {self.ESC_PAREN : self.handle_auto,
367 self.esc_handlers = {self.ESC_PAREN : self.handle_auto,
368 self.ESC_QUOTE : self.handle_auto,
368 self.ESC_QUOTE : self.handle_auto,
369 self.ESC_QUOTE2 : self.handle_auto,
369 self.ESC_QUOTE2 : self.handle_auto,
370 self.ESC_MAGIC : self.handle_magic,
370 self.ESC_MAGIC : self.handle_magic,
371 self.ESC_HELP : self.handle_help,
371 self.ESC_HELP : self.handle_help,
372 self.ESC_SHELL : self.handle_shell_escape,
372 self.ESC_SHELL : self.handle_shell_escape,
373 }
373 }
374
374
375 # class initializations
375 # class initializations
376 Magic.__init__(self,self)
376 Magic.__init__(self,self)
377
377
378 # Python source parser/formatter for syntax highlighting
378 # Python source parser/formatter for syntax highlighting
379 pyformat = PyColorize.Parser().format
379 pyformat = PyColorize.Parser().format
380 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
380 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
381
381
382 # hooks holds pointers used for user-side customizations
382 # hooks holds pointers used for user-side customizations
383 self.hooks = Struct()
383 self.hooks = Struct()
384
384
385 # Set all default hooks, defined in the IPython.hooks module.
385 # Set all default hooks, defined in the IPython.hooks module.
386 hooks = IPython.hooks
386 hooks = IPython.hooks
387 for hook_name in hooks.__all__:
387 for hook_name in hooks.__all__:
388 self.set_hook(hook_name,getattr(hooks,hook_name))
388 self.set_hook(hook_name,getattr(hooks,hook_name))
389
389
390 # Flag to mark unconditional exit
390 # Flag to mark unconditional exit
391 self.exit_now = False
391 self.exit_now = False
392
392
393 self.usage_min = """\
393 self.usage_min = """\
394 An enhanced console for Python.
394 An enhanced console for Python.
395 Some of its features are:
395 Some of its features are:
396 - Readline support if the readline library is present.
396 - Readline support if the readline library is present.
397 - Tab completion in the local namespace.
397 - Tab completion in the local namespace.
398 - Logging of input, see command-line options.
398 - Logging of input, see command-line options.
399 - System shell escape via ! , eg !ls.
399 - System shell escape via ! , eg !ls.
400 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
400 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
401 - Keeps track of locally defined variables via %who, %whos.
401 - Keeps track of locally defined variables via %who, %whos.
402 - Show object information with a ? eg ?x or x? (use ?? for more info).
402 - Show object information with a ? eg ?x or x? (use ?? for more info).
403 """
403 """
404 if usage: self.usage = usage
404 if usage: self.usage = usage
405 else: self.usage = self.usage_min
405 else: self.usage = self.usage_min
406
406
407 # Storage
407 # Storage
408 self.rc = rc # This will hold all configuration information
408 self.rc = rc # This will hold all configuration information
409 self.pager = 'less'
409 self.pager = 'less'
410 # temporary files used for various purposes. Deleted at exit.
410 # temporary files used for various purposes. Deleted at exit.
411 self.tempfiles = []
411 self.tempfiles = []
412
412
413 # Keep track of readline usage (later set by init_readline)
413 # Keep track of readline usage (later set by init_readline)
414 self.has_readline = False
414 self.has_readline = False
415
415
416 # template for logfile headers. It gets resolved at runtime by the
416 # template for logfile headers. It gets resolved at runtime by the
417 # logstart method.
417 # logstart method.
418 self.loghead_tpl = \
418 self.loghead_tpl = \
419 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
419 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
420 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
420 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
421 #log# opts = %s
421 #log# opts = %s
422 #log# args = %s
422 #log# args = %s
423 #log# It is safe to make manual edits below here.
423 #log# It is safe to make manual edits below here.
424 #log#-----------------------------------------------------------------------
424 #log#-----------------------------------------------------------------------
425 """
425 """
426 # for pushd/popd management
426 # for pushd/popd management
427 try:
427 try:
428 self.home_dir = get_home_dir()
428 self.home_dir = get_home_dir()
429 except HomeDirError,msg:
429 except HomeDirError,msg:
430 fatal(msg)
430 fatal(msg)
431
431
432 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
432 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
433
433
434 # Functions to call the underlying shell.
434 # Functions to call the underlying shell.
435
435
436 # utility to expand user variables via Itpl
436 # utility to expand user variables via Itpl
437 self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'),
437 self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'),
438 self.user_ns))
438 self.user_ns))
439 # The first is similar to os.system, but it doesn't return a value,
439 # The first is similar to os.system, but it doesn't return a value,
440 # and it allows interpolation of variables in the user's namespace.
440 # and it allows interpolation of variables in the user's namespace.
441 self.system = lambda cmd: shell(self.var_expand(cmd),
441 self.system = lambda cmd: shell(self.var_expand(cmd),
442 header='IPython system call: ',
442 header='IPython system call: ',
443 verbose=self.rc.system_verbose)
443 verbose=self.rc.system_verbose)
444 # These are for getoutput and getoutputerror:
444 # These are for getoutput and getoutputerror:
445 self.getoutput = lambda cmd: \
445 self.getoutput = lambda cmd: \
446 getoutput(self.var_expand(cmd),
446 getoutput(self.var_expand(cmd),
447 header='IPython system call: ',
447 header='IPython system call: ',
448 verbose=self.rc.system_verbose)
448 verbose=self.rc.system_verbose)
449 self.getoutputerror = lambda cmd: \
449 self.getoutputerror = lambda cmd: \
450 getoutputerror(str(ItplNS(cmd.replace('#','\#'),
450 getoutputerror(str(ItplNS(cmd.replace('#','\#'),
451 self.user_ns)),
451 self.user_ns)),
452 header='IPython system call: ',
452 header='IPython system call: ',
453 verbose=self.rc.system_verbose)
453 verbose=self.rc.system_verbose)
454
454
455 # RegExp for splitting line contents into pre-char//first
455 # RegExp for splitting line contents into pre-char//first
456 # word-method//rest. For clarity, each group in on one line.
456 # word-method//rest. For clarity, each group in on one line.
457
457
458 # WARNING: update the regexp if the above escapes are changed, as they
458 # WARNING: update the regexp if the above escapes are changed, as they
459 # are hardwired in.
459 # are hardwired in.
460
460
461 # Don't get carried away with trying to make the autocalling catch too
461 # Don't get carried away with trying to make the autocalling catch too
462 # much: it's better to be conservative rather than to trigger hidden
462 # much: it's better to be conservative rather than to trigger hidden
463 # evals() somewhere and end up causing side effects.
463 # evals() somewhere and end up causing side effects.
464
464
465 self.line_split = re.compile(r'^([\s*,;/])'
465 self.line_split = re.compile(r'^([\s*,;/])'
466 r'([\?\w\.]+\w*\s*)'
466 r'([\?\w\.]+\w*\s*)'
467 r'(\(?.*$)')
467 r'(\(?.*$)')
468
468
469 # Original re, keep around for a while in case changes break something
469 # Original re, keep around for a while in case changes break something
470 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
470 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
471 # r'(\s*[\?\w\.]+\w*\s*)'
471 # r'(\s*[\?\w\.]+\w*\s*)'
472 # r'(\(?.*$)')
472 # r'(\(?.*$)')
473
473
474 # RegExp to identify potential function names
474 # RegExp to identify potential function names
475 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
475 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
476 # RegExp to exclude strings with this start from autocalling
476 # RegExp to exclude strings with this start from autocalling
477 self.re_exclude_auto = re.compile('^[!=()<>,\*/\+-]|^is ')
477 self.re_exclude_auto = re.compile('^[!=()<>,\*/\+-]|^is ')
478
478
479 # try to catch also methods for stuff in lists/tuples/dicts: off
479 # try to catch also methods for stuff in lists/tuples/dicts: off
480 # (experimental). For this to work, the line_split regexp would need
480 # (experimental). For this to work, the line_split regexp would need
481 # to be modified so it wouldn't break things at '['. That line is
481 # to be modified so it wouldn't break things at '['. That line is
482 # nasty enough that I shouldn't change it until I can test it _well_.
482 # nasty enough that I shouldn't change it until I can test it _well_.
483 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
483 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
484
484
485 # keep track of where we started running (mainly for crash post-mortem)
485 # keep track of where we started running (mainly for crash post-mortem)
486 self.starting_dir = os.getcwd()
486 self.starting_dir = os.getcwd()
487
487
488 # Various switches which can be set
488 # Various switches which can be set
489 self.CACHELENGTH = 5000 # this is cheap, it's just text
489 self.CACHELENGTH = 5000 # this is cheap, it's just text
490 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
490 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
491 self.banner2 = banner2
491 self.banner2 = banner2
492
492
493 # TraceBack handlers:
493 # TraceBack handlers:
494
494
495 # Syntax error handler.
495 # Syntax error handler.
496 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
496 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
497
497
498 # The interactive one is initialized with an offset, meaning we always
498 # The interactive one is initialized with an offset, meaning we always
499 # want to remove the topmost item in the traceback, which is our own
499 # want to remove the topmost item in the traceback, which is our own
500 # internal code. Valid modes: ['Plain','Context','Verbose']
500 # internal code. Valid modes: ['Plain','Context','Verbose']
501 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
501 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
502 color_scheme='NoColor',
502 color_scheme='NoColor',
503 tb_offset = 1)
503 tb_offset = 1)
504
504
505 # IPython itself shouldn't crash. This will produce a detailed
505 # IPython itself shouldn't crash. This will produce a detailed
506 # post-mortem if it does. But we only install the crash handler for
506 # post-mortem if it does. But we only install the crash handler for
507 # non-threaded shells, the threaded ones use a normal verbose reporter
507 # non-threaded shells, the threaded ones use a normal verbose reporter
508 # and lose the crash handler. This is because exceptions in the main
508 # and lose the crash handler. This is because exceptions in the main
509 # thread (such as in GUI code) propagate directly to sys.excepthook,
509 # thread (such as in GUI code) propagate directly to sys.excepthook,
510 # and there's no point in printing crash dumps for every user exception.
510 # and there's no point in printing crash dumps for every user exception.
511 if self.isthreaded:
511 if self.isthreaded:
512 sys.excepthook = ultraTB.FormattedTB()
512 sys.excepthook = ultraTB.FormattedTB()
513 else:
513 else:
514 from IPython import CrashHandler
514 from IPython import CrashHandler
515 sys.excepthook = CrashHandler.CrashHandler(self)
515 sys.excepthook = CrashHandler.CrashHandler(self)
516
516
517 # The instance will store a pointer to this, so that runtime code
517 # The instance will store a pointer to this, so that runtime code
518 # (such as magics) can access it. This is because during the
518 # (such as magics) can access it. This is because during the
519 # read-eval loop, it gets temporarily overwritten (to deal with GUI
519 # read-eval loop, it gets temporarily overwritten (to deal with GUI
520 # frameworks).
520 # frameworks).
521 self.sys_excepthook = sys.excepthook
521 self.sys_excepthook = sys.excepthook
522
522
523 # and add any custom exception handlers the user may have specified
523 # and add any custom exception handlers the user may have specified
524 self.set_custom_exc(*custom_exceptions)
524 self.set_custom_exc(*custom_exceptions)
525
525
526 # Object inspector
526 # Object inspector
527 self.inspector = OInspect.Inspector(OInspect.InspectColors,
527 self.inspector = OInspect.Inspector(OInspect.InspectColors,
528 PyColorize.ANSICodeColors,
528 PyColorize.ANSICodeColors,
529 'NoColor')
529 'NoColor')
530 # indentation management
530 # indentation management
531 self.autoindent = False
531 self.autoindent = False
532 self.indent_current_nsp = 0
532 self.indent_current_nsp = 0
533 self.indent_current = '' # actual indent string
533 self.indent_current = '' # actual indent string
534
534
535 # Make some aliases automatically
535 # Make some aliases automatically
536 # Prepare list of shell aliases to auto-define
536 # Prepare list of shell aliases to auto-define
537 if os.name == 'posix':
537 if os.name == 'posix':
538 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
538 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
539 'mv mv -i','rm rm -i','cp cp -i',
539 'mv mv -i','rm rm -i','cp cp -i',
540 'cat cat','less less','clear clear',
540 'cat cat','less less','clear clear',
541 # a better ls
541 # a better ls
542 'ls ls -F',
542 'ls ls -F',
543 # long ls
543 # long ls
544 'll ls -lF',
544 'll ls -lF',
545 # color ls
545 # color ls
546 'lc ls -F -o --color',
546 'lc ls -F -o --color',
547 # ls normal files only
547 # ls normal files only
548 'lf ls -F -o --color %l | grep ^-',
548 'lf ls -F -o --color %l | grep ^-',
549 # ls symbolic links
549 # ls symbolic links
550 'lk ls -F -o --color %l | grep ^l',
550 'lk ls -F -o --color %l | grep ^l',
551 # directories or links to directories,
551 # directories or links to directories,
552 'ldir ls -F -o --color %l | grep /$',
552 'ldir ls -F -o --color %l | grep /$',
553 # things which are executable
553 # things which are executable
554 'lx ls -F -o --color %l | grep ^-..x',
554 'lx ls -F -o --color %l | grep ^-..x',
555 )
555 )
556 elif os.name in ['nt','dos']:
556 elif os.name in ['nt','dos']:
557 auto_alias = ('dir dir /on', 'ls dir /on',
557 auto_alias = ('dir dir /on', 'ls dir /on',
558 'ddir dir /ad /on', 'ldir dir /ad /on',
558 'ddir dir /ad /on', 'ldir dir /ad /on',
559 'mkdir mkdir','rmdir rmdir','echo echo',
559 'mkdir mkdir','rmdir rmdir','echo echo',
560 'ren ren','cls cls','copy copy')
560 'ren ren','cls cls','copy copy')
561 else:
561 else:
562 auto_alias = ()
562 auto_alias = ()
563 self.auto_alias = map(lambda s:s.split(None,1),auto_alias)
563 self.auto_alias = map(lambda s:s.split(None,1),auto_alias)
564 # Call the actual (public) initializer
564 # Call the actual (public) initializer
565 self.init_auto_alias()
565 self.init_auto_alias()
566 # end __init__
566 # end __init__
567
567
568 def post_config_initialization(self):
568 def post_config_initialization(self):
569 """Post configuration init method
569 """Post configuration init method
570
570
571 This is called after the configuration files have been processed to
571 This is called after the configuration files have been processed to
572 'finalize' the initialization."""
572 'finalize' the initialization."""
573
573
574 rc = self.rc
574 rc = self.rc
575
575
576 # Load readline proper
576 # Load readline proper
577 if rc.readline:
577 if rc.readline:
578 self.init_readline()
578 self.init_readline()
579
579
580 # log system
580 # log system
581 self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate')
581 self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate')
582 # local shortcut, this is used a LOT
582 # local shortcut, this is used a LOT
583 self.log = self.logger.log
583 self.log = self.logger.log
584
584
585 # Initialize cache, set in/out prompts and printing system
585 # Initialize cache, set in/out prompts and printing system
586 self.outputcache = CachedOutput(self,
586 self.outputcache = CachedOutput(self,
587 rc.cache_size,
587 rc.cache_size,
588 rc.pprint,
588 rc.pprint,
589 input_sep = rc.separate_in,
589 input_sep = rc.separate_in,
590 output_sep = rc.separate_out,
590 output_sep = rc.separate_out,
591 output_sep2 = rc.separate_out2,
591 output_sep2 = rc.separate_out2,
592 ps1 = rc.prompt_in1,
592 ps1 = rc.prompt_in1,
593 ps2 = rc.prompt_in2,
593 ps2 = rc.prompt_in2,
594 ps_out = rc.prompt_out,
594 ps_out = rc.prompt_out,
595 pad_left = rc.prompts_pad_left)
595 pad_left = rc.prompts_pad_left)
596
596
597 # user may have over-ridden the default print hook:
597 # user may have over-ridden the default print hook:
598 try:
598 try:
599 self.outputcache.__class__.display = self.hooks.display
599 self.outputcache.__class__.display = self.hooks.display
600 except AttributeError:
600 except AttributeError:
601 pass
601 pass
602
602
603 # I don't like assigning globally to sys, because it means when embedding
603 # I don't like assigning globally to sys, because it means when embedding
604 # instances, each embedded instance overrides the previous choice. But
604 # instances, each embedded instance overrides the previous choice. But
605 # sys.displayhook seems to be called internally by exec, so I don't see a
605 # sys.displayhook seems to be called internally by exec, so I don't see a
606 # way around it.
606 # way around it.
607 sys.displayhook = self.outputcache
607 sys.displayhook = self.outputcache
608
608
609 # Set user colors (don't do it in the constructor above so that it
609 # Set user colors (don't do it in the constructor above so that it
610 # doesn't crash if colors option is invalid)
610 # doesn't crash if colors option is invalid)
611 self.magic_colors(rc.colors)
611 self.magic_colors(rc.colors)
612
612
613 # Set calling of pdb on exceptions
613 # Set calling of pdb on exceptions
614 self.call_pdb = rc.pdb
614 self.call_pdb = rc.pdb
615
615
616 # Load user aliases
616 # Load user aliases
617 for alias in rc.alias:
617 for alias in rc.alias:
618 self.magic_alias(alias)
618 self.magic_alias(alias)
619
619
620 # dynamic data that survives through sessions
620 # dynamic data that survives through sessions
621 # XXX make the filename a config option?
621 # XXX make the filename a config option?
622 persist_base = 'persist'
622 persist_base = 'persist'
623 if rc.profile:
623 if rc.profile:
624 persist_base += '_%s' % rc.profile
624 persist_base += '_%s' % rc.profile
625 self.persist_fname = os.path.join(rc.ipythondir,persist_base)
625 self.persist_fname = os.path.join(rc.ipythondir,persist_base)
626
626
627 try:
627 try:
628 self.persist = pickle.load(file(self.persist_fname))
628 self.persist = pickle.load(file(self.persist_fname))
629 except:
629 except:
630 self.persist = {}
630 self.persist = {}
631
631
632
632
633 for (key, value) in [(k[2:],v) for (k,v) in self.persist.items() if k.startswith('S:')]:
633 for (key, value) in [(k[2:],v) for (k,v) in self.persist.items() if k.startswith('S:')]:
634 try:
634 try:
635 obj = pickle.loads(value)
635 obj = pickle.loads(value)
636 except:
636 except:
637
637
638 print "Unable to restore variable '%s', ignoring (use %%store -d to forget!)" % key
638 print "Unable to restore variable '%s', ignoring (use %%store -d to forget!)" % key
639 print "The error was:",sys.exc_info()[0]
639 print "The error was:",sys.exc_info()[0]
640 continue
640 continue
641
641
642
642
643 self.user_ns[key] = obj
643 self.user_ns[key] = obj
644
644
645 def add_builtins(self):
645 def add_builtins(self):
646 """Store ipython references into the builtin namespace.
646 """Store ipython references into the builtin namespace.
647
647
648 Some parts of ipython operate via builtins injected here, which hold a
648 Some parts of ipython operate via builtins injected here, which hold a
649 reference to IPython itself."""
649 reference to IPython itself."""
650
650
651 builtins_new = dict(__IPYTHON__ = self,
651 builtins_new = dict(__IPYTHON__ = self,
652 ip_set_hook = self.set_hook,
652 ip_set_hook = self.set_hook,
653 jobs = self.jobs,
653 jobs = self.jobs,
654 ipmagic = self.ipmagic,
654 ipmagic = self.ipmagic,
655 ipalias = self.ipalias,
655 ipalias = self.ipalias,
656 ipsystem = self.ipsystem,
656 ipsystem = self.ipsystem,
657 )
657 )
658 for biname,bival in builtins_new.items():
658 for biname,bival in builtins_new.items():
659 try:
659 try:
660 # store the orignal value so we can restore it
660 # store the orignal value so we can restore it
661 self.builtins_added[biname] = __builtin__.__dict__[biname]
661 self.builtins_added[biname] = __builtin__.__dict__[biname]
662 except KeyError:
662 except KeyError:
663 # or mark that it wasn't defined, and we'll just delete it at
663 # or mark that it wasn't defined, and we'll just delete it at
664 # cleanup
664 # cleanup
665 self.builtins_added[biname] = Undefined
665 self.builtins_added[biname] = Undefined
666 __builtin__.__dict__[biname] = bival
666 __builtin__.__dict__[biname] = bival
667
667
668 # Keep in the builtins a flag for when IPython is active. We set it
668 # Keep in the builtins a flag for when IPython is active. We set it
669 # with setdefault so that multiple nested IPythons don't clobber one
669 # with setdefault so that multiple nested IPythons don't clobber one
670 # another. Each will increase its value by one upon being activated,
670 # another. Each will increase its value by one upon being activated,
671 # which also gives us a way to determine the nesting level.
671 # which also gives us a way to determine the nesting level.
672 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
672 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
673
673
674 def clean_builtins(self):
674 def clean_builtins(self):
675 """Remove any builtins which might have been added by add_builtins, or
675 """Remove any builtins which might have been added by add_builtins, or
676 restore overwritten ones to their previous values."""
676 restore overwritten ones to their previous values."""
677 for biname,bival in self.builtins_added.items():
677 for biname,bival in self.builtins_added.items():
678 if bival is Undefined:
678 if bival is Undefined:
679 del __builtin__.__dict__[biname]
679 del __builtin__.__dict__[biname]
680 else:
680 else:
681 __builtin__.__dict__[biname] = bival
681 __builtin__.__dict__[biname] = bival
682 self.builtins_added.clear()
682 self.builtins_added.clear()
683
683
684 def set_hook(self,name,hook):
684 def set_hook(self,name,hook):
685 """set_hook(name,hook) -> sets an internal IPython hook.
685 """set_hook(name,hook) -> sets an internal IPython hook.
686
686
687 IPython exposes some of its internal API as user-modifiable hooks. By
687 IPython exposes some of its internal API as user-modifiable hooks. By
688 resetting one of these hooks, you can modify IPython's behavior to
688 resetting one of these hooks, you can modify IPython's behavior to
689 call at runtime your own routines."""
689 call at runtime your own routines."""
690
690
691 # At some point in the future, this should validate the hook before it
691 # At some point in the future, this should validate the hook before it
692 # accepts it. Probably at least check that the hook takes the number
692 # accepts it. Probably at least check that the hook takes the number
693 # of args it's supposed to.
693 # of args it's supposed to.
694 setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
694 setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
695
695
696 def set_custom_exc(self,exc_tuple,handler):
696 def set_custom_exc(self,exc_tuple,handler):
697 """set_custom_exc(exc_tuple,handler)
697 """set_custom_exc(exc_tuple,handler)
698
698
699 Set a custom exception handler, which will be called if any of the
699 Set a custom exception handler, which will be called if any of the
700 exceptions in exc_tuple occur in the mainloop (specifically, in the
700 exceptions in exc_tuple occur in the mainloop (specifically, in the
701 runcode() method.
701 runcode() method.
702
702
703 Inputs:
703 Inputs:
704
704
705 - exc_tuple: a *tuple* of valid exceptions to call the defined
705 - exc_tuple: a *tuple* of valid exceptions to call the defined
706 handler for. It is very important that you use a tuple, and NOT A
706 handler for. It is very important that you use a tuple, and NOT A
707 LIST here, because of the way Python's except statement works. If
707 LIST here, because of the way Python's except statement works. If
708 you only want to trap a single exception, use a singleton tuple:
708 you only want to trap a single exception, use a singleton tuple:
709
709
710 exc_tuple == (MyCustomException,)
710 exc_tuple == (MyCustomException,)
711
711
712 - handler: this must be defined as a function with the following
712 - handler: this must be defined as a function with the following
713 basic interface: def my_handler(self,etype,value,tb).
713 basic interface: def my_handler(self,etype,value,tb).
714
714
715 This will be made into an instance method (via new.instancemethod)
715 This will be made into an instance method (via new.instancemethod)
716 of IPython itself, and it will be called if any of the exceptions
716 of IPython itself, and it will be called if any of the exceptions
717 listed in the exc_tuple are caught. If the handler is None, an
717 listed in the exc_tuple are caught. If the handler is None, an
718 internal basic one is used, which just prints basic info.
718 internal basic one is used, which just prints basic info.
719
719
720 WARNING: by putting in your own exception handler into IPython's main
720 WARNING: by putting in your own exception handler into IPython's main
721 execution loop, you run a very good chance of nasty crashes. This
721 execution loop, you run a very good chance of nasty crashes. This
722 facility should only be used if you really know what you are doing."""
722 facility should only be used if you really know what you are doing."""
723
723
724 assert type(exc_tuple)==type(()) , \
724 assert type(exc_tuple)==type(()) , \
725 "The custom exceptions must be given AS A TUPLE."
725 "The custom exceptions must be given AS A TUPLE."
726
726
727 def dummy_handler(self,etype,value,tb):
727 def dummy_handler(self,etype,value,tb):
728 print '*** Simple custom exception handler ***'
728 print '*** Simple custom exception handler ***'
729 print 'Exception type :',etype
729 print 'Exception type :',etype
730 print 'Exception value:',value
730 print 'Exception value:',value
731 print 'Traceback :',tb
731 print 'Traceback :',tb
732 print 'Source code :','\n'.join(self.buffer)
732 print 'Source code :','\n'.join(self.buffer)
733
733
734 if handler is None: handler = dummy_handler
734 if handler is None: handler = dummy_handler
735
735
736 self.CustomTB = new.instancemethod(handler,self,self.__class__)
736 self.CustomTB = new.instancemethod(handler,self,self.__class__)
737 self.custom_exceptions = exc_tuple
737 self.custom_exceptions = exc_tuple
738
738
739 def set_custom_completer(self,completer,pos=0):
739 def set_custom_completer(self,completer,pos=0):
740 """set_custom_completer(completer,pos=0)
740 """set_custom_completer(completer,pos=0)
741
741
742 Adds a new custom completer function.
742 Adds a new custom completer function.
743
743
744 The position argument (defaults to 0) is the index in the completers
744 The position argument (defaults to 0) is the index in the completers
745 list where you want the completer to be inserted."""
745 list where you want the completer to be inserted."""
746
746
747 newcomp = new.instancemethod(completer,self.Completer,
747 newcomp = new.instancemethod(completer,self.Completer,
748 self.Completer.__class__)
748 self.Completer.__class__)
749 self.Completer.matchers.insert(pos,newcomp)
749 self.Completer.matchers.insert(pos,newcomp)
750
750
751 def _get_call_pdb(self):
751 def _get_call_pdb(self):
752 return self._call_pdb
752 return self._call_pdb
753
753
754 def _set_call_pdb(self,val):
754 def _set_call_pdb(self,val):
755
755
756 if val not in (0,1,False,True):
756 if val not in (0,1,False,True):
757 raise ValueError,'new call_pdb value must be boolean'
757 raise ValueError,'new call_pdb value must be boolean'
758
758
759 # store value in instance
759 # store value in instance
760 self._call_pdb = val
760 self._call_pdb = val
761
761
762 # notify the actual exception handlers
762 # notify the actual exception handlers
763 self.InteractiveTB.call_pdb = val
763 self.InteractiveTB.call_pdb = val
764 if self.isthreaded:
764 if self.isthreaded:
765 try:
765 try:
766 self.sys_excepthook.call_pdb = val
766 self.sys_excepthook.call_pdb = val
767 except:
767 except:
768 warn('Failed to activate pdb for threaded exception handler')
768 warn('Failed to activate pdb for threaded exception handler')
769
769
770 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
770 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
771 'Control auto-activation of pdb at exceptions')
771 'Control auto-activation of pdb at exceptions')
772
772
773
773
774 # These special functions get installed in the builtin namespace, to
774 # These special functions get installed in the builtin namespace, to
775 # provide programmatic (pure python) access to magics, aliases and system
775 # provide programmatic (pure python) access to magics, aliases and system
776 # calls. This is important for logging, user scripting, and more.
776 # calls. This is important for logging, user scripting, and more.
777
777
778 # We are basically exposing, via normal python functions, the three
778 # We are basically exposing, via normal python functions, the three
779 # mechanisms in which ipython offers special call modes (magics for
779 # mechanisms in which ipython offers special call modes (magics for
780 # internal control, aliases for direct system access via pre-selected
780 # internal control, aliases for direct system access via pre-selected
781 # names, and !cmd for calling arbitrary system commands).
781 # names, and !cmd for calling arbitrary system commands).
782
782
783 def ipmagic(self,arg_s):
783 def ipmagic(self,arg_s):
784 """Call a magic function by name.
784 """Call a magic function by name.
785
785
786 Input: a string containing the name of the magic function to call and any
786 Input: a string containing the name of the magic function to call and any
787 additional arguments to be passed to the magic.
787 additional arguments to be passed to the magic.
788
788
789 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
789 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
790 prompt:
790 prompt:
791
791
792 In[1]: %name -opt foo bar
792 In[1]: %name -opt foo bar
793
793
794 To call a magic without arguments, simply use ipmagic('name').
794 To call a magic without arguments, simply use ipmagic('name').
795
795
796 This provides a proper Python function to call IPython's magics in any
796 This provides a proper Python function to call IPython's magics in any
797 valid Python code you can type at the interpreter, including loops and
797 valid Python code you can type at the interpreter, including loops and
798 compound statements. It is added by IPython to the Python builtin
798 compound statements. It is added by IPython to the Python builtin
799 namespace upon initialization."""
799 namespace upon initialization."""
800
800
801 args = arg_s.split(' ',1)
801 args = arg_s.split(' ',1)
802 magic_name = args[0]
802 magic_name = args[0]
803 if magic_name.startswith(self.ESC_MAGIC):
803 if magic_name.startswith(self.ESC_MAGIC):
804 magic_name = magic_name[1:]
804 magic_name = magic_name[1:]
805 try:
805 try:
806 magic_args = args[1]
806 magic_args = args[1]
807 except IndexError:
807 except IndexError:
808 magic_args = ''
808 magic_args = ''
809 fn = getattr(self,'magic_'+magic_name,None)
809 fn = getattr(self,'magic_'+magic_name,None)
810 if fn is None:
810 if fn is None:
811 error("Magic function `%s` not found." % magic_name)
811 error("Magic function `%s` not found." % magic_name)
812 else:
812 else:
813 magic_args = self.var_expand(magic_args)
813 magic_args = self.var_expand(magic_args)
814 return fn(magic_args)
814 return fn(magic_args)
815
815
816 def ipalias(self,arg_s):
816 def ipalias(self,arg_s):
817 """Call an alias by name.
817 """Call an alias by name.
818
818
819 Input: a string containing the name of the alias to call and any
819 Input: a string containing the name of the alias to call and any
820 additional arguments to be passed to the magic.
820 additional arguments to be passed to the magic.
821
821
822 ipalias('name -opt foo bar') is equivalent to typing at the ipython
822 ipalias('name -opt foo bar') is equivalent to typing at the ipython
823 prompt:
823 prompt:
824
824
825 In[1]: name -opt foo bar
825 In[1]: name -opt foo bar
826
826
827 To call an alias without arguments, simply use ipalias('name').
827 To call an alias without arguments, simply use ipalias('name').
828
828
829 This provides a proper Python function to call IPython's aliases in any
829 This provides a proper Python function to call IPython's aliases in any
830 valid Python code you can type at the interpreter, including loops and
830 valid Python code you can type at the interpreter, including loops and
831 compound statements. It is added by IPython to the Python builtin
831 compound statements. It is added by IPython to the Python builtin
832 namespace upon initialization."""
832 namespace upon initialization."""
833
833
834 args = arg_s.split(' ',1)
834 args = arg_s.split(' ',1)
835 alias_name = args[0]
835 alias_name = args[0]
836 try:
836 try:
837 alias_args = args[1]
837 alias_args = args[1]
838 except IndexError:
838 except IndexError:
839 alias_args = ''
839 alias_args = ''
840 if alias_name in self.alias_table:
840 if alias_name in self.alias_table:
841 self.call_alias(alias_name,alias_args)
841 self.call_alias(alias_name,alias_args)
842 else:
842 else:
843 error("Alias `%s` not found." % alias_name)
843 error("Alias `%s` not found." % alias_name)
844
844
845 def ipsystem(self,arg_s):
845 def ipsystem(self,arg_s):
846 """Make a system call, using IPython."""
846 """Make a system call, using IPython."""
847
847
848 self.system(arg_s)
848 self.system(arg_s)
849
849
850 def complete(self,text):
850 def complete(self,text):
851 """Return a sorted list of all possible completions on text.
851 """Return a sorted list of all possible completions on text.
852
852
853 Inputs:
853 Inputs:
854
854
855 - text: a string of text to be completed on.
855 - text: a string of text to be completed on.
856
856
857 This is a wrapper around the completion mechanism, similar to what
857 This is a wrapper around the completion mechanism, similar to what
858 readline does at the command line when the TAB key is hit. By
858 readline does at the command line when the TAB key is hit. By
859 exposing it as a method, it can be used by other non-readline
859 exposing it as a method, it can be used by other non-readline
860 environments (such as GUIs) for text completion.
860 environments (such as GUIs) for text completion.
861
861
862 Simple usage example:
862 Simple usage example:
863
863
864 In [1]: x = 'hello'
864 In [1]: x = 'hello'
865
865
866 In [2]: __IP.complete('x.l')
866 In [2]: __IP.complete('x.l')
867 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
867 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
868
868
869 complete = self.Completer.complete
869 complete = self.Completer.complete
870 state = 0
870 state = 0
871 # use a dict so we get unique keys, since ipyhton's multiple
871 # use a dict so we get unique keys, since ipyhton's multiple
872 # completers can return duplicates.
872 # completers can return duplicates.
873 comps = {}
873 comps = {}
874 while True:
874 while True:
875 newcomp = complete(text,state)
875 newcomp = complete(text,state)
876 if newcomp is None:
876 if newcomp is None:
877 break
877 break
878 comps[newcomp] = 1
878 comps[newcomp] = 1
879 state += 1
879 state += 1
880 outcomps = comps.keys()
880 outcomps = comps.keys()
881 outcomps.sort()
881 outcomps.sort()
882 return outcomps
882 return outcomps
883
883
884 def set_completer_frame(self, frame=None):
884 def set_completer_frame(self, frame=None):
885 if frame:
885 if frame:
886 self.Completer.namespace = frame.f_locals
886 self.Completer.namespace = frame.f_locals
887 self.Completer.global_namespace = frame.f_globals
887 self.Completer.global_namespace = frame.f_globals
888 else:
888 else:
889 self.Completer.namespace = self.user_ns
889 self.Completer.namespace = self.user_ns
890 self.Completer.global_namespace = self.user_global_ns
890 self.Completer.global_namespace = self.user_global_ns
891
891
892 def init_auto_alias(self):
892 def init_auto_alias(self):
893 """Define some aliases automatically.
893 """Define some aliases automatically.
894
894
895 These are ALL parameter-less aliases"""
895 These are ALL parameter-less aliases"""
896
896
897 for alias,cmd in self.auto_alias:
897 for alias,cmd in self.auto_alias:
898 self.alias_table[alias] = (0,cmd)
898 self.alias_table[alias] = (0,cmd)
899
899
900 def alias_table_validate(self,verbose=0):
900 def alias_table_validate(self,verbose=0):
901 """Update information about the alias table.
901 """Update information about the alias table.
902
902
903 In particular, make sure no Python keywords/builtins are in it."""
903 In particular, make sure no Python keywords/builtins are in it."""
904
904
905 no_alias = self.no_alias
905 no_alias = self.no_alias
906 for k in self.alias_table.keys():
906 for k in self.alias_table.keys():
907 if k in no_alias:
907 if k in no_alias:
908 del self.alias_table[k]
908 del self.alias_table[k]
909 if verbose:
909 if verbose:
910 print ("Deleting alias <%s>, it's a Python "
910 print ("Deleting alias <%s>, it's a Python "
911 "keyword or builtin." % k)
911 "keyword or builtin." % k)
912
912
913 def set_autoindent(self,value=None):
913 def set_autoindent(self,value=None):
914 """Set the autoindent flag, checking for readline support.
914 """Set the autoindent flag, checking for readline support.
915
915
916 If called with no arguments, it acts as a toggle."""
916 If called with no arguments, it acts as a toggle."""
917
917
918 if not self.has_readline:
918 if not self.has_readline:
919 if os.name == 'posix':
919 if os.name == 'posix':
920 warn("The auto-indent feature requires the readline library")
920 warn("The auto-indent feature requires the readline library")
921 self.autoindent = 0
921 self.autoindent = 0
922 return
922 return
923 if value is None:
923 if value is None:
924 self.autoindent = not self.autoindent
924 self.autoindent = not self.autoindent
925 else:
925 else:
926 self.autoindent = value
926 self.autoindent = value
927
927
928 def rc_set_toggle(self,rc_field,value=None):
928 def rc_set_toggle(self,rc_field,value=None):
929 """Set or toggle a field in IPython's rc config. structure.
929 """Set or toggle a field in IPython's rc config. structure.
930
930
931 If called with no arguments, it acts as a toggle.
931 If called with no arguments, it acts as a toggle.
932
932
933 If called with a non-existent field, the resulting AttributeError
933 If called with a non-existent field, the resulting AttributeError
934 exception will propagate out."""
934 exception will propagate out."""
935
935
936 rc_val = getattr(self.rc,rc_field)
936 rc_val = getattr(self.rc,rc_field)
937 if value is None:
937 if value is None:
938 value = not rc_val
938 value = not rc_val
939 setattr(self.rc,rc_field,value)
939 setattr(self.rc,rc_field,value)
940
940
941 def user_setup(self,ipythondir,rc_suffix,mode='install'):
941 def user_setup(self,ipythondir,rc_suffix,mode='install'):
942 """Install the user configuration directory.
942 """Install the user configuration directory.
943
943
944 Can be called when running for the first time or to upgrade the user's
944 Can be called when running for the first time or to upgrade the user's
945 .ipython/ directory with the mode parameter. Valid modes are 'install'
945 .ipython/ directory with the mode parameter. Valid modes are 'install'
946 and 'upgrade'."""
946 and 'upgrade'."""
947
947
948 def wait():
948 def wait():
949 try:
949 try:
950 raw_input("Please press <RETURN> to start IPython.")
950 raw_input("Please press <RETURN> to start IPython.")
951 except EOFError:
951 except EOFError:
952 print >> Term.cout
952 print >> Term.cout
953 print '*'*70
953 print '*'*70
954
954
955 cwd = os.getcwd() # remember where we started
955 cwd = os.getcwd() # remember where we started
956 glb = glob.glob
956 glb = glob.glob
957 print '*'*70
957 print '*'*70
958 if mode == 'install':
958 if mode == 'install':
959 print \
959 print \
960 """Welcome to IPython. I will try to create a personal configuration directory
960 """Welcome to IPython. I will try to create a personal configuration directory
961 where you can customize many aspects of IPython's functionality in:\n"""
961 where you can customize many aspects of IPython's functionality in:\n"""
962 else:
962 else:
963 print 'I am going to upgrade your configuration in:'
963 print 'I am going to upgrade your configuration in:'
964
964
965 print ipythondir
965 print ipythondir
966
966
967 rcdirend = os.path.join('IPython','UserConfig')
967 rcdirend = os.path.join('IPython','UserConfig')
968 cfg = lambda d: os.path.join(d,rcdirend)
968 cfg = lambda d: os.path.join(d,rcdirend)
969 try:
969 try:
970 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
970 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
971 except IOError:
971 except IOError:
972 warning = """
972 warning = """
973 Installation error. IPython's directory was not found.
973 Installation error. IPython's directory was not found.
974
974
975 Check the following:
975 Check the following:
976
976
977 The ipython/IPython directory should be in a directory belonging to your
977 The ipython/IPython directory should be in a directory belonging to your
978 PYTHONPATH environment variable (that is, it should be in a directory
978 PYTHONPATH environment variable (that is, it should be in a directory
979 belonging to sys.path). You can copy it explicitly there or just link to it.
979 belonging to sys.path). You can copy it explicitly there or just link to it.
980
980
981 IPython will proceed with builtin defaults.
981 IPython will proceed with builtin defaults.
982 """
982 """
983 warn(warning)
983 warn(warning)
984 wait()
984 wait()
985 return
985 return
986
986
987 if mode == 'install':
987 if mode == 'install':
988 try:
988 try:
989 shutil.copytree(rcdir,ipythondir)
989 shutil.copytree(rcdir,ipythondir)
990 os.chdir(ipythondir)
990 os.chdir(ipythondir)
991 rc_files = glb("ipythonrc*")
991 rc_files = glb("ipythonrc*")
992 for rc_file in rc_files:
992 for rc_file in rc_files:
993 os.rename(rc_file,rc_file+rc_suffix)
993 os.rename(rc_file,rc_file+rc_suffix)
994 except:
994 except:
995 warning = """
995 warning = """
996
996
997 There was a problem with the installation:
997 There was a problem with the installation:
998 %s
998 %s
999 Try to correct it or contact the developers if you think it's a bug.
999 Try to correct it or contact the developers if you think it's a bug.
1000 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1000 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1001 warn(warning)
1001 warn(warning)
1002 wait()
1002 wait()
1003 return
1003 return
1004
1004
1005 elif mode == 'upgrade':
1005 elif mode == 'upgrade':
1006 try:
1006 try:
1007 os.chdir(ipythondir)
1007 os.chdir(ipythondir)
1008 except:
1008 except:
1009 print """
1009 print """
1010 Can not upgrade: changing to directory %s failed. Details:
1010 Can not upgrade: changing to directory %s failed. Details:
1011 %s
1011 %s
1012 """ % (ipythondir,sys.exc_info()[1])
1012 """ % (ipythondir,sys.exc_info()[1])
1013 wait()
1013 wait()
1014 return
1014 return
1015 else:
1015 else:
1016 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1016 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1017 for new_full_path in sources:
1017 for new_full_path in sources:
1018 new_filename = os.path.basename(new_full_path)
1018 new_filename = os.path.basename(new_full_path)
1019 if new_filename.startswith('ipythonrc'):
1019 if new_filename.startswith('ipythonrc'):
1020 new_filename = new_filename + rc_suffix
1020 new_filename = new_filename + rc_suffix
1021 # The config directory should only contain files, skip any
1021 # The config directory should only contain files, skip any
1022 # directories which may be there (like CVS)
1022 # directories which may be there (like CVS)
1023 if os.path.isdir(new_full_path):
1023 if os.path.isdir(new_full_path):
1024 continue
1024 continue
1025 if os.path.exists(new_filename):
1025 if os.path.exists(new_filename):
1026 old_file = new_filename+'.old'
1026 old_file = new_filename+'.old'
1027 if os.path.exists(old_file):
1027 if os.path.exists(old_file):
1028 os.remove(old_file)
1028 os.remove(old_file)
1029 os.rename(new_filename,old_file)
1029 os.rename(new_filename,old_file)
1030 shutil.copy(new_full_path,new_filename)
1030 shutil.copy(new_full_path,new_filename)
1031 else:
1031 else:
1032 raise ValueError,'unrecognized mode for install:',`mode`
1032 raise ValueError,'unrecognized mode for install:',`mode`
1033
1033
1034 # Fix line-endings to those native to each platform in the config
1034 # Fix line-endings to those native to each platform in the config
1035 # directory.
1035 # directory.
1036 try:
1036 try:
1037 os.chdir(ipythondir)
1037 os.chdir(ipythondir)
1038 except:
1038 except:
1039 print """
1039 print """
1040 Problem: changing to directory %s failed.
1040 Problem: changing to directory %s failed.
1041 Details:
1041 Details:
1042 %s
1042 %s
1043
1043
1044 Some configuration files may have incorrect line endings. This should not
1044 Some configuration files may have incorrect line endings. This should not
1045 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1045 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1046 wait()
1046 wait()
1047 else:
1047 else:
1048 for fname in glb('ipythonrc*'):
1048 for fname in glb('ipythonrc*'):
1049 try:
1049 try:
1050 native_line_ends(fname,backup=0)
1050 native_line_ends(fname,backup=0)
1051 except IOError:
1051 except IOError:
1052 pass
1052 pass
1053
1053
1054 if mode == 'install':
1054 if mode == 'install':
1055 print """
1055 print """
1056 Successful installation!
1056 Successful installation!
1057
1057
1058 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1058 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1059 IPython manual (there are both HTML and PDF versions supplied with the
1059 IPython manual (there are both HTML and PDF versions supplied with the
1060 distribution) to make sure that your system environment is properly configured
1060 distribution) to make sure that your system environment is properly configured
1061 to take advantage of IPython's features."""
1061 to take advantage of IPython's features."""
1062 else:
1062 else:
1063 print """
1063 print """
1064 Successful upgrade!
1064 Successful upgrade!
1065
1065
1066 All files in your directory:
1066 All files in your directory:
1067 %(ipythondir)s
1067 %(ipythondir)s
1068 which would have been overwritten by the upgrade were backed up with a .old
1068 which would have been overwritten by the upgrade were backed up with a .old
1069 extension. If you had made particular customizations in those files you may
1069 extension. If you had made particular customizations in those files you may
1070 want to merge them back into the new files.""" % locals()
1070 want to merge them back into the new files.""" % locals()
1071 wait()
1071 wait()
1072 os.chdir(cwd)
1072 os.chdir(cwd)
1073 # end user_setup()
1073 # end user_setup()
1074
1074
1075 def atexit_operations(self):
1075 def atexit_operations(self):
1076 """This will be executed at the time of exit.
1076 """This will be executed at the time of exit.
1077
1077
1078 Saving of persistent data should be performed here. """
1078 Saving of persistent data should be performed here. """
1079
1079
1080 # input history
1080 # input history
1081 self.savehist()
1081 self.savehist()
1082
1082
1083 # Cleanup all tempfiles left around
1083 # Cleanup all tempfiles left around
1084 for tfile in self.tempfiles:
1084 for tfile in self.tempfiles:
1085 try:
1085 try:
1086 os.unlink(tfile)
1086 os.unlink(tfile)
1087 except OSError:
1087 except OSError:
1088 pass
1088 pass
1089
1089
1090 # save the "persistent data" catch-all dictionary
1090 # save the "persistent data" catch-all dictionary
1091 try:
1091 try:
1092 pickle.dump(self.persist, open(self.persist_fname,"w"))
1092 pickle.dump(self.persist, open(self.persist_fname,"w"))
1093 except:
1093 except:
1094 print "*** ERROR *** persistent data saving failed."
1094 print "*** ERROR *** persistent data saving failed."
1095
1095
1096 def savehist(self):
1096 def savehist(self):
1097 """Save input history to a file (via readline library)."""
1097 """Save input history to a file (via readline library)."""
1098 try:
1098 try:
1099 self.readline.write_history_file(self.histfile)
1099 self.readline.write_history_file(self.histfile)
1100 except:
1100 except:
1101 print 'Unable to save IPython command history to file: ' + \
1101 print 'Unable to save IPython command history to file: ' + \
1102 `self.histfile`
1102 `self.histfile`
1103
1103
1104 def pre_readline(self):
1104 def pre_readline(self):
1105 """readline hook to be used at the start of each line.
1105 """readline hook to be used at the start of each line.
1106
1106
1107 Currently it handles auto-indent only."""
1107 Currently it handles auto-indent only."""
1108
1108
1109 self.readline.insert_text(self.indent_current)
1109 self.readline.insert_text(self.indent_current)
1110
1110
1111 def init_readline(self):
1111 def init_readline(self):
1112 """Command history completion/saving/reloading."""
1112 """Command history completion/saving/reloading."""
1113 try:
1113 try:
1114 import readline
1114 import readline
1115 except ImportError:
1115 except ImportError:
1116 self.has_readline = 0
1116 self.has_readline = 0
1117 self.readline = None
1117 self.readline = None
1118 # no point in bugging windows users with this every time:
1118 # no point in bugging windows users with this every time:
1119 if os.name == 'posix':
1119 if os.name == 'posix':
1120 warn('Readline services not available on this platform.')
1120 warn('Readline services not available on this platform.')
1121 else:
1121 else:
1122 import atexit
1122 import atexit
1123 from IPython.completer import IPCompleter
1123 from IPython.completer import IPCompleter
1124 self.Completer = IPCompleter(self,
1124 self.Completer = IPCompleter(self,
1125 self.user_ns,
1125 self.user_ns,
1126 self.user_global_ns,
1126 self.user_global_ns,
1127 self.rc.readline_omit__names,
1127 self.rc.readline_omit__names,
1128 self.alias_table)
1128 self.alias_table)
1129
1129
1130 # Platform-specific configuration
1130 # Platform-specific configuration
1131 if os.name == 'nt':
1131 if os.name == 'nt':
1132 self.readline_startup_hook = readline.set_pre_input_hook
1132 self.readline_startup_hook = readline.set_pre_input_hook
1133 else:
1133 else:
1134 self.readline_startup_hook = readline.set_startup_hook
1134 self.readline_startup_hook = readline.set_startup_hook
1135
1135
1136 # Load user's initrc file (readline config)
1136 # Load user's initrc file (readline config)
1137 inputrc_name = os.environ.get('INPUTRC')
1137 inputrc_name = os.environ.get('INPUTRC')
1138 if inputrc_name is None:
1138 if inputrc_name is None:
1139 home_dir = get_home_dir()
1139 home_dir = get_home_dir()
1140 if home_dir is not None:
1140 if home_dir is not None:
1141 inputrc_name = os.path.join(home_dir,'.inputrc')
1141 inputrc_name = os.path.join(home_dir,'.inputrc')
1142 if os.path.isfile(inputrc_name):
1142 if os.path.isfile(inputrc_name):
1143 try:
1143 try:
1144 readline.read_init_file(inputrc_name)
1144 readline.read_init_file(inputrc_name)
1145 except:
1145 except:
1146 warn('Problems reading readline initialization file <%s>'
1146 warn('Problems reading readline initialization file <%s>'
1147 % inputrc_name)
1147 % inputrc_name)
1148
1148
1149 self.has_readline = 1
1149 self.has_readline = 1
1150 self.readline = readline
1150 self.readline = readline
1151 # save this in sys so embedded copies can restore it properly
1151 # save this in sys so embedded copies can restore it properly
1152 sys.ipcompleter = self.Completer.complete
1152 sys.ipcompleter = self.Completer.complete
1153 readline.set_completer(self.Completer.complete)
1153 readline.set_completer(self.Completer.complete)
1154
1154
1155 # Configure readline according to user's prefs
1155 # Configure readline according to user's prefs
1156 for rlcommand in self.rc.readline_parse_and_bind:
1156 for rlcommand in self.rc.readline_parse_and_bind:
1157 readline.parse_and_bind(rlcommand)
1157 readline.parse_and_bind(rlcommand)
1158
1158
1159 # remove some chars from the delimiters list
1159 # remove some chars from the delimiters list
1160 delims = readline.get_completer_delims()
1160 delims = readline.get_completer_delims()
1161 delims = delims.translate(string._idmap,
1161 delims = delims.translate(string._idmap,
1162 self.rc.readline_remove_delims)
1162 self.rc.readline_remove_delims)
1163 readline.set_completer_delims(delims)
1163 readline.set_completer_delims(delims)
1164 # otherwise we end up with a monster history after a while:
1164 # otherwise we end up with a monster history after a while:
1165 readline.set_history_length(1000)
1165 readline.set_history_length(1000)
1166 try:
1166 try:
1167 #print '*** Reading readline history' # dbg
1167 #print '*** Reading readline history' # dbg
1168 readline.read_history_file(self.histfile)
1168 readline.read_history_file(self.histfile)
1169 except IOError:
1169 except IOError:
1170 pass # It doesn't exist yet.
1170 pass # It doesn't exist yet.
1171
1171
1172 atexit.register(self.atexit_operations)
1172 atexit.register(self.atexit_operations)
1173 del atexit
1173 del atexit
1174
1174
1175 # Configure auto-indent for all platforms
1175 # Configure auto-indent for all platforms
1176 self.set_autoindent(self.rc.autoindent)
1176 self.set_autoindent(self.rc.autoindent)
1177
1177
1178 def _should_recompile(self,e):
1178 def _should_recompile(self,e):
1179 """Utility routine for edit_syntax_error"""
1179 """Utility routine for edit_syntax_error"""
1180
1180
1181 if e.filename in ('<ipython console>','<input>','<string>',
1181 if e.filename in ('<ipython console>','<input>','<string>',
1182 '<console>'):
1182 '<console>'):
1183 return False
1183 return False
1184 try:
1184 try:
1185 if not ask_yes_no('Return to editor to correct syntax error? '
1185 if not ask_yes_no('Return to editor to correct syntax error? '
1186 '[Y/n] ','y'):
1186 '[Y/n] ','y'):
1187 return False
1187 return False
1188 except EOFError:
1188 except EOFError:
1189 return False
1189 return False
1190
1190
1191 def int0(x):
1191 def int0(x):
1192 try:
1192 try:
1193 return int(x)
1193 return int(x)
1194 except TypeError:
1194 except TypeError:
1195 return 0
1195 return 0
1196 # always pass integer line and offset values to editor hook
1196 # always pass integer line and offset values to editor hook
1197 self.hooks.fix_error_editor(e.filename,
1197 self.hooks.fix_error_editor(e.filename,
1198 int0(e.lineno),int0(e.offset),e.msg)
1198 int0(e.lineno),int0(e.offset),e.msg)
1199 return True
1199 return True
1200
1200
1201 def edit_syntax_error(self):
1201 def edit_syntax_error(self):
1202 """The bottom half of the syntax error handler called in the main loop.
1202 """The bottom half of the syntax error handler called in the main loop.
1203
1203
1204 Loop until syntax error is fixed or user cancels.
1204 Loop until syntax error is fixed or user cancels.
1205 """
1205 """
1206
1206
1207 while self.SyntaxTB.last_syntax_error:
1207 while self.SyntaxTB.last_syntax_error:
1208 # copy and clear last_syntax_error
1208 # copy and clear last_syntax_error
1209 err = self.SyntaxTB.clear_err_state()
1209 err = self.SyntaxTB.clear_err_state()
1210 if not self._should_recompile(err):
1210 if not self._should_recompile(err):
1211 return
1211 return
1212 try:
1212 try:
1213 # may set last_syntax_error again if a SyntaxError is raised
1213 # may set last_syntax_error again if a SyntaxError is raised
1214 self.safe_execfile(err.filename,self.shell.user_ns)
1214 self.safe_execfile(err.filename,self.shell.user_ns)
1215 except:
1215 except:
1216 self.showtraceback()
1216 self.showtraceback()
1217 else:
1217 else:
1218 f = file(err.filename)
1218 f = file(err.filename)
1219 try:
1219 try:
1220 sys.displayhook(f.read())
1220 sys.displayhook(f.read())
1221 finally:
1221 finally:
1222 f.close()
1222 f.close()
1223
1223
1224 def showsyntaxerror(self, filename=None):
1224 def showsyntaxerror(self, filename=None):
1225 """Display the syntax error that just occurred.
1225 """Display the syntax error that just occurred.
1226
1226
1227 This doesn't display a stack trace because there isn't one.
1227 This doesn't display a stack trace because there isn't one.
1228
1228
1229 If a filename is given, it is stuffed in the exception instead
1229 If a filename is given, it is stuffed in the exception instead
1230 of what was there before (because Python's parser always uses
1230 of what was there before (because Python's parser always uses
1231 "<string>" when reading from a string).
1231 "<string>" when reading from a string).
1232 """
1232 """
1233 etype, value, last_traceback = sys.exc_info()
1233 etype, value, last_traceback = sys.exc_info()
1234 if filename and etype is SyntaxError:
1234 if filename and etype is SyntaxError:
1235 # Work hard to stuff the correct filename in the exception
1235 # Work hard to stuff the correct filename in the exception
1236 try:
1236 try:
1237 msg, (dummy_filename, lineno, offset, line) = value
1237 msg, (dummy_filename, lineno, offset, line) = value
1238 except:
1238 except:
1239 # Not the format we expect; leave it alone
1239 # Not the format we expect; leave it alone
1240 pass
1240 pass
1241 else:
1241 else:
1242 # Stuff in the right filename
1242 # Stuff in the right filename
1243 try:
1243 try:
1244 # Assume SyntaxError is a class exception
1244 # Assume SyntaxError is a class exception
1245 value = SyntaxError(msg, (filename, lineno, offset, line))
1245 value = SyntaxError(msg, (filename, lineno, offset, line))
1246 except:
1246 except:
1247 # If that failed, assume SyntaxError is a string
1247 # If that failed, assume SyntaxError is a string
1248 value = msg, (filename, lineno, offset, line)
1248 value = msg, (filename, lineno, offset, line)
1249 self.SyntaxTB(etype,value,[])
1249 self.SyntaxTB(etype,value,[])
1250
1250
1251 def debugger(self):
1251 def debugger(self):
1252 """Call the pdb debugger."""
1252 """Call the pdb debugger."""
1253
1253
1254 if not self.rc.pdb:
1254 if not self.rc.pdb:
1255 return
1255 return
1256 pdb.pm()
1256 pdb.pm()
1257
1257
1258 def showtraceback(self,exc_tuple = None,filename=None):
1258 def showtraceback(self,exc_tuple = None,filename=None):
1259 """Display the exception that just occurred."""
1259 """Display the exception that just occurred."""
1260
1260
1261 # Though this won't be called by syntax errors in the input line,
1261 # Though this won't be called by syntax errors in the input line,
1262 # there may be SyntaxError cases whith imported code.
1262 # there may be SyntaxError cases whith imported code.
1263 if exc_tuple is None:
1263 if exc_tuple is None:
1264 type, value, tb = sys.exc_info()
1264 type, value, tb = sys.exc_info()
1265 else:
1265 else:
1266 type, value, tb = exc_tuple
1266 type, value, tb = exc_tuple
1267 if type is SyntaxError:
1267 if type is SyntaxError:
1268 self.showsyntaxerror(filename)
1268 self.showsyntaxerror(filename)
1269 else:
1269 else:
1270 self.InteractiveTB()
1270 self.InteractiveTB()
1271 if self.InteractiveTB.call_pdb and self.has_readline:
1271 if self.InteractiveTB.call_pdb and self.has_readline:
1272 # pdb mucks up readline, fix it back
1272 # pdb mucks up readline, fix it back
1273 self.readline.set_completer(self.Completer.complete)
1273 self.readline.set_completer(self.Completer.complete)
1274
1274
1275 def mainloop(self,banner=None):
1275 def mainloop(self,banner=None):
1276 """Creates the local namespace and starts the mainloop.
1276 """Creates the local namespace and starts the mainloop.
1277
1277
1278 If an optional banner argument is given, it will override the
1278 If an optional banner argument is given, it will override the
1279 internally created default banner."""
1279 internally created default banner."""
1280
1280
1281 if self.rc.c: # Emulate Python's -c option
1281 if self.rc.c: # Emulate Python's -c option
1282 self.exec_init_cmd()
1282 self.exec_init_cmd()
1283 if banner is None:
1283 if banner is None:
1284 if self.rc.banner:
1284 if self.rc.banner:
1285 banner = self.BANNER+self.banner2
1285 banner = self.BANNER+self.banner2
1286 else:
1286 else:
1287 banner = ''
1287 banner = ''
1288 self.interact(banner)
1288 self.interact(banner)
1289
1289
1290 def exec_init_cmd(self):
1290 def exec_init_cmd(self):
1291 """Execute a command given at the command line.
1291 """Execute a command given at the command line.
1292
1292
1293 This emulates Python's -c option."""
1293 This emulates Python's -c option."""
1294
1294
1295 sys.argv = ['-c']
1295 sys.argv = ['-c']
1296 self.push(self.rc.c)
1296 self.push(self.rc.c)
1297
1297
1298 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1298 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1299 """Embeds IPython into a running python program.
1299 """Embeds IPython into a running python program.
1300
1300
1301 Input:
1301 Input:
1302
1302
1303 - header: An optional header message can be specified.
1303 - header: An optional header message can be specified.
1304
1304
1305 - local_ns, global_ns: working namespaces. If given as None, the
1305 - local_ns, global_ns: working namespaces. If given as None, the
1306 IPython-initialized one is updated with __main__.__dict__, so that
1306 IPython-initialized one is updated with __main__.__dict__, so that
1307 program variables become visible but user-specific configuration
1307 program variables become visible but user-specific configuration
1308 remains possible.
1308 remains possible.
1309
1309
1310 - stack_depth: specifies how many levels in the stack to go to
1310 - stack_depth: specifies how many levels in the stack to go to
1311 looking for namespaces (when local_ns and global_ns are None). This
1311 looking for namespaces (when local_ns and global_ns are None). This
1312 allows an intermediate caller to make sure that this function gets
1312 allows an intermediate caller to make sure that this function gets
1313 the namespace from the intended level in the stack. By default (0)
1313 the namespace from the intended level in the stack. By default (0)
1314 it will get its locals and globals from the immediate caller.
1314 it will get its locals and globals from the immediate caller.
1315
1315
1316 Warning: it's possible to use this in a program which is being run by
1316 Warning: it's possible to use this in a program which is being run by
1317 IPython itself (via %run), but some funny things will happen (a few
1317 IPython itself (via %run), but some funny things will happen (a few
1318 globals get overwritten). In the future this will be cleaned up, as
1318 globals get overwritten). In the future this will be cleaned up, as
1319 there is no fundamental reason why it can't work perfectly."""
1319 there is no fundamental reason why it can't work perfectly."""
1320
1320
1321 # Get locals and globals from caller
1321 # Get locals and globals from caller
1322 if local_ns is None or global_ns is None:
1322 if local_ns is None or global_ns is None:
1323 call_frame = sys._getframe(stack_depth).f_back
1323 call_frame = sys._getframe(stack_depth).f_back
1324
1324
1325 if local_ns is None:
1325 if local_ns is None:
1326 local_ns = call_frame.f_locals
1326 local_ns = call_frame.f_locals
1327 if global_ns is None:
1327 if global_ns is None:
1328 global_ns = call_frame.f_globals
1328 global_ns = call_frame.f_globals
1329
1329
1330 # Update namespaces and fire up interpreter
1330 # Update namespaces and fire up interpreter
1331
1331
1332 # The global one is easy, we can just throw it in
1332 # The global one is easy, we can just throw it in
1333 self.user_global_ns = global_ns
1333 self.user_global_ns = global_ns
1334
1334
1335 # but the user/local one is tricky: ipython needs it to store internal
1335 # but the user/local one is tricky: ipython needs it to store internal
1336 # data, but we also need the locals. We'll copy locals in the user
1336 # data, but we also need the locals. We'll copy locals in the user
1337 # one, but will track what got copied so we can delete them at exit.
1337 # one, but will track what got copied so we can delete them at exit.
1338 # This is so that a later embedded call doesn't see locals from a
1338 # This is so that a later embedded call doesn't see locals from a
1339 # previous call (which most likely existed in a separate scope).
1339 # previous call (which most likely existed in a separate scope).
1340 local_varnames = local_ns.keys()
1340 local_varnames = local_ns.keys()
1341 self.user_ns.update(local_ns)
1341 self.user_ns.update(local_ns)
1342
1342
1343 # Patch for global embedding to make sure that things don't overwrite
1343 # Patch for global embedding to make sure that things don't overwrite
1344 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1344 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1345 # FIXME. Test this a bit more carefully (the if.. is new)
1345 # FIXME. Test this a bit more carefully (the if.. is new)
1346 if local_ns is None and global_ns is None:
1346 if local_ns is None and global_ns is None:
1347 self.user_global_ns.update(__main__.__dict__)
1347 self.user_global_ns.update(__main__.__dict__)
1348
1348
1349 # make sure the tab-completer has the correct frame information, so it
1349 # make sure the tab-completer has the correct frame information, so it
1350 # actually completes using the frame's locals/globals
1350 # actually completes using the frame's locals/globals
1351 self.set_completer_frame()
1351 self.set_completer_frame()
1352
1352
1353 # before activating the interactive mode, we need to make sure that
1353 # before activating the interactive mode, we need to make sure that
1354 # all names in the builtin namespace needed by ipython point to
1354 # all names in the builtin namespace needed by ipython point to
1355 # ourselves, and not to other instances.
1355 # ourselves, and not to other instances.
1356 self.add_builtins()
1356 self.add_builtins()
1357
1357
1358 self.interact(header)
1358 self.interact(header)
1359
1359
1360 # now, purge out the user namespace from anything we might have added
1360 # now, purge out the user namespace from anything we might have added
1361 # from the caller's local namespace
1361 # from the caller's local namespace
1362 delvar = self.user_ns.pop
1362 delvar = self.user_ns.pop
1363 for var in local_varnames:
1363 for var in local_varnames:
1364 delvar(var,None)
1364 delvar(var,None)
1365 # and clean builtins we may have overridden
1365 # and clean builtins we may have overridden
1366 self.clean_builtins()
1366 self.clean_builtins()
1367
1367
1368 def interact(self, banner=None):
1368 def interact(self, banner=None):
1369 """Closely emulate the interactive Python console.
1369 """Closely emulate the interactive Python console.
1370
1370
1371 The optional banner argument specify the banner to print
1371 The optional banner argument specify the banner to print
1372 before the first interaction; by default it prints a banner
1372 before the first interaction; by default it prints a banner
1373 similar to the one printed by the real Python interpreter,
1373 similar to the one printed by the real Python interpreter,
1374 followed by the current class name in parentheses (so as not
1374 followed by the current class name in parentheses (so as not
1375 to confuse this with the real interpreter -- since it's so
1375 to confuse this with the real interpreter -- since it's so
1376 close!).
1376 close!).
1377
1377
1378 """
1378 """
1379 cprt = 'Type "copyright", "credits" or "license" for more information.'
1379 cprt = 'Type "copyright", "credits" or "license" for more information.'
1380 if banner is None:
1380 if banner is None:
1381 self.write("Python %s on %s\n%s\n(%s)\n" %
1381 self.write("Python %s on %s\n%s\n(%s)\n" %
1382 (sys.version, sys.platform, cprt,
1382 (sys.version, sys.platform, cprt,
1383 self.__class__.__name__))
1383 self.__class__.__name__))
1384 else:
1384 else:
1385 self.write(banner)
1385 self.write(banner)
1386
1386
1387 more = 0
1387 more = 0
1388
1388
1389 # Mark activity in the builtins
1389 # Mark activity in the builtins
1390 __builtin__.__dict__['__IPYTHON__active'] += 1
1390 __builtin__.__dict__['__IPYTHON__active'] += 1
1391
1391
1392 # exit_now is set by a call to %Exit or %Quit
1392 # exit_now is set by a call to %Exit or %Quit
1393 self.exit_now = False
1393 self.exit_now = False
1394 while not self.exit_now:
1394 while not self.exit_now:
1395
1395
1396 try:
1396 try:
1397 if more:
1397 if more:
1398 prompt = self.outputcache.prompt2
1398 prompt = self.outputcache.prompt2
1399 if self.autoindent:
1399 if self.autoindent:
1400 self.readline_startup_hook(self.pre_readline)
1400 self.readline_startup_hook(self.pre_readline)
1401 else:
1401 else:
1402 prompt = self.outputcache.prompt1
1402 prompt = self.outputcache.prompt1
1403 try:
1403 try:
1404 line = self.raw_input(prompt,more)
1404 line = self.raw_input(prompt,more)
1405 if self.autoindent:
1405 if self.autoindent:
1406 self.readline_startup_hook(None)
1406 self.readline_startup_hook(None)
1407 except EOFError:
1407 except EOFError:
1408 if self.autoindent:
1408 if self.autoindent:
1409 self.readline_startup_hook(None)
1409 self.readline_startup_hook(None)
1410 self.write("\n")
1410 self.write("\n")
1411 self.exit()
1411 self.exit()
1412 else:
1412 else:
1413 more = self.push(line)
1413 more = self.push(line)
1414
1414
1415 if (self.SyntaxTB.last_syntax_error and
1415 if (self.SyntaxTB.last_syntax_error and
1416 self.rc.autoedit_syntax):
1416 self.rc.autoedit_syntax):
1417 self.edit_syntax_error()
1417 self.edit_syntax_error()
1418
1418
1419 except KeyboardInterrupt:
1419 except KeyboardInterrupt:
1420 self.write("\nKeyboardInterrupt\n")
1420 self.write("\nKeyboardInterrupt\n")
1421 self.resetbuffer()
1421 self.resetbuffer()
1422 more = 0
1422 more = 0
1423 # keep cache in sync with the prompt counter:
1423 # keep cache in sync with the prompt counter:
1424 self.outputcache.prompt_count -= 1
1424 self.outputcache.prompt_count -= 1
1425
1425
1426 if self.autoindent:
1426 if self.autoindent:
1427 self.indent_current_nsp = 0
1427 self.indent_current_nsp = 0
1428 self.indent_current = ' '* self.indent_current_nsp
1428 self.indent_current = ' '* self.indent_current_nsp
1429
1429
1430 except bdb.BdbQuit:
1430 except bdb.BdbQuit:
1431 warn("The Python debugger has exited with a BdbQuit exception.\n"
1431 warn("The Python debugger has exited with a BdbQuit exception.\n"
1432 "Because of how pdb handles the stack, it is impossible\n"
1432 "Because of how pdb handles the stack, it is impossible\n"
1433 "for IPython to properly format this particular exception.\n"
1433 "for IPython to properly format this particular exception.\n"
1434 "IPython will resume normal operation.")
1434 "IPython will resume normal operation.")
1435
1435
1436 # We are off again...
1436 # We are off again...
1437 __builtin__.__dict__['__IPYTHON__active'] -= 1
1437 __builtin__.__dict__['__IPYTHON__active'] -= 1
1438
1438
1439 def excepthook(self, type, value, tb):
1439 def excepthook(self, type, value, tb):
1440 """One more defense for GUI apps that call sys.excepthook.
1440 """One more defense for GUI apps that call sys.excepthook.
1441
1441
1442 GUI frameworks like wxPython trap exceptions and call
1442 GUI frameworks like wxPython trap exceptions and call
1443 sys.excepthook themselves. I guess this is a feature that
1443 sys.excepthook themselves. I guess this is a feature that
1444 enables them to keep running after exceptions that would
1444 enables them to keep running after exceptions that would
1445 otherwise kill their mainloop. This is a bother for IPython
1445 otherwise kill their mainloop. This is a bother for IPython
1446 which excepts to catch all of the program exceptions with a try:
1446 which excepts to catch all of the program exceptions with a try:
1447 except: statement.
1447 except: statement.
1448
1448
1449 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1449 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1450 any app directly invokes sys.excepthook, it will look to the user like
1450 any app directly invokes sys.excepthook, it will look to the user like
1451 IPython crashed. In order to work around this, we can disable the
1451 IPython crashed. In order to work around this, we can disable the
1452 CrashHandler and replace it with this excepthook instead, which prints a
1452 CrashHandler and replace it with this excepthook instead, which prints a
1453 regular traceback using our InteractiveTB. In this fashion, apps which
1453 regular traceback using our InteractiveTB. In this fashion, apps which
1454 call sys.excepthook will generate a regular-looking exception from
1454 call sys.excepthook will generate a regular-looking exception from
1455 IPython, and the CrashHandler will only be triggered by real IPython
1455 IPython, and the CrashHandler will only be triggered by real IPython
1456 crashes.
1456 crashes.
1457
1457
1458 This hook should be used sparingly, only in places which are not likely
1458 This hook should be used sparingly, only in places which are not likely
1459 to be true IPython errors.
1459 to be true IPython errors.
1460 """
1460 """
1461
1461
1462 self.InteractiveTB(type, value, tb, tb_offset=0)
1462 self.InteractiveTB(type, value, tb, tb_offset=0)
1463 if self.InteractiveTB.call_pdb and self.has_readline:
1463 if self.InteractiveTB.call_pdb and self.has_readline:
1464 self.readline.set_completer(self.Completer.complete)
1464 self.readline.set_completer(self.Completer.complete)
1465
1465
1466 def call_alias(self,alias,rest=''):
1466 def call_alias(self,alias,rest=''):
1467 """Call an alias given its name and the rest of the line.
1467 """Call an alias given its name and the rest of the line.
1468
1468
1469 This function MUST be given a proper alias, because it doesn't make
1469 This function MUST be given a proper alias, because it doesn't make
1470 any checks when looking up into the alias table. The caller is
1470 any checks when looking up into the alias table. The caller is
1471 responsible for invoking it only with a valid alias."""
1471 responsible for invoking it only with a valid alias."""
1472
1472
1473 #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg
1473 #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg
1474 nargs,cmd = self.alias_table[alias]
1474 nargs,cmd = self.alias_table[alias]
1475 # Expand the %l special to be the user's input line
1475 # Expand the %l special to be the user's input line
1476 if cmd.find('%l') >= 0:
1476 if cmd.find('%l') >= 0:
1477 cmd = cmd.replace('%l',rest)
1477 cmd = cmd.replace('%l',rest)
1478 rest = ''
1478 rest = ''
1479 if nargs==0:
1479 if nargs==0:
1480 # Simple, argument-less aliases
1480 # Simple, argument-less aliases
1481 cmd = '%s %s' % (cmd,rest)
1481 cmd = '%s %s' % (cmd,rest)
1482 else:
1482 else:
1483 # Handle aliases with positional arguments
1483 # Handle aliases with positional arguments
1484 args = rest.split(None,nargs)
1484 args = rest.split(None,nargs)
1485 if len(args)< nargs:
1485 if len(args)< nargs:
1486 error('Alias <%s> requires %s arguments, %s given.' %
1486 error('Alias <%s> requires %s arguments, %s given.' %
1487 (alias,nargs,len(args)))
1487 (alias,nargs,len(args)))
1488 return
1488 return
1489 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1489 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1490 # Now call the macro, evaluating in the user's namespace
1490 # Now call the macro, evaluating in the user's namespace
1491 try:
1491 try:
1492 self.system(cmd)
1492 self.system(cmd)
1493 except:
1493 except:
1494 self.showtraceback()
1494 self.showtraceback()
1495
1495
1496 def autoindent_update(self,line):
1496 def autoindent_update(self,line):
1497 """Keep track of the indent level."""
1497 """Keep track of the indent level."""
1498 if self.autoindent:
1498 if self.autoindent:
1499 if line:
1499 if line:
1500 ini_spaces = ini_spaces_re.match(line)
1500 ini_spaces = ini_spaces_re.match(line)
1501 if ini_spaces:
1501 if ini_spaces:
1502 nspaces = ini_spaces.end()
1502 nspaces = ini_spaces.end()
1503 else:
1503 else:
1504 nspaces = 0
1504 nspaces = 0
1505 self.indent_current_nsp = nspaces
1505 self.indent_current_nsp = nspaces
1506
1506
1507 if line[-1] == ':':
1507 if line[-1] == ':':
1508 self.indent_current_nsp += 4
1508 self.indent_current_nsp += 4
1509 elif dedent_re.match(line):
1509 elif dedent_re.match(line):
1510 self.indent_current_nsp -= 4
1510 self.indent_current_nsp -= 4
1511 else:
1511 else:
1512 self.indent_current_nsp = 0
1512 self.indent_current_nsp = 0
1513
1513
1514 # indent_current is the actual string to be inserted
1514 # indent_current is the actual string to be inserted
1515 # by the readline hooks for indentation
1515 # by the readline hooks for indentation
1516 self.indent_current = ' '* self.indent_current_nsp
1516 self.indent_current = ' '* self.indent_current_nsp
1517
1517
1518 def runlines(self,lines):
1518 def runlines(self,lines):
1519 """Run a string of one or more lines of source.
1519 """Run a string of one or more lines of source.
1520
1520
1521 This method is capable of running a string containing multiple source
1521 This method is capable of running a string containing multiple source
1522 lines, as if they had been entered at the IPython prompt. Since it
1522 lines, as if they had been entered at the IPython prompt. Since it
1523 exposes IPython's processing machinery, the given strings can contain
1523 exposes IPython's processing machinery, the given strings can contain
1524 magic calls (%magic), special shell access (!cmd), etc."""
1524 magic calls (%magic), special shell access (!cmd), etc."""
1525
1525
1526 # We must start with a clean buffer, in case this is run from an
1526 # We must start with a clean buffer, in case this is run from an
1527 # interactive IPython session (via a magic, for example).
1527 # interactive IPython session (via a magic, for example).
1528 self.resetbuffer()
1528 self.resetbuffer()
1529 lines = lines.split('\n')
1529 lines = lines.split('\n')
1530 more = 0
1530 more = 0
1531 for line in lines:
1531 for line in lines:
1532 # skip blank lines so we don't mess up the prompt counter, but do
1532 # skip blank lines so we don't mess up the prompt counter, but do
1533 # NOT skip even a blank line if we are in a code block (more is
1533 # NOT skip even a blank line if we are in a code block (more is
1534 # true)
1534 # true)
1535 if line or more:
1535 if line or more:
1536 more = self.push(self.prefilter(line,more))
1536 more = self.push(self.prefilter(line,more))
1537 # IPython's runsource returns None if there was an error
1537 # IPython's runsource returns None if there was an error
1538 # compiling the code. This allows us to stop processing right
1538 # compiling the code. This allows us to stop processing right
1539 # away, so the user gets the error message at the right place.
1539 # away, so the user gets the error message at the right place.
1540 if more is None:
1540 if more is None:
1541 break
1541 break
1542 # final newline in case the input didn't have it, so that the code
1542 # final newline in case the input didn't have it, so that the code
1543 # actually does get executed
1543 # actually does get executed
1544 if more:
1544 if more:
1545 self.push('\n')
1545 self.push('\n')
1546
1546
1547 def runsource(self, source, filename='<input>', symbol='single'):
1547 def runsource(self, source, filename='<input>', symbol='single'):
1548 """Compile and run some source in the interpreter.
1548 """Compile and run some source in the interpreter.
1549
1549
1550 Arguments are as for compile_command().
1550 Arguments are as for compile_command().
1551
1551
1552 One several things can happen:
1552 One several things can happen:
1553
1553
1554 1) The input is incorrect; compile_command() raised an
1554 1) The input is incorrect; compile_command() raised an
1555 exception (SyntaxError or OverflowError). A syntax traceback
1555 exception (SyntaxError or OverflowError). A syntax traceback
1556 will be printed by calling the showsyntaxerror() method.
1556 will be printed by calling the showsyntaxerror() method.
1557
1557
1558 2) The input is incomplete, and more input is required;
1558 2) The input is incomplete, and more input is required;
1559 compile_command() returned None. Nothing happens.
1559 compile_command() returned None. Nothing happens.
1560
1560
1561 3) The input is complete; compile_command() returned a code
1561 3) The input is complete; compile_command() returned a code
1562 object. The code is executed by calling self.runcode() (which
1562 object. The code is executed by calling self.runcode() (which
1563 also handles run-time exceptions, except for SystemExit).
1563 also handles run-time exceptions, except for SystemExit).
1564
1564
1565 The return value is:
1565 The return value is:
1566
1566
1567 - True in case 2
1567 - True in case 2
1568
1568
1569 - False in the other cases, unless an exception is raised, where
1569 - False in the other cases, unless an exception is raised, where
1570 None is returned instead. This can be used by external callers to
1570 None is returned instead. This can be used by external callers to
1571 know whether to continue feeding input or not.
1571 know whether to continue feeding input or not.
1572
1572
1573 The return value can be used to decide whether to use sys.ps1 or
1573 The return value can be used to decide whether to use sys.ps1 or
1574 sys.ps2 to prompt the next line."""
1574 sys.ps2 to prompt the next line."""
1575
1575
1576 try:
1576 try:
1577 code = self.compile(source,filename,symbol)
1577 code = self.compile(source,filename,symbol)
1578 except (OverflowError, SyntaxError, ValueError):
1578 except (OverflowError, SyntaxError, ValueError):
1579 # Case 1
1579 # Case 1
1580 self.showsyntaxerror(filename)
1580 self.showsyntaxerror(filename)
1581 return None
1581 return None
1582
1582
1583 if code is None:
1583 if code is None:
1584 # Case 2
1584 # Case 2
1585 return True
1585 return True
1586
1586
1587 # Case 3
1587 # Case 3
1588 # We store the code object so that threaded shells and
1588 # We store the code object so that threaded shells and
1589 # custom exception handlers can access all this info if needed.
1589 # custom exception handlers can access all this info if needed.
1590 # The source corresponding to this can be obtained from the
1590 # The source corresponding to this can be obtained from the
1591 # buffer attribute as '\n'.join(self.buffer).
1591 # buffer attribute as '\n'.join(self.buffer).
1592 self.code_to_run = code
1592 self.code_to_run = code
1593 # now actually execute the code object
1593 # now actually execute the code object
1594 if self.runcode(code) == 0:
1594 if self.runcode(code) == 0:
1595 return False
1595 return False
1596 else:
1596 else:
1597 return None
1597 return None
1598
1598
1599 def runcode(self,code_obj):
1599 def runcode(self,code_obj):
1600 """Execute a code object.
1600 """Execute a code object.
1601
1601
1602 When an exception occurs, self.showtraceback() is called to display a
1602 When an exception occurs, self.showtraceback() is called to display a
1603 traceback.
1603 traceback.
1604
1604
1605 Return value: a flag indicating whether the code to be run completed
1605 Return value: a flag indicating whether the code to be run completed
1606 successfully:
1606 successfully:
1607
1607
1608 - 0: successful execution.
1608 - 0: successful execution.
1609 - 1: an error occurred.
1609 - 1: an error occurred.
1610 """
1610 """
1611
1611
1612 # Set our own excepthook in case the user code tries to call it
1612 # Set our own excepthook in case the user code tries to call it
1613 # directly, so that the IPython crash handler doesn't get triggered
1613 # directly, so that the IPython crash handler doesn't get triggered
1614 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1614 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1615
1615
1616 # we save the original sys.excepthook in the instance, in case config
1616 # we save the original sys.excepthook in the instance, in case config
1617 # code (such as magics) needs access to it.
1617 # code (such as magics) needs access to it.
1618 self.sys_excepthook = old_excepthook
1618 self.sys_excepthook = old_excepthook
1619 outflag = 1 # happens in more places, so it's easier as default
1619 outflag = 1 # happens in more places, so it's easier as default
1620 try:
1620 try:
1621 try:
1621 try:
1622 # Embedded instances require separate global/local namespaces
1622 # Embedded instances require separate global/local namespaces
1623 # so they can see both the surrounding (local) namespace and
1623 # so they can see both the surrounding (local) namespace and
1624 # the module-level globals when called inside another function.
1624 # the module-level globals when called inside another function.
1625 if self.embedded:
1625 if self.embedded:
1626 exec code_obj in self.user_global_ns, self.user_ns
1626 exec code_obj in self.user_global_ns, self.user_ns
1627 # Normal (non-embedded) instances should only have a single
1627 # Normal (non-embedded) instances should only have a single
1628 # namespace for user code execution, otherwise functions won't
1628 # namespace for user code execution, otherwise functions won't
1629 # see interactive top-level globals.
1629 # see interactive top-level globals.
1630 else:
1630 else:
1631 exec code_obj in self.user_ns
1631 exec code_obj in self.user_ns
1632 finally:
1632 finally:
1633 # Reset our crash handler in place
1633 # Reset our crash handler in place
1634 sys.excepthook = old_excepthook
1634 sys.excepthook = old_excepthook
1635 except SystemExit:
1635 except SystemExit:
1636 self.resetbuffer()
1636 self.resetbuffer()
1637 self.showtraceback()
1637 self.showtraceback()
1638 warn("Type exit or quit to exit IPython "
1638 warn("Type exit or quit to exit IPython "
1639 "(%Exit or %Quit do so unconditionally).",level=1)
1639 "(%Exit or %Quit do so unconditionally).",level=1)
1640 except self.custom_exceptions:
1640 except self.custom_exceptions:
1641 etype,value,tb = sys.exc_info()
1641 etype,value,tb = sys.exc_info()
1642 self.CustomTB(etype,value,tb)
1642 self.CustomTB(etype,value,tb)
1643 except:
1643 except:
1644 self.showtraceback()
1644 self.showtraceback()
1645 else:
1645 else:
1646 outflag = 0
1646 outflag = 0
1647 if softspace(sys.stdout, 0):
1647 if softspace(sys.stdout, 0):
1648 print
1648 print
1649 # Flush out code object which has been run (and source)
1649 # Flush out code object which has been run (and source)
1650 self.code_to_run = None
1650 self.code_to_run = None
1651 return outflag
1651 return outflag
1652
1652
1653 def push(self, line):
1653 def push(self, line):
1654 """Push a line to the interpreter.
1654 """Push a line to the interpreter.
1655
1655
1656 The line should not have a trailing newline; it may have
1656 The line should not have a trailing newline; it may have
1657 internal newlines. The line is appended to a buffer and the
1657 internal newlines. The line is appended to a buffer and the
1658 interpreter's runsource() method is called with the
1658 interpreter's runsource() method is called with the
1659 concatenated contents of the buffer as source. If this
1659 concatenated contents of the buffer as source. If this
1660 indicates that the command was executed or invalid, the buffer
1660 indicates that the command was executed or invalid, the buffer
1661 is reset; otherwise, the command is incomplete, and the buffer
1661 is reset; otherwise, the command is incomplete, and the buffer
1662 is left as it was after the line was appended. The return
1662 is left as it was after the line was appended. The return
1663 value is 1 if more input is required, 0 if the line was dealt
1663 value is 1 if more input is required, 0 if the line was dealt
1664 with in some way (this is the same as runsource()).
1664 with in some way (this is the same as runsource()).
1665 """
1665 """
1666
1666
1667 # autoindent management should be done here, and not in the
1667 # autoindent management should be done here, and not in the
1668 # interactive loop, since that one is only seen by keyboard input. We
1668 # interactive loop, since that one is only seen by keyboard input. We
1669 # need this done correctly even for code run via runlines (which uses
1669 # need this done correctly even for code run via runlines (which uses
1670 # push).
1670 # push).
1671
1671
1672 #print 'push line: <%s>' % line # dbg
1672 #print 'push line: <%s>' % line # dbg
1673 self.autoindent_update(line)
1673 self.autoindent_update(line)
1674
1674
1675 self.buffer.append(line)
1675 self.buffer.append(line)
1676 more = self.runsource('\n'.join(self.buffer), self.filename)
1676 more = self.runsource('\n'.join(self.buffer), self.filename)
1677 if not more:
1677 if not more:
1678 self.resetbuffer()
1678 self.resetbuffer()
1679 return more
1679 return more
1680
1680
1681 def resetbuffer(self):
1681 def resetbuffer(self):
1682 """Reset the input buffer."""
1682 """Reset the input buffer."""
1683 self.buffer[:] = []
1683 self.buffer[:] = []
1684
1684
1685 def raw_input(self,prompt='',continue_prompt=False):
1685 def raw_input(self,prompt='',continue_prompt=False):
1686 """Write a prompt and read a line.
1686 """Write a prompt and read a line.
1687
1687
1688 The returned line does not include the trailing newline.
1688 The returned line does not include the trailing newline.
1689 When the user enters the EOF key sequence, EOFError is raised.
1689 When the user enters the EOF key sequence, EOFError is raised.
1690
1690
1691 Optional inputs:
1691 Optional inputs:
1692
1692
1693 - prompt(''): a string to be printed to prompt the user.
1693 - prompt(''): a string to be printed to prompt the user.
1694
1694
1695 - continue_prompt(False): whether this line is the first one or a
1695 - continue_prompt(False): whether this line is the first one or a
1696 continuation in a sequence of inputs.
1696 continuation in a sequence of inputs.
1697 """
1697 """
1698
1698
1699 line = raw_input_original(prompt)
1699 line = raw_input_original(prompt)
1700 # Try to be reasonably smart about not re-indenting pasted input more
1700 # Try to be reasonably smart about not re-indenting pasted input more
1701 # than necessary. We do this by trimming out the auto-indent initial
1701 # than necessary. We do this by trimming out the auto-indent initial
1702 # spaces, if the user's actual input started itself with whitespace.
1702 # spaces, if the user's actual input started itself with whitespace.
1703 if self.autoindent:
1703 if self.autoindent:
1704 line2 = line[self.indent_current_nsp:]
1704 line2 = line[self.indent_current_nsp:]
1705 if line2[0:1] in (' ','\t'):
1705 if line2[0:1] in (' ','\t'):
1706 line = line2
1706 line = line2
1707 return self.prefilter(line,continue_prompt)
1707 return self.prefilter(line,continue_prompt)
1708
1708
1709 def split_user_input(self,line):
1709 def split_user_input(self,line):
1710 """Split user input into pre-char, function part and rest."""
1710 """Split user input into pre-char, function part and rest."""
1711
1711
1712 lsplit = self.line_split.match(line)
1712 lsplit = self.line_split.match(line)
1713 if lsplit is None: # no regexp match returns None
1713 if lsplit is None: # no regexp match returns None
1714 try:
1714 try:
1715 iFun,theRest = line.split(None,1)
1715 iFun,theRest = line.split(None,1)
1716 except ValueError:
1716 except ValueError:
1717 iFun,theRest = line,''
1717 iFun,theRest = line,''
1718 pre = re.match('^(\s*)(.*)',line).groups()[0]
1718 pre = re.match('^(\s*)(.*)',line).groups()[0]
1719 else:
1719 else:
1720 pre,iFun,theRest = lsplit.groups()
1720 pre,iFun,theRest = lsplit.groups()
1721
1721
1722 #print 'line:<%s>' % line # dbg
1722 #print 'line:<%s>' % line # dbg
1723 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
1723 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
1724 return pre,iFun.strip(),theRest
1724 return pre,iFun.strip(),theRest
1725
1725
1726 def _prefilter(self, line, continue_prompt):
1726 def _prefilter(self, line, continue_prompt):
1727 """Calls different preprocessors, depending on the form of line."""
1727 """Calls different preprocessors, depending on the form of line."""
1728
1728
1729 # All handlers *must* return a value, even if it's blank ('').
1729 # All handlers *must* return a value, even if it's blank ('').
1730
1730
1731 # Lines are NOT logged here. Handlers should process the line as
1731 # Lines are NOT logged here. Handlers should process the line as
1732 # needed, update the cache AND log it (so that the input cache array
1732 # needed, update the cache AND log it (so that the input cache array
1733 # stays synced).
1733 # stays synced).
1734
1734
1735 # This function is _very_ delicate, and since it's also the one which
1735 # This function is _very_ delicate, and since it's also the one which
1736 # determines IPython's response to user input, it must be as efficient
1736 # determines IPython's response to user input, it must be as efficient
1737 # as possible. For this reason it has _many_ returns in it, trying
1737 # as possible. For this reason it has _many_ returns in it, trying
1738 # always to exit as quickly as it can figure out what it needs to do.
1738 # always to exit as quickly as it can figure out what it needs to do.
1739
1739
1740 # This function is the main responsible for maintaining IPython's
1740 # This function is the main responsible for maintaining IPython's
1741 # behavior respectful of Python's semantics. So be _very_ careful if
1741 # behavior respectful of Python's semantics. So be _very_ careful if
1742 # making changes to anything here.
1742 # making changes to anything here.
1743
1743
1744 #.....................................................................
1744 #.....................................................................
1745 # Code begins
1745 # Code begins
1746
1746
1747 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
1747 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
1748
1748
1749 # save the line away in case we crash, so the post-mortem handler can
1749 # save the line away in case we crash, so the post-mortem handler can
1750 # record it
1750 # record it
1751 self._last_input_line = line
1751 self._last_input_line = line
1752
1752
1753 #print '***line: <%s>' % line # dbg
1753 #print '***line: <%s>' % line # dbg
1754
1754
1755 # the input history needs to track even empty lines
1755 # the input history needs to track even empty lines
1756 if not line.strip():
1756 if not line.strip():
1757 if not continue_prompt:
1757 if not continue_prompt:
1758 self.outputcache.prompt_count -= 1
1758 self.outputcache.prompt_count -= 1
1759 return self.handle_normal(line,continue_prompt)
1759 return self.handle_normal(line,continue_prompt)
1760 #return self.handle_normal('',continue_prompt)
1760 #return self.handle_normal('',continue_prompt)
1761
1761
1762 # print '***cont',continue_prompt # dbg
1762 # print '***cont',continue_prompt # dbg
1763 # special handlers are only allowed for single line statements
1763 # special handlers are only allowed for single line statements
1764 if continue_prompt and not self.rc.multi_line_specials:
1764 if continue_prompt and not self.rc.multi_line_specials:
1765 return self.handle_normal(line,continue_prompt)
1765 return self.handle_normal(line,continue_prompt)
1766
1766
1767 # For the rest, we need the structure of the input
1767 # For the rest, we need the structure of the input
1768 pre,iFun,theRest = self.split_user_input(line)
1768 pre,iFun,theRest = self.split_user_input(line)
1769 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1769 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1770
1770
1771 # First check for explicit escapes in the last/first character
1771 # First check for explicit escapes in the last/first character
1772 handler = None
1772 handler = None
1773 if line[-1] == self.ESC_HELP:
1773 if line[-1] == self.ESC_HELP:
1774 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
1774 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
1775 if handler is None:
1775 if handler is None:
1776 # look at the first character of iFun, NOT of line, so we skip
1776 # look at the first character of iFun, NOT of line, so we skip
1777 # leading whitespace in multiline input
1777 # leading whitespace in multiline input
1778 handler = self.esc_handlers.get(iFun[0:1])
1778 handler = self.esc_handlers.get(iFun[0:1])
1779 if handler is not None:
1779 if handler is not None:
1780 return handler(line,continue_prompt,pre,iFun,theRest)
1780 return handler(line,continue_prompt,pre,iFun,theRest)
1781 # Emacs ipython-mode tags certain input lines
1781 # Emacs ipython-mode tags certain input lines
1782 if line.endswith('# PYTHON-MODE'):
1782 if line.endswith('# PYTHON-MODE'):
1783 return self.handle_emacs(line,continue_prompt)
1783 return self.handle_emacs(line,continue_prompt)
1784
1784
1785 # Next, check if we can automatically execute this thing
1785 # Next, check if we can automatically execute this thing
1786
1786
1787 # Allow ! in multi-line statements if multi_line_specials is on:
1787 # Allow ! in multi-line statements if multi_line_specials is on:
1788 if continue_prompt and self.rc.multi_line_specials and \
1788 if continue_prompt and self.rc.multi_line_specials and \
1789 iFun.startswith(self.ESC_SHELL):
1789 iFun.startswith(self.ESC_SHELL):
1790 return self.handle_shell_escape(line,continue_prompt,
1790 return self.handle_shell_escape(line,continue_prompt,
1791 pre=pre,iFun=iFun,
1791 pre=pre,iFun=iFun,
1792 theRest=theRest)
1792 theRest=theRest)
1793
1793
1794 # Let's try to find if the input line is a magic fn
1794 # Let's try to find if the input line is a magic fn
1795 oinfo = None
1795 oinfo = None
1796 if hasattr(self,'magic_'+iFun):
1796 if hasattr(self,'magic_'+iFun):
1797 # WARNING: _ofind uses getattr(), so it can consume generators and
1797 # WARNING: _ofind uses getattr(), so it can consume generators and
1798 # cause other side effects.
1798 # cause other side effects.
1799 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1799 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1800 if oinfo['ismagic']:
1800 if oinfo['ismagic']:
1801 # Be careful not to call magics when a variable assignment is
1801 # Be careful not to call magics when a variable assignment is
1802 # being made (ls='hi', for example)
1802 # being made (ls='hi', for example)
1803 if self.rc.automagic and \
1803 if self.rc.automagic and \
1804 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
1804 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
1805 (self.rc.multi_line_specials or not continue_prompt):
1805 (self.rc.multi_line_specials or not continue_prompt):
1806 return self.handle_magic(line,continue_prompt,
1806 return self.handle_magic(line,continue_prompt,
1807 pre,iFun,theRest)
1807 pre,iFun,theRest)
1808 else:
1808 else:
1809 return self.handle_normal(line,continue_prompt)
1809 return self.handle_normal(line,continue_prompt)
1810
1810
1811 # If the rest of the line begins with an (in)equality, assginment or
1811 # If the rest of the line begins with an (in)equality, assginment or
1812 # function call, we should not call _ofind but simply execute it.
1812 # function call, we should not call _ofind but simply execute it.
1813 # This avoids spurious geattr() accesses on objects upon assignment.
1813 # This avoids spurious geattr() accesses on objects upon assignment.
1814 #
1814 #
1815 # It also allows users to assign to either alias or magic names true
1815 # It also allows users to assign to either alias or magic names true
1816 # python variables (the magic/alias systems always take second seat to
1816 # python variables (the magic/alias systems always take second seat to
1817 # true python code).
1817 # true python code).
1818 if theRest and theRest[0] in '!=()':
1818 if theRest and theRest[0] in '!=()':
1819 return self.handle_normal(line,continue_prompt)
1819 return self.handle_normal(line,continue_prompt)
1820
1820
1821 if oinfo is None:
1821 if oinfo is None:
1822 # let's try to ensure that _oinfo is ONLY called when autocall is
1822 # let's try to ensure that _oinfo is ONLY called when autocall is
1823 # on. Since it has inevitable potential side effects, at least
1823 # on. Since it has inevitable potential side effects, at least
1824 # having autocall off should be a guarantee to the user that no
1824 # having autocall off should be a guarantee to the user that no
1825 # weird things will happen.
1825 # weird things will happen.
1826
1826
1827 if self.rc.autocall:
1827 if self.rc.autocall:
1828 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1828 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1829 else:
1829 else:
1830 # in this case, all that's left is either an alias or
1830 # in this case, all that's left is either an alias or
1831 # processing the line normally.
1831 # processing the line normally.
1832 if iFun in self.alias_table:
1832 if iFun in self.alias_table:
1833 return self.handle_alias(line,continue_prompt,
1833 return self.handle_alias(line,continue_prompt,
1834 pre,iFun,theRest)
1834 pre,iFun,theRest)
1835 else:
1835 else:
1836 return self.handle_normal(line,continue_prompt)
1836 return self.handle_normal(line,continue_prompt)
1837
1837
1838 if not oinfo['found']:
1838 if not oinfo['found']:
1839 return self.handle_normal(line,continue_prompt)
1839 return self.handle_normal(line,continue_prompt)
1840 else:
1840 else:
1841 #print 'iFun <%s> rest <%s>' % (iFun,theRest) # dbg
1841 #print 'iFun <%s> rest <%s>' % (iFun,theRest) # dbg
1842 if oinfo['isalias']:
1842 if oinfo['isalias']:
1843 return self.handle_alias(line,continue_prompt,
1843 return self.handle_alias(line,continue_prompt,
1844 pre,iFun,theRest)
1844 pre,iFun,theRest)
1845
1845
1846 if self.rc.autocall and \
1846 if self.rc.autocall and \
1847 not self.re_exclude_auto.match(theRest) and \
1847 not self.re_exclude_auto.match(theRest) and \
1848 self.re_fun_name.match(iFun) and \
1848 self.re_fun_name.match(iFun) and \
1849 callable(oinfo['obj']) :
1849 callable(oinfo['obj']) :
1850 #print 'going auto' # dbg
1850 #print 'going auto' # dbg
1851 return self.handle_auto(line,continue_prompt,
1851 return self.handle_auto(line,continue_prompt,
1852 pre,iFun,theRest,oinfo['obj'])
1852 pre,iFun,theRest,oinfo['obj'])
1853 else:
1853 else:
1854 #print 'was callable?', callable(oinfo['obj']) # dbg
1854 #print 'was callable?', callable(oinfo['obj']) # dbg
1855 return self.handle_normal(line,continue_prompt)
1855 return self.handle_normal(line,continue_prompt)
1856
1856
1857 # If we get here, we have a normal Python line. Log and return.
1857 # If we get here, we have a normal Python line. Log and return.
1858 return self.handle_normal(line,continue_prompt)
1858 return self.handle_normal(line,continue_prompt)
1859
1859
1860 def _prefilter_dumb(self, line, continue_prompt):
1860 def _prefilter_dumb(self, line, continue_prompt):
1861 """simple prefilter function, for debugging"""
1861 """simple prefilter function, for debugging"""
1862 return self.handle_normal(line,continue_prompt)
1862 return self.handle_normal(line,continue_prompt)
1863
1863
1864 # Set the default prefilter() function (this can be user-overridden)
1864 # Set the default prefilter() function (this can be user-overridden)
1865 prefilter = _prefilter
1865 prefilter = _prefilter
1866
1866
1867 def handle_normal(self,line,continue_prompt=None,
1867 def handle_normal(self,line,continue_prompt=None,
1868 pre=None,iFun=None,theRest=None):
1868 pre=None,iFun=None,theRest=None):
1869 """Handle normal input lines. Use as a template for handlers."""
1869 """Handle normal input lines. Use as a template for handlers."""
1870
1870
1871 # With autoindent on, we need some way to exit the input loop, and I
1871 # With autoindent on, we need some way to exit the input loop, and I
1872 # don't want to force the user to have to backspace all the way to
1872 # don't want to force the user to have to backspace all the way to
1873 # clear the line. The rule will be in this case, that either two
1873 # clear the line. The rule will be in this case, that either two
1874 # lines of pure whitespace in a row, or a line of pure whitespace but
1874 # lines of pure whitespace in a row, or a line of pure whitespace but
1875 # of a size different to the indent level, will exit the input loop.
1875 # of a size different to the indent level, will exit the input loop.
1876
1876
1877 if (continue_prompt and self.autoindent and isspace(line) and
1877 if (continue_prompt and self.autoindent and isspace(line) and
1878 (line != self.indent_current or isspace(self.buffer[-1]))):
1878 (line != self.indent_current or isspace(self.buffer[-1]))):
1879 line = ''
1879 line = ''
1880
1880
1881 self.log(line,continue_prompt)
1881 self.log(line,continue_prompt)
1882 return line
1882 return line
1883
1883
1884 def handle_alias(self,line,continue_prompt=None,
1884 def handle_alias(self,line,continue_prompt=None,
1885 pre=None,iFun=None,theRest=None):
1885 pre=None,iFun=None,theRest=None):
1886 """Handle alias input lines. """
1886 """Handle alias input lines. """
1887
1887
1888 # pre is needed, because it carries the leading whitespace. Otherwise
1888 # pre is needed, because it carries the leading whitespace. Otherwise
1889 # aliases won't work in indented sections.
1889 # aliases won't work in indented sections.
1890 line_out = '%sipalias("%s %s")' % (pre,iFun,esc_quotes(theRest))
1890 line_out = '%sipalias("%s %s")' % (pre,iFun,esc_quotes(theRest))
1891 self.log(line_out,continue_prompt)
1891 self.log(line_out,continue_prompt)
1892 return line_out
1892 return line_out
1893
1893
1894 def handle_shell_escape(self, line, continue_prompt=None,
1894 def handle_shell_escape(self, line, continue_prompt=None,
1895 pre=None,iFun=None,theRest=None):
1895 pre=None,iFun=None,theRest=None):
1896 """Execute the line in a shell, empty return value"""
1896 """Execute the line in a shell, empty return value"""
1897
1897
1898 #print 'line in :', `line` # dbg
1898 #print 'line in :', `line` # dbg
1899 # Example of a special handler. Others follow a similar pattern.
1899 # Example of a special handler. Others follow a similar pattern.
1900 if continue_prompt: # multi-line statements
1900 if continue_prompt: # multi-line statements
1901 if iFun.startswith('!!'):
1901 if iFun.startswith('!!'):
1902 print 'SyntaxError: !! is not allowed in multiline statements'
1902 print 'SyntaxError: !! is not allowed in multiline statements'
1903 return pre
1903 return pre
1904 else:
1904 else:
1905 cmd = ("%s %s" % (iFun[1:],theRest))
1905 cmd = ("%s %s" % (iFun[1:],theRest))
1906 line_out = '%sipsystem(r"""%s"""[:-1])' % (pre,cmd + "_")
1906 line_out = '%sipsystem(r"""%s"""[:-1])' % (pre,cmd + "_")
1907 else: # single-line input
1907 else: # single-line input
1908 if line.startswith('!!'):
1908 if line.startswith('!!'):
1909 # rewrite iFun/theRest to properly hold the call to %sx and
1909 # rewrite iFun/theRest to properly hold the call to %sx and
1910 # the actual command to be executed, so handle_magic can work
1910 # the actual command to be executed, so handle_magic can work
1911 # correctly
1911 # correctly
1912 theRest = '%s %s' % (iFun[2:],theRest)
1912 theRest = '%s %s' % (iFun[2:],theRest)
1913 iFun = 'sx'
1913 iFun = 'sx'
1914 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,line[2:]),
1914 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,line[2:]),
1915 continue_prompt,pre,iFun,theRest)
1915 continue_prompt,pre,iFun,theRest)
1916 else:
1916 else:
1917 cmd=line[1:]
1917 cmd=line[1:]
1918 line_out = '%sipsystem(r"""%s"""[:-1])' % (pre,cmd +"_")
1918 line_out = '%sipsystem(r"""%s"""[:-1])' % (pre,cmd +"_")
1919 # update cache/log and return
1919 # update cache/log and return
1920 self.log(line_out,continue_prompt)
1920 self.log(line_out,continue_prompt)
1921 return line_out
1921 return line_out
1922
1922
1923 def handle_magic(self, line, continue_prompt=None,
1923 def handle_magic(self, line, continue_prompt=None,
1924 pre=None,iFun=None,theRest=None):
1924 pre=None,iFun=None,theRest=None):
1925 """Execute magic functions.
1925 """Execute magic functions.
1926
1926
1927 Also log them with a prepended # so the log is clean Python."""
1927 Also log them with a prepended # so the log is clean Python."""
1928
1928
1929 cmd = '%sipmagic("%s")' % (pre,esc_quotes('%s %s' % (iFun,theRest)))
1929 cmd = '%sipmagic("%s")' % (pre,esc_quotes('%s %s' % (iFun,theRest)))
1930 self.log(cmd,continue_prompt)
1930 self.log(cmd,continue_prompt)
1931 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
1931 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
1932 return cmd
1932 return cmd
1933
1933
1934 def handle_auto(self, line, continue_prompt=None,
1934 def handle_auto(self, line, continue_prompt=None,
1935 pre=None,iFun=None,theRest=None,obj=None):
1935 pre=None,iFun=None,theRest=None,obj=None):
1936 """Hande lines which can be auto-executed, quoting if requested."""
1936 """Hande lines which can be auto-executed, quoting if requested."""
1937
1937
1938 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1938 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1939
1939
1940 # This should only be active for single-line input!
1940 # This should only be active for single-line input!
1941 if continue_prompt:
1941 if continue_prompt:
1942 self.log(line,continue_prompt)
1942 self.log(line,continue_prompt)
1943 return line
1943 return line
1944
1944
1945 auto_rewrite = True
1945 auto_rewrite = True
1946 if pre == self.ESC_QUOTE:
1946 if pre == self.ESC_QUOTE:
1947 # Auto-quote splitting on whitespace
1947 # Auto-quote splitting on whitespace
1948 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
1948 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
1949 elif pre == self.ESC_QUOTE2:
1949 elif pre == self.ESC_QUOTE2:
1950 # Auto-quote whole string
1950 # Auto-quote whole string
1951 newcmd = '%s("%s")' % (iFun,theRest)
1951 newcmd = '%s("%s")' % (iFun,theRest)
1952 else:
1952 else:
1953 # Auto-paren.
1953 # Auto-paren.
1954 # We only apply it to argument-less calls if the autocall
1954 # We only apply it to argument-less calls if the autocall
1955 # parameter is set to 2. We only need to check that autocall is <
1955 # parameter is set to 2. We only need to check that autocall is <
1956 # 2, since this function isn't called unless it's at least 1.
1956 # 2, since this function isn't called unless it's at least 1.
1957 if not theRest and (self.rc.autocall < 2):
1957 if not theRest and (self.rc.autocall < 2):
1958 newcmd = '%s %s' % (iFun,theRest)
1958 newcmd = '%s %s' % (iFun,theRest)
1959 auto_rewrite = False
1959 auto_rewrite = False
1960 else:
1960 else:
1961 if theRest.startswith('['):
1961 if theRest.startswith('['):
1962 if hasattr(obj,'__getitem__'):
1962 if hasattr(obj,'__getitem__'):
1963 # Don't autocall in this case: item access for an object
1963 # Don't autocall in this case: item access for an object
1964 # which is BOTH callable and implements __getitem__.
1964 # which is BOTH callable and implements __getitem__.
1965 newcmd = '%s %s' % (iFun,theRest)
1965 newcmd = '%s %s' % (iFun,theRest)
1966 auto_rewrite = False
1966 auto_rewrite = False
1967 else:
1967 else:
1968 # if the object doesn't support [] access, go ahead and
1968 # if the object doesn't support [] access, go ahead and
1969 # autocall
1969 # autocall
1970 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
1970 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
1971 elif theRest.endswith(';'):
1971 elif theRest.endswith(';'):
1972 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
1972 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
1973 else:
1973 else:
1974 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
1974 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
1975
1975
1976 if auto_rewrite:
1976 if auto_rewrite:
1977 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
1977 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
1978 # log what is now valid Python, not the actual user input (without the
1978 # log what is now valid Python, not the actual user input (without the
1979 # final newline)
1979 # final newline)
1980 self.log(newcmd,continue_prompt)
1980 self.log(newcmd,continue_prompt)
1981 return newcmd
1981 return newcmd
1982
1982
1983 def handle_help(self, line, continue_prompt=None,
1983 def handle_help(self, line, continue_prompt=None,
1984 pre=None,iFun=None,theRest=None):
1984 pre=None,iFun=None,theRest=None):
1985 """Try to get some help for the object.
1985 """Try to get some help for the object.
1986
1986
1987 obj? or ?obj -> basic information.
1987 obj? or ?obj -> basic information.
1988 obj?? or ??obj -> more details.
1988 obj?? or ??obj -> more details.
1989 """
1989 """
1990
1990
1991 # We need to make sure that we don't process lines which would be
1991 # We need to make sure that we don't process lines which would be
1992 # otherwise valid python, such as "x=1 # what?"
1992 # otherwise valid python, such as "x=1 # what?"
1993 try:
1993 try:
1994 codeop.compile_command(line)
1994 codeop.compile_command(line)
1995 except SyntaxError:
1995 except SyntaxError:
1996 # We should only handle as help stuff which is NOT valid syntax
1996 # We should only handle as help stuff which is NOT valid syntax
1997 if line[0]==self.ESC_HELP:
1997 if line[0]==self.ESC_HELP:
1998 line = line[1:]
1998 line = line[1:]
1999 elif line[-1]==self.ESC_HELP:
1999 elif line[-1]==self.ESC_HELP:
2000 line = line[:-1]
2000 line = line[:-1]
2001 self.log('#?'+line)
2001 self.log('#?'+line)
2002 if line:
2002 if line:
2003 self.magic_pinfo(line)
2003 self.magic_pinfo(line)
2004 else:
2004 else:
2005 page(self.usage,screen_lines=self.rc.screen_length)
2005 page(self.usage,screen_lines=self.rc.screen_length)
2006 return '' # Empty string is needed here!
2006 return '' # Empty string is needed here!
2007 except:
2007 except:
2008 # Pass any other exceptions through to the normal handler
2008 # Pass any other exceptions through to the normal handler
2009 return self.handle_normal(line,continue_prompt)
2009 return self.handle_normal(line,continue_prompt)
2010 else:
2010 else:
2011 # If the code compiles ok, we should handle it normally
2011 # If the code compiles ok, we should handle it normally
2012 return self.handle_normal(line,continue_prompt)
2012 return self.handle_normal(line,continue_prompt)
2013
2013
2014 def handle_emacs(self,line,continue_prompt=None,
2014 def handle_emacs(self,line,continue_prompt=None,
2015 pre=None,iFun=None,theRest=None):
2015 pre=None,iFun=None,theRest=None):
2016 """Handle input lines marked by python-mode."""
2016 """Handle input lines marked by python-mode."""
2017
2017
2018 # Currently, nothing is done. Later more functionality can be added
2018 # Currently, nothing is done. Later more functionality can be added
2019 # here if needed.
2019 # here if needed.
2020
2020
2021 # The input cache shouldn't be updated
2021 # The input cache shouldn't be updated
2022
2022
2023 return line
2023 return line
2024
2024
2025 def mktempfile(self,data=None):
2025 def mktempfile(self,data=None):
2026 """Make a new tempfile and return its filename.
2026 """Make a new tempfile and return its filename.
2027
2027
2028 This makes a call to tempfile.mktemp, but it registers the created
2028 This makes a call to tempfile.mktemp, but it registers the created
2029 filename internally so ipython cleans it up at exit time.
2029 filename internally so ipython cleans it up at exit time.
2030
2030
2031 Optional inputs:
2031 Optional inputs:
2032
2032
2033 - data(None): if data is given, it gets written out to the temp file
2033 - data(None): if data is given, it gets written out to the temp file
2034 immediately, and the file is closed again."""
2034 immediately, and the file is closed again."""
2035
2035
2036 filename = tempfile.mktemp('.py')
2036 filename = tempfile.mktemp('.py','ipython_edit_')
2037 self.tempfiles.append(filename)
2037 self.tempfiles.append(filename)
2038
2038
2039 if data:
2039 if data:
2040 tmp_file = open(filename,'w')
2040 tmp_file = open(filename,'w')
2041 tmp_file.write(data)
2041 tmp_file.write(data)
2042 tmp_file.close()
2042 tmp_file.close()
2043 return filename
2043 return filename
2044
2044
2045 def write(self,data):
2045 def write(self,data):
2046 """Write a string to the default output"""
2046 """Write a string to the default output"""
2047 Term.cout.write(data)
2047 Term.cout.write(data)
2048
2048
2049 def write_err(self,data):
2049 def write_err(self,data):
2050 """Write a string to the default error output"""
2050 """Write a string to the default error output"""
2051 Term.cerr.write(data)
2051 Term.cerr.write(data)
2052
2052
2053 def exit(self):
2053 def exit(self):
2054 """Handle interactive exit.
2054 """Handle interactive exit.
2055
2055
2056 This method sets the exit_now attribute."""
2056 This method sets the exit_now attribute."""
2057
2057
2058 if self.rc.confirm_exit:
2058 if self.rc.confirm_exit:
2059 if ask_yes_no('Do you really want to exit ([y]/n)?','y'):
2059 if ask_yes_no('Do you really want to exit ([y]/n)?','y'):
2060 self.exit_now = True
2060 self.exit_now = True
2061 else:
2061 else:
2062 self.exit_now = True
2062 self.exit_now = True
2063 return self.exit_now
2063 return self.exit_now
2064
2064
2065 def safe_execfile(self,fname,*where,**kw):
2065 def safe_execfile(self,fname,*where,**kw):
2066 fname = os.path.expanduser(fname)
2066 fname = os.path.expanduser(fname)
2067
2067
2068 # find things also in current directory
2068 # find things also in current directory
2069 dname = os.path.dirname(fname)
2069 dname = os.path.dirname(fname)
2070 if not sys.path.count(dname):
2070 if not sys.path.count(dname):
2071 sys.path.append(dname)
2071 sys.path.append(dname)
2072
2072
2073 try:
2073 try:
2074 xfile = open(fname)
2074 xfile = open(fname)
2075 except:
2075 except:
2076 print >> Term.cerr, \
2076 print >> Term.cerr, \
2077 'Could not open file <%s> for safe execution.' % fname
2077 'Could not open file <%s> for safe execution.' % fname
2078 return None
2078 return None
2079
2079
2080 kw.setdefault('islog',0)
2080 kw.setdefault('islog',0)
2081 kw.setdefault('quiet',1)
2081 kw.setdefault('quiet',1)
2082 kw.setdefault('exit_ignore',0)
2082 kw.setdefault('exit_ignore',0)
2083 first = xfile.readline()
2083 first = xfile.readline()
2084 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
2084 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
2085 xfile.close()
2085 xfile.close()
2086 # line by line execution
2086 # line by line execution
2087 if first.startswith(loghead) or kw['islog']:
2087 if first.startswith(loghead) or kw['islog']:
2088 print 'Loading log file <%s> one line at a time...' % fname
2088 print 'Loading log file <%s> one line at a time...' % fname
2089 if kw['quiet']:
2089 if kw['quiet']:
2090 stdout_save = sys.stdout
2090 stdout_save = sys.stdout
2091 sys.stdout = StringIO.StringIO()
2091 sys.stdout = StringIO.StringIO()
2092 try:
2092 try:
2093 globs,locs = where[0:2]
2093 globs,locs = where[0:2]
2094 except:
2094 except:
2095 try:
2095 try:
2096 globs = locs = where[0]
2096 globs = locs = where[0]
2097 except:
2097 except:
2098 globs = locs = globals()
2098 globs = locs = globals()
2099 badblocks = []
2099 badblocks = []
2100
2100
2101 # we also need to identify indented blocks of code when replaying
2101 # we also need to identify indented blocks of code when replaying
2102 # logs and put them together before passing them to an exec
2102 # logs and put them together before passing them to an exec
2103 # statement. This takes a bit of regexp and look-ahead work in the
2103 # statement. This takes a bit of regexp and look-ahead work in the
2104 # file. It's easiest if we swallow the whole thing in memory
2104 # file. It's easiest if we swallow the whole thing in memory
2105 # first, and manually walk through the lines list moving the
2105 # first, and manually walk through the lines list moving the
2106 # counter ourselves.
2106 # counter ourselves.
2107 indent_re = re.compile('\s+\S')
2107 indent_re = re.compile('\s+\S')
2108 xfile = open(fname)
2108 xfile = open(fname)
2109 filelines = xfile.readlines()
2109 filelines = xfile.readlines()
2110 xfile.close()
2110 xfile.close()
2111 nlines = len(filelines)
2111 nlines = len(filelines)
2112 lnum = 0
2112 lnum = 0
2113 while lnum < nlines:
2113 while lnum < nlines:
2114 line = filelines[lnum]
2114 line = filelines[lnum]
2115 lnum += 1
2115 lnum += 1
2116 # don't re-insert logger status info into cache
2116 # don't re-insert logger status info into cache
2117 if line.startswith('#log#'):
2117 if line.startswith('#log#'):
2118 continue
2118 continue
2119 else:
2119 else:
2120 # build a block of code (maybe a single line) for execution
2120 # build a block of code (maybe a single line) for execution
2121 block = line
2121 block = line
2122 try:
2122 try:
2123 next = filelines[lnum] # lnum has already incremented
2123 next = filelines[lnum] # lnum has already incremented
2124 except:
2124 except:
2125 next = None
2125 next = None
2126 while next and indent_re.match(next):
2126 while next and indent_re.match(next):
2127 block += next
2127 block += next
2128 lnum += 1
2128 lnum += 1
2129 try:
2129 try:
2130 next = filelines[lnum]
2130 next = filelines[lnum]
2131 except:
2131 except:
2132 next = None
2132 next = None
2133 # now execute the block of one or more lines
2133 # now execute the block of one or more lines
2134 try:
2134 try:
2135 exec block in globs,locs
2135 exec block in globs,locs
2136 except SystemExit:
2136 except SystemExit:
2137 pass
2137 pass
2138 except:
2138 except:
2139 badblocks.append(block.rstrip())
2139 badblocks.append(block.rstrip())
2140 if kw['quiet']: # restore stdout
2140 if kw['quiet']: # restore stdout
2141 sys.stdout.close()
2141 sys.stdout.close()
2142 sys.stdout = stdout_save
2142 sys.stdout = stdout_save
2143 print 'Finished replaying log file <%s>' % fname
2143 print 'Finished replaying log file <%s>' % fname
2144 if badblocks:
2144 if badblocks:
2145 print >> sys.stderr, ('\nThe following lines/blocks in file '
2145 print >> sys.stderr, ('\nThe following lines/blocks in file '
2146 '<%s> reported errors:' % fname)
2146 '<%s> reported errors:' % fname)
2147
2147
2148 for badline in badblocks:
2148 for badline in badblocks:
2149 print >> sys.stderr, badline
2149 print >> sys.stderr, badline
2150 else: # regular file execution
2150 else: # regular file execution
2151 try:
2151 try:
2152 execfile(fname,*where)
2152 execfile(fname,*where)
2153 except SyntaxError:
2153 except SyntaxError:
2154 etype,evalue = sys.exc_info()[:2]
2154 etype,evalue = sys.exc_info()[:2]
2155 self.SyntaxTB(etype,evalue,[])
2155 self.SyntaxTB(etype,evalue,[])
2156 warn('Failure executing file: <%s>' % fname)
2156 warn('Failure executing file: <%s>' % fname)
2157 except SystemExit,status:
2157 except SystemExit,status:
2158 if not kw['exit_ignore']:
2158 if not kw['exit_ignore']:
2159 self.InteractiveTB()
2159 self.InteractiveTB()
2160 warn('Failure executing file: <%s>' % fname)
2160 warn('Failure executing file: <%s>' % fname)
2161 except:
2161 except:
2162 self.InteractiveTB()
2162 self.InteractiveTB()
2163 warn('Failure executing file: <%s>' % fname)
2163 warn('Failure executing file: <%s>' % fname)
2164
2164
2165 #************************* end of file <iplib.py> *****************************
2165 #************************* end of file <iplib.py> *****************************
@@ -1,4804 +1,4814 b''
1 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
2
3 * IPython/Release.py (revision): tag version number to 0.7.0,
4 ready for release.
5
6 * IPython/Magic.py (magic_edit): Add print statement to %edit so
7 it informs the user of the name of the temp. file used. This can
8 help if you decide later to reuse that same file, so you know
9 where to copy the info from.
10
1 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
11 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
2
12
3 * setup_bdist_egg.py: little script to build an egg. Added
13 * setup_bdist_egg.py: little script to build an egg. Added
4 support in the release tools as well.
14 support in the release tools as well.
5
15
6 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
16 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
7
17
8 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
18 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
9 version selection (new -wxversion command line and ipythonrc
19 version selection (new -wxversion command line and ipythonrc
10 parameter). Patch contributed by Arnd Baecker
20 parameter). Patch contributed by Arnd Baecker
11 <arnd.baecker-AT-web.de>.
21 <arnd.baecker-AT-web.de>.
12
22
13 * IPython/iplib.py (embed_mainloop): fix tab-completion in
23 * IPython/iplib.py (embed_mainloop): fix tab-completion in
14 embedded instances, for variables defined at the interactive
24 embedded instances, for variables defined at the interactive
15 prompt of the embedded ipython. Reported by Arnd.
25 prompt of the embedded ipython. Reported by Arnd.
16
26
17 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
27 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
18 it can be used as a (stateful) toggle, or with a direct parameter.
28 it can be used as a (stateful) toggle, or with a direct parameter.
19
29
20 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
30 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
21 could be triggered in certain cases and cause the traceback
31 could be triggered in certain cases and cause the traceback
22 printer not to work.
32 printer not to work.
23
33
24 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
34 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
25
35
26 * IPython/iplib.py (_should_recompile): Small fix, closes
36 * IPython/iplib.py (_should_recompile): Small fix, closes
27 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
37 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
28
38
29 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
39 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
30
40
31 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
41 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
32 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
42 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
33 Moad for help with tracking it down.
43 Moad for help with tracking it down.
34
44
35 * IPython/iplib.py (handle_auto): fix autocall handling for
45 * IPython/iplib.py (handle_auto): fix autocall handling for
36 objects which support BOTH __getitem__ and __call__ (so that f [x]
46 objects which support BOTH __getitem__ and __call__ (so that f [x]
37 is left alone, instead of becoming f([x]) automatically).
47 is left alone, instead of becoming f([x]) automatically).
38
48
39 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
49 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
40 Ville's patch.
50 Ville's patch.
41
51
42 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
52 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
43
53
44 * IPython/iplib.py (handle_auto): changed autocall semantics to
54 * IPython/iplib.py (handle_auto): changed autocall semantics to
45 include 'smart' mode, where the autocall transformation is NOT
55 include 'smart' mode, where the autocall transformation is NOT
46 applied if there are no arguments on the line. This allows you to
56 applied if there are no arguments on the line. This allows you to
47 just type 'foo' if foo is a callable to see its internal form,
57 just type 'foo' if foo is a callable to see its internal form,
48 instead of having it called with no arguments (typically a
58 instead of having it called with no arguments (typically a
49 mistake). The old 'full' autocall still exists: for that, you
59 mistake). The old 'full' autocall still exists: for that, you
50 need to set the 'autocall' parameter to 2 in your ipythonrc file.
60 need to set the 'autocall' parameter to 2 in your ipythonrc file.
51
61
52 * IPython/completer.py (Completer.attr_matches): add
62 * IPython/completer.py (Completer.attr_matches): add
53 tab-completion support for Enthoughts' traits. After a report by
63 tab-completion support for Enthoughts' traits. After a report by
54 Arnd and a patch by Prabhu.
64 Arnd and a patch by Prabhu.
55
65
56 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
66 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
57
67
58 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
68 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
59 Schmolck's patch to fix inspect.getinnerframes().
69 Schmolck's patch to fix inspect.getinnerframes().
60
70
61 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
71 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
62 for embedded instances, regarding handling of namespaces and items
72 for embedded instances, regarding handling of namespaces and items
63 added to the __builtin__ one. Multiple embedded instances and
73 added to the __builtin__ one. Multiple embedded instances and
64 recursive embeddings should work better now (though I'm not sure
74 recursive embeddings should work better now (though I'm not sure
65 I've got all the corner cases fixed, that code is a bit of a brain
75 I've got all the corner cases fixed, that code is a bit of a brain
66 twister).
76 twister).
67
77
68 * IPython/Magic.py (magic_edit): added support to edit in-memory
78 * IPython/Magic.py (magic_edit): added support to edit in-memory
69 macros (automatically creates the necessary temp files). %edit
79 macros (automatically creates the necessary temp files). %edit
70 also doesn't return the file contents anymore, it's just noise.
80 also doesn't return the file contents anymore, it's just noise.
71
81
72 * IPython/completer.py (Completer.attr_matches): revert change to
82 * IPython/completer.py (Completer.attr_matches): revert change to
73 complete only on attributes listed in __all__. I realized it
83 complete only on attributes listed in __all__. I realized it
74 cripples the tab-completion system as a tool for exploring the
84 cripples the tab-completion system as a tool for exploring the
75 internals of unknown libraries (it renders any non-__all__
85 internals of unknown libraries (it renders any non-__all__
76 attribute off-limits). I got bit by this when trying to see
86 attribute off-limits). I got bit by this when trying to see
77 something inside the dis module.
87 something inside the dis module.
78
88
79 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
89 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
80
90
81 * IPython/iplib.py (InteractiveShell.__init__): add .meta
91 * IPython/iplib.py (InteractiveShell.__init__): add .meta
82 namespace for users and extension writers to hold data in. This
92 namespace for users and extension writers to hold data in. This
83 follows the discussion in
93 follows the discussion in
84 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
94 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
85
95
86 * IPython/completer.py (IPCompleter.complete): small patch to help
96 * IPython/completer.py (IPCompleter.complete): small patch to help
87 tab-completion under Emacs, after a suggestion by John Barnard
97 tab-completion under Emacs, after a suggestion by John Barnard
88 <barnarj-AT-ccf.org>.
98 <barnarj-AT-ccf.org>.
89
99
90 * IPython/Magic.py (Magic.extract_input_slices): added support for
100 * IPython/Magic.py (Magic.extract_input_slices): added support for
91 the slice notation in magics to use N-M to represent numbers N...M
101 the slice notation in magics to use N-M to represent numbers N...M
92 (closed endpoints). This is used by %macro and %save.
102 (closed endpoints). This is used by %macro and %save.
93
103
94 * IPython/completer.py (Completer.attr_matches): for modules which
104 * IPython/completer.py (Completer.attr_matches): for modules which
95 define __all__, complete only on those. After a patch by Jeffrey
105 define __all__, complete only on those. After a patch by Jeffrey
96 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
106 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
97 speed up this routine.
107 speed up this routine.
98
108
99 * IPython/Logger.py (Logger.log): fix a history handling bug. I
109 * IPython/Logger.py (Logger.log): fix a history handling bug. I
100 don't know if this is the end of it, but the behavior now is
110 don't know if this is the end of it, but the behavior now is
101 certainly much more correct. Note that coupled with macros,
111 certainly much more correct. Note that coupled with macros,
102 slightly surprising (at first) behavior may occur: a macro will in
112 slightly surprising (at first) behavior may occur: a macro will in
103 general expand to multiple lines of input, so upon exiting, the
113 general expand to multiple lines of input, so upon exiting, the
104 in/out counters will both be bumped by the corresponding amount
114 in/out counters will both be bumped by the corresponding amount
105 (as if the macro's contents had been typed interactively). Typing
115 (as if the macro's contents had been typed interactively). Typing
106 %hist will reveal the intermediate (silently processed) lines.
116 %hist will reveal the intermediate (silently processed) lines.
107
117
108 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
118 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
109 pickle to fail (%run was overwriting __main__ and not restoring
119 pickle to fail (%run was overwriting __main__ and not restoring
110 it, but pickle relies on __main__ to operate).
120 it, but pickle relies on __main__ to operate).
111
121
112 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
122 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
113 using properties, but forgot to make the main InteractiveShell
123 using properties, but forgot to make the main InteractiveShell
114 class a new-style class. Properties fail silently, and
124 class a new-style class. Properties fail silently, and
115 misteriously, with old-style class (getters work, but
125 misteriously, with old-style class (getters work, but
116 setters don't do anything).
126 setters don't do anything).
117
127
118 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
128 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
119
129
120 * IPython/Magic.py (magic_history): fix history reporting bug (I
130 * IPython/Magic.py (magic_history): fix history reporting bug (I
121 know some nasties are still there, I just can't seem to find a
131 know some nasties are still there, I just can't seem to find a
122 reproducible test case to track them down; the input history is
132 reproducible test case to track them down; the input history is
123 falling out of sync...)
133 falling out of sync...)
124
134
125 * IPython/iplib.py (handle_shell_escape): fix bug where both
135 * IPython/iplib.py (handle_shell_escape): fix bug where both
126 aliases and system accesses where broken for indented code (such
136 aliases and system accesses where broken for indented code (such
127 as loops).
137 as loops).
128
138
129 * IPython/genutils.py (shell): fix small but critical bug for
139 * IPython/genutils.py (shell): fix small but critical bug for
130 win32 system access.
140 win32 system access.
131
141
132 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
142 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
133
143
134 * IPython/iplib.py (showtraceback): remove use of the
144 * IPython/iplib.py (showtraceback): remove use of the
135 sys.last_{type/value/traceback} structures, which are non
145 sys.last_{type/value/traceback} structures, which are non
136 thread-safe.
146 thread-safe.
137 (_prefilter): change control flow to ensure that we NEVER
147 (_prefilter): change control flow to ensure that we NEVER
138 introspect objects when autocall is off. This will guarantee that
148 introspect objects when autocall is off. This will guarantee that
139 having an input line of the form 'x.y', where access to attribute
149 having an input line of the form 'x.y', where access to attribute
140 'y' has side effects, doesn't trigger the side effect TWICE. It
150 'y' has side effects, doesn't trigger the side effect TWICE. It
141 is important to note that, with autocall on, these side effects
151 is important to note that, with autocall on, these side effects
142 can still happen.
152 can still happen.
143 (ipsystem): new builtin, to complete the ip{magic/alias/system}
153 (ipsystem): new builtin, to complete the ip{magic/alias/system}
144 trio. IPython offers these three kinds of special calls which are
154 trio. IPython offers these three kinds of special calls which are
145 not python code, and it's a good thing to have their call method
155 not python code, and it's a good thing to have their call method
146 be accessible as pure python functions (not just special syntax at
156 be accessible as pure python functions (not just special syntax at
147 the command line). It gives us a better internal implementation
157 the command line). It gives us a better internal implementation
148 structure, as well as exposing these for user scripting more
158 structure, as well as exposing these for user scripting more
149 cleanly.
159 cleanly.
150
160
151 * IPython/macro.py (Macro.__init__): moved macros to a standalone
161 * IPython/macro.py (Macro.__init__): moved macros to a standalone
152 file. Now that they'll be more likely to be used with the
162 file. Now that they'll be more likely to be used with the
153 persistance system (%store), I want to make sure their module path
163 persistance system (%store), I want to make sure their module path
154 doesn't change in the future, so that we don't break things for
164 doesn't change in the future, so that we don't break things for
155 users' persisted data.
165 users' persisted data.
156
166
157 * IPython/iplib.py (autoindent_update): move indentation
167 * IPython/iplib.py (autoindent_update): move indentation
158 management into the _text_ processing loop, not the keyboard
168 management into the _text_ processing loop, not the keyboard
159 interactive one. This is necessary to correctly process non-typed
169 interactive one. This is necessary to correctly process non-typed
160 multiline input (such as macros).
170 multiline input (such as macros).
161
171
162 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
172 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
163 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
173 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
164 which was producing problems in the resulting manual.
174 which was producing problems in the resulting manual.
165 (magic_whos): improve reporting of instances (show their class,
175 (magic_whos): improve reporting of instances (show their class,
166 instead of simply printing 'instance' which isn't terribly
176 instead of simply printing 'instance' which isn't terribly
167 informative).
177 informative).
168
178
169 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
179 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
170 (minor mods) to support network shares under win32.
180 (minor mods) to support network shares under win32.
171
181
172 * IPython/winconsole.py (get_console_size): add new winconsole
182 * IPython/winconsole.py (get_console_size): add new winconsole
173 module and fixes to page_dumb() to improve its behavior under
183 module and fixes to page_dumb() to improve its behavior under
174 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
184 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
175
185
176 * IPython/Magic.py (Macro): simplified Macro class to just
186 * IPython/Magic.py (Macro): simplified Macro class to just
177 subclass list. We've had only 2.2 compatibility for a very long
187 subclass list. We've had only 2.2 compatibility for a very long
178 time, yet I was still avoiding subclassing the builtin types. No
188 time, yet I was still avoiding subclassing the builtin types. No
179 more (I'm also starting to use properties, though I won't shift to
189 more (I'm also starting to use properties, though I won't shift to
180 2.3-specific features quite yet).
190 2.3-specific features quite yet).
181 (magic_store): added Ville's patch for lightweight variable
191 (magic_store): added Ville's patch for lightweight variable
182 persistence, after a request on the user list by Matt Wilkie
192 persistence, after a request on the user list by Matt Wilkie
183 <maphew-AT-gmail.com>. The new %store magic's docstring has full
193 <maphew-AT-gmail.com>. The new %store magic's docstring has full
184 details.
194 details.
185
195
186 * IPython/iplib.py (InteractiveShell.post_config_initialization):
196 * IPython/iplib.py (InteractiveShell.post_config_initialization):
187 changed the default logfile name from 'ipython.log' to
197 changed the default logfile name from 'ipython.log' to
188 'ipython_log.py'. These logs are real python files, and now that
198 'ipython_log.py'. These logs are real python files, and now that
189 we have much better multiline support, people are more likely to
199 we have much better multiline support, people are more likely to
190 want to use them as such. Might as well name them correctly.
200 want to use them as such. Might as well name them correctly.
191
201
192 * IPython/Magic.py: substantial cleanup. While we can't stop
202 * IPython/Magic.py: substantial cleanup. While we can't stop
193 using magics as mixins, due to the existing customizations 'out
203 using magics as mixins, due to the existing customizations 'out
194 there' which rely on the mixin naming conventions, at least I
204 there' which rely on the mixin naming conventions, at least I
195 cleaned out all cross-class name usage. So once we are OK with
205 cleaned out all cross-class name usage. So once we are OK with
196 breaking compatibility, the two systems can be separated.
206 breaking compatibility, the two systems can be separated.
197
207
198 * IPython/Logger.py: major cleanup. This one is NOT a mixin
208 * IPython/Logger.py: major cleanup. This one is NOT a mixin
199 anymore, and the class is a fair bit less hideous as well. New
209 anymore, and the class is a fair bit less hideous as well. New
200 features were also introduced: timestamping of input, and logging
210 features were also introduced: timestamping of input, and logging
201 of output results. These are user-visible with the -t and -o
211 of output results. These are user-visible with the -t and -o
202 options to %logstart. Closes
212 options to %logstart. Closes
203 http://www.scipy.net/roundup/ipython/issue11 and a request by
213 http://www.scipy.net/roundup/ipython/issue11 and a request by
204 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
214 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
205
215
206 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
216 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
207
217
208 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
218 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
209 better hadnle backslashes in paths. See the thread 'More Windows
219 better hadnle backslashes in paths. See the thread 'More Windows
210 questions part 2 - \/ characters revisited' on the iypthon user
220 questions part 2 - \/ characters revisited' on the iypthon user
211 list:
221 list:
212 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
222 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
213
223
214 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
224 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
215
225
216 (InteractiveShell.__init__): change threaded shells to not use the
226 (InteractiveShell.__init__): change threaded shells to not use the
217 ipython crash handler. This was causing more problems than not,
227 ipython crash handler. This was causing more problems than not,
218 as exceptions in the main thread (GUI code, typically) would
228 as exceptions in the main thread (GUI code, typically) would
219 always show up as a 'crash', when they really weren't.
229 always show up as a 'crash', when they really weren't.
220
230
221 The colors and exception mode commands (%colors/%xmode) have been
231 The colors and exception mode commands (%colors/%xmode) have been
222 synchronized to also take this into account, so users can get
232 synchronized to also take this into account, so users can get
223 verbose exceptions for their threaded code as well. I also added
233 verbose exceptions for their threaded code as well. I also added
224 support for activating pdb inside this exception handler as well,
234 support for activating pdb inside this exception handler as well,
225 so now GUI authors can use IPython's enhanced pdb at runtime.
235 so now GUI authors can use IPython's enhanced pdb at runtime.
226
236
227 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
237 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
228 true by default, and add it to the shipped ipythonrc file. Since
238 true by default, and add it to the shipped ipythonrc file. Since
229 this asks the user before proceeding, I think it's OK to make it
239 this asks the user before proceeding, I think it's OK to make it
230 true by default.
240 true by default.
231
241
232 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
242 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
233 of the previous special-casing of input in the eval loop. I think
243 of the previous special-casing of input in the eval loop. I think
234 this is cleaner, as they really are commands and shouldn't have
244 this is cleaner, as they really are commands and shouldn't have
235 a special role in the middle of the core code.
245 a special role in the middle of the core code.
236
246
237 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
247 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
238
248
239 * IPython/iplib.py (edit_syntax_error): added support for
249 * IPython/iplib.py (edit_syntax_error): added support for
240 automatically reopening the editor if the file had a syntax error
250 automatically reopening the editor if the file had a syntax error
241 in it. Thanks to scottt who provided the patch at:
251 in it. Thanks to scottt who provided the patch at:
242 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
252 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
243 version committed).
253 version committed).
244
254
245 * IPython/iplib.py (handle_normal): add suport for multi-line
255 * IPython/iplib.py (handle_normal): add suport for multi-line
246 input with emtpy lines. This fixes
256 input with emtpy lines. This fixes
247 http://www.scipy.net/roundup/ipython/issue43 and a similar
257 http://www.scipy.net/roundup/ipython/issue43 and a similar
248 discussion on the user list.
258 discussion on the user list.
249
259
250 WARNING: a behavior change is necessarily introduced to support
260 WARNING: a behavior change is necessarily introduced to support
251 blank lines: now a single blank line with whitespace does NOT
261 blank lines: now a single blank line with whitespace does NOT
252 break the input loop, which means that when autoindent is on, by
262 break the input loop, which means that when autoindent is on, by
253 default hitting return on the next (indented) line does NOT exit.
263 default hitting return on the next (indented) line does NOT exit.
254
264
255 Instead, to exit a multiline input you can either have:
265 Instead, to exit a multiline input you can either have:
256
266
257 - TWO whitespace lines (just hit return again), or
267 - TWO whitespace lines (just hit return again), or
258 - a single whitespace line of a different length than provided
268 - a single whitespace line of a different length than provided
259 by the autoindent (add or remove a space).
269 by the autoindent (add or remove a space).
260
270
261 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
271 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
262 module to better organize all readline-related functionality.
272 module to better organize all readline-related functionality.
263 I've deleted FlexCompleter and put all completion clases here.
273 I've deleted FlexCompleter and put all completion clases here.
264
274
265 * IPython/iplib.py (raw_input): improve indentation management.
275 * IPython/iplib.py (raw_input): improve indentation management.
266 It is now possible to paste indented code with autoindent on, and
276 It is now possible to paste indented code with autoindent on, and
267 the code is interpreted correctly (though it still looks bad on
277 the code is interpreted correctly (though it still looks bad on
268 screen, due to the line-oriented nature of ipython).
278 screen, due to the line-oriented nature of ipython).
269 (MagicCompleter.complete): change behavior so that a TAB key on an
279 (MagicCompleter.complete): change behavior so that a TAB key on an
270 otherwise empty line actually inserts a tab, instead of completing
280 otherwise empty line actually inserts a tab, instead of completing
271 on the entire global namespace. This makes it easier to use the
281 on the entire global namespace. This makes it easier to use the
272 TAB key for indentation. After a request by Hans Meine
282 TAB key for indentation. After a request by Hans Meine
273 <hans_meine-AT-gmx.net>
283 <hans_meine-AT-gmx.net>
274 (_prefilter): add support so that typing plain 'exit' or 'quit'
284 (_prefilter): add support so that typing plain 'exit' or 'quit'
275 does a sensible thing. Originally I tried to deviate as little as
285 does a sensible thing. Originally I tried to deviate as little as
276 possible from the default python behavior, but even that one may
286 possible from the default python behavior, but even that one may
277 change in this direction (thread on python-dev to that effect).
287 change in this direction (thread on python-dev to that effect).
278 Regardless, ipython should do the right thing even if CPython's
288 Regardless, ipython should do the right thing even if CPython's
279 '>>>' prompt doesn't.
289 '>>>' prompt doesn't.
280 (InteractiveShell): removed subclassing code.InteractiveConsole
290 (InteractiveShell): removed subclassing code.InteractiveConsole
281 class. By now we'd overridden just about all of its methods: I've
291 class. By now we'd overridden just about all of its methods: I've
282 copied the remaining two over, and now ipython is a standalone
292 copied the remaining two over, and now ipython is a standalone
283 class. This will provide a clearer picture for the chainsaw
293 class. This will provide a clearer picture for the chainsaw
284 branch refactoring.
294 branch refactoring.
285
295
286 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
296 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
287
297
288 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
298 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
289 failures for objects which break when dir() is called on them.
299 failures for objects which break when dir() is called on them.
290
300
291 * IPython/FlexCompleter.py (Completer.__init__): Added support for
301 * IPython/FlexCompleter.py (Completer.__init__): Added support for
292 distinct local and global namespaces in the completer API. This
302 distinct local and global namespaces in the completer API. This
293 change allows us top properly handle completion with distinct
303 change allows us top properly handle completion with distinct
294 scopes, including in embedded instances (this had never really
304 scopes, including in embedded instances (this had never really
295 worked correctly).
305 worked correctly).
296
306
297 Note: this introduces a change in the constructor for
307 Note: this introduces a change in the constructor for
298 MagicCompleter, as a new global_namespace parameter is now the
308 MagicCompleter, as a new global_namespace parameter is now the
299 second argument (the others were bumped one position).
309 second argument (the others were bumped one position).
300
310
301 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
311 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
302
312
303 * IPython/iplib.py (embed_mainloop): fix tab-completion in
313 * IPython/iplib.py (embed_mainloop): fix tab-completion in
304 embedded instances (which can be done now thanks to Vivian's
314 embedded instances (which can be done now thanks to Vivian's
305 frame-handling fixes for pdb).
315 frame-handling fixes for pdb).
306 (InteractiveShell.__init__): Fix namespace handling problem in
316 (InteractiveShell.__init__): Fix namespace handling problem in
307 embedded instances. We were overwriting __main__ unconditionally,
317 embedded instances. We were overwriting __main__ unconditionally,
308 and this should only be done for 'full' (non-embedded) IPython;
318 and this should only be done for 'full' (non-embedded) IPython;
309 embedded instances must respect the caller's __main__. Thanks to
319 embedded instances must respect the caller's __main__. Thanks to
310 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
320 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
311
321
312 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
322 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
313
323
314 * setup.py: added download_url to setup(). This registers the
324 * setup.py: added download_url to setup(). This registers the
315 download address at PyPI, which is not only useful to humans
325 download address at PyPI, which is not only useful to humans
316 browsing the site, but is also picked up by setuptools (the Eggs
326 browsing the site, but is also picked up by setuptools (the Eggs
317 machinery). Thanks to Ville and R. Kern for the info/discussion
327 machinery). Thanks to Ville and R. Kern for the info/discussion
318 on this.
328 on this.
319
329
320 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
330 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
321
331
322 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
332 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
323 This brings a lot of nice functionality to the pdb mode, which now
333 This brings a lot of nice functionality to the pdb mode, which now
324 has tab-completion, syntax highlighting, and better stack handling
334 has tab-completion, syntax highlighting, and better stack handling
325 than before. Many thanks to Vivian De Smedt
335 than before. Many thanks to Vivian De Smedt
326 <vivian-AT-vdesmedt.com> for the original patches.
336 <vivian-AT-vdesmedt.com> for the original patches.
327
337
328 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
338 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
329
339
330 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
340 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
331 sequence to consistently accept the banner argument. The
341 sequence to consistently accept the banner argument. The
332 inconsistency was tripping SAGE, thanks to Gary Zablackis
342 inconsistency was tripping SAGE, thanks to Gary Zablackis
333 <gzabl-AT-yahoo.com> for the report.
343 <gzabl-AT-yahoo.com> for the report.
334
344
335 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
345 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
336
346
337 * IPython/iplib.py (InteractiveShell.post_config_initialization):
347 * IPython/iplib.py (InteractiveShell.post_config_initialization):
338 Fix bug where a naked 'alias' call in the ipythonrc file would
348 Fix bug where a naked 'alias' call in the ipythonrc file would
339 cause a crash. Bug reported by Jorgen Stenarson.
349 cause a crash. Bug reported by Jorgen Stenarson.
340
350
341 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
351 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
342
352
343 * IPython/ipmaker.py (make_IPython): cleanups which should improve
353 * IPython/ipmaker.py (make_IPython): cleanups which should improve
344 startup time.
354 startup time.
345
355
346 * IPython/iplib.py (runcode): my globals 'fix' for embedded
356 * IPython/iplib.py (runcode): my globals 'fix' for embedded
347 instances had introduced a bug with globals in normal code. Now
357 instances had introduced a bug with globals in normal code. Now
348 it's working in all cases.
358 it's working in all cases.
349
359
350 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
360 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
351 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
361 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
352 has been introduced to set the default case sensitivity of the
362 has been introduced to set the default case sensitivity of the
353 searches. Users can still select either mode at runtime on a
363 searches. Users can still select either mode at runtime on a
354 per-search basis.
364 per-search basis.
355
365
356 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
366 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
357
367
358 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
368 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
359 attributes in wildcard searches for subclasses. Modified version
369 attributes in wildcard searches for subclasses. Modified version
360 of a patch by Jorgen.
370 of a patch by Jorgen.
361
371
362 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
372 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
363
373
364 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
374 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
365 embedded instances. I added a user_global_ns attribute to the
375 embedded instances. I added a user_global_ns attribute to the
366 InteractiveShell class to handle this.
376 InteractiveShell class to handle this.
367
377
368 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
378 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
369
379
370 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
380 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
371 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
381 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
372 (reported under win32, but may happen also in other platforms).
382 (reported under win32, but may happen also in other platforms).
373 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
383 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
374
384
375 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
385 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
376
386
377 * IPython/Magic.py (magic_psearch): new support for wildcard
387 * IPython/Magic.py (magic_psearch): new support for wildcard
378 patterns. Now, typing ?a*b will list all names which begin with a
388 patterns. Now, typing ?a*b will list all names which begin with a
379 and end in b, for example. The %psearch magic has full
389 and end in b, for example. The %psearch magic has full
380 docstrings. Many thanks to Jörgen Stenarson
390 docstrings. Many thanks to Jörgen Stenarson
381 <jorgen.stenarson-AT-bostream.nu>, author of the patches
391 <jorgen.stenarson-AT-bostream.nu>, author of the patches
382 implementing this functionality.
392 implementing this functionality.
383
393
384 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
394 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
385
395
386 * Manual: fixed long-standing annoyance of double-dashes (as in
396 * Manual: fixed long-standing annoyance of double-dashes (as in
387 --prefix=~, for example) being stripped in the HTML version. This
397 --prefix=~, for example) being stripped in the HTML version. This
388 is a latex2html bug, but a workaround was provided. Many thanks
398 is a latex2html bug, but a workaround was provided. Many thanks
389 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
399 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
390 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
400 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
391 rolling. This seemingly small issue had tripped a number of users
401 rolling. This seemingly small issue had tripped a number of users
392 when first installing, so I'm glad to see it gone.
402 when first installing, so I'm glad to see it gone.
393
403
394 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
404 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
395
405
396 * IPython/Extensions/numeric_formats.py: fix missing import,
406 * IPython/Extensions/numeric_formats.py: fix missing import,
397 reported by Stephen Walton.
407 reported by Stephen Walton.
398
408
399 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
409 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
400
410
401 * IPython/demo.py: finish demo module, fully documented now.
411 * IPython/demo.py: finish demo module, fully documented now.
402
412
403 * IPython/genutils.py (file_read): simple little utility to read a
413 * IPython/genutils.py (file_read): simple little utility to read a
404 file and ensure it's closed afterwards.
414 file and ensure it's closed afterwards.
405
415
406 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
416 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
407
417
408 * IPython/demo.py (Demo.__init__): added support for individually
418 * IPython/demo.py (Demo.__init__): added support for individually
409 tagging blocks for automatic execution.
419 tagging blocks for automatic execution.
410
420
411 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
421 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
412 syntax-highlighted python sources, requested by John.
422 syntax-highlighted python sources, requested by John.
413
423
414 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
424 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
415
425
416 * IPython/demo.py (Demo.again): fix bug where again() blocks after
426 * IPython/demo.py (Demo.again): fix bug where again() blocks after
417 finishing.
427 finishing.
418
428
419 * IPython/genutils.py (shlex_split): moved from Magic to here,
429 * IPython/genutils.py (shlex_split): moved from Magic to here,
420 where all 2.2 compatibility stuff lives. I needed it for demo.py.
430 where all 2.2 compatibility stuff lives. I needed it for demo.py.
421
431
422 * IPython/demo.py (Demo.__init__): added support for silent
432 * IPython/demo.py (Demo.__init__): added support for silent
423 blocks, improved marks as regexps, docstrings written.
433 blocks, improved marks as regexps, docstrings written.
424 (Demo.__init__): better docstring, added support for sys.argv.
434 (Demo.__init__): better docstring, added support for sys.argv.
425
435
426 * IPython/genutils.py (marquee): little utility used by the demo
436 * IPython/genutils.py (marquee): little utility used by the demo
427 code, handy in general.
437 code, handy in general.
428
438
429 * IPython/demo.py (Demo.__init__): new class for interactive
439 * IPython/demo.py (Demo.__init__): new class for interactive
430 demos. Not documented yet, I just wrote it in a hurry for
440 demos. Not documented yet, I just wrote it in a hurry for
431 scipy'05. Will docstring later.
441 scipy'05. Will docstring later.
432
442
433 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
443 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
434
444
435 * IPython/Shell.py (sigint_handler): Drastic simplification which
445 * IPython/Shell.py (sigint_handler): Drastic simplification which
436 also seems to make Ctrl-C work correctly across threads! This is
446 also seems to make Ctrl-C work correctly across threads! This is
437 so simple, that I can't beleive I'd missed it before. Needs more
447 so simple, that I can't beleive I'd missed it before. Needs more
438 testing, though.
448 testing, though.
439 (KBINT): Never mind, revert changes. I'm sure I'd tried something
449 (KBINT): Never mind, revert changes. I'm sure I'd tried something
440 like this before...
450 like this before...
441
451
442 * IPython/genutils.py (get_home_dir): add protection against
452 * IPython/genutils.py (get_home_dir): add protection against
443 non-dirs in win32 registry.
453 non-dirs in win32 registry.
444
454
445 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
455 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
446 bug where dict was mutated while iterating (pysh crash).
456 bug where dict was mutated while iterating (pysh crash).
447
457
448 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
458 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
449
459
450 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
460 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
451 spurious newlines added by this routine. After a report by
461 spurious newlines added by this routine. After a report by
452 F. Mantegazza.
462 F. Mantegazza.
453
463
454 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
464 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
455
465
456 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
466 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
457 calls. These were a leftover from the GTK 1.x days, and can cause
467 calls. These were a leftover from the GTK 1.x days, and can cause
458 problems in certain cases (after a report by John Hunter).
468 problems in certain cases (after a report by John Hunter).
459
469
460 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
470 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
461 os.getcwd() fails at init time. Thanks to patch from David Remahl
471 os.getcwd() fails at init time. Thanks to patch from David Remahl
462 <chmod007-AT-mac.com>.
472 <chmod007-AT-mac.com>.
463 (InteractiveShell.__init__): prevent certain special magics from
473 (InteractiveShell.__init__): prevent certain special magics from
464 being shadowed by aliases. Closes
474 being shadowed by aliases. Closes
465 http://www.scipy.net/roundup/ipython/issue41.
475 http://www.scipy.net/roundup/ipython/issue41.
466
476
467 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
477 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
468
478
469 * IPython/iplib.py (InteractiveShell.complete): Added new
479 * IPython/iplib.py (InteractiveShell.complete): Added new
470 top-level completion method to expose the completion mechanism
480 top-level completion method to expose the completion mechanism
471 beyond readline-based environments.
481 beyond readline-based environments.
472
482
473 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
483 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
474
484
475 * tools/ipsvnc (svnversion): fix svnversion capture.
485 * tools/ipsvnc (svnversion): fix svnversion capture.
476
486
477 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
487 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
478 attribute to self, which was missing. Before, it was set by a
488 attribute to self, which was missing. Before, it was set by a
479 routine which in certain cases wasn't being called, so the
489 routine which in certain cases wasn't being called, so the
480 instance could end up missing the attribute. This caused a crash.
490 instance could end up missing the attribute. This caused a crash.
481 Closes http://www.scipy.net/roundup/ipython/issue40.
491 Closes http://www.scipy.net/roundup/ipython/issue40.
482
492
483 2005-08-16 Fernando Perez <fperez@colorado.edu>
493 2005-08-16 Fernando Perez <fperez@colorado.edu>
484
494
485 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
495 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
486 contains non-string attribute. Closes
496 contains non-string attribute. Closes
487 http://www.scipy.net/roundup/ipython/issue38.
497 http://www.scipy.net/roundup/ipython/issue38.
488
498
489 2005-08-14 Fernando Perez <fperez@colorado.edu>
499 2005-08-14 Fernando Perez <fperez@colorado.edu>
490
500
491 * tools/ipsvnc: Minor improvements, to add changeset info.
501 * tools/ipsvnc: Minor improvements, to add changeset info.
492
502
493 2005-08-12 Fernando Perez <fperez@colorado.edu>
503 2005-08-12 Fernando Perez <fperez@colorado.edu>
494
504
495 * IPython/iplib.py (runsource): remove self.code_to_run_src
505 * IPython/iplib.py (runsource): remove self.code_to_run_src
496 attribute. I realized this is nothing more than
506 attribute. I realized this is nothing more than
497 '\n'.join(self.buffer), and having the same data in two different
507 '\n'.join(self.buffer), and having the same data in two different
498 places is just asking for synchronization bugs. This may impact
508 places is just asking for synchronization bugs. This may impact
499 people who have custom exception handlers, so I need to warn
509 people who have custom exception handlers, so I need to warn
500 ipython-dev about it (F. Mantegazza may use them).
510 ipython-dev about it (F. Mantegazza may use them).
501
511
502 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
512 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
503
513
504 * IPython/genutils.py: fix 2.2 compatibility (generators)
514 * IPython/genutils.py: fix 2.2 compatibility (generators)
505
515
506 2005-07-18 Fernando Perez <fperez@colorado.edu>
516 2005-07-18 Fernando Perez <fperez@colorado.edu>
507
517
508 * IPython/genutils.py (get_home_dir): fix to help users with
518 * IPython/genutils.py (get_home_dir): fix to help users with
509 invalid $HOME under win32.
519 invalid $HOME under win32.
510
520
511 2005-07-17 Fernando Perez <fperez@colorado.edu>
521 2005-07-17 Fernando Perez <fperez@colorado.edu>
512
522
513 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
523 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
514 some old hacks and clean up a bit other routines; code should be
524 some old hacks and clean up a bit other routines; code should be
515 simpler and a bit faster.
525 simpler and a bit faster.
516
526
517 * IPython/iplib.py (interact): removed some last-resort attempts
527 * IPython/iplib.py (interact): removed some last-resort attempts
518 to survive broken stdout/stderr. That code was only making it
528 to survive broken stdout/stderr. That code was only making it
519 harder to abstract out the i/o (necessary for gui integration),
529 harder to abstract out the i/o (necessary for gui integration),
520 and the crashes it could prevent were extremely rare in practice
530 and the crashes it could prevent were extremely rare in practice
521 (besides being fully user-induced in a pretty violent manner).
531 (besides being fully user-induced in a pretty violent manner).
522
532
523 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
533 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
524 Nothing major yet, but the code is simpler to read; this should
534 Nothing major yet, but the code is simpler to read; this should
525 make it easier to do more serious modifications in the future.
535 make it easier to do more serious modifications in the future.
526
536
527 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
537 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
528 which broke in .15 (thanks to a report by Ville).
538 which broke in .15 (thanks to a report by Ville).
529
539
530 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
540 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
531 be quite correct, I know next to nothing about unicode). This
541 be quite correct, I know next to nothing about unicode). This
532 will allow unicode strings to be used in prompts, amongst other
542 will allow unicode strings to be used in prompts, amongst other
533 cases. It also will prevent ipython from crashing when unicode
543 cases. It also will prevent ipython from crashing when unicode
534 shows up unexpectedly in many places. If ascii encoding fails, we
544 shows up unexpectedly in many places. If ascii encoding fails, we
535 assume utf_8. Currently the encoding is not a user-visible
545 assume utf_8. Currently the encoding is not a user-visible
536 setting, though it could be made so if there is demand for it.
546 setting, though it could be made so if there is demand for it.
537
547
538 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
548 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
539
549
540 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
550 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
541
551
542 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
552 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
543
553
544 * IPython/genutils.py: Add 2.2 compatibility here, so all other
554 * IPython/genutils.py: Add 2.2 compatibility here, so all other
545 code can work transparently for 2.2/2.3.
555 code can work transparently for 2.2/2.3.
546
556
547 2005-07-16 Fernando Perez <fperez@colorado.edu>
557 2005-07-16 Fernando Perez <fperez@colorado.edu>
548
558
549 * IPython/ultraTB.py (ExceptionColors): Make a global variable
559 * IPython/ultraTB.py (ExceptionColors): Make a global variable
550 out of the color scheme table used for coloring exception
560 out of the color scheme table used for coloring exception
551 tracebacks. This allows user code to add new schemes at runtime.
561 tracebacks. This allows user code to add new schemes at runtime.
552 This is a minimally modified version of the patch at
562 This is a minimally modified version of the patch at
553 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
563 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
554 for the contribution.
564 for the contribution.
555
565
556 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
566 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
557 slightly modified version of the patch in
567 slightly modified version of the patch in
558 http://www.scipy.net/roundup/ipython/issue34, which also allows me
568 http://www.scipy.net/roundup/ipython/issue34, which also allows me
559 to remove the previous try/except solution (which was costlier).
569 to remove the previous try/except solution (which was costlier).
560 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
570 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
561
571
562 2005-06-08 Fernando Perez <fperez@colorado.edu>
572 2005-06-08 Fernando Perez <fperez@colorado.edu>
563
573
564 * IPython/iplib.py (write/write_err): Add methods to abstract all
574 * IPython/iplib.py (write/write_err): Add methods to abstract all
565 I/O a bit more.
575 I/O a bit more.
566
576
567 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
577 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
568 warning, reported by Aric Hagberg, fix by JD Hunter.
578 warning, reported by Aric Hagberg, fix by JD Hunter.
569
579
570 2005-06-02 *** Released version 0.6.15
580 2005-06-02 *** Released version 0.6.15
571
581
572 2005-06-01 Fernando Perez <fperez@colorado.edu>
582 2005-06-01 Fernando Perez <fperez@colorado.edu>
573
583
574 * IPython/iplib.py (MagicCompleter.file_matches): Fix
584 * IPython/iplib.py (MagicCompleter.file_matches): Fix
575 tab-completion of filenames within open-quoted strings. Note that
585 tab-completion of filenames within open-quoted strings. Note that
576 this requires that in ~/.ipython/ipythonrc, users change the
586 this requires that in ~/.ipython/ipythonrc, users change the
577 readline delimiters configuration to read:
587 readline delimiters configuration to read:
578
588
579 readline_remove_delims -/~
589 readline_remove_delims -/~
580
590
581
591
582 2005-05-31 *** Released version 0.6.14
592 2005-05-31 *** Released version 0.6.14
583
593
584 2005-05-29 Fernando Perez <fperez@colorado.edu>
594 2005-05-29 Fernando Perez <fperez@colorado.edu>
585
595
586 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
596 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
587 with files not on the filesystem. Reported by Eliyahu Sandler
597 with files not on the filesystem. Reported by Eliyahu Sandler
588 <eli@gondolin.net>
598 <eli@gondolin.net>
589
599
590 2005-05-22 Fernando Perez <fperez@colorado.edu>
600 2005-05-22 Fernando Perez <fperez@colorado.edu>
591
601
592 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
602 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
593 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
603 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
594
604
595 2005-05-19 Fernando Perez <fperez@colorado.edu>
605 2005-05-19 Fernando Perez <fperez@colorado.edu>
596
606
597 * IPython/iplib.py (safe_execfile): close a file which could be
607 * IPython/iplib.py (safe_execfile): close a file which could be
598 left open (causing problems in win32, which locks open files).
608 left open (causing problems in win32, which locks open files).
599 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
609 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
600
610
601 2005-05-18 Fernando Perez <fperez@colorado.edu>
611 2005-05-18 Fernando Perez <fperez@colorado.edu>
602
612
603 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
613 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
604 keyword arguments correctly to safe_execfile().
614 keyword arguments correctly to safe_execfile().
605
615
606 2005-05-13 Fernando Perez <fperez@colorado.edu>
616 2005-05-13 Fernando Perez <fperez@colorado.edu>
607
617
608 * ipython.1: Added info about Qt to manpage, and threads warning
618 * ipython.1: Added info about Qt to manpage, and threads warning
609 to usage page (invoked with --help).
619 to usage page (invoked with --help).
610
620
611 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
621 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
612 new matcher (it goes at the end of the priority list) to do
622 new matcher (it goes at the end of the priority list) to do
613 tab-completion on named function arguments. Submitted by George
623 tab-completion on named function arguments. Submitted by George
614 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
624 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
615 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
625 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
616 for more details.
626 for more details.
617
627
618 * IPython/Magic.py (magic_run): Added new -e flag to ignore
628 * IPython/Magic.py (magic_run): Added new -e flag to ignore
619 SystemExit exceptions in the script being run. Thanks to a report
629 SystemExit exceptions in the script being run. Thanks to a report
620 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
630 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
621 producing very annoying behavior when running unit tests.
631 producing very annoying behavior when running unit tests.
622
632
623 2005-05-12 Fernando Perez <fperez@colorado.edu>
633 2005-05-12 Fernando Perez <fperez@colorado.edu>
624
634
625 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
635 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
626 which I'd broken (again) due to a changed regexp. In the process,
636 which I'd broken (again) due to a changed regexp. In the process,
627 added ';' as an escape to auto-quote the whole line without
637 added ';' as an escape to auto-quote the whole line without
628 splitting its arguments. Thanks to a report by Jerry McRae
638 splitting its arguments. Thanks to a report by Jerry McRae
629 <qrs0xyc02-AT-sneakemail.com>.
639 <qrs0xyc02-AT-sneakemail.com>.
630
640
631 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
641 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
632 possible crashes caused by a TokenError. Reported by Ed Schofield
642 possible crashes caused by a TokenError. Reported by Ed Schofield
633 <schofield-AT-ftw.at>.
643 <schofield-AT-ftw.at>.
634
644
635 2005-05-06 Fernando Perez <fperez@colorado.edu>
645 2005-05-06 Fernando Perez <fperez@colorado.edu>
636
646
637 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
647 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
638
648
639 2005-04-29 Fernando Perez <fperez@colorado.edu>
649 2005-04-29 Fernando Perez <fperez@colorado.edu>
640
650
641 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
651 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
642 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
652 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
643 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
653 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
644 which provides support for Qt interactive usage (similar to the
654 which provides support for Qt interactive usage (similar to the
645 existing one for WX and GTK). This had been often requested.
655 existing one for WX and GTK). This had been often requested.
646
656
647 2005-04-14 *** Released version 0.6.13
657 2005-04-14 *** Released version 0.6.13
648
658
649 2005-04-08 Fernando Perez <fperez@colorado.edu>
659 2005-04-08 Fernando Perez <fperez@colorado.edu>
650
660
651 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
661 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
652 from _ofind, which gets called on almost every input line. Now,
662 from _ofind, which gets called on almost every input line. Now,
653 we only try to get docstrings if they are actually going to be
663 we only try to get docstrings if they are actually going to be
654 used (the overhead of fetching unnecessary docstrings can be
664 used (the overhead of fetching unnecessary docstrings can be
655 noticeable for certain objects, such as Pyro proxies).
665 noticeable for certain objects, such as Pyro proxies).
656
666
657 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
667 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
658 for completers. For some reason I had been passing them the state
668 for completers. For some reason I had been passing them the state
659 variable, which completers never actually need, and was in
669 variable, which completers never actually need, and was in
660 conflict with the rlcompleter API. Custom completers ONLY need to
670 conflict with the rlcompleter API. Custom completers ONLY need to
661 take the text parameter.
671 take the text parameter.
662
672
663 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
673 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
664 work correctly in pysh. I've also moved all the logic which used
674 work correctly in pysh. I've also moved all the logic which used
665 to be in pysh.py here, which will prevent problems with future
675 to be in pysh.py here, which will prevent problems with future
666 upgrades. However, this time I must warn users to update their
676 upgrades. However, this time I must warn users to update their
667 pysh profile to include the line
677 pysh profile to include the line
668
678
669 import_all IPython.Extensions.InterpreterExec
679 import_all IPython.Extensions.InterpreterExec
670
680
671 because otherwise things won't work for them. They MUST also
681 because otherwise things won't work for them. They MUST also
672 delete pysh.py and the line
682 delete pysh.py and the line
673
683
674 execfile pysh.py
684 execfile pysh.py
675
685
676 from their ipythonrc-pysh.
686 from their ipythonrc-pysh.
677
687
678 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
688 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
679 robust in the face of objects whose dir() returns non-strings
689 robust in the face of objects whose dir() returns non-strings
680 (which it shouldn't, but some broken libs like ITK do). Thanks to
690 (which it shouldn't, but some broken libs like ITK do). Thanks to
681 a patch by John Hunter (implemented differently, though). Also
691 a patch by John Hunter (implemented differently, though). Also
682 minor improvements by using .extend instead of + on lists.
692 minor improvements by using .extend instead of + on lists.
683
693
684 * pysh.py:
694 * pysh.py:
685
695
686 2005-04-06 Fernando Perez <fperez@colorado.edu>
696 2005-04-06 Fernando Perez <fperez@colorado.edu>
687
697
688 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
698 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
689 by default, so that all users benefit from it. Those who don't
699 by default, so that all users benefit from it. Those who don't
690 want it can still turn it off.
700 want it can still turn it off.
691
701
692 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
702 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
693 config file, I'd forgotten about this, so users were getting it
703 config file, I'd forgotten about this, so users were getting it
694 off by default.
704 off by default.
695
705
696 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
706 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
697 consistency. Now magics can be called in multiline statements,
707 consistency. Now magics can be called in multiline statements,
698 and python variables can be expanded in magic calls via $var.
708 and python variables can be expanded in magic calls via $var.
699 This makes the magic system behave just like aliases or !system
709 This makes the magic system behave just like aliases or !system
700 calls.
710 calls.
701
711
702 2005-03-28 Fernando Perez <fperez@colorado.edu>
712 2005-03-28 Fernando Perez <fperez@colorado.edu>
703
713
704 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
714 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
705 expensive string additions for building command. Add support for
715 expensive string additions for building command. Add support for
706 trailing ';' when autocall is used.
716 trailing ';' when autocall is used.
707
717
708 2005-03-26 Fernando Perez <fperez@colorado.edu>
718 2005-03-26 Fernando Perez <fperez@colorado.edu>
709
719
710 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
720 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
711 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
721 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
712 ipython.el robust against prompts with any number of spaces
722 ipython.el robust against prompts with any number of spaces
713 (including 0) after the ':' character.
723 (including 0) after the ':' character.
714
724
715 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
725 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
716 continuation prompt, which misled users to think the line was
726 continuation prompt, which misled users to think the line was
717 already indented. Closes debian Bug#300847, reported to me by
727 already indented. Closes debian Bug#300847, reported to me by
718 Norbert Tretkowski <tretkowski-AT-inittab.de>.
728 Norbert Tretkowski <tretkowski-AT-inittab.de>.
719
729
720 2005-03-23 Fernando Perez <fperez@colorado.edu>
730 2005-03-23 Fernando Perez <fperez@colorado.edu>
721
731
722 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
732 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
723 properly aligned if they have embedded newlines.
733 properly aligned if they have embedded newlines.
724
734
725 * IPython/iplib.py (runlines): Add a public method to expose
735 * IPython/iplib.py (runlines): Add a public method to expose
726 IPython's code execution machinery, so that users can run strings
736 IPython's code execution machinery, so that users can run strings
727 as if they had been typed at the prompt interactively.
737 as if they had been typed at the prompt interactively.
728 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
738 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
729 methods which can call the system shell, but with python variable
739 methods which can call the system shell, but with python variable
730 expansion. The three such methods are: __IPYTHON__.system,
740 expansion. The three such methods are: __IPYTHON__.system,
731 .getoutput and .getoutputerror. These need to be documented in a
741 .getoutput and .getoutputerror. These need to be documented in a
732 'public API' section (to be written) of the manual.
742 'public API' section (to be written) of the manual.
733
743
734 2005-03-20 Fernando Perez <fperez@colorado.edu>
744 2005-03-20 Fernando Perez <fperez@colorado.edu>
735
745
736 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
746 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
737 for custom exception handling. This is quite powerful, and it
747 for custom exception handling. This is quite powerful, and it
738 allows for user-installable exception handlers which can trap
748 allows for user-installable exception handlers which can trap
739 custom exceptions at runtime and treat them separately from
749 custom exceptions at runtime and treat them separately from
740 IPython's default mechanisms. At the request of Frédéric
750 IPython's default mechanisms. At the request of Frédéric
741 Mantegazza <mantegazza-AT-ill.fr>.
751 Mantegazza <mantegazza-AT-ill.fr>.
742 (InteractiveShell.set_custom_completer): public API function to
752 (InteractiveShell.set_custom_completer): public API function to
743 add new completers at runtime.
753 add new completers at runtime.
744
754
745 2005-03-19 Fernando Perez <fperez@colorado.edu>
755 2005-03-19 Fernando Perez <fperez@colorado.edu>
746
756
747 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
757 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
748 allow objects which provide their docstrings via non-standard
758 allow objects which provide their docstrings via non-standard
749 mechanisms (like Pyro proxies) to still be inspected by ipython's
759 mechanisms (like Pyro proxies) to still be inspected by ipython's
750 ? system.
760 ? system.
751
761
752 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
762 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
753 automatic capture system. I tried quite hard to make it work
763 automatic capture system. I tried quite hard to make it work
754 reliably, and simply failed. I tried many combinations with the
764 reliably, and simply failed. I tried many combinations with the
755 subprocess module, but eventually nothing worked in all needed
765 subprocess module, but eventually nothing worked in all needed
756 cases (not blocking stdin for the child, duplicating stdout
766 cases (not blocking stdin for the child, duplicating stdout
757 without blocking, etc). The new %sc/%sx still do capture to these
767 without blocking, etc). The new %sc/%sx still do capture to these
758 magical list/string objects which make shell use much more
768 magical list/string objects which make shell use much more
759 conveninent, so not all is lost.
769 conveninent, so not all is lost.
760
770
761 XXX - FIX MANUAL for the change above!
771 XXX - FIX MANUAL for the change above!
762
772
763 (runsource): I copied code.py's runsource() into ipython to modify
773 (runsource): I copied code.py's runsource() into ipython to modify
764 it a bit. Now the code object and source to be executed are
774 it a bit. Now the code object and source to be executed are
765 stored in ipython. This makes this info accessible to third-party
775 stored in ipython. This makes this info accessible to third-party
766 tools, like custom exception handlers. After a request by Frédéric
776 tools, like custom exception handlers. After a request by Frédéric
767 Mantegazza <mantegazza-AT-ill.fr>.
777 Mantegazza <mantegazza-AT-ill.fr>.
768
778
769 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
779 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
770 history-search via readline (like C-p/C-n). I'd wanted this for a
780 history-search via readline (like C-p/C-n). I'd wanted this for a
771 long time, but only recently found out how to do it. For users
781 long time, but only recently found out how to do it. For users
772 who already have their ipythonrc files made and want this, just
782 who already have their ipythonrc files made and want this, just
773 add:
783 add:
774
784
775 readline_parse_and_bind "\e[A": history-search-backward
785 readline_parse_and_bind "\e[A": history-search-backward
776 readline_parse_and_bind "\e[B": history-search-forward
786 readline_parse_and_bind "\e[B": history-search-forward
777
787
778 2005-03-18 Fernando Perez <fperez@colorado.edu>
788 2005-03-18 Fernando Perez <fperez@colorado.edu>
779
789
780 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
790 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
781 LSString and SList classes which allow transparent conversions
791 LSString and SList classes which allow transparent conversions
782 between list mode and whitespace-separated string.
792 between list mode and whitespace-separated string.
783 (magic_r): Fix recursion problem in %r.
793 (magic_r): Fix recursion problem in %r.
784
794
785 * IPython/genutils.py (LSString): New class to be used for
795 * IPython/genutils.py (LSString): New class to be used for
786 automatic storage of the results of all alias/system calls in _o
796 automatic storage of the results of all alias/system calls in _o
787 and _e (stdout/err). These provide a .l/.list attribute which
797 and _e (stdout/err). These provide a .l/.list attribute which
788 does automatic splitting on newlines. This means that for most
798 does automatic splitting on newlines. This means that for most
789 uses, you'll never need to do capturing of output with %sc/%sx
799 uses, you'll never need to do capturing of output with %sc/%sx
790 anymore, since ipython keeps this always done for you. Note that
800 anymore, since ipython keeps this always done for you. Note that
791 only the LAST results are stored, the _o/e variables are
801 only the LAST results are stored, the _o/e variables are
792 overwritten on each call. If you need to save their contents
802 overwritten on each call. If you need to save their contents
793 further, simply bind them to any other name.
803 further, simply bind them to any other name.
794
804
795 2005-03-17 Fernando Perez <fperez@colorado.edu>
805 2005-03-17 Fernando Perez <fperez@colorado.edu>
796
806
797 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
807 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
798 prompt namespace handling.
808 prompt namespace handling.
799
809
800 2005-03-16 Fernando Perez <fperez@colorado.edu>
810 2005-03-16 Fernando Perez <fperez@colorado.edu>
801
811
802 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
812 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
803 classic prompts to be '>>> ' (final space was missing, and it
813 classic prompts to be '>>> ' (final space was missing, and it
804 trips the emacs python mode).
814 trips the emacs python mode).
805 (BasePrompt.__str__): Added safe support for dynamic prompt
815 (BasePrompt.__str__): Added safe support for dynamic prompt
806 strings. Now you can set your prompt string to be '$x', and the
816 strings. Now you can set your prompt string to be '$x', and the
807 value of x will be printed from your interactive namespace. The
817 value of x will be printed from your interactive namespace. The
808 interpolation syntax includes the full Itpl support, so
818 interpolation syntax includes the full Itpl support, so
809 ${foo()+x+bar()} is a valid prompt string now, and the function
819 ${foo()+x+bar()} is a valid prompt string now, and the function
810 calls will be made at runtime.
820 calls will be made at runtime.
811
821
812 2005-03-15 Fernando Perez <fperez@colorado.edu>
822 2005-03-15 Fernando Perez <fperez@colorado.edu>
813
823
814 * IPython/Magic.py (magic_history): renamed %hist to %history, to
824 * IPython/Magic.py (magic_history): renamed %hist to %history, to
815 avoid name clashes in pylab. %hist still works, it just forwards
825 avoid name clashes in pylab. %hist still works, it just forwards
816 the call to %history.
826 the call to %history.
817
827
818 2005-03-02 *** Released version 0.6.12
828 2005-03-02 *** Released version 0.6.12
819
829
820 2005-03-02 Fernando Perez <fperez@colorado.edu>
830 2005-03-02 Fernando Perez <fperez@colorado.edu>
821
831
822 * IPython/iplib.py (handle_magic): log magic calls properly as
832 * IPython/iplib.py (handle_magic): log magic calls properly as
823 ipmagic() function calls.
833 ipmagic() function calls.
824
834
825 * IPython/Magic.py (magic_time): Improved %time to support
835 * IPython/Magic.py (magic_time): Improved %time to support
826 statements and provide wall-clock as well as CPU time.
836 statements and provide wall-clock as well as CPU time.
827
837
828 2005-02-27 Fernando Perez <fperez@colorado.edu>
838 2005-02-27 Fernando Perez <fperez@colorado.edu>
829
839
830 * IPython/hooks.py: New hooks module, to expose user-modifiable
840 * IPython/hooks.py: New hooks module, to expose user-modifiable
831 IPython functionality in a clean manner. For now only the editor
841 IPython functionality in a clean manner. For now only the editor
832 hook is actually written, and other thigns which I intend to turn
842 hook is actually written, and other thigns which I intend to turn
833 into proper hooks aren't yet there. The display and prefilter
843 into proper hooks aren't yet there. The display and prefilter
834 stuff, for example, should be hooks. But at least now the
844 stuff, for example, should be hooks. But at least now the
835 framework is in place, and the rest can be moved here with more
845 framework is in place, and the rest can be moved here with more
836 time later. IPython had had a .hooks variable for a long time for
846 time later. IPython had had a .hooks variable for a long time for
837 this purpose, but I'd never actually used it for anything.
847 this purpose, but I'd never actually used it for anything.
838
848
839 2005-02-26 Fernando Perez <fperez@colorado.edu>
849 2005-02-26 Fernando Perez <fperez@colorado.edu>
840
850
841 * IPython/ipmaker.py (make_IPython): make the default ipython
851 * IPython/ipmaker.py (make_IPython): make the default ipython
842 directory be called _ipython under win32, to follow more the
852 directory be called _ipython under win32, to follow more the
843 naming peculiarities of that platform (where buggy software like
853 naming peculiarities of that platform (where buggy software like
844 Visual Sourcesafe breaks with .named directories). Reported by
854 Visual Sourcesafe breaks with .named directories). Reported by
845 Ville Vainio.
855 Ville Vainio.
846
856
847 2005-02-23 Fernando Perez <fperez@colorado.edu>
857 2005-02-23 Fernando Perez <fperez@colorado.edu>
848
858
849 * IPython/iplib.py (InteractiveShell.__init__): removed a few
859 * IPython/iplib.py (InteractiveShell.__init__): removed a few
850 auto_aliases for win32 which were causing problems. Users can
860 auto_aliases for win32 which were causing problems. Users can
851 define the ones they personally like.
861 define the ones they personally like.
852
862
853 2005-02-21 Fernando Perez <fperez@colorado.edu>
863 2005-02-21 Fernando Perez <fperez@colorado.edu>
854
864
855 * IPython/Magic.py (magic_time): new magic to time execution of
865 * IPython/Magic.py (magic_time): new magic to time execution of
856 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
866 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
857
867
858 2005-02-19 Fernando Perez <fperez@colorado.edu>
868 2005-02-19 Fernando Perez <fperez@colorado.edu>
859
869
860 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
870 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
861 into keys (for prompts, for example).
871 into keys (for prompts, for example).
862
872
863 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
873 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
864 prompts in case users want them. This introduces a small behavior
874 prompts in case users want them. This introduces a small behavior
865 change: ipython does not automatically add a space to all prompts
875 change: ipython does not automatically add a space to all prompts
866 anymore. To get the old prompts with a space, users should add it
876 anymore. To get the old prompts with a space, users should add it
867 manually to their ipythonrc file, so for example prompt_in1 should
877 manually to their ipythonrc file, so for example prompt_in1 should
868 now read 'In [\#]: ' instead of 'In [\#]:'.
878 now read 'In [\#]: ' instead of 'In [\#]:'.
869 (BasePrompt.__init__): New option prompts_pad_left (only in rc
879 (BasePrompt.__init__): New option prompts_pad_left (only in rc
870 file) to control left-padding of secondary prompts.
880 file) to control left-padding of secondary prompts.
871
881
872 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
882 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
873 the profiler can't be imported. Fix for Debian, which removed
883 the profiler can't be imported. Fix for Debian, which removed
874 profile.py because of License issues. I applied a slightly
884 profile.py because of License issues. I applied a slightly
875 modified version of the original Debian patch at
885 modified version of the original Debian patch at
876 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
886 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
877
887
878 2005-02-17 Fernando Perez <fperez@colorado.edu>
888 2005-02-17 Fernando Perez <fperez@colorado.edu>
879
889
880 * IPython/genutils.py (native_line_ends): Fix bug which would
890 * IPython/genutils.py (native_line_ends): Fix bug which would
881 cause improper line-ends under win32 b/c I was not opening files
891 cause improper line-ends under win32 b/c I was not opening files
882 in binary mode. Bug report and fix thanks to Ville.
892 in binary mode. Bug report and fix thanks to Ville.
883
893
884 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
894 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
885 trying to catch spurious foo[1] autocalls. My fix actually broke
895 trying to catch spurious foo[1] autocalls. My fix actually broke
886 ',/' autoquote/call with explicit escape (bad regexp).
896 ',/' autoquote/call with explicit escape (bad regexp).
887
897
888 2005-02-15 *** Released version 0.6.11
898 2005-02-15 *** Released version 0.6.11
889
899
890 2005-02-14 Fernando Perez <fperez@colorado.edu>
900 2005-02-14 Fernando Perez <fperez@colorado.edu>
891
901
892 * IPython/background_jobs.py: New background job management
902 * IPython/background_jobs.py: New background job management
893 subsystem. This is implemented via a new set of classes, and
903 subsystem. This is implemented via a new set of classes, and
894 IPython now provides a builtin 'jobs' object for background job
904 IPython now provides a builtin 'jobs' object for background job
895 execution. A convenience %bg magic serves as a lightweight
905 execution. A convenience %bg magic serves as a lightweight
896 frontend for starting the more common type of calls. This was
906 frontend for starting the more common type of calls. This was
897 inspired by discussions with B. Granger and the BackgroundCommand
907 inspired by discussions with B. Granger and the BackgroundCommand
898 class described in the book Python Scripting for Computational
908 class described in the book Python Scripting for Computational
899 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
909 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
900 (although ultimately no code from this text was used, as IPython's
910 (although ultimately no code from this text was used, as IPython's
901 system is a separate implementation).
911 system is a separate implementation).
902
912
903 * IPython/iplib.py (MagicCompleter.python_matches): add new option
913 * IPython/iplib.py (MagicCompleter.python_matches): add new option
904 to control the completion of single/double underscore names
914 to control the completion of single/double underscore names
905 separately. As documented in the example ipytonrc file, the
915 separately. As documented in the example ipytonrc file, the
906 readline_omit__names variable can now be set to 2, to omit even
916 readline_omit__names variable can now be set to 2, to omit even
907 single underscore names. Thanks to a patch by Brian Wong
917 single underscore names. Thanks to a patch by Brian Wong
908 <BrianWong-AT-AirgoNetworks.Com>.
918 <BrianWong-AT-AirgoNetworks.Com>.
909 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
919 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
910 be autocalled as foo([1]) if foo were callable. A problem for
920 be autocalled as foo([1]) if foo were callable. A problem for
911 things which are both callable and implement __getitem__.
921 things which are both callable and implement __getitem__.
912 (init_readline): Fix autoindentation for win32. Thanks to a patch
922 (init_readline): Fix autoindentation for win32. Thanks to a patch
913 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
923 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
914
924
915 2005-02-12 Fernando Perez <fperez@colorado.edu>
925 2005-02-12 Fernando Perez <fperez@colorado.edu>
916
926
917 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
927 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
918 which I had written long ago to sort out user error messages which
928 which I had written long ago to sort out user error messages which
919 may occur during startup. This seemed like a good idea initially,
929 may occur during startup. This seemed like a good idea initially,
920 but it has proven a disaster in retrospect. I don't want to
930 but it has proven a disaster in retrospect. I don't want to
921 change much code for now, so my fix is to set the internal 'debug'
931 change much code for now, so my fix is to set the internal 'debug'
922 flag to true everywhere, whose only job was precisely to control
932 flag to true everywhere, whose only job was precisely to control
923 this subsystem. This closes issue 28 (as well as avoiding all
933 this subsystem. This closes issue 28 (as well as avoiding all
924 sorts of strange hangups which occur from time to time).
934 sorts of strange hangups which occur from time to time).
925
935
926 2005-02-07 Fernando Perez <fperez@colorado.edu>
936 2005-02-07 Fernando Perez <fperez@colorado.edu>
927
937
928 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
938 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
929 previous call produced a syntax error.
939 previous call produced a syntax error.
930
940
931 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
941 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
932 classes without constructor.
942 classes without constructor.
933
943
934 2005-02-06 Fernando Perez <fperez@colorado.edu>
944 2005-02-06 Fernando Perez <fperez@colorado.edu>
935
945
936 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
946 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
937 completions with the results of each matcher, so we return results
947 completions with the results of each matcher, so we return results
938 to the user from all namespaces. This breaks with ipython
948 to the user from all namespaces. This breaks with ipython
939 tradition, but I think it's a nicer behavior. Now you get all
949 tradition, but I think it's a nicer behavior. Now you get all
940 possible completions listed, from all possible namespaces (python,
950 possible completions listed, from all possible namespaces (python,
941 filesystem, magics...) After a request by John Hunter
951 filesystem, magics...) After a request by John Hunter
942 <jdhunter-AT-nitace.bsd.uchicago.edu>.
952 <jdhunter-AT-nitace.bsd.uchicago.edu>.
943
953
944 2005-02-05 Fernando Perez <fperez@colorado.edu>
954 2005-02-05 Fernando Perez <fperez@colorado.edu>
945
955
946 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
956 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
947 the call had quote characters in it (the quotes were stripped).
957 the call had quote characters in it (the quotes were stripped).
948
958
949 2005-01-31 Fernando Perez <fperez@colorado.edu>
959 2005-01-31 Fernando Perez <fperez@colorado.edu>
950
960
951 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
961 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
952 Itpl.itpl() to make the code more robust against psyco
962 Itpl.itpl() to make the code more robust against psyco
953 optimizations.
963 optimizations.
954
964
955 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
965 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
956 of causing an exception. Quicker, cleaner.
966 of causing an exception. Quicker, cleaner.
957
967
958 2005-01-28 Fernando Perez <fperez@colorado.edu>
968 2005-01-28 Fernando Perez <fperez@colorado.edu>
959
969
960 * scripts/ipython_win_post_install.py (install): hardcode
970 * scripts/ipython_win_post_install.py (install): hardcode
961 sys.prefix+'python.exe' as the executable path. It turns out that
971 sys.prefix+'python.exe' as the executable path. It turns out that
962 during the post-installation run, sys.executable resolves to the
972 during the post-installation run, sys.executable resolves to the
963 name of the binary installer! I should report this as a distutils
973 name of the binary installer! I should report this as a distutils
964 bug, I think. I updated the .10 release with this tiny fix, to
974 bug, I think. I updated the .10 release with this tiny fix, to
965 avoid annoying the lists further.
975 avoid annoying the lists further.
966
976
967 2005-01-27 *** Released version 0.6.10
977 2005-01-27 *** Released version 0.6.10
968
978
969 2005-01-27 Fernando Perez <fperez@colorado.edu>
979 2005-01-27 Fernando Perez <fperez@colorado.edu>
970
980
971 * IPython/numutils.py (norm): Added 'inf' as optional name for
981 * IPython/numutils.py (norm): Added 'inf' as optional name for
972 L-infinity norm, included references to mathworld.com for vector
982 L-infinity norm, included references to mathworld.com for vector
973 norm definitions.
983 norm definitions.
974 (amin/amax): added amin/amax for array min/max. Similar to what
984 (amin/amax): added amin/amax for array min/max. Similar to what
975 pylab ships with after the recent reorganization of names.
985 pylab ships with after the recent reorganization of names.
976 (spike/spike_odd): removed deprecated spike/spike_odd functions.
986 (spike/spike_odd): removed deprecated spike/spike_odd functions.
977
987
978 * ipython.el: committed Alex's recent fixes and improvements.
988 * ipython.el: committed Alex's recent fixes and improvements.
979 Tested with python-mode from CVS, and it looks excellent. Since
989 Tested with python-mode from CVS, and it looks excellent. Since
980 python-mode hasn't released anything in a while, I'm temporarily
990 python-mode hasn't released anything in a while, I'm temporarily
981 putting a copy of today's CVS (v 4.70) of python-mode in:
991 putting a copy of today's CVS (v 4.70) of python-mode in:
982 http://ipython.scipy.org/tmp/python-mode.el
992 http://ipython.scipy.org/tmp/python-mode.el
983
993
984 * scripts/ipython_win_post_install.py (install): Win32 fix to use
994 * scripts/ipython_win_post_install.py (install): Win32 fix to use
985 sys.executable for the executable name, instead of assuming it's
995 sys.executable for the executable name, instead of assuming it's
986 called 'python.exe' (the post-installer would have produced broken
996 called 'python.exe' (the post-installer would have produced broken
987 setups on systems with a differently named python binary).
997 setups on systems with a differently named python binary).
988
998
989 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
999 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
990 references to os.linesep, to make the code more
1000 references to os.linesep, to make the code more
991 platform-independent. This is also part of the win32 coloring
1001 platform-independent. This is also part of the win32 coloring
992 fixes.
1002 fixes.
993
1003
994 * IPython/genutils.py (page_dumb): Remove attempts to chop long
1004 * IPython/genutils.py (page_dumb): Remove attempts to chop long
995 lines, which actually cause coloring bugs because the length of
1005 lines, which actually cause coloring bugs because the length of
996 the line is very difficult to correctly compute with embedded
1006 the line is very difficult to correctly compute with embedded
997 escapes. This was the source of all the coloring problems under
1007 escapes. This was the source of all the coloring problems under
998 Win32. I think that _finally_, Win32 users have a properly
1008 Win32. I think that _finally_, Win32 users have a properly
999 working ipython in all respects. This would never have happened
1009 working ipython in all respects. This would never have happened
1000 if not for Gary Bishop and Viktor Ransmayr's great help and work.
1010 if not for Gary Bishop and Viktor Ransmayr's great help and work.
1001
1011
1002 2005-01-26 *** Released version 0.6.9
1012 2005-01-26 *** Released version 0.6.9
1003
1013
1004 2005-01-25 Fernando Perez <fperez@colorado.edu>
1014 2005-01-25 Fernando Perez <fperez@colorado.edu>
1005
1015
1006 * setup.py: finally, we have a true Windows installer, thanks to
1016 * setup.py: finally, we have a true Windows installer, thanks to
1007 the excellent work of Viktor Ransmayr
1017 the excellent work of Viktor Ransmayr
1008 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
1018 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
1009 Windows users. The setup routine is quite a bit cleaner thanks to
1019 Windows users. The setup routine is quite a bit cleaner thanks to
1010 this, and the post-install script uses the proper functions to
1020 this, and the post-install script uses the proper functions to
1011 allow a clean de-installation using the standard Windows Control
1021 allow a clean de-installation using the standard Windows Control
1012 Panel.
1022 Panel.
1013
1023
1014 * IPython/genutils.py (get_home_dir): changed to use the $HOME
1024 * IPython/genutils.py (get_home_dir): changed to use the $HOME
1015 environment variable under all OSes (including win32) if
1025 environment variable under all OSes (including win32) if
1016 available. This will give consistency to win32 users who have set
1026 available. This will give consistency to win32 users who have set
1017 this variable for any reason. If os.environ['HOME'] fails, the
1027 this variable for any reason. If os.environ['HOME'] fails, the
1018 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
1028 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
1019
1029
1020 2005-01-24 Fernando Perez <fperez@colorado.edu>
1030 2005-01-24 Fernando Perez <fperez@colorado.edu>
1021
1031
1022 * IPython/numutils.py (empty_like): add empty_like(), similar to
1032 * IPython/numutils.py (empty_like): add empty_like(), similar to
1023 zeros_like() but taking advantage of the new empty() Numeric routine.
1033 zeros_like() but taking advantage of the new empty() Numeric routine.
1024
1034
1025 2005-01-23 *** Released version 0.6.8
1035 2005-01-23 *** Released version 0.6.8
1026
1036
1027 2005-01-22 Fernando Perez <fperez@colorado.edu>
1037 2005-01-22 Fernando Perez <fperez@colorado.edu>
1028
1038
1029 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
1039 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
1030 automatic show() calls. After discussing things with JDH, it
1040 automatic show() calls. After discussing things with JDH, it
1031 turns out there are too many corner cases where this can go wrong.
1041 turns out there are too many corner cases where this can go wrong.
1032 It's best not to try to be 'too smart', and simply have ipython
1042 It's best not to try to be 'too smart', and simply have ipython
1033 reproduce as much as possible the default behavior of a normal
1043 reproduce as much as possible the default behavior of a normal
1034 python shell.
1044 python shell.
1035
1045
1036 * IPython/iplib.py (InteractiveShell.__init__): Modified the
1046 * IPython/iplib.py (InteractiveShell.__init__): Modified the
1037 line-splitting regexp and _prefilter() to avoid calling getattr()
1047 line-splitting regexp and _prefilter() to avoid calling getattr()
1038 on assignments. This closes
1048 on assignments. This closes
1039 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
1049 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
1040 readline uses getattr(), so a simple <TAB> keypress is still
1050 readline uses getattr(), so a simple <TAB> keypress is still
1041 enough to trigger getattr() calls on an object.
1051 enough to trigger getattr() calls on an object.
1042
1052
1043 2005-01-21 Fernando Perez <fperez@colorado.edu>
1053 2005-01-21 Fernando Perez <fperez@colorado.edu>
1044
1054
1045 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
1055 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
1046 docstring under pylab so it doesn't mask the original.
1056 docstring under pylab so it doesn't mask the original.
1047
1057
1048 2005-01-21 *** Released version 0.6.7
1058 2005-01-21 *** Released version 0.6.7
1049
1059
1050 2005-01-21 Fernando Perez <fperez@colorado.edu>
1060 2005-01-21 Fernando Perez <fperez@colorado.edu>
1051
1061
1052 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
1062 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
1053 signal handling for win32 users in multithreaded mode.
1063 signal handling for win32 users in multithreaded mode.
1054
1064
1055 2005-01-17 Fernando Perez <fperez@colorado.edu>
1065 2005-01-17 Fernando Perez <fperez@colorado.edu>
1056
1066
1057 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1067 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1058 instances with no __init__. After a crash report by Norbert Nemec
1068 instances with no __init__. After a crash report by Norbert Nemec
1059 <Norbert-AT-nemec-online.de>.
1069 <Norbert-AT-nemec-online.de>.
1060
1070
1061 2005-01-14 Fernando Perez <fperez@colorado.edu>
1071 2005-01-14 Fernando Perez <fperez@colorado.edu>
1062
1072
1063 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
1073 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
1064 names for verbose exceptions, when multiple dotted names and the
1074 names for verbose exceptions, when multiple dotted names and the
1065 'parent' object were present on the same line.
1075 'parent' object were present on the same line.
1066
1076
1067 2005-01-11 Fernando Perez <fperez@colorado.edu>
1077 2005-01-11 Fernando Perez <fperez@colorado.edu>
1068
1078
1069 * IPython/genutils.py (flag_calls): new utility to trap and flag
1079 * IPython/genutils.py (flag_calls): new utility to trap and flag
1070 calls in functions. I need it to clean up matplotlib support.
1080 calls in functions. I need it to clean up matplotlib support.
1071 Also removed some deprecated code in genutils.
1081 Also removed some deprecated code in genutils.
1072
1082
1073 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
1083 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
1074 that matplotlib scripts called with %run, which don't call show()
1084 that matplotlib scripts called with %run, which don't call show()
1075 themselves, still have their plotting windows open.
1085 themselves, still have their plotting windows open.
1076
1086
1077 2005-01-05 Fernando Perez <fperez@colorado.edu>
1087 2005-01-05 Fernando Perez <fperez@colorado.edu>
1078
1088
1079 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
1089 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
1080 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
1090 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
1081
1091
1082 2004-12-19 Fernando Perez <fperez@colorado.edu>
1092 2004-12-19 Fernando Perez <fperez@colorado.edu>
1083
1093
1084 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
1094 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
1085 parent_runcode, which was an eyesore. The same result can be
1095 parent_runcode, which was an eyesore. The same result can be
1086 obtained with Python's regular superclass mechanisms.
1096 obtained with Python's regular superclass mechanisms.
1087
1097
1088 2004-12-17 Fernando Perez <fperez@colorado.edu>
1098 2004-12-17 Fernando Perez <fperez@colorado.edu>
1089
1099
1090 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
1100 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
1091 reported by Prabhu.
1101 reported by Prabhu.
1092 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
1102 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
1093 sys.stderr) instead of explicitly calling sys.stderr. This helps
1103 sys.stderr) instead of explicitly calling sys.stderr. This helps
1094 maintain our I/O abstractions clean, for future GUI embeddings.
1104 maintain our I/O abstractions clean, for future GUI embeddings.
1095
1105
1096 * IPython/genutils.py (info): added new utility for sys.stderr
1106 * IPython/genutils.py (info): added new utility for sys.stderr
1097 unified info message handling (thin wrapper around warn()).
1107 unified info message handling (thin wrapper around warn()).
1098
1108
1099 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
1109 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
1100 composite (dotted) names on verbose exceptions.
1110 composite (dotted) names on verbose exceptions.
1101 (VerboseTB.nullrepr): harden against another kind of errors which
1111 (VerboseTB.nullrepr): harden against another kind of errors which
1102 Python's inspect module can trigger, and which were crashing
1112 Python's inspect module can trigger, and which were crashing
1103 IPython. Thanks to a report by Marco Lombardi
1113 IPython. Thanks to a report by Marco Lombardi
1104 <mlombard-AT-ma010192.hq.eso.org>.
1114 <mlombard-AT-ma010192.hq.eso.org>.
1105
1115
1106 2004-12-13 *** Released version 0.6.6
1116 2004-12-13 *** Released version 0.6.6
1107
1117
1108 2004-12-12 Fernando Perez <fperez@colorado.edu>
1118 2004-12-12 Fernando Perez <fperez@colorado.edu>
1109
1119
1110 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
1120 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
1111 generated by pygtk upon initialization if it was built without
1121 generated by pygtk upon initialization if it was built without
1112 threads (for matplotlib users). After a crash reported by
1122 threads (for matplotlib users). After a crash reported by
1113 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
1123 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
1114
1124
1115 * IPython/ipmaker.py (make_IPython): fix small bug in the
1125 * IPython/ipmaker.py (make_IPython): fix small bug in the
1116 import_some parameter for multiple imports.
1126 import_some parameter for multiple imports.
1117
1127
1118 * IPython/iplib.py (ipmagic): simplified the interface of
1128 * IPython/iplib.py (ipmagic): simplified the interface of
1119 ipmagic() to take a single string argument, just as it would be
1129 ipmagic() to take a single string argument, just as it would be
1120 typed at the IPython cmd line.
1130 typed at the IPython cmd line.
1121 (ipalias): Added new ipalias() with an interface identical to
1131 (ipalias): Added new ipalias() with an interface identical to
1122 ipmagic(). This completes exposing a pure python interface to the
1132 ipmagic(). This completes exposing a pure python interface to the
1123 alias and magic system, which can be used in loops or more complex
1133 alias and magic system, which can be used in loops or more complex
1124 code where IPython's automatic line mangling is not active.
1134 code where IPython's automatic line mangling is not active.
1125
1135
1126 * IPython/genutils.py (timing): changed interface of timing to
1136 * IPython/genutils.py (timing): changed interface of timing to
1127 simply run code once, which is the most common case. timings()
1137 simply run code once, which is the most common case. timings()
1128 remains unchanged, for the cases where you want multiple runs.
1138 remains unchanged, for the cases where you want multiple runs.
1129
1139
1130 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
1140 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
1131 bug where Python2.2 crashes with exec'ing code which does not end
1141 bug where Python2.2 crashes with exec'ing code which does not end
1132 in a single newline. Python 2.3 is OK, so I hadn't noticed this
1142 in a single newline. Python 2.3 is OK, so I hadn't noticed this
1133 before.
1143 before.
1134
1144
1135 2004-12-10 Fernando Perez <fperez@colorado.edu>
1145 2004-12-10 Fernando Perez <fperez@colorado.edu>
1136
1146
1137 * IPython/Magic.py (Magic.magic_prun): changed name of option from
1147 * IPython/Magic.py (Magic.magic_prun): changed name of option from
1138 -t to -T, to accomodate the new -t flag in %run (the %run and
1148 -t to -T, to accomodate the new -t flag in %run (the %run and
1139 %prun options are kind of intermixed, and it's not easy to change
1149 %prun options are kind of intermixed, and it's not easy to change
1140 this with the limitations of python's getopt).
1150 this with the limitations of python's getopt).
1141
1151
1142 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
1152 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
1143 the execution of scripts. It's not as fine-tuned as timeit.py,
1153 the execution of scripts. It's not as fine-tuned as timeit.py,
1144 but it works from inside ipython (and under 2.2, which lacks
1154 but it works from inside ipython (and under 2.2, which lacks
1145 timeit.py). Optionally a number of runs > 1 can be given for
1155 timeit.py). Optionally a number of runs > 1 can be given for
1146 timing very short-running code.
1156 timing very short-running code.
1147
1157
1148 * IPython/genutils.py (uniq_stable): new routine which returns a
1158 * IPython/genutils.py (uniq_stable): new routine which returns a
1149 list of unique elements in any iterable, but in stable order of
1159 list of unique elements in any iterable, but in stable order of
1150 appearance. I needed this for the ultraTB fixes, and it's a handy
1160 appearance. I needed this for the ultraTB fixes, and it's a handy
1151 utility.
1161 utility.
1152
1162
1153 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
1163 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
1154 dotted names in Verbose exceptions. This had been broken since
1164 dotted names in Verbose exceptions. This had been broken since
1155 the very start, now x.y will properly be printed in a Verbose
1165 the very start, now x.y will properly be printed in a Verbose
1156 traceback, instead of x being shown and y appearing always as an
1166 traceback, instead of x being shown and y appearing always as an
1157 'undefined global'. Getting this to work was a bit tricky,
1167 'undefined global'. Getting this to work was a bit tricky,
1158 because by default python tokenizers are stateless. Saved by
1168 because by default python tokenizers are stateless. Saved by
1159 python's ability to easily add a bit of state to an arbitrary
1169 python's ability to easily add a bit of state to an arbitrary
1160 function (without needing to build a full-blown callable object).
1170 function (without needing to build a full-blown callable object).
1161
1171
1162 Also big cleanup of this code, which had horrendous runtime
1172 Also big cleanup of this code, which had horrendous runtime
1163 lookups of zillions of attributes for colorization. Moved all
1173 lookups of zillions of attributes for colorization. Moved all
1164 this code into a few templates, which make it cleaner and quicker.
1174 this code into a few templates, which make it cleaner and quicker.
1165
1175
1166 Printout quality was also improved for Verbose exceptions: one
1176 Printout quality was also improved for Verbose exceptions: one
1167 variable per line, and memory addresses are printed (this can be
1177 variable per line, and memory addresses are printed (this can be
1168 quite handy in nasty debugging situations, which is what Verbose
1178 quite handy in nasty debugging situations, which is what Verbose
1169 is for).
1179 is for).
1170
1180
1171 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
1181 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
1172 the command line as scripts to be loaded by embedded instances.
1182 the command line as scripts to be loaded by embedded instances.
1173 Doing so has the potential for an infinite recursion if there are
1183 Doing so has the potential for an infinite recursion if there are
1174 exceptions thrown in the process. This fixes a strange crash
1184 exceptions thrown in the process. This fixes a strange crash
1175 reported by Philippe MULLER <muller-AT-irit.fr>.
1185 reported by Philippe MULLER <muller-AT-irit.fr>.
1176
1186
1177 2004-12-09 Fernando Perez <fperez@colorado.edu>
1187 2004-12-09 Fernando Perez <fperez@colorado.edu>
1178
1188
1179 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
1189 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
1180 to reflect new names in matplotlib, which now expose the
1190 to reflect new names in matplotlib, which now expose the
1181 matlab-compatible interface via a pylab module instead of the
1191 matlab-compatible interface via a pylab module instead of the
1182 'matlab' name. The new code is backwards compatible, so users of
1192 'matlab' name. The new code is backwards compatible, so users of
1183 all matplotlib versions are OK. Patch by J. Hunter.
1193 all matplotlib versions are OK. Patch by J. Hunter.
1184
1194
1185 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
1195 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
1186 of __init__ docstrings for instances (class docstrings are already
1196 of __init__ docstrings for instances (class docstrings are already
1187 automatically printed). Instances with customized docstrings
1197 automatically printed). Instances with customized docstrings
1188 (indep. of the class) are also recognized and all 3 separate
1198 (indep. of the class) are also recognized and all 3 separate
1189 docstrings are printed (instance, class, constructor). After some
1199 docstrings are printed (instance, class, constructor). After some
1190 comments/suggestions by J. Hunter.
1200 comments/suggestions by J. Hunter.
1191
1201
1192 2004-12-05 Fernando Perez <fperez@colorado.edu>
1202 2004-12-05 Fernando Perez <fperez@colorado.edu>
1193
1203
1194 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
1204 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
1195 warnings when tab-completion fails and triggers an exception.
1205 warnings when tab-completion fails and triggers an exception.
1196
1206
1197 2004-12-03 Fernando Perez <fperez@colorado.edu>
1207 2004-12-03 Fernando Perez <fperez@colorado.edu>
1198
1208
1199 * IPython/Magic.py (magic_prun): Fix bug where an exception would
1209 * IPython/Magic.py (magic_prun): Fix bug where an exception would
1200 be triggered when using 'run -p'. An incorrect option flag was
1210 be triggered when using 'run -p'. An incorrect option flag was
1201 being set ('d' instead of 'D').
1211 being set ('d' instead of 'D').
1202 (manpage): fix missing escaped \- sign.
1212 (manpage): fix missing escaped \- sign.
1203
1213
1204 2004-11-30 *** Released version 0.6.5
1214 2004-11-30 *** Released version 0.6.5
1205
1215
1206 2004-11-30 Fernando Perez <fperez@colorado.edu>
1216 2004-11-30 Fernando Perez <fperez@colorado.edu>
1207
1217
1208 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
1218 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
1209 setting with -d option.
1219 setting with -d option.
1210
1220
1211 * setup.py (docfiles): Fix problem where the doc glob I was using
1221 * setup.py (docfiles): Fix problem where the doc glob I was using
1212 was COMPLETELY BROKEN. It was giving the right files by pure
1222 was COMPLETELY BROKEN. It was giving the right files by pure
1213 accident, but failed once I tried to include ipython.el. Note:
1223 accident, but failed once I tried to include ipython.el. Note:
1214 glob() does NOT allow you to do exclusion on multiple endings!
1224 glob() does NOT allow you to do exclusion on multiple endings!
1215
1225
1216 2004-11-29 Fernando Perez <fperez@colorado.edu>
1226 2004-11-29 Fernando Perez <fperez@colorado.edu>
1217
1227
1218 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
1228 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
1219 the manpage as the source. Better formatting & consistency.
1229 the manpage as the source. Better formatting & consistency.
1220
1230
1221 * IPython/Magic.py (magic_run): Added new -d option, to run
1231 * IPython/Magic.py (magic_run): Added new -d option, to run
1222 scripts under the control of the python pdb debugger. Note that
1232 scripts under the control of the python pdb debugger. Note that
1223 this required changing the %prun option -d to -D, to avoid a clash
1233 this required changing the %prun option -d to -D, to avoid a clash
1224 (since %run must pass options to %prun, and getopt is too dumb to
1234 (since %run must pass options to %prun, and getopt is too dumb to
1225 handle options with string values with embedded spaces). Thanks
1235 handle options with string values with embedded spaces). Thanks
1226 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
1236 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
1227 (magic_who_ls): added type matching to %who and %whos, so that one
1237 (magic_who_ls): added type matching to %who and %whos, so that one
1228 can filter their output to only include variables of certain
1238 can filter their output to only include variables of certain
1229 types. Another suggestion by Matthew.
1239 types. Another suggestion by Matthew.
1230 (magic_whos): Added memory summaries in kb and Mb for arrays.
1240 (magic_whos): Added memory summaries in kb and Mb for arrays.
1231 (magic_who): Improve formatting (break lines every 9 vars).
1241 (magic_who): Improve formatting (break lines every 9 vars).
1232
1242
1233 2004-11-28 Fernando Perez <fperez@colorado.edu>
1243 2004-11-28 Fernando Perez <fperez@colorado.edu>
1234
1244
1235 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
1245 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
1236 cache when empty lines were present.
1246 cache when empty lines were present.
1237
1247
1238 2004-11-24 Fernando Perez <fperez@colorado.edu>
1248 2004-11-24 Fernando Perez <fperez@colorado.edu>
1239
1249
1240 * IPython/usage.py (__doc__): document the re-activated threading
1250 * IPython/usage.py (__doc__): document the re-activated threading
1241 options for WX and GTK.
1251 options for WX and GTK.
1242
1252
1243 2004-11-23 Fernando Perez <fperez@colorado.edu>
1253 2004-11-23 Fernando Perez <fperez@colorado.edu>
1244
1254
1245 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
1255 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
1246 the -wthread and -gthread options, along with a new -tk one to try
1256 the -wthread and -gthread options, along with a new -tk one to try
1247 and coordinate Tk threading with wx/gtk. The tk support is very
1257 and coordinate Tk threading with wx/gtk. The tk support is very
1248 platform dependent, since it seems to require Tcl and Tk to be
1258 platform dependent, since it seems to require Tcl and Tk to be
1249 built with threads (Fedora1/2 appears NOT to have it, but in
1259 built with threads (Fedora1/2 appears NOT to have it, but in
1250 Prabhu's Debian boxes it works OK). But even with some Tk
1260 Prabhu's Debian boxes it works OK). But even with some Tk
1251 limitations, this is a great improvement.
1261 limitations, this is a great improvement.
1252
1262
1253 * IPython/Prompts.py (prompt_specials_color): Added \t for time
1263 * IPython/Prompts.py (prompt_specials_color): Added \t for time
1254 info in user prompts. Patch by Prabhu.
1264 info in user prompts. Patch by Prabhu.
1255
1265
1256 2004-11-18 Fernando Perez <fperez@colorado.edu>
1266 2004-11-18 Fernando Perez <fperez@colorado.edu>
1257
1267
1258 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
1268 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
1259 EOFErrors and bail, to avoid infinite loops if a non-terminating
1269 EOFErrors and bail, to avoid infinite loops if a non-terminating
1260 file is fed into ipython. Patch submitted in issue 19 by user,
1270 file is fed into ipython. Patch submitted in issue 19 by user,
1261 many thanks.
1271 many thanks.
1262
1272
1263 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
1273 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
1264 autoquote/parens in continuation prompts, which can cause lots of
1274 autoquote/parens in continuation prompts, which can cause lots of
1265 problems. Closes roundup issue 20.
1275 problems. Closes roundup issue 20.
1266
1276
1267 2004-11-17 Fernando Perez <fperez@colorado.edu>
1277 2004-11-17 Fernando Perez <fperez@colorado.edu>
1268
1278
1269 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
1279 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
1270 reported as debian bug #280505. I'm not sure my local changelog
1280 reported as debian bug #280505. I'm not sure my local changelog
1271 entry has the proper debian format (Jack?).
1281 entry has the proper debian format (Jack?).
1272
1282
1273 2004-11-08 *** Released version 0.6.4
1283 2004-11-08 *** Released version 0.6.4
1274
1284
1275 2004-11-08 Fernando Perez <fperez@colorado.edu>
1285 2004-11-08 Fernando Perez <fperez@colorado.edu>
1276
1286
1277 * IPython/iplib.py (init_readline): Fix exit message for Windows
1287 * IPython/iplib.py (init_readline): Fix exit message for Windows
1278 when readline is active. Thanks to a report by Eric Jones
1288 when readline is active. Thanks to a report by Eric Jones
1279 <eric-AT-enthought.com>.
1289 <eric-AT-enthought.com>.
1280
1290
1281 2004-11-07 Fernando Perez <fperez@colorado.edu>
1291 2004-11-07 Fernando Perez <fperez@colorado.edu>
1282
1292
1283 * IPython/genutils.py (page): Add a trap for OSError exceptions,
1293 * IPython/genutils.py (page): Add a trap for OSError exceptions,
1284 sometimes seen by win2k/cygwin users.
1294 sometimes seen by win2k/cygwin users.
1285
1295
1286 2004-11-06 Fernando Perez <fperez@colorado.edu>
1296 2004-11-06 Fernando Perez <fperez@colorado.edu>
1287
1297
1288 * IPython/iplib.py (interact): Change the handling of %Exit from
1298 * IPython/iplib.py (interact): Change the handling of %Exit from
1289 trying to propagate a SystemExit to an internal ipython flag.
1299 trying to propagate a SystemExit to an internal ipython flag.
1290 This is less elegant than using Python's exception mechanism, but
1300 This is less elegant than using Python's exception mechanism, but
1291 I can't get that to work reliably with threads, so under -pylab
1301 I can't get that to work reliably with threads, so under -pylab
1292 %Exit was hanging IPython. Cross-thread exception handling is
1302 %Exit was hanging IPython. Cross-thread exception handling is
1293 really a bitch. Thaks to a bug report by Stephen Walton
1303 really a bitch. Thaks to a bug report by Stephen Walton
1294 <stephen.walton-AT-csun.edu>.
1304 <stephen.walton-AT-csun.edu>.
1295
1305
1296 2004-11-04 Fernando Perez <fperez@colorado.edu>
1306 2004-11-04 Fernando Perez <fperez@colorado.edu>
1297
1307
1298 * IPython/iplib.py (raw_input_original): store a pointer to the
1308 * IPython/iplib.py (raw_input_original): store a pointer to the
1299 true raw_input to harden against code which can modify it
1309 true raw_input to harden against code which can modify it
1300 (wx.py.PyShell does this and would otherwise crash ipython).
1310 (wx.py.PyShell does this and would otherwise crash ipython).
1301 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
1311 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
1302
1312
1303 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
1313 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
1304 Ctrl-C problem, which does not mess up the input line.
1314 Ctrl-C problem, which does not mess up the input line.
1305
1315
1306 2004-11-03 Fernando Perez <fperez@colorado.edu>
1316 2004-11-03 Fernando Perez <fperez@colorado.edu>
1307
1317
1308 * IPython/Release.py: Changed licensing to BSD, in all files.
1318 * IPython/Release.py: Changed licensing to BSD, in all files.
1309 (name): lowercase name for tarball/RPM release.
1319 (name): lowercase name for tarball/RPM release.
1310
1320
1311 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
1321 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
1312 use throughout ipython.
1322 use throughout ipython.
1313
1323
1314 * IPython/Magic.py (Magic._ofind): Switch to using the new
1324 * IPython/Magic.py (Magic._ofind): Switch to using the new
1315 OInspect.getdoc() function.
1325 OInspect.getdoc() function.
1316
1326
1317 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
1327 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
1318 of the line currently being canceled via Ctrl-C. It's extremely
1328 of the line currently being canceled via Ctrl-C. It's extremely
1319 ugly, but I don't know how to do it better (the problem is one of
1329 ugly, but I don't know how to do it better (the problem is one of
1320 handling cross-thread exceptions).
1330 handling cross-thread exceptions).
1321
1331
1322 2004-10-28 Fernando Perez <fperez@colorado.edu>
1332 2004-10-28 Fernando Perez <fperez@colorado.edu>
1323
1333
1324 * IPython/Shell.py (signal_handler): add signal handlers to trap
1334 * IPython/Shell.py (signal_handler): add signal handlers to trap
1325 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
1335 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
1326 report by Francesc Alted.
1336 report by Francesc Alted.
1327
1337
1328 2004-10-21 Fernando Perez <fperez@colorado.edu>
1338 2004-10-21 Fernando Perez <fperez@colorado.edu>
1329
1339
1330 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
1340 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
1331 to % for pysh syntax extensions.
1341 to % for pysh syntax extensions.
1332
1342
1333 2004-10-09 Fernando Perez <fperez@colorado.edu>
1343 2004-10-09 Fernando Perez <fperez@colorado.edu>
1334
1344
1335 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
1345 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
1336 arrays to print a more useful summary, without calling str(arr).
1346 arrays to print a more useful summary, without calling str(arr).
1337 This avoids the problem of extremely lengthy computations which
1347 This avoids the problem of extremely lengthy computations which
1338 occur if arr is large, and appear to the user as a system lockup
1348 occur if arr is large, and appear to the user as a system lockup
1339 with 100% cpu activity. After a suggestion by Kristian Sandberg
1349 with 100% cpu activity. After a suggestion by Kristian Sandberg
1340 <Kristian.Sandberg@colorado.edu>.
1350 <Kristian.Sandberg@colorado.edu>.
1341 (Magic.__init__): fix bug in global magic escapes not being
1351 (Magic.__init__): fix bug in global magic escapes not being
1342 correctly set.
1352 correctly set.
1343
1353
1344 2004-10-08 Fernando Perez <fperez@colorado.edu>
1354 2004-10-08 Fernando Perez <fperez@colorado.edu>
1345
1355
1346 * IPython/Magic.py (__license__): change to absolute imports of
1356 * IPython/Magic.py (__license__): change to absolute imports of
1347 ipython's own internal packages, to start adapting to the absolute
1357 ipython's own internal packages, to start adapting to the absolute
1348 import requirement of PEP-328.
1358 import requirement of PEP-328.
1349
1359
1350 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
1360 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
1351 files, and standardize author/license marks through the Release
1361 files, and standardize author/license marks through the Release
1352 module instead of having per/file stuff (except for files with
1362 module instead of having per/file stuff (except for files with
1353 particular licenses, like the MIT/PSF-licensed codes).
1363 particular licenses, like the MIT/PSF-licensed codes).
1354
1364
1355 * IPython/Debugger.py: remove dead code for python 2.1
1365 * IPython/Debugger.py: remove dead code for python 2.1
1356
1366
1357 2004-10-04 Fernando Perez <fperez@colorado.edu>
1367 2004-10-04 Fernando Perez <fperez@colorado.edu>
1358
1368
1359 * IPython/iplib.py (ipmagic): New function for accessing magics
1369 * IPython/iplib.py (ipmagic): New function for accessing magics
1360 via a normal python function call.
1370 via a normal python function call.
1361
1371
1362 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
1372 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
1363 from '@' to '%', to accomodate the new @decorator syntax of python
1373 from '@' to '%', to accomodate the new @decorator syntax of python
1364 2.4.
1374 2.4.
1365
1375
1366 2004-09-29 Fernando Perez <fperez@colorado.edu>
1376 2004-09-29 Fernando Perez <fperez@colorado.edu>
1367
1377
1368 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
1378 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
1369 matplotlib.use to prevent running scripts which try to switch
1379 matplotlib.use to prevent running scripts which try to switch
1370 interactive backends from within ipython. This will just crash
1380 interactive backends from within ipython. This will just crash
1371 the python interpreter, so we can't allow it (but a detailed error
1381 the python interpreter, so we can't allow it (but a detailed error
1372 is given to the user).
1382 is given to the user).
1373
1383
1374 2004-09-28 Fernando Perez <fperez@colorado.edu>
1384 2004-09-28 Fernando Perez <fperez@colorado.edu>
1375
1385
1376 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
1386 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
1377 matplotlib-related fixes so that using @run with non-matplotlib
1387 matplotlib-related fixes so that using @run with non-matplotlib
1378 scripts doesn't pop up spurious plot windows. This requires
1388 scripts doesn't pop up spurious plot windows. This requires
1379 matplotlib >= 0.63, where I had to make some changes as well.
1389 matplotlib >= 0.63, where I had to make some changes as well.
1380
1390
1381 * IPython/ipmaker.py (make_IPython): update version requirement to
1391 * IPython/ipmaker.py (make_IPython): update version requirement to
1382 python 2.2.
1392 python 2.2.
1383
1393
1384 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
1394 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
1385 banner arg for embedded customization.
1395 banner arg for embedded customization.
1386
1396
1387 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
1397 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
1388 explicit uses of __IP as the IPython's instance name. Now things
1398 explicit uses of __IP as the IPython's instance name. Now things
1389 are properly handled via the shell.name value. The actual code
1399 are properly handled via the shell.name value. The actual code
1390 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
1400 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
1391 is much better than before. I'll clean things completely when the
1401 is much better than before. I'll clean things completely when the
1392 magic stuff gets a real overhaul.
1402 magic stuff gets a real overhaul.
1393
1403
1394 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
1404 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
1395 minor changes to debian dir.
1405 minor changes to debian dir.
1396
1406
1397 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
1407 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
1398 pointer to the shell itself in the interactive namespace even when
1408 pointer to the shell itself in the interactive namespace even when
1399 a user-supplied dict is provided. This is needed for embedding
1409 a user-supplied dict is provided. This is needed for embedding
1400 purposes (found by tests with Michel Sanner).
1410 purposes (found by tests with Michel Sanner).
1401
1411
1402 2004-09-27 Fernando Perez <fperez@colorado.edu>
1412 2004-09-27 Fernando Perez <fperez@colorado.edu>
1403
1413
1404 * IPython/UserConfig/ipythonrc: remove []{} from
1414 * IPython/UserConfig/ipythonrc: remove []{} from
1405 readline_remove_delims, so that things like [modname.<TAB> do
1415 readline_remove_delims, so that things like [modname.<TAB> do
1406 proper completion. This disables [].TAB, but that's a less common
1416 proper completion. This disables [].TAB, but that's a less common
1407 case than module names in list comprehensions, for example.
1417 case than module names in list comprehensions, for example.
1408 Thanks to a report by Andrea Riciputi.
1418 Thanks to a report by Andrea Riciputi.
1409
1419
1410 2004-09-09 Fernando Perez <fperez@colorado.edu>
1420 2004-09-09 Fernando Perez <fperez@colorado.edu>
1411
1421
1412 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1422 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1413 blocking problems in win32 and osx. Fix by John.
1423 blocking problems in win32 and osx. Fix by John.
1414
1424
1415 2004-09-08 Fernando Perez <fperez@colorado.edu>
1425 2004-09-08 Fernando Perez <fperez@colorado.edu>
1416
1426
1417 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1427 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1418 for Win32 and OSX. Fix by John Hunter.
1428 for Win32 and OSX. Fix by John Hunter.
1419
1429
1420 2004-08-30 *** Released version 0.6.3
1430 2004-08-30 *** Released version 0.6.3
1421
1431
1422 2004-08-30 Fernando Perez <fperez@colorado.edu>
1432 2004-08-30 Fernando Perez <fperez@colorado.edu>
1423
1433
1424 * setup.py (isfile): Add manpages to list of dependent files to be
1434 * setup.py (isfile): Add manpages to list of dependent files to be
1425 updated.
1435 updated.
1426
1436
1427 2004-08-27 Fernando Perez <fperez@colorado.edu>
1437 2004-08-27 Fernando Perez <fperez@colorado.edu>
1428
1438
1429 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1439 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1430 for now. They don't really work with standalone WX/GTK code
1440 for now. They don't really work with standalone WX/GTK code
1431 (though matplotlib IS working fine with both of those backends).
1441 (though matplotlib IS working fine with both of those backends).
1432 This will neeed much more testing. I disabled most things with
1442 This will neeed much more testing. I disabled most things with
1433 comments, so turning it back on later should be pretty easy.
1443 comments, so turning it back on later should be pretty easy.
1434
1444
1435 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1445 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1436 autocalling of expressions like r'foo', by modifying the line
1446 autocalling of expressions like r'foo', by modifying the line
1437 split regexp. Closes
1447 split regexp. Closes
1438 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1448 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1439 Riley <ipythonbugs-AT-sabi.net>.
1449 Riley <ipythonbugs-AT-sabi.net>.
1440 (InteractiveShell.mainloop): honor --nobanner with banner
1450 (InteractiveShell.mainloop): honor --nobanner with banner
1441 extensions.
1451 extensions.
1442
1452
1443 * IPython/Shell.py: Significant refactoring of all classes, so
1453 * IPython/Shell.py: Significant refactoring of all classes, so
1444 that we can really support ALL matplotlib backends and threading
1454 that we can really support ALL matplotlib backends and threading
1445 models (John spotted a bug with Tk which required this). Now we
1455 models (John spotted a bug with Tk which required this). Now we
1446 should support single-threaded, WX-threads and GTK-threads, both
1456 should support single-threaded, WX-threads and GTK-threads, both
1447 for generic code and for matplotlib.
1457 for generic code and for matplotlib.
1448
1458
1449 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1459 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1450 -pylab, to simplify things for users. Will also remove the pylab
1460 -pylab, to simplify things for users. Will also remove the pylab
1451 profile, since now all of matplotlib configuration is directly
1461 profile, since now all of matplotlib configuration is directly
1452 handled here. This also reduces startup time.
1462 handled here. This also reduces startup time.
1453
1463
1454 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1464 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1455 shell wasn't being correctly called. Also in IPShellWX.
1465 shell wasn't being correctly called. Also in IPShellWX.
1456
1466
1457 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1467 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1458 fine-tune banner.
1468 fine-tune banner.
1459
1469
1460 * IPython/numutils.py (spike): Deprecate these spike functions,
1470 * IPython/numutils.py (spike): Deprecate these spike functions,
1461 delete (long deprecated) gnuplot_exec handler.
1471 delete (long deprecated) gnuplot_exec handler.
1462
1472
1463 2004-08-26 Fernando Perez <fperez@colorado.edu>
1473 2004-08-26 Fernando Perez <fperez@colorado.edu>
1464
1474
1465 * ipython.1: Update for threading options, plus some others which
1475 * ipython.1: Update for threading options, plus some others which
1466 were missing.
1476 were missing.
1467
1477
1468 * IPython/ipmaker.py (__call__): Added -wthread option for
1478 * IPython/ipmaker.py (__call__): Added -wthread option for
1469 wxpython thread handling. Make sure threading options are only
1479 wxpython thread handling. Make sure threading options are only
1470 valid at the command line.
1480 valid at the command line.
1471
1481
1472 * scripts/ipython: moved shell selection into a factory function
1482 * scripts/ipython: moved shell selection into a factory function
1473 in Shell.py, to keep the starter script to a minimum.
1483 in Shell.py, to keep the starter script to a minimum.
1474
1484
1475 2004-08-25 Fernando Perez <fperez@colorado.edu>
1485 2004-08-25 Fernando Perez <fperez@colorado.edu>
1476
1486
1477 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1487 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1478 John. Along with some recent changes he made to matplotlib, the
1488 John. Along with some recent changes he made to matplotlib, the
1479 next versions of both systems should work very well together.
1489 next versions of both systems should work very well together.
1480
1490
1481 2004-08-24 Fernando Perez <fperez@colorado.edu>
1491 2004-08-24 Fernando Perez <fperez@colorado.edu>
1482
1492
1483 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1493 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1484 tried to switch the profiling to using hotshot, but I'm getting
1494 tried to switch the profiling to using hotshot, but I'm getting
1485 strange errors from prof.runctx() there. I may be misreading the
1495 strange errors from prof.runctx() there. I may be misreading the
1486 docs, but it looks weird. For now the profiling code will
1496 docs, but it looks weird. For now the profiling code will
1487 continue to use the standard profiler.
1497 continue to use the standard profiler.
1488
1498
1489 2004-08-23 Fernando Perez <fperez@colorado.edu>
1499 2004-08-23 Fernando Perez <fperez@colorado.edu>
1490
1500
1491 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1501 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1492 threaded shell, by John Hunter. It's not quite ready yet, but
1502 threaded shell, by John Hunter. It's not quite ready yet, but
1493 close.
1503 close.
1494
1504
1495 2004-08-22 Fernando Perez <fperez@colorado.edu>
1505 2004-08-22 Fernando Perez <fperez@colorado.edu>
1496
1506
1497 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1507 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1498 in Magic and ultraTB.
1508 in Magic and ultraTB.
1499
1509
1500 * ipython.1: document threading options in manpage.
1510 * ipython.1: document threading options in manpage.
1501
1511
1502 * scripts/ipython: Changed name of -thread option to -gthread,
1512 * scripts/ipython: Changed name of -thread option to -gthread,
1503 since this is GTK specific. I want to leave the door open for a
1513 since this is GTK specific. I want to leave the door open for a
1504 -wthread option for WX, which will most likely be necessary. This
1514 -wthread option for WX, which will most likely be necessary. This
1505 change affects usage and ipmaker as well.
1515 change affects usage and ipmaker as well.
1506
1516
1507 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1517 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1508 handle the matplotlib shell issues. Code by John Hunter
1518 handle the matplotlib shell issues. Code by John Hunter
1509 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1519 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1510 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1520 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1511 broken (and disabled for end users) for now, but it puts the
1521 broken (and disabled for end users) for now, but it puts the
1512 infrastructure in place.
1522 infrastructure in place.
1513
1523
1514 2004-08-21 Fernando Perez <fperez@colorado.edu>
1524 2004-08-21 Fernando Perez <fperez@colorado.edu>
1515
1525
1516 * ipythonrc-pylab: Add matplotlib support.
1526 * ipythonrc-pylab: Add matplotlib support.
1517
1527
1518 * matplotlib_config.py: new files for matplotlib support, part of
1528 * matplotlib_config.py: new files for matplotlib support, part of
1519 the pylab profile.
1529 the pylab profile.
1520
1530
1521 * IPython/usage.py (__doc__): documented the threading options.
1531 * IPython/usage.py (__doc__): documented the threading options.
1522
1532
1523 2004-08-20 Fernando Perez <fperez@colorado.edu>
1533 2004-08-20 Fernando Perez <fperez@colorado.edu>
1524
1534
1525 * ipython: Modified the main calling routine to handle the -thread
1535 * ipython: Modified the main calling routine to handle the -thread
1526 and -mpthread options. This needs to be done as a top-level hack,
1536 and -mpthread options. This needs to be done as a top-level hack,
1527 because it determines which class to instantiate for IPython
1537 because it determines which class to instantiate for IPython
1528 itself.
1538 itself.
1529
1539
1530 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1540 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1531 classes to support multithreaded GTK operation without blocking,
1541 classes to support multithreaded GTK operation without blocking,
1532 and matplotlib with all backends. This is a lot of still very
1542 and matplotlib with all backends. This is a lot of still very
1533 experimental code, and threads are tricky. So it may still have a
1543 experimental code, and threads are tricky. So it may still have a
1534 few rough edges... This code owes a lot to
1544 few rough edges... This code owes a lot to
1535 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1545 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1536 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1546 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1537 to John Hunter for all the matplotlib work.
1547 to John Hunter for all the matplotlib work.
1538
1548
1539 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1549 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1540 options for gtk thread and matplotlib support.
1550 options for gtk thread and matplotlib support.
1541
1551
1542 2004-08-16 Fernando Perez <fperez@colorado.edu>
1552 2004-08-16 Fernando Perez <fperez@colorado.edu>
1543
1553
1544 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1554 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1545 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1555 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1546 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1556 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1547
1557
1548 2004-08-11 Fernando Perez <fperez@colorado.edu>
1558 2004-08-11 Fernando Perez <fperez@colorado.edu>
1549
1559
1550 * setup.py (isfile): Fix build so documentation gets updated for
1560 * setup.py (isfile): Fix build so documentation gets updated for
1551 rpms (it was only done for .tgz builds).
1561 rpms (it was only done for .tgz builds).
1552
1562
1553 2004-08-10 Fernando Perez <fperez@colorado.edu>
1563 2004-08-10 Fernando Perez <fperez@colorado.edu>
1554
1564
1555 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1565 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1556
1566
1557 * iplib.py : Silence syntax error exceptions in tab-completion.
1567 * iplib.py : Silence syntax error exceptions in tab-completion.
1558
1568
1559 2004-08-05 Fernando Perez <fperez@colorado.edu>
1569 2004-08-05 Fernando Perez <fperez@colorado.edu>
1560
1570
1561 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1571 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1562 'color off' mark for continuation prompts. This was causing long
1572 'color off' mark for continuation prompts. This was causing long
1563 continuation lines to mis-wrap.
1573 continuation lines to mis-wrap.
1564
1574
1565 2004-08-01 Fernando Perez <fperez@colorado.edu>
1575 2004-08-01 Fernando Perez <fperez@colorado.edu>
1566
1576
1567 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1577 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1568 for building ipython to be a parameter. All this is necessary
1578 for building ipython to be a parameter. All this is necessary
1569 right now to have a multithreaded version, but this insane
1579 right now to have a multithreaded version, but this insane
1570 non-design will be cleaned up soon. For now, it's a hack that
1580 non-design will be cleaned up soon. For now, it's a hack that
1571 works.
1581 works.
1572
1582
1573 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1583 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1574 args in various places. No bugs so far, but it's a dangerous
1584 args in various places. No bugs so far, but it's a dangerous
1575 practice.
1585 practice.
1576
1586
1577 2004-07-31 Fernando Perez <fperez@colorado.edu>
1587 2004-07-31 Fernando Perez <fperez@colorado.edu>
1578
1588
1579 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1589 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1580 fix completion of files with dots in their names under most
1590 fix completion of files with dots in their names under most
1581 profiles (pysh was OK because the completion order is different).
1591 profiles (pysh was OK because the completion order is different).
1582
1592
1583 2004-07-27 Fernando Perez <fperez@colorado.edu>
1593 2004-07-27 Fernando Perez <fperez@colorado.edu>
1584
1594
1585 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1595 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1586 keywords manually, b/c the one in keyword.py was removed in python
1596 keywords manually, b/c the one in keyword.py was removed in python
1587 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1597 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1588 This is NOT a bug under python 2.3 and earlier.
1598 This is NOT a bug under python 2.3 and earlier.
1589
1599
1590 2004-07-26 Fernando Perez <fperez@colorado.edu>
1600 2004-07-26 Fernando Perez <fperez@colorado.edu>
1591
1601
1592 * IPython/ultraTB.py (VerboseTB.text): Add another
1602 * IPython/ultraTB.py (VerboseTB.text): Add another
1593 linecache.checkcache() call to try to prevent inspect.py from
1603 linecache.checkcache() call to try to prevent inspect.py from
1594 crashing under python 2.3. I think this fixes
1604 crashing under python 2.3. I think this fixes
1595 http://www.scipy.net/roundup/ipython/issue17.
1605 http://www.scipy.net/roundup/ipython/issue17.
1596
1606
1597 2004-07-26 *** Released version 0.6.2
1607 2004-07-26 *** Released version 0.6.2
1598
1608
1599 2004-07-26 Fernando Perez <fperez@colorado.edu>
1609 2004-07-26 Fernando Perez <fperez@colorado.edu>
1600
1610
1601 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1611 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1602 fail for any number.
1612 fail for any number.
1603 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1613 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1604 empty bookmarks.
1614 empty bookmarks.
1605
1615
1606 2004-07-26 *** Released version 0.6.1
1616 2004-07-26 *** Released version 0.6.1
1607
1617
1608 2004-07-26 Fernando Perez <fperez@colorado.edu>
1618 2004-07-26 Fernando Perez <fperez@colorado.edu>
1609
1619
1610 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1620 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1611
1621
1612 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1622 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1613 escaping '()[]{}' in filenames.
1623 escaping '()[]{}' in filenames.
1614
1624
1615 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1625 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1616 Python 2.2 users who lack a proper shlex.split.
1626 Python 2.2 users who lack a proper shlex.split.
1617
1627
1618 2004-07-19 Fernando Perez <fperez@colorado.edu>
1628 2004-07-19 Fernando Perez <fperez@colorado.edu>
1619
1629
1620 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1630 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1621 for reading readline's init file. I follow the normal chain:
1631 for reading readline's init file. I follow the normal chain:
1622 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1632 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1623 report by Mike Heeter. This closes
1633 report by Mike Heeter. This closes
1624 http://www.scipy.net/roundup/ipython/issue16.
1634 http://www.scipy.net/roundup/ipython/issue16.
1625
1635
1626 2004-07-18 Fernando Perez <fperez@colorado.edu>
1636 2004-07-18 Fernando Perez <fperez@colorado.edu>
1627
1637
1628 * IPython/iplib.py (__init__): Add better handling of '\' under
1638 * IPython/iplib.py (__init__): Add better handling of '\' under
1629 Win32 for filenames. After a patch by Ville.
1639 Win32 for filenames. After a patch by Ville.
1630
1640
1631 2004-07-17 Fernando Perez <fperez@colorado.edu>
1641 2004-07-17 Fernando Perez <fperez@colorado.edu>
1632
1642
1633 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1643 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1634 autocalling would be triggered for 'foo is bar' if foo is
1644 autocalling would be triggered for 'foo is bar' if foo is
1635 callable. I also cleaned up the autocall detection code to use a
1645 callable. I also cleaned up the autocall detection code to use a
1636 regexp, which is faster. Bug reported by Alexander Schmolck.
1646 regexp, which is faster. Bug reported by Alexander Schmolck.
1637
1647
1638 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1648 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1639 '?' in them would confuse the help system. Reported by Alex
1649 '?' in them would confuse the help system. Reported by Alex
1640 Schmolck.
1650 Schmolck.
1641
1651
1642 2004-07-16 Fernando Perez <fperez@colorado.edu>
1652 2004-07-16 Fernando Perez <fperez@colorado.edu>
1643
1653
1644 * IPython/GnuplotInteractive.py (__all__): added plot2.
1654 * IPython/GnuplotInteractive.py (__all__): added plot2.
1645
1655
1646 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1656 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1647 plotting dictionaries, lists or tuples of 1d arrays.
1657 plotting dictionaries, lists or tuples of 1d arrays.
1648
1658
1649 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1659 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1650 optimizations.
1660 optimizations.
1651
1661
1652 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1662 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1653 the information which was there from Janko's original IPP code:
1663 the information which was there from Janko's original IPP code:
1654
1664
1655 03.05.99 20:53 porto.ifm.uni-kiel.de
1665 03.05.99 20:53 porto.ifm.uni-kiel.de
1656 --Started changelog.
1666 --Started changelog.
1657 --make clear do what it say it does
1667 --make clear do what it say it does
1658 --added pretty output of lines from inputcache
1668 --added pretty output of lines from inputcache
1659 --Made Logger a mixin class, simplifies handling of switches
1669 --Made Logger a mixin class, simplifies handling of switches
1660 --Added own completer class. .string<TAB> expands to last history
1670 --Added own completer class. .string<TAB> expands to last history
1661 line which starts with string. The new expansion is also present
1671 line which starts with string. The new expansion is also present
1662 with Ctrl-r from the readline library. But this shows, who this
1672 with Ctrl-r from the readline library. But this shows, who this
1663 can be done for other cases.
1673 can be done for other cases.
1664 --Added convention that all shell functions should accept a
1674 --Added convention that all shell functions should accept a
1665 parameter_string This opens the door for different behaviour for
1675 parameter_string This opens the door for different behaviour for
1666 each function. @cd is a good example of this.
1676 each function. @cd is a good example of this.
1667
1677
1668 04.05.99 12:12 porto.ifm.uni-kiel.de
1678 04.05.99 12:12 porto.ifm.uni-kiel.de
1669 --added logfile rotation
1679 --added logfile rotation
1670 --added new mainloop method which freezes first the namespace
1680 --added new mainloop method which freezes first the namespace
1671
1681
1672 07.05.99 21:24 porto.ifm.uni-kiel.de
1682 07.05.99 21:24 porto.ifm.uni-kiel.de
1673 --added the docreader classes. Now there is a help system.
1683 --added the docreader classes. Now there is a help system.
1674 -This is only a first try. Currently it's not easy to put new
1684 -This is only a first try. Currently it's not easy to put new
1675 stuff in the indices. But this is the way to go. Info would be
1685 stuff in the indices. But this is the way to go. Info would be
1676 better, but HTML is every where and not everybody has an info
1686 better, but HTML is every where and not everybody has an info
1677 system installed and it's not so easy to change html-docs to info.
1687 system installed and it's not so easy to change html-docs to info.
1678 --added global logfile option
1688 --added global logfile option
1679 --there is now a hook for object inspection method pinfo needs to
1689 --there is now a hook for object inspection method pinfo needs to
1680 be provided for this. Can be reached by two '??'.
1690 be provided for this. Can be reached by two '??'.
1681
1691
1682 08.05.99 20:51 porto.ifm.uni-kiel.de
1692 08.05.99 20:51 porto.ifm.uni-kiel.de
1683 --added a README
1693 --added a README
1684 --bug in rc file. Something has changed so functions in the rc
1694 --bug in rc file. Something has changed so functions in the rc
1685 file need to reference the shell and not self. Not clear if it's a
1695 file need to reference the shell and not self. Not clear if it's a
1686 bug or feature.
1696 bug or feature.
1687 --changed rc file for new behavior
1697 --changed rc file for new behavior
1688
1698
1689 2004-07-15 Fernando Perez <fperez@colorado.edu>
1699 2004-07-15 Fernando Perez <fperez@colorado.edu>
1690
1700
1691 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1701 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1692 cache was falling out of sync in bizarre manners when multi-line
1702 cache was falling out of sync in bizarre manners when multi-line
1693 input was present. Minor optimizations and cleanup.
1703 input was present. Minor optimizations and cleanup.
1694
1704
1695 (Logger): Remove old Changelog info for cleanup. This is the
1705 (Logger): Remove old Changelog info for cleanup. This is the
1696 information which was there from Janko's original code:
1706 information which was there from Janko's original code:
1697
1707
1698 Changes to Logger: - made the default log filename a parameter
1708 Changes to Logger: - made the default log filename a parameter
1699
1709
1700 - put a check for lines beginning with !@? in log(). Needed
1710 - put a check for lines beginning with !@? in log(). Needed
1701 (even if the handlers properly log their lines) for mid-session
1711 (even if the handlers properly log their lines) for mid-session
1702 logging activation to work properly. Without this, lines logged
1712 logging activation to work properly. Without this, lines logged
1703 in mid session, which get read from the cache, would end up
1713 in mid session, which get read from the cache, would end up
1704 'bare' (with !@? in the open) in the log. Now they are caught
1714 'bare' (with !@? in the open) in the log. Now they are caught
1705 and prepended with a #.
1715 and prepended with a #.
1706
1716
1707 * IPython/iplib.py (InteractiveShell.init_readline): added check
1717 * IPython/iplib.py (InteractiveShell.init_readline): added check
1708 in case MagicCompleter fails to be defined, so we don't crash.
1718 in case MagicCompleter fails to be defined, so we don't crash.
1709
1719
1710 2004-07-13 Fernando Perez <fperez@colorado.edu>
1720 2004-07-13 Fernando Perez <fperez@colorado.edu>
1711
1721
1712 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1722 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1713 of EPS if the requested filename ends in '.eps'.
1723 of EPS if the requested filename ends in '.eps'.
1714
1724
1715 2004-07-04 Fernando Perez <fperez@colorado.edu>
1725 2004-07-04 Fernando Perez <fperez@colorado.edu>
1716
1726
1717 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1727 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1718 escaping of quotes when calling the shell.
1728 escaping of quotes when calling the shell.
1719
1729
1720 2004-07-02 Fernando Perez <fperez@colorado.edu>
1730 2004-07-02 Fernando Perez <fperez@colorado.edu>
1721
1731
1722 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1732 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1723 gettext not working because we were clobbering '_'. Fixes
1733 gettext not working because we were clobbering '_'. Fixes
1724 http://www.scipy.net/roundup/ipython/issue6.
1734 http://www.scipy.net/roundup/ipython/issue6.
1725
1735
1726 2004-07-01 Fernando Perez <fperez@colorado.edu>
1736 2004-07-01 Fernando Perez <fperez@colorado.edu>
1727
1737
1728 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1738 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1729 into @cd. Patch by Ville.
1739 into @cd. Patch by Ville.
1730
1740
1731 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1741 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1732 new function to store things after ipmaker runs. Patch by Ville.
1742 new function to store things after ipmaker runs. Patch by Ville.
1733 Eventually this will go away once ipmaker is removed and the class
1743 Eventually this will go away once ipmaker is removed and the class
1734 gets cleaned up, but for now it's ok. Key functionality here is
1744 gets cleaned up, but for now it's ok. Key functionality here is
1735 the addition of the persistent storage mechanism, a dict for
1745 the addition of the persistent storage mechanism, a dict for
1736 keeping data across sessions (for now just bookmarks, but more can
1746 keeping data across sessions (for now just bookmarks, but more can
1737 be implemented later).
1747 be implemented later).
1738
1748
1739 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
1749 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
1740 persistent across sections. Patch by Ville, I modified it
1750 persistent across sections. Patch by Ville, I modified it
1741 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
1751 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
1742 added a '-l' option to list all bookmarks.
1752 added a '-l' option to list all bookmarks.
1743
1753
1744 * IPython/iplib.py (InteractiveShell.atexit_operations): new
1754 * IPython/iplib.py (InteractiveShell.atexit_operations): new
1745 center for cleanup. Registered with atexit.register(). I moved
1755 center for cleanup. Registered with atexit.register(). I moved
1746 here the old exit_cleanup(). After a patch by Ville.
1756 here the old exit_cleanup(). After a patch by Ville.
1747
1757
1748 * IPython/Magic.py (get_py_filename): added '~' to the accepted
1758 * IPython/Magic.py (get_py_filename): added '~' to the accepted
1749 characters in the hacked shlex_split for python 2.2.
1759 characters in the hacked shlex_split for python 2.2.
1750
1760
1751 * IPython/iplib.py (file_matches): more fixes to filenames with
1761 * IPython/iplib.py (file_matches): more fixes to filenames with
1752 whitespace in them. It's not perfect, but limitations in python's
1762 whitespace in them. It's not perfect, but limitations in python's
1753 readline make it impossible to go further.
1763 readline make it impossible to go further.
1754
1764
1755 2004-06-29 Fernando Perez <fperez@colorado.edu>
1765 2004-06-29 Fernando Perez <fperez@colorado.edu>
1756
1766
1757 * IPython/iplib.py (file_matches): escape whitespace correctly in
1767 * IPython/iplib.py (file_matches): escape whitespace correctly in
1758 filename completions. Bug reported by Ville.
1768 filename completions. Bug reported by Ville.
1759
1769
1760 2004-06-28 Fernando Perez <fperez@colorado.edu>
1770 2004-06-28 Fernando Perez <fperez@colorado.edu>
1761
1771
1762 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
1772 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
1763 the history file will be called 'history-PROFNAME' (or just
1773 the history file will be called 'history-PROFNAME' (or just
1764 'history' if no profile is loaded). I was getting annoyed at
1774 'history' if no profile is loaded). I was getting annoyed at
1765 getting my Numerical work history clobbered by pysh sessions.
1775 getting my Numerical work history clobbered by pysh sessions.
1766
1776
1767 * IPython/iplib.py (InteractiveShell.__init__): Internal
1777 * IPython/iplib.py (InteractiveShell.__init__): Internal
1768 getoutputerror() function so that we can honor the system_verbose
1778 getoutputerror() function so that we can honor the system_verbose
1769 flag for _all_ system calls. I also added escaping of #
1779 flag for _all_ system calls. I also added escaping of #
1770 characters here to avoid confusing Itpl.
1780 characters here to avoid confusing Itpl.
1771
1781
1772 * IPython/Magic.py (shlex_split): removed call to shell in
1782 * IPython/Magic.py (shlex_split): removed call to shell in
1773 parse_options and replaced it with shlex.split(). The annoying
1783 parse_options and replaced it with shlex.split(). The annoying
1774 part was that in Python 2.2, shlex.split() doesn't exist, so I had
1784 part was that in Python 2.2, shlex.split() doesn't exist, so I had
1775 to backport it from 2.3, with several frail hacks (the shlex
1785 to backport it from 2.3, with several frail hacks (the shlex
1776 module is rather limited in 2.2). Thanks to a suggestion by Ville
1786 module is rather limited in 2.2). Thanks to a suggestion by Ville
1777 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
1787 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
1778 problem.
1788 problem.
1779
1789
1780 (Magic.magic_system_verbose): new toggle to print the actual
1790 (Magic.magic_system_verbose): new toggle to print the actual
1781 system calls made by ipython. Mainly for debugging purposes.
1791 system calls made by ipython. Mainly for debugging purposes.
1782
1792
1783 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
1793 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
1784 doesn't support persistence. Reported (and fix suggested) by
1794 doesn't support persistence. Reported (and fix suggested) by
1785 Travis Caldwell <travis_caldwell2000@yahoo.com>.
1795 Travis Caldwell <travis_caldwell2000@yahoo.com>.
1786
1796
1787 2004-06-26 Fernando Perez <fperez@colorado.edu>
1797 2004-06-26 Fernando Perez <fperez@colorado.edu>
1788
1798
1789 * IPython/Logger.py (Logger.log): fix to handle correctly empty
1799 * IPython/Logger.py (Logger.log): fix to handle correctly empty
1790 continue prompts.
1800 continue prompts.
1791
1801
1792 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
1802 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
1793 function (basically a big docstring) and a few more things here to
1803 function (basically a big docstring) and a few more things here to
1794 speedup startup. pysh.py is now very lightweight. We want because
1804 speedup startup. pysh.py is now very lightweight. We want because
1795 it gets execfile'd, while InterpreterExec gets imported, so
1805 it gets execfile'd, while InterpreterExec gets imported, so
1796 byte-compilation saves time.
1806 byte-compilation saves time.
1797
1807
1798 2004-06-25 Fernando Perez <fperez@colorado.edu>
1808 2004-06-25 Fernando Perez <fperez@colorado.edu>
1799
1809
1800 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
1810 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
1801 -NUM', which was recently broken.
1811 -NUM', which was recently broken.
1802
1812
1803 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
1813 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
1804 in multi-line input (but not !!, which doesn't make sense there).
1814 in multi-line input (but not !!, which doesn't make sense there).
1805
1815
1806 * IPython/UserConfig/ipythonrc: made autoindent on by default.
1816 * IPython/UserConfig/ipythonrc: made autoindent on by default.
1807 It's just too useful, and people can turn it off in the less
1817 It's just too useful, and people can turn it off in the less
1808 common cases where it's a problem.
1818 common cases where it's a problem.
1809
1819
1810 2004-06-24 Fernando Perez <fperez@colorado.edu>
1820 2004-06-24 Fernando Perez <fperez@colorado.edu>
1811
1821
1812 * IPython/iplib.py (InteractiveShell._prefilter): big change -
1822 * IPython/iplib.py (InteractiveShell._prefilter): big change -
1813 special syntaxes (like alias calling) is now allied in multi-line
1823 special syntaxes (like alias calling) is now allied in multi-line
1814 input. This is still _very_ experimental, but it's necessary for
1824 input. This is still _very_ experimental, but it's necessary for
1815 efficient shell usage combining python looping syntax with system
1825 efficient shell usage combining python looping syntax with system
1816 calls. For now it's restricted to aliases, I don't think it
1826 calls. For now it's restricted to aliases, I don't think it
1817 really even makes sense to have this for magics.
1827 really even makes sense to have this for magics.
1818
1828
1819 2004-06-23 Fernando Perez <fperez@colorado.edu>
1829 2004-06-23 Fernando Perez <fperez@colorado.edu>
1820
1830
1821 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
1831 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
1822 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
1832 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
1823
1833
1824 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
1834 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
1825 extensions under Windows (after code sent by Gary Bishop). The
1835 extensions under Windows (after code sent by Gary Bishop). The
1826 extensions considered 'executable' are stored in IPython's rc
1836 extensions considered 'executable' are stored in IPython's rc
1827 structure as win_exec_ext.
1837 structure as win_exec_ext.
1828
1838
1829 * IPython/genutils.py (shell): new function, like system() but
1839 * IPython/genutils.py (shell): new function, like system() but
1830 without return value. Very useful for interactive shell work.
1840 without return value. Very useful for interactive shell work.
1831
1841
1832 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
1842 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
1833 delete aliases.
1843 delete aliases.
1834
1844
1835 * IPython/iplib.py (InteractiveShell.alias_table_update): make
1845 * IPython/iplib.py (InteractiveShell.alias_table_update): make
1836 sure that the alias table doesn't contain python keywords.
1846 sure that the alias table doesn't contain python keywords.
1837
1847
1838 2004-06-21 Fernando Perez <fperez@colorado.edu>
1848 2004-06-21 Fernando Perez <fperez@colorado.edu>
1839
1849
1840 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
1850 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
1841 non-existent items are found in $PATH. Reported by Thorsten.
1851 non-existent items are found in $PATH. Reported by Thorsten.
1842
1852
1843 2004-06-20 Fernando Perez <fperez@colorado.edu>
1853 2004-06-20 Fernando Perez <fperez@colorado.edu>
1844
1854
1845 * IPython/iplib.py (complete): modified the completer so that the
1855 * IPython/iplib.py (complete): modified the completer so that the
1846 order of priorities can be easily changed at runtime.
1856 order of priorities can be easily changed at runtime.
1847
1857
1848 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
1858 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
1849 Modified to auto-execute all lines beginning with '~', '/' or '.'.
1859 Modified to auto-execute all lines beginning with '~', '/' or '.'.
1850
1860
1851 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
1861 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
1852 expand Python variables prepended with $ in all system calls. The
1862 expand Python variables prepended with $ in all system calls. The
1853 same was done to InteractiveShell.handle_shell_escape. Now all
1863 same was done to InteractiveShell.handle_shell_escape. Now all
1854 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
1864 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
1855 expansion of python variables and expressions according to the
1865 expansion of python variables and expressions according to the
1856 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
1866 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
1857
1867
1858 Though PEP-215 has been rejected, a similar (but simpler) one
1868 Though PEP-215 has been rejected, a similar (but simpler) one
1859 seems like it will go into Python 2.4, PEP-292 -
1869 seems like it will go into Python 2.4, PEP-292 -
1860 http://www.python.org/peps/pep-0292.html.
1870 http://www.python.org/peps/pep-0292.html.
1861
1871
1862 I'll keep the full syntax of PEP-215, since IPython has since the
1872 I'll keep the full syntax of PEP-215, since IPython has since the
1863 start used Ka-Ping Yee's reference implementation discussed there
1873 start used Ka-Ping Yee's reference implementation discussed there
1864 (Itpl), and I actually like the powerful semantics it offers.
1874 (Itpl), and I actually like the powerful semantics it offers.
1865
1875
1866 In order to access normal shell variables, the $ has to be escaped
1876 In order to access normal shell variables, the $ has to be escaped
1867 via an extra $. For example:
1877 via an extra $. For example:
1868
1878
1869 In [7]: PATH='a python variable'
1879 In [7]: PATH='a python variable'
1870
1880
1871 In [8]: !echo $PATH
1881 In [8]: !echo $PATH
1872 a python variable
1882 a python variable
1873
1883
1874 In [9]: !echo $$PATH
1884 In [9]: !echo $$PATH
1875 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1885 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1876
1886
1877 (Magic.parse_options): escape $ so the shell doesn't evaluate
1887 (Magic.parse_options): escape $ so the shell doesn't evaluate
1878 things prematurely.
1888 things prematurely.
1879
1889
1880 * IPython/iplib.py (InteractiveShell.call_alias): added the
1890 * IPython/iplib.py (InteractiveShell.call_alias): added the
1881 ability for aliases to expand python variables via $.
1891 ability for aliases to expand python variables via $.
1882
1892
1883 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
1893 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
1884 system, now there's a @rehash/@rehashx pair of magics. These work
1894 system, now there's a @rehash/@rehashx pair of magics. These work
1885 like the csh rehash command, and can be invoked at any time. They
1895 like the csh rehash command, and can be invoked at any time. They
1886 build a table of aliases to everything in the user's $PATH
1896 build a table of aliases to everything in the user's $PATH
1887 (@rehash uses everything, @rehashx is slower but only adds
1897 (@rehash uses everything, @rehashx is slower but only adds
1888 executable files). With this, the pysh.py-based shell profile can
1898 executable files). With this, the pysh.py-based shell profile can
1889 now simply call rehash upon startup, and full access to all
1899 now simply call rehash upon startup, and full access to all
1890 programs in the user's path is obtained.
1900 programs in the user's path is obtained.
1891
1901
1892 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
1902 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
1893 functionality is now fully in place. I removed the old dynamic
1903 functionality is now fully in place. I removed the old dynamic
1894 code generation based approach, in favor of a much lighter one
1904 code generation based approach, in favor of a much lighter one
1895 based on a simple dict. The advantage is that this allows me to
1905 based on a simple dict. The advantage is that this allows me to
1896 now have thousands of aliases with negligible cost (unthinkable
1906 now have thousands of aliases with negligible cost (unthinkable
1897 with the old system).
1907 with the old system).
1898
1908
1899 2004-06-19 Fernando Perez <fperez@colorado.edu>
1909 2004-06-19 Fernando Perez <fperez@colorado.edu>
1900
1910
1901 * IPython/iplib.py (__init__): extended MagicCompleter class to
1911 * IPython/iplib.py (__init__): extended MagicCompleter class to
1902 also complete (last in priority) on user aliases.
1912 also complete (last in priority) on user aliases.
1903
1913
1904 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
1914 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
1905 call to eval.
1915 call to eval.
1906 (ItplNS.__init__): Added a new class which functions like Itpl,
1916 (ItplNS.__init__): Added a new class which functions like Itpl,
1907 but allows configuring the namespace for the evaluation to occur
1917 but allows configuring the namespace for the evaluation to occur
1908 in.
1918 in.
1909
1919
1910 2004-06-18 Fernando Perez <fperez@colorado.edu>
1920 2004-06-18 Fernando Perez <fperez@colorado.edu>
1911
1921
1912 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
1922 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
1913 better message when 'exit' or 'quit' are typed (a common newbie
1923 better message when 'exit' or 'quit' are typed (a common newbie
1914 confusion).
1924 confusion).
1915
1925
1916 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
1926 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
1917 check for Windows users.
1927 check for Windows users.
1918
1928
1919 * IPython/iplib.py (InteractiveShell.user_setup): removed
1929 * IPython/iplib.py (InteractiveShell.user_setup): removed
1920 disabling of colors for Windows. I'll test at runtime and issue a
1930 disabling of colors for Windows. I'll test at runtime and issue a
1921 warning if Gary's readline isn't found, as to nudge users to
1931 warning if Gary's readline isn't found, as to nudge users to
1922 download it.
1932 download it.
1923
1933
1924 2004-06-16 Fernando Perez <fperez@colorado.edu>
1934 2004-06-16 Fernando Perez <fperez@colorado.edu>
1925
1935
1926 * IPython/genutils.py (Stream.__init__): changed to print errors
1936 * IPython/genutils.py (Stream.__init__): changed to print errors
1927 to sys.stderr. I had a circular dependency here. Now it's
1937 to sys.stderr. I had a circular dependency here. Now it's
1928 possible to run ipython as IDLE's shell (consider this pre-alpha,
1938 possible to run ipython as IDLE's shell (consider this pre-alpha,
1929 since true stdout things end up in the starting terminal instead
1939 since true stdout things end up in the starting terminal instead
1930 of IDLE's out).
1940 of IDLE's out).
1931
1941
1932 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
1942 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
1933 users who haven't # updated their prompt_in2 definitions. Remove
1943 users who haven't # updated their prompt_in2 definitions. Remove
1934 eventually.
1944 eventually.
1935 (multiple_replace): added credit to original ASPN recipe.
1945 (multiple_replace): added credit to original ASPN recipe.
1936
1946
1937 2004-06-15 Fernando Perez <fperez@colorado.edu>
1947 2004-06-15 Fernando Perez <fperez@colorado.edu>
1938
1948
1939 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
1949 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
1940 list of auto-defined aliases.
1950 list of auto-defined aliases.
1941
1951
1942 2004-06-13 Fernando Perez <fperez@colorado.edu>
1952 2004-06-13 Fernando Perez <fperez@colorado.edu>
1943
1953
1944 * setup.py (scriptfiles): Don't trigger win_post_install unless an
1954 * setup.py (scriptfiles): Don't trigger win_post_install unless an
1945 install was really requested (so setup.py can be used for other
1955 install was really requested (so setup.py can be used for other
1946 things under Windows).
1956 things under Windows).
1947
1957
1948 2004-06-10 Fernando Perez <fperez@colorado.edu>
1958 2004-06-10 Fernando Perez <fperez@colorado.edu>
1949
1959
1950 * IPython/Logger.py (Logger.create_log): Manually remove any old
1960 * IPython/Logger.py (Logger.create_log): Manually remove any old
1951 backup, since os.remove may fail under Windows. Fixes bug
1961 backup, since os.remove may fail under Windows. Fixes bug
1952 reported by Thorsten.
1962 reported by Thorsten.
1953
1963
1954 2004-06-09 Fernando Perez <fperez@colorado.edu>
1964 2004-06-09 Fernando Perez <fperez@colorado.edu>
1955
1965
1956 * examples/example-embed.py: fixed all references to %n (replaced
1966 * examples/example-embed.py: fixed all references to %n (replaced
1957 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
1967 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
1958 for all examples and the manual as well.
1968 for all examples and the manual as well.
1959
1969
1960 2004-06-08 Fernando Perez <fperez@colorado.edu>
1970 2004-06-08 Fernando Perez <fperez@colorado.edu>
1961
1971
1962 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
1972 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
1963 alignment and color management. All 3 prompt subsystems now
1973 alignment and color management. All 3 prompt subsystems now
1964 inherit from BasePrompt.
1974 inherit from BasePrompt.
1965
1975
1966 * tools/release: updates for windows installer build and tag rpms
1976 * tools/release: updates for windows installer build and tag rpms
1967 with python version (since paths are fixed).
1977 with python version (since paths are fixed).
1968
1978
1969 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
1979 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
1970 which will become eventually obsolete. Also fixed the default
1980 which will become eventually obsolete. Also fixed the default
1971 prompt_in2 to use \D, so at least new users start with the correct
1981 prompt_in2 to use \D, so at least new users start with the correct
1972 defaults.
1982 defaults.
1973 WARNING: Users with existing ipythonrc files will need to apply
1983 WARNING: Users with existing ipythonrc files will need to apply
1974 this fix manually!
1984 this fix manually!
1975
1985
1976 * setup.py: make windows installer (.exe). This is finally the
1986 * setup.py: make windows installer (.exe). This is finally the
1977 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
1987 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
1978 which I hadn't included because it required Python 2.3 (or recent
1988 which I hadn't included because it required Python 2.3 (or recent
1979 distutils).
1989 distutils).
1980
1990
1981 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
1991 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
1982 usage of new '\D' escape.
1992 usage of new '\D' escape.
1983
1993
1984 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
1994 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
1985 lacks os.getuid())
1995 lacks os.getuid())
1986 (CachedOutput.set_colors): Added the ability to turn coloring
1996 (CachedOutput.set_colors): Added the ability to turn coloring
1987 on/off with @colors even for manually defined prompt colors. It
1997 on/off with @colors even for manually defined prompt colors. It
1988 uses a nasty global, but it works safely and via the generic color
1998 uses a nasty global, but it works safely and via the generic color
1989 handling mechanism.
1999 handling mechanism.
1990 (Prompt2.__init__): Introduced new escape '\D' for continuation
2000 (Prompt2.__init__): Introduced new escape '\D' for continuation
1991 prompts. It represents the counter ('\#') as dots.
2001 prompts. It represents the counter ('\#') as dots.
1992 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
2002 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
1993 need to update their ipythonrc files and replace '%n' with '\D' in
2003 need to update their ipythonrc files and replace '%n' with '\D' in
1994 their prompt_in2 settings everywhere. Sorry, but there's
2004 their prompt_in2 settings everywhere. Sorry, but there's
1995 otherwise no clean way to get all prompts to properly align. The
2005 otherwise no clean way to get all prompts to properly align. The
1996 ipythonrc shipped with IPython has been updated.
2006 ipythonrc shipped with IPython has been updated.
1997
2007
1998 2004-06-07 Fernando Perez <fperez@colorado.edu>
2008 2004-06-07 Fernando Perez <fperez@colorado.edu>
1999
2009
2000 * setup.py (isfile): Pass local_icons option to latex2html, so the
2010 * setup.py (isfile): Pass local_icons option to latex2html, so the
2001 resulting HTML file is self-contained. Thanks to
2011 resulting HTML file is self-contained. Thanks to
2002 dryice-AT-liu.com.cn for the tip.
2012 dryice-AT-liu.com.cn for the tip.
2003
2013
2004 * pysh.py: I created a new profile 'shell', which implements a
2014 * pysh.py: I created a new profile 'shell', which implements a
2005 _rudimentary_ IPython-based shell. This is in NO WAY a realy
2015 _rudimentary_ IPython-based shell. This is in NO WAY a realy
2006 system shell, nor will it become one anytime soon. It's mainly
2016 system shell, nor will it become one anytime soon. It's mainly
2007 meant to illustrate the use of the new flexible bash-like prompts.
2017 meant to illustrate the use of the new flexible bash-like prompts.
2008 I guess it could be used by hardy souls for true shell management,
2018 I guess it could be used by hardy souls for true shell management,
2009 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
2019 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
2010 profile. This uses the InterpreterExec extension provided by
2020 profile. This uses the InterpreterExec extension provided by
2011 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
2021 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
2012
2022
2013 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
2023 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
2014 auto-align itself with the length of the previous input prompt
2024 auto-align itself with the length of the previous input prompt
2015 (taking into account the invisible color escapes).
2025 (taking into account the invisible color escapes).
2016 (CachedOutput.__init__): Large restructuring of this class. Now
2026 (CachedOutput.__init__): Large restructuring of this class. Now
2017 all three prompts (primary1, primary2, output) are proper objects,
2027 all three prompts (primary1, primary2, output) are proper objects,
2018 managed by the 'parent' CachedOutput class. The code is still a
2028 managed by the 'parent' CachedOutput class. The code is still a
2019 bit hackish (all prompts share state via a pointer to the cache),
2029 bit hackish (all prompts share state via a pointer to the cache),
2020 but it's overall far cleaner than before.
2030 but it's overall far cleaner than before.
2021
2031
2022 * IPython/genutils.py (getoutputerror): modified to add verbose,
2032 * IPython/genutils.py (getoutputerror): modified to add verbose,
2023 debug and header options. This makes the interface of all getout*
2033 debug and header options. This makes the interface of all getout*
2024 functions uniform.
2034 functions uniform.
2025 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
2035 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
2026
2036
2027 * IPython/Magic.py (Magic.default_option): added a function to
2037 * IPython/Magic.py (Magic.default_option): added a function to
2028 allow registering default options for any magic command. This
2038 allow registering default options for any magic command. This
2029 makes it easy to have profiles which customize the magics globally
2039 makes it easy to have profiles which customize the magics globally
2030 for a certain use. The values set through this function are
2040 for a certain use. The values set through this function are
2031 picked up by the parse_options() method, which all magics should
2041 picked up by the parse_options() method, which all magics should
2032 use to parse their options.
2042 use to parse their options.
2033
2043
2034 * IPython/genutils.py (warn): modified the warnings framework to
2044 * IPython/genutils.py (warn): modified the warnings framework to
2035 use the Term I/O class. I'm trying to slowly unify all of
2045 use the Term I/O class. I'm trying to slowly unify all of
2036 IPython's I/O operations to pass through Term.
2046 IPython's I/O operations to pass through Term.
2037
2047
2038 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
2048 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
2039 the secondary prompt to correctly match the length of the primary
2049 the secondary prompt to correctly match the length of the primary
2040 one for any prompt. Now multi-line code will properly line up
2050 one for any prompt. Now multi-line code will properly line up
2041 even for path dependent prompts, such as the new ones available
2051 even for path dependent prompts, such as the new ones available
2042 via the prompt_specials.
2052 via the prompt_specials.
2043
2053
2044 2004-06-06 Fernando Perez <fperez@colorado.edu>
2054 2004-06-06 Fernando Perez <fperez@colorado.edu>
2045
2055
2046 * IPython/Prompts.py (prompt_specials): Added the ability to have
2056 * IPython/Prompts.py (prompt_specials): Added the ability to have
2047 bash-like special sequences in the prompts, which get
2057 bash-like special sequences in the prompts, which get
2048 automatically expanded. Things like hostname, current working
2058 automatically expanded. Things like hostname, current working
2049 directory and username are implemented already, but it's easy to
2059 directory and username are implemented already, but it's easy to
2050 add more in the future. Thanks to a patch by W.J. van der Laan
2060 add more in the future. Thanks to a patch by W.J. van der Laan
2051 <gnufnork-AT-hetdigitalegat.nl>
2061 <gnufnork-AT-hetdigitalegat.nl>
2052 (prompt_specials): Added color support for prompt strings, so
2062 (prompt_specials): Added color support for prompt strings, so
2053 users can define arbitrary color setups for their prompts.
2063 users can define arbitrary color setups for their prompts.
2054
2064
2055 2004-06-05 Fernando Perez <fperez@colorado.edu>
2065 2004-06-05 Fernando Perez <fperez@colorado.edu>
2056
2066
2057 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
2067 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
2058 code to load Gary Bishop's readline and configure it
2068 code to load Gary Bishop's readline and configure it
2059 automatically. Thanks to Gary for help on this.
2069 automatically. Thanks to Gary for help on this.
2060
2070
2061 2004-06-01 Fernando Perez <fperez@colorado.edu>
2071 2004-06-01 Fernando Perez <fperez@colorado.edu>
2062
2072
2063 * IPython/Logger.py (Logger.create_log): fix bug for logging
2073 * IPython/Logger.py (Logger.create_log): fix bug for logging
2064 with no filename (previous fix was incomplete).
2074 with no filename (previous fix was incomplete).
2065
2075
2066 2004-05-25 Fernando Perez <fperez@colorado.edu>
2076 2004-05-25 Fernando Perez <fperez@colorado.edu>
2067
2077
2068 * IPython/Magic.py (Magic.parse_options): fix bug where naked
2078 * IPython/Magic.py (Magic.parse_options): fix bug where naked
2069 parens would get passed to the shell.
2079 parens would get passed to the shell.
2070
2080
2071 2004-05-20 Fernando Perez <fperez@colorado.edu>
2081 2004-05-20 Fernando Perez <fperez@colorado.edu>
2072
2082
2073 * IPython/Magic.py (Magic.magic_prun): changed default profile
2083 * IPython/Magic.py (Magic.magic_prun): changed default profile
2074 sort order to 'time' (the more common profiling need).
2084 sort order to 'time' (the more common profiling need).
2075
2085
2076 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
2086 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
2077 so that source code shown is guaranteed in sync with the file on
2087 so that source code shown is guaranteed in sync with the file on
2078 disk (also changed in psource). Similar fix to the one for
2088 disk (also changed in psource). Similar fix to the one for
2079 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
2089 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
2080 <yann.ledu-AT-noos.fr>.
2090 <yann.ledu-AT-noos.fr>.
2081
2091
2082 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
2092 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
2083 with a single option would not be correctly parsed. Closes
2093 with a single option would not be correctly parsed. Closes
2084 http://www.scipy.net/roundup/ipython/issue14. This bug had been
2094 http://www.scipy.net/roundup/ipython/issue14. This bug had been
2085 introduced in 0.6.0 (on 2004-05-06).
2095 introduced in 0.6.0 (on 2004-05-06).
2086
2096
2087 2004-05-13 *** Released version 0.6.0
2097 2004-05-13 *** Released version 0.6.0
2088
2098
2089 2004-05-13 Fernando Perez <fperez@colorado.edu>
2099 2004-05-13 Fernando Perez <fperez@colorado.edu>
2090
2100
2091 * debian/: Added debian/ directory to CVS, so that debian support
2101 * debian/: Added debian/ directory to CVS, so that debian support
2092 is publicly accessible. The debian package is maintained by Jack
2102 is publicly accessible. The debian package is maintained by Jack
2093 Moffit <jack-AT-xiph.org>.
2103 Moffit <jack-AT-xiph.org>.
2094
2104
2095 * Documentation: included the notes about an ipython-based system
2105 * Documentation: included the notes about an ipython-based system
2096 shell (the hypothetical 'pysh') into the new_design.pdf document,
2106 shell (the hypothetical 'pysh') into the new_design.pdf document,
2097 so that these ideas get distributed to users along with the
2107 so that these ideas get distributed to users along with the
2098 official documentation.
2108 official documentation.
2099
2109
2100 2004-05-10 Fernando Perez <fperez@colorado.edu>
2110 2004-05-10 Fernando Perez <fperez@colorado.edu>
2101
2111
2102 * IPython/Logger.py (Logger.create_log): fix recently introduced
2112 * IPython/Logger.py (Logger.create_log): fix recently introduced
2103 bug (misindented line) where logstart would fail when not given an
2113 bug (misindented line) where logstart would fail when not given an
2104 explicit filename.
2114 explicit filename.
2105
2115
2106 2004-05-09 Fernando Perez <fperez@colorado.edu>
2116 2004-05-09 Fernando Perez <fperez@colorado.edu>
2107
2117
2108 * IPython/Magic.py (Magic.parse_options): skip system call when
2118 * IPython/Magic.py (Magic.parse_options): skip system call when
2109 there are no options to look for. Faster, cleaner for the common
2119 there are no options to look for. Faster, cleaner for the common
2110 case.
2120 case.
2111
2121
2112 * Documentation: many updates to the manual: describing Windows
2122 * Documentation: many updates to the manual: describing Windows
2113 support better, Gnuplot updates, credits, misc small stuff. Also
2123 support better, Gnuplot updates, credits, misc small stuff. Also
2114 updated the new_design doc a bit.
2124 updated the new_design doc a bit.
2115
2125
2116 2004-05-06 *** Released version 0.6.0.rc1
2126 2004-05-06 *** Released version 0.6.0.rc1
2117
2127
2118 2004-05-06 Fernando Perez <fperez@colorado.edu>
2128 2004-05-06 Fernando Perez <fperez@colorado.edu>
2119
2129
2120 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
2130 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
2121 operations to use the vastly more efficient list/''.join() method.
2131 operations to use the vastly more efficient list/''.join() method.
2122 (FormattedTB.text): Fix
2132 (FormattedTB.text): Fix
2123 http://www.scipy.net/roundup/ipython/issue12 - exception source
2133 http://www.scipy.net/roundup/ipython/issue12 - exception source
2124 extract not updated after reload. Thanks to Mike Salib
2134 extract not updated after reload. Thanks to Mike Salib
2125 <msalib-AT-mit.edu> for pinning the source of the problem.
2135 <msalib-AT-mit.edu> for pinning the source of the problem.
2126 Fortunately, the solution works inside ipython and doesn't require
2136 Fortunately, the solution works inside ipython and doesn't require
2127 any changes to python proper.
2137 any changes to python proper.
2128
2138
2129 * IPython/Magic.py (Magic.parse_options): Improved to process the
2139 * IPython/Magic.py (Magic.parse_options): Improved to process the
2130 argument list as a true shell would (by actually using the
2140 argument list as a true shell would (by actually using the
2131 underlying system shell). This way, all @magics automatically get
2141 underlying system shell). This way, all @magics automatically get
2132 shell expansion for variables. Thanks to a comment by Alex
2142 shell expansion for variables. Thanks to a comment by Alex
2133 Schmolck.
2143 Schmolck.
2134
2144
2135 2004-04-04 Fernando Perez <fperez@colorado.edu>
2145 2004-04-04 Fernando Perez <fperez@colorado.edu>
2136
2146
2137 * IPython/iplib.py (InteractiveShell.interact): Added a special
2147 * IPython/iplib.py (InteractiveShell.interact): Added a special
2138 trap for a debugger quit exception, which is basically impossible
2148 trap for a debugger quit exception, which is basically impossible
2139 to handle by normal mechanisms, given what pdb does to the stack.
2149 to handle by normal mechanisms, given what pdb does to the stack.
2140 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
2150 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
2141
2151
2142 2004-04-03 Fernando Perez <fperez@colorado.edu>
2152 2004-04-03 Fernando Perez <fperez@colorado.edu>
2143
2153
2144 * IPython/genutils.py (Term): Standardized the names of the Term
2154 * IPython/genutils.py (Term): Standardized the names of the Term
2145 class streams to cin/cout/cerr, following C++ naming conventions
2155 class streams to cin/cout/cerr, following C++ naming conventions
2146 (I can't use in/out/err because 'in' is not a valid attribute
2156 (I can't use in/out/err because 'in' is not a valid attribute
2147 name).
2157 name).
2148
2158
2149 * IPython/iplib.py (InteractiveShell.interact): don't increment
2159 * IPython/iplib.py (InteractiveShell.interact): don't increment
2150 the prompt if there's no user input. By Daniel 'Dang' Griffith
2160 the prompt if there's no user input. By Daniel 'Dang' Griffith
2151 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
2161 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
2152 Francois Pinard.
2162 Francois Pinard.
2153
2163
2154 2004-04-02 Fernando Perez <fperez@colorado.edu>
2164 2004-04-02 Fernando Perez <fperez@colorado.edu>
2155
2165
2156 * IPython/genutils.py (Stream.__init__): Modified to survive at
2166 * IPython/genutils.py (Stream.__init__): Modified to survive at
2157 least importing in contexts where stdin/out/err aren't true file
2167 least importing in contexts where stdin/out/err aren't true file
2158 objects, such as PyCrust (they lack fileno() and mode). However,
2168 objects, such as PyCrust (they lack fileno() and mode). However,
2159 the recovery facilities which rely on these things existing will
2169 the recovery facilities which rely on these things existing will
2160 not work.
2170 not work.
2161
2171
2162 2004-04-01 Fernando Perez <fperez@colorado.edu>
2172 2004-04-01 Fernando Perez <fperez@colorado.edu>
2163
2173
2164 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
2174 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
2165 use the new getoutputerror() function, so it properly
2175 use the new getoutputerror() function, so it properly
2166 distinguishes stdout/err.
2176 distinguishes stdout/err.
2167
2177
2168 * IPython/genutils.py (getoutputerror): added a function to
2178 * IPython/genutils.py (getoutputerror): added a function to
2169 capture separately the standard output and error of a command.
2179 capture separately the standard output and error of a command.
2170 After a comment from dang on the mailing lists. This code is
2180 After a comment from dang on the mailing lists. This code is
2171 basically a modified version of commands.getstatusoutput(), from
2181 basically a modified version of commands.getstatusoutput(), from
2172 the standard library.
2182 the standard library.
2173
2183
2174 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
2184 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
2175 '!!' as a special syntax (shorthand) to access @sx.
2185 '!!' as a special syntax (shorthand) to access @sx.
2176
2186
2177 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
2187 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
2178 command and return its output as a list split on '\n'.
2188 command and return its output as a list split on '\n'.
2179
2189
2180 2004-03-31 Fernando Perez <fperez@colorado.edu>
2190 2004-03-31 Fernando Perez <fperez@colorado.edu>
2181
2191
2182 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
2192 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
2183 method to dictionaries used as FakeModule instances if they lack
2193 method to dictionaries used as FakeModule instances if they lack
2184 it. At least pydoc in python2.3 breaks for runtime-defined
2194 it. At least pydoc in python2.3 breaks for runtime-defined
2185 functions without this hack. At some point I need to _really_
2195 functions without this hack. At some point I need to _really_
2186 understand what FakeModule is doing, because it's a gross hack.
2196 understand what FakeModule is doing, because it's a gross hack.
2187 But it solves Arnd's problem for now...
2197 But it solves Arnd's problem for now...
2188
2198
2189 2004-02-27 Fernando Perez <fperez@colorado.edu>
2199 2004-02-27 Fernando Perez <fperez@colorado.edu>
2190
2200
2191 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
2201 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
2192 mode would behave erratically. Also increased the number of
2202 mode would behave erratically. Also increased the number of
2193 possible logs in rotate mod to 999. Thanks to Rod Holland
2203 possible logs in rotate mod to 999. Thanks to Rod Holland
2194 <rhh@StructureLABS.com> for the report and fixes.
2204 <rhh@StructureLABS.com> for the report and fixes.
2195
2205
2196 2004-02-26 Fernando Perez <fperez@colorado.edu>
2206 2004-02-26 Fernando Perez <fperez@colorado.edu>
2197
2207
2198 * IPython/genutils.py (page): Check that the curses module really
2208 * IPython/genutils.py (page): Check that the curses module really
2199 has the initscr attribute before trying to use it. For some
2209 has the initscr attribute before trying to use it. For some
2200 reason, the Solaris curses module is missing this. I think this
2210 reason, the Solaris curses module is missing this. I think this
2201 should be considered a Solaris python bug, but I'm not sure.
2211 should be considered a Solaris python bug, but I'm not sure.
2202
2212
2203 2004-01-17 Fernando Perez <fperez@colorado.edu>
2213 2004-01-17 Fernando Perez <fperez@colorado.edu>
2204
2214
2205 * IPython/genutils.py (Stream.__init__): Changes to try to make
2215 * IPython/genutils.py (Stream.__init__): Changes to try to make
2206 ipython robust against stdin/out/err being closed by the user.
2216 ipython robust against stdin/out/err being closed by the user.
2207 This is 'user error' (and blocks a normal python session, at least
2217 This is 'user error' (and blocks a normal python session, at least
2208 the stdout case). However, Ipython should be able to survive such
2218 the stdout case). However, Ipython should be able to survive such
2209 instances of abuse as gracefully as possible. To simplify the
2219 instances of abuse as gracefully as possible. To simplify the
2210 coding and maintain compatibility with Gary Bishop's Term
2220 coding and maintain compatibility with Gary Bishop's Term
2211 contributions, I've made use of classmethods for this. I think
2221 contributions, I've made use of classmethods for this. I think
2212 this introduces a dependency on python 2.2.
2222 this introduces a dependency on python 2.2.
2213
2223
2214 2004-01-13 Fernando Perez <fperez@colorado.edu>
2224 2004-01-13 Fernando Perez <fperez@colorado.edu>
2215
2225
2216 * IPython/numutils.py (exp_safe): simplified the code a bit and
2226 * IPython/numutils.py (exp_safe): simplified the code a bit and
2217 removed the need for importing the kinds module altogether.
2227 removed the need for importing the kinds module altogether.
2218
2228
2219 2004-01-06 Fernando Perez <fperez@colorado.edu>
2229 2004-01-06 Fernando Perez <fperez@colorado.edu>
2220
2230
2221 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
2231 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
2222 a magic function instead, after some community feedback. No
2232 a magic function instead, after some community feedback. No
2223 special syntax will exist for it, but its name is deliberately
2233 special syntax will exist for it, but its name is deliberately
2224 very short.
2234 very short.
2225
2235
2226 2003-12-20 Fernando Perez <fperez@colorado.edu>
2236 2003-12-20 Fernando Perez <fperez@colorado.edu>
2227
2237
2228 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
2238 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
2229 new functionality, to automagically assign the result of a shell
2239 new functionality, to automagically assign the result of a shell
2230 command to a variable. I'll solicit some community feedback on
2240 command to a variable. I'll solicit some community feedback on
2231 this before making it permanent.
2241 this before making it permanent.
2232
2242
2233 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
2243 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
2234 requested about callables for which inspect couldn't obtain a
2244 requested about callables for which inspect couldn't obtain a
2235 proper argspec. Thanks to a crash report sent by Etienne
2245 proper argspec. Thanks to a crash report sent by Etienne
2236 Posthumus <etienne-AT-apple01.cs.vu.nl>.
2246 Posthumus <etienne-AT-apple01.cs.vu.nl>.
2237
2247
2238 2003-12-09 Fernando Perez <fperez@colorado.edu>
2248 2003-12-09 Fernando Perez <fperez@colorado.edu>
2239
2249
2240 * IPython/genutils.py (page): patch for the pager to work across
2250 * IPython/genutils.py (page): patch for the pager to work across
2241 various versions of Windows. By Gary Bishop.
2251 various versions of Windows. By Gary Bishop.
2242
2252
2243 2003-12-04 Fernando Perez <fperez@colorado.edu>
2253 2003-12-04 Fernando Perez <fperez@colorado.edu>
2244
2254
2245 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
2255 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
2246 Gnuplot.py version 1.7, whose internal names changed quite a bit.
2256 Gnuplot.py version 1.7, whose internal names changed quite a bit.
2247 While I tested this and it looks ok, there may still be corner
2257 While I tested this and it looks ok, there may still be corner
2248 cases I've missed.
2258 cases I've missed.
2249
2259
2250 2003-12-01 Fernando Perez <fperez@colorado.edu>
2260 2003-12-01 Fernando Perez <fperez@colorado.edu>
2251
2261
2252 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
2262 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
2253 where a line like 'p,q=1,2' would fail because the automagic
2263 where a line like 'p,q=1,2' would fail because the automagic
2254 system would be triggered for @p.
2264 system would be triggered for @p.
2255
2265
2256 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
2266 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
2257 cleanups, code unmodified.
2267 cleanups, code unmodified.
2258
2268
2259 * IPython/genutils.py (Term): added a class for IPython to handle
2269 * IPython/genutils.py (Term): added a class for IPython to handle
2260 output. In most cases it will just be a proxy for stdout/err, but
2270 output. In most cases it will just be a proxy for stdout/err, but
2261 having this allows modifications to be made for some platforms,
2271 having this allows modifications to be made for some platforms,
2262 such as handling color escapes under Windows. All of this code
2272 such as handling color escapes under Windows. All of this code
2263 was contributed by Gary Bishop, with minor modifications by me.
2273 was contributed by Gary Bishop, with minor modifications by me.
2264 The actual changes affect many files.
2274 The actual changes affect many files.
2265
2275
2266 2003-11-30 Fernando Perez <fperez@colorado.edu>
2276 2003-11-30 Fernando Perez <fperez@colorado.edu>
2267
2277
2268 * IPython/iplib.py (file_matches): new completion code, courtesy
2278 * IPython/iplib.py (file_matches): new completion code, courtesy
2269 of Jeff Collins. This enables filename completion again under
2279 of Jeff Collins. This enables filename completion again under
2270 python 2.3, which disabled it at the C level.
2280 python 2.3, which disabled it at the C level.
2271
2281
2272 2003-11-11 Fernando Perez <fperez@colorado.edu>
2282 2003-11-11 Fernando Perez <fperez@colorado.edu>
2273
2283
2274 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
2284 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
2275 for Numeric.array(map(...)), but often convenient.
2285 for Numeric.array(map(...)), but often convenient.
2276
2286
2277 2003-11-05 Fernando Perez <fperez@colorado.edu>
2287 2003-11-05 Fernando Perez <fperez@colorado.edu>
2278
2288
2279 * IPython/numutils.py (frange): Changed a call from int() to
2289 * IPython/numutils.py (frange): Changed a call from int() to
2280 int(round()) to prevent a problem reported with arange() in the
2290 int(round()) to prevent a problem reported with arange() in the
2281 numpy list.
2291 numpy list.
2282
2292
2283 2003-10-06 Fernando Perez <fperez@colorado.edu>
2293 2003-10-06 Fernando Perez <fperez@colorado.edu>
2284
2294
2285 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
2295 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
2286 prevent crashes if sys lacks an argv attribute (it happens with
2296 prevent crashes if sys lacks an argv attribute (it happens with
2287 embedded interpreters which build a bare-bones sys module).
2297 embedded interpreters which build a bare-bones sys module).
2288 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
2298 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
2289
2299
2290 2003-09-24 Fernando Perez <fperez@colorado.edu>
2300 2003-09-24 Fernando Perez <fperez@colorado.edu>
2291
2301
2292 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
2302 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
2293 to protect against poorly written user objects where __getattr__
2303 to protect against poorly written user objects where __getattr__
2294 raises exceptions other than AttributeError. Thanks to a bug
2304 raises exceptions other than AttributeError. Thanks to a bug
2295 report by Oliver Sander <osander-AT-gmx.de>.
2305 report by Oliver Sander <osander-AT-gmx.de>.
2296
2306
2297 * IPython/FakeModule.py (FakeModule.__repr__): this method was
2307 * IPython/FakeModule.py (FakeModule.__repr__): this method was
2298 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
2308 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
2299
2309
2300 2003-09-09 Fernando Perez <fperez@colorado.edu>
2310 2003-09-09 Fernando Perez <fperez@colorado.edu>
2301
2311
2302 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2312 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2303 unpacking a list whith a callable as first element would
2313 unpacking a list whith a callable as first element would
2304 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
2314 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
2305 Collins.
2315 Collins.
2306
2316
2307 2003-08-25 *** Released version 0.5.0
2317 2003-08-25 *** Released version 0.5.0
2308
2318
2309 2003-08-22 Fernando Perez <fperez@colorado.edu>
2319 2003-08-22 Fernando Perez <fperez@colorado.edu>
2310
2320
2311 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
2321 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
2312 improperly defined user exceptions. Thanks to feedback from Mark
2322 improperly defined user exceptions. Thanks to feedback from Mark
2313 Russell <mrussell-AT-verio.net>.
2323 Russell <mrussell-AT-verio.net>.
2314
2324
2315 2003-08-20 Fernando Perez <fperez@colorado.edu>
2325 2003-08-20 Fernando Perez <fperez@colorado.edu>
2316
2326
2317 * IPython/OInspect.py (Inspector.pinfo): changed String Form
2327 * IPython/OInspect.py (Inspector.pinfo): changed String Form
2318 printing so that it would print multi-line string forms starting
2328 printing so that it would print multi-line string forms starting
2319 with a new line. This way the formatting is better respected for
2329 with a new line. This way the formatting is better respected for
2320 objects which work hard to make nice string forms.
2330 objects which work hard to make nice string forms.
2321
2331
2322 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
2332 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
2323 autocall would overtake data access for objects with both
2333 autocall would overtake data access for objects with both
2324 __getitem__ and __call__.
2334 __getitem__ and __call__.
2325
2335
2326 2003-08-19 *** Released version 0.5.0-rc1
2336 2003-08-19 *** Released version 0.5.0-rc1
2327
2337
2328 2003-08-19 Fernando Perez <fperez@colorado.edu>
2338 2003-08-19 Fernando Perez <fperez@colorado.edu>
2329
2339
2330 * IPython/deep_reload.py (load_tail): single tiny change here
2340 * IPython/deep_reload.py (load_tail): single tiny change here
2331 seems to fix the long-standing bug of dreload() failing to work
2341 seems to fix the long-standing bug of dreload() failing to work
2332 for dotted names. But this module is pretty tricky, so I may have
2342 for dotted names. But this module is pretty tricky, so I may have
2333 missed some subtlety. Needs more testing!.
2343 missed some subtlety. Needs more testing!.
2334
2344
2335 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
2345 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
2336 exceptions which have badly implemented __str__ methods.
2346 exceptions which have badly implemented __str__ methods.
2337 (VerboseTB.text): harden against inspect.getinnerframes crashing,
2347 (VerboseTB.text): harden against inspect.getinnerframes crashing,
2338 which I've been getting reports about from Python 2.3 users. I
2348 which I've been getting reports about from Python 2.3 users. I
2339 wish I had a simple test case to reproduce the problem, so I could
2349 wish I had a simple test case to reproduce the problem, so I could
2340 either write a cleaner workaround or file a bug report if
2350 either write a cleaner workaround or file a bug report if
2341 necessary.
2351 necessary.
2342
2352
2343 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
2353 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
2344 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
2354 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
2345 a bug report by Tjabo Kloppenburg.
2355 a bug report by Tjabo Kloppenburg.
2346
2356
2347 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
2357 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
2348 crashes. Wrapped the pdb call in a blanket try/except, since pdb
2358 crashes. Wrapped the pdb call in a blanket try/except, since pdb
2349 seems rather unstable. Thanks to a bug report by Tjabo
2359 seems rather unstable. Thanks to a bug report by Tjabo
2350 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
2360 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
2351
2361
2352 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
2362 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
2353 this out soon because of the critical fixes in the inner loop for
2363 this out soon because of the critical fixes in the inner loop for
2354 generators.
2364 generators.
2355
2365
2356 * IPython/Magic.py (Magic.getargspec): removed. This (and
2366 * IPython/Magic.py (Magic.getargspec): removed. This (and
2357 _get_def) have been obsoleted by OInspect for a long time, I
2367 _get_def) have been obsoleted by OInspect for a long time, I
2358 hadn't noticed that they were dead code.
2368 hadn't noticed that they were dead code.
2359 (Magic._ofind): restored _ofind functionality for a few literals
2369 (Magic._ofind): restored _ofind functionality for a few literals
2360 (those in ["''",'""','[]','{}','()']). But it won't work anymore
2370 (those in ["''",'""','[]','{}','()']). But it won't work anymore
2361 for things like "hello".capitalize?, since that would require a
2371 for things like "hello".capitalize?, since that would require a
2362 potentially dangerous eval() again.
2372 potentially dangerous eval() again.
2363
2373
2364 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
2374 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
2365 logic a bit more to clean up the escapes handling and minimize the
2375 logic a bit more to clean up the escapes handling and minimize the
2366 use of _ofind to only necessary cases. The interactive 'feel' of
2376 use of _ofind to only necessary cases. The interactive 'feel' of
2367 IPython should have improved quite a bit with the changes in
2377 IPython should have improved quite a bit with the changes in
2368 _prefilter and _ofind (besides being far safer than before).
2378 _prefilter and _ofind (besides being far safer than before).
2369
2379
2370 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
2380 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
2371 obscure, never reported). Edit would fail to find the object to
2381 obscure, never reported). Edit would fail to find the object to
2372 edit under some circumstances.
2382 edit under some circumstances.
2373 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
2383 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
2374 which were causing double-calling of generators. Those eval calls
2384 which were causing double-calling of generators. Those eval calls
2375 were _very_ dangerous, since code with side effects could be
2385 were _very_ dangerous, since code with side effects could be
2376 triggered. As they say, 'eval is evil'... These were the
2386 triggered. As they say, 'eval is evil'... These were the
2377 nastiest evals in IPython. Besides, _ofind is now far simpler,
2387 nastiest evals in IPython. Besides, _ofind is now far simpler,
2378 and it should also be quite a bit faster. Its use of inspect is
2388 and it should also be quite a bit faster. Its use of inspect is
2379 also safer, so perhaps some of the inspect-related crashes I've
2389 also safer, so perhaps some of the inspect-related crashes I've
2380 seen lately with Python 2.3 might be taken care of. That will
2390 seen lately with Python 2.3 might be taken care of. That will
2381 need more testing.
2391 need more testing.
2382
2392
2383 2003-08-17 Fernando Perez <fperez@colorado.edu>
2393 2003-08-17 Fernando Perez <fperez@colorado.edu>
2384
2394
2385 * IPython/iplib.py (InteractiveShell._prefilter): significant
2395 * IPython/iplib.py (InteractiveShell._prefilter): significant
2386 simplifications to the logic for handling user escapes. Faster
2396 simplifications to the logic for handling user escapes. Faster
2387 and simpler code.
2397 and simpler code.
2388
2398
2389 2003-08-14 Fernando Perez <fperez@colorado.edu>
2399 2003-08-14 Fernando Perez <fperez@colorado.edu>
2390
2400
2391 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
2401 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
2392 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
2402 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
2393 but it should be quite a bit faster. And the recursive version
2403 but it should be quite a bit faster. And the recursive version
2394 generated O(log N) intermediate storage for all rank>1 arrays,
2404 generated O(log N) intermediate storage for all rank>1 arrays,
2395 even if they were contiguous.
2405 even if they were contiguous.
2396 (l1norm): Added this function.
2406 (l1norm): Added this function.
2397 (norm): Added this function for arbitrary norms (including
2407 (norm): Added this function for arbitrary norms (including
2398 l-infinity). l1 and l2 are still special cases for convenience
2408 l-infinity). l1 and l2 are still special cases for convenience
2399 and speed.
2409 and speed.
2400
2410
2401 2003-08-03 Fernando Perez <fperez@colorado.edu>
2411 2003-08-03 Fernando Perez <fperez@colorado.edu>
2402
2412
2403 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
2413 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
2404 exceptions, which now raise PendingDeprecationWarnings in Python
2414 exceptions, which now raise PendingDeprecationWarnings in Python
2405 2.3. There were some in Magic and some in Gnuplot2.
2415 2.3. There were some in Magic and some in Gnuplot2.
2406
2416
2407 2003-06-30 Fernando Perez <fperez@colorado.edu>
2417 2003-06-30 Fernando Perez <fperez@colorado.edu>
2408
2418
2409 * IPython/genutils.py (page): modified to call curses only for
2419 * IPython/genutils.py (page): modified to call curses only for
2410 terminals where TERM=='xterm'. After problems under many other
2420 terminals where TERM=='xterm'. After problems under many other
2411 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2421 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2412
2422
2413 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2423 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2414 would be triggered when readline was absent. This was just an old
2424 would be triggered when readline was absent. This was just an old
2415 debugging statement I'd forgotten to take out.
2425 debugging statement I'd forgotten to take out.
2416
2426
2417 2003-06-20 Fernando Perez <fperez@colorado.edu>
2427 2003-06-20 Fernando Perez <fperez@colorado.edu>
2418
2428
2419 * IPython/genutils.py (clock): modified to return only user time
2429 * IPython/genutils.py (clock): modified to return only user time
2420 (not counting system time), after a discussion on scipy. While
2430 (not counting system time), after a discussion on scipy. While
2421 system time may be a useful quantity occasionally, it may much
2431 system time may be a useful quantity occasionally, it may much
2422 more easily be skewed by occasional swapping or other similar
2432 more easily be skewed by occasional swapping or other similar
2423 activity.
2433 activity.
2424
2434
2425 2003-06-05 Fernando Perez <fperez@colorado.edu>
2435 2003-06-05 Fernando Perez <fperez@colorado.edu>
2426
2436
2427 * IPython/numutils.py (identity): new function, for building
2437 * IPython/numutils.py (identity): new function, for building
2428 arbitrary rank Kronecker deltas (mostly backwards compatible with
2438 arbitrary rank Kronecker deltas (mostly backwards compatible with
2429 Numeric.identity)
2439 Numeric.identity)
2430
2440
2431 2003-06-03 Fernando Perez <fperez@colorado.edu>
2441 2003-06-03 Fernando Perez <fperez@colorado.edu>
2432
2442
2433 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2443 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2434 arguments passed to magics with spaces, to allow trailing '\' to
2444 arguments passed to magics with spaces, to allow trailing '\' to
2435 work normally (mainly for Windows users).
2445 work normally (mainly for Windows users).
2436
2446
2437 2003-05-29 Fernando Perez <fperez@colorado.edu>
2447 2003-05-29 Fernando Perez <fperez@colorado.edu>
2438
2448
2439 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2449 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2440 instead of pydoc.help. This fixes a bizarre behavior where
2450 instead of pydoc.help. This fixes a bizarre behavior where
2441 printing '%s' % locals() would trigger the help system. Now
2451 printing '%s' % locals() would trigger the help system. Now
2442 ipython behaves like normal python does.
2452 ipython behaves like normal python does.
2443
2453
2444 Note that if one does 'from pydoc import help', the bizarre
2454 Note that if one does 'from pydoc import help', the bizarre
2445 behavior returns, but this will also happen in normal python, so
2455 behavior returns, but this will also happen in normal python, so
2446 it's not an ipython bug anymore (it has to do with how pydoc.help
2456 it's not an ipython bug anymore (it has to do with how pydoc.help
2447 is implemented).
2457 is implemented).
2448
2458
2449 2003-05-22 Fernando Perez <fperez@colorado.edu>
2459 2003-05-22 Fernando Perez <fperez@colorado.edu>
2450
2460
2451 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2461 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2452 return [] instead of None when nothing matches, also match to end
2462 return [] instead of None when nothing matches, also match to end
2453 of line. Patch by Gary Bishop.
2463 of line. Patch by Gary Bishop.
2454
2464
2455 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2465 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2456 protection as before, for files passed on the command line. This
2466 protection as before, for files passed on the command line. This
2457 prevents the CrashHandler from kicking in if user files call into
2467 prevents the CrashHandler from kicking in if user files call into
2458 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2468 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2459 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2469 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2460
2470
2461 2003-05-20 *** Released version 0.4.0
2471 2003-05-20 *** Released version 0.4.0
2462
2472
2463 2003-05-20 Fernando Perez <fperez@colorado.edu>
2473 2003-05-20 Fernando Perez <fperez@colorado.edu>
2464
2474
2465 * setup.py: added support for manpages. It's a bit hackish b/c of
2475 * setup.py: added support for manpages. It's a bit hackish b/c of
2466 a bug in the way the bdist_rpm distutils target handles gzipped
2476 a bug in the way the bdist_rpm distutils target handles gzipped
2467 manpages, but it works. After a patch by Jack.
2477 manpages, but it works. After a patch by Jack.
2468
2478
2469 2003-05-19 Fernando Perez <fperez@colorado.edu>
2479 2003-05-19 Fernando Perez <fperez@colorado.edu>
2470
2480
2471 * IPython/numutils.py: added a mockup of the kinds module, since
2481 * IPython/numutils.py: added a mockup of the kinds module, since
2472 it was recently removed from Numeric. This way, numutils will
2482 it was recently removed from Numeric. This way, numutils will
2473 work for all users even if they are missing kinds.
2483 work for all users even if they are missing kinds.
2474
2484
2475 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2485 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2476 failure, which can occur with SWIG-wrapped extensions. After a
2486 failure, which can occur with SWIG-wrapped extensions. After a
2477 crash report from Prabhu.
2487 crash report from Prabhu.
2478
2488
2479 2003-05-16 Fernando Perez <fperez@colorado.edu>
2489 2003-05-16 Fernando Perez <fperez@colorado.edu>
2480
2490
2481 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2491 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2482 protect ipython from user code which may call directly
2492 protect ipython from user code which may call directly
2483 sys.excepthook (this looks like an ipython crash to the user, even
2493 sys.excepthook (this looks like an ipython crash to the user, even
2484 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2494 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2485 This is especially important to help users of WxWindows, but may
2495 This is especially important to help users of WxWindows, but may
2486 also be useful in other cases.
2496 also be useful in other cases.
2487
2497
2488 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2498 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2489 an optional tb_offset to be specified, and to preserve exception
2499 an optional tb_offset to be specified, and to preserve exception
2490 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2500 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2491
2501
2492 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2502 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2493
2503
2494 2003-05-15 Fernando Perez <fperez@colorado.edu>
2504 2003-05-15 Fernando Perez <fperez@colorado.edu>
2495
2505
2496 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2506 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2497 installing for a new user under Windows.
2507 installing for a new user under Windows.
2498
2508
2499 2003-05-12 Fernando Perez <fperez@colorado.edu>
2509 2003-05-12 Fernando Perez <fperez@colorado.edu>
2500
2510
2501 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2511 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2502 handler for Emacs comint-based lines. Currently it doesn't do
2512 handler for Emacs comint-based lines. Currently it doesn't do
2503 much (but importantly, it doesn't update the history cache). In
2513 much (but importantly, it doesn't update the history cache). In
2504 the future it may be expanded if Alex needs more functionality
2514 the future it may be expanded if Alex needs more functionality
2505 there.
2515 there.
2506
2516
2507 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2517 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2508 info to crash reports.
2518 info to crash reports.
2509
2519
2510 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2520 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2511 just like Python's -c. Also fixed crash with invalid -color
2521 just like Python's -c. Also fixed crash with invalid -color
2512 option value at startup. Thanks to Will French
2522 option value at startup. Thanks to Will French
2513 <wfrench-AT-bestweb.net> for the bug report.
2523 <wfrench-AT-bestweb.net> for the bug report.
2514
2524
2515 2003-05-09 Fernando Perez <fperez@colorado.edu>
2525 2003-05-09 Fernando Perez <fperez@colorado.edu>
2516
2526
2517 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2527 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2518 to EvalDict (it's a mapping, after all) and simplified its code
2528 to EvalDict (it's a mapping, after all) and simplified its code
2519 quite a bit, after a nice discussion on c.l.py where Gustavo
2529 quite a bit, after a nice discussion on c.l.py where Gustavo
2520 Córdova <gcordova-AT-sismex.com> suggested the new version.
2530 Córdova <gcordova-AT-sismex.com> suggested the new version.
2521
2531
2522 2003-04-30 Fernando Perez <fperez@colorado.edu>
2532 2003-04-30 Fernando Perez <fperez@colorado.edu>
2523
2533
2524 * IPython/genutils.py (timings_out): modified it to reduce its
2534 * IPython/genutils.py (timings_out): modified it to reduce its
2525 overhead in the common reps==1 case.
2535 overhead in the common reps==1 case.
2526
2536
2527 2003-04-29 Fernando Perez <fperez@colorado.edu>
2537 2003-04-29 Fernando Perez <fperez@colorado.edu>
2528
2538
2529 * IPython/genutils.py (timings_out): Modified to use the resource
2539 * IPython/genutils.py (timings_out): Modified to use the resource
2530 module, which avoids the wraparound problems of time.clock().
2540 module, which avoids the wraparound problems of time.clock().
2531
2541
2532 2003-04-17 *** Released version 0.2.15pre4
2542 2003-04-17 *** Released version 0.2.15pre4
2533
2543
2534 2003-04-17 Fernando Perez <fperez@colorado.edu>
2544 2003-04-17 Fernando Perez <fperez@colorado.edu>
2535
2545
2536 * setup.py (scriptfiles): Split windows-specific stuff over to a
2546 * setup.py (scriptfiles): Split windows-specific stuff over to a
2537 separate file, in an attempt to have a Windows GUI installer.
2547 separate file, in an attempt to have a Windows GUI installer.
2538 That didn't work, but part of the groundwork is done.
2548 That didn't work, but part of the groundwork is done.
2539
2549
2540 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2550 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2541 indent/unindent with 4 spaces. Particularly useful in combination
2551 indent/unindent with 4 spaces. Particularly useful in combination
2542 with the new auto-indent option.
2552 with the new auto-indent option.
2543
2553
2544 2003-04-16 Fernando Perez <fperez@colorado.edu>
2554 2003-04-16 Fernando Perez <fperez@colorado.edu>
2545
2555
2546 * IPython/Magic.py: various replacements of self.rc for
2556 * IPython/Magic.py: various replacements of self.rc for
2547 self.shell.rc. A lot more remains to be done to fully disentangle
2557 self.shell.rc. A lot more remains to be done to fully disentangle
2548 this class from the main Shell class.
2558 this class from the main Shell class.
2549
2559
2550 * IPython/GnuplotRuntime.py: added checks for mouse support so
2560 * IPython/GnuplotRuntime.py: added checks for mouse support so
2551 that we don't try to enable it if the current gnuplot doesn't
2561 that we don't try to enable it if the current gnuplot doesn't
2552 really support it. Also added checks so that we don't try to
2562 really support it. Also added checks so that we don't try to
2553 enable persist under Windows (where Gnuplot doesn't recognize the
2563 enable persist under Windows (where Gnuplot doesn't recognize the
2554 option).
2564 option).
2555
2565
2556 * IPython/iplib.py (InteractiveShell.interact): Added optional
2566 * IPython/iplib.py (InteractiveShell.interact): Added optional
2557 auto-indenting code, after a patch by King C. Shu
2567 auto-indenting code, after a patch by King C. Shu
2558 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2568 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2559 get along well with pasting indented code. If I ever figure out
2569 get along well with pasting indented code. If I ever figure out
2560 how to make that part go well, it will become on by default.
2570 how to make that part go well, it will become on by default.
2561
2571
2562 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2572 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2563 crash ipython if there was an unmatched '%' in the user's prompt
2573 crash ipython if there was an unmatched '%' in the user's prompt
2564 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2574 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2565
2575
2566 * IPython/iplib.py (InteractiveShell.interact): removed the
2576 * IPython/iplib.py (InteractiveShell.interact): removed the
2567 ability to ask the user whether he wants to crash or not at the
2577 ability to ask the user whether he wants to crash or not at the
2568 'last line' exception handler. Calling functions at that point
2578 'last line' exception handler. Calling functions at that point
2569 changes the stack, and the error reports would have incorrect
2579 changes the stack, and the error reports would have incorrect
2570 tracebacks.
2580 tracebacks.
2571
2581
2572 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2582 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2573 pass through a peger a pretty-printed form of any object. After a
2583 pass through a peger a pretty-printed form of any object. After a
2574 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2584 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2575
2585
2576 2003-04-14 Fernando Perez <fperez@colorado.edu>
2586 2003-04-14 Fernando Perez <fperez@colorado.edu>
2577
2587
2578 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2588 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2579 all files in ~ would be modified at first install (instead of
2589 all files in ~ would be modified at first install (instead of
2580 ~/.ipython). This could be potentially disastrous, as the
2590 ~/.ipython). This could be potentially disastrous, as the
2581 modification (make line-endings native) could damage binary files.
2591 modification (make line-endings native) could damage binary files.
2582
2592
2583 2003-04-10 Fernando Perez <fperez@colorado.edu>
2593 2003-04-10 Fernando Perez <fperez@colorado.edu>
2584
2594
2585 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2595 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2586 handle only lines which are invalid python. This now means that
2596 handle only lines which are invalid python. This now means that
2587 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2597 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2588 for the bug report.
2598 for the bug report.
2589
2599
2590 2003-04-01 Fernando Perez <fperez@colorado.edu>
2600 2003-04-01 Fernando Perez <fperez@colorado.edu>
2591
2601
2592 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2602 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2593 where failing to set sys.last_traceback would crash pdb.pm().
2603 where failing to set sys.last_traceback would crash pdb.pm().
2594 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2604 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2595 report.
2605 report.
2596
2606
2597 2003-03-25 Fernando Perez <fperez@colorado.edu>
2607 2003-03-25 Fernando Perez <fperez@colorado.edu>
2598
2608
2599 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2609 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2600 before printing it (it had a lot of spurious blank lines at the
2610 before printing it (it had a lot of spurious blank lines at the
2601 end).
2611 end).
2602
2612
2603 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2613 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2604 output would be sent 21 times! Obviously people don't use this
2614 output would be sent 21 times! Obviously people don't use this
2605 too often, or I would have heard about it.
2615 too often, or I would have heard about it.
2606
2616
2607 2003-03-24 Fernando Perez <fperez@colorado.edu>
2617 2003-03-24 Fernando Perez <fperez@colorado.edu>
2608
2618
2609 * setup.py (scriptfiles): renamed the data_files parameter from
2619 * setup.py (scriptfiles): renamed the data_files parameter from
2610 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2620 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2611 for the patch.
2621 for the patch.
2612
2622
2613 2003-03-20 Fernando Perez <fperez@colorado.edu>
2623 2003-03-20 Fernando Perez <fperez@colorado.edu>
2614
2624
2615 * IPython/genutils.py (error): added error() and fatal()
2625 * IPython/genutils.py (error): added error() and fatal()
2616 functions.
2626 functions.
2617
2627
2618 2003-03-18 *** Released version 0.2.15pre3
2628 2003-03-18 *** Released version 0.2.15pre3
2619
2629
2620 2003-03-18 Fernando Perez <fperez@colorado.edu>
2630 2003-03-18 Fernando Perez <fperez@colorado.edu>
2621
2631
2622 * setupext/install_data_ext.py
2632 * setupext/install_data_ext.py
2623 (install_data_ext.initialize_options): Class contributed by Jack
2633 (install_data_ext.initialize_options): Class contributed by Jack
2624 Moffit for fixing the old distutils hack. He is sending this to
2634 Moffit for fixing the old distutils hack. He is sending this to
2625 the distutils folks so in the future we may not need it as a
2635 the distutils folks so in the future we may not need it as a
2626 private fix.
2636 private fix.
2627
2637
2628 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2638 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2629 changes for Debian packaging. See his patch for full details.
2639 changes for Debian packaging. See his patch for full details.
2630 The old distutils hack of making the ipythonrc* files carry a
2640 The old distutils hack of making the ipythonrc* files carry a
2631 bogus .py extension is gone, at last. Examples were moved to a
2641 bogus .py extension is gone, at last. Examples were moved to a
2632 separate subdir under doc/, and the separate executable scripts
2642 separate subdir under doc/, and the separate executable scripts
2633 now live in their own directory. Overall a great cleanup. The
2643 now live in their own directory. Overall a great cleanup. The
2634 manual was updated to use the new files, and setup.py has been
2644 manual was updated to use the new files, and setup.py has been
2635 fixed for this setup.
2645 fixed for this setup.
2636
2646
2637 * IPython/PyColorize.py (Parser.usage): made non-executable and
2647 * IPython/PyColorize.py (Parser.usage): made non-executable and
2638 created a pycolor wrapper around it to be included as a script.
2648 created a pycolor wrapper around it to be included as a script.
2639
2649
2640 2003-03-12 *** Released version 0.2.15pre2
2650 2003-03-12 *** Released version 0.2.15pre2
2641
2651
2642 2003-03-12 Fernando Perez <fperez@colorado.edu>
2652 2003-03-12 Fernando Perez <fperez@colorado.edu>
2643
2653
2644 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2654 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2645 long-standing problem with garbage characters in some terminals.
2655 long-standing problem with garbage characters in some terminals.
2646 The issue was really that the \001 and \002 escapes must _only_ be
2656 The issue was really that the \001 and \002 escapes must _only_ be
2647 passed to input prompts (which call readline), but _never_ to
2657 passed to input prompts (which call readline), but _never_ to
2648 normal text to be printed on screen. I changed ColorANSI to have
2658 normal text to be printed on screen. I changed ColorANSI to have
2649 two classes: TermColors and InputTermColors, each with the
2659 two classes: TermColors and InputTermColors, each with the
2650 appropriate escapes for input prompts or normal text. The code in
2660 appropriate escapes for input prompts or normal text. The code in
2651 Prompts.py got slightly more complicated, but this very old and
2661 Prompts.py got slightly more complicated, but this very old and
2652 annoying bug is finally fixed.
2662 annoying bug is finally fixed.
2653
2663
2654 All the credit for nailing down the real origin of this problem
2664 All the credit for nailing down the real origin of this problem
2655 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2665 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2656 *Many* thanks to him for spending quite a bit of effort on this.
2666 *Many* thanks to him for spending quite a bit of effort on this.
2657
2667
2658 2003-03-05 *** Released version 0.2.15pre1
2668 2003-03-05 *** Released version 0.2.15pre1
2659
2669
2660 2003-03-03 Fernando Perez <fperez@colorado.edu>
2670 2003-03-03 Fernando Perez <fperez@colorado.edu>
2661
2671
2662 * IPython/FakeModule.py: Moved the former _FakeModule to a
2672 * IPython/FakeModule.py: Moved the former _FakeModule to a
2663 separate file, because it's also needed by Magic (to fix a similar
2673 separate file, because it's also needed by Magic (to fix a similar
2664 pickle-related issue in @run).
2674 pickle-related issue in @run).
2665
2675
2666 2003-03-02 Fernando Perez <fperez@colorado.edu>
2676 2003-03-02 Fernando Perez <fperez@colorado.edu>
2667
2677
2668 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2678 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2669 the autocall option at runtime.
2679 the autocall option at runtime.
2670 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2680 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2671 across Magic.py to start separating Magic from InteractiveShell.
2681 across Magic.py to start separating Magic from InteractiveShell.
2672 (Magic._ofind): Fixed to return proper namespace for dotted
2682 (Magic._ofind): Fixed to return proper namespace for dotted
2673 names. Before, a dotted name would always return 'not currently
2683 names. Before, a dotted name would always return 'not currently
2674 defined', because it would find the 'parent'. s.x would be found,
2684 defined', because it would find the 'parent'. s.x would be found,
2675 but since 'x' isn't defined by itself, it would get confused.
2685 but since 'x' isn't defined by itself, it would get confused.
2676 (Magic.magic_run): Fixed pickling problems reported by Ralf
2686 (Magic.magic_run): Fixed pickling problems reported by Ralf
2677 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2687 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2678 that I'd used when Mike Heeter reported similar issues at the
2688 that I'd used when Mike Heeter reported similar issues at the
2679 top-level, but now for @run. It boils down to injecting the
2689 top-level, but now for @run. It boils down to injecting the
2680 namespace where code is being executed with something that looks
2690 namespace where code is being executed with something that looks
2681 enough like a module to fool pickle.dump(). Since a pickle stores
2691 enough like a module to fool pickle.dump(). Since a pickle stores
2682 a named reference to the importing module, we need this for
2692 a named reference to the importing module, we need this for
2683 pickles to save something sensible.
2693 pickles to save something sensible.
2684
2694
2685 * IPython/ipmaker.py (make_IPython): added an autocall option.
2695 * IPython/ipmaker.py (make_IPython): added an autocall option.
2686
2696
2687 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2697 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2688 the auto-eval code. Now autocalling is an option, and the code is
2698 the auto-eval code. Now autocalling is an option, and the code is
2689 also vastly safer. There is no more eval() involved at all.
2699 also vastly safer. There is no more eval() involved at all.
2690
2700
2691 2003-03-01 Fernando Perez <fperez@colorado.edu>
2701 2003-03-01 Fernando Perez <fperez@colorado.edu>
2692
2702
2693 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2703 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2694 dict with named keys instead of a tuple.
2704 dict with named keys instead of a tuple.
2695
2705
2696 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2706 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2697
2707
2698 * setup.py (make_shortcut): Fixed message about directories
2708 * setup.py (make_shortcut): Fixed message about directories
2699 created during Windows installation (the directories were ok, just
2709 created during Windows installation (the directories were ok, just
2700 the printed message was misleading). Thanks to Chris Liechti
2710 the printed message was misleading). Thanks to Chris Liechti
2701 <cliechti-AT-gmx.net> for the heads up.
2711 <cliechti-AT-gmx.net> for the heads up.
2702
2712
2703 2003-02-21 Fernando Perez <fperez@colorado.edu>
2713 2003-02-21 Fernando Perez <fperez@colorado.edu>
2704
2714
2705 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2715 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2706 of ValueError exception when checking for auto-execution. This
2716 of ValueError exception when checking for auto-execution. This
2707 one is raised by things like Numeric arrays arr.flat when the
2717 one is raised by things like Numeric arrays arr.flat when the
2708 array is non-contiguous.
2718 array is non-contiguous.
2709
2719
2710 2003-01-31 Fernando Perez <fperez@colorado.edu>
2720 2003-01-31 Fernando Perez <fperez@colorado.edu>
2711
2721
2712 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2722 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2713 not return any value at all (even though the command would get
2723 not return any value at all (even though the command would get
2714 executed).
2724 executed).
2715 (xsys): Flush stdout right after printing the command to ensure
2725 (xsys): Flush stdout right after printing the command to ensure
2716 proper ordering of commands and command output in the total
2726 proper ordering of commands and command output in the total
2717 output.
2727 output.
2718 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2728 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2719 system/getoutput as defaults. The old ones are kept for
2729 system/getoutput as defaults. The old ones are kept for
2720 compatibility reasons, so no code which uses this library needs
2730 compatibility reasons, so no code which uses this library needs
2721 changing.
2731 changing.
2722
2732
2723 2003-01-27 *** Released version 0.2.14
2733 2003-01-27 *** Released version 0.2.14
2724
2734
2725 2003-01-25 Fernando Perez <fperez@colorado.edu>
2735 2003-01-25 Fernando Perez <fperez@colorado.edu>
2726
2736
2727 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2737 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2728 functions defined in previous edit sessions could not be re-edited
2738 functions defined in previous edit sessions could not be re-edited
2729 (because the temp files were immediately removed). Now temp files
2739 (because the temp files were immediately removed). Now temp files
2730 are removed only at IPython's exit.
2740 are removed only at IPython's exit.
2731 (Magic.magic_run): Improved @run to perform shell-like expansions
2741 (Magic.magic_run): Improved @run to perform shell-like expansions
2732 on its arguments (~users and $VARS). With this, @run becomes more
2742 on its arguments (~users and $VARS). With this, @run becomes more
2733 like a normal command-line.
2743 like a normal command-line.
2734
2744
2735 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2745 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2736 bugs related to embedding and cleaned up that code. A fairly
2746 bugs related to embedding and cleaned up that code. A fairly
2737 important one was the impossibility to access the global namespace
2747 important one was the impossibility to access the global namespace
2738 through the embedded IPython (only local variables were visible).
2748 through the embedded IPython (only local variables were visible).
2739
2749
2740 2003-01-14 Fernando Perez <fperez@colorado.edu>
2750 2003-01-14 Fernando Perez <fperez@colorado.edu>
2741
2751
2742 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
2752 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
2743 auto-calling to be a bit more conservative. Now it doesn't get
2753 auto-calling to be a bit more conservative. Now it doesn't get
2744 triggered if any of '!=()<>' are in the rest of the input line, to
2754 triggered if any of '!=()<>' are in the rest of the input line, to
2745 allow comparing callables. Thanks to Alex for the heads up.
2755 allow comparing callables. Thanks to Alex for the heads up.
2746
2756
2747 2003-01-07 Fernando Perez <fperez@colorado.edu>
2757 2003-01-07 Fernando Perez <fperez@colorado.edu>
2748
2758
2749 * IPython/genutils.py (page): fixed estimation of the number of
2759 * IPython/genutils.py (page): fixed estimation of the number of
2750 lines in a string to be paged to simply count newlines. This
2760 lines in a string to be paged to simply count newlines. This
2751 prevents over-guessing due to embedded escape sequences. A better
2761 prevents over-guessing due to embedded escape sequences. A better
2752 long-term solution would involve stripping out the control chars
2762 long-term solution would involve stripping out the control chars
2753 for the count, but it's potentially so expensive I just don't
2763 for the count, but it's potentially so expensive I just don't
2754 think it's worth doing.
2764 think it's worth doing.
2755
2765
2756 2002-12-19 *** Released version 0.2.14pre50
2766 2002-12-19 *** Released version 0.2.14pre50
2757
2767
2758 2002-12-19 Fernando Perez <fperez@colorado.edu>
2768 2002-12-19 Fernando Perez <fperez@colorado.edu>
2759
2769
2760 * tools/release (version): Changed release scripts to inform
2770 * tools/release (version): Changed release scripts to inform
2761 Andrea and build a NEWS file with a list of recent changes.
2771 Andrea and build a NEWS file with a list of recent changes.
2762
2772
2763 * IPython/ColorANSI.py (__all__): changed terminal detection
2773 * IPython/ColorANSI.py (__all__): changed terminal detection
2764 code. Seems to work better for xterms without breaking
2774 code. Seems to work better for xterms without breaking
2765 konsole. Will need more testing to determine if WinXP and Mac OSX
2775 konsole. Will need more testing to determine if WinXP and Mac OSX
2766 also work ok.
2776 also work ok.
2767
2777
2768 2002-12-18 *** Released version 0.2.14pre49
2778 2002-12-18 *** Released version 0.2.14pre49
2769
2779
2770 2002-12-18 Fernando Perez <fperez@colorado.edu>
2780 2002-12-18 Fernando Perez <fperez@colorado.edu>
2771
2781
2772 * Docs: added new info about Mac OSX, from Andrea.
2782 * Docs: added new info about Mac OSX, from Andrea.
2773
2783
2774 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
2784 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
2775 allow direct plotting of python strings whose format is the same
2785 allow direct plotting of python strings whose format is the same
2776 of gnuplot data files.
2786 of gnuplot data files.
2777
2787
2778 2002-12-16 Fernando Perez <fperez@colorado.edu>
2788 2002-12-16 Fernando Perez <fperez@colorado.edu>
2779
2789
2780 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
2790 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
2781 value of exit question to be acknowledged.
2791 value of exit question to be acknowledged.
2782
2792
2783 2002-12-03 Fernando Perez <fperez@colorado.edu>
2793 2002-12-03 Fernando Perez <fperez@colorado.edu>
2784
2794
2785 * IPython/ipmaker.py: removed generators, which had been added
2795 * IPython/ipmaker.py: removed generators, which had been added
2786 by mistake in an earlier debugging run. This was causing trouble
2796 by mistake in an earlier debugging run. This was causing trouble
2787 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
2797 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
2788 for pointing this out.
2798 for pointing this out.
2789
2799
2790 2002-11-17 Fernando Perez <fperez@colorado.edu>
2800 2002-11-17 Fernando Perez <fperez@colorado.edu>
2791
2801
2792 * Manual: updated the Gnuplot section.
2802 * Manual: updated the Gnuplot section.
2793
2803
2794 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
2804 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
2795 a much better split of what goes in Runtime and what goes in
2805 a much better split of what goes in Runtime and what goes in
2796 Interactive.
2806 Interactive.
2797
2807
2798 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
2808 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
2799 being imported from iplib.
2809 being imported from iplib.
2800
2810
2801 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
2811 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
2802 for command-passing. Now the global Gnuplot instance is called
2812 for command-passing. Now the global Gnuplot instance is called
2803 'gp' instead of 'g', which was really a far too fragile and
2813 'gp' instead of 'g', which was really a far too fragile and
2804 common name.
2814 common name.
2805
2815
2806 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
2816 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
2807 bounding boxes generated by Gnuplot for square plots.
2817 bounding boxes generated by Gnuplot for square plots.
2808
2818
2809 * IPython/genutils.py (popkey): new function added. I should
2819 * IPython/genutils.py (popkey): new function added. I should
2810 suggest this on c.l.py as a dict method, it seems useful.
2820 suggest this on c.l.py as a dict method, it seems useful.
2811
2821
2812 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
2822 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
2813 to transparently handle PostScript generation. MUCH better than
2823 to transparently handle PostScript generation. MUCH better than
2814 the previous plot_eps/replot_eps (which I removed now). The code
2824 the previous plot_eps/replot_eps (which I removed now). The code
2815 is also fairly clean and well documented now (including
2825 is also fairly clean and well documented now (including
2816 docstrings).
2826 docstrings).
2817
2827
2818 2002-11-13 Fernando Perez <fperez@colorado.edu>
2828 2002-11-13 Fernando Perez <fperez@colorado.edu>
2819
2829
2820 * IPython/Magic.py (Magic.magic_edit): fixed docstring
2830 * IPython/Magic.py (Magic.magic_edit): fixed docstring
2821 (inconsistent with options).
2831 (inconsistent with options).
2822
2832
2823 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
2833 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
2824 manually disabled, I don't know why. Fixed it.
2834 manually disabled, I don't know why. Fixed it.
2825 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
2835 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
2826 eps output.
2836 eps output.
2827
2837
2828 2002-11-12 Fernando Perez <fperez@colorado.edu>
2838 2002-11-12 Fernando Perez <fperez@colorado.edu>
2829
2839
2830 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
2840 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
2831 don't propagate up to caller. Fixes crash reported by François
2841 don't propagate up to caller. Fixes crash reported by François
2832 Pinard.
2842 Pinard.
2833
2843
2834 2002-11-09 Fernando Perez <fperez@colorado.edu>
2844 2002-11-09 Fernando Perez <fperez@colorado.edu>
2835
2845
2836 * IPython/ipmaker.py (make_IPython): fixed problem with writing
2846 * IPython/ipmaker.py (make_IPython): fixed problem with writing
2837 history file for new users.
2847 history file for new users.
2838 (make_IPython): fixed bug where initial install would leave the
2848 (make_IPython): fixed bug where initial install would leave the
2839 user running in the .ipython dir.
2849 user running in the .ipython dir.
2840 (make_IPython): fixed bug where config dir .ipython would be
2850 (make_IPython): fixed bug where config dir .ipython would be
2841 created regardless of the given -ipythondir option. Thanks to Cory
2851 created regardless of the given -ipythondir option. Thanks to Cory
2842 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
2852 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
2843
2853
2844 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
2854 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
2845 type confirmations. Will need to use it in all of IPython's code
2855 type confirmations. Will need to use it in all of IPython's code
2846 consistently.
2856 consistently.
2847
2857
2848 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
2858 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
2849 context to print 31 lines instead of the default 5. This will make
2859 context to print 31 lines instead of the default 5. This will make
2850 the crash reports extremely detailed in case the problem is in
2860 the crash reports extremely detailed in case the problem is in
2851 libraries I don't have access to.
2861 libraries I don't have access to.
2852
2862
2853 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
2863 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
2854 line of defense' code to still crash, but giving users fair
2864 line of defense' code to still crash, but giving users fair
2855 warning. I don't want internal errors to go unreported: if there's
2865 warning. I don't want internal errors to go unreported: if there's
2856 an internal problem, IPython should crash and generate a full
2866 an internal problem, IPython should crash and generate a full
2857 report.
2867 report.
2858
2868
2859 2002-11-08 Fernando Perez <fperez@colorado.edu>
2869 2002-11-08 Fernando Perez <fperez@colorado.edu>
2860
2870
2861 * IPython/iplib.py (InteractiveShell.interact): added code to trap
2871 * IPython/iplib.py (InteractiveShell.interact): added code to trap
2862 otherwise uncaught exceptions which can appear if people set
2872 otherwise uncaught exceptions which can appear if people set
2863 sys.stdout to something badly broken. Thanks to a crash report
2873 sys.stdout to something badly broken. Thanks to a crash report
2864 from henni-AT-mail.brainbot.com.
2874 from henni-AT-mail.brainbot.com.
2865
2875
2866 2002-11-04 Fernando Perez <fperez@colorado.edu>
2876 2002-11-04 Fernando Perez <fperez@colorado.edu>
2867
2877
2868 * IPython/iplib.py (InteractiveShell.interact): added
2878 * IPython/iplib.py (InteractiveShell.interact): added
2869 __IPYTHON__active to the builtins. It's a flag which goes on when
2879 __IPYTHON__active to the builtins. It's a flag which goes on when
2870 the interaction starts and goes off again when it stops. This
2880 the interaction starts and goes off again when it stops. This
2871 allows embedding code to detect being inside IPython. Before this
2881 allows embedding code to detect being inside IPython. Before this
2872 was done via __IPYTHON__, but that only shows that an IPython
2882 was done via __IPYTHON__, but that only shows that an IPython
2873 instance has been created.
2883 instance has been created.
2874
2884
2875 * IPython/Magic.py (Magic.magic_env): I realized that in a
2885 * IPython/Magic.py (Magic.magic_env): I realized that in a
2876 UserDict, instance.data holds the data as a normal dict. So I
2886 UserDict, instance.data holds the data as a normal dict. So I
2877 modified @env to return os.environ.data instead of rebuilding a
2887 modified @env to return os.environ.data instead of rebuilding a
2878 dict by hand.
2888 dict by hand.
2879
2889
2880 2002-11-02 Fernando Perez <fperez@colorado.edu>
2890 2002-11-02 Fernando Perez <fperez@colorado.edu>
2881
2891
2882 * IPython/genutils.py (warn): changed so that level 1 prints no
2892 * IPython/genutils.py (warn): changed so that level 1 prints no
2883 header. Level 2 is now the default (with 'WARNING' header, as
2893 header. Level 2 is now the default (with 'WARNING' header, as
2884 before). I think I tracked all places where changes were needed in
2894 before). I think I tracked all places where changes were needed in
2885 IPython, but outside code using the old level numbering may have
2895 IPython, but outside code using the old level numbering may have
2886 broken.
2896 broken.
2887
2897
2888 * IPython/iplib.py (InteractiveShell.runcode): added this to
2898 * IPython/iplib.py (InteractiveShell.runcode): added this to
2889 handle the tracebacks in SystemExit traps correctly. The previous
2899 handle the tracebacks in SystemExit traps correctly. The previous
2890 code (through interact) was printing more of the stack than
2900 code (through interact) was printing more of the stack than
2891 necessary, showing IPython internal code to the user.
2901 necessary, showing IPython internal code to the user.
2892
2902
2893 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
2903 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
2894 default. Now that the default at the confirmation prompt is yes,
2904 default. Now that the default at the confirmation prompt is yes,
2895 it's not so intrusive. François' argument that ipython sessions
2905 it's not so intrusive. François' argument that ipython sessions
2896 tend to be complex enough not to lose them from an accidental C-d,
2906 tend to be complex enough not to lose them from an accidental C-d,
2897 is a valid one.
2907 is a valid one.
2898
2908
2899 * IPython/iplib.py (InteractiveShell.interact): added a
2909 * IPython/iplib.py (InteractiveShell.interact): added a
2900 showtraceback() call to the SystemExit trap, and modified the exit
2910 showtraceback() call to the SystemExit trap, and modified the exit
2901 confirmation to have yes as the default.
2911 confirmation to have yes as the default.
2902
2912
2903 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
2913 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
2904 this file. It's been gone from the code for a long time, this was
2914 this file. It's been gone from the code for a long time, this was
2905 simply leftover junk.
2915 simply leftover junk.
2906
2916
2907 2002-11-01 Fernando Perez <fperez@colorado.edu>
2917 2002-11-01 Fernando Perez <fperez@colorado.edu>
2908
2918
2909 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
2919 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
2910 added. If set, IPython now traps EOF and asks for
2920 added. If set, IPython now traps EOF and asks for
2911 confirmation. After a request by François Pinard.
2921 confirmation. After a request by François Pinard.
2912
2922
2913 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
2923 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
2914 of @abort, and with a new (better) mechanism for handling the
2924 of @abort, and with a new (better) mechanism for handling the
2915 exceptions.
2925 exceptions.
2916
2926
2917 2002-10-27 Fernando Perez <fperez@colorado.edu>
2927 2002-10-27 Fernando Perez <fperez@colorado.edu>
2918
2928
2919 * IPython/usage.py (__doc__): updated the --help information and
2929 * IPython/usage.py (__doc__): updated the --help information and
2920 the ipythonrc file to indicate that -log generates
2930 the ipythonrc file to indicate that -log generates
2921 ./ipython.log. Also fixed the corresponding info in @logstart.
2931 ./ipython.log. Also fixed the corresponding info in @logstart.
2922 This and several other fixes in the manuals thanks to reports by
2932 This and several other fixes in the manuals thanks to reports by
2923 François Pinard <pinard-AT-iro.umontreal.ca>.
2933 François Pinard <pinard-AT-iro.umontreal.ca>.
2924
2934
2925 * IPython/Logger.py (Logger.switch_log): Fixed error message to
2935 * IPython/Logger.py (Logger.switch_log): Fixed error message to
2926 refer to @logstart (instead of @log, which doesn't exist).
2936 refer to @logstart (instead of @log, which doesn't exist).
2927
2937
2928 * IPython/iplib.py (InteractiveShell._prefilter): fixed
2938 * IPython/iplib.py (InteractiveShell._prefilter): fixed
2929 AttributeError crash. Thanks to Christopher Armstrong
2939 AttributeError crash. Thanks to Christopher Armstrong
2930 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
2940 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
2931 introduced recently (in 0.2.14pre37) with the fix to the eval
2941 introduced recently (in 0.2.14pre37) with the fix to the eval
2932 problem mentioned below.
2942 problem mentioned below.
2933
2943
2934 2002-10-17 Fernando Perez <fperez@colorado.edu>
2944 2002-10-17 Fernando Perez <fperez@colorado.edu>
2935
2945
2936 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
2946 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
2937 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
2947 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
2938
2948
2939 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
2949 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
2940 this function to fix a problem reported by Alex Schmolck. He saw
2950 this function to fix a problem reported by Alex Schmolck. He saw
2941 it with list comprehensions and generators, which were getting
2951 it with list comprehensions and generators, which were getting
2942 called twice. The real problem was an 'eval' call in testing for
2952 called twice. The real problem was an 'eval' call in testing for
2943 automagic which was evaluating the input line silently.
2953 automagic which was evaluating the input line silently.
2944
2954
2945 This is a potentially very nasty bug, if the input has side
2955 This is a potentially very nasty bug, if the input has side
2946 effects which must not be repeated. The code is much cleaner now,
2956 effects which must not be repeated. The code is much cleaner now,
2947 without any blanket 'except' left and with a regexp test for
2957 without any blanket 'except' left and with a regexp test for
2948 actual function names.
2958 actual function names.
2949
2959
2950 But an eval remains, which I'm not fully comfortable with. I just
2960 But an eval remains, which I'm not fully comfortable with. I just
2951 don't know how to find out if an expression could be a callable in
2961 don't know how to find out if an expression could be a callable in
2952 the user's namespace without doing an eval on the string. However
2962 the user's namespace without doing an eval on the string. However
2953 that string is now much more strictly checked so that no code
2963 that string is now much more strictly checked so that no code
2954 slips by, so the eval should only happen for things that can
2964 slips by, so the eval should only happen for things that can
2955 really be only function/method names.
2965 really be only function/method names.
2956
2966
2957 2002-10-15 Fernando Perez <fperez@colorado.edu>
2967 2002-10-15 Fernando Perez <fperez@colorado.edu>
2958
2968
2959 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
2969 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
2960 OSX information to main manual, removed README_Mac_OSX file from
2970 OSX information to main manual, removed README_Mac_OSX file from
2961 distribution. Also updated credits for recent additions.
2971 distribution. Also updated credits for recent additions.
2962
2972
2963 2002-10-10 Fernando Perez <fperez@colorado.edu>
2973 2002-10-10 Fernando Perez <fperez@colorado.edu>
2964
2974
2965 * README_Mac_OSX: Added a README for Mac OSX users for fixing
2975 * README_Mac_OSX: Added a README for Mac OSX users for fixing
2966 terminal-related issues. Many thanks to Andrea Riciputi
2976 terminal-related issues. Many thanks to Andrea Riciputi
2967 <andrea.riciputi-AT-libero.it> for writing it.
2977 <andrea.riciputi-AT-libero.it> for writing it.
2968
2978
2969 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
2979 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
2970 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2980 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2971
2981
2972 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
2982 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
2973 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
2983 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
2974 <syver-en-AT-online.no> who both submitted patches for this problem.
2984 <syver-en-AT-online.no> who both submitted patches for this problem.
2975
2985
2976 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
2986 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
2977 global embedding to make sure that things don't overwrite user
2987 global embedding to make sure that things don't overwrite user
2978 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
2988 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
2979
2989
2980 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
2990 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
2981 compatibility. Thanks to Hayden Callow
2991 compatibility. Thanks to Hayden Callow
2982 <h.callow-AT-elec.canterbury.ac.nz>
2992 <h.callow-AT-elec.canterbury.ac.nz>
2983
2993
2984 2002-10-04 Fernando Perez <fperez@colorado.edu>
2994 2002-10-04 Fernando Perez <fperez@colorado.edu>
2985
2995
2986 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
2996 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
2987 Gnuplot.File objects.
2997 Gnuplot.File objects.
2988
2998
2989 2002-07-23 Fernando Perez <fperez@colorado.edu>
2999 2002-07-23 Fernando Perez <fperez@colorado.edu>
2990
3000
2991 * IPython/genutils.py (timing): Added timings() and timing() for
3001 * IPython/genutils.py (timing): Added timings() and timing() for
2992 quick access to the most commonly needed data, the execution
3002 quick access to the most commonly needed data, the execution
2993 times. Old timing() renamed to timings_out().
3003 times. Old timing() renamed to timings_out().
2994
3004
2995 2002-07-18 Fernando Perez <fperez@colorado.edu>
3005 2002-07-18 Fernando Perez <fperez@colorado.edu>
2996
3006
2997 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
3007 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
2998 bug with nested instances disrupting the parent's tab completion.
3008 bug with nested instances disrupting the parent's tab completion.
2999
3009
3000 * IPython/iplib.py (all_completions): Added Alex Schmolck's
3010 * IPython/iplib.py (all_completions): Added Alex Schmolck's
3001 all_completions code to begin the emacs integration.
3011 all_completions code to begin the emacs integration.
3002
3012
3003 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
3013 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
3004 argument to allow titling individual arrays when plotting.
3014 argument to allow titling individual arrays when plotting.
3005
3015
3006 2002-07-15 Fernando Perez <fperez@colorado.edu>
3016 2002-07-15 Fernando Perez <fperez@colorado.edu>
3007
3017
3008 * setup.py (make_shortcut): changed to retrieve the value of
3018 * setup.py (make_shortcut): changed to retrieve the value of
3009 'Program Files' directory from the registry (this value changes in
3019 'Program Files' directory from the registry (this value changes in
3010 non-english versions of Windows). Thanks to Thomas Fanslau
3020 non-english versions of Windows). Thanks to Thomas Fanslau
3011 <tfanslau-AT-gmx.de> for the report.
3021 <tfanslau-AT-gmx.de> for the report.
3012
3022
3013 2002-07-10 Fernando Perez <fperez@colorado.edu>
3023 2002-07-10 Fernando Perez <fperez@colorado.edu>
3014
3024
3015 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
3025 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
3016 a bug in pdb, which crashes if a line with only whitespace is
3026 a bug in pdb, which crashes if a line with only whitespace is
3017 entered. Bug report submitted to sourceforge.
3027 entered. Bug report submitted to sourceforge.
3018
3028
3019 2002-07-09 Fernando Perez <fperez@colorado.edu>
3029 2002-07-09 Fernando Perez <fperez@colorado.edu>
3020
3030
3021 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
3031 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
3022 reporting exceptions (it's a bug in inspect.py, I just set a
3032 reporting exceptions (it's a bug in inspect.py, I just set a
3023 workaround).
3033 workaround).
3024
3034
3025 2002-07-08 Fernando Perez <fperez@colorado.edu>
3035 2002-07-08 Fernando Perez <fperez@colorado.edu>
3026
3036
3027 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
3037 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
3028 __IPYTHON__ in __builtins__ to show up in user_ns.
3038 __IPYTHON__ in __builtins__ to show up in user_ns.
3029
3039
3030 2002-07-03 Fernando Perez <fperez@colorado.edu>
3040 2002-07-03 Fernando Perez <fperez@colorado.edu>
3031
3041
3032 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
3042 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
3033 name from @gp_set_instance to @gp_set_default.
3043 name from @gp_set_instance to @gp_set_default.
3034
3044
3035 * IPython/ipmaker.py (make_IPython): default editor value set to
3045 * IPython/ipmaker.py (make_IPython): default editor value set to
3036 '0' (a string), to match the rc file. Otherwise will crash when
3046 '0' (a string), to match the rc file. Otherwise will crash when
3037 .strip() is called on it.
3047 .strip() is called on it.
3038
3048
3039
3049
3040 2002-06-28 Fernando Perez <fperez@colorado.edu>
3050 2002-06-28 Fernando Perez <fperez@colorado.edu>
3041
3051
3042 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
3052 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
3043 of files in current directory when a file is executed via
3053 of files in current directory when a file is executed via
3044 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
3054 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
3045
3055
3046 * setup.py (manfiles): fix for rpm builds, submitted by RA
3056 * setup.py (manfiles): fix for rpm builds, submitted by RA
3047 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
3057 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
3048
3058
3049 * IPython/ipmaker.py (make_IPython): fixed lookup of default
3059 * IPython/ipmaker.py (make_IPython): fixed lookup of default
3050 editor when set to '0'. Problem was, '0' evaluates to True (it's a
3060 editor when set to '0'. Problem was, '0' evaluates to True (it's a
3051 string!). A. Schmolck caught this one.
3061 string!). A. Schmolck caught this one.
3052
3062
3053 2002-06-27 Fernando Perez <fperez@colorado.edu>
3063 2002-06-27 Fernando Perez <fperez@colorado.edu>
3054
3064
3055 * IPython/ipmaker.py (make_IPython): fixed bug when running user
3065 * IPython/ipmaker.py (make_IPython): fixed bug when running user
3056 defined files at the cmd line. __name__ wasn't being set to
3066 defined files at the cmd line. __name__ wasn't being set to
3057 __main__.
3067 __main__.
3058
3068
3059 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
3069 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
3060 regular lists and tuples besides Numeric arrays.
3070 regular lists and tuples besides Numeric arrays.
3061
3071
3062 * IPython/Prompts.py (CachedOutput.__call__): Added output
3072 * IPython/Prompts.py (CachedOutput.__call__): Added output
3063 supression for input ending with ';'. Similar to Mathematica and
3073 supression for input ending with ';'. Similar to Mathematica and
3064 Matlab. The _* vars and Out[] list are still updated, just like
3074 Matlab. The _* vars and Out[] list are still updated, just like
3065 Mathematica behaves.
3075 Mathematica behaves.
3066
3076
3067 2002-06-25 Fernando Perez <fperez@colorado.edu>
3077 2002-06-25 Fernando Perez <fperez@colorado.edu>
3068
3078
3069 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
3079 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
3070 .ini extensions for profiels under Windows.
3080 .ini extensions for profiels under Windows.
3071
3081
3072 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
3082 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
3073 string form. Fix contributed by Alexander Schmolck
3083 string form. Fix contributed by Alexander Schmolck
3074 <a.schmolck-AT-gmx.net>
3084 <a.schmolck-AT-gmx.net>
3075
3085
3076 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
3086 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
3077 pre-configured Gnuplot instance.
3087 pre-configured Gnuplot instance.
3078
3088
3079 2002-06-21 Fernando Perez <fperez@colorado.edu>
3089 2002-06-21 Fernando Perez <fperez@colorado.edu>
3080
3090
3081 * IPython/numutils.py (exp_safe): new function, works around the
3091 * IPython/numutils.py (exp_safe): new function, works around the
3082 underflow problems in Numeric.
3092 underflow problems in Numeric.
3083 (log2): New fn. Safe log in base 2: returns exact integer answer
3093 (log2): New fn. Safe log in base 2: returns exact integer answer
3084 for exact integer powers of 2.
3094 for exact integer powers of 2.
3085
3095
3086 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
3096 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
3087 properly.
3097 properly.
3088
3098
3089 2002-06-20 Fernando Perez <fperez@colorado.edu>
3099 2002-06-20 Fernando Perez <fperez@colorado.edu>
3090
3100
3091 * IPython/genutils.py (timing): new function like
3101 * IPython/genutils.py (timing): new function like
3092 Mathematica's. Similar to time_test, but returns more info.
3102 Mathematica's. Similar to time_test, but returns more info.
3093
3103
3094 2002-06-18 Fernando Perez <fperez@colorado.edu>
3104 2002-06-18 Fernando Perez <fperez@colorado.edu>
3095
3105
3096 * IPython/Magic.py (Magic.magic_save): modified @save and @r
3106 * IPython/Magic.py (Magic.magic_save): modified @save and @r
3097 according to Mike Heeter's suggestions.
3107 according to Mike Heeter's suggestions.
3098
3108
3099 2002-06-16 Fernando Perez <fperez@colorado.edu>
3109 2002-06-16 Fernando Perez <fperez@colorado.edu>
3100
3110
3101 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
3111 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
3102 system. GnuplotMagic is gone as a user-directory option. New files
3112 system. GnuplotMagic is gone as a user-directory option. New files
3103 make it easier to use all the gnuplot stuff both from external
3113 make it easier to use all the gnuplot stuff both from external
3104 programs as well as from IPython. Had to rewrite part of
3114 programs as well as from IPython. Had to rewrite part of
3105 hardcopy() b/c of a strange bug: often the ps files simply don't
3115 hardcopy() b/c of a strange bug: often the ps files simply don't
3106 get created, and require a repeat of the command (often several
3116 get created, and require a repeat of the command (often several
3107 times).
3117 times).
3108
3118
3109 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
3119 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
3110 resolve output channel at call time, so that if sys.stderr has
3120 resolve output channel at call time, so that if sys.stderr has
3111 been redirected by user this gets honored.
3121 been redirected by user this gets honored.
3112
3122
3113 2002-06-13 Fernando Perez <fperez@colorado.edu>
3123 2002-06-13 Fernando Perez <fperez@colorado.edu>
3114
3124
3115 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
3125 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
3116 IPShell. Kept a copy with the old names to avoid breaking people's
3126 IPShell. Kept a copy with the old names to avoid breaking people's
3117 embedded code.
3127 embedded code.
3118
3128
3119 * IPython/ipython: simplified it to the bare minimum after
3129 * IPython/ipython: simplified it to the bare minimum after
3120 Holger's suggestions. Added info about how to use it in
3130 Holger's suggestions. Added info about how to use it in
3121 PYTHONSTARTUP.
3131 PYTHONSTARTUP.
3122
3132
3123 * IPython/Shell.py (IPythonShell): changed the options passing
3133 * IPython/Shell.py (IPythonShell): changed the options passing
3124 from a string with funky %s replacements to a straight list. Maybe
3134 from a string with funky %s replacements to a straight list. Maybe
3125 a bit more typing, but it follows sys.argv conventions, so there's
3135 a bit more typing, but it follows sys.argv conventions, so there's
3126 less special-casing to remember.
3136 less special-casing to remember.
3127
3137
3128 2002-06-12 Fernando Perez <fperez@colorado.edu>
3138 2002-06-12 Fernando Perez <fperez@colorado.edu>
3129
3139
3130 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
3140 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
3131 command. Thanks to a suggestion by Mike Heeter.
3141 command. Thanks to a suggestion by Mike Heeter.
3132 (Magic.magic_pfile): added behavior to look at filenames if given
3142 (Magic.magic_pfile): added behavior to look at filenames if given
3133 arg is not a defined object.
3143 arg is not a defined object.
3134 (Magic.magic_save): New @save function to save code snippets. Also
3144 (Magic.magic_save): New @save function to save code snippets. Also
3135 a Mike Heeter idea.
3145 a Mike Heeter idea.
3136
3146
3137 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
3147 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
3138 plot() and replot(). Much more convenient now, especially for
3148 plot() and replot(). Much more convenient now, especially for
3139 interactive use.
3149 interactive use.
3140
3150
3141 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
3151 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
3142 filenames.
3152 filenames.
3143
3153
3144 2002-06-02 Fernando Perez <fperez@colorado.edu>
3154 2002-06-02 Fernando Perez <fperez@colorado.edu>
3145
3155
3146 * IPython/Struct.py (Struct.__init__): modified to admit
3156 * IPython/Struct.py (Struct.__init__): modified to admit
3147 initialization via another struct.
3157 initialization via another struct.
3148
3158
3149 * IPython/genutils.py (SystemExec.__init__): New stateful
3159 * IPython/genutils.py (SystemExec.__init__): New stateful
3150 interface to xsys and bq. Useful for writing system scripts.
3160 interface to xsys and bq. Useful for writing system scripts.
3151
3161
3152 2002-05-30 Fernando Perez <fperez@colorado.edu>
3162 2002-05-30 Fernando Perez <fperez@colorado.edu>
3153
3163
3154 * MANIFEST.in: Changed docfile selection to exclude all the lyx
3164 * MANIFEST.in: Changed docfile selection to exclude all the lyx
3155 documents. This will make the user download smaller (it's getting
3165 documents. This will make the user download smaller (it's getting
3156 too big).
3166 too big).
3157
3167
3158 2002-05-29 Fernando Perez <fperez@colorado.edu>
3168 2002-05-29 Fernando Perez <fperez@colorado.edu>
3159
3169
3160 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
3170 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
3161 fix problems with shelve and pickle. Seems to work, but I don't
3171 fix problems with shelve and pickle. Seems to work, but I don't
3162 know if corner cases break it. Thanks to Mike Heeter
3172 know if corner cases break it. Thanks to Mike Heeter
3163 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
3173 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
3164
3174
3165 2002-05-24 Fernando Perez <fperez@colorado.edu>
3175 2002-05-24 Fernando Perez <fperez@colorado.edu>
3166
3176
3167 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
3177 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
3168 macros having broken.
3178 macros having broken.
3169
3179
3170 2002-05-21 Fernando Perez <fperez@colorado.edu>
3180 2002-05-21 Fernando Perez <fperez@colorado.edu>
3171
3181
3172 * IPython/Magic.py (Magic.magic_logstart): fixed recently
3182 * IPython/Magic.py (Magic.magic_logstart): fixed recently
3173 introduced logging bug: all history before logging started was
3183 introduced logging bug: all history before logging started was
3174 being written one character per line! This came from the redesign
3184 being written one character per line! This came from the redesign
3175 of the input history as a special list which slices to strings,
3185 of the input history as a special list which slices to strings,
3176 not to lists.
3186 not to lists.
3177
3187
3178 2002-05-20 Fernando Perez <fperez@colorado.edu>
3188 2002-05-20 Fernando Perez <fperez@colorado.edu>
3179
3189
3180 * IPython/Prompts.py (CachedOutput.__init__): made the color table
3190 * IPython/Prompts.py (CachedOutput.__init__): made the color table
3181 be an attribute of all classes in this module. The design of these
3191 be an attribute of all classes in this module. The design of these
3182 classes needs some serious overhauling.
3192 classes needs some serious overhauling.
3183
3193
3184 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
3194 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
3185 which was ignoring '_' in option names.
3195 which was ignoring '_' in option names.
3186
3196
3187 * IPython/ultraTB.py (FormattedTB.__init__): Changed
3197 * IPython/ultraTB.py (FormattedTB.__init__): Changed
3188 'Verbose_novars' to 'Context' and made it the new default. It's a
3198 'Verbose_novars' to 'Context' and made it the new default. It's a
3189 bit more readable and also safer than verbose.
3199 bit more readable and also safer than verbose.
3190
3200
3191 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
3201 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
3192 triple-quoted strings.
3202 triple-quoted strings.
3193
3203
3194 * IPython/OInspect.py (__all__): new module exposing the object
3204 * IPython/OInspect.py (__all__): new module exposing the object
3195 introspection facilities. Now the corresponding magics are dummy
3205 introspection facilities. Now the corresponding magics are dummy
3196 wrappers around this. Having this module will make it much easier
3206 wrappers around this. Having this module will make it much easier
3197 to put these functions into our modified pdb.
3207 to put these functions into our modified pdb.
3198 This new object inspector system uses the new colorizing module,
3208 This new object inspector system uses the new colorizing module,
3199 so source code and other things are nicely syntax highlighted.
3209 so source code and other things are nicely syntax highlighted.
3200
3210
3201 2002-05-18 Fernando Perez <fperez@colorado.edu>
3211 2002-05-18 Fernando Perez <fperez@colorado.edu>
3202
3212
3203 * IPython/ColorANSI.py: Split the coloring tools into a separate
3213 * IPython/ColorANSI.py: Split the coloring tools into a separate
3204 module so I can use them in other code easier (they were part of
3214 module so I can use them in other code easier (they were part of
3205 ultraTB).
3215 ultraTB).
3206
3216
3207 2002-05-17 Fernando Perez <fperez@colorado.edu>
3217 2002-05-17 Fernando Perez <fperez@colorado.edu>
3208
3218
3209 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3219 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3210 fixed it to set the global 'g' also to the called instance, as
3220 fixed it to set the global 'g' also to the called instance, as
3211 long as 'g' was still a gnuplot instance (so it doesn't overwrite
3221 long as 'g' was still a gnuplot instance (so it doesn't overwrite
3212 user's 'g' variables).
3222 user's 'g' variables).
3213
3223
3214 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
3224 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
3215 global variables (aliases to _ih,_oh) so that users which expect
3225 global variables (aliases to _ih,_oh) so that users which expect
3216 In[5] or Out[7] to work aren't unpleasantly surprised.
3226 In[5] or Out[7] to work aren't unpleasantly surprised.
3217 (InputList.__getslice__): new class to allow executing slices of
3227 (InputList.__getslice__): new class to allow executing slices of
3218 input history directly. Very simple class, complements the use of
3228 input history directly. Very simple class, complements the use of
3219 macros.
3229 macros.
3220
3230
3221 2002-05-16 Fernando Perez <fperez@colorado.edu>
3231 2002-05-16 Fernando Perez <fperez@colorado.edu>
3222
3232
3223 * setup.py (docdirbase): make doc directory be just doc/IPython
3233 * setup.py (docdirbase): make doc directory be just doc/IPython
3224 without version numbers, it will reduce clutter for users.
3234 without version numbers, it will reduce clutter for users.
3225
3235
3226 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
3236 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
3227 execfile call to prevent possible memory leak. See for details:
3237 execfile call to prevent possible memory leak. See for details:
3228 http://mail.python.org/pipermail/python-list/2002-February/088476.html
3238 http://mail.python.org/pipermail/python-list/2002-February/088476.html
3229
3239
3230 2002-05-15 Fernando Perez <fperez@colorado.edu>
3240 2002-05-15 Fernando Perez <fperez@colorado.edu>
3231
3241
3232 * IPython/Magic.py (Magic.magic_psource): made the object
3242 * IPython/Magic.py (Magic.magic_psource): made the object
3233 introspection names be more standard: pdoc, pdef, pfile and
3243 introspection names be more standard: pdoc, pdef, pfile and
3234 psource. They all print/page their output, and it makes
3244 psource. They all print/page their output, and it makes
3235 remembering them easier. Kept old names for compatibility as
3245 remembering them easier. Kept old names for compatibility as
3236 aliases.
3246 aliases.
3237
3247
3238 2002-05-14 Fernando Perez <fperez@colorado.edu>
3248 2002-05-14 Fernando Perez <fperez@colorado.edu>
3239
3249
3240 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
3250 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
3241 what the mouse problem was. The trick is to use gnuplot with temp
3251 what the mouse problem was. The trick is to use gnuplot with temp
3242 files and NOT with pipes (for data communication), because having
3252 files and NOT with pipes (for data communication), because having
3243 both pipes and the mouse on is bad news.
3253 both pipes and the mouse on is bad news.
3244
3254
3245 2002-05-13 Fernando Perez <fperez@colorado.edu>
3255 2002-05-13 Fernando Perez <fperez@colorado.edu>
3246
3256
3247 * IPython/Magic.py (Magic._ofind): fixed namespace order search
3257 * IPython/Magic.py (Magic._ofind): fixed namespace order search
3248 bug. Information would be reported about builtins even when
3258 bug. Information would be reported about builtins even when
3249 user-defined functions overrode them.
3259 user-defined functions overrode them.
3250
3260
3251 2002-05-11 Fernando Perez <fperez@colorado.edu>
3261 2002-05-11 Fernando Perez <fperez@colorado.edu>
3252
3262
3253 * IPython/__init__.py (__all__): removed FlexCompleter from
3263 * IPython/__init__.py (__all__): removed FlexCompleter from
3254 __all__ so that things don't fail in platforms without readline.
3264 __all__ so that things don't fail in platforms without readline.
3255
3265
3256 2002-05-10 Fernando Perez <fperez@colorado.edu>
3266 2002-05-10 Fernando Perez <fperez@colorado.edu>
3257
3267
3258 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
3268 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
3259 it requires Numeric, effectively making Numeric a dependency for
3269 it requires Numeric, effectively making Numeric a dependency for
3260 IPython.
3270 IPython.
3261
3271
3262 * Released 0.2.13
3272 * Released 0.2.13
3263
3273
3264 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
3274 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
3265 profiler interface. Now all the major options from the profiler
3275 profiler interface. Now all the major options from the profiler
3266 module are directly supported in IPython, both for single
3276 module are directly supported in IPython, both for single
3267 expressions (@prun) and for full programs (@run -p).
3277 expressions (@prun) and for full programs (@run -p).
3268
3278
3269 2002-05-09 Fernando Perez <fperez@colorado.edu>
3279 2002-05-09 Fernando Perez <fperez@colorado.edu>
3270
3280
3271 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
3281 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
3272 magic properly formatted for screen.
3282 magic properly formatted for screen.
3273
3283
3274 * setup.py (make_shortcut): Changed things to put pdf version in
3284 * setup.py (make_shortcut): Changed things to put pdf version in
3275 doc/ instead of doc/manual (had to change lyxport a bit).
3285 doc/ instead of doc/manual (had to change lyxport a bit).
3276
3286
3277 * IPython/Magic.py (Profile.string_stats): made profile runs go
3287 * IPython/Magic.py (Profile.string_stats): made profile runs go
3278 through pager (they are long and a pager allows searching, saving,
3288 through pager (they are long and a pager allows searching, saving,
3279 etc.)
3289 etc.)
3280
3290
3281 2002-05-08 Fernando Perez <fperez@colorado.edu>
3291 2002-05-08 Fernando Perez <fperez@colorado.edu>
3282
3292
3283 * Released 0.2.12
3293 * Released 0.2.12
3284
3294
3285 2002-05-06 Fernando Perez <fperez@colorado.edu>
3295 2002-05-06 Fernando Perez <fperez@colorado.edu>
3286
3296
3287 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
3297 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
3288 introduced); 'hist n1 n2' was broken.
3298 introduced); 'hist n1 n2' was broken.
3289 (Magic.magic_pdb): added optional on/off arguments to @pdb
3299 (Magic.magic_pdb): added optional on/off arguments to @pdb
3290 (Magic.magic_run): added option -i to @run, which executes code in
3300 (Magic.magic_run): added option -i to @run, which executes code in
3291 the IPython namespace instead of a clean one. Also added @irun as
3301 the IPython namespace instead of a clean one. Also added @irun as
3292 an alias to @run -i.
3302 an alias to @run -i.
3293
3303
3294 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3304 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3295 fixed (it didn't really do anything, the namespaces were wrong).
3305 fixed (it didn't really do anything, the namespaces were wrong).
3296
3306
3297 * IPython/Debugger.py (__init__): Added workaround for python 2.1
3307 * IPython/Debugger.py (__init__): Added workaround for python 2.1
3298
3308
3299 * IPython/__init__.py (__all__): Fixed package namespace, now
3309 * IPython/__init__.py (__all__): Fixed package namespace, now
3300 'import IPython' does give access to IPython.<all> as
3310 'import IPython' does give access to IPython.<all> as
3301 expected. Also renamed __release__ to Release.
3311 expected. Also renamed __release__ to Release.
3302
3312
3303 * IPython/Debugger.py (__license__): created new Pdb class which
3313 * IPython/Debugger.py (__license__): created new Pdb class which
3304 functions like a drop-in for the normal pdb.Pdb but does NOT
3314 functions like a drop-in for the normal pdb.Pdb but does NOT
3305 import readline by default. This way it doesn't muck up IPython's
3315 import readline by default. This way it doesn't muck up IPython's
3306 readline handling, and now tab-completion finally works in the
3316 readline handling, and now tab-completion finally works in the
3307 debugger -- sort of. It completes things globally visible, but the
3317 debugger -- sort of. It completes things globally visible, but the
3308 completer doesn't track the stack as pdb walks it. That's a bit
3318 completer doesn't track the stack as pdb walks it. That's a bit
3309 tricky, and I'll have to implement it later.
3319 tricky, and I'll have to implement it later.
3310
3320
3311 2002-05-05 Fernando Perez <fperez@colorado.edu>
3321 2002-05-05 Fernando Perez <fperez@colorado.edu>
3312
3322
3313 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
3323 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
3314 magic docstrings when printed via ? (explicit \'s were being
3324 magic docstrings when printed via ? (explicit \'s were being
3315 printed).
3325 printed).
3316
3326
3317 * IPython/ipmaker.py (make_IPython): fixed namespace
3327 * IPython/ipmaker.py (make_IPython): fixed namespace
3318 identification bug. Now variables loaded via logs or command-line
3328 identification bug. Now variables loaded via logs or command-line
3319 files are recognized in the interactive namespace by @who.
3329 files are recognized in the interactive namespace by @who.
3320
3330
3321 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
3331 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
3322 log replay system stemming from the string form of Structs.
3332 log replay system stemming from the string form of Structs.
3323
3333
3324 * IPython/Magic.py (Macro.__init__): improved macros to properly
3334 * IPython/Magic.py (Macro.__init__): improved macros to properly
3325 handle magic commands in them.
3335 handle magic commands in them.
3326 (Magic.magic_logstart): usernames are now expanded so 'logstart
3336 (Magic.magic_logstart): usernames are now expanded so 'logstart
3327 ~/mylog' now works.
3337 ~/mylog' now works.
3328
3338
3329 * IPython/iplib.py (complete): fixed bug where paths starting with
3339 * IPython/iplib.py (complete): fixed bug where paths starting with
3330 '/' would be completed as magic names.
3340 '/' would be completed as magic names.
3331
3341
3332 2002-05-04 Fernando Perez <fperez@colorado.edu>
3342 2002-05-04 Fernando Perez <fperez@colorado.edu>
3333
3343
3334 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
3344 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
3335 allow running full programs under the profiler's control.
3345 allow running full programs under the profiler's control.
3336
3346
3337 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
3347 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
3338 mode to report exceptions verbosely but without formatting
3348 mode to report exceptions verbosely but without formatting
3339 variables. This addresses the issue of ipython 'freezing' (it's
3349 variables. This addresses the issue of ipython 'freezing' (it's
3340 not frozen, but caught in an expensive formatting loop) when huge
3350 not frozen, but caught in an expensive formatting loop) when huge
3341 variables are in the context of an exception.
3351 variables are in the context of an exception.
3342 (VerboseTB.text): Added '--->' markers at line where exception was
3352 (VerboseTB.text): Added '--->' markers at line where exception was
3343 triggered. Much clearer to read, especially in NoColor modes.
3353 triggered. Much clearer to read, especially in NoColor modes.
3344
3354
3345 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
3355 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
3346 implemented in reverse when changing to the new parse_options().
3356 implemented in reverse when changing to the new parse_options().
3347
3357
3348 2002-05-03 Fernando Perez <fperez@colorado.edu>
3358 2002-05-03 Fernando Perez <fperez@colorado.edu>
3349
3359
3350 * IPython/Magic.py (Magic.parse_options): new function so that
3360 * IPython/Magic.py (Magic.parse_options): new function so that
3351 magics can parse options easier.
3361 magics can parse options easier.
3352 (Magic.magic_prun): new function similar to profile.run(),
3362 (Magic.magic_prun): new function similar to profile.run(),
3353 suggested by Chris Hart.
3363 suggested by Chris Hart.
3354 (Magic.magic_cd): fixed behavior so that it only changes if
3364 (Magic.magic_cd): fixed behavior so that it only changes if
3355 directory actually is in history.
3365 directory actually is in history.
3356
3366
3357 * IPython/usage.py (__doc__): added information about potential
3367 * IPython/usage.py (__doc__): added information about potential
3358 slowness of Verbose exception mode when there are huge data
3368 slowness of Verbose exception mode when there are huge data
3359 structures to be formatted (thanks to Archie Paulson).
3369 structures to be formatted (thanks to Archie Paulson).
3360
3370
3361 * IPython/ipmaker.py (make_IPython): Changed default logging
3371 * IPython/ipmaker.py (make_IPython): Changed default logging
3362 (when simply called with -log) to use curr_dir/ipython.log in
3372 (when simply called with -log) to use curr_dir/ipython.log in
3363 rotate mode. Fixed crash which was occuring with -log before
3373 rotate mode. Fixed crash which was occuring with -log before
3364 (thanks to Jim Boyle).
3374 (thanks to Jim Boyle).
3365
3375
3366 2002-05-01 Fernando Perez <fperez@colorado.edu>
3376 2002-05-01 Fernando Perez <fperez@colorado.edu>
3367
3377
3368 * Released 0.2.11 for these fixes (mainly the ultraTB one which
3378 * Released 0.2.11 for these fixes (mainly the ultraTB one which
3369 was nasty -- though somewhat of a corner case).
3379 was nasty -- though somewhat of a corner case).
3370
3380
3371 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
3381 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
3372 text (was a bug).
3382 text (was a bug).
3373
3383
3374 2002-04-30 Fernando Perez <fperez@colorado.edu>
3384 2002-04-30 Fernando Perez <fperez@colorado.edu>
3375
3385
3376 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
3386 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
3377 a print after ^D or ^C from the user so that the In[] prompt
3387 a print after ^D or ^C from the user so that the In[] prompt
3378 doesn't over-run the gnuplot one.
3388 doesn't over-run the gnuplot one.
3379
3389
3380 2002-04-29 Fernando Perez <fperez@colorado.edu>
3390 2002-04-29 Fernando Perez <fperez@colorado.edu>
3381
3391
3382 * Released 0.2.10
3392 * Released 0.2.10
3383
3393
3384 * IPython/__release__.py (version): get date dynamically.
3394 * IPython/__release__.py (version): get date dynamically.
3385
3395
3386 * Misc. documentation updates thanks to Arnd's comments. Also ran
3396 * Misc. documentation updates thanks to Arnd's comments. Also ran
3387 a full spellcheck on the manual (hadn't been done in a while).
3397 a full spellcheck on the manual (hadn't been done in a while).
3388
3398
3389 2002-04-27 Fernando Perez <fperez@colorado.edu>
3399 2002-04-27 Fernando Perez <fperez@colorado.edu>
3390
3400
3391 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
3401 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
3392 starting a log in mid-session would reset the input history list.
3402 starting a log in mid-session would reset the input history list.
3393
3403
3394 2002-04-26 Fernando Perez <fperez@colorado.edu>
3404 2002-04-26 Fernando Perez <fperez@colorado.edu>
3395
3405
3396 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
3406 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
3397 all files were being included in an update. Now anything in
3407 all files were being included in an update. Now anything in
3398 UserConfig that matches [A-Za-z]*.py will go (this excludes
3408 UserConfig that matches [A-Za-z]*.py will go (this excludes
3399 __init__.py)
3409 __init__.py)
3400
3410
3401 2002-04-25 Fernando Perez <fperez@colorado.edu>
3411 2002-04-25 Fernando Perez <fperez@colorado.edu>
3402
3412
3403 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
3413 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
3404 to __builtins__ so that any form of embedded or imported code can
3414 to __builtins__ so that any form of embedded or imported code can
3405 test for being inside IPython.
3415 test for being inside IPython.
3406
3416
3407 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3417 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3408 changed to GnuplotMagic because it's now an importable module,
3418 changed to GnuplotMagic because it's now an importable module,
3409 this makes the name follow that of the standard Gnuplot module.
3419 this makes the name follow that of the standard Gnuplot module.
3410 GnuplotMagic can now be loaded at any time in mid-session.
3420 GnuplotMagic can now be loaded at any time in mid-session.
3411
3421
3412 2002-04-24 Fernando Perez <fperez@colorado.edu>
3422 2002-04-24 Fernando Perez <fperez@colorado.edu>
3413
3423
3414 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3424 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3415 the globals (IPython has its own namespace) and the
3425 the globals (IPython has its own namespace) and the
3416 PhysicalQuantity stuff is much better anyway.
3426 PhysicalQuantity stuff is much better anyway.
3417
3427
3418 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3428 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3419 embedding example to standard user directory for
3429 embedding example to standard user directory for
3420 distribution. Also put it in the manual.
3430 distribution. Also put it in the manual.
3421
3431
3422 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3432 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3423 instance as first argument (so it doesn't rely on some obscure
3433 instance as first argument (so it doesn't rely on some obscure
3424 hidden global).
3434 hidden global).
3425
3435
3426 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3436 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3427 delimiters. While it prevents ().TAB from working, it allows
3437 delimiters. While it prevents ().TAB from working, it allows
3428 completions in open (... expressions. This is by far a more common
3438 completions in open (... expressions. This is by far a more common
3429 case.
3439 case.
3430
3440
3431 2002-04-23 Fernando Perez <fperez@colorado.edu>
3441 2002-04-23 Fernando Perez <fperez@colorado.edu>
3432
3442
3433 * IPython/Extensions/InterpreterPasteInput.py: new
3443 * IPython/Extensions/InterpreterPasteInput.py: new
3434 syntax-processing module for pasting lines with >>> or ... at the
3444 syntax-processing module for pasting lines with >>> or ... at the
3435 start.
3445 start.
3436
3446
3437 * IPython/Extensions/PhysicalQ_Interactive.py
3447 * IPython/Extensions/PhysicalQ_Interactive.py
3438 (PhysicalQuantityInteractive.__int__): fixed to work with either
3448 (PhysicalQuantityInteractive.__int__): fixed to work with either
3439 Numeric or math.
3449 Numeric or math.
3440
3450
3441 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3451 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3442 provided profiles. Now we have:
3452 provided profiles. Now we have:
3443 -math -> math module as * and cmath with its own namespace.
3453 -math -> math module as * and cmath with its own namespace.
3444 -numeric -> Numeric as *, plus gnuplot & grace
3454 -numeric -> Numeric as *, plus gnuplot & grace
3445 -physics -> same as before
3455 -physics -> same as before
3446
3456
3447 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3457 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3448 user-defined magics wouldn't be found by @magic if they were
3458 user-defined magics wouldn't be found by @magic if they were
3449 defined as class methods. Also cleaned up the namespace search
3459 defined as class methods. Also cleaned up the namespace search
3450 logic and the string building (to use %s instead of many repeated
3460 logic and the string building (to use %s instead of many repeated
3451 string adds).
3461 string adds).
3452
3462
3453 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3463 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3454 of user-defined magics to operate with class methods (cleaner, in
3464 of user-defined magics to operate with class methods (cleaner, in
3455 line with the gnuplot code).
3465 line with the gnuplot code).
3456
3466
3457 2002-04-22 Fernando Perez <fperez@colorado.edu>
3467 2002-04-22 Fernando Perez <fperez@colorado.edu>
3458
3468
3459 * setup.py: updated dependency list so that manual is updated when
3469 * setup.py: updated dependency list so that manual is updated when
3460 all included files change.
3470 all included files change.
3461
3471
3462 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3472 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3463 the delimiter removal option (the fix is ugly right now).
3473 the delimiter removal option (the fix is ugly right now).
3464
3474
3465 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3475 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3466 all of the math profile (quicker loading, no conflict between
3476 all of the math profile (quicker loading, no conflict between
3467 g-9.8 and g-gnuplot).
3477 g-9.8 and g-gnuplot).
3468
3478
3469 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3479 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3470 name of post-mortem files to IPython_crash_report.txt.
3480 name of post-mortem files to IPython_crash_report.txt.
3471
3481
3472 * Cleanup/update of the docs. Added all the new readline info and
3482 * Cleanup/update of the docs. Added all the new readline info and
3473 formatted all lists as 'real lists'.
3483 formatted all lists as 'real lists'.
3474
3484
3475 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3485 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3476 tab-completion options, since the full readline parse_and_bind is
3486 tab-completion options, since the full readline parse_and_bind is
3477 now accessible.
3487 now accessible.
3478
3488
3479 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3489 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3480 handling of readline options. Now users can specify any string to
3490 handling of readline options. Now users can specify any string to
3481 be passed to parse_and_bind(), as well as the delimiters to be
3491 be passed to parse_and_bind(), as well as the delimiters to be
3482 removed.
3492 removed.
3483 (InteractiveShell.__init__): Added __name__ to the global
3493 (InteractiveShell.__init__): Added __name__ to the global
3484 namespace so that things like Itpl which rely on its existence
3494 namespace so that things like Itpl which rely on its existence
3485 don't crash.
3495 don't crash.
3486 (InteractiveShell._prefilter): Defined the default with a _ so
3496 (InteractiveShell._prefilter): Defined the default with a _ so
3487 that prefilter() is easier to override, while the default one
3497 that prefilter() is easier to override, while the default one
3488 remains available.
3498 remains available.
3489
3499
3490 2002-04-18 Fernando Perez <fperez@colorado.edu>
3500 2002-04-18 Fernando Perez <fperez@colorado.edu>
3491
3501
3492 * Added information about pdb in the docs.
3502 * Added information about pdb in the docs.
3493
3503
3494 2002-04-17 Fernando Perez <fperez@colorado.edu>
3504 2002-04-17 Fernando Perez <fperez@colorado.edu>
3495
3505
3496 * IPython/ipmaker.py (make_IPython): added rc_override option to
3506 * IPython/ipmaker.py (make_IPython): added rc_override option to
3497 allow passing config options at creation time which may override
3507 allow passing config options at creation time which may override
3498 anything set in the config files or command line. This is
3508 anything set in the config files or command line. This is
3499 particularly useful for configuring embedded instances.
3509 particularly useful for configuring embedded instances.
3500
3510
3501 2002-04-15 Fernando Perez <fperez@colorado.edu>
3511 2002-04-15 Fernando Perez <fperez@colorado.edu>
3502
3512
3503 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3513 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3504 crash embedded instances because of the input cache falling out of
3514 crash embedded instances because of the input cache falling out of
3505 sync with the output counter.
3515 sync with the output counter.
3506
3516
3507 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3517 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3508 mode which calls pdb after an uncaught exception in IPython itself.
3518 mode which calls pdb after an uncaught exception in IPython itself.
3509
3519
3510 2002-04-14 Fernando Perez <fperez@colorado.edu>
3520 2002-04-14 Fernando Perez <fperez@colorado.edu>
3511
3521
3512 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3522 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3513 readline, fix it back after each call.
3523 readline, fix it back after each call.
3514
3524
3515 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3525 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3516 method to force all access via __call__(), which guarantees that
3526 method to force all access via __call__(), which guarantees that
3517 traceback references are properly deleted.
3527 traceback references are properly deleted.
3518
3528
3519 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3529 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3520 improve printing when pprint is in use.
3530 improve printing when pprint is in use.
3521
3531
3522 2002-04-13 Fernando Perez <fperez@colorado.edu>
3532 2002-04-13 Fernando Perez <fperez@colorado.edu>
3523
3533
3524 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3534 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3525 exceptions aren't caught anymore. If the user triggers one, he
3535 exceptions aren't caught anymore. If the user triggers one, he
3526 should know why he's doing it and it should go all the way up,
3536 should know why he's doing it and it should go all the way up,
3527 just like any other exception. So now @abort will fully kill the
3537 just like any other exception. So now @abort will fully kill the
3528 embedded interpreter and the embedding code (unless that happens
3538 embedded interpreter and the embedding code (unless that happens
3529 to catch SystemExit).
3539 to catch SystemExit).
3530
3540
3531 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3541 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3532 and a debugger() method to invoke the interactive pdb debugger
3542 and a debugger() method to invoke the interactive pdb debugger
3533 after printing exception information. Also added the corresponding
3543 after printing exception information. Also added the corresponding
3534 -pdb option and @pdb magic to control this feature, and updated
3544 -pdb option and @pdb magic to control this feature, and updated
3535 the docs. After a suggestion from Christopher Hart
3545 the docs. After a suggestion from Christopher Hart
3536 (hart-AT-caltech.edu).
3546 (hart-AT-caltech.edu).
3537
3547
3538 2002-04-12 Fernando Perez <fperez@colorado.edu>
3548 2002-04-12 Fernando Perez <fperez@colorado.edu>
3539
3549
3540 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3550 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3541 the exception handlers defined by the user (not the CrashHandler)
3551 the exception handlers defined by the user (not the CrashHandler)
3542 so that user exceptions don't trigger an ipython bug report.
3552 so that user exceptions don't trigger an ipython bug report.
3543
3553
3544 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3554 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3545 configurable (it should have always been so).
3555 configurable (it should have always been so).
3546
3556
3547 2002-03-26 Fernando Perez <fperez@colorado.edu>
3557 2002-03-26 Fernando Perez <fperez@colorado.edu>
3548
3558
3549 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3559 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3550 and there to fix embedding namespace issues. This should all be
3560 and there to fix embedding namespace issues. This should all be
3551 done in a more elegant way.
3561 done in a more elegant way.
3552
3562
3553 2002-03-25 Fernando Perez <fperez@colorado.edu>
3563 2002-03-25 Fernando Perez <fperez@colorado.edu>
3554
3564
3555 * IPython/genutils.py (get_home_dir): Try to make it work under
3565 * IPython/genutils.py (get_home_dir): Try to make it work under
3556 win9x also.
3566 win9x also.
3557
3567
3558 2002-03-20 Fernando Perez <fperez@colorado.edu>
3568 2002-03-20 Fernando Perez <fperez@colorado.edu>
3559
3569
3560 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3570 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3561 sys.displayhook untouched upon __init__.
3571 sys.displayhook untouched upon __init__.
3562
3572
3563 2002-03-19 Fernando Perez <fperez@colorado.edu>
3573 2002-03-19 Fernando Perez <fperez@colorado.edu>
3564
3574
3565 * Released 0.2.9 (for embedding bug, basically).
3575 * Released 0.2.9 (for embedding bug, basically).
3566
3576
3567 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3577 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3568 exceptions so that enclosing shell's state can be restored.
3578 exceptions so that enclosing shell's state can be restored.
3569
3579
3570 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3580 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3571 naming conventions in the .ipython/ dir.
3581 naming conventions in the .ipython/ dir.
3572
3582
3573 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3583 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3574 from delimiters list so filenames with - in them get expanded.
3584 from delimiters list so filenames with - in them get expanded.
3575
3585
3576 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3586 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3577 sys.displayhook not being properly restored after an embedded call.
3587 sys.displayhook not being properly restored after an embedded call.
3578
3588
3579 2002-03-18 Fernando Perez <fperez@colorado.edu>
3589 2002-03-18 Fernando Perez <fperez@colorado.edu>
3580
3590
3581 * Released 0.2.8
3591 * Released 0.2.8
3582
3592
3583 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3593 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3584 some files weren't being included in a -upgrade.
3594 some files weren't being included in a -upgrade.
3585 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3595 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3586 on' so that the first tab completes.
3596 on' so that the first tab completes.
3587 (InteractiveShell.handle_magic): fixed bug with spaces around
3597 (InteractiveShell.handle_magic): fixed bug with spaces around
3588 quotes breaking many magic commands.
3598 quotes breaking many magic commands.
3589
3599
3590 * setup.py: added note about ignoring the syntax error messages at
3600 * setup.py: added note about ignoring the syntax error messages at
3591 installation.
3601 installation.
3592
3602
3593 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3603 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3594 streamlining the gnuplot interface, now there's only one magic @gp.
3604 streamlining the gnuplot interface, now there's only one magic @gp.
3595
3605
3596 2002-03-17 Fernando Perez <fperez@colorado.edu>
3606 2002-03-17 Fernando Perez <fperez@colorado.edu>
3597
3607
3598 * IPython/UserConfig/magic_gnuplot.py: new name for the
3608 * IPython/UserConfig/magic_gnuplot.py: new name for the
3599 example-magic_pm.py file. Much enhanced system, now with a shell
3609 example-magic_pm.py file. Much enhanced system, now with a shell
3600 for communicating directly with gnuplot, one command at a time.
3610 for communicating directly with gnuplot, one command at a time.
3601
3611
3602 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3612 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3603 setting __name__=='__main__'.
3613 setting __name__=='__main__'.
3604
3614
3605 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3615 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3606 mini-shell for accessing gnuplot from inside ipython. Should
3616 mini-shell for accessing gnuplot from inside ipython. Should
3607 extend it later for grace access too. Inspired by Arnd's
3617 extend it later for grace access too. Inspired by Arnd's
3608 suggestion.
3618 suggestion.
3609
3619
3610 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3620 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3611 calling magic functions with () in their arguments. Thanks to Arnd
3621 calling magic functions with () in their arguments. Thanks to Arnd
3612 Baecker for pointing this to me.
3622 Baecker for pointing this to me.
3613
3623
3614 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3624 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3615 infinitely for integer or complex arrays (only worked with floats).
3625 infinitely for integer or complex arrays (only worked with floats).
3616
3626
3617 2002-03-16 Fernando Perez <fperez@colorado.edu>
3627 2002-03-16 Fernando Perez <fperez@colorado.edu>
3618
3628
3619 * setup.py: Merged setup and setup_windows into a single script
3629 * setup.py: Merged setup and setup_windows into a single script
3620 which properly handles things for windows users.
3630 which properly handles things for windows users.
3621
3631
3622 2002-03-15 Fernando Perez <fperez@colorado.edu>
3632 2002-03-15 Fernando Perez <fperez@colorado.edu>
3623
3633
3624 * Big change to the manual: now the magics are all automatically
3634 * Big change to the manual: now the magics are all automatically
3625 documented. This information is generated from their docstrings
3635 documented. This information is generated from their docstrings
3626 and put in a latex file included by the manual lyx file. This way
3636 and put in a latex file included by the manual lyx file. This way
3627 we get always up to date information for the magics. The manual
3637 we get always up to date information for the magics. The manual
3628 now also has proper version information, also auto-synced.
3638 now also has proper version information, also auto-synced.
3629
3639
3630 For this to work, an undocumented --magic_docstrings option was added.
3640 For this to work, an undocumented --magic_docstrings option was added.
3631
3641
3632 2002-03-13 Fernando Perez <fperez@colorado.edu>
3642 2002-03-13 Fernando Perez <fperez@colorado.edu>
3633
3643
3634 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3644 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3635 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3645 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3636
3646
3637 2002-03-12 Fernando Perez <fperez@colorado.edu>
3647 2002-03-12 Fernando Perez <fperez@colorado.edu>
3638
3648
3639 * IPython/ultraTB.py (TermColors): changed color escapes again to
3649 * IPython/ultraTB.py (TermColors): changed color escapes again to
3640 fix the (old, reintroduced) line-wrapping bug. Basically, if
3650 fix the (old, reintroduced) line-wrapping bug. Basically, if
3641 \001..\002 aren't given in the color escapes, lines get wrapped
3651 \001..\002 aren't given in the color escapes, lines get wrapped
3642 weirdly. But giving those screws up old xterms and emacs terms. So
3652 weirdly. But giving those screws up old xterms and emacs terms. So
3643 I added some logic for emacs terms to be ok, but I can't identify old
3653 I added some logic for emacs terms to be ok, but I can't identify old
3644 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3654 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3645
3655
3646 2002-03-10 Fernando Perez <fperez@colorado.edu>
3656 2002-03-10 Fernando Perez <fperez@colorado.edu>
3647
3657
3648 * IPython/usage.py (__doc__): Various documentation cleanups and
3658 * IPython/usage.py (__doc__): Various documentation cleanups and
3649 updates, both in usage docstrings and in the manual.
3659 updates, both in usage docstrings and in the manual.
3650
3660
3651 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3661 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3652 handling of caching. Set minimum acceptabe value for having a
3662 handling of caching. Set minimum acceptabe value for having a
3653 cache at 20 values.
3663 cache at 20 values.
3654
3664
3655 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3665 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3656 install_first_time function to a method, renamed it and added an
3666 install_first_time function to a method, renamed it and added an
3657 'upgrade' mode. Now people can update their config directory with
3667 'upgrade' mode. Now people can update their config directory with
3658 a simple command line switch (-upgrade, also new).
3668 a simple command line switch (-upgrade, also new).
3659
3669
3660 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3670 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3661 @file (convenient for automagic users under Python >= 2.2).
3671 @file (convenient for automagic users under Python >= 2.2).
3662 Removed @files (it seemed more like a plural than an abbrev. of
3672 Removed @files (it seemed more like a plural than an abbrev. of
3663 'file show').
3673 'file show').
3664
3674
3665 * IPython/iplib.py (install_first_time): Fixed crash if there were
3675 * IPython/iplib.py (install_first_time): Fixed crash if there were
3666 backup files ('~') in .ipython/ install directory.
3676 backup files ('~') in .ipython/ install directory.
3667
3677
3668 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3678 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3669 system. Things look fine, but these changes are fairly
3679 system. Things look fine, but these changes are fairly
3670 intrusive. Test them for a few days.
3680 intrusive. Test them for a few days.
3671
3681
3672 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3682 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3673 the prompts system. Now all in/out prompt strings are user
3683 the prompts system. Now all in/out prompt strings are user
3674 controllable. This is particularly useful for embedding, as one
3684 controllable. This is particularly useful for embedding, as one
3675 can tag embedded instances with particular prompts.
3685 can tag embedded instances with particular prompts.
3676
3686
3677 Also removed global use of sys.ps1/2, which now allows nested
3687 Also removed global use of sys.ps1/2, which now allows nested
3678 embeddings without any problems. Added command-line options for
3688 embeddings without any problems. Added command-line options for
3679 the prompt strings.
3689 the prompt strings.
3680
3690
3681 2002-03-08 Fernando Perez <fperez@colorado.edu>
3691 2002-03-08 Fernando Perez <fperez@colorado.edu>
3682
3692
3683 * IPython/UserConfig/example-embed-short.py (ipshell): added
3693 * IPython/UserConfig/example-embed-short.py (ipshell): added
3684 example file with the bare minimum code for embedding.
3694 example file with the bare minimum code for embedding.
3685
3695
3686 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3696 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3687 functionality for the embeddable shell to be activated/deactivated
3697 functionality for the embeddable shell to be activated/deactivated
3688 either globally or at each call.
3698 either globally or at each call.
3689
3699
3690 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3700 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3691 rewriting the prompt with '--->' for auto-inputs with proper
3701 rewriting the prompt with '--->' for auto-inputs with proper
3692 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3702 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3693 this is handled by the prompts class itself, as it should.
3703 this is handled by the prompts class itself, as it should.
3694
3704
3695 2002-03-05 Fernando Perez <fperez@colorado.edu>
3705 2002-03-05 Fernando Perez <fperez@colorado.edu>
3696
3706
3697 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3707 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3698 @logstart to avoid name clashes with the math log function.
3708 @logstart to avoid name clashes with the math log function.
3699
3709
3700 * Big updates to X/Emacs section of the manual.
3710 * Big updates to X/Emacs section of the manual.
3701
3711
3702 * Removed ipython_emacs. Milan explained to me how to pass
3712 * Removed ipython_emacs. Milan explained to me how to pass
3703 arguments to ipython through Emacs. Some day I'm going to end up
3713 arguments to ipython through Emacs. Some day I'm going to end up
3704 learning some lisp...
3714 learning some lisp...
3705
3715
3706 2002-03-04 Fernando Perez <fperez@colorado.edu>
3716 2002-03-04 Fernando Perez <fperez@colorado.edu>
3707
3717
3708 * IPython/ipython_emacs: Created script to be used as the
3718 * IPython/ipython_emacs: Created script to be used as the
3709 py-python-command Emacs variable so we can pass IPython
3719 py-python-command Emacs variable so we can pass IPython
3710 parameters. I can't figure out how to tell Emacs directly to pass
3720 parameters. I can't figure out how to tell Emacs directly to pass
3711 parameters to IPython, so a dummy shell script will do it.
3721 parameters to IPython, so a dummy shell script will do it.
3712
3722
3713 Other enhancements made for things to work better under Emacs'
3723 Other enhancements made for things to work better under Emacs'
3714 various types of terminals. Many thanks to Milan Zamazal
3724 various types of terminals. Many thanks to Milan Zamazal
3715 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3725 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3716
3726
3717 2002-03-01 Fernando Perez <fperez@colorado.edu>
3727 2002-03-01 Fernando Perez <fperez@colorado.edu>
3718
3728
3719 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3729 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3720 that loading of readline is now optional. This gives better
3730 that loading of readline is now optional. This gives better
3721 control to emacs users.
3731 control to emacs users.
3722
3732
3723 * IPython/ultraTB.py (__date__): Modified color escape sequences
3733 * IPython/ultraTB.py (__date__): Modified color escape sequences
3724 and now things work fine under xterm and in Emacs' term buffers
3734 and now things work fine under xterm and in Emacs' term buffers
3725 (though not shell ones). Well, in emacs you get colors, but all
3735 (though not shell ones). Well, in emacs you get colors, but all
3726 seem to be 'light' colors (no difference between dark and light
3736 seem to be 'light' colors (no difference between dark and light
3727 ones). But the garbage chars are gone, and also in xterms. It
3737 ones). But the garbage chars are gone, and also in xterms. It
3728 seems that now I'm using 'cleaner' ansi sequences.
3738 seems that now I'm using 'cleaner' ansi sequences.
3729
3739
3730 2002-02-21 Fernando Perez <fperez@colorado.edu>
3740 2002-02-21 Fernando Perez <fperez@colorado.edu>
3731
3741
3732 * Released 0.2.7 (mainly to publish the scoping fix).
3742 * Released 0.2.7 (mainly to publish the scoping fix).
3733
3743
3734 * IPython/Logger.py (Logger.logstate): added. A corresponding
3744 * IPython/Logger.py (Logger.logstate): added. A corresponding
3735 @logstate magic was created.
3745 @logstate magic was created.
3736
3746
3737 * IPython/Magic.py: fixed nested scoping problem under Python
3747 * IPython/Magic.py: fixed nested scoping problem under Python
3738 2.1.x (automagic wasn't working).
3748 2.1.x (automagic wasn't working).
3739
3749
3740 2002-02-20 Fernando Perez <fperez@colorado.edu>
3750 2002-02-20 Fernando Perez <fperez@colorado.edu>
3741
3751
3742 * Released 0.2.6.
3752 * Released 0.2.6.
3743
3753
3744 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
3754 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
3745 option so that logs can come out without any headers at all.
3755 option so that logs can come out without any headers at all.
3746
3756
3747 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
3757 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
3748 SciPy.
3758 SciPy.
3749
3759
3750 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
3760 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
3751 that embedded IPython calls don't require vars() to be explicitly
3761 that embedded IPython calls don't require vars() to be explicitly
3752 passed. Now they are extracted from the caller's frame (code
3762 passed. Now they are extracted from the caller's frame (code
3753 snatched from Eric Jones' weave). Added better documentation to
3763 snatched from Eric Jones' weave). Added better documentation to
3754 the section on embedding and the example file.
3764 the section on embedding and the example file.
3755
3765
3756 * IPython/genutils.py (page): Changed so that under emacs, it just
3766 * IPython/genutils.py (page): Changed so that under emacs, it just
3757 prints the string. You can then page up and down in the emacs
3767 prints the string. You can then page up and down in the emacs
3758 buffer itself. This is how the builtin help() works.
3768 buffer itself. This is how the builtin help() works.
3759
3769
3760 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
3770 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
3761 macro scoping: macros need to be executed in the user's namespace
3771 macro scoping: macros need to be executed in the user's namespace
3762 to work as if they had been typed by the user.
3772 to work as if they had been typed by the user.
3763
3773
3764 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
3774 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
3765 execute automatically (no need to type 'exec...'). They then
3775 execute automatically (no need to type 'exec...'). They then
3766 behave like 'true macros'. The printing system was also modified
3776 behave like 'true macros'. The printing system was also modified
3767 for this to work.
3777 for this to work.
3768
3778
3769 2002-02-19 Fernando Perez <fperez@colorado.edu>
3779 2002-02-19 Fernando Perez <fperez@colorado.edu>
3770
3780
3771 * IPython/genutils.py (page_file): new function for paging files
3781 * IPython/genutils.py (page_file): new function for paging files
3772 in an OS-independent way. Also necessary for file viewing to work
3782 in an OS-independent way. Also necessary for file viewing to work
3773 well inside Emacs buffers.
3783 well inside Emacs buffers.
3774 (page): Added checks for being in an emacs buffer.
3784 (page): Added checks for being in an emacs buffer.
3775 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
3785 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
3776 same bug in iplib.
3786 same bug in iplib.
3777
3787
3778 2002-02-18 Fernando Perez <fperez@colorado.edu>
3788 2002-02-18 Fernando Perez <fperez@colorado.edu>
3779
3789
3780 * IPython/iplib.py (InteractiveShell.init_readline): modified use
3790 * IPython/iplib.py (InteractiveShell.init_readline): modified use
3781 of readline so that IPython can work inside an Emacs buffer.
3791 of readline so that IPython can work inside an Emacs buffer.
3782
3792
3783 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
3793 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
3784 method signatures (they weren't really bugs, but it looks cleaner
3794 method signatures (they weren't really bugs, but it looks cleaner
3785 and keeps PyChecker happy).
3795 and keeps PyChecker happy).
3786
3796
3787 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
3797 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
3788 for implementing various user-defined hooks. Currently only
3798 for implementing various user-defined hooks. Currently only
3789 display is done.
3799 display is done.
3790
3800
3791 * IPython/Prompts.py (CachedOutput._display): changed display
3801 * IPython/Prompts.py (CachedOutput._display): changed display
3792 functions so that they can be dynamically changed by users easily.
3802 functions so that they can be dynamically changed by users easily.
3793
3803
3794 * IPython/Extensions/numeric_formats.py (num_display): added an
3804 * IPython/Extensions/numeric_formats.py (num_display): added an
3795 extension for printing NumPy arrays in flexible manners. It
3805 extension for printing NumPy arrays in flexible manners. It
3796 doesn't do anything yet, but all the structure is in
3806 doesn't do anything yet, but all the structure is in
3797 place. Ultimately the plan is to implement output format control
3807 place. Ultimately the plan is to implement output format control
3798 like in Octave.
3808 like in Octave.
3799
3809
3800 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
3810 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
3801 methods are found at run-time by all the automatic machinery.
3811 methods are found at run-time by all the automatic machinery.
3802
3812
3803 2002-02-17 Fernando Perez <fperez@colorado.edu>
3813 2002-02-17 Fernando Perez <fperez@colorado.edu>
3804
3814
3805 * setup_Windows.py (make_shortcut): documented. Cleaned up the
3815 * setup_Windows.py (make_shortcut): documented. Cleaned up the
3806 whole file a little.
3816 whole file a little.
3807
3817
3808 * ToDo: closed this document. Now there's a new_design.lyx
3818 * ToDo: closed this document. Now there's a new_design.lyx
3809 document for all new ideas. Added making a pdf of it for the
3819 document for all new ideas. Added making a pdf of it for the
3810 end-user distro.
3820 end-user distro.
3811
3821
3812 * IPython/Logger.py (Logger.switch_log): Created this to replace
3822 * IPython/Logger.py (Logger.switch_log): Created this to replace
3813 logon() and logoff(). It also fixes a nasty crash reported by
3823 logon() and logoff(). It also fixes a nasty crash reported by
3814 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
3824 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
3815
3825
3816 * IPython/iplib.py (complete): got auto-completion to work with
3826 * IPython/iplib.py (complete): got auto-completion to work with
3817 automagic (I had wanted this for a long time).
3827 automagic (I had wanted this for a long time).
3818
3828
3819 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
3829 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
3820 to @file, since file() is now a builtin and clashes with automagic
3830 to @file, since file() is now a builtin and clashes with automagic
3821 for @file.
3831 for @file.
3822
3832
3823 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
3833 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
3824 of this was previously in iplib, which had grown to more than 2000
3834 of this was previously in iplib, which had grown to more than 2000
3825 lines, way too long. No new functionality, but it makes managing
3835 lines, way too long. No new functionality, but it makes managing
3826 the code a bit easier.
3836 the code a bit easier.
3827
3837
3828 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
3838 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
3829 information to crash reports.
3839 information to crash reports.
3830
3840
3831 2002-02-12 Fernando Perez <fperez@colorado.edu>
3841 2002-02-12 Fernando Perez <fperez@colorado.edu>
3832
3842
3833 * Released 0.2.5.
3843 * Released 0.2.5.
3834
3844
3835 2002-02-11 Fernando Perez <fperez@colorado.edu>
3845 2002-02-11 Fernando Perez <fperez@colorado.edu>
3836
3846
3837 * Wrote a relatively complete Windows installer. It puts
3847 * Wrote a relatively complete Windows installer. It puts
3838 everything in place, creates Start Menu entries and fixes the
3848 everything in place, creates Start Menu entries and fixes the
3839 color issues. Nothing fancy, but it works.
3849 color issues. Nothing fancy, but it works.
3840
3850
3841 2002-02-10 Fernando Perez <fperez@colorado.edu>
3851 2002-02-10 Fernando Perez <fperez@colorado.edu>
3842
3852
3843 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
3853 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
3844 os.path.expanduser() call so that we can type @run ~/myfile.py and
3854 os.path.expanduser() call so that we can type @run ~/myfile.py and
3845 have thigs work as expected.
3855 have thigs work as expected.
3846
3856
3847 * IPython/genutils.py (page): fixed exception handling so things
3857 * IPython/genutils.py (page): fixed exception handling so things
3848 work both in Unix and Windows correctly. Quitting a pager triggers
3858 work both in Unix and Windows correctly. Quitting a pager triggers
3849 an IOError/broken pipe in Unix, and in windows not finding a pager
3859 an IOError/broken pipe in Unix, and in windows not finding a pager
3850 is also an IOError, so I had to actually look at the return value
3860 is also an IOError, so I had to actually look at the return value
3851 of the exception, not just the exception itself. Should be ok now.
3861 of the exception, not just the exception itself. Should be ok now.
3852
3862
3853 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
3863 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
3854 modified to allow case-insensitive color scheme changes.
3864 modified to allow case-insensitive color scheme changes.
3855
3865
3856 2002-02-09 Fernando Perez <fperez@colorado.edu>
3866 2002-02-09 Fernando Perez <fperez@colorado.edu>
3857
3867
3858 * IPython/genutils.py (native_line_ends): new function to leave
3868 * IPython/genutils.py (native_line_ends): new function to leave
3859 user config files with os-native line-endings.
3869 user config files with os-native line-endings.
3860
3870
3861 * README and manual updates.
3871 * README and manual updates.
3862
3872
3863 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
3873 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
3864 instead of StringType to catch Unicode strings.
3874 instead of StringType to catch Unicode strings.
3865
3875
3866 * IPython/genutils.py (filefind): fixed bug for paths with
3876 * IPython/genutils.py (filefind): fixed bug for paths with
3867 embedded spaces (very common in Windows).
3877 embedded spaces (very common in Windows).
3868
3878
3869 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
3879 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
3870 files under Windows, so that they get automatically associated
3880 files under Windows, so that they get automatically associated
3871 with a text editor. Windows makes it a pain to handle
3881 with a text editor. Windows makes it a pain to handle
3872 extension-less files.
3882 extension-less files.
3873
3883
3874 * IPython/iplib.py (InteractiveShell.init_readline): Made the
3884 * IPython/iplib.py (InteractiveShell.init_readline): Made the
3875 warning about readline only occur for Posix. In Windows there's no
3885 warning about readline only occur for Posix. In Windows there's no
3876 way to get readline, so why bother with the warning.
3886 way to get readline, so why bother with the warning.
3877
3887
3878 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
3888 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
3879 for __str__ instead of dir(self), since dir() changed in 2.2.
3889 for __str__ instead of dir(self), since dir() changed in 2.2.
3880
3890
3881 * Ported to Windows! Tested on XP, I suspect it should work fine
3891 * Ported to Windows! Tested on XP, I suspect it should work fine
3882 on NT/2000, but I don't think it will work on 98 et al. That
3892 on NT/2000, but I don't think it will work on 98 et al. That
3883 series of Windows is such a piece of junk anyway that I won't try
3893 series of Windows is such a piece of junk anyway that I won't try
3884 porting it there. The XP port was straightforward, showed a few
3894 porting it there. The XP port was straightforward, showed a few
3885 bugs here and there (fixed all), in particular some string
3895 bugs here and there (fixed all), in particular some string
3886 handling stuff which required considering Unicode strings (which
3896 handling stuff which required considering Unicode strings (which
3887 Windows uses). This is good, but hasn't been too tested :) No
3897 Windows uses). This is good, but hasn't been too tested :) No
3888 fancy installer yet, I'll put a note in the manual so people at
3898 fancy installer yet, I'll put a note in the manual so people at
3889 least make manually a shortcut.
3899 least make manually a shortcut.
3890
3900
3891 * IPython/iplib.py (Magic.magic_colors): Unified the color options
3901 * IPython/iplib.py (Magic.magic_colors): Unified the color options
3892 into a single one, "colors". This now controls both prompt and
3902 into a single one, "colors". This now controls both prompt and
3893 exception color schemes, and can be changed both at startup
3903 exception color schemes, and can be changed both at startup
3894 (either via command-line switches or via ipythonrc files) and at
3904 (either via command-line switches or via ipythonrc files) and at
3895 runtime, with @colors.
3905 runtime, with @colors.
3896 (Magic.magic_run): renamed @prun to @run and removed the old
3906 (Magic.magic_run): renamed @prun to @run and removed the old
3897 @run. The two were too similar to warrant keeping both.
3907 @run. The two were too similar to warrant keeping both.
3898
3908
3899 2002-02-03 Fernando Perez <fperez@colorado.edu>
3909 2002-02-03 Fernando Perez <fperez@colorado.edu>
3900
3910
3901 * IPython/iplib.py (install_first_time): Added comment on how to
3911 * IPython/iplib.py (install_first_time): Added comment on how to
3902 configure the color options for first-time users. Put a <return>
3912 configure the color options for first-time users. Put a <return>
3903 request at the end so that small-terminal users get a chance to
3913 request at the end so that small-terminal users get a chance to
3904 read the startup info.
3914 read the startup info.
3905
3915
3906 2002-01-23 Fernando Perez <fperez@colorado.edu>
3916 2002-01-23 Fernando Perez <fperez@colorado.edu>
3907
3917
3908 * IPython/iplib.py (CachedOutput.update): Changed output memory
3918 * IPython/iplib.py (CachedOutput.update): Changed output memory
3909 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
3919 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
3910 input history we still use _i. Did this b/c these variable are
3920 input history we still use _i. Did this b/c these variable are
3911 very commonly used in interactive work, so the less we need to
3921 very commonly used in interactive work, so the less we need to
3912 type the better off we are.
3922 type the better off we are.
3913 (Magic.magic_prun): updated @prun to better handle the namespaces
3923 (Magic.magic_prun): updated @prun to better handle the namespaces
3914 the file will run in, including a fix for __name__ not being set
3924 the file will run in, including a fix for __name__ not being set
3915 before.
3925 before.
3916
3926
3917 2002-01-20 Fernando Perez <fperez@colorado.edu>
3927 2002-01-20 Fernando Perez <fperez@colorado.edu>
3918
3928
3919 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
3929 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
3920 extra garbage for Python 2.2. Need to look more carefully into
3930 extra garbage for Python 2.2. Need to look more carefully into
3921 this later.
3931 this later.
3922
3932
3923 2002-01-19 Fernando Perez <fperez@colorado.edu>
3933 2002-01-19 Fernando Perez <fperez@colorado.edu>
3924
3934
3925 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
3935 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
3926 display SyntaxError exceptions properly formatted when they occur
3936 display SyntaxError exceptions properly formatted when they occur
3927 (they can be triggered by imported code).
3937 (they can be triggered by imported code).
3928
3938
3929 2002-01-18 Fernando Perez <fperez@colorado.edu>
3939 2002-01-18 Fernando Perez <fperez@colorado.edu>
3930
3940
3931 * IPython/iplib.py (InteractiveShell.safe_execfile): now
3941 * IPython/iplib.py (InteractiveShell.safe_execfile): now
3932 SyntaxError exceptions are reported nicely formatted, instead of
3942 SyntaxError exceptions are reported nicely formatted, instead of
3933 spitting out only offset information as before.
3943 spitting out only offset information as before.
3934 (Magic.magic_prun): Added the @prun function for executing
3944 (Magic.magic_prun): Added the @prun function for executing
3935 programs with command line args inside IPython.
3945 programs with command line args inside IPython.
3936
3946
3937 2002-01-16 Fernando Perez <fperez@colorado.edu>
3947 2002-01-16 Fernando Perez <fperez@colorado.edu>
3938
3948
3939 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
3949 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
3940 to *not* include the last item given in a range. This brings their
3950 to *not* include the last item given in a range. This brings their
3941 behavior in line with Python's slicing:
3951 behavior in line with Python's slicing:
3942 a[n1:n2] -> a[n1]...a[n2-1]
3952 a[n1:n2] -> a[n1]...a[n2-1]
3943 It may be a bit less convenient, but I prefer to stick to Python's
3953 It may be a bit less convenient, but I prefer to stick to Python's
3944 conventions *everywhere*, so users never have to wonder.
3954 conventions *everywhere*, so users never have to wonder.
3945 (Magic.magic_macro): Added @macro function to ease the creation of
3955 (Magic.magic_macro): Added @macro function to ease the creation of
3946 macros.
3956 macros.
3947
3957
3948 2002-01-05 Fernando Perez <fperez@colorado.edu>
3958 2002-01-05 Fernando Perez <fperez@colorado.edu>
3949
3959
3950 * Released 0.2.4.
3960 * Released 0.2.4.
3951
3961
3952 * IPython/iplib.py (Magic.magic_pdef):
3962 * IPython/iplib.py (Magic.magic_pdef):
3953 (InteractiveShell.safe_execfile): report magic lines and error
3963 (InteractiveShell.safe_execfile): report magic lines and error
3954 lines without line numbers so one can easily copy/paste them for
3964 lines without line numbers so one can easily copy/paste them for
3955 re-execution.
3965 re-execution.
3956
3966
3957 * Updated manual with recent changes.
3967 * Updated manual with recent changes.
3958
3968
3959 * IPython/iplib.py (Magic.magic_oinfo): added constructor
3969 * IPython/iplib.py (Magic.magic_oinfo): added constructor
3960 docstring printing when class? is called. Very handy for knowing
3970 docstring printing when class? is called. Very handy for knowing
3961 how to create class instances (as long as __init__ is well
3971 how to create class instances (as long as __init__ is well
3962 documented, of course :)
3972 documented, of course :)
3963 (Magic.magic_doc): print both class and constructor docstrings.
3973 (Magic.magic_doc): print both class and constructor docstrings.
3964 (Magic.magic_pdef): give constructor info if passed a class and
3974 (Magic.magic_pdef): give constructor info if passed a class and
3965 __call__ info for callable object instances.
3975 __call__ info for callable object instances.
3966
3976
3967 2002-01-04 Fernando Perez <fperez@colorado.edu>
3977 2002-01-04 Fernando Perez <fperez@colorado.edu>
3968
3978
3969 * Made deep_reload() off by default. It doesn't always work
3979 * Made deep_reload() off by default. It doesn't always work
3970 exactly as intended, so it's probably safer to have it off. It's
3980 exactly as intended, so it's probably safer to have it off. It's
3971 still available as dreload() anyway, so nothing is lost.
3981 still available as dreload() anyway, so nothing is lost.
3972
3982
3973 2002-01-02 Fernando Perez <fperez@colorado.edu>
3983 2002-01-02 Fernando Perez <fperez@colorado.edu>
3974
3984
3975 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
3985 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
3976 so I wanted an updated release).
3986 so I wanted an updated release).
3977
3987
3978 2001-12-27 Fernando Perez <fperez@colorado.edu>
3988 2001-12-27 Fernando Perez <fperez@colorado.edu>
3979
3989
3980 * IPython/iplib.py (InteractiveShell.interact): Added the original
3990 * IPython/iplib.py (InteractiveShell.interact): Added the original
3981 code from 'code.py' for this module in order to change the
3991 code from 'code.py' for this module in order to change the
3982 handling of a KeyboardInterrupt. This was necessary b/c otherwise
3992 handling of a KeyboardInterrupt. This was necessary b/c otherwise
3983 the history cache would break when the user hit Ctrl-C, and
3993 the history cache would break when the user hit Ctrl-C, and
3984 interact() offers no way to add any hooks to it.
3994 interact() offers no way to add any hooks to it.
3985
3995
3986 2001-12-23 Fernando Perez <fperez@colorado.edu>
3996 2001-12-23 Fernando Perez <fperez@colorado.edu>
3987
3997
3988 * setup.py: added check for 'MANIFEST' before trying to remove
3998 * setup.py: added check for 'MANIFEST' before trying to remove
3989 it. Thanks to Sean Reifschneider.
3999 it. Thanks to Sean Reifschneider.
3990
4000
3991 2001-12-22 Fernando Perez <fperez@colorado.edu>
4001 2001-12-22 Fernando Perez <fperez@colorado.edu>
3992
4002
3993 * Released 0.2.2.
4003 * Released 0.2.2.
3994
4004
3995 * Finished (reasonably) writing the manual. Later will add the
4005 * Finished (reasonably) writing the manual. Later will add the
3996 python-standard navigation stylesheets, but for the time being
4006 python-standard navigation stylesheets, but for the time being
3997 it's fairly complete. Distribution will include html and pdf
4007 it's fairly complete. Distribution will include html and pdf
3998 versions.
4008 versions.
3999
4009
4000 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
4010 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
4001 (MayaVi author).
4011 (MayaVi author).
4002
4012
4003 2001-12-21 Fernando Perez <fperez@colorado.edu>
4013 2001-12-21 Fernando Perez <fperez@colorado.edu>
4004
4014
4005 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
4015 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
4006 good public release, I think (with the manual and the distutils
4016 good public release, I think (with the manual and the distutils
4007 installer). The manual can use some work, but that can go
4017 installer). The manual can use some work, but that can go
4008 slowly. Otherwise I think it's quite nice for end users. Next
4018 slowly. Otherwise I think it's quite nice for end users. Next
4009 summer, rewrite the guts of it...
4019 summer, rewrite the guts of it...
4010
4020
4011 * Changed format of ipythonrc files to use whitespace as the
4021 * Changed format of ipythonrc files to use whitespace as the
4012 separator instead of an explicit '='. Cleaner.
4022 separator instead of an explicit '='. Cleaner.
4013
4023
4014 2001-12-20 Fernando Perez <fperez@colorado.edu>
4024 2001-12-20 Fernando Perez <fperez@colorado.edu>
4015
4025
4016 * Started a manual in LyX. For now it's just a quick merge of the
4026 * Started a manual in LyX. For now it's just a quick merge of the
4017 various internal docstrings and READMEs. Later it may grow into a
4027 various internal docstrings and READMEs. Later it may grow into a
4018 nice, full-blown manual.
4028 nice, full-blown manual.
4019
4029
4020 * Set up a distutils based installer. Installation should now be
4030 * Set up a distutils based installer. Installation should now be
4021 trivially simple for end-users.
4031 trivially simple for end-users.
4022
4032
4023 2001-12-11 Fernando Perez <fperez@colorado.edu>
4033 2001-12-11 Fernando Perez <fperez@colorado.edu>
4024
4034
4025 * Released 0.2.0. First public release, announced it at
4035 * Released 0.2.0. First public release, announced it at
4026 comp.lang.python. From now on, just bugfixes...
4036 comp.lang.python. From now on, just bugfixes...
4027
4037
4028 * Went through all the files, set copyright/license notices and
4038 * Went through all the files, set copyright/license notices and
4029 cleaned up things. Ready for release.
4039 cleaned up things. Ready for release.
4030
4040
4031 2001-12-10 Fernando Perez <fperez@colorado.edu>
4041 2001-12-10 Fernando Perez <fperez@colorado.edu>
4032
4042
4033 * Changed the first-time installer not to use tarfiles. It's more
4043 * Changed the first-time installer not to use tarfiles. It's more
4034 robust now and less unix-dependent. Also makes it easier for
4044 robust now and less unix-dependent. Also makes it easier for
4035 people to later upgrade versions.
4045 people to later upgrade versions.
4036
4046
4037 * Changed @exit to @abort to reflect the fact that it's pretty
4047 * Changed @exit to @abort to reflect the fact that it's pretty
4038 brutal (a sys.exit()). The difference between @abort and Ctrl-D
4048 brutal (a sys.exit()). The difference between @abort and Ctrl-D
4039 becomes significant only when IPyhton is embedded: in that case,
4049 becomes significant only when IPyhton is embedded: in that case,
4040 C-D closes IPython only, but @abort kills the enclosing program
4050 C-D closes IPython only, but @abort kills the enclosing program
4041 too (unless it had called IPython inside a try catching
4051 too (unless it had called IPython inside a try catching
4042 SystemExit).
4052 SystemExit).
4043
4053
4044 * Created Shell module which exposes the actuall IPython Shell
4054 * Created Shell module which exposes the actuall IPython Shell
4045 classes, currently the normal and the embeddable one. This at
4055 classes, currently the normal and the embeddable one. This at
4046 least offers a stable interface we won't need to change when
4056 least offers a stable interface we won't need to change when
4047 (later) the internals are rewritten. That rewrite will be confined
4057 (later) the internals are rewritten. That rewrite will be confined
4048 to iplib and ipmaker, but the Shell interface should remain as is.
4058 to iplib and ipmaker, but the Shell interface should remain as is.
4049
4059
4050 * Added embed module which offers an embeddable IPShell object,
4060 * Added embed module which offers an embeddable IPShell object,
4051 useful to fire up IPython *inside* a running program. Great for
4061 useful to fire up IPython *inside* a running program. Great for
4052 debugging or dynamical data analysis.
4062 debugging or dynamical data analysis.
4053
4063
4054 2001-12-08 Fernando Perez <fperez@colorado.edu>
4064 2001-12-08 Fernando Perez <fperez@colorado.edu>
4055
4065
4056 * Fixed small bug preventing seeing info from methods of defined
4066 * Fixed small bug preventing seeing info from methods of defined
4057 objects (incorrect namespace in _ofind()).
4067 objects (incorrect namespace in _ofind()).
4058
4068
4059 * Documentation cleanup. Moved the main usage docstrings to a
4069 * Documentation cleanup. Moved the main usage docstrings to a
4060 separate file, usage.py (cleaner to maintain, and hopefully in the
4070 separate file, usage.py (cleaner to maintain, and hopefully in the
4061 future some perlpod-like way of producing interactive, man and
4071 future some perlpod-like way of producing interactive, man and
4062 html docs out of it will be found).
4072 html docs out of it will be found).
4063
4073
4064 * Added @profile to see your profile at any time.
4074 * Added @profile to see your profile at any time.
4065
4075
4066 * Added @p as an alias for 'print'. It's especially convenient if
4076 * Added @p as an alias for 'print'. It's especially convenient if
4067 using automagic ('p x' prints x).
4077 using automagic ('p x' prints x).
4068
4078
4069 * Small cleanups and fixes after a pychecker run.
4079 * Small cleanups and fixes after a pychecker run.
4070
4080
4071 * Changed the @cd command to handle @cd - and @cd -<n> for
4081 * Changed the @cd command to handle @cd - and @cd -<n> for
4072 visiting any directory in _dh.
4082 visiting any directory in _dh.
4073
4083
4074 * Introduced _dh, a history of visited directories. @dhist prints
4084 * Introduced _dh, a history of visited directories. @dhist prints
4075 it out with numbers.
4085 it out with numbers.
4076
4086
4077 2001-12-07 Fernando Perez <fperez@colorado.edu>
4087 2001-12-07 Fernando Perez <fperez@colorado.edu>
4078
4088
4079 * Released 0.1.22
4089 * Released 0.1.22
4080
4090
4081 * Made initialization a bit more robust against invalid color
4091 * Made initialization a bit more robust against invalid color
4082 options in user input (exit, not traceback-crash).
4092 options in user input (exit, not traceback-crash).
4083
4093
4084 * Changed the bug crash reporter to write the report only in the
4094 * Changed the bug crash reporter to write the report only in the
4085 user's .ipython directory. That way IPython won't litter people's
4095 user's .ipython directory. That way IPython won't litter people's
4086 hard disks with crash files all over the place. Also print on
4096 hard disks with crash files all over the place. Also print on
4087 screen the necessary mail command.
4097 screen the necessary mail command.
4088
4098
4089 * With the new ultraTB, implemented LightBG color scheme for light
4099 * With the new ultraTB, implemented LightBG color scheme for light
4090 background terminals. A lot of people like white backgrounds, so I
4100 background terminals. A lot of people like white backgrounds, so I
4091 guess we should at least give them something readable.
4101 guess we should at least give them something readable.
4092
4102
4093 2001-12-06 Fernando Perez <fperez@colorado.edu>
4103 2001-12-06 Fernando Perez <fperez@colorado.edu>
4094
4104
4095 * Modified the structure of ultraTB. Now there's a proper class
4105 * Modified the structure of ultraTB. Now there's a proper class
4096 for tables of color schemes which allow adding schemes easily and
4106 for tables of color schemes which allow adding schemes easily and
4097 switching the active scheme without creating a new instance every
4107 switching the active scheme without creating a new instance every
4098 time (which was ridiculous). The syntax for creating new schemes
4108 time (which was ridiculous). The syntax for creating new schemes
4099 is also cleaner. I think ultraTB is finally done, with a clean
4109 is also cleaner. I think ultraTB is finally done, with a clean
4100 class structure. Names are also much cleaner (now there's proper
4110 class structure. Names are also much cleaner (now there's proper
4101 color tables, no need for every variable to also have 'color' in
4111 color tables, no need for every variable to also have 'color' in
4102 its name).
4112 its name).
4103
4113
4104 * Broke down genutils into separate files. Now genutils only
4114 * Broke down genutils into separate files. Now genutils only
4105 contains utility functions, and classes have been moved to their
4115 contains utility functions, and classes have been moved to their
4106 own files (they had enough independent functionality to warrant
4116 own files (they had enough independent functionality to warrant
4107 it): ConfigLoader, OutputTrap, Struct.
4117 it): ConfigLoader, OutputTrap, Struct.
4108
4118
4109 2001-12-05 Fernando Perez <fperez@colorado.edu>
4119 2001-12-05 Fernando Perez <fperez@colorado.edu>
4110
4120
4111 * IPython turns 21! Released version 0.1.21, as a candidate for
4121 * IPython turns 21! Released version 0.1.21, as a candidate for
4112 public consumption. If all goes well, release in a few days.
4122 public consumption. If all goes well, release in a few days.
4113
4123
4114 * Fixed path bug (files in Extensions/ directory wouldn't be found
4124 * Fixed path bug (files in Extensions/ directory wouldn't be found
4115 unless IPython/ was explicitly in sys.path).
4125 unless IPython/ was explicitly in sys.path).
4116
4126
4117 * Extended the FlexCompleter class as MagicCompleter to allow
4127 * Extended the FlexCompleter class as MagicCompleter to allow
4118 completion of @-starting lines.
4128 completion of @-starting lines.
4119
4129
4120 * Created __release__.py file as a central repository for release
4130 * Created __release__.py file as a central repository for release
4121 info that other files can read from.
4131 info that other files can read from.
4122
4132
4123 * Fixed small bug in logging: when logging was turned on in
4133 * Fixed small bug in logging: when logging was turned on in
4124 mid-session, old lines with special meanings (!@?) were being
4134 mid-session, old lines with special meanings (!@?) were being
4125 logged without the prepended comment, which is necessary since
4135 logged without the prepended comment, which is necessary since
4126 they are not truly valid python syntax. This should make session
4136 they are not truly valid python syntax. This should make session
4127 restores produce less errors.
4137 restores produce less errors.
4128
4138
4129 * The namespace cleanup forced me to make a FlexCompleter class
4139 * The namespace cleanup forced me to make a FlexCompleter class
4130 which is nothing but a ripoff of rlcompleter, but with selectable
4140 which is nothing but a ripoff of rlcompleter, but with selectable
4131 namespace (rlcompleter only works in __main__.__dict__). I'll try
4141 namespace (rlcompleter only works in __main__.__dict__). I'll try
4132 to submit a note to the authors to see if this change can be
4142 to submit a note to the authors to see if this change can be
4133 incorporated in future rlcompleter releases (Dec.6: done)
4143 incorporated in future rlcompleter releases (Dec.6: done)
4134
4144
4135 * More fixes to namespace handling. It was a mess! Now all
4145 * More fixes to namespace handling. It was a mess! Now all
4136 explicit references to __main__.__dict__ are gone (except when
4146 explicit references to __main__.__dict__ are gone (except when
4137 really needed) and everything is handled through the namespace
4147 really needed) and everything is handled through the namespace
4138 dicts in the IPython instance. We seem to be getting somewhere
4148 dicts in the IPython instance. We seem to be getting somewhere
4139 with this, finally...
4149 with this, finally...
4140
4150
4141 * Small documentation updates.
4151 * Small documentation updates.
4142
4152
4143 * Created the Extensions directory under IPython (with an
4153 * Created the Extensions directory under IPython (with an
4144 __init__.py). Put the PhysicalQ stuff there. This directory should
4154 __init__.py). Put the PhysicalQ stuff there. This directory should
4145 be used for all special-purpose extensions.
4155 be used for all special-purpose extensions.
4146
4156
4147 * File renaming:
4157 * File renaming:
4148 ipythonlib --> ipmaker
4158 ipythonlib --> ipmaker
4149 ipplib --> iplib
4159 ipplib --> iplib
4150 This makes a bit more sense in terms of what these files actually do.
4160 This makes a bit more sense in terms of what these files actually do.
4151
4161
4152 * Moved all the classes and functions in ipythonlib to ipplib, so
4162 * Moved all the classes and functions in ipythonlib to ipplib, so
4153 now ipythonlib only has make_IPython(). This will ease up its
4163 now ipythonlib only has make_IPython(). This will ease up its
4154 splitting in smaller functional chunks later.
4164 splitting in smaller functional chunks later.
4155
4165
4156 * Cleaned up (done, I think) output of @whos. Better column
4166 * Cleaned up (done, I think) output of @whos. Better column
4157 formatting, and now shows str(var) for as much as it can, which is
4167 formatting, and now shows str(var) for as much as it can, which is
4158 typically what one gets with a 'print var'.
4168 typically what one gets with a 'print var'.
4159
4169
4160 2001-12-04 Fernando Perez <fperez@colorado.edu>
4170 2001-12-04 Fernando Perez <fperez@colorado.edu>
4161
4171
4162 * Fixed namespace problems. Now builtin/IPyhton/user names get
4172 * Fixed namespace problems. Now builtin/IPyhton/user names get
4163 properly reported in their namespace. Internal namespace handling
4173 properly reported in their namespace. Internal namespace handling
4164 is finally getting decent (not perfect yet, but much better than
4174 is finally getting decent (not perfect yet, but much better than
4165 the ad-hoc mess we had).
4175 the ad-hoc mess we had).
4166
4176
4167 * Removed -exit option. If people just want to run a python
4177 * Removed -exit option. If people just want to run a python
4168 script, that's what the normal interpreter is for. Less
4178 script, that's what the normal interpreter is for. Less
4169 unnecessary options, less chances for bugs.
4179 unnecessary options, less chances for bugs.
4170
4180
4171 * Added a crash handler which generates a complete post-mortem if
4181 * Added a crash handler which generates a complete post-mortem if
4172 IPython crashes. This will help a lot in tracking bugs down the
4182 IPython crashes. This will help a lot in tracking bugs down the
4173 road.
4183 road.
4174
4184
4175 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
4185 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
4176 which were boud to functions being reassigned would bypass the
4186 which were boud to functions being reassigned would bypass the
4177 logger, breaking the sync of _il with the prompt counter. This
4187 logger, breaking the sync of _il with the prompt counter. This
4178 would then crash IPython later when a new line was logged.
4188 would then crash IPython later when a new line was logged.
4179
4189
4180 2001-12-02 Fernando Perez <fperez@colorado.edu>
4190 2001-12-02 Fernando Perez <fperez@colorado.edu>
4181
4191
4182 * Made IPython a package. This means people don't have to clutter
4192 * Made IPython a package. This means people don't have to clutter
4183 their sys.path with yet another directory. Changed the INSTALL
4193 their sys.path with yet another directory. Changed the INSTALL
4184 file accordingly.
4194 file accordingly.
4185
4195
4186 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
4196 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
4187 sorts its output (so @who shows it sorted) and @whos formats the
4197 sorts its output (so @who shows it sorted) and @whos formats the
4188 table according to the width of the first column. Nicer, easier to
4198 table according to the width of the first column. Nicer, easier to
4189 read. Todo: write a generic table_format() which takes a list of
4199 read. Todo: write a generic table_format() which takes a list of
4190 lists and prints it nicely formatted, with optional row/column
4200 lists and prints it nicely formatted, with optional row/column
4191 separators and proper padding and justification.
4201 separators and proper padding and justification.
4192
4202
4193 * Released 0.1.20
4203 * Released 0.1.20
4194
4204
4195 * Fixed bug in @log which would reverse the inputcache list (a
4205 * Fixed bug in @log which would reverse the inputcache list (a
4196 copy operation was missing).
4206 copy operation was missing).
4197
4207
4198 * Code cleanup. @config was changed to use page(). Better, since
4208 * Code cleanup. @config was changed to use page(). Better, since
4199 its output is always quite long.
4209 its output is always quite long.
4200
4210
4201 * Itpl is back as a dependency. I was having too many problems
4211 * Itpl is back as a dependency. I was having too many problems
4202 getting the parametric aliases to work reliably, and it's just
4212 getting the parametric aliases to work reliably, and it's just
4203 easier to code weird string operations with it than playing %()s
4213 easier to code weird string operations with it than playing %()s
4204 games. It's only ~6k, so I don't think it's too big a deal.
4214 games. It's only ~6k, so I don't think it's too big a deal.
4205
4215
4206 * Found (and fixed) a very nasty bug with history. !lines weren't
4216 * Found (and fixed) a very nasty bug with history. !lines weren't
4207 getting cached, and the out of sync caches would crash
4217 getting cached, and the out of sync caches would crash
4208 IPython. Fixed it by reorganizing the prefilter/handlers/logger
4218 IPython. Fixed it by reorganizing the prefilter/handlers/logger
4209 division of labor a bit better. Bug fixed, cleaner structure.
4219 division of labor a bit better. Bug fixed, cleaner structure.
4210
4220
4211 2001-12-01 Fernando Perez <fperez@colorado.edu>
4221 2001-12-01 Fernando Perez <fperez@colorado.edu>
4212
4222
4213 * Released 0.1.19
4223 * Released 0.1.19
4214
4224
4215 * Added option -n to @hist to prevent line number printing. Much
4225 * Added option -n to @hist to prevent line number printing. Much
4216 easier to copy/paste code this way.
4226 easier to copy/paste code this way.
4217
4227
4218 * Created global _il to hold the input list. Allows easy
4228 * Created global _il to hold the input list. Allows easy
4219 re-execution of blocks of code by slicing it (inspired by Janko's
4229 re-execution of blocks of code by slicing it (inspired by Janko's
4220 comment on 'macros').
4230 comment on 'macros').
4221
4231
4222 * Small fixes and doc updates.
4232 * Small fixes and doc updates.
4223
4233
4224 * Rewrote @history function (was @h). Renamed it to @hist, @h is
4234 * Rewrote @history function (was @h). Renamed it to @hist, @h is
4225 much too fragile with automagic. Handles properly multi-line
4235 much too fragile with automagic. Handles properly multi-line
4226 statements and takes parameters.
4236 statements and takes parameters.
4227
4237
4228 2001-11-30 Fernando Perez <fperez@colorado.edu>
4238 2001-11-30 Fernando Perez <fperez@colorado.edu>
4229
4239
4230 * Version 0.1.18 released.
4240 * Version 0.1.18 released.
4231
4241
4232 * Fixed nasty namespace bug in initial module imports.
4242 * Fixed nasty namespace bug in initial module imports.
4233
4243
4234 * Added copyright/license notes to all code files (except
4244 * Added copyright/license notes to all code files (except
4235 DPyGetOpt). For the time being, LGPL. That could change.
4245 DPyGetOpt). For the time being, LGPL. That could change.
4236
4246
4237 * Rewrote a much nicer README, updated INSTALL, cleaned up
4247 * Rewrote a much nicer README, updated INSTALL, cleaned up
4238 ipythonrc-* samples.
4248 ipythonrc-* samples.
4239
4249
4240 * Overall code/documentation cleanup. Basically ready for
4250 * Overall code/documentation cleanup. Basically ready for
4241 release. Only remaining thing: licence decision (LGPL?).
4251 release. Only remaining thing: licence decision (LGPL?).
4242
4252
4243 * Converted load_config to a class, ConfigLoader. Now recursion
4253 * Converted load_config to a class, ConfigLoader. Now recursion
4244 control is better organized. Doesn't include the same file twice.
4254 control is better organized. Doesn't include the same file twice.
4245
4255
4246 2001-11-29 Fernando Perez <fperez@colorado.edu>
4256 2001-11-29 Fernando Perez <fperez@colorado.edu>
4247
4257
4248 * Got input history working. Changed output history variables from
4258 * Got input history working. Changed output history variables from
4249 _p to _o so that _i is for input and _o for output. Just cleaner
4259 _p to _o so that _i is for input and _o for output. Just cleaner
4250 convention.
4260 convention.
4251
4261
4252 * Implemented parametric aliases. This pretty much allows the
4262 * Implemented parametric aliases. This pretty much allows the
4253 alias system to offer full-blown shell convenience, I think.
4263 alias system to offer full-blown shell convenience, I think.
4254
4264
4255 * Version 0.1.17 released, 0.1.18 opened.
4265 * Version 0.1.17 released, 0.1.18 opened.
4256
4266
4257 * dot_ipython/ipythonrc (alias): added documentation.
4267 * dot_ipython/ipythonrc (alias): added documentation.
4258 (xcolor): Fixed small bug (xcolors -> xcolor)
4268 (xcolor): Fixed small bug (xcolors -> xcolor)
4259
4269
4260 * Changed the alias system. Now alias is a magic command to define
4270 * Changed the alias system. Now alias is a magic command to define
4261 aliases just like the shell. Rationale: the builtin magics should
4271 aliases just like the shell. Rationale: the builtin magics should
4262 be there for things deeply connected to IPython's
4272 be there for things deeply connected to IPython's
4263 architecture. And this is a much lighter system for what I think
4273 architecture. And this is a much lighter system for what I think
4264 is the really important feature: allowing users to define quickly
4274 is the really important feature: allowing users to define quickly
4265 magics that will do shell things for them, so they can customize
4275 magics that will do shell things for them, so they can customize
4266 IPython easily to match their work habits. If someone is really
4276 IPython easily to match their work habits. If someone is really
4267 desperate to have another name for a builtin alias, they can
4277 desperate to have another name for a builtin alias, they can
4268 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
4278 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
4269 works.
4279 works.
4270
4280
4271 2001-11-28 Fernando Perez <fperez@colorado.edu>
4281 2001-11-28 Fernando Perez <fperez@colorado.edu>
4272
4282
4273 * Changed @file so that it opens the source file at the proper
4283 * Changed @file so that it opens the source file at the proper
4274 line. Since it uses less, if your EDITOR environment is
4284 line. Since it uses less, if your EDITOR environment is
4275 configured, typing v will immediately open your editor of choice
4285 configured, typing v will immediately open your editor of choice
4276 right at the line where the object is defined. Not as quick as
4286 right at the line where the object is defined. Not as quick as
4277 having a direct @edit command, but for all intents and purposes it
4287 having a direct @edit command, but for all intents and purposes it
4278 works. And I don't have to worry about writing @edit to deal with
4288 works. And I don't have to worry about writing @edit to deal with
4279 all the editors, less does that.
4289 all the editors, less does that.
4280
4290
4281 * Version 0.1.16 released, 0.1.17 opened.
4291 * Version 0.1.16 released, 0.1.17 opened.
4282
4292
4283 * Fixed some nasty bugs in the page/page_dumb combo that could
4293 * Fixed some nasty bugs in the page/page_dumb combo that could
4284 crash IPython.
4294 crash IPython.
4285
4295
4286 2001-11-27 Fernando Perez <fperez@colorado.edu>
4296 2001-11-27 Fernando Perez <fperez@colorado.edu>
4287
4297
4288 * Version 0.1.15 released, 0.1.16 opened.
4298 * Version 0.1.15 released, 0.1.16 opened.
4289
4299
4290 * Finally got ? and ?? to work for undefined things: now it's
4300 * Finally got ? and ?? to work for undefined things: now it's
4291 possible to type {}.get? and get information about the get method
4301 possible to type {}.get? and get information about the get method
4292 of dicts, or os.path? even if only os is defined (so technically
4302 of dicts, or os.path? even if only os is defined (so technically
4293 os.path isn't). Works at any level. For example, after import os,
4303 os.path isn't). Works at any level. For example, after import os,
4294 os?, os.path?, os.path.abspath? all work. This is great, took some
4304 os?, os.path?, os.path.abspath? all work. This is great, took some
4295 work in _ofind.
4305 work in _ofind.
4296
4306
4297 * Fixed more bugs with logging. The sanest way to do it was to add
4307 * Fixed more bugs with logging. The sanest way to do it was to add
4298 to @log a 'mode' parameter. Killed two in one shot (this mode
4308 to @log a 'mode' parameter. Killed two in one shot (this mode
4299 option was a request of Janko's). I think it's finally clean
4309 option was a request of Janko's). I think it's finally clean
4300 (famous last words).
4310 (famous last words).
4301
4311
4302 * Added a page_dumb() pager which does a decent job of paging on
4312 * Added a page_dumb() pager which does a decent job of paging on
4303 screen, if better things (like less) aren't available. One less
4313 screen, if better things (like less) aren't available. One less
4304 unix dependency (someday maybe somebody will port this to
4314 unix dependency (someday maybe somebody will port this to
4305 windows).
4315 windows).
4306
4316
4307 * Fixed problem in magic_log: would lock of logging out if log
4317 * Fixed problem in magic_log: would lock of logging out if log
4308 creation failed (because it would still think it had succeeded).
4318 creation failed (because it would still think it had succeeded).
4309
4319
4310 * Improved the page() function using curses to auto-detect screen
4320 * Improved the page() function using curses to auto-detect screen
4311 size. Now it can make a much better decision on whether to print
4321 size. Now it can make a much better decision on whether to print
4312 or page a string. Option screen_length was modified: a value 0
4322 or page a string. Option screen_length was modified: a value 0
4313 means auto-detect, and that's the default now.
4323 means auto-detect, and that's the default now.
4314
4324
4315 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
4325 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
4316 go out. I'll test it for a few days, then talk to Janko about
4326 go out. I'll test it for a few days, then talk to Janko about
4317 licences and announce it.
4327 licences and announce it.
4318
4328
4319 * Fixed the length of the auto-generated ---> prompt which appears
4329 * Fixed the length of the auto-generated ---> prompt which appears
4320 for auto-parens and auto-quotes. Getting this right isn't trivial,
4330 for auto-parens and auto-quotes. Getting this right isn't trivial,
4321 with all the color escapes, different prompt types and optional
4331 with all the color escapes, different prompt types and optional
4322 separators. But it seems to be working in all the combinations.
4332 separators. But it seems to be working in all the combinations.
4323
4333
4324 2001-11-26 Fernando Perez <fperez@colorado.edu>
4334 2001-11-26 Fernando Perez <fperez@colorado.edu>
4325
4335
4326 * Wrote a regexp filter to get option types from the option names
4336 * Wrote a regexp filter to get option types from the option names
4327 string. This eliminates the need to manually keep two duplicate
4337 string. This eliminates the need to manually keep two duplicate
4328 lists.
4338 lists.
4329
4339
4330 * Removed the unneeded check_option_names. Now options are handled
4340 * Removed the unneeded check_option_names. Now options are handled
4331 in a much saner manner and it's easy to visually check that things
4341 in a much saner manner and it's easy to visually check that things
4332 are ok.
4342 are ok.
4333
4343
4334 * Updated version numbers on all files I modified to carry a
4344 * Updated version numbers on all files I modified to carry a
4335 notice so Janko and Nathan have clear version markers.
4345 notice so Janko and Nathan have clear version markers.
4336
4346
4337 * Updated docstring for ultraTB with my changes. I should send
4347 * Updated docstring for ultraTB with my changes. I should send
4338 this to Nathan.
4348 this to Nathan.
4339
4349
4340 * Lots of small fixes. Ran everything through pychecker again.
4350 * Lots of small fixes. Ran everything through pychecker again.
4341
4351
4342 * Made loading of deep_reload an cmd line option. If it's not too
4352 * Made loading of deep_reload an cmd line option. If it's not too
4343 kosher, now people can just disable it. With -nodeep_reload it's
4353 kosher, now people can just disable it. With -nodeep_reload it's
4344 still available as dreload(), it just won't overwrite reload().
4354 still available as dreload(), it just won't overwrite reload().
4345
4355
4346 * Moved many options to the no| form (-opt and -noopt
4356 * Moved many options to the no| form (-opt and -noopt
4347 accepted). Cleaner.
4357 accepted). Cleaner.
4348
4358
4349 * Changed magic_log so that if called with no parameters, it uses
4359 * Changed magic_log so that if called with no parameters, it uses
4350 'rotate' mode. That way auto-generated logs aren't automatically
4360 'rotate' mode. That way auto-generated logs aren't automatically
4351 over-written. For normal logs, now a backup is made if it exists
4361 over-written. For normal logs, now a backup is made if it exists
4352 (only 1 level of backups). A new 'backup' mode was added to the
4362 (only 1 level of backups). A new 'backup' mode was added to the
4353 Logger class to support this. This was a request by Janko.
4363 Logger class to support this. This was a request by Janko.
4354
4364
4355 * Added @logoff/@logon to stop/restart an active log.
4365 * Added @logoff/@logon to stop/restart an active log.
4356
4366
4357 * Fixed a lot of bugs in log saving/replay. It was pretty
4367 * Fixed a lot of bugs in log saving/replay. It was pretty
4358 broken. Now special lines (!@,/) appear properly in the command
4368 broken. Now special lines (!@,/) appear properly in the command
4359 history after a log replay.
4369 history after a log replay.
4360
4370
4361 * Tried and failed to implement full session saving via pickle. My
4371 * Tried and failed to implement full session saving via pickle. My
4362 idea was to pickle __main__.__dict__, but modules can't be
4372 idea was to pickle __main__.__dict__, but modules can't be
4363 pickled. This would be a better alternative to replaying logs, but
4373 pickled. This would be a better alternative to replaying logs, but
4364 seems quite tricky to get to work. Changed -session to be called
4374 seems quite tricky to get to work. Changed -session to be called
4365 -logplay, which more accurately reflects what it does. And if we
4375 -logplay, which more accurately reflects what it does. And if we
4366 ever get real session saving working, -session is now available.
4376 ever get real session saving working, -session is now available.
4367
4377
4368 * Implemented color schemes for prompts also. As for tracebacks,
4378 * Implemented color schemes for prompts also. As for tracebacks,
4369 currently only NoColor and Linux are supported. But now the
4379 currently only NoColor and Linux are supported. But now the
4370 infrastructure is in place, based on a generic ColorScheme
4380 infrastructure is in place, based on a generic ColorScheme
4371 class. So writing and activating new schemes both for the prompts
4381 class. So writing and activating new schemes both for the prompts
4372 and the tracebacks should be straightforward.
4382 and the tracebacks should be straightforward.
4373
4383
4374 * Version 0.1.13 released, 0.1.14 opened.
4384 * Version 0.1.13 released, 0.1.14 opened.
4375
4385
4376 * Changed handling of options for output cache. Now counter is
4386 * Changed handling of options for output cache. Now counter is
4377 hardwired starting at 1 and one specifies the maximum number of
4387 hardwired starting at 1 and one specifies the maximum number of
4378 entries *in the outcache* (not the max prompt counter). This is
4388 entries *in the outcache* (not the max prompt counter). This is
4379 much better, since many statements won't increase the cache
4389 much better, since many statements won't increase the cache
4380 count. It also eliminated some confusing options, now there's only
4390 count. It also eliminated some confusing options, now there's only
4381 one: cache_size.
4391 one: cache_size.
4382
4392
4383 * Added 'alias' magic function and magic_alias option in the
4393 * Added 'alias' magic function and magic_alias option in the
4384 ipythonrc file. Now the user can easily define whatever names he
4394 ipythonrc file. Now the user can easily define whatever names he
4385 wants for the magic functions without having to play weird
4395 wants for the magic functions without having to play weird
4386 namespace games. This gives IPython a real shell-like feel.
4396 namespace games. This gives IPython a real shell-like feel.
4387
4397
4388 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
4398 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
4389 @ or not).
4399 @ or not).
4390
4400
4391 This was one of the last remaining 'visible' bugs (that I know
4401 This was one of the last remaining 'visible' bugs (that I know
4392 of). I think if I can clean up the session loading so it works
4402 of). I think if I can clean up the session loading so it works
4393 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
4403 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
4394 about licensing).
4404 about licensing).
4395
4405
4396 2001-11-25 Fernando Perez <fperez@colorado.edu>
4406 2001-11-25 Fernando Perez <fperez@colorado.edu>
4397
4407
4398 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
4408 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
4399 there's a cleaner distinction between what ? and ?? show.
4409 there's a cleaner distinction between what ? and ?? show.
4400
4410
4401 * Added screen_length option. Now the user can define his own
4411 * Added screen_length option. Now the user can define his own
4402 screen size for page() operations.
4412 screen size for page() operations.
4403
4413
4404 * Implemented magic shell-like functions with automatic code
4414 * Implemented magic shell-like functions with automatic code
4405 generation. Now adding another function is just a matter of adding
4415 generation. Now adding another function is just a matter of adding
4406 an entry to a dict, and the function is dynamically generated at
4416 an entry to a dict, and the function is dynamically generated at
4407 run-time. Python has some really cool features!
4417 run-time. Python has some really cool features!
4408
4418
4409 * Renamed many options to cleanup conventions a little. Now all
4419 * Renamed many options to cleanup conventions a little. Now all
4410 are lowercase, and only underscores where needed. Also in the code
4420 are lowercase, and only underscores where needed. Also in the code
4411 option name tables are clearer.
4421 option name tables are clearer.
4412
4422
4413 * Changed prompts a little. Now input is 'In [n]:' instead of
4423 * Changed prompts a little. Now input is 'In [n]:' instead of
4414 'In[n]:='. This allows it the numbers to be aligned with the
4424 'In[n]:='. This allows it the numbers to be aligned with the
4415 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4425 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4416 Python (it was a Mathematica thing). The '...' continuation prompt
4426 Python (it was a Mathematica thing). The '...' continuation prompt
4417 was also changed a little to align better.
4427 was also changed a little to align better.
4418
4428
4419 * Fixed bug when flushing output cache. Not all _p<n> variables
4429 * Fixed bug when flushing output cache. Not all _p<n> variables
4420 exist, so their deletion needs to be wrapped in a try:
4430 exist, so their deletion needs to be wrapped in a try:
4421
4431
4422 * Figured out how to properly use inspect.formatargspec() (it
4432 * Figured out how to properly use inspect.formatargspec() (it
4423 requires the args preceded by *). So I removed all the code from
4433 requires the args preceded by *). So I removed all the code from
4424 _get_pdef in Magic, which was just replicating that.
4434 _get_pdef in Magic, which was just replicating that.
4425
4435
4426 * Added test to prefilter to allow redefining magic function names
4436 * Added test to prefilter to allow redefining magic function names
4427 as variables. This is ok, since the @ form is always available,
4437 as variables. This is ok, since the @ form is always available,
4428 but whe should allow the user to define a variable called 'ls' if
4438 but whe should allow the user to define a variable called 'ls' if
4429 he needs it.
4439 he needs it.
4430
4440
4431 * Moved the ToDo information from README into a separate ToDo.
4441 * Moved the ToDo information from README into a separate ToDo.
4432
4442
4433 * General code cleanup and small bugfixes. I think it's close to a
4443 * General code cleanup and small bugfixes. I think it's close to a
4434 state where it can be released, obviously with a big 'beta'
4444 state where it can be released, obviously with a big 'beta'
4435 warning on it.
4445 warning on it.
4436
4446
4437 * Got the magic function split to work. Now all magics are defined
4447 * Got the magic function split to work. Now all magics are defined
4438 in a separate class. It just organizes things a bit, and now
4448 in a separate class. It just organizes things a bit, and now
4439 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4449 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4440 was too long).
4450 was too long).
4441
4451
4442 * Changed @clear to @reset to avoid potential confusions with
4452 * Changed @clear to @reset to avoid potential confusions with
4443 the shell command clear. Also renamed @cl to @clear, which does
4453 the shell command clear. Also renamed @cl to @clear, which does
4444 exactly what people expect it to from their shell experience.
4454 exactly what people expect it to from their shell experience.
4445
4455
4446 Added a check to the @reset command (since it's so
4456 Added a check to the @reset command (since it's so
4447 destructive, it's probably a good idea to ask for confirmation).
4457 destructive, it's probably a good idea to ask for confirmation).
4448 But now reset only works for full namespace resetting. Since the
4458 But now reset only works for full namespace resetting. Since the
4449 del keyword is already there for deleting a few specific
4459 del keyword is already there for deleting a few specific
4450 variables, I don't see the point of having a redundant magic
4460 variables, I don't see the point of having a redundant magic
4451 function for the same task.
4461 function for the same task.
4452
4462
4453 2001-11-24 Fernando Perez <fperez@colorado.edu>
4463 2001-11-24 Fernando Perez <fperez@colorado.edu>
4454
4464
4455 * Updated the builtin docs (esp. the ? ones).
4465 * Updated the builtin docs (esp. the ? ones).
4456
4466
4457 * Ran all the code through pychecker. Not terribly impressed with
4467 * Ran all the code through pychecker. Not terribly impressed with
4458 it: lots of spurious warnings and didn't really find anything of
4468 it: lots of spurious warnings and didn't really find anything of
4459 substance (just a few modules being imported and not used).
4469 substance (just a few modules being imported and not used).
4460
4470
4461 * Implemented the new ultraTB functionality into IPython. New
4471 * Implemented the new ultraTB functionality into IPython. New
4462 option: xcolors. This chooses color scheme. xmode now only selects
4472 option: xcolors. This chooses color scheme. xmode now only selects
4463 between Plain and Verbose. Better orthogonality.
4473 between Plain and Verbose. Better orthogonality.
4464
4474
4465 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4475 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4466 mode and color scheme for the exception handlers. Now it's
4476 mode and color scheme for the exception handlers. Now it's
4467 possible to have the verbose traceback with no coloring.
4477 possible to have the verbose traceback with no coloring.
4468
4478
4469 2001-11-23 Fernando Perez <fperez@colorado.edu>
4479 2001-11-23 Fernando Perez <fperez@colorado.edu>
4470
4480
4471 * Version 0.1.12 released, 0.1.13 opened.
4481 * Version 0.1.12 released, 0.1.13 opened.
4472
4482
4473 * Removed option to set auto-quote and auto-paren escapes by
4483 * Removed option to set auto-quote and auto-paren escapes by
4474 user. The chances of breaking valid syntax are just too high. If
4484 user. The chances of breaking valid syntax are just too high. If
4475 someone *really* wants, they can always dig into the code.
4485 someone *really* wants, they can always dig into the code.
4476
4486
4477 * Made prompt separators configurable.
4487 * Made prompt separators configurable.
4478
4488
4479 2001-11-22 Fernando Perez <fperez@colorado.edu>
4489 2001-11-22 Fernando Perez <fperez@colorado.edu>
4480
4490
4481 * Small bugfixes in many places.
4491 * Small bugfixes in many places.
4482
4492
4483 * Removed the MyCompleter class from ipplib. It seemed redundant
4493 * Removed the MyCompleter class from ipplib. It seemed redundant
4484 with the C-p,C-n history search functionality. Less code to
4494 with the C-p,C-n history search functionality. Less code to
4485 maintain.
4495 maintain.
4486
4496
4487 * Moved all the original ipython.py code into ipythonlib.py. Right
4497 * Moved all the original ipython.py code into ipythonlib.py. Right
4488 now it's just one big dump into a function called make_IPython, so
4498 now it's just one big dump into a function called make_IPython, so
4489 no real modularity has been gained. But at least it makes the
4499 no real modularity has been gained. But at least it makes the
4490 wrapper script tiny, and since ipythonlib is a module, it gets
4500 wrapper script tiny, and since ipythonlib is a module, it gets
4491 compiled and startup is much faster.
4501 compiled and startup is much faster.
4492
4502
4493 This is a reasobably 'deep' change, so we should test it for a
4503 This is a reasobably 'deep' change, so we should test it for a
4494 while without messing too much more with the code.
4504 while without messing too much more with the code.
4495
4505
4496 2001-11-21 Fernando Perez <fperez@colorado.edu>
4506 2001-11-21 Fernando Perez <fperez@colorado.edu>
4497
4507
4498 * Version 0.1.11 released, 0.1.12 opened for further work.
4508 * Version 0.1.11 released, 0.1.12 opened for further work.
4499
4509
4500 * Removed dependency on Itpl. It was only needed in one place. It
4510 * Removed dependency on Itpl. It was only needed in one place. It
4501 would be nice if this became part of python, though. It makes life
4511 would be nice if this became part of python, though. It makes life
4502 *a lot* easier in some cases.
4512 *a lot* easier in some cases.
4503
4513
4504 * Simplified the prefilter code a bit. Now all handlers are
4514 * Simplified the prefilter code a bit. Now all handlers are
4505 expected to explicitly return a value (at least a blank string).
4515 expected to explicitly return a value (at least a blank string).
4506
4516
4507 * Heavy edits in ipplib. Removed the help system altogether. Now
4517 * Heavy edits in ipplib. Removed the help system altogether. Now
4508 obj?/?? is used for inspecting objects, a magic @doc prints
4518 obj?/?? is used for inspecting objects, a magic @doc prints
4509 docstrings, and full-blown Python help is accessed via the 'help'
4519 docstrings, and full-blown Python help is accessed via the 'help'
4510 keyword. This cleans up a lot of code (less to maintain) and does
4520 keyword. This cleans up a lot of code (less to maintain) and does
4511 the job. Since 'help' is now a standard Python component, might as
4521 the job. Since 'help' is now a standard Python component, might as
4512 well use it and remove duplicate functionality.
4522 well use it and remove duplicate functionality.
4513
4523
4514 Also removed the option to use ipplib as a standalone program. By
4524 Also removed the option to use ipplib as a standalone program. By
4515 now it's too dependent on other parts of IPython to function alone.
4525 now it's too dependent on other parts of IPython to function alone.
4516
4526
4517 * Fixed bug in genutils.pager. It would crash if the pager was
4527 * Fixed bug in genutils.pager. It would crash if the pager was
4518 exited immediately after opening (broken pipe).
4528 exited immediately after opening (broken pipe).
4519
4529
4520 * Trimmed down the VerboseTB reporting a little. The header is
4530 * Trimmed down the VerboseTB reporting a little. The header is
4521 much shorter now and the repeated exception arguments at the end
4531 much shorter now and the repeated exception arguments at the end
4522 have been removed. For interactive use the old header seemed a bit
4532 have been removed. For interactive use the old header seemed a bit
4523 excessive.
4533 excessive.
4524
4534
4525 * Fixed small bug in output of @whos for variables with multi-word
4535 * Fixed small bug in output of @whos for variables with multi-word
4526 types (only first word was displayed).
4536 types (only first word was displayed).
4527
4537
4528 2001-11-17 Fernando Perez <fperez@colorado.edu>
4538 2001-11-17 Fernando Perez <fperez@colorado.edu>
4529
4539
4530 * Version 0.1.10 released, 0.1.11 opened for further work.
4540 * Version 0.1.10 released, 0.1.11 opened for further work.
4531
4541
4532 * Modified dirs and friends. dirs now *returns* the stack (not
4542 * Modified dirs and friends. dirs now *returns* the stack (not
4533 prints), so one can manipulate it as a variable. Convenient to
4543 prints), so one can manipulate it as a variable. Convenient to
4534 travel along many directories.
4544 travel along many directories.
4535
4545
4536 * Fixed bug in magic_pdef: would only work with functions with
4546 * Fixed bug in magic_pdef: would only work with functions with
4537 arguments with default values.
4547 arguments with default values.
4538
4548
4539 2001-11-14 Fernando Perez <fperez@colorado.edu>
4549 2001-11-14 Fernando Perez <fperez@colorado.edu>
4540
4550
4541 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4551 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4542 example with IPython. Various other minor fixes and cleanups.
4552 example with IPython. Various other minor fixes and cleanups.
4543
4553
4544 * Version 0.1.9 released, 0.1.10 opened for further work.
4554 * Version 0.1.9 released, 0.1.10 opened for further work.
4545
4555
4546 * Added sys.path to the list of directories searched in the
4556 * Added sys.path to the list of directories searched in the
4547 execfile= option. It used to be the current directory and the
4557 execfile= option. It used to be the current directory and the
4548 user's IPYTHONDIR only.
4558 user's IPYTHONDIR only.
4549
4559
4550 2001-11-13 Fernando Perez <fperez@colorado.edu>
4560 2001-11-13 Fernando Perez <fperez@colorado.edu>
4551
4561
4552 * Reinstated the raw_input/prefilter separation that Janko had
4562 * Reinstated the raw_input/prefilter separation that Janko had
4553 initially. This gives a more convenient setup for extending the
4563 initially. This gives a more convenient setup for extending the
4554 pre-processor from the outside: raw_input always gets a string,
4564 pre-processor from the outside: raw_input always gets a string,
4555 and prefilter has to process it. We can then redefine prefilter
4565 and prefilter has to process it. We can then redefine prefilter
4556 from the outside and implement extensions for special
4566 from the outside and implement extensions for special
4557 purposes.
4567 purposes.
4558
4568
4559 Today I got one for inputting PhysicalQuantity objects
4569 Today I got one for inputting PhysicalQuantity objects
4560 (from Scientific) without needing any function calls at
4570 (from Scientific) without needing any function calls at
4561 all. Extremely convenient, and it's all done as a user-level
4571 all. Extremely convenient, and it's all done as a user-level
4562 extension (no IPython code was touched). Now instead of:
4572 extension (no IPython code was touched). Now instead of:
4563 a = PhysicalQuantity(4.2,'m/s**2')
4573 a = PhysicalQuantity(4.2,'m/s**2')
4564 one can simply say
4574 one can simply say
4565 a = 4.2 m/s**2
4575 a = 4.2 m/s**2
4566 or even
4576 or even
4567 a = 4.2 m/s^2
4577 a = 4.2 m/s^2
4568
4578
4569 I use this, but it's also a proof of concept: IPython really is
4579 I use this, but it's also a proof of concept: IPython really is
4570 fully user-extensible, even at the level of the parsing of the
4580 fully user-extensible, even at the level of the parsing of the
4571 command line. It's not trivial, but it's perfectly doable.
4581 command line. It's not trivial, but it's perfectly doable.
4572
4582
4573 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4583 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4574 the problem of modules being loaded in the inverse order in which
4584 the problem of modules being loaded in the inverse order in which
4575 they were defined in
4585 they were defined in
4576
4586
4577 * Version 0.1.8 released, 0.1.9 opened for further work.
4587 * Version 0.1.8 released, 0.1.9 opened for further work.
4578
4588
4579 * Added magics pdef, source and file. They respectively show the
4589 * Added magics pdef, source and file. They respectively show the
4580 definition line ('prototype' in C), source code and full python
4590 definition line ('prototype' in C), source code and full python
4581 file for any callable object. The object inspector oinfo uses
4591 file for any callable object. The object inspector oinfo uses
4582 these to show the same information.
4592 these to show the same information.
4583
4593
4584 * Version 0.1.7 released, 0.1.8 opened for further work.
4594 * Version 0.1.7 released, 0.1.8 opened for further work.
4585
4595
4586 * Separated all the magic functions into a class called Magic. The
4596 * Separated all the magic functions into a class called Magic. The
4587 InteractiveShell class was becoming too big for Xemacs to handle
4597 InteractiveShell class was becoming too big for Xemacs to handle
4588 (de-indenting a line would lock it up for 10 seconds while it
4598 (de-indenting a line would lock it up for 10 seconds while it
4589 backtracked on the whole class!)
4599 backtracked on the whole class!)
4590
4600
4591 FIXME: didn't work. It can be done, but right now namespaces are
4601 FIXME: didn't work. It can be done, but right now namespaces are
4592 all messed up. Do it later (reverted it for now, so at least
4602 all messed up. Do it later (reverted it for now, so at least
4593 everything works as before).
4603 everything works as before).
4594
4604
4595 * Got the object introspection system (magic_oinfo) working! I
4605 * Got the object introspection system (magic_oinfo) working! I
4596 think this is pretty much ready for release to Janko, so he can
4606 think this is pretty much ready for release to Janko, so he can
4597 test it for a while and then announce it. Pretty much 100% of what
4607 test it for a while and then announce it. Pretty much 100% of what
4598 I wanted for the 'phase 1' release is ready. Happy, tired.
4608 I wanted for the 'phase 1' release is ready. Happy, tired.
4599
4609
4600 2001-11-12 Fernando Perez <fperez@colorado.edu>
4610 2001-11-12 Fernando Perez <fperez@colorado.edu>
4601
4611
4602 * Version 0.1.6 released, 0.1.7 opened for further work.
4612 * Version 0.1.6 released, 0.1.7 opened for further work.
4603
4613
4604 * Fixed bug in printing: it used to test for truth before
4614 * Fixed bug in printing: it used to test for truth before
4605 printing, so 0 wouldn't print. Now checks for None.
4615 printing, so 0 wouldn't print. Now checks for None.
4606
4616
4607 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4617 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4608 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4618 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4609 reaches by hand into the outputcache. Think of a better way to do
4619 reaches by hand into the outputcache. Think of a better way to do
4610 this later.
4620 this later.
4611
4621
4612 * Various small fixes thanks to Nathan's comments.
4622 * Various small fixes thanks to Nathan's comments.
4613
4623
4614 * Changed magic_pprint to magic_Pprint. This way it doesn't
4624 * Changed magic_pprint to magic_Pprint. This way it doesn't
4615 collide with pprint() and the name is consistent with the command
4625 collide with pprint() and the name is consistent with the command
4616 line option.
4626 line option.
4617
4627
4618 * Changed prompt counter behavior to be fully like
4628 * Changed prompt counter behavior to be fully like
4619 Mathematica's. That is, even input that doesn't return a result
4629 Mathematica's. That is, even input that doesn't return a result
4620 raises the prompt counter. The old behavior was kind of confusing
4630 raises the prompt counter. The old behavior was kind of confusing
4621 (getting the same prompt number several times if the operation
4631 (getting the same prompt number several times if the operation
4622 didn't return a result).
4632 didn't return a result).
4623
4633
4624 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4634 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4625
4635
4626 * Fixed -Classic mode (wasn't working anymore).
4636 * Fixed -Classic mode (wasn't working anymore).
4627
4637
4628 * Added colored prompts using Nathan's new code. Colors are
4638 * Added colored prompts using Nathan's new code. Colors are
4629 currently hardwired, they can be user-configurable. For
4639 currently hardwired, they can be user-configurable. For
4630 developers, they can be chosen in file ipythonlib.py, at the
4640 developers, they can be chosen in file ipythonlib.py, at the
4631 beginning of the CachedOutput class def.
4641 beginning of the CachedOutput class def.
4632
4642
4633 2001-11-11 Fernando Perez <fperez@colorado.edu>
4643 2001-11-11 Fernando Perez <fperez@colorado.edu>
4634
4644
4635 * Version 0.1.5 released, 0.1.6 opened for further work.
4645 * Version 0.1.5 released, 0.1.6 opened for further work.
4636
4646
4637 * Changed magic_env to *return* the environment as a dict (not to
4647 * Changed magic_env to *return* the environment as a dict (not to
4638 print it). This way it prints, but it can also be processed.
4648 print it). This way it prints, but it can also be processed.
4639
4649
4640 * Added Verbose exception reporting to interactive
4650 * Added Verbose exception reporting to interactive
4641 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4651 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4642 traceback. Had to make some changes to the ultraTB file. This is
4652 traceback. Had to make some changes to the ultraTB file. This is
4643 probably the last 'big' thing in my mental todo list. This ties
4653 probably the last 'big' thing in my mental todo list. This ties
4644 in with the next entry:
4654 in with the next entry:
4645
4655
4646 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4656 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4647 has to specify is Plain, Color or Verbose for all exception
4657 has to specify is Plain, Color or Verbose for all exception
4648 handling.
4658 handling.
4649
4659
4650 * Removed ShellServices option. All this can really be done via
4660 * Removed ShellServices option. All this can really be done via
4651 the magic system. It's easier to extend, cleaner and has automatic
4661 the magic system. It's easier to extend, cleaner and has automatic
4652 namespace protection and documentation.
4662 namespace protection and documentation.
4653
4663
4654 2001-11-09 Fernando Perez <fperez@colorado.edu>
4664 2001-11-09 Fernando Perez <fperez@colorado.edu>
4655
4665
4656 * Fixed bug in output cache flushing (missing parameter to
4666 * Fixed bug in output cache flushing (missing parameter to
4657 __init__). Other small bugs fixed (found using pychecker).
4667 __init__). Other small bugs fixed (found using pychecker).
4658
4668
4659 * Version 0.1.4 opened for bugfixing.
4669 * Version 0.1.4 opened for bugfixing.
4660
4670
4661 2001-11-07 Fernando Perez <fperez@colorado.edu>
4671 2001-11-07 Fernando Perez <fperez@colorado.edu>
4662
4672
4663 * Version 0.1.3 released, mainly because of the raw_input bug.
4673 * Version 0.1.3 released, mainly because of the raw_input bug.
4664
4674
4665 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4675 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4666 and when testing for whether things were callable, a call could
4676 and when testing for whether things were callable, a call could
4667 actually be made to certain functions. They would get called again
4677 actually be made to certain functions. They would get called again
4668 once 'really' executed, with a resulting double call. A disaster
4678 once 'really' executed, with a resulting double call. A disaster
4669 in many cases (list.reverse() would never work!).
4679 in many cases (list.reverse() would never work!).
4670
4680
4671 * Removed prefilter() function, moved its code to raw_input (which
4681 * Removed prefilter() function, moved its code to raw_input (which
4672 after all was just a near-empty caller for prefilter). This saves
4682 after all was just a near-empty caller for prefilter). This saves
4673 a function call on every prompt, and simplifies the class a tiny bit.
4683 a function call on every prompt, and simplifies the class a tiny bit.
4674
4684
4675 * Fix _ip to __ip name in magic example file.
4685 * Fix _ip to __ip name in magic example file.
4676
4686
4677 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4687 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4678 work with non-gnu versions of tar.
4688 work with non-gnu versions of tar.
4679
4689
4680 2001-11-06 Fernando Perez <fperez@colorado.edu>
4690 2001-11-06 Fernando Perez <fperez@colorado.edu>
4681
4691
4682 * Version 0.1.2. Just to keep track of the recent changes.
4692 * Version 0.1.2. Just to keep track of the recent changes.
4683
4693
4684 * Fixed nasty bug in output prompt routine. It used to check 'if
4694 * Fixed nasty bug in output prompt routine. It used to check 'if
4685 arg != None...'. Problem is, this fails if arg implements a
4695 arg != None...'. Problem is, this fails if arg implements a
4686 special comparison (__cmp__) which disallows comparing to
4696 special comparison (__cmp__) which disallows comparing to
4687 None. Found it when trying to use the PhysicalQuantity module from
4697 None. Found it when trying to use the PhysicalQuantity module from
4688 ScientificPython.
4698 ScientificPython.
4689
4699
4690 2001-11-05 Fernando Perez <fperez@colorado.edu>
4700 2001-11-05 Fernando Perez <fperez@colorado.edu>
4691
4701
4692 * Also added dirs. Now the pushd/popd/dirs family functions
4702 * Also added dirs. Now the pushd/popd/dirs family functions
4693 basically like the shell, with the added convenience of going home
4703 basically like the shell, with the added convenience of going home
4694 when called with no args.
4704 when called with no args.
4695
4705
4696 * pushd/popd slightly modified to mimic shell behavior more
4706 * pushd/popd slightly modified to mimic shell behavior more
4697 closely.
4707 closely.
4698
4708
4699 * Added env,pushd,popd from ShellServices as magic functions. I
4709 * Added env,pushd,popd from ShellServices as magic functions. I
4700 think the cleanest will be to port all desired functions from
4710 think the cleanest will be to port all desired functions from
4701 ShellServices as magics and remove ShellServices altogether. This
4711 ShellServices as magics and remove ShellServices altogether. This
4702 will provide a single, clean way of adding functionality
4712 will provide a single, clean way of adding functionality
4703 (shell-type or otherwise) to IP.
4713 (shell-type or otherwise) to IP.
4704
4714
4705 2001-11-04 Fernando Perez <fperez@colorado.edu>
4715 2001-11-04 Fernando Perez <fperez@colorado.edu>
4706
4716
4707 * Added .ipython/ directory to sys.path. This way users can keep
4717 * Added .ipython/ directory to sys.path. This way users can keep
4708 customizations there and access them via import.
4718 customizations there and access them via import.
4709
4719
4710 2001-11-03 Fernando Perez <fperez@colorado.edu>
4720 2001-11-03 Fernando Perez <fperez@colorado.edu>
4711
4721
4712 * Opened version 0.1.1 for new changes.
4722 * Opened version 0.1.1 for new changes.
4713
4723
4714 * Changed version number to 0.1.0: first 'public' release, sent to
4724 * Changed version number to 0.1.0: first 'public' release, sent to
4715 Nathan and Janko.
4725 Nathan and Janko.
4716
4726
4717 * Lots of small fixes and tweaks.
4727 * Lots of small fixes and tweaks.
4718
4728
4719 * Minor changes to whos format. Now strings are shown, snipped if
4729 * Minor changes to whos format. Now strings are shown, snipped if
4720 too long.
4730 too long.
4721
4731
4722 * Changed ShellServices to work on __main__ so they show up in @who
4732 * Changed ShellServices to work on __main__ so they show up in @who
4723
4733
4724 * Help also works with ? at the end of a line:
4734 * Help also works with ? at the end of a line:
4725 ?sin and sin?
4735 ?sin and sin?
4726 both produce the same effect. This is nice, as often I use the
4736 both produce the same effect. This is nice, as often I use the
4727 tab-complete to find the name of a method, but I used to then have
4737 tab-complete to find the name of a method, but I used to then have
4728 to go to the beginning of the line to put a ? if I wanted more
4738 to go to the beginning of the line to put a ? if I wanted more
4729 info. Now I can just add the ? and hit return. Convenient.
4739 info. Now I can just add the ? and hit return. Convenient.
4730
4740
4731 2001-11-02 Fernando Perez <fperez@colorado.edu>
4741 2001-11-02 Fernando Perez <fperez@colorado.edu>
4732
4742
4733 * Python version check (>=2.1) added.
4743 * Python version check (>=2.1) added.
4734
4744
4735 * Added LazyPython documentation. At this point the docs are quite
4745 * Added LazyPython documentation. At this point the docs are quite
4736 a mess. A cleanup is in order.
4746 a mess. A cleanup is in order.
4737
4747
4738 * Auto-installer created. For some bizarre reason, the zipfiles
4748 * Auto-installer created. For some bizarre reason, the zipfiles
4739 module isn't working on my system. So I made a tar version
4749 module isn't working on my system. So I made a tar version
4740 (hopefully the command line options in various systems won't kill
4750 (hopefully the command line options in various systems won't kill
4741 me).
4751 me).
4742
4752
4743 * Fixes to Struct in genutils. Now all dictionary-like methods are
4753 * Fixes to Struct in genutils. Now all dictionary-like methods are
4744 protected (reasonably).
4754 protected (reasonably).
4745
4755
4746 * Added pager function to genutils and changed ? to print usage
4756 * Added pager function to genutils and changed ? to print usage
4747 note through it (it was too long).
4757 note through it (it was too long).
4748
4758
4749 * Added the LazyPython functionality. Works great! I changed the
4759 * Added the LazyPython functionality. Works great! I changed the
4750 auto-quote escape to ';', it's on home row and next to '. But
4760 auto-quote escape to ';', it's on home row and next to '. But
4751 both auto-quote and auto-paren (still /) escapes are command-line
4761 both auto-quote and auto-paren (still /) escapes are command-line
4752 parameters.
4762 parameters.
4753
4763
4754
4764
4755 2001-11-01 Fernando Perez <fperez@colorado.edu>
4765 2001-11-01 Fernando Perez <fperez@colorado.edu>
4756
4766
4757 * Version changed to 0.0.7. Fairly large change: configuration now
4767 * Version changed to 0.0.7. Fairly large change: configuration now
4758 is all stored in a directory, by default .ipython. There, all
4768 is all stored in a directory, by default .ipython. There, all
4759 config files have normal looking names (not .names)
4769 config files have normal looking names (not .names)
4760
4770
4761 * Version 0.0.6 Released first to Lucas and Archie as a test
4771 * Version 0.0.6 Released first to Lucas and Archie as a test
4762 run. Since it's the first 'semi-public' release, change version to
4772 run. Since it's the first 'semi-public' release, change version to
4763 > 0.0.6 for any changes now.
4773 > 0.0.6 for any changes now.
4764
4774
4765 * Stuff I had put in the ipplib.py changelog:
4775 * Stuff I had put in the ipplib.py changelog:
4766
4776
4767 Changes to InteractiveShell:
4777 Changes to InteractiveShell:
4768
4778
4769 - Made the usage message a parameter.
4779 - Made the usage message a parameter.
4770
4780
4771 - Require the name of the shell variable to be given. It's a bit
4781 - Require the name of the shell variable to be given. It's a bit
4772 of a hack, but allows the name 'shell' not to be hardwire in the
4782 of a hack, but allows the name 'shell' not to be hardwire in the
4773 magic (@) handler, which is problematic b/c it requires
4783 magic (@) handler, which is problematic b/c it requires
4774 polluting the global namespace with 'shell'. This in turn is
4784 polluting the global namespace with 'shell'. This in turn is
4775 fragile: if a user redefines a variable called shell, things
4785 fragile: if a user redefines a variable called shell, things
4776 break.
4786 break.
4777
4787
4778 - magic @: all functions available through @ need to be defined
4788 - magic @: all functions available through @ need to be defined
4779 as magic_<name>, even though they can be called simply as
4789 as magic_<name>, even though they can be called simply as
4780 @<name>. This allows the special command @magic to gather
4790 @<name>. This allows the special command @magic to gather
4781 information automatically about all existing magic functions,
4791 information automatically about all existing magic functions,
4782 even if they are run-time user extensions, by parsing the shell
4792 even if they are run-time user extensions, by parsing the shell
4783 instance __dict__ looking for special magic_ names.
4793 instance __dict__ looking for special magic_ names.
4784
4794
4785 - mainloop: added *two* local namespace parameters. This allows
4795 - mainloop: added *two* local namespace parameters. This allows
4786 the class to differentiate between parameters which were there
4796 the class to differentiate between parameters which were there
4787 before and after command line initialization was processed. This
4797 before and after command line initialization was processed. This
4788 way, later @who can show things loaded at startup by the
4798 way, later @who can show things loaded at startup by the
4789 user. This trick was necessary to make session saving/reloading
4799 user. This trick was necessary to make session saving/reloading
4790 really work: ideally after saving/exiting/reloading a session,
4800 really work: ideally after saving/exiting/reloading a session,
4791 *everythin* should look the same, including the output of @who. I
4801 *everythin* should look the same, including the output of @who. I
4792 was only able to make this work with this double namespace
4802 was only able to make this work with this double namespace
4793 trick.
4803 trick.
4794
4804
4795 - added a header to the logfile which allows (almost) full
4805 - added a header to the logfile which allows (almost) full
4796 session restoring.
4806 session restoring.
4797
4807
4798 - prepend lines beginning with @ or !, with a and log
4808 - prepend lines beginning with @ or !, with a and log
4799 them. Why? !lines: may be useful to know what you did @lines:
4809 them. Why? !lines: may be useful to know what you did @lines:
4800 they may affect session state. So when restoring a session, at
4810 they may affect session state. So when restoring a session, at
4801 least inform the user of their presence. I couldn't quite get
4811 least inform the user of their presence. I couldn't quite get
4802 them to properly re-execute, but at least the user is warned.
4812 them to properly re-execute, but at least the user is warned.
4803
4813
4804 * Started ChangeLog.
4814 * Started ChangeLog.
@@ -1,9307 +1,9376 b''
1 #LyX 1.3 created this file. For more info see http://www.lyx.org/
1 #LyX 1.3 created this file. For more info see http://www.lyx.org/
2 \lyxformat 221
2 \lyxformat 221
3 \textclass article
3 \textclass article
4 \begin_preamble
4 \begin_preamble
5 %\usepackage{ae,aecompl}
5 %\usepackage{ae,aecompl}
6 \usepackage{color}
6 \usepackage{color}
7
7
8 % A few colors to replace the defaults for certain link types
8 % A few colors to replace the defaults for certain link types
9 \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
9 \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
10 \definecolor{darkorange}{rgb}{.71,0.21,0.01}
10 \definecolor{darkorange}{rgb}{.71,0.21,0.01}
11 \definecolor{darkred}{rgb}{.52,0.08,0.01}
11 \definecolor{darkred}{rgb}{.52,0.08,0.01}
12 \definecolor{darkgreen}{rgb}{.12,.54,.11}
12 \definecolor{darkgreen}{rgb}{.12,.54,.11}
13
13
14 % Use and configure listings package for nicely formatted code
14 % Use and configure listings package for nicely formatted code
15 \usepackage{listings}
15 \usepackage{listings}
16 \lstset{
16 \lstset{
17 language=Python,
17 language=Python,
18 basicstyle=\small\ttfamily,
18 basicstyle=\small\ttfamily,
19 commentstyle=\ttfamily\color{blue},
19 commentstyle=\ttfamily\color{blue},
20 stringstyle=\ttfamily\color{darkorange},
20 stringstyle=\ttfamily\color{darkorange},
21 showstringspaces=false,
21 showstringspaces=false,
22 breaklines=true,
22 breaklines=true,
23 postbreak = \space\dots
23 postbreak = \space\dots
24 }
24 }
25
25
26 \usepackage[%pdftex, % needed for pdflatex
26 \usepackage[%pdftex, % needed for pdflatex
27 breaklinks=true, % so long urls are correctly broken across lines
27 breaklinks=true, % so long urls are correctly broken across lines
28 colorlinks=true,
28 colorlinks=true,
29 urlcolor=blue,
29 urlcolor=blue,
30 linkcolor=darkred,
30 linkcolor=darkred,
31 citecolor=darkgreen,
31 citecolor=darkgreen,
32 ]{hyperref}
32 ]{hyperref}
33
33
34 \usepackage{html}
34 \usepackage{html}
35
35
36 % This helps prevent overly long lines that stretch beyond the margins
36 % This helps prevent overly long lines that stretch beyond the margins
37 \sloppy
37 \sloppy
38
38
39 % Define a \codelist command which either uses listings for latex, or
39 % Define a \codelist command which either uses listings for latex, or
40 % plain verbatim for html (since latex2html doesn't understand the
40 % plain verbatim for html (since latex2html doesn't understand the
41 % listings package).
41 % listings package).
42 \usepackage{verbatim}
42 \usepackage{verbatim}
43 \newcommand{\codelist}[1] {
43 \newcommand{\codelist}[1] {
44 \latex{\lstinputlisting{#1}}
44 \latex{\lstinputlisting{#1}}
45 \html{\verbatiminput{#1}}
45 \html{\verbatiminput{#1}}
46 }
46 }
47 \end_preamble
47 \end_preamble
48 \language english
48 \language english
49 \inputencoding latin1
49 \inputencoding latin1
50 \fontscheme palatino
50 \fontscheme palatino
51 \graphics default
51 \graphics default
52 \paperfontsize 10
52 \paperfontsize 11
53 \spacing single
53 \spacing single
54 \papersize Default
54 \papersize Default
55 \paperpackage a4
55 \paperpackage a4
56 \use_geometry 1
56 \use_geometry 1
57 \use_amsmath 0
57 \use_amsmath 0
58 \use_natbib 0
58 \use_natbib 0
59 \use_numerical_citations 0
59 \use_numerical_citations 0
60 \paperorientation portrait
60 \paperorientation portrait
61 \leftmargin 1.1in
61 \leftmargin 1in
62 \topmargin 1in
62 \topmargin 1in
63 \rightmargin 1.1in
63 \rightmargin 1in
64 \bottommargin 1in
64 \bottommargin 1in
65 \secnumdepth 3
65 \secnumdepth 3
66 \tocdepth 3
66 \tocdepth 3
67 \paragraph_separation skip
67 \paragraph_separation skip
68 \defskip medskip
68 \defskip medskip
69 \quotes_language english
69 \quotes_language english
70 \quotes_times 2
70 \quotes_times 2
71 \papercolumns 1
71 \papercolumns 1
72 \papersides 1
72 \papersides 1
73 \paperpagestyle fancy
73 \paperpagestyle fancy
74
74
75 \layout Title
75 \layout Title
76
76
77 IPython
77 IPython
78 \newline
78 \newline
79
79
80 \size larger
80 \size larger
81 An enhanced Interactive Python
81 An enhanced Interactive Python
82 \size large
82 \size large
83
83
84 \newline
84 \newline
85 User Manual, v.
85 User Manual, v.
86 __version__
86 __version__
87 \layout Author
87 \layout Author
88
88
89 Fernando P�rez
89 Fernando P�rez
90 \layout Standard
90 \layout Standard
91
91
92
92
93 \begin_inset ERT
93 \begin_inset ERT
94 status Collapsed
94 status Collapsed
95
95
96 \layout Standard
96 \layout Standard
97
97
98 \backslash
98 \backslash
99 latex{
99 latex{
100 \end_inset
100 \end_inset
101
101
102
102
103 \begin_inset LatexCommand \tableofcontents{}
103 \begin_inset LatexCommand \tableofcontents{}
104
104
105 \end_inset
105 \end_inset
106
106
107
107
108 \begin_inset ERT
108 \begin_inset ERT
109 status Collapsed
109 status Collapsed
110
110
111 \layout Standard
111 \layout Standard
112 }
112 }
113 \end_inset
113 \end_inset
114
114
115
115
116 \layout Standard
116 \layout Standard
117
117
118
118
119 \begin_inset ERT
119 \begin_inset ERT
120 status Open
120 status Open
121
121
122 \layout Standard
122 \layout Standard
123
123
124 \backslash
124 \backslash
125 html{
125 html{
126 \backslash
126 \backslash
127 bodytext{bgcolor=#ffffff}}
127 bodytext{bgcolor=#ffffff}}
128 \end_inset
128 \end_inset
129
129
130
130
131 \layout Section
131 \layout Section
132 \pagebreak_top
132 \pagebreak_top
133 Overview
133 Overview
134 \layout Standard
134 \layout Standard
135
135
136 One of Python's most useful features is its interactive interpreter.
136 One of Python's most useful features is its interactive interpreter.
137 This system allows very fast testing of ideas without the overhead of creating
137 This system allows very fast testing of ideas without the overhead of creating
138 test files as is typical in most programming languages.
138 test files as is typical in most programming languages.
139 However, the interpreter supplied with the standard Python distribution
139 However, the interpreter supplied with the standard Python distribution
140 is somewhat limited for extended interactive use.
140 is somewhat limited for extended interactive use.
141 \layout Standard
141 \layout Standard
142
142
143 IPython is a free software project (released under the BSD license) which
143 IPython is a free software project (released under the BSD license) which
144 tries to:
144 tries to:
145 \layout Enumerate
145 \layout Enumerate
146
146
147 Provide an interactive shell superior to Python's default.
147 Provide an interactive shell superior to Python's default.
148 IPython has many features for object introspection, system shell access,
148 IPython has many features for object introspection, system shell access,
149 and its own special command system for adding functionality when working
149 and its own special command system for adding functionality when working
150 interactively.
150 interactively.
151 It tries to be a very efficient environment both for Python code development
151 It tries to be a very efficient environment both for Python code development
152 and for exploration of problems using Python objects (in situations like
152 and for exploration of problems using Python objects (in situations like
153 data analysis).
153 data analysis).
154 \layout Enumerate
154 \layout Enumerate
155
155
156 Serve as an embeddable, ready to use interpreter for your own programs.
156 Serve as an embeddable, ready to use interpreter for your own programs.
157 IPython can be started with a single call from inside another program,
157 IPython can be started with a single call from inside another program,
158 providing access to the current namespace.
158 providing access to the current namespace.
159 This can be very useful both for debugging purposes and for situations
159 This can be very useful both for debugging purposes and for situations
160 where a blend of batch-processing and interactive exploration are needed.
160 where a blend of batch-processing and interactive exploration are needed.
161 \layout Enumerate
161 \layout Enumerate
162
162
163 Offer a flexible framework which can be used as the base environment for
163 Offer a flexible framework which can be used as the base environment for
164 other systems with Python as the underlying language.
164 other systems with Python as the underlying language.
165 Specifically scientific environments like Mathematica, IDL and Matlab inspired
165 Specifically scientific environments like Mathematica, IDL and Matlab inspired
166 its design, but similar ideas can be useful in many fields.
166 its design, but similar ideas can be useful in many fields.
167 \layout Enumerate
167 \layout Enumerate
168
168
169 Allow interactive testing of threaded graphical toolkits.
169 Allow interactive testing of threaded graphical toolkits.
170 IPython has support for interactive, non-blocking control of GTK, Qt and
170 IPython has support for interactive, non-blocking control of GTK, Qt and
171 WX applications via special threading flags.
171 WX applications via special threading flags.
172 The normal Python shell can only do this for Tkinter applications.
172 The normal Python shell can only do this for Tkinter applications.
173 \layout Subsection
173 \layout Subsection
174
174
175 Main features
175 Main features
176 \layout Itemize
176 \layout Itemize
177
177
178 Dynamic object introspection.
178 Dynamic object introspection.
179 One can access docstrings, function definition prototypes, source code,
179 One can access docstrings, function definition prototypes, source code,
180 source files and other details of any object accessible to the interpreter
180 source files and other details of any object accessible to the interpreter
181 with a single keystroke (`
181 with a single keystroke (`
182 \family typewriter
182 \family typewriter
183 ?
183 ?
184 \family default
184 \family default
185 ', and using `
185 ', and using `
186 \family typewriter
186 \family typewriter
187 ??
187 ??
188 \family default
188 \family default
189 ' provides additional detail).
189 ' provides additional detail).
190 \layout Itemize
190 \layout Itemize
191
191
192 Searching through modules and namespaces with `
192 Searching through modules and namespaces with `
193 \family typewriter
193 \family typewriter
194 *
194 *
195 \family default
195 \family default
196 ' wildcards, both when using the `
196 ' wildcards, both when using the `
197 \family typewriter
197 \family typewriter
198 ?
198 ?
199 \family default
199 \family default
200 ' system and via the
200 ' system and via the
201 \family typewriter
201 \family typewriter
202 %psearch
202 %psearch
203 \family default
203 \family default
204 command.
204 command.
205 \layout Itemize
205 \layout Itemize
206
206
207 Completion in the local namespace, by typing TAB at the prompt.
207 Completion in the local namespace, by typing TAB at the prompt.
208 This works for keywords, methods, variables and files in the current directory.
208 This works for keywords, methods, variables and files in the current directory.
209 This is supported via the readline library, and full access to configuring
209 This is supported via the readline library, and full access to configuring
210 readline's behavior is provided.
210 readline's behavior is provided.
211 \layout Itemize
211 \layout Itemize
212
212
213 Numbered input/output prompts with command history (persistent across sessions
213 Numbered input/output prompts with command history (persistent across sessions
214 and tied to each profile), full searching in this history and caching of
214 and tied to each profile), full searching in this history and caching of
215 all input and output.
215 all input and output.
216 \layout Itemize
216 \layout Itemize
217
217
218 User-extensible `magic' commands.
218 User-extensible `magic' commands.
219 A set of commands prefixed with
219 A set of commands prefixed with
220 \family typewriter
220 \family typewriter
221 %
221 %
222 \family default
222 \family default
223 is available for controlling IPython itself and provides directory control,
223 is available for controlling IPython itself and provides directory control,
224 namespace information and many aliases to common system shell commands.
224 namespace information and many aliases to common system shell commands.
225 \layout Itemize
225 \layout Itemize
226
226
227 Alias facility for defining your own system aliases.
227 Alias facility for defining your own system aliases.
228 \layout Itemize
228 \layout Itemize
229
229
230 Complete system shell access.
230 Complete system shell access.
231 Lines starting with ! are passed directly to the system shell, and using
231 Lines starting with ! are passed directly to the system shell, and using
232 !! captures shell output into python variables for further use.
232 !! captures shell output into python variables for further use.
233 \layout Itemize
233 \layout Itemize
234
234
235 Background execution of Python commands in a separate thread.
235 Background execution of Python commands in a separate thread.
236 IPython has an internal job manager called
236 IPython has an internal job manager called
237 \family typewriter
237 \family typewriter
238 jobs
238 jobs
239 \family default
239 \family default
240 , and a conveninence backgrounding magic function called
240 , and a conveninence backgrounding magic function called
241 \family typewriter
241 \family typewriter
242 %bg
242 %bg
243 \family default
243 \family default
244 .
244 .
245 \layout Itemize
245 \layout Itemize
246
246
247 The ability to expand python variables when calling the system shell.
247 The ability to expand python variables when calling the system shell.
248 In a shell command, any python variable prefixed with
248 In a shell command, any python variable prefixed with
249 \family typewriter
249 \family typewriter
250 $
250 $
251 \family default
251 \family default
252 is expanded.
252 is expanded.
253 A double
253 A double
254 \family typewriter
254 \family typewriter
255 $$
255 $$
256 \family default
256 \family default
257 allows passing a literal
257 allows passing a literal
258 \family typewriter
258 \family typewriter
259 $
259 $
260 \family default
260 \family default
261 to the shell (for access to shell and environment variables like
261 to the shell (for access to shell and environment variables like
262 \family typewriter
262 \family typewriter
263 $PATH
263 $PATH
264 \family default
264 \family default
265 ).
265 ).
266 \layout Itemize
266 \layout Itemize
267
267
268 Filesystem navigation, via a magic
268 Filesystem navigation, via a magic
269 \family typewriter
269 \family typewriter
270 %cd
270 %cd
271 \family default
271 \family default
272 command, along with a persistent bookmark system (using
272 command, along with a persistent bookmark system (using
273 \family typewriter
273 \family typewriter
274 %bookmark
274 %bookmark
275 \family default
275 \family default
276 ) for fast access to frequently visited directories.
276 ) for fast access to frequently visited directories.
277 \layout Itemize
277 \layout Itemize
278
278
279 A lightweight persistence framework via the
279 A lightweight persistence framework via the
280 \family typewriter
280 \family typewriter
281 %store
281 %store
282 \family default
282 \family default
283 command, which allows you to save arbitrary Python variables.
283 command, which allows you to save arbitrary Python variables.
284 These get restored automatically when your session restarts.
284 These get restored automatically when your session restarts.
285 \layout Itemize
285 \layout Itemize
286
286
287 Automatic indentation (optional) of code as you type (through the readline
287 Automatic indentation (optional) of code as you type (through the readline
288 library).
288 library).
289 \layout Itemize
289 \layout Itemize
290
290
291 Macro system for quickly re-executing multiple lines of previous input with
291 Macro system for quickly re-executing multiple lines of previous input with
292 a single name.
292 a single name.
293 Macros can be stored persistently via
293 Macros can be stored persistently via
294 \family typewriter
294 \family typewriter
295 %store
295 %store
296 \family default
296 \family default
297 and edited via
297 and edited via
298 \family typewriter
298 \family typewriter
299 %edit
299 %edit
300 \family default
300 \family default
301 .
301 .
302
302
303 \layout Itemize
303 \layout Itemize
304
304
305 Session logging (you can then later use these logs as code in your programs).
305 Session logging (you can then later use these logs as code in your programs).
306 Logs can optionally timestamp all input, and also store session output
306 Logs can optionally timestamp all input, and also store session output
307 (marked as comments, so the log remains valid Python source code).
307 (marked as comments, so the log remains valid Python source code).
308 \layout Itemize
308 \layout Itemize
309
309
310 Session restoring: logs can be replayed to restore a previous session to
310 Session restoring: logs can be replayed to restore a previous session to
311 the state where you left it.
311 the state where you left it.
312 \layout Itemize
312 \layout Itemize
313
313
314 Verbose and colored exception traceback printouts.
314 Verbose and colored exception traceback printouts.
315 Easier to parse visually, and in verbose mode they produce a lot of useful
315 Easier to parse visually, and in verbose mode they produce a lot of useful
316 debugging information (basically a terminal version of the cgitb module).
316 debugging information (basically a terminal version of the cgitb module).
317 \layout Itemize
317 \layout Itemize
318
318
319 Auto-parentheses: callable objects can be executed without parentheses:
319 Auto-parentheses: callable objects can be executed without parentheses:
320
320
321 \family typewriter
321 \family typewriter
322 `sin 3'
322 `sin 3'
323 \family default
323 \family default
324 is automatically converted to
324 is automatically converted to
325 \family typewriter
325 \family typewriter
326 `sin(3)
326 `sin(3)
327 \family default
327 \family default
328 '.
328 '.
329 \layout Itemize
329 \layout Itemize
330
330
331 Auto-quoting: using `
331 Auto-quoting: using `
332 \family typewriter
332 \family typewriter
333 ,
333 ,
334 \family default
334 \family default
335 ' or `
335 ' or `
336 \family typewriter
336 \family typewriter
337 ;
337 ;
338 \family default
338 \family default
339 ' as the first character forces auto-quoting of the rest of the line:
339 ' as the first character forces auto-quoting of the rest of the line:
340 \family typewriter
340 \family typewriter
341 `,my_function a\SpecialChar ~
341 `,my_function a\SpecialChar ~
342 b'
342 b'
343 \family default
343 \family default
344 becomes automatically
344 becomes automatically
345 \family typewriter
345 \family typewriter
346 `my_function("a","b")'
346 `my_function("a","b")'
347 \family default
347 \family default
348 , while
348 , while
349 \family typewriter
349 \family typewriter
350 `;my_function a\SpecialChar ~
350 `;my_function a\SpecialChar ~
351 b'
351 b'
352 \family default
352 \family default
353 becomes
353 becomes
354 \family typewriter
354 \family typewriter
355 `my_function("a b")'
355 `my_function("a b")'
356 \family default
356 \family default
357 .
357 .
358 \layout Itemize
358 \layout Itemize
359
359
360 Extensible input syntax.
360 Extensible input syntax.
361 You can define filters that pre-process user input to simplify input in
361 You can define filters that pre-process user input to simplify input in
362 special situations.
362 special situations.
363 This allows for example pasting multi-line code fragments which start with
363 This allows for example pasting multi-line code fragments which start with
364
364
365 \family typewriter
365 \family typewriter
366 `>>>'
366 `>>>'
367 \family default
367 \family default
368 or
368 or
369 \family typewriter
369 \family typewriter
370 `...'
370 `...'
371 \family default
371 \family default
372 such as those from other python sessions or the standard Python documentation.
372 such as those from other python sessions or the standard Python documentation.
373 \layout Itemize
373 \layout Itemize
374
374
375 Flexible configuration system.
375 Flexible configuration system.
376 It uses a configuration file which allows permanent setting of all command-line
376 It uses a configuration file which allows permanent setting of all command-line
377 options, module loading, code and file execution.
377 options, module loading, code and file execution.
378 The system allows recursive file inclusion, so you can have a base file
378 The system allows recursive file inclusion, so you can have a base file
379 with defaults and layers which load other customizations for particular
379 with defaults and layers which load other customizations for particular
380 projects.
380 projects.
381 \layout Itemize
381 \layout Itemize
382
382
383 Embeddable.
383 Embeddable.
384 You can call IPython as a python shell inside your own python programs.
384 You can call IPython as a python shell inside your own python programs.
385 This can be used both for debugging code or for providing interactive abilities
385 This can be used both for debugging code or for providing interactive abilities
386 to your programs with knowledge about the local namespaces (very useful
386 to your programs with knowledge about the local namespaces (very useful
387 in debugging and data analysis situations).
387 in debugging and data analysis situations).
388 \layout Itemize
388 \layout Itemize
389
389
390 Easy debugger access.
390 Easy debugger access.
391 You can set IPython to call up an enhanced version of the Python debugger
391 You can set IPython to call up an enhanced version of the Python debugger
392 (
392 (
393 \family typewriter
393 \family typewriter
394 pdb
394 pdb
395 \family default
395 \family default
396 ) every time there is an uncaught exception.
396 ) every time there is an uncaught exception.
397 This drops you inside the code which triggered the exception with all the
397 This drops you inside the code which triggered the exception with all the
398 data live and it is possible to navigate the stack to rapidly isolate the
398 data live and it is possible to navigate the stack to rapidly isolate the
399 source of a bug.
399 source of a bug.
400 The
400 The
401 \family typewriter
401 \family typewriter
402 %run
402 %run
403 \family default
403 \family default
404 magic command --with the
404 magic command --with the
405 \family typewriter
405 \family typewriter
406 -d
406 -d
407 \family default
407 \family default
408 option-- can run any script under
408 option-- can run any script under
409 \family typewriter
409 \family typewriter
410 pdb
410 pdb
411 \family default
411 \family default
412 's control, automatically setting initial breakpoints for you.
412 's control, automatically setting initial breakpoints for you.
413 This version of
413 This version of
414 \family typewriter
414 \family typewriter
415 pdb
415 pdb
416 \family default
416 \family default
417 has IPython-specific improvements, including tab-completion and traceback
417 has IPython-specific improvements, including tab-completion and traceback
418 coloring support.
418 coloring support.
419 \layout Itemize
419 \layout Itemize
420
420
421 Profiler support.
421 Profiler support.
422 You can run single statements (similar to
422 You can run single statements (similar to
423 \family typewriter
423 \family typewriter
424 profile.run()
424 profile.run()
425 \family default
425 \family default
426 ) or complete programs under the profiler's control.
426 ) or complete programs under the profiler's control.
427 While this is possible with the standard
427 While this is possible with the standard
428 \family typewriter
428 \family typewriter
429 profile
429 profile
430 \family default
430 \family default
431 module, IPython wraps this functionality with magic commands (see
431 module, IPython wraps this functionality with magic commands (see
432 \family typewriter
432 \family typewriter
433 `%prun'
433 `%prun'
434 \family default
434 \family default
435 and
435 and
436 \family typewriter
436 \family typewriter
437 `%run -p
437 `%run -p
438 \family default
438 \family default
439 ') convenient for rapid interactive work.
439 ') convenient for rapid interactive work.
440 \layout Subsection
440 \layout Subsection
441
441
442 Portability and Python requirements
442 Portability and Python requirements
443 \layout Standard
443 \layout Standard
444
444
445
445
446 \series bold
446 \series bold
447 Python requirements:
447 Python requirements:
448 \series default
448 \series default
449 IPython requires with Python version 2.3 or newer.
449 IPython requires with Python version 2.3 or newer.
450 If you are still using Python 2.2 and can not upgrade, the last version
450 If you are still using Python 2.2 and can not upgrade, the last version
451 of IPython which worked with Python 2.2 was 0.6.15, so you will have to use
451 of IPython which worked with Python 2.2 was 0.6.15, so you will have to use
452 that.
452 that.
453 \layout Standard
453 \layout Standard
454
454
455 IPython is developed under
455 IPython is developed under
456 \series bold
456 \series bold
457 Linux
457 Linux
458 \series default
458 \series default
459 , but it should work in any reasonable Unix-type system (tested OK under
459 , but it should work in any reasonable Unix-type system (tested OK under
460 Solaris and the *BSD family, for which a port exists thanks to Dryice Liu).
460 Solaris and the *BSD family, for which a port exists thanks to Dryice Liu).
461 \layout Standard
461 \layout Standard
462
462
463
463
464 \series bold
464 \series bold
465 Mac OS X
465 Mac OS X
466 \series default
466 \series default
467 : it works, apparently without any problems (thanks to Jim Boyle at Lawrence
467 : it works, apparently without any problems (thanks to Jim Boyle at Lawrence
468 Livermore for the information).
468 Livermore for the information).
469 Thanks to Andrea Riciputi, Fink support is available.
469 Thanks to Andrea Riciputi, Fink support is available.
470 \layout Standard
470 \layout Standard
471
471
472
472
473 \series bold
473 \series bold
474 CygWin
474 CygWin
475 \series default
475 \series default
476 : it works mostly OK, though some users have reported problems with prompt
476 : it works mostly OK, though some users have reported problems with prompt
477 coloring.
477 coloring.
478 No satisfactory solution to this has been found so far, you may want to
478 No satisfactory solution to this has been found so far, you may want to
479 disable colors permanently in the
479 disable colors permanently in the
480 \family typewriter
480 \family typewriter
481 ipythonrc
481 ipythonrc
482 \family default
482 \family default
483 configuration file if you experience problems.
483 configuration file if you experience problems.
484 If you have proper color support under cygwin, please post to the IPython
484 If you have proper color support under cygwin, please post to the IPython
485 mailing list so this issue can be resolved for all users.
485 mailing list so this issue can be resolved for all users.
486 \layout Standard
486 \layout Standard
487
487
488
488
489 \series bold
489 \series bold
490 Windows
490 Windows
491 \series default
491 \series default
492 : it works well under Windows XP/2k, and I suspect NT should behave similarly.
492 : it works well under Windows XP/2k, and I suspect NT should behave similarly.
493 Section\SpecialChar ~
493 Section\SpecialChar ~
494
494
495 \begin_inset LatexCommand \ref{sub:Under-Windows}
495 \begin_inset LatexCommand \ref{sub:Under-Windows}
496
496
497 \end_inset
497 \end_inset
498
498
499 describes installation details for Windows, including some additional tools
499 describes installation details for Windows, including some additional tools
500 needed on this platform.
500 needed on this platform.
501 \layout Standard
501 \layout Standard
502
502
503 Windows 9x support is present, and has been reported to work fine (at least
503 Windows 9x support is present, and has been reported to work fine (at least
504 on WinME).
504 on WinME).
505 \layout Standard
505 \layout Standard
506
506
507 Note, that I have very little access to and experience with Windows development.
507 Note, that I have very little access to and experience with Windows development.
508 However, an excellent group of Win32 users (led by Ville Vainio), consistenly
508 However, an excellent group of Win32 users (led by Ville Vainio), consistenly
509 contribute bugfixes and platform-specific enhancements, so they more than
509 contribute bugfixes and platform-specific enhancements, so they more than
510 make up for my deficiencies on that front.
510 make up for my deficiencies on that front.
511 In fact, Win32 users report using IPython as a system shell (see Sec.\SpecialChar ~
511 In fact, Win32 users report using IPython as a system shell (see Sec.\SpecialChar ~
512
512
513 \begin_inset LatexCommand \ref{sec:IPython-as-shell}
513 \begin_inset LatexCommand \ref{sec:IPython-as-shell}
514
514
515 \end_inset
515 \end_inset
516
516
517 for details), as it offers a level of control and features which the default
517 for details), as it offers a level of control and features which the default
518
518
519 \family typewriter
519 \family typewriter
520 cmd.exe
520 cmd.exe
521 \family default
521 \family default
522 doesn't provide.
522 doesn't provide.
523 \layout Subsection
523 \layout Subsection
524
524
525 Location
525 Location
526 \layout Standard
526 \layout Standard
527
527
528 IPython is generously hosted at
528 IPython is generously hosted at
529 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
529 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
530
530
531 \end_inset
531 \end_inset
532
532
533 by the Enthought, Inc and the SciPy project.
533 by the Enthought, Inc and the SciPy project.
534 This site offers downloads, subversion access, mailing lists and a bug
534 This site offers downloads, subversion access, mailing lists and a bug
535 tracking system.
535 tracking system.
536 I am very grateful to Enthought (
536 I am very grateful to Enthought (
537 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
537 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
538
538
539 \end_inset
539 \end_inset
540
540
541 ) and all of the SciPy team for their contribution.
541 ) and all of the SciPy team for their contribution.
542 \layout Section
542 \layout Section
543
543
544
544
545 \begin_inset LatexCommand \label{sec:install}
545 \begin_inset LatexCommand \label{sec:install}
546
546
547 \end_inset
547 \end_inset
548
548
549 Installation
549 Installation
550 \layout Subsection
550 \layout Subsection
551
551
552 Instant instructions
552 Instant instructions
553 \layout Standard
553 \layout Standard
554
554
555 If you are of the impatient kind, under Linux/Unix simply untar/unzip the
555 If you are of the impatient kind, under Linux/Unix simply untar/unzip the
556 download, then install with
556 download, then install with
557 \family typewriter
557 \family typewriter
558 `python setup.py install'
558 `python setup.py install'
559 \family default
559 \family default
560 .
560 .
561 Under Windows, double-click on the provided
561 Under Windows, double-click on the provided
562 \family typewriter
562 \family typewriter
563 .exe
563 .exe
564 \family default
564 \family default
565 binary installer.
565 binary installer.
566 \layout Standard
566 \layout Standard
567
567
568 Then, take a look at Sections
568 Then, take a look at Sections
569 \begin_inset LatexCommand \ref{sec:good_config}
569 \begin_inset LatexCommand \ref{sec:good_config}
570
570
571 \end_inset
571 \end_inset
572
572
573 for configuring things optimally and
573 for configuring things optimally and
574 \begin_inset LatexCommand \ref{sec:quick_tips}
574 \begin_inset LatexCommand \ref{sec:quick_tips}
575
575
576 \end_inset
576 \end_inset
577
577
578 for quick tips on efficient use of IPython.
578 for quick tips on efficient use of IPython.
579 You can later refer to the rest of the manual for all the gory details.
579 You can later refer to the rest of the manual for all the gory details.
580 \layout Standard
580 \layout Standard
581
581
582 See the notes in sec.
582 See the notes in sec.
583
583
584 \begin_inset LatexCommand \ref{sec:upgrade}
584 \begin_inset LatexCommand \ref{sec:upgrade}
585
585
586 \end_inset
586 \end_inset
587
587
588 for upgrading IPython versions.
588 for upgrading IPython versions.
589 \layout Subsection
589 \layout Subsection
590
590
591 Detailed Unix instructions (Linux, Mac OS X, etc.)
591 Detailed Unix instructions (Linux, Mac OS X, etc.)
592 \layout Standard
592 \layout Standard
593
593
594 For RPM based systems, simply install the supplied package in the usual
594 For RPM based systems, simply install the supplied package in the usual
595 manner.
595 manner.
596 If you download the tar archive, the process is:
596 If you download the tar archive, the process is:
597 \layout Enumerate
597 \layout Enumerate
598
598
599 Unzip/untar the
599 Unzip/untar the
600 \family typewriter
600 \family typewriter
601 ipython-XXX.tar.gz
601 ipython-XXX.tar.gz
602 \family default
602 \family default
603 file wherever you want (
603 file wherever you want (
604 \family typewriter
604 \family typewriter
605 XXX
605 XXX
606 \family default
606 \family default
607 is the version number).
607 is the version number).
608 It will make a directory called
608 It will make a directory called
609 \family typewriter
609 \family typewriter
610 ipython-XXX.
610 ipython-XXX.
611
611
612 \family default
612 \family default
613 Change into that directory where you will find the files
613 Change into that directory where you will find the files
614 \family typewriter
614 \family typewriter
615 README
615 README
616 \family default
616 \family default
617 and
617 and
618 \family typewriter
618 \family typewriter
619 setup.py
619 setup.py
620 \family default
620 \family default
621 .
621 .
622
622
623 \family typewriter
623 \family typewriter
624 O
624 O
625 \family default
625 \family default
626 nce you've completed the installation, you can safely remove this directory.
626 nce you've completed the installation, you can safely remove this directory.
627
627
628 \layout Enumerate
628 \layout Enumerate
629
629
630 If you are installing over a previous installation of version 0.2.0 or earlier,
630 If you are installing over a previous installation of version 0.2.0 or earlier,
631 first remove your
631 first remove your
632 \family typewriter
632 \family typewriter
633 $HOME/.ipython
633 $HOME/.ipython
634 \family default
634 \family default
635 directory, since the configuration file format has changed somewhat (the
635 directory, since the configuration file format has changed somewhat (the
636 '=' were removed from all option specifications).
636 '=' were removed from all option specifications).
637 Or you can call ipython with the
637 Or you can call ipython with the
638 \family typewriter
638 \family typewriter
639 -upgrade
639 -upgrade
640 \family default
640 \family default
641 option and it will do this automatically for you.
641 option and it will do this automatically for you.
642 \layout Enumerate
642 \layout Enumerate
643
643
644 IPython uses distutils, so you can install it by simply typing at the system
644 IPython uses distutils, so you can install it by simply typing at the system
645 prompt (don't type the
645 prompt (don't type the
646 \family typewriter
646 \family typewriter
647 $
647 $
648 \family default
648 \family default
649 )
649 )
650 \newline
650 \newline
651
651
652 \family typewriter
652 \family typewriter
653 $ python setup.py install
653 $ python setup.py install
654 \family default
654 \family default
655
655
656 \newline
656 \newline
657 Note that this assumes you have root access to your machine.
657 Note that this assumes you have root access to your machine.
658 If you don't have root access or don't want IPython to go in the default
658 If you don't have root access or don't want IPython to go in the default
659 python directories, you'll need to use the
659 python directories, you'll need to use the
660 \begin_inset ERT
660 \begin_inset ERT
661 status Collapsed
661 status Collapsed
662
662
663 \layout Standard
663 \layout Standard
664
664
665 \backslash
665 \backslash
666 verb|--home|
666 verb|--home|
667 \end_inset
667 \end_inset
668
668
669 option (or
669 option (or
670 \begin_inset ERT
670 \begin_inset ERT
671 status Collapsed
671 status Collapsed
672
672
673 \layout Standard
673 \layout Standard
674
674
675 \backslash
675 \backslash
676 verb|--prefix|
676 verb|--prefix|
677 \end_inset
677 \end_inset
678
678
679 ).
679 ).
680 For example:
680 For example:
681 \newline
681 \newline
682
682
683 \begin_inset ERT
683 \begin_inset ERT
684 status Collapsed
684 status Collapsed
685
685
686 \layout Standard
686 \layout Standard
687
687
688 \backslash
688 \backslash
689 verb|$ python setup.py install --home $HOME/local|
689 verb|$ python setup.py install --home $HOME/local|
690 \end_inset
690 \end_inset
691
691
692
692
693 \newline
693 \newline
694 will install IPython into
694 will install IPython into
695 \family typewriter
695 \family typewriter
696 $HOME/local
696 $HOME/local
697 \family default
697 \family default
698 and its subdirectories (creating them if necessary).
698 and its subdirectories (creating them if necessary).
699 \newline
699 \newline
700 You can type
700 You can type
701 \newline
701 \newline
702
702
703 \begin_inset ERT
703 \begin_inset ERT
704 status Collapsed
704 status Collapsed
705
705
706 \layout Standard
706 \layout Standard
707
707
708 \backslash
708 \backslash
709 verb|$ python setup.py --help|
709 verb|$ python setup.py --help|
710 \end_inset
710 \end_inset
711
711
712
712
713 \newline
713 \newline
714 for more details.
714 for more details.
715 \newline
715 \newline
716 Note that if you change the default location for
716 Note that if you change the default location for
717 \begin_inset ERT
717 \begin_inset ERT
718 status Collapsed
718 status Collapsed
719
719
720 \layout Standard
720 \layout Standard
721
721
722 \backslash
722 \backslash
723 verb|--home|
723 verb|--home|
724 \end_inset
724 \end_inset
725
725
726 at installation, IPython may end up installed at a location which is not
726 at installation, IPython may end up installed at a location which is not
727 part of your
727 part of your
728 \family typewriter
728 \family typewriter
729 $PYTHONPATH
729 $PYTHONPATH
730 \family default
730 \family default
731 environment variable.
731 environment variable.
732 In this case, you'll need to configure this variable to include the actual
732 In this case, you'll need to configure this variable to include the actual
733 directory where the
733 directory where the
734 \family typewriter
734 \family typewriter
735 IPython/
735 IPython/
736 \family default
736 \family default
737 directory ended (typically the value you give to
737 directory ended (typically the value you give to
738 \begin_inset ERT
738 \begin_inset ERT
739 status Collapsed
739 status Collapsed
740
740
741 \layout Standard
741 \layout Standard
742
742
743 \backslash
743 \backslash
744 verb|--home|
744 verb|--home|
745 \end_inset
745 \end_inset
746
746
747 plus
747 plus
748 \family typewriter
748 \family typewriter
749 /lib/python
749 /lib/python
750 \family default
750 \family default
751 ).
751 ).
752 \layout Subsubsection
752 \layout Subsubsection
753
753
754 Mac OSX information
754 Mac OSX information
755 \layout Standard
755 \layout Standard
756
756
757 Under OSX, there is a choice you need to make.
757 Under OSX, there is a choice you need to make.
758 Apple ships its own build of Python, which lives in the core OSX filesystem
758 Apple ships its own build of Python, which lives in the core OSX filesystem
759 hierarchy.
759 hierarchy.
760 You can also manually install a separate Python, either purely by hand
760 You can also manually install a separate Python, either purely by hand
761 (typically in
761 (typically in
762 \family typewriter
762 \family typewriter
763 /usr/local
763 /usr/local
764 \family default
764 \family default
765 ) or by using Fink, which puts everything under
765 ) or by using Fink, which puts everything under
766 \family typewriter
766 \family typewriter
767 /sw
767 /sw
768 \family default
768 \family default
769 .
769 .
770 Which route to follow is a matter of personal preference, as I've seen
770 Which route to follow is a matter of personal preference, as I've seen
771 users who favor each of the approaches.
771 users who favor each of the approaches.
772 Here I will simply list the known installation issues under OSX, along
772 Here I will simply list the known installation issues under OSX, along
773 with their solutions.
773 with their solutions.
774 \layout Standard
774 \layout Standard
775
775
776 This page:
776 This page:
777 \begin_inset LatexCommand \htmlurl{http://geosci.uchicago.edu/~tobis/pylab.html}
777 \begin_inset LatexCommand \htmlurl{http://geosci.uchicago.edu/~tobis/pylab.html}
778
778
779 \end_inset
779 \end_inset
780
780
781 contains information on this topic, with additional details on how to make
781 contains information on this topic, with additional details on how to make
782 IPython and matplotlib play nicely under OSX.
782 IPython and matplotlib play nicely under OSX.
783 \layout Subsubsection*
783 \layout Subsubsection*
784
784
785 GUI problems
785 GUI problems
786 \layout Standard
786 \layout Standard
787
787
788 The following instructions apply to an install of IPython under OSX from
788 The following instructions apply to an install of IPython under OSX from
789 unpacking the
789 unpacking the
790 \family typewriter
790 \family typewriter
791 .tar.gz
791 .tar.gz
792 \family default
792 \family default
793 distribution and installing it for the default Python interpreter shipped
793 distribution and installing it for the default Python interpreter shipped
794 by Apple.
794 by Apple.
795 If you are using a fink install, fink will take care of these details for
795 If you are using a fink install, fink will take care of these details for
796 you, by installing IPython against fink's Python.
796 you, by installing IPython against fink's Python.
797 \layout Standard
797 \layout Standard
798
798
799 IPython offers various forms of support for interacting with graphical applicati
799 IPython offers various forms of support for interacting with graphical applicati
800 ons from the command line, from simple Tk apps (which are in principle always
800 ons from the command line, from simple Tk apps (which are in principle always
801 supported by Python) to interactive control of WX, Qt and GTK apps.
801 supported by Python) to interactive control of WX, Qt and GTK apps.
802 Under OSX, however, this requires that ipython is installed by calling
802 Under OSX, however, this requires that ipython is installed by calling
803 the special
803 the special
804 \family typewriter
804 \family typewriter
805 pythonw
805 pythonw
806 \family default
806 \family default
807 script at installation time, which takes care of coordinating things with
807 script at installation time, which takes care of coordinating things with
808 Apple's graphical environment.
808 Apple's graphical environment.
809 \layout Standard
809 \layout Standard
810
810
811 So when installing under OSX, it is best to use the following command:
811 So when installing under OSX, it is best to use the following command:
812 \family typewriter
812 \family typewriter
813
813
814 \newline
814 \newline
815
815
816 \family default
816 \family default
817
817
818 \begin_inset ERT
818 \begin_inset ERT
819 status Collapsed
819 status Collapsed
820
820
821 \layout Standard
821 \layout Standard
822
822
823 \backslash
823 \backslash
824 verb| $ sudo pythonw setup.py install --install-scripts=/usr/local/bin|
824 verb| $ sudo pythonw setup.py install --install-scripts=/usr/local/bin|
825 \end_inset
825 \end_inset
826
826
827
827
828 \newline
828 \newline
829 or
829 or
830 \newline
830 \newline
831
831
832 \begin_inset ERT
832 \begin_inset ERT
833 status Collapsed
833 status Collapsed
834
834
835 \layout Standard
835 \layout Standard
836
836
837 \backslash
837 \backslash
838 verb| $ sudo pythonw setup.py install --install-scripts=/usr/bin|
838 verb| $ sudo pythonw setup.py install --install-scripts=/usr/bin|
839 \end_inset
839 \end_inset
840
840
841
841
842 \newline
842 \newline
843 depending on where you like to keep hand-installed executables.
843 depending on where you like to keep hand-installed executables.
844 \layout Standard
844 \layout Standard
845
845
846 The resulting script will have an appropriate shebang line (the first line
846 The resulting script will have an appropriate shebang line (the first line
847 in the script whic begins with
847 in the script whic begins with
848 \family typewriter
848 \family typewriter
849 #!...
849 #!...
850 \family default
850 \family default
851 ) such that the ipython interpreter can interact with the OS X GUI.
851 ) such that the ipython interpreter can interact with the OS X GUI.
852 If the installed version does not work and has a shebang line that points
852 If the installed version does not work and has a shebang line that points
853 to, for example, just
853 to, for example, just
854 \family typewriter
854 \family typewriter
855 /usr/bin/python
855 /usr/bin/python
856 \family default
856 \family default
857 , then you might have a stale, cached version in your
857 , then you might have a stale, cached version in your
858 \family typewriter
858 \family typewriter
859 build/scripts-<python-version>
859 build/scripts-<python-version>
860 \family default
860 \family default
861 directory.
861 directory.
862 Delete that directory and rerun the
862 Delete that directory and rerun the
863 \family typewriter
863 \family typewriter
864 setup.py
864 setup.py
865 \family default
865 \family default
866 .
866 .
867
867
868 \layout Standard
868 \layout Standard
869
869
870 It is also a good idea to use the special flag
870 It is also a good idea to use the special flag
871 \begin_inset ERT
871 \begin_inset ERT
872 status Collapsed
872 status Collapsed
873
873
874 \layout Standard
874 \layout Standard
875
875
876 \backslash
876 \backslash
877 verb|--install-scripts|
877 verb|--install-scripts|
878 \end_inset
878 \end_inset
879
879
880 as indicated above, to ensure that the ipython scripts end up in a location
880 as indicated above, to ensure that the ipython scripts end up in a location
881 which is part of your
881 which is part of your
882 \family typewriter
882 \family typewriter
883 $PATH
883 $PATH
884 \family default
884 \family default
885 .
885 .
886 Otherwise Apple's Python will put the scripts in an internal directory
886 Otherwise Apple's Python will put the scripts in an internal directory
887 not available by default at the command line (if you use
887 not available by default at the command line (if you use
888 \family typewriter
888 \family typewriter
889 /usr/local/bin
889 /usr/local/bin
890 \family default
890 \family default
891 , you need to make sure this is in your
891 , you need to make sure this is in your
892 \family typewriter
892 \family typewriter
893 $PATH
893 $PATH
894 \family default
894 \family default
895 , which may not be true by default).
895 , which may not be true by default).
896 \layout Subsubsection*
896 \layout Subsubsection*
897
897
898 Readline problems
898 Readline problems
899 \layout Standard
899 \layout Standard
900
900
901 By default, the Python version shipped by Apple does
901 By default, the Python version shipped by Apple does
902 \emph on
902 \emph on
903 not
903 not
904 \emph default
904 \emph default
905 include the readline library, so central to IPython's behavior.
905 include the readline library, so central to IPython's behavior.
906 If you install IPython against Apple's Python, you will not have arrow
906 If you install IPython against Apple's Python, you will not have arrow
907 keys, tab completion, etc.
907 keys, tab completion, etc.
908 For Mac OSX 10.3 (Panther), you can find a prebuilt readline library here:
908 For Mac OSX 10.3 (Panther), you can find a prebuilt readline library here:
909 \newline
909 \newline
910
910
911 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/readline-5.0-py2.3-macosx10.3.zip}
911 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/readline-5.0-py2.3-macosx10.3.zip}
912
912
913 \end_inset
913 \end_inset
914
914
915
915
916 \layout Standard
916 \layout Standard
917
917
918 If you are using OSX 10.4 (Tiger), after installing this package you need
918 If you are using OSX 10.4 (Tiger), after installing this package you need
919 to either:
919 to either:
920 \layout Enumerate
920 \layout Enumerate
921
921
922 move
922 move
923 \family typewriter
923 \family typewriter
924 readline.so
924 readline.so
925 \family default
925 \family default
926 from
926 from
927 \family typewriter
927 \family typewriter
928 /Library/Python/2.3
928 /Library/Python/2.3
929 \family default
929 \family default
930 to
930 to
931 \family typewriter
931 \family typewriter
932 /Library/Python/2.3/site-packages
932 /Library/Python/2.3/site-packages
933 \family default
933 \family default
934 , or
934 , or
935 \layout Enumerate
935 \layout Enumerate
936
936
937 install
937 install
938 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/TigerPython23Compat.pkg.zip}
938 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/TigerPython23Compat.pkg.zip}
939
939
940 \end_inset
940 \end_inset
941
941
942
942
943 \layout Standard
943 \layout Standard
944
944
945 Users installing against Fink's Python or a properly hand-built one should
945 Users installing against Fink's Python or a properly hand-built one should
946 not have this problem.
946 not have this problem.
947 \layout Subsubsection*
947 \layout Subsubsection*
948
948
949 DarwinPorts
949 DarwinPorts
950 \layout Standard
950 \layout Standard
951
951
952 I report here a message from an OSX user, who suggests an alternative means
952 I report here a message from an OSX user, who suggests an alternative means
953 of using IPython under this operating system with good results.
953 of using IPython under this operating system with good results.
954 Please let me know of any updates that may be useful for this section.
954 Please let me know of any updates that may be useful for this section.
955 His message is reproduced verbatim below:
955 His message is reproduced verbatim below:
956 \layout Quote
956 \layout Quote
957
957
958 From: Markus Banfi
958 From: Markus Banfi
959 \family typewriter
959 \family typewriter
960 <markus.banfi-AT-mospheira.net>
960 <markus.banfi-AT-mospheira.net>
961 \layout Quote
961 \layout Quote
962
962
963 As a MacOS X (10.4.2) user I prefer to install software using DawinPorts instead
963 As a MacOS X (10.4.2) user I prefer to install software using DawinPorts instead
964 of Fink.
964 of Fink.
965 I had no problems installing ipython with DarwinPorts.
965 I had no problems installing ipython with DarwinPorts.
966 It's just:
966 It's just:
967 \layout Quote
967 \layout Quote
968
968
969
969
970 \family typewriter
970 \family typewriter
971 sudo port install py-ipython
971 sudo port install py-ipython
972 \layout Quote
972 \layout Quote
973
973
974 It automatically resolved all dependencies (python24, readline, py-readline).
974 It automatically resolved all dependencies (python24, readline, py-readline).
975 So far I did not encounter any problems with the DarwinPorts port of ipython.
975 So far I did not encounter any problems with the DarwinPorts port of ipython.
976
976
977 \layout Subsection
977 \layout Subsection
978
978
979
979
980 \begin_inset LatexCommand \label{sub:Under-Windows}
980 \begin_inset LatexCommand \label{sub:Under-Windows}
981
981
982 \end_inset
982 \end_inset
983
983
984 Windows instructions
984 Windows instructions
985 \layout Standard
985 \layout Standard
986
986
987 Some of IPython's very useful features are:
987 Some of IPython's very useful features are:
988 \layout Itemize
988 \layout Itemize
989
989
990 Integrated readline support (Tab-based file, object and attribute completion,
990 Integrated readline support (Tab-based file, object and attribute completion,
991 input history across sessions, editable command line, etc.)
991 input history across sessions, editable command line, etc.)
992 \layout Itemize
992 \layout Itemize
993
993
994 Coloring of prompts, code and tracebacks.
994 Coloring of prompts, code and tracebacks.
995 \layout Standard
995 \layout Standard
996
996
997 These, by default, are only available under Unix-like operating systems.
997 These, by default, are only available under Unix-like operating systems.
998 However, thanks to Gary Bishop's work, Windows XP/2k users can also benefit
998 However, thanks to Gary Bishop's work, Windows XP/2k users can also benefit
999 from them.
999 from them.
1000 His readline library implements both GNU readline functionality and color
1000 His readline library implements both GNU readline functionality and color
1001 support, so that IPython under Windows XP/2k can be as friendly and powerful
1001 support, so that IPython under Windows XP/2k can be as friendly and powerful
1002 as under Unix-like environments.
1002 as under Unix-like environments.
1003 \layout Standard
1003 \layout Standard
1004
1004
1005 The
1005 The
1006 \family typewriter
1006 \family typewriter
1007 readline
1007 readline
1008 \family default
1008 \family default
1009 extension needs two other libraries to work, so in all you need:
1009 extension needs two other libraries to work, so in all you need:
1010 \layout Enumerate
1010 \layout Enumerate
1011
1011
1012
1012
1013 \family typewriter
1013 \family typewriter
1014 PyWin32
1014 PyWin32
1015 \family default
1015 \family default
1016 from
1016 from
1017 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/mhammond}
1017 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/mhammond}
1018
1018
1019 \end_inset
1019 \end_inset
1020
1020
1021 .
1021 .
1022 \layout Enumerate
1022 \layout Enumerate
1023
1023
1024
1024
1025 \family typewriter
1025 \family typewriter
1026 CTypes
1026 CTypes
1027 \family default
1027 \family default
1028 from
1028 from
1029 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/theller/ctypes}
1029 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/theller/ctypes}
1030
1030
1031 \end_inset
1031 \end_inset
1032
1032
1033 (you
1033 (you
1034 \emph on
1034 \emph on
1035 must
1035 must
1036 \emph default
1036 \emph default
1037 use version 0.9.1 or newer).
1037 use version 0.9.1 or newer).
1038 \layout Enumerate
1038 \layout Enumerate
1039
1039
1040
1040
1041 \family typewriter
1041 \family typewriter
1042 Readline
1042 Readline
1043 \family default
1043 \family default
1044 for Windows from
1044 for Windows from
1045 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/uncpythontools}
1045 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/uncpythontools}
1046
1046
1047 \end_inset
1047 \end_inset
1048
1048
1049 .
1049 .
1050 \layout Standard
1050 \layout Standard
1051
1051
1052
1052
1053 \series bold
1053 \series bold
1054 Warning about a broken readline-like library:
1054 Warning about a broken readline-like library:
1055 \series default
1055 \series default
1056 several users have reported problems stemming from using the pseudo-readline
1056 several users have reported problems stemming from using the pseudo-readline
1057 library at
1057 library at
1058 \begin_inset LatexCommand \htmlurl{http://newcenturycomputers.net/projects/readline.html}
1058 \begin_inset LatexCommand \htmlurl{http://newcenturycomputers.net/projects/readline.html}
1059
1059
1060 \end_inset
1060 \end_inset
1061
1061
1062 .
1062 .
1063 This is a broken library which, while called readline, only implements
1063 This is a broken library which, while called readline, only implements
1064 an incomplete subset of the readline API.
1064 an incomplete subset of the readline API.
1065 Since it is still called readline, it fools IPython's detection mechanisms
1065 Since it is still called readline, it fools IPython's detection mechanisms
1066 and causes unpredictable crashes later.
1066 and causes unpredictable crashes later.
1067 If you wish to use IPython under Windows, you must NOT use this library,
1067 If you wish to use IPython under Windows, you must NOT use this library,
1068 which for all purposes is (at least as of version 1.6) terminally broken.
1068 which for all purposes is (at least as of version 1.6) terminally broken.
1069 \layout Subsubsection
1069 \layout Subsubsection
1070
1070
1071 Installation procedure
1071 Installation procedure
1072 \layout Standard
1072 \layout Standard
1073
1073
1074 Once you have the above installed, from the IPython download directory grab
1074 Once you have the above installed, from the IPython download directory grab
1075 the
1075 the
1076 \family typewriter
1076 \family typewriter
1077 ipython-XXX.win32.exe
1077 ipython-XXX.win32.exe
1078 \family default
1078 \family default
1079 file, where
1079 file, where
1080 \family typewriter
1080 \family typewriter
1081 XXX
1081 XXX
1082 \family default
1082 \family default
1083 represents the version number.
1083 represents the version number.
1084 This is a regular windows executable installer, which you can simply double-cli
1084 This is a regular windows executable installer, which you can simply double-cli
1085 ck to install.
1085 ck to install.
1086 It will add an entry for IPython to your Start Menu, as well as registering
1086 It will add an entry for IPython to your Start Menu, as well as registering
1087 IPython in the Windows list of applications, so you can later uninstall
1087 IPython in the Windows list of applications, so you can later uninstall
1088 it from the Control Panel.
1088 it from the Control Panel.
1089
1089
1090 \layout Standard
1090 \layout Standard
1091
1091
1092 IPython tries to install the configuration information in a directory named
1092 IPython tries to install the configuration information in a directory named
1093
1093
1094 \family typewriter
1094 \family typewriter
1095 .ipython
1095 .ipython
1096 \family default
1096 \family default
1097 (
1097 (
1098 \family typewriter
1098 \family typewriter
1099 _ipython
1099 _ipython
1100 \family default
1100 \family default
1101 under Windows) located in your `home' directory.
1101 under Windows) located in your `home' directory.
1102 IPython sets this directory by looking for a
1102 IPython sets this directory by looking for a
1103 \family typewriter
1103 \family typewriter
1104 HOME
1104 HOME
1105 \family default
1105 \family default
1106 environment variable; if such a variable does not exist, it uses
1106 environment variable; if such a variable does not exist, it uses
1107 \family typewriter
1107 \family typewriter
1108 HOMEDRIVE
1108 HOMEDRIVE
1109 \backslash
1109 \backslash
1110 HOMEPATH
1110 HOMEPATH
1111 \family default
1111 \family default
1112 (these are always defined by Windows).
1112 (these are always defined by Windows).
1113 This typically gives something like
1113 This typically gives something like
1114 \family typewriter
1114 \family typewriter
1115 C:
1115 C:
1116 \backslash
1116 \backslash
1117 Documents and Settings
1117 Documents and Settings
1118 \backslash
1118 \backslash
1119 YourUserName
1119 YourUserName
1120 \family default
1120 \family default
1121 , but your local details may vary.
1121 , but your local details may vary.
1122 In this directory you will find all the files that configure IPython's
1122 In this directory you will find all the files that configure IPython's
1123 defaults, and you can put there your profiles and extensions.
1123 defaults, and you can put there your profiles and extensions.
1124 This directory is automatically added by IPython to
1124 This directory is automatically added by IPython to
1125 \family typewriter
1125 \family typewriter
1126 sys.path
1126 sys.path
1127 \family default
1127 \family default
1128 , so anything you place there can be found by
1128 , so anything you place there can be found by
1129 \family typewriter
1129 \family typewriter
1130 import
1130 import
1131 \family default
1131 \family default
1132 statements.
1132 statements.
1133 \layout Paragraph
1133 \layout Paragraph
1134
1134
1135 Upgrading
1135 Upgrading
1136 \layout Standard
1136 \layout Standard
1137
1137
1138 For an IPython upgrade, you should first uninstall the previous version.
1138 For an IPython upgrade, you should first uninstall the previous version.
1139 This will ensure that all files and directories (such as the documentation)
1139 This will ensure that all files and directories (such as the documentation)
1140 which carry embedded version strings in their names are properly removed.
1140 which carry embedded version strings in their names are properly removed.
1141 \layout Paragraph
1141 \layout Paragraph
1142
1142
1143 Manual installation under Win32
1143 Manual installation under Win32
1144 \layout Standard
1144 \layout Standard
1145
1145
1146 In case the automatic installer does not work for some reason, you can download
1146 In case the automatic installer does not work for some reason, you can download
1147 the
1147 the
1148 \family typewriter
1148 \family typewriter
1149 ipython-XXX.tar.gz
1149 ipython-XXX.tar.gz
1150 \family default
1150 \family default
1151 file, which contains the full IPython source distribution (the popular
1151 file, which contains the full IPython source distribution (the popular
1152 WinZip can read
1152 WinZip can read
1153 \family typewriter
1153 \family typewriter
1154 .tar.gz
1154 .tar.gz
1155 \family default
1155 \family default
1156 files).
1156 files).
1157 After uncompressing the archive, you can install it at a command terminal
1157 After uncompressing the archive, you can install it at a command terminal
1158 just like any other Python module, by using
1158 just like any other Python module, by using
1159 \family typewriter
1159 \family typewriter
1160 `python setup.py install'
1160 `python setup.py install'
1161 \family default
1161 \family default
1162 .
1162 .
1163
1163
1164 \layout Standard
1164 \layout Standard
1165
1165
1166 After the installation, run the supplied
1166 After the installation, run the supplied
1167 \family typewriter
1167 \family typewriter
1168 win32_manual_post_install.py
1168 win32_manual_post_install.py
1169 \family default
1169 \family default
1170 script, which creates the necessary Start Menu shortcuts for you.
1170 script, which creates the necessary Start Menu shortcuts for you.
1171 \layout Subsection
1171 \layout Subsection
1172
1172
1173
1173
1174 \begin_inset LatexCommand \label{sec:upgrade}
1174 \begin_inset LatexCommand \label{sec:upgrade}
1175
1175
1176 \end_inset
1176 \end_inset
1177
1177
1178 Upgrading from a previous version
1178 Upgrading from a previous version
1179 \layout Standard
1179 \layout Standard
1180
1180
1181 If you are upgrading from a previous version of IPython, after doing the
1181 If you are upgrading from a previous version of IPython, after doing the
1182 routine installation described above, you should call IPython with the
1182 routine installation described above, you should call IPython with the
1183
1183
1184 \family typewriter
1184 \family typewriter
1185 -upgrade
1185 -upgrade
1186 \family default
1186 \family default
1187 option the first time you run your new copy.
1187 option the first time you run your new copy.
1188 This will automatically update your configuration directory while preserving
1188 This will automatically update your configuration directory while preserving
1189 copies of your old files.
1189 copies of your old files.
1190 You can then later merge back any personal customizations you may have
1190 You can then later merge back any personal customizations you may have
1191 made into the new files.
1191 made into the new files.
1192 It is a good idea to do this as there may be new options available in the
1192 It is a good idea to do this as there may be new options available in the
1193 new configuration files which you will not have.
1193 new configuration files which you will not have.
1194 \layout Standard
1194 \layout Standard
1195
1195
1196 Under Windows, if you don't know how to call python scripts with arguments
1196 Under Windows, if you don't know how to call python scripts with arguments
1197 from a command line, simply delete the old config directory and IPython
1197 from a command line, simply delete the old config directory and IPython
1198 will make a new one.
1198 will make a new one.
1199 Win2k and WinXP users will find it in
1199 Win2k and WinXP users will find it in
1200 \family typewriter
1200 \family typewriter
1201 C:
1201 C:
1202 \backslash
1202 \backslash
1203 Documents and Settings
1203 Documents and Settings
1204 \backslash
1204 \backslash
1205 YourUserName
1205 YourUserName
1206 \backslash
1206 \backslash
1207 _ipython
1207 _ipython
1208 \family default
1208 \family default
1209 , and Win 9x users under
1209 , and Win 9x users under
1210 \family typewriter
1210 \family typewriter
1211 C:
1211 C:
1212 \backslash
1212 \backslash
1213 Program Files
1213 Program Files
1214 \backslash
1214 \backslash
1215 IPython
1215 IPython
1216 \backslash
1216 \backslash
1217 _ipython.
1217 _ipython.
1218 \layout Section
1218 \layout Section
1219
1219
1220
1220
1221 \begin_inset LatexCommand \label{sec:good_config}
1221 \begin_inset LatexCommand \label{sec:good_config}
1222
1222
1223 \end_inset
1223 \end_inset
1224
1224
1225
1225
1226 \begin_inset OptArg
1226 \begin_inset OptArg
1227 collapsed true
1227 collapsed true
1228
1228
1229 \layout Standard
1229 \layout Standard
1230
1230
1231 Initial configuration
1231 Initial configuration
1232 \begin_inset ERT
1232 \begin_inset ERT
1233 status Collapsed
1233 status Collapsed
1234
1234
1235 \layout Standard
1235 \layout Standard
1236
1236
1237 \backslash
1237 \backslash
1238 ldots
1238 ldots
1239 \end_inset
1239 \end_inset
1240
1240
1241
1241
1242 \end_inset
1242 \end_inset
1243
1243
1244 Initial configuration of your environment
1244 Initial configuration of your environment
1245 \layout Standard
1245 \layout Standard
1246
1246
1247 This section will help you set various things in your environment for your
1247 This section will help you set various things in your environment for your
1248 IPython sessions to be as efficient as possible.
1248 IPython sessions to be as efficient as possible.
1249 All of IPython's configuration information, along with several example
1249 All of IPython's configuration information, along with several example
1250 files, is stored in a directory named by default
1250 files, is stored in a directory named by default
1251 \family typewriter
1251 \family typewriter
1252 $HOME/.ipython
1252 $HOME/.ipython
1253 \family default
1253 \family default
1254 .
1254 .
1255 You can change this by defining the environment variable
1255 You can change this by defining the environment variable
1256 \family typewriter
1256 \family typewriter
1257 IPYTHONDIR
1257 IPYTHONDIR
1258 \family default
1258 \family default
1259 , or at runtime with the command line option
1259 , or at runtime with the command line option
1260 \family typewriter
1260 \family typewriter
1261 -ipythondir
1261 -ipythondir
1262 \family default
1262 \family default
1263 .
1263 .
1264 \layout Standard
1264 \layout Standard
1265
1265
1266 If all goes well, the first time you run IPython it should automatically
1266 If all goes well, the first time you run IPython it should automatically
1267 create a user copy of the config directory for you, based on its builtin
1267 create a user copy of the config directory for you, based on its builtin
1268 defaults.
1268 defaults.
1269 You can look at the files it creates to learn more about configuring the
1269 You can look at the files it creates to learn more about configuring the
1270 system.
1270 system.
1271 The main file you will modify to configure IPython's behavior is called
1271 The main file you will modify to configure IPython's behavior is called
1272
1272
1273 \family typewriter
1273 \family typewriter
1274 ipythonrc
1274 ipythonrc
1275 \family default
1275 \family default
1276 (with a
1276 (with a
1277 \family typewriter
1277 \family typewriter
1278 .ini
1278 .ini
1279 \family default
1279 \family default
1280 extension under Windows), included for reference in Sec.
1280 extension under Windows), included for reference in Sec.
1281
1281
1282 \begin_inset LatexCommand \ref{sec:ipytonrc-sample}
1282 \begin_inset LatexCommand \ref{sec:ipytonrc-sample}
1283
1283
1284 \end_inset
1284 \end_inset
1285
1285
1286 .
1286 .
1287 This file is very commented and has many variables you can change to suit
1287 This file is very commented and has many variables you can change to suit
1288 your taste, you can find more details in Sec.
1288 your taste, you can find more details in Sec.
1289
1289
1290 \begin_inset LatexCommand \ref{sec:customization}
1290 \begin_inset LatexCommand \ref{sec:customization}
1291
1291
1292 \end_inset
1292 \end_inset
1293
1293
1294 .
1294 .
1295 Here we discuss the basic things you will want to make sure things are
1295 Here we discuss the basic things you will want to make sure things are
1296 working properly from the beginning.
1296 working properly from the beginning.
1297 \layout Subsection
1297 \layout Subsection
1298
1298
1299
1299
1300 \begin_inset LatexCommand \label{sec:help-access}
1300 \begin_inset LatexCommand \label{sec:help-access}
1301
1301
1302 \end_inset
1302 \end_inset
1303
1303
1304 Access to the Python help system
1304 Access to the Python help system
1305 \layout Standard
1305 \layout Standard
1306
1306
1307 This is true for Python in general (not just for IPython): you should have
1307 This is true for Python in general (not just for IPython): you should have
1308 an environment variable called
1308 an environment variable called
1309 \family typewriter
1309 \family typewriter
1310 PYTHONDOCS
1310 PYTHONDOCS
1311 \family default
1311 \family default
1312 pointing to the directory where your HTML Python documentation lives.
1312 pointing to the directory where your HTML Python documentation lives.
1313 In my system it's
1313 In my system it's
1314 \family typewriter
1314 \family typewriter
1315 /usr/share/doc/python-docs-2.3.4/html
1315 /usr/share/doc/python-docs-2.3.4/html
1316 \family default
1316 \family default
1317 , check your local details or ask your systems administrator.
1317 , check your local details or ask your systems administrator.
1318
1318
1319 \layout Standard
1319 \layout Standard
1320
1320
1321 This is the directory which holds the HTML version of the Python manuals.
1321 This is the directory which holds the HTML version of the Python manuals.
1322 Unfortunately it seems that different Linux distributions package these
1322 Unfortunately it seems that different Linux distributions package these
1323 files differently, so you may have to look around a bit.
1323 files differently, so you may have to look around a bit.
1324 Below I show the contents of this directory on my system for reference:
1324 Below I show the contents of this directory on my system for reference:
1325 \layout Standard
1325 \layout Standard
1326
1326
1327
1327
1328 \family typewriter
1328 \family typewriter
1329 [html]> ls
1329 [html]> ls
1330 \newline
1330 \newline
1331 about.dat acks.html dist/ ext/ index.html lib/ modindex.html stdabout.dat tut/
1331 about.dat acks.html dist/ ext/ index.html lib/ modindex.html stdabout.dat tut/
1332 about.html api/ doc/ icons/ inst/ mac/ ref/ style.css
1332 about.html api/ doc/ icons/ inst/ mac/ ref/ style.css
1333 \layout Standard
1333 \layout Standard
1334
1334
1335 You should really make sure this variable is correctly set so that Python's
1335 You should really make sure this variable is correctly set so that Python's
1336 pydoc-based help system works.
1336 pydoc-based help system works.
1337 It is a powerful and convenient system with full access to the Python manuals
1337 It is a powerful and convenient system with full access to the Python manuals
1338 and all modules accessible to you.
1338 and all modules accessible to you.
1339 \layout Standard
1339 \layout Standard
1340
1340
1341 Under Windows it seems that pydoc finds the documentation automatically,
1341 Under Windows it seems that pydoc finds the documentation automatically,
1342 so no extra setup appears necessary.
1342 so no extra setup appears necessary.
1343 \layout Subsection
1343 \layout Subsection
1344
1344
1345 Editor
1345 Editor
1346 \layout Standard
1346 \layout Standard
1347
1347
1348 The
1348 The
1349 \family typewriter
1349 \family typewriter
1350 %edit
1350 %edit
1351 \family default
1351 \family default
1352 command (and its alias
1352 command (and its alias
1353 \family typewriter
1353 \family typewriter
1354 %ed
1354 %ed
1355 \family default
1355 \family default
1356 ) will invoke the editor set in your environment as
1356 ) will invoke the editor set in your environment as
1357 \family typewriter
1357 \family typewriter
1358 EDITOR
1358 EDITOR
1359 \family default
1359 \family default
1360 .
1360 .
1361 If this variable is not set, it will default to
1361 If this variable is not set, it will default to
1362 \family typewriter
1362 \family typewriter
1363 vi
1363 vi
1364 \family default
1364 \family default
1365 under Linux/Unix and to
1365 under Linux/Unix and to
1366 \family typewriter
1366 \family typewriter
1367 notepad
1367 notepad
1368 \family default
1368 \family default
1369 under Windows.
1369 under Windows.
1370 You may want to set this variable properly and to a lightweight editor
1370 You may want to set this variable properly and to a lightweight editor
1371 which doesn't take too long to start (that is, something other than a new
1371 which doesn't take too long to start (that is, something other than a new
1372 instance of
1372 instance of
1373 \family typewriter
1373 \family typewriter
1374 Emacs
1374 Emacs
1375 \family default
1375 \family default
1376 ).
1376 ).
1377 This way you can edit multi-line code quickly and with the power of a real
1377 This way you can edit multi-line code quickly and with the power of a real
1378 editor right inside IPython.
1378 editor right inside IPython.
1379
1379
1380 \layout Standard
1380 \layout Standard
1381
1381
1382 If you are a dedicated
1382 If you are a dedicated
1383 \family typewriter
1383 \family typewriter
1384 Emacs
1384 Emacs
1385 \family default
1385 \family default
1386 user, you should set up the
1386 user, you should set up the
1387 \family typewriter
1387 \family typewriter
1388 Emacs
1388 Emacs
1389 \family default
1389 \family default
1390 server so that new requests are handled by the original process.
1390 server so that new requests are handled by the original process.
1391 This means that almost no time is spent in handling the request (assuming
1391 This means that almost no time is spent in handling the request (assuming
1392 an
1392 an
1393 \family typewriter
1393 \family typewriter
1394 Emacs
1394 Emacs
1395 \family default
1395 \family default
1396 process is already running).
1396 process is already running).
1397 For this to work, you need to set your
1397 For this to work, you need to set your
1398 \family typewriter
1398 \family typewriter
1399 EDITOR
1399 EDITOR
1400 \family default
1400 \family default
1401 environment variable to
1401 environment variable to
1402 \family typewriter
1402 \family typewriter
1403 'emacsclient'
1403 'emacsclient'
1404 \family default
1404 \family default
1405 .
1405 .
1406
1406
1407 \family typewriter
1407 \family typewriter
1408
1408
1409 \family default
1409 \family default
1410 The code below, supplied by Francois Pinard, can then be used in your
1410 The code below, supplied by Francois Pinard, can then be used in your
1411 \family typewriter
1411 \family typewriter
1412 .emacs
1412 .emacs
1413 \family default
1413 \family default
1414 file to enable the server:
1414 file to enable the server:
1415 \layout Standard
1415 \layout Standard
1416
1416
1417
1417
1418 \family typewriter
1418 \family typewriter
1419 (defvar server-buffer-clients)
1419 (defvar server-buffer-clients)
1420 \newline
1420 \newline
1421 (when (and (fboundp 'server-start) (string-equal (getenv "TERM") 'xterm))
1421 (when (and (fboundp 'server-start) (string-equal (getenv "TERM") 'xterm))
1422 \newline
1422 \newline
1423
1423
1424 \begin_inset ERT
1424 \begin_inset ERT
1425 status Collapsed
1425 status Collapsed
1426
1426
1427 \layout Standard
1427 \layout Standard
1428
1428
1429 \backslash
1429 \backslash
1430 hspace*{0mm}
1430 hspace*{0mm}
1431 \end_inset
1431 \end_inset
1432
1432
1433 \SpecialChar ~
1433 \SpecialChar ~
1434 \SpecialChar ~
1434 \SpecialChar ~
1435 (server-start)
1435 (server-start)
1436 \newline
1436 \newline
1437
1437
1438 \begin_inset ERT
1438 \begin_inset ERT
1439 status Collapsed
1439 status Collapsed
1440
1440
1441 \layout Standard
1441 \layout Standard
1442
1442
1443 \backslash
1443 \backslash
1444 hspace*{0mm}
1444 hspace*{0mm}
1445 \end_inset
1445 \end_inset
1446
1446
1447 \SpecialChar ~
1447 \SpecialChar ~
1448 \SpecialChar ~
1448 \SpecialChar ~
1449 (defun fp-kill-server-with-buffer-routine ()
1449 (defun fp-kill-server-with-buffer-routine ()
1450 \newline
1450 \newline
1451
1451
1452 \begin_inset ERT
1452 \begin_inset ERT
1453 status Collapsed
1453 status Collapsed
1454
1454
1455 \layout Standard
1455 \layout Standard
1456
1456
1457 \backslash
1457 \backslash
1458 hspace*{0mm}
1458 hspace*{0mm}
1459 \end_inset
1459 \end_inset
1460
1460
1461 \SpecialChar ~
1461 \SpecialChar ~
1462 \SpecialChar ~
1462 \SpecialChar ~
1463 \SpecialChar ~
1463 \SpecialChar ~
1464 \SpecialChar ~
1464 \SpecialChar ~
1465 (and server-buffer-clients (server-done)))
1465 (and server-buffer-clients (server-done)))
1466 \newline
1466 \newline
1467
1467
1468 \begin_inset ERT
1468 \begin_inset ERT
1469 status Collapsed
1469 status Collapsed
1470
1470
1471 \layout Standard
1471 \layout Standard
1472
1472
1473 \backslash
1473 \backslash
1474 hspace*{0mm}
1474 hspace*{0mm}
1475 \end_inset
1475 \end_inset
1476
1476
1477 \SpecialChar ~
1477 \SpecialChar ~
1478 \SpecialChar ~
1478 \SpecialChar ~
1479 (add-hook 'kill-buffer-hook 'fp-kill-server-with-buffer-routine))
1479 (add-hook 'kill-buffer-hook 'fp-kill-server-with-buffer-routine))
1480 \layout Standard
1480 \layout Standard
1481
1481
1482 You can also set the value of this editor via the commmand-line option '-
1482 You can also set the value of this editor via the commmand-line option '-
1483 \family typewriter
1483 \family typewriter
1484 editor'
1484 editor'
1485 \family default
1485 \family default
1486 or in your
1486 or in your
1487 \family typewriter
1487 \family typewriter
1488 ipythonrc
1488 ipythonrc
1489 \family default
1489 \family default
1490 file.
1490 file.
1491 This is useful if you wish to use specifically for IPython an editor different
1491 This is useful if you wish to use specifically for IPython an editor different
1492 from your typical default (and for Windows users who tend to use fewer
1492 from your typical default (and for Windows users who tend to use fewer
1493 environment variables).
1493 environment variables).
1494 \layout Subsection
1494 \layout Subsection
1495
1495
1496 Color
1496 Color
1497 \layout Standard
1497 \layout Standard
1498
1498
1499 The default IPython configuration has most bells and whistles turned on
1499 The default IPython configuration has most bells and whistles turned on
1500 (they're pretty safe).
1500 (they're pretty safe).
1501 But there's one that
1501 But there's one that
1502 \emph on
1502 \emph on
1503 may
1503 may
1504 \emph default
1504 \emph default
1505 cause problems on some systems: the use of color on screen for displaying
1505 cause problems on some systems: the use of color on screen for displaying
1506 information.
1506 information.
1507 This is very useful, since IPython can show prompts and exception tracebacks
1507 This is very useful, since IPython can show prompts and exception tracebacks
1508 with various colors, display syntax-highlighted source code, and in general
1508 with various colors, display syntax-highlighted source code, and in general
1509 make it easier to visually parse information.
1509 make it easier to visually parse information.
1510 \layout Standard
1510 \layout Standard
1511
1511
1512 The following terminals seem to handle the color sequences fine:
1512 The following terminals seem to handle the color sequences fine:
1513 \layout Itemize
1513 \layout Itemize
1514
1514
1515 Linux main text console, KDE Konsole, Gnome Terminal, E-term, rxvt, xterm.
1515 Linux main text console, KDE Konsole, Gnome Terminal, E-term, rxvt, xterm.
1516 \layout Itemize
1516 \layout Itemize
1517
1517
1518 CDE terminal (tested under Solaris).
1518 CDE terminal (tested under Solaris).
1519 This one boldfaces light colors.
1519 This one boldfaces light colors.
1520 \layout Itemize
1520 \layout Itemize
1521
1521
1522 (X)Emacs buffers.
1522 (X)Emacs buffers.
1523 See sec.
1523 See sec.
1524 \begin_inset LatexCommand \ref{sec:emacs}
1524 \begin_inset LatexCommand \ref{sec:emacs}
1525
1525
1526 \end_inset
1526 \end_inset
1527
1527
1528 for more details on using IPython with (X)Emacs.
1528 for more details on using IPython with (X)Emacs.
1529 \layout Itemize
1529 \layout Itemize
1530
1530
1531 A Windows (XP/2k) command prompt
1531 A Windows (XP/2k) command prompt
1532 \emph on
1532 \emph on
1533 with Gary Bishop's support extensions
1533 with Gary Bishop's support extensions
1534 \emph default
1534 \emph default
1535 .
1535 .
1536 Gary's extensions are discussed in Sec.\SpecialChar ~
1536 Gary's extensions are discussed in Sec.\SpecialChar ~
1537
1537
1538 \begin_inset LatexCommand \ref{sub:Under-Windows}
1538 \begin_inset LatexCommand \ref{sub:Under-Windows}
1539
1539
1540 \end_inset
1540 \end_inset
1541
1541
1542 .
1542 .
1543 \layout Itemize
1543 \layout Itemize
1544
1544
1545 A Windows (XP/2k) CygWin shell.
1545 A Windows (XP/2k) CygWin shell.
1546 Although some users have reported problems; it is not clear whether there
1546 Although some users have reported problems; it is not clear whether there
1547 is an issue for everyone or only under specific configurations.
1547 is an issue for everyone or only under specific configurations.
1548 If you have full color support under cygwin, please post to the IPython
1548 If you have full color support under cygwin, please post to the IPython
1549 mailing list so this issue can be resolved for all users.
1549 mailing list so this issue can be resolved for all users.
1550 \layout Standard
1550 \layout Standard
1551
1551
1552 These have shown problems:
1552 These have shown problems:
1553 \layout Itemize
1553 \layout Itemize
1554
1554
1555 Windows command prompt in WinXP/2k logged into a Linux machine via telnet
1555 Windows command prompt in WinXP/2k logged into a Linux machine via telnet
1556 or ssh.
1556 or ssh.
1557 \layout Itemize
1557 \layout Itemize
1558
1558
1559 Windows native command prompt in WinXP/2k,
1559 Windows native command prompt in WinXP/2k,
1560 \emph on
1560 \emph on
1561 without
1561 without
1562 \emph default
1562 \emph default
1563 Gary Bishop's extensions.
1563 Gary Bishop's extensions.
1564 Once Gary's readline library is installed, the normal WinXP/2k command
1564 Once Gary's readline library is installed, the normal WinXP/2k command
1565 prompt works perfectly.
1565 prompt works perfectly.
1566 \layout Standard
1566 \layout Standard
1567
1567
1568 Currently the following color schemes are available:
1568 Currently the following color schemes are available:
1569 \layout Itemize
1569 \layout Itemize
1570
1570
1571
1571
1572 \family typewriter
1572 \family typewriter
1573 NoColor
1573 NoColor
1574 \family default
1574 \family default
1575 : uses no color escapes at all (all escapes are empty
1575 : uses no color escapes at all (all escapes are empty
1576 \begin_inset Quotes eld
1576 \begin_inset Quotes eld
1577 \end_inset
1577 \end_inset
1578
1578
1579
1579
1580 \begin_inset Quotes eld
1580 \begin_inset Quotes eld
1581 \end_inset
1581 \end_inset
1582
1582
1583 strings).
1583 strings).
1584 This 'scheme' is thus fully safe to use in any terminal.
1584 This 'scheme' is thus fully safe to use in any terminal.
1585 \layout Itemize
1585 \layout Itemize
1586
1586
1587
1587
1588 \family typewriter
1588 \family typewriter
1589 Linux
1589 Linux
1590 \family default
1590 \family default
1591 : works well in Linux console type environments: dark background with light
1591 : works well in Linux console type environments: dark background with light
1592 fonts.
1592 fonts.
1593 It uses bright colors for information, so it is difficult to read if you
1593 It uses bright colors for information, so it is difficult to read if you
1594 have a light colored background.
1594 have a light colored background.
1595 \layout Itemize
1595 \layout Itemize
1596
1596
1597
1597
1598 \family typewriter
1598 \family typewriter
1599 LightBG
1599 LightBG
1600 \family default
1600 \family default
1601 : the basic colors are similar to those in the
1601 : the basic colors are similar to those in the
1602 \family typewriter
1602 \family typewriter
1603 Linux
1603 Linux
1604 \family default
1604 \family default
1605 scheme but darker.
1605 scheme but darker.
1606 It is easy to read in terminals with light backgrounds.
1606 It is easy to read in terminals with light backgrounds.
1607 \layout Standard
1607 \layout Standard
1608
1608
1609 IPython uses colors for two main groups of things: prompts and tracebacks
1609 IPython uses colors for two main groups of things: prompts and tracebacks
1610 which are directly printed to the terminal, and the object introspection
1610 which are directly printed to the terminal, and the object introspection
1611 system which passes large sets of data through a pager.
1611 system which passes large sets of data through a pager.
1612 \layout Subsubsection
1612 \layout Subsubsection
1613
1613
1614 Input/Output prompts and exception tracebacks
1614 Input/Output prompts and exception tracebacks
1615 \layout Standard
1615 \layout Standard
1616
1616
1617 You can test whether the colored prompts and tracebacks work on your system
1617 You can test whether the colored prompts and tracebacks work on your system
1618 interactively by typing
1618 interactively by typing
1619 \family typewriter
1619 \family typewriter
1620 '%colors Linux'
1620 '%colors Linux'
1621 \family default
1621 \family default
1622 at the prompt (use '
1622 at the prompt (use '
1623 \family typewriter
1623 \family typewriter
1624 %colors LightBG'
1624 %colors LightBG'
1625 \family default
1625 \family default
1626 if your terminal has a light background).
1626 if your terminal has a light background).
1627 If the input prompt shows garbage like:
1627 If the input prompt shows garbage like:
1628 \newline
1628 \newline
1629
1629
1630 \family typewriter
1630 \family typewriter
1631 [0;32mIn [[1;32m1[0;32m]: [0;00m
1631 [0;32mIn [[1;32m1[0;32m]: [0;00m
1632 \family default
1632 \family default
1633
1633
1634 \newline
1634 \newline
1635 instead of (in color) something like:
1635 instead of (in color) something like:
1636 \newline
1636 \newline
1637
1637
1638 \family typewriter
1638 \family typewriter
1639 In [1]:
1639 In [1]:
1640 \family default
1640 \family default
1641
1641
1642 \newline
1642 \newline
1643 this means that your terminal doesn't properly handle color escape sequences.
1643 this means that your terminal doesn't properly handle color escape sequences.
1644 You can go to a 'no color' mode by typing '
1644 You can go to a 'no color' mode by typing '
1645 \family typewriter
1645 \family typewriter
1646 %colors NoColor
1646 %colors NoColor
1647 \family default
1647 \family default
1648 '.
1648 '.
1649
1649
1650 \layout Standard
1650 \layout Standard
1651
1651
1652 You can try using a different terminal emulator program.
1652 You can try using a different terminal emulator program.
1653 To permanently set your color preferences, edit the file
1653 To permanently set your color preferences, edit the file
1654 \family typewriter
1654 \family typewriter
1655 $HOME/.ipython/ipythonrc
1655 $HOME/.ipython/ipythonrc
1656 \family default
1656 \family default
1657 and set the
1657 and set the
1658 \family typewriter
1658 \family typewriter
1659 colors
1659 colors
1660 \family default
1660 \family default
1661 option to the desired value.
1661 option to the desired value.
1662 \layout Subsubsection
1662 \layout Subsubsection
1663
1663
1664 Object details (types, docstrings, source code, etc.)
1664 Object details (types, docstrings, source code, etc.)
1665 \layout Standard
1665 \layout Standard
1666
1666
1667 IPython has a set of special functions for studying the objects you are
1667 IPython has a set of special functions for studying the objects you are
1668 working with, discussed in detail in Sec.
1668 working with, discussed in detail in Sec.
1669
1669
1670 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1670 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1671
1671
1672 \end_inset
1672 \end_inset
1673
1673
1674 .
1674 .
1675 But this system relies on passing information which is longer than your
1675 But this system relies on passing information which is longer than your
1676 screen through a data pager, such as the common Unix
1676 screen through a data pager, such as the common Unix
1677 \family typewriter
1677 \family typewriter
1678 less
1678 less
1679 \family default
1679 \family default
1680 and
1680 and
1681 \family typewriter
1681 \family typewriter
1682 more
1682 more
1683 \family default
1683 \family default
1684 programs.
1684 programs.
1685 In order to be able to see this information in color, your pager needs
1685 In order to be able to see this information in color, your pager needs
1686 to be properly configured.
1686 to be properly configured.
1687 I strongly recommend using
1687 I strongly recommend using
1688 \family typewriter
1688 \family typewriter
1689 less
1689 less
1690 \family default
1690 \family default
1691 instead of
1691 instead of
1692 \family typewriter
1692 \family typewriter
1693 more
1693 more
1694 \family default
1694 \family default
1695 , as it seems that
1695 , as it seems that
1696 \family typewriter
1696 \family typewriter
1697 more
1697 more
1698 \family default
1698 \family default
1699 simply can not understand colored text correctly.
1699 simply can not understand colored text correctly.
1700 \layout Standard
1700 \layout Standard
1701
1701
1702 In order to configure
1702 In order to configure
1703 \family typewriter
1703 \family typewriter
1704 less
1704 less
1705 \family default
1705 \family default
1706 as your default pager, do the following:
1706 as your default pager, do the following:
1707 \layout Enumerate
1707 \layout Enumerate
1708
1708
1709 Set the environment
1709 Set the environment
1710 \family typewriter
1710 \family typewriter
1711 PAGER
1711 PAGER
1712 \family default
1712 \family default
1713 variable to
1713 variable to
1714 \family typewriter
1714 \family typewriter
1715 less
1715 less
1716 \family default
1716 \family default
1717 .
1717 .
1718 \layout Enumerate
1718 \layout Enumerate
1719
1719
1720 Set the environment
1720 Set the environment
1721 \family typewriter
1721 \family typewriter
1722 LESS
1722 LESS
1723 \family default
1723 \family default
1724 variable to
1724 variable to
1725 \family typewriter
1725 \family typewriter
1726 -r
1726 -r
1727 \family default
1727 \family default
1728 (plus any other options you always want to pass to
1728 (plus any other options you always want to pass to
1729 \family typewriter
1729 \family typewriter
1730 less
1730 less
1731 \family default
1731 \family default
1732 by default).
1732 by default).
1733 This tells
1733 This tells
1734 \family typewriter
1734 \family typewriter
1735 less
1735 less
1736 \family default
1736 \family default
1737 to properly interpret control sequences, which is how color information
1737 to properly interpret control sequences, which is how color information
1738 is given to your terminal.
1738 is given to your terminal.
1739 \layout Standard
1739 \layout Standard
1740
1740
1741 For the
1741 For the
1742 \family typewriter
1742 \family typewriter
1743 csh
1743 csh
1744 \family default
1744 \family default
1745 or
1745 or
1746 \family typewriter
1746 \family typewriter
1747 tcsh
1747 tcsh
1748 \family default
1748 \family default
1749 shells, add to your
1749 shells, add to your
1750 \family typewriter
1750 \family typewriter
1751 ~/.cshrc
1751 ~/.cshrc
1752 \family default
1752 \family default
1753 file the lines:
1753 file the lines:
1754 \layout Standard
1754 \layout Standard
1755
1755
1756
1756
1757 \family typewriter
1757 \family typewriter
1758 setenv PAGER less
1758 setenv PAGER less
1759 \newline
1759 \newline
1760 setenv LESS -r
1760 setenv LESS -r
1761 \layout Standard
1761 \layout Standard
1762
1762
1763 There is similar syntax for other Unix shells, look at your system documentation
1763 There is similar syntax for other Unix shells, look at your system documentation
1764 for details.
1764 for details.
1765 \layout Standard
1765 \layout Standard
1766
1766
1767 If you are on a system which lacks proper data pagers (such as Windows),
1767 If you are on a system which lacks proper data pagers (such as Windows),
1768 IPython will use a very limited builtin pager.
1768 IPython will use a very limited builtin pager.
1769 \layout Subsection
1769 \layout Subsection
1770
1770
1771
1771
1772 \begin_inset LatexCommand \label{sec:emacs}
1772 \begin_inset LatexCommand \label{sec:emacs}
1773
1773
1774 \end_inset
1774 \end_inset
1775
1775
1776 (X)Emacs configuration
1776 (X)Emacs configuration
1777 \layout Standard
1777 \layout Standard
1778
1778
1779 Thanks to the work of Alexander Schmolck and Prabhu Ramachandran, currently
1779 Thanks to the work of Alexander Schmolck and Prabhu Ramachandran, currently
1780 (X)Emacs and IPython get along very well.
1780 (X)Emacs and IPython get along very well.
1781
1781
1782 \layout Standard
1782 \layout Standard
1783
1783
1784
1784
1785 \series bold
1785 \series bold
1786 Important note:
1786 Important note:
1787 \series default
1787 \series default
1788 You will need to use a recent enough version of
1788 You will need to use a recent enough version of
1789 \family typewriter
1789 \family typewriter
1790 python-mode.el
1790 python-mode.el
1791 \family default
1791 \family default
1792 , along with the file
1792 , along with the file
1793 \family typewriter
1793 \family typewriter
1794 ipython.el
1794 ipython.el
1795 \family default
1795 \family default
1796 .
1796 .
1797 You can check that the version you have of
1797 You can check that the version you have of
1798 \family typewriter
1798 \family typewriter
1799 python-mode.el
1799 python-mode.el
1800 \family default
1800 \family default
1801 is new enough by either looking at the revision number in the file itself,
1801 is new enough by either looking at the revision number in the file itself,
1802 or asking for it in (X)Emacs via
1802 or asking for it in (X)Emacs via
1803 \family typewriter
1803 \family typewriter
1804 M-x py-version
1804 M-x py-version
1805 \family default
1805 \family default
1806 .
1806 .
1807 Versions 4.68 and newer contain the necessary fixes for proper IPython support.
1807 Versions 4.68 and newer contain the necessary fixes for proper IPython support.
1808 \layout Standard
1808 \layout Standard
1809
1809
1810 The file
1810 The file
1811 \family typewriter
1811 \family typewriter
1812 ipython.el
1812 ipython.el
1813 \family default
1813 \family default
1814 is included with the IPython distribution, in the documentation directory
1814 is included with the IPython distribution, in the documentation directory
1815 (where this manual resides in PDF and HTML formats).
1815 (where this manual resides in PDF and HTML formats).
1816 \layout Standard
1816 \layout Standard
1817
1817
1818 Once you put these files in your Emacs path, all you need in your
1818 Once you put these files in your Emacs path, all you need in your
1819 \family typewriter
1819 \family typewriter
1820 .emacs
1820 .emacs
1821 \family default
1821 \family default
1822 file is:
1822 file is:
1823 \layout Standard
1823 \layout Standard
1824
1824
1825
1825
1826 \family typewriter
1826 \family typewriter
1827 (require 'ipython)
1827 (require 'ipython)
1828 \layout Standard
1828 \layout Standard
1829
1829
1830 This should give you full support for executing code snippets via IPython,
1830 This should give you full support for executing code snippets via IPython,
1831 opening IPython as your Python shell via
1831 opening IPython as your Python shell via
1832 \family typewriter
1832 \family typewriter
1833 C-c\SpecialChar ~
1833 C-c\SpecialChar ~
1834 !
1834 !
1835 \family default
1835 \family default
1836 , etc.
1836 , etc.
1837
1837
1838 \layout Subsubsection*
1838 \layout Subsubsection*
1839
1839
1840 Notes
1840 Notes
1841 \layout Itemize
1841 \layout Itemize
1842
1842
1843 There is one caveat you should be aware of: you must start the IPython shell
1843 There is one caveat you should be aware of: you must start the IPython shell
1844
1844
1845 \emph on
1845 \emph on
1846 before
1846 before
1847 \emph default
1847 \emph default
1848 attempting to execute any code regions via
1848 attempting to execute any code regions via
1849 \family typewriter
1849 \family typewriter
1850 C-c\SpecialChar ~
1850 C-c\SpecialChar ~
1851 |
1851 |
1852 \family default
1852 \family default
1853 .
1853 .
1854 Simply type
1854 Simply type
1855 \family typewriter
1855 \family typewriter
1856 C-c\SpecialChar ~
1856 C-c\SpecialChar ~
1857 !
1857 !
1858 \family default
1858 \family default
1859 to start IPython before passing any code regions to the interpreter, and
1859 to start IPython before passing any code regions to the interpreter, and
1860 you shouldn't experience any problems.
1860 you shouldn't experience any problems.
1861 \newline
1861 \newline
1862 This is due to a bug in Python itself, which has been fixed for Python 2.3,
1862 This is due to a bug in Python itself, which has been fixed for Python 2.3,
1863 but exists as of Python 2.2.2 (reported as SF bug [ 737947 ]).
1863 but exists as of Python 2.2.2 (reported as SF bug [ 737947 ]).
1864 \layout Itemize
1864 \layout Itemize
1865
1865
1866 The (X)Emacs support is maintained by Alexander Schmolck, so all comments/reques
1866 The (X)Emacs support is maintained by Alexander Schmolck, so all comments/reques
1867 ts should be directed to him through the IPython mailing lists.
1867 ts should be directed to him through the IPython mailing lists.
1868
1868
1869 \layout Itemize
1869 \layout Itemize
1870
1870
1871 This code is still somewhat experimental so it's a bit rough around the
1871 This code is still somewhat experimental so it's a bit rough around the
1872 edges (although in practice, it works quite well).
1872 edges (although in practice, it works quite well).
1873 \layout Itemize
1873 \layout Itemize
1874
1874
1875 Be aware that if you customize
1875 Be aware that if you customize
1876 \family typewriter
1876 \family typewriter
1877 py-python-command
1877 py-python-command
1878 \family default
1878 \family default
1879 previously, this value will override what
1879 previously, this value will override what
1880 \family typewriter
1880 \family typewriter
1881 ipython.el
1881 ipython.el
1882 \family default
1882 \family default
1883 does (because loading the customization variables comes later).
1883 does (because loading the customization variables comes later).
1884 \layout Section
1884 \layout Section
1885
1885
1886
1886
1887 \begin_inset LatexCommand \label{sec:quick_tips}
1887 \begin_inset LatexCommand \label{sec:quick_tips}
1888
1888
1889 \end_inset
1889 \end_inset
1890
1890
1891 Quick tips
1891 Quick tips
1892 \layout Standard
1892 \layout Standard
1893
1893
1894 IPython can be used as an improved replacement for the Python prompt, and
1894 IPython can be used as an improved replacement for the Python prompt, and
1895 for that you don't really need to read any more of this manual.
1895 for that you don't really need to read any more of this manual.
1896 But in this section we'll try to summarize a few tips on how to make the
1896 But in this section we'll try to summarize a few tips on how to make the
1897 most effective use of it for everyday Python development, highlighting
1897 most effective use of it for everyday Python development, highlighting
1898 things you might miss in the rest of the manual (which is getting long).
1898 things you might miss in the rest of the manual (which is getting long).
1899 We'll give references to parts in the manual which provide more detail
1899 We'll give references to parts in the manual which provide more detail
1900 when appropriate.
1900 when appropriate.
1901 \layout Standard
1901 \layout Standard
1902
1902
1903 The following article by Jeremy Jones provides an introductory tutorial
1903 The following article by Jeremy Jones provides an introductory tutorial
1904 about IPython:
1904 about IPython:
1905 \newline
1905 \newline
1906
1906
1907 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2005/01/27/ipython.html}
1907 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2005/01/27/ipython.html}
1908
1908
1909 \end_inset
1909 \end_inset
1910
1910
1911
1911
1912 \layout Itemize
1912 \layout Itemize
1913
1913
1914 The TAB key.
1914 The TAB key.
1915 TAB-completion, especially for attributes, is a convenient way to explore
1915 TAB-completion, especially for attributes, is a convenient way to explore
1916 the structure of any object you're dealing with.
1916 the structure of any object you're dealing with.
1917 Simply type
1917 Simply type
1918 \family typewriter
1918 \family typewriter
1919 object_name.<TAB>
1919 object_name.<TAB>
1920 \family default
1920 \family default
1921 and a list of the object's attributes will be printed (see sec.
1921 and a list of the object's attributes will be printed (see sec.
1922
1922
1923 \begin_inset LatexCommand \ref{sec:readline}
1923 \begin_inset LatexCommand \ref{sec:readline}
1924
1924
1925 \end_inset
1925 \end_inset
1926
1926
1927 for more).
1927 for more).
1928 Tab completion also works on file and directory names, which combined with
1928 Tab completion also works on file and directory names, which combined with
1929 IPython's alias system allows you to do from within IPython many of the
1929 IPython's alias system allows you to do from within IPython many of the
1930 things you normally would need the system shell for.
1930 things you normally would need the system shell for.
1931
1931
1932 \layout Itemize
1932 \layout Itemize
1933
1933
1934 Explore your objects.
1934 Explore your objects.
1935 Typing
1935 Typing
1936 \family typewriter
1936 \family typewriter
1937 object_name?
1937 object_name?
1938 \family default
1938 \family default
1939 will print all sorts of details about any object, including docstrings,
1939 will print all sorts of details about any object, including docstrings,
1940 function definition lines (for call arguments) and constructor details
1940 function definition lines (for call arguments) and constructor details
1941 for classes.
1941 for classes.
1942 The magic commands
1942 The magic commands
1943 \family typewriter
1943 \family typewriter
1944 %pdoc
1944 %pdoc
1945 \family default
1945 \family default
1946 ,
1946 ,
1947 \family typewriter
1947 \family typewriter
1948 %pdef
1948 %pdef
1949 \family default
1949 \family default
1950 ,
1950 ,
1951 \family typewriter
1951 \family typewriter
1952 %psource
1952 %psource
1953 \family default
1953 \family default
1954 and
1954 and
1955 \family typewriter
1955 \family typewriter
1956 %pfile
1956 %pfile
1957 \family default
1957 \family default
1958 will respectively print the docstring, function definition line, full source
1958 will respectively print the docstring, function definition line, full source
1959 code and the complete file for any object (when they can be found).
1959 code and the complete file for any object (when they can be found).
1960 If automagic is on (it is by default), you don't need to type the '
1960 If automagic is on (it is by default), you don't need to type the '
1961 \family typewriter
1961 \family typewriter
1962 %
1962 %
1963 \family default
1963 \family default
1964 ' explicitly.
1964 ' explicitly.
1965 See sec.
1965 See sec.
1966
1966
1967 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1967 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1968
1968
1969 \end_inset
1969 \end_inset
1970
1970
1971 for more.
1971 for more.
1972 \layout Itemize
1972 \layout Itemize
1973
1973
1974 The
1974 The
1975 \family typewriter
1975 \family typewriter
1976 %run
1976 %run
1977 \family default
1977 \family default
1978 magic command allows you to run any python script and load all of its data
1978 magic command allows you to run any python script and load all of its data
1979 directly into the interactive namespace.
1979 directly into the interactive namespace.
1980 Since the file is re-read from disk each time, changes you make to it are
1980 Since the file is re-read from disk each time, changes you make to it are
1981 reflected immediately (in contrast to the behavior of
1981 reflected immediately (in contrast to the behavior of
1982 \family typewriter
1982 \family typewriter
1983 import
1983 import
1984 \family default
1984 \family default
1985 ).
1985 ).
1986 I rarely use
1986 I rarely use
1987 \family typewriter
1987 \family typewriter
1988 import
1988 import
1989 \family default
1989 \family default
1990 for code I am testing, relying on
1990 for code I am testing, relying on
1991 \family typewriter
1991 \family typewriter
1992 %run
1992 %run
1993 \family default
1993 \family default
1994 instead.
1994 instead.
1995 See sec.
1995 See sec.
1996
1996
1997 \begin_inset LatexCommand \ref{sec:magic}
1997 \begin_inset LatexCommand \ref{sec:magic}
1998
1998
1999 \end_inset
1999 \end_inset
2000
2000
2001 for more on this and other magic commands, or type the name of any magic
2001 for more on this and other magic commands, or type the name of any magic
2002 command and ? to get details on it.
2002 command and ? to get details on it.
2003 See also sec.
2003 See also sec.
2004
2004
2005 \begin_inset LatexCommand \ref{sec:dreload}
2005 \begin_inset LatexCommand \ref{sec:dreload}
2006
2006
2007 \end_inset
2007 \end_inset
2008
2008
2009 for a recursive reload command.
2009 for a recursive reload command.
2010 \newline
2010 \newline
2011
2011
2012 \family typewriter
2012 \family typewriter
2013 %run
2013 %run
2014 \family default
2014 \family default
2015 also has special flags for timing the execution of your scripts (
2015 also has special flags for timing the execution of your scripts (
2016 \family typewriter
2016 \family typewriter
2017 -t
2017 -t
2018 \family default
2018 \family default
2019 ) and for executing them under the control of either Python's
2019 ) and for executing them under the control of either Python's
2020 \family typewriter
2020 \family typewriter
2021 pdb
2021 pdb
2022 \family default
2022 \family default
2023 debugger (
2023 debugger (
2024 \family typewriter
2024 \family typewriter
2025 -d
2025 -d
2026 \family default
2026 \family default
2027 ) or profiler (
2027 ) or profiler (
2028 \family typewriter
2028 \family typewriter
2029 -p
2029 -p
2030 \family default
2030 \family default
2031 ).
2031 ).
2032 With all of these,
2032 With all of these,
2033 \family typewriter
2033 \family typewriter
2034 %run
2034 %run
2035 \family default
2035 \family default
2036 can be used as the main tool for efficient interactive development of code
2036 can be used as the main tool for efficient interactive development of code
2037 which you write in your editor of choice.
2037 which you write in your editor of choice.
2038 \layout Itemize
2038 \layout Itemize
2039
2039
2040 Use the Python debugger,
2040 Use the Python debugger,
2041 \family typewriter
2041 \family typewriter
2042 pdb
2042 pdb
2043 \family default
2043 \family default
2044
2044
2045 \begin_inset Foot
2045 \begin_inset Foot
2046 collapsed true
2046 collapsed true
2047
2047
2048 \layout Standard
2048 \layout Standard
2049
2049
2050 Thanks to Christian Hart and Matthew Arnison for the suggestions leading
2050 Thanks to Christian Hart and Matthew Arnison for the suggestions leading
2051 to IPython's improved debugger and profiler support.
2051 to IPython's improved debugger and profiler support.
2052 \end_inset
2052 \end_inset
2053
2053
2054 .
2054 .
2055 The
2055 The
2056 \family typewriter
2056 \family typewriter
2057 %pdb
2057 %pdb
2058 \family default
2058 \family default
2059 command allows you to toggle on and off the automatic invocation of an
2059 command allows you to toggle on and off the automatic invocation of an
2060 IPython-enhanced
2060 IPython-enhanced
2061 \family typewriter
2061 \family typewriter
2062 pdb
2062 pdb
2063 \family default
2063 \family default
2064 debugger (with coloring, tab completion and more) at any uncaught exception.
2064 debugger (with coloring, tab completion and more) at any uncaught exception.
2065 The advantage of this is that
2065 The advantage of this is that
2066 \family typewriter
2066 \family typewriter
2067 pdb
2067 pdb
2068 \family default
2068 \family default
2069 starts
2069 starts
2070 \emph on
2070 \emph on
2071 inside
2071 inside
2072 \emph default
2072 \emph default
2073 the function where the exception occurred, with all data still available.
2073 the function where the exception occurred, with all data still available.
2074 You can print variables, see code, execute statements and even walk up
2074 You can print variables, see code, execute statements and even walk up
2075 and down the call stack to track down the true source of the problem (which
2075 and down the call stack to track down the true source of the problem (which
2076 often is many layers in the stack above where the exception gets triggered).
2076 often is many layers in the stack above where the exception gets triggered).
2077 \newline
2077 \newline
2078 Running programs with
2078 Running programs with
2079 \family typewriter
2079 \family typewriter
2080 %run
2080 %run
2081 \family default
2081 \family default
2082 and pdb active can be an efficient to develop and debug code, in many cases
2082 and pdb active can be an efficient to develop and debug code, in many cases
2083 eliminating the need for
2083 eliminating the need for
2084 \family typewriter
2084 \family typewriter
2085 print
2085 print
2086 \family default
2086 \family default
2087 statements or external debugging tools.
2087 statements or external debugging tools.
2088 I often simply put a
2088 I often simply put a
2089 \family typewriter
2089 \family typewriter
2090 1/0
2090 1/0
2091 \family default
2091 \family default
2092 in a place where I want to take a look so that pdb gets called, quickly
2092 in a place where I want to take a look so that pdb gets called, quickly
2093 view whatever variables I need to or test various pieces of code and then
2093 view whatever variables I need to or test various pieces of code and then
2094 remove the
2094 remove the
2095 \family typewriter
2095 \family typewriter
2096 1/0
2096 1/0
2097 \family default
2097 \family default
2098 .
2098 .
2099 \newline
2099 \newline
2100 Note also that `
2100 Note also that `
2101 \family typewriter
2101 \family typewriter
2102 %run -d
2102 %run -d
2103 \family default
2103 \family default
2104 ' activates
2104 ' activates
2105 \family typewriter
2105 \family typewriter
2106 pdb
2106 pdb
2107 \family default
2107 \family default
2108 and automatically sets initial breakpoints for you to step through your
2108 and automatically sets initial breakpoints for you to step through your
2109 code, watch variables, etc.
2109 code, watch variables, etc.
2110 See Sec.\SpecialChar ~
2110 See Sec.\SpecialChar ~
2111
2111
2112 \begin_inset LatexCommand \ref{sec:cache_output}
2112 \begin_inset LatexCommand \ref{sec:cache_output}
2113
2113
2114 \end_inset
2114 \end_inset
2115
2115
2116 for details.
2116 for details.
2117 \layout Itemize
2117 \layout Itemize
2118
2118
2119 Use the output cache.
2119 Use the output cache.
2120 All output results are automatically stored in a global dictionary named
2120 All output results are automatically stored in a global dictionary named
2121
2121
2122 \family typewriter
2122 \family typewriter
2123 Out
2123 Out
2124 \family default
2124 \family default
2125 and variables named
2125 and variables named
2126 \family typewriter
2126 \family typewriter
2127 _1
2127 _1
2128 \family default
2128 \family default
2129 ,
2129 ,
2130 \family typewriter
2130 \family typewriter
2131 _2
2131 _2
2132 \family default
2132 \family default
2133 , etc.
2133 , etc.
2134 alias them.
2134 alias them.
2135 For example, the result of input line 4 is available either as
2135 For example, the result of input line 4 is available either as
2136 \family typewriter
2136 \family typewriter
2137 Out[4]
2137 Out[4]
2138 \family default
2138 \family default
2139 or as
2139 or as
2140 \family typewriter
2140 \family typewriter
2141 _4
2141 _4
2142 \family default
2142 \family default
2143 .
2143 .
2144 Additionally, three variables named
2144 Additionally, three variables named
2145 \family typewriter
2145 \family typewriter
2146 _
2146 _
2147 \family default
2147 \family default
2148 ,
2148 ,
2149 \family typewriter
2149 \family typewriter
2150 __
2150 __
2151 \family default
2151 \family default
2152 and
2152 and
2153 \family typewriter
2153 \family typewriter
2154 ___
2154 ___
2155 \family default
2155 \family default
2156 are always kept updated with the for the last three results.
2156 are always kept updated with the for the last three results.
2157 This allows you to recall any previous result and further use it for new
2157 This allows you to recall any previous result and further use it for new
2158 calculations.
2158 calculations.
2159 See Sec.\SpecialChar ~
2159 See Sec.\SpecialChar ~
2160
2160
2161 \begin_inset LatexCommand \ref{sec:cache_output}
2161 \begin_inset LatexCommand \ref{sec:cache_output}
2162
2162
2163 \end_inset
2163 \end_inset
2164
2164
2165 for more.
2165 for more.
2166 \layout Itemize
2166 \layout Itemize
2167
2167
2168 Put a '
2168 Put a '
2169 \family typewriter
2169 \family typewriter
2170 ;
2170 ;
2171 \family default
2171 \family default
2172 ' at the end of a line to supress the printing of output.
2172 ' at the end of a line to supress the printing of output.
2173 This is useful when doing calculations which generate long output you are
2173 This is useful when doing calculations which generate long output you are
2174 not interested in seeing.
2174 not interested in seeing.
2175 The
2175 The
2176 \family typewriter
2176 \family typewriter
2177 _*
2177 _*
2178 \family default
2178 \family default
2179 variables and the
2179 variables and the
2180 \family typewriter
2180 \family typewriter
2181 Out[]
2181 Out[]
2182 \family default
2182 \family default
2183 list do get updated with the contents of the output, even if it is not
2183 list do get updated with the contents of the output, even if it is not
2184 printed.
2184 printed.
2185 You can thus still access the generated results this way for further processing.
2185 You can thus still access the generated results this way for further processing.
2186 \layout Itemize
2186 \layout Itemize
2187
2187
2188 A similar system exists for caching input.
2188 A similar system exists for caching input.
2189 All input is stored in a global list called
2189 All input is stored in a global list called
2190 \family typewriter
2190 \family typewriter
2191 In
2191 In
2192 \family default
2192 \family default
2193 , so you can re-execute lines 22 through 28 plus line 34 by typing
2193 , so you can re-execute lines 22 through 28 plus line 34 by typing
2194 \family typewriter
2194 \family typewriter
2195 'exec In[22:29]+In[34]'
2195 'exec In[22:29]+In[34]'
2196 \family default
2196 \family default
2197 (using Python slicing notation).
2197 (using Python slicing notation).
2198 If you need to execute the same set of lines often, you can assign them
2198 If you need to execute the same set of lines often, you can assign them
2199 to a macro with the
2199 to a macro with the
2200 \family typewriter
2200 \family typewriter
2201 %macro
2201 %macro
2202 \family default
2202 \family default
2203
2203
2204 \family typewriter
2204 \family typewriter
2205 function.
2205 function.
2206
2206
2207 \family default
2207 \family default
2208 See sec.
2208 See sec.
2209
2209
2210 \begin_inset LatexCommand \ref{sec:cache_input}
2210 \begin_inset LatexCommand \ref{sec:cache_input}
2211
2211
2212 \end_inset
2212 \end_inset
2213
2213
2214 for more.
2214 for more.
2215 \layout Itemize
2215 \layout Itemize
2216
2216
2217 Use your input history.
2217 Use your input history.
2218 The
2218 The
2219 \family typewriter
2219 \family typewriter
2220 %hist
2220 %hist
2221 \family default
2221 \family default
2222 command can show you all previous input, without line numbers if desired
2222 command can show you all previous input, without line numbers if desired
2223 (option
2223 (option
2224 \family typewriter
2224 \family typewriter
2225 -n
2225 -n
2226 \family default
2226 \family default
2227 ) so you can directly copy and paste code either back in IPython or in a
2227 ) so you can directly copy and paste code either back in IPython or in a
2228 text editor.
2228 text editor.
2229 You can also save all your history by turning on logging via
2229 You can also save all your history by turning on logging via
2230 \family typewriter
2230 \family typewriter
2231 %logstart
2231 %logstart
2232 \family default
2232 \family default
2233 ; these logs can later be either reloaded as IPython sessions or used as
2233 ; these logs can later be either reloaded as IPython sessions or used as
2234 code for your programs.
2234 code for your programs.
2235 \layout Itemize
2235 \layout Itemize
2236
2236
2237 Define your own macros with
2238 \family typewriter
2239 %macro
2240 \family default
2241 .
2242 This can be useful for automating sequences of expressions when working
2243 interactively.
2244 You can edit a macro (they are just Python variables holding your input
2245 as a string) by simply typing `
2246 \family typewriter
2247 %edit macroname
2248 \family default
2249 ', and macros can be stored persistently across session with `
2250 \family typewriter
2251 %store macroname
2252 \family default
2253 ' (the storage system is per-profile).
2254 The combination of quick macros, persistent storage and editing, allows
2255 you to easily refine quick-and-dirty interactive input into permanent utilities
2256 , always available both in IPython and as files for general reuse.
2257 \layout Itemize
2258
2259 While
2260 \family typewriter
2261 %macro
2262 \family default
2263 saves input lines into memory for interactive re-execution, sometimes you'd
2264 like to save your input directly to a file.
2265 The
2266 \family typewriter
2267 %save
2268 \family default
2269 magic does this: its input sytnax is the same as
2270 \family typewriter
2271 %macro
2272 \family default
2273 , but it saves your input directly to a Python file.
2274 Note that the
2275 \family typewriter
2276 %logstart
2277 \family default
2278 command also saves input, but it logs
2279 \emph on
2280 all
2281 \emph default
2282 input to disk (though you can temporarily suspend it and reactivate it
2283 with
2284 \family typewriter
2285 %logoff/%logon
2286 \family default
2287 );
2288 \family typewriter
2289 %save
2290 \family default
2291 allows you to select which lines of input you need to save.
2292 \layout Itemize
2293
2294 Define your own system aliases.
2237 Define your own system aliases.
2295 Even though IPython gives you access to your system shell via the
2238 Even though IPython gives you access to your system shell via the
2296 \family typewriter
2239 \family typewriter
2297 !
2240 !
2298 \family default
2241 \family default
2299 prefix, it is convenient to have aliases to the system commands you use
2242 prefix, it is convenient to have aliases to the system commands you use
2300 most often.
2243 most often.
2301 This allows you to work seamlessly from inside IPython with the same commands
2244 This allows you to work seamlessly from inside IPython with the same commands
2302 you are used to in your system shell.
2245 you are used to in your system shell.
2303 \newline
2246 \newline
2304 IPython comes with some pre-defined aliases and a complete system for changing
2247 IPython comes with some pre-defined aliases and a complete system for changing
2305 directories, both via a stack (see
2248 directories, both via a stack (see
2306 \family typewriter
2249 \family typewriter
2307 %pushd
2250 %pushd
2308 \family default
2251 \family default
2309 ,
2252 ,
2310 \family typewriter
2253 \family typewriter
2311 %popd
2254 %popd
2312 \family default
2255 \family default
2313 and
2256 and
2314 \family typewriter
2257 \family typewriter
2315 %ds
2258 %ds
2316 \family default
2259 \family default
2317 ) and via direct
2260 ) and via direct
2318 \family typewriter
2261 \family typewriter
2319 %cd
2262 %cd
2320 \family default
2263 \family default
2321 .
2264 .
2322 The latter keeps a history of visited directories and allows you to go
2265 The latter keeps a history of visited directories and allows you to go
2323 to any previously visited one.
2266 to any previously visited one.
2324 \layout Itemize
2267 \layout Itemize
2325
2268
2326 Use Python to manipulate the results of system commands.
2269 Use Python to manipulate the results of system commands.
2327 The `
2270 The `
2328 \family typewriter
2271 \family typewriter
2329 !!
2272 !!
2330 \family default
2273 \family default
2331 ' special syntax, and the
2274 ' special syntax, and the
2332 \family typewriter
2275 \family typewriter
2333 %sc
2276 %sc
2334 \family default
2277 \family default
2335 and
2278 and
2336 \family typewriter
2279 \family typewriter
2337 %sx
2280 %sx
2338 \family default
2281 \family default
2339 magic commands allow you to capture system output into Python variables.
2282 magic commands allow you to capture system output into Python variables.
2340 \layout Itemize
2283 \layout Itemize
2341
2284
2342 Expand python variables when calling the shell (either via
2285 Expand python variables when calling the shell (either via
2343 \family typewriter
2286 \family typewriter
2344 `!'
2287 `!'
2345 \family default
2288 \family default
2346 and
2289 and
2347 \family typewriter
2290 \family typewriter
2348 `!!'
2291 `!!'
2349 \family default
2292 \family default
2350 or via aliases) by prepending a
2293 or via aliases) by prepending a
2351 \family typewriter
2294 \family typewriter
2352 $
2295 $
2353 \family default
2296 \family default
2354 in front of them.
2297 in front of them.
2355 You can also expand complete python expressions.
2298 You can also expand complete python expressions.
2356 See sec.\SpecialChar ~
2299 See sec.\SpecialChar ~
2357
2300
2358 \begin_inset LatexCommand \ref{sub:System-shell-access}
2301 \begin_inset LatexCommand \ref{sub:System-shell-access}
2359
2302
2360 \end_inset
2303 \end_inset
2361
2304
2362 for more.
2305 for more.
2363 \layout Itemize
2306 \layout Itemize
2364
2307
2365 Use profiles to maintain different configurations (modules to load, function
2308 Use profiles to maintain different configurations (modules to load, function
2366 definitions, option settings) for particular tasks.
2309 definitions, option settings) for particular tasks.
2367 You can then have customized versions of IPython for specific purposes.
2310 You can then have customized versions of IPython for specific purposes.
2368 See sec.\SpecialChar ~
2311 See sec.\SpecialChar ~
2369
2312
2370 \begin_inset LatexCommand \ref{sec:profiles}
2313 \begin_inset LatexCommand \ref{sec:profiles}
2371
2314
2372 \end_inset
2315 \end_inset
2373
2316
2374 for more.
2317 for more.
2375 \layout Itemize
2318 \layout Itemize
2376
2319
2377 Embed IPython in your programs.
2320 Embed IPython in your programs.
2378 A few lines of code are enough to load a complete IPython inside your own
2321 A few lines of code are enough to load a complete IPython inside your own
2379 programs, giving you the ability to work with your data interactively after
2322 programs, giving you the ability to work with your data interactively after
2380 automatic processing has been completed.
2323 automatic processing has been completed.
2381 See sec.\SpecialChar ~
2324 See sec.\SpecialChar ~
2382
2325
2383 \begin_inset LatexCommand \ref{sec:embed}
2326 \begin_inset LatexCommand \ref{sec:embed}
2384
2327
2385 \end_inset
2328 \end_inset
2386
2329
2387 for more.
2330 for more.
2388 \layout Itemize
2331 \layout Itemize
2389
2332
2390 Use the Python profiler.
2333 Use the Python profiler.
2391 When dealing with performance issues, the
2334 When dealing with performance issues, the
2392 \family typewriter
2335 \family typewriter
2393 %run
2336 %run
2394 \family default
2337 \family default
2395 command with a
2338 command with a
2396 \family typewriter
2339 \family typewriter
2397 -p
2340 -p
2398 \family default
2341 \family default
2399 option allows you to run complete programs under the control of the Python
2342 option allows you to run complete programs under the control of the Python
2400 profiler.
2343 profiler.
2401 The
2344 The
2402 \family typewriter
2345 \family typewriter
2403 %prun
2346 %prun
2404 \family default
2347 \family default
2405 command does a similar job for single Python expressions (like function
2348 command does a similar job for single Python expressions (like function
2406 calls).
2349 calls).
2407 \layout Itemize
2350 \layout Itemize
2408
2351
2409 Use
2410 \family typewriter
2411 %edit
2412 \family default
2413 to have almost multiline editing.
2414 While IPython doesn't support true multiline editing, this command allows
2415 you to call an editor on the spot, and IPython will execute the code you
2416 type in there as if it were typed interactively.
2417 \layout Itemize
2418
2419 Use the IPython.demo.Demo class to load any Python script as an interactive
2352 Use the IPython.demo.Demo class to load any Python script as an interactive
2420 demo.
2353 demo.
2421 With a minimal amount of simple markup, you can control the execution of
2354 With a minimal amount of simple markup, you can control the execution of
2422 the script, stopping as needed.
2355 the script, stopping as needed.
2423 See sec.\SpecialChar ~
2356 See sec.\SpecialChar ~
2424
2357
2425 \begin_inset LatexCommand \ref{sec:interactive-demos}
2358 \begin_inset LatexCommand \ref{sec:interactive-demos}
2426
2359
2427 \end_inset
2360 \end_inset
2428
2361
2429 for more.
2362 for more.
2363 \layout Subsection
2364
2365 Source code handling tips
2430 \layout Standard
2366 \layout Standard
2431
2367
2368 IPython is a line-oriented program, without full control of the terminal.
2369 Therefore, it doesn't support true multiline editing.
2370 However, it has a number of useful tools to help you in dealing effectively
2371 with more complex editing.
2372 \layout Standard
2432
2373
2433 \series bold
2374 The
2434 Effective logging:
2375 \family typewriter
2435 \series default
2376 %edit
2436 a very useful suggestion sent in by Robert Kern follows
2377 \family default
2378 command gives a reasonable approximation of multiline editing, by invoking
2379 your favorite editor on the spot.
2380 IPython will execute the code you type in there as if it were typed interactive
2381 ly.
2382 Type
2383 \family typewriter
2384 %edit?
2385 \family default
2386 for the full details on the edit command.
2387 \layout Standard
2388
2389 If you have typed various commands during a session, which you'd like to
2390 reuse, IPython provides you with a number of tools.
2391 Start by using
2392 \family typewriter
2393 %hist
2394 \family default
2395 to see your input history, so you can see the line numbers of all input.
2396 Let us say that you'd like to reuse lines 10 through 20, plus lines 24
2397 and 28.
2398 All the commands below can operate on these with the syntax
2399 \layout LyX-Code
2400
2401 %command 10-20 24 28
2402 \layout Standard
2403
2404 where the command given can be:
2405 \layout Itemize
2406
2407
2408 \family typewriter
2409 %macro <macroname>
2410 \family default
2411 : this stores the lines into a variable which, when called at the prompt,
2412 re-executes the input.
2413 Macros can be edited later using
2414 \family typewriter
2415 `%edit macroname
2416 \family default
2417 ', and they can be stored persistently across sessions with `
2418 \family typewriter
2419 %store macroname
2420 \family default
2421 ' (the storage system is per-profile).
2422 The combination of quick macros, persistent storage and editing, allows
2423 you to easily refine quick-and-dirty interactive input into permanent utilities
2424 , always available both in IPython and as files for general reuse.
2425 \layout Itemize
2426
2427
2428 \family typewriter
2429 %edit
2430 \family default
2431 : this will open a text editor with those lines pre-loaded for further modificat
2432 ion.
2433 It will then execute the resulting file's contents as if you had typed
2434 it at the prompt.
2435 \layout Itemize
2436
2437
2438 \family typewriter
2439 %save <filename>
2440 \family default
2441 : this saves the lines directly to a named file on disk.
2442 \layout Standard
2443
2444 While
2445 \family typewriter
2446 %macro
2447 \family default
2448 saves input lines into memory for interactive re-execution, sometimes you'd
2449 like to save your input directly to a file.
2450 The
2451 \family typewriter
2452 %save
2453 \family default
2454 magic does this: its input sytnax is the same as
2455 \family typewriter
2456 %macro
2457 \family default
2458 , but it saves your input directly to a Python file.
2459 Note that the
2460 \family typewriter
2461 %logstart
2462 \family default
2463 command also saves input, but it logs
2464 \emph on
2465 all
2466 \emph default
2467 input to disk (though you can temporarily suspend it and reactivate it
2468 with
2469 \family typewriter
2470 %logoff/%logon
2471 \family default
2472 );
2473 \family typewriter
2474 %save
2475 \family default
2476 allows you to select which lines of input you need to save.
2477 \layout Standard
2478
2479 And
2480 \layout Subsection
2481
2482 Effective logging
2483 \layout Standard
2484
2485 A very useful suggestion sent in by Robert Kern follows:
2437 \layout Standard
2486 \layout Standard
2438
2487
2439 I recently happened on a nifty way to keep tidy per-project log files.
2488 I recently happened on a nifty way to keep tidy per-project log files.
2440 I made a profile for my project (which is called "parkfield").
2489 I made a profile for my project (which is called "parkfield").
2441 \layout LyX-Code
2490 \layout LyX-Code
2442
2491
2443 include ipythonrc
2492 include ipythonrc
2444 \layout LyX-Code
2493 \layout LyX-Code
2445
2494
2446 logfile '' # cancel earlier logfile invocation
2495 logfile '' # cancel earlier logfile invocation
2447 \layout LyX-Code
2496 \layout LyX-Code
2448
2497
2449 execute import time
2498 execute import time
2450 \layout LyX-Code
2499 \layout LyX-Code
2451
2500
2452 execute __cmd = '/Users/kern/research/logfiles/parkfield-%s.log rotate'
2501 execute __cmd = '/Users/kern/research/logfiles/parkfield-%s.log rotate'
2453 \layout LyX-Code
2502 \layout LyX-Code
2454
2503
2455 execute __IP.magic_logstart(__cmd % time.strftime('%Y-%m-%d'))
2504 execute __IP.magic_logstart(__cmd % time.strftime('%Y-%m-%d'))
2456 \layout Standard
2505 \layout Standard
2457
2506
2458 I also added a shell alias for convenience:
2507 I also added a shell alias for convenience:
2459 \layout LyX-Code
2508 \layout LyX-Code
2460
2509
2461 alias parkfield="ipython -pylab -profile parkfield"
2510 alias parkfield="ipython -pylab -profile parkfield"
2462 \layout Standard
2511 \layout Standard
2463
2512
2464 Now I have a nice little directory with everything I ever type in, organized
2513 Now I have a nice little directory with everything I ever type in, organized
2465 by project and date.
2514 by project and date.
2466 \layout Standard
2515 \layout Standard
2467
2516
2468
2517
2469 \series bold
2518 \series bold
2470 Contribute your own:
2519 Contribute your own:
2471 \series default
2520 \series default
2472 If you have your own favorite tip on using IPython efficiently for a certain
2521 If you have your own favorite tip on using IPython efficiently for a certain
2473 task (especially things which can't be done in the normal Python interpreter),
2522 task (especially things which can't be done in the normal Python interpreter),
2474 don't hesitate to send it!
2523 don't hesitate to send it!
2475 \layout Section
2524 \layout Section
2476
2525
2477 Command-line use
2526 Command-line use
2478 \layout Standard
2527 \layout Standard
2479
2528
2480 You start IPython with the command:
2529 You start IPython with the command:
2481 \layout Standard
2530 \layout Standard
2482
2531
2483
2532
2484 \family typewriter
2533 \family typewriter
2485 $ ipython [options] files
2534 $ ipython [options] files
2486 \layout Standard
2535 \layout Standard
2487
2536
2488 If invoked with no options, it executes all the files listed in sequence
2537 If invoked with no options, it executes all the files listed in sequence
2489 and drops you into the interpreter while still acknowledging any options
2538 and drops you into the interpreter while still acknowledging any options
2490 you may have set in your ipythonrc file.
2539 you may have set in your ipythonrc file.
2491 This behavior is different from standard Python, which when called as
2540 This behavior is different from standard Python, which when called as
2492 \family typewriter
2541 \family typewriter
2493 python -i
2542 python -i
2494 \family default
2543 \family default
2495 will only execute one file and ignore your configuration setup.
2544 will only execute one file and ignore your configuration setup.
2496 \layout Standard
2545 \layout Standard
2497
2546
2498 Please note that some of the configuration options are not available at
2547 Please note that some of the configuration options are not available at
2499 the command line, simply because they are not practical here.
2548 the command line, simply because they are not practical here.
2500 Look into your ipythonrc configuration file for details on those.
2549 Look into your ipythonrc configuration file for details on those.
2501 This file typically installed in the
2550 This file typically installed in the
2502 \family typewriter
2551 \family typewriter
2503 $HOME/.ipython
2552 $HOME/.ipython
2504 \family default
2553 \family default
2505 directory.
2554 directory.
2506 For Windows users,
2555 For Windows users,
2507 \family typewriter
2556 \family typewriter
2508 $HOME
2557 $HOME
2509 \family default
2558 \family default
2510 resolves to
2559 resolves to
2511 \family typewriter
2560 \family typewriter
2512 C:
2561 C:
2513 \backslash
2562 \backslash
2514
2563
2515 \backslash
2564 \backslash
2516 Documents and Settings
2565 Documents and Settings
2517 \backslash
2566 \backslash
2518
2567
2519 \backslash
2568 \backslash
2520 YourUserName
2569 YourUserName
2521 \family default
2570 \family default
2522 in most instances.
2571 in most instances.
2523 In the rest of this text, we will refer to this directory as
2572 In the rest of this text, we will refer to this directory as
2524 \family typewriter
2573 \family typewriter
2525 IPYTHONDIR
2574 IPYTHONDIR
2526 \family default
2575 \family default
2527 .
2576 .
2528 \layout Subsection
2577 \layout Subsection
2529
2578
2530
2579
2531 \begin_inset LatexCommand \label{sec:threading-opts}
2580 \begin_inset LatexCommand \label{sec:threading-opts}
2532
2581
2533 \end_inset
2582 \end_inset
2534
2583
2535 Special Threading Options
2584 Special Threading Options
2536 \layout Standard
2585 \layout Standard
2537
2586
2538 The following special options are ONLY valid at the beginning of the command
2587 The following special options are ONLY valid at the beginning of the command
2539 line, and not later.
2588 line, and not later.
2540 This is because they control the initial- ization of ipython itself, before
2589 This is because they control the initial- ization of ipython itself, before
2541 the normal option-handling mechanism is active.
2590 the normal option-handling mechanism is active.
2542 \layout List
2591 \layout List
2543 \labelwidthstring 00.00.0000
2592 \labelwidthstring 00.00.0000
2544
2593
2545
2594
2546 \family typewriter
2595 \family typewriter
2547 \series bold
2596 \series bold
2548 -gthread,\SpecialChar ~
2597 -gthread,\SpecialChar ~
2549 -qthread,\SpecialChar ~
2598 -qthread,\SpecialChar ~
2550 -wthread,\SpecialChar ~
2599 -wthread,\SpecialChar ~
2551 -pylab:
2600 -pylab:
2552 \family default
2601 \family default
2553 \series default
2602 \series default
2554 Only
2603 Only
2555 \emph on
2604 \emph on
2556 one
2605 one
2557 \emph default
2606 \emph default
2558 of these can be given, and it can only be given as the first option passed
2607 of these can be given, and it can only be given as the first option passed
2559 to IPython (it will have no effect in any other position).
2608 to IPython (it will have no effect in any other position).
2560 They provide threading support for the GTK Qt and WXPython toolkits, and
2609 They provide threading support for the GTK Qt and WXPython toolkits, and
2561 for the matplotlib library.
2610 for the matplotlib library.
2562 \layout List
2611 \layout List
2563 \labelwidthstring 00.00.0000
2612 \labelwidthstring 00.00.0000
2564
2613
2565 \SpecialChar ~
2614 \SpecialChar ~
2566 With any of the first three options, IPython starts running a separate
2615 With any of the first three options, IPython starts running a separate
2567 thread for the graphical toolkit's operation, so that you can open and
2616 thread for the graphical toolkit's operation, so that you can open and
2568 control graphical elements from within an IPython command line, without
2617 control graphical elements from within an IPython command line, without
2569 blocking.
2618 blocking.
2570 All three provide essentially the same functionality, respectively for
2619 All three provide essentially the same functionality, respectively for
2571 GTK, QT and WXWidgets (via their Python interfaces).
2620 GTK, QT and WXWidgets (via their Python interfaces).
2572 \layout List
2621 \layout List
2573 \labelwidthstring 00.00.0000
2622 \labelwidthstring 00.00.0000
2574
2623
2575 \SpecialChar ~
2624 \SpecialChar ~
2576 Note that with
2625 Note that with
2577 \family typewriter
2626 \family typewriter
2578 -wthread
2627 -wthread
2579 \family default
2628 \family default
2580 , you can additionally use the -wxversion option to request a specific version
2629 , you can additionally use the -wxversion option to request a specific version
2581 of wx to be used.
2630 of wx to be used.
2582 This requires that you have the
2631 This requires that you have the
2583 \family typewriter
2632 \family typewriter
2584 wxversion
2633 wxversion
2585 \family default
2634 \family default
2586 Python module installed, which is part of recent wxPython distributions.
2635 Python module installed, which is part of recent wxPython distributions.
2587 \layout List
2636 \layout List
2588 \labelwidthstring 00.00.0000
2637 \labelwidthstring 00.00.0000
2589
2638
2590 \SpecialChar ~
2639 \SpecialChar ~
2591 If
2640 If
2592 \family typewriter
2641 \family typewriter
2593 -pylab
2642 -pylab
2594 \family default
2643 \family default
2595 is given, IPython loads special support for the mat plotlib library (
2644 is given, IPython loads special support for the mat plotlib library (
2596 \begin_inset LatexCommand \htmlurl{http://matplotlib.sourceforge.net}
2645 \begin_inset LatexCommand \htmlurl{http://matplotlib.sourceforge.net}
2597
2646
2598 \end_inset
2647 \end_inset
2599
2648
2600 ), allowing interactive usage of any of its backends as defined in the user's
2649 ), allowing interactive usage of any of its backends as defined in the user's
2601
2650
2602 \family typewriter
2651 \family typewriter
2603 ~/.matplotlib/matplotlibrc
2652 ~/.matplotlib/matplotlibrc
2604 \family default
2653 \family default
2605 file.
2654 file.
2606 It automatically activates GTK, Qt or WX threading for IPyhton if the choice
2655 It automatically activates GTK, Qt or WX threading for IPyhton if the choice
2607 of matplotlib backend requires it.
2656 of matplotlib backend requires it.
2608 It also modifies the
2657 It also modifies the
2609 \family typewriter
2658 \family typewriter
2610 %run
2659 %run
2611 \family default
2660 \family default
2612 command to correctly execute (without blocking) any matplotlib-based script
2661 command to correctly execute (without blocking) any matplotlib-based script
2613 which calls
2662 which calls
2614 \family typewriter
2663 \family typewriter
2615 show()
2664 show()
2616 \family default
2665 \family default
2617 at the end.
2666 at the end.
2618
2667
2619 \layout List
2668 \layout List
2620 \labelwidthstring 00.00.0000
2669 \labelwidthstring 00.00.0000
2621
2670
2622
2671
2623 \family typewriter
2672 \family typewriter
2624 \series bold
2673 \series bold
2625 -tk
2674 -tk
2626 \family default
2675 \family default
2627 \series default
2676 \series default
2628 The
2677 The
2629 \family typewriter
2678 \family typewriter
2630 -g/q/wthread
2679 -g/q/wthread
2631 \family default
2680 \family default
2632 options, and
2681 options, and
2633 \family typewriter
2682 \family typewriter
2634 -pylab
2683 -pylab
2635 \family default
2684 \family default
2636 (if matplotlib is configured to use GTK, Qt or WX), will normally block
2685 (if matplotlib is configured to use GTK, Qt or WX), will normally block
2637 Tk graphical interfaces.
2686 Tk graphical interfaces.
2638 This means that when either GTK, Qt or WX threading is active, any attempt
2687 This means that when either GTK, Qt or WX threading is active, any attempt
2639 to open a Tk GUI will result in a dead window, and possibly cause the Python
2688 to open a Tk GUI will result in a dead window, and possibly cause the Python
2640 interpreter to crash.
2689 interpreter to crash.
2641 An extra option,
2690 An extra option,
2642 \family typewriter
2691 \family typewriter
2643 -tk
2692 -tk
2644 \family default
2693 \family default
2645 , is available to address this issue.
2694 , is available to address this issue.
2646 It can
2695 It can
2647 \emph on
2696 \emph on
2648 only
2697 only
2649 \emph default
2698 \emph default
2650 be given as a
2699 be given as a
2651 \emph on
2700 \emph on
2652 second
2701 second
2653 \emph default
2702 \emph default
2654 option after any of the above (
2703 option after any of the above (
2655 \family typewriter
2704 \family typewriter
2656 -gthread
2705 -gthread
2657 \family default
2706 \family default
2658 ,
2707 ,
2659 \family typewriter
2708 \family typewriter
2660 -wthread
2709 -wthread
2661 \family default
2710 \family default
2662 or
2711 or
2663 \family typewriter
2712 \family typewriter
2664 -pylab
2713 -pylab
2665 \family default
2714 \family default
2666 ).
2715 ).
2667 \layout List
2716 \layout List
2668 \labelwidthstring 00.00.0000
2717 \labelwidthstring 00.00.0000
2669
2718
2670 \SpecialChar ~
2719 \SpecialChar ~
2671 If
2720 If
2672 \family typewriter
2721 \family typewriter
2673 -tk
2722 -tk
2674 \family default
2723 \family default
2675 is given, IPython will try to coordinate Tk threading with GTK, Qt or WX.
2724 is given, IPython will try to coordinate Tk threading with GTK, Qt or WX.
2676 This is however potentially unreliable, and you will have to test on your
2725 This is however potentially unreliable, and you will have to test on your
2677 platform and Python configuration to determine whether it works for you.
2726 platform and Python configuration to determine whether it works for you.
2678 Debian users have reported success, apparently due to the fact that Debian
2727 Debian users have reported success, apparently due to the fact that Debian
2679 builds all of Tcl, Tk, Tkinter and Python with pthreads support.
2728 builds all of Tcl, Tk, Tkinter and Python with pthreads support.
2680 Under other Linux environments (such as Fedora Core 2/3), this option has
2729 Under other Linux environments (such as Fedora Core 2/3), this option has
2681 caused random crashes and lockups of the Python interpreter.
2730 caused random crashes and lockups of the Python interpreter.
2682 Under other operating systems (Mac OSX and Windows), you'll need to try
2731 Under other operating systems (Mac OSX and Windows), you'll need to try
2683 it to find out, since currently no user reports are available.
2732 it to find out, since currently no user reports are available.
2684 \layout List
2733 \layout List
2685 \labelwidthstring 00.00.0000
2734 \labelwidthstring 00.00.0000
2686
2735
2687 \SpecialChar ~
2736 \SpecialChar ~
2688 There is unfortunately no way for IPython to determine at run time whether
2737 There is unfortunately no way for IPython to determine at run time whether
2689
2738
2690 \family typewriter
2739 \family typewriter
2691 -tk
2740 -tk
2692 \family default
2741 \family default
2693 will work reliably or not, so you will need to do some experiments before
2742 will work reliably or not, so you will need to do some experiments before
2694 relying on it for regular work.
2743 relying on it for regular work.
2695
2744
2696 \layout Subsection
2745 \layout Subsection
2697
2746
2698
2747
2699 \begin_inset LatexCommand \label{sec:cmd-line-opts}
2748 \begin_inset LatexCommand \label{sec:cmd-line-opts}
2700
2749
2701 \end_inset
2750 \end_inset
2702
2751
2703 Regular Options
2752 Regular Options
2704 \layout Standard
2753 \layout Standard
2705
2754
2706 After the above threading options have been given, regular options can follow
2755 After the above threading options have been given, regular options can follow
2707 in any order.
2756 in any order.
2708 All options can be abbreviated to their shortest non-ambiguous form and
2757 All options can be abbreviated to their shortest non-ambiguous form and
2709 are case-sensitive.
2758 are case-sensitive.
2710 One or two dashes can be used.
2759 One or two dashes can be used.
2711 Some options have an alternate short form, indicated after a
2760 Some options have an alternate short form, indicated after a
2712 \family typewriter
2761 \family typewriter
2713 |
2762 |
2714 \family default
2763 \family default
2715 .
2764 .
2716 \layout Standard
2765 \layout Standard
2717
2766
2718 Most options can also be set from your ipythonrc configuration file.
2767 Most options can also be set from your ipythonrc configuration file.
2719 See the provided example for more details on what the options do.
2768 See the provided example for more details on what the options do.
2720 Options given at the command line override the values set in the ipythonrc
2769 Options given at the command line override the values set in the ipythonrc
2721 file.
2770 file.
2722 \layout Standard
2771 \layout Standard
2723
2772
2724 All options with a
2773 All options with a
2725 \family typewriter
2774 \family typewriter
2726 [no]
2775 [no]
2727 \family default
2776 \family default
2728 prepended can be specified in negated form (
2777 prepended can be specified in negated form (
2729 \family typewriter
2778 \family typewriter
2730 -nooption
2779 -nooption
2731 \family default
2780 \family default
2732 instead of
2781 instead of
2733 \family typewriter
2782 \family typewriter
2734 -option
2783 -option
2735 \family default
2784 \family default
2736 ) to turn the feature off.
2785 ) to turn the feature off.
2737 \layout List
2786 \layout List
2738 \labelwidthstring 00.00.0000
2787 \labelwidthstring 00.00.0000
2739
2788
2740
2789
2741 \family typewriter
2790 \family typewriter
2742 \series bold
2791 \series bold
2743 -help
2792 -help
2744 \family default
2793 \family default
2745 \series default
2794 \series default
2746 : print a help message and exit.
2795 : print a help message and exit.
2747 \layout List
2796 \layout List
2748 \labelwidthstring 00.00.0000
2797 \labelwidthstring 00.00.0000
2749
2798
2750
2799
2751 \family typewriter
2800 \family typewriter
2752 \series bold
2801 \series bold
2753 -pylab:
2802 -pylab:
2754 \family default
2803 \family default
2755 \series default
2804 \series default
2756 this can
2805 this can
2757 \emph on
2806 \emph on
2758 only
2807 only
2759 \emph default
2808 \emph default
2760 be given as the
2809 be given as the
2761 \emph on
2810 \emph on
2762 first
2811 first
2763 \emph default
2812 \emph default
2764 option passed to IPython (it will have no effect in any other position).
2813 option passed to IPython (it will have no effect in any other position).
2765 It adds special support for the matplotlib library (
2814 It adds special support for the matplotlib library (
2766 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
2815 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
2767
2816
2768 \end_inset
2817 \end_inset
2769
2818
2770 ), allowing interactive usage of any of its backends as defined in the user's
2819 ), allowing interactive usage of any of its backends as defined in the user's
2771
2820
2772 \family typewriter
2821 \family typewriter
2773 .matplotlibrc
2822 .matplotlibrc
2774 \family default
2823 \family default
2775 file.
2824 file.
2776 It automatically activates GTK or WX threading for IPyhton if the choice
2825 It automatically activates GTK or WX threading for IPyhton if the choice
2777 of matplotlib backend requires it.
2826 of matplotlib backend requires it.
2778 It also modifies the
2827 It also modifies the
2779 \family typewriter
2828 \family typewriter
2780 %run
2829 %run
2781 \family default
2830 \family default
2782 command to correctly execute (without blocking) any matplotlib-based script
2831 command to correctly execute (without blocking) any matplotlib-based script
2783 which calls
2832 which calls
2784 \family typewriter
2833 \family typewriter
2785 show()
2834 show()
2786 \family default
2835 \family default
2787 at the end.
2836 at the end.
2788 See Sec.\SpecialChar ~
2837 See Sec.\SpecialChar ~
2789
2838
2790 \begin_inset LatexCommand \ref{sec:matplotlib-support}
2839 \begin_inset LatexCommand \ref{sec:matplotlib-support}
2791
2840
2792 \end_inset
2841 \end_inset
2793
2842
2794 for more details.
2843 for more details.
2795 \layout List
2844 \layout List
2796 \labelwidthstring 00.00.0000
2845 \labelwidthstring 00.00.0000
2797
2846
2798
2847
2799 \family typewriter
2848 \family typewriter
2800 \series bold
2849 \series bold
2801 -autocall <val>:
2850 -autocall <val>:
2802 \family default
2851 \family default
2803 \series default
2852 \series default
2804 Make IPython automatically call any callable object even if you didn't
2853 Make IPython automatically call any callable object even if you didn't
2805 type explicit parentheses.
2854 type explicit parentheses.
2806 For example, `str 43' becomes `str(43)' automatically.
2855 For example, `str 43' becomes `str(43)' automatically.
2807 The value can be `0' to disable the feature, `1' for
2856 The value can be `0' to disable the feature, `1' for
2808 \emph on
2857 \emph on
2809 smart
2858 smart
2810 \emph default
2859 \emph default
2811 autocall, where it is not applied if there are no more arguments on the
2860 autocall, where it is not applied if there are no more arguments on the
2812 line, and `2' for
2861 line, and `2' for
2813 \emph on
2862 \emph on
2814 full
2863 full
2815 \emph default
2864 \emph default
2816 autocall, where all callable objects are automatically called (even if
2865 autocall, where all callable objects are automatically called (even if
2817 no arguments are present).
2866 no arguments are present).
2818 The default is `1'.
2867 The default is `1'.
2819 \layout List
2868 \layout List
2820 \labelwidthstring 00.00.0000
2869 \labelwidthstring 00.00.0000
2821
2870
2822
2871
2823 \family typewriter
2872 \family typewriter
2824 \series bold
2873 \series bold
2825 -[no]autoindent:
2874 -[no]autoindent:
2826 \family default
2875 \family default
2827 \series default
2876 \series default
2828 Turn automatic indentation on/off.
2877 Turn automatic indentation on/off.
2829 \layout List
2878 \layout List
2830 \labelwidthstring 00.00.0000
2879 \labelwidthstring 00.00.0000
2831
2880
2832
2881
2833 \family typewriter
2882 \family typewriter
2834 \series bold
2883 \series bold
2835 -[no]automagic
2884 -[no]automagic
2836 \series default
2885 \series default
2837 :
2886 :
2838 \family default
2887 \family default
2839 make magic commands automatic (without needing their first character to
2888 make magic commands automatic (without needing their first character to
2840 be
2889 be
2841 \family typewriter
2890 \family typewriter
2842 %
2891 %
2843 \family default
2892 \family default
2844 ).
2893 ).
2845 Type
2894 Type
2846 \family typewriter
2895 \family typewriter
2847 %magic
2896 %magic
2848 \family default
2897 \family default
2849 at the IPython prompt for more information.
2898 at the IPython prompt for more information.
2850 \layout List
2899 \layout List
2851 \labelwidthstring 00.00.0000
2900 \labelwidthstring 00.00.0000
2852
2901
2853
2902
2854 \family typewriter
2903 \family typewriter
2855 \series bold
2904 \series bold
2856 -[no]autoedit_syntax:
2905 -[no]autoedit_syntax:
2857 \family default
2906 \family default
2858 \series default
2907 \series default
2859 When a syntax error occurs after editing a file, automatically open the
2908 When a syntax error occurs after editing a file, automatically open the
2860 file to the trouble causing line for convenient fixing.
2909 file to the trouble causing line for convenient fixing.
2861
2910
2862 \layout List
2911 \layout List
2863 \labelwidthstring 00.00.0000
2912 \labelwidthstring 00.00.0000
2864
2913
2865
2914
2866 \family typewriter
2915 \family typewriter
2867 \series bold
2916 \series bold
2868 -[no]banner
2917 -[no]banner
2869 \series default
2918 \series default
2870 :
2919 :
2871 \family default
2920 \family default
2872 Print the initial information banner (default on).
2921 Print the initial information banner (default on).
2873 \layout List
2922 \layout List
2874 \labelwidthstring 00.00.0000
2923 \labelwidthstring 00.00.0000
2875
2924
2876
2925
2877 \family typewriter
2926 \family typewriter
2878 \series bold
2927 \series bold
2879 -c\SpecialChar ~
2928 -c\SpecialChar ~
2880 <command>:
2929 <command>:
2881 \family default
2930 \family default
2882 \series default
2931 \series default
2883 execute the given command string, and set sys.argv to
2932 execute the given command string, and set sys.argv to
2884 \family typewriter
2933 \family typewriter
2885 ['c']
2934 ['c']
2886 \family default
2935 \family default
2887 .
2936 .
2888 This is similar to the
2937 This is similar to the
2889 \family typewriter
2938 \family typewriter
2890 -c
2939 -c
2891 \family default
2940 \family default
2892 option in the normal Python interpreter.
2941 option in the normal Python interpreter.
2893
2942
2894 \layout List
2943 \layout List
2895 \labelwidthstring 00.00.0000
2944 \labelwidthstring 00.00.0000
2896
2945
2897
2946
2898 \family typewriter
2947 \family typewriter
2899 \series bold
2948 \series bold
2900 -cache_size|cs\SpecialChar ~
2949 -cache_size|cs\SpecialChar ~
2901 <n>
2950 <n>
2902 \series default
2951 \series default
2903 :
2952 :
2904 \family default
2953 \family default
2905 size of the output cache (maximum number of entries to hold in memory).
2954 size of the output cache (maximum number of entries to hold in memory).
2906 The default is 1000, you can change it permanently in your config file.
2955 The default is 1000, you can change it permanently in your config file.
2907 Setting it to 0 completely disables the caching system, and the minimum
2956 Setting it to 0 completely disables the caching system, and the minimum
2908 value accepted is 20 (if you provide a value less than 20, it is reset
2957 value accepted is 20 (if you provide a value less than 20, it is reset
2909 to 0 and a warning is issued) This limit is defined because otherwise you'll
2958 to 0 and a warning is issued) This limit is defined because otherwise you'll
2910 spend more time re-flushing a too small cache than working.
2959 spend more time re-flushing a too small cache than working.
2911 \layout List
2960 \layout List
2912 \labelwidthstring 00.00.0000
2961 \labelwidthstring 00.00.0000
2913
2962
2914
2963
2915 \family typewriter
2964 \family typewriter
2916 \series bold
2965 \series bold
2917 -classic|cl
2966 -classic|cl
2918 \series default
2967 \series default
2919 :
2968 :
2920 \family default
2969 \family default
2921 Gives IPython a similar feel to the classic Python prompt.
2970 Gives IPython a similar feel to the classic Python prompt.
2922 \layout List
2971 \layout List
2923 \labelwidthstring 00.00.0000
2972 \labelwidthstring 00.00.0000
2924
2973
2925
2974
2926 \family typewriter
2975 \family typewriter
2927 \series bold
2976 \series bold
2928 -colors\SpecialChar ~
2977 -colors\SpecialChar ~
2929 <scheme>:
2978 <scheme>:
2930 \family default
2979 \family default
2931 \series default
2980 \series default
2932 Color scheme for prompts and exception reporting.
2981 Color scheme for prompts and exception reporting.
2933 Currently implemented: NoColor, Linux and LightBG.
2982 Currently implemented: NoColor, Linux and LightBG.
2934 \layout List
2983 \layout List
2935 \labelwidthstring 00.00.0000
2984 \labelwidthstring 00.00.0000
2936
2985
2937
2986
2938 \family typewriter
2987 \family typewriter
2939 \series bold
2988 \series bold
2940 -[no]color_info:
2989 -[no]color_info:
2941 \family default
2990 \family default
2942 \series default
2991 \series default
2943 IPython can display information about objects via a set of functions, and
2992 IPython can display information about objects via a set of functions, and
2944 optionally can use colors for this, syntax highlighting source code and
2993 optionally can use colors for this, syntax highlighting source code and
2945 various other elements.
2994 various other elements.
2946 However, because this information is passed through a pager (like 'less')
2995 However, because this information is passed through a pager (like 'less')
2947 and many pagers get confused with color codes, this option is off by default.
2996 and many pagers get confused with color codes, this option is off by default.
2948 You can test it and turn it on permanently in your ipythonrc file if it
2997 You can test it and turn it on permanently in your ipythonrc file if it
2949 works for you.
2998 works for you.
2950 As a reference, the 'less' pager supplied with Mandrake 8.2 works ok, but
2999 As a reference, the 'less' pager supplied with Mandrake 8.2 works ok, but
2951 that in RedHat 7.2 doesn't.
3000 that in RedHat 7.2 doesn't.
2952 \layout List
3001 \layout List
2953 \labelwidthstring 00.00.0000
3002 \labelwidthstring 00.00.0000
2954
3003
2955 \SpecialChar ~
3004 \SpecialChar ~
2956 Test it and turn it on permanently if it works with your system.
3005 Test it and turn it on permanently if it works with your system.
2957 The magic function
3006 The magic function
2958 \family typewriter
3007 \family typewriter
2959 %color_info
3008 %color_info
2960 \family default
3009 \family default
2961 allows you to toggle this interactively for testing.
3010 allows you to toggle this interactively for testing.
2962 \layout List
3011 \layout List
2963 \labelwidthstring 00.00.0000
3012 \labelwidthstring 00.00.0000
2964
3013
2965
3014
2966 \family typewriter
3015 \family typewriter
2967 \series bold
3016 \series bold
2968 -[no]debug
3017 -[no]debug
2969 \family default
3018 \family default
2970 \series default
3019 \series default
2971 : Show information about the loading process.
3020 : Show information about the loading process.
2972 Very useful to pin down problems with your configuration files or to get
3021 Very useful to pin down problems with your configuration files or to get
2973 details about session restores.
3022 details about session restores.
2974 \layout List
3023 \layout List
2975 \labelwidthstring 00.00.0000
3024 \labelwidthstring 00.00.0000
2976
3025
2977
3026
2978 \family typewriter
3027 \family typewriter
2979 \series bold
3028 \series bold
2980 -[no]deep_reload
3029 -[no]deep_reload
2981 \series default
3030 \series default
2982 :
3031 :
2983 \family default
3032 \family default
2984 IPython can use the
3033 IPython can use the
2985 \family typewriter
3034 \family typewriter
2986 deep_reload
3035 deep_reload
2987 \family default
3036 \family default
2988 module which reloads changes in modules recursively (it replaces the
3037 module which reloads changes in modules recursively (it replaces the
2989 \family typewriter
3038 \family typewriter
2990 reload()
3039 reload()
2991 \family default
3040 \family default
2992 function, so you don't need to change anything to use it).
3041 function, so you don't need to change anything to use it).
2993
3042
2994 \family typewriter
3043 \family typewriter
2995 deep_reload()
3044 deep_reload()
2996 \family default
3045 \family default
2997 forces a full reload of modules whose code may have changed, which the
3046 forces a full reload of modules whose code may have changed, which the
2998 default
3047 default
2999 \family typewriter
3048 \family typewriter
3000 reload()
3049 reload()
3001 \family default
3050 \family default
3002 function does not.
3051 function does not.
3003 \layout List
3052 \layout List
3004 \labelwidthstring 00.00.0000
3053 \labelwidthstring 00.00.0000
3005
3054
3006 \SpecialChar ~
3055 \SpecialChar ~
3007 When deep_reload is off, IPython will use the normal
3056 When deep_reload is off, IPython will use the normal
3008 \family typewriter
3057 \family typewriter
3009 reload()
3058 reload()
3010 \family default
3059 \family default
3011 , but deep_reload will still be available as
3060 , but deep_reload will still be available as
3012 \family typewriter
3061 \family typewriter
3013 dreload()
3062 dreload()
3014 \family default
3063 \family default
3015 .
3064 .
3016 This feature is off by default [which means that you have both normal
3065 This feature is off by default [which means that you have both normal
3017 \family typewriter
3066 \family typewriter
3018 reload()
3067 reload()
3019 \family default
3068 \family default
3020 and
3069 and
3021 \family typewriter
3070 \family typewriter
3022 dreload()
3071 dreload()
3023 \family default
3072 \family default
3024 ].
3073 ].
3025 \layout List
3074 \layout List
3026 \labelwidthstring 00.00.0000
3075 \labelwidthstring 00.00.0000
3027
3076
3028
3077
3029 \family typewriter
3078 \family typewriter
3030 \series bold
3079 \series bold
3031 -editor\SpecialChar ~
3080 -editor\SpecialChar ~
3032 <name>
3081 <name>
3033 \family default
3082 \family default
3034 \series default
3083 \series default
3035 : Which editor to use with the
3084 : Which editor to use with the
3036 \family typewriter
3085 \family typewriter
3037 %edit
3086 %edit
3038 \family default
3087 \family default
3039 command.
3088 command.
3040 By default, IPython will honor your
3089 By default, IPython will honor your
3041 \family typewriter
3090 \family typewriter
3042 EDITOR
3091 EDITOR
3043 \family default
3092 \family default
3044 environment variable (if not set, vi is the Unix default and notepad the
3093 environment variable (if not set, vi is the Unix default and notepad the
3045 Windows one).
3094 Windows one).
3046 Since this editor is invoked on the fly by IPython and is meant for editing
3095 Since this editor is invoked on the fly by IPython and is meant for editing
3047 small code snippets, you may want to use a small, lightweight editor here
3096 small code snippets, you may want to use a small, lightweight editor here
3048 (in case your default
3097 (in case your default
3049 \family typewriter
3098 \family typewriter
3050 EDITOR
3099 EDITOR
3051 \family default
3100 \family default
3052 is something like Emacs).
3101 is something like Emacs).
3053 \layout List
3102 \layout List
3054 \labelwidthstring 00.00.0000
3103 \labelwidthstring 00.00.0000
3055
3104
3056
3105
3057 \family typewriter
3106 \family typewriter
3058 \series bold
3107 \series bold
3059 -ipythondir\SpecialChar ~
3108 -ipythondir\SpecialChar ~
3060 <name>
3109 <name>
3061 \series default
3110 \series default
3062 :
3111 :
3063 \family default
3112 \family default
3064 name of your IPython configuration directory
3113 name of your IPython configuration directory
3065 \family typewriter
3114 \family typewriter
3066 IPYTHONDIR
3115 IPYTHONDIR
3067 \family default
3116 \family default
3068 .
3117 .
3069 This can also be specified through the environment variable
3118 This can also be specified through the environment variable
3070 \family typewriter
3119 \family typewriter
3071 IPYTHONDIR
3120 IPYTHONDIR
3072 \family default
3121 \family default
3073 .
3122 .
3074 \layout List
3123 \layout List
3075 \labelwidthstring 00.00.0000
3124 \labelwidthstring 00.00.0000
3076
3125
3077
3126
3078 \family typewriter
3127 \family typewriter
3079 \series bold
3128 \series bold
3080 -log|l
3129 -log|l
3081 \family default
3130 \family default
3082 \series default
3131 \series default
3083 : generate a log file of all input.
3132 : generate a log file of all input.
3084 The file is named
3133 The file is named
3085 \family typewriter
3134 \family typewriter
3086 ipython_log.py
3135 ipython_log.py
3087 \family default
3136 \family default
3088 in your current directory (which prevents logs from multiple IPython sessions
3137 in your current directory (which prevents logs from multiple IPython sessions
3089 from trampling each other).
3138 from trampling each other).
3090 You can use this to later restore a session by loading your logfile as
3139 You can use this to later restore a session by loading your logfile as
3091 a file to be executed with option
3140 a file to be executed with option
3092 \family typewriter
3141 \family typewriter
3093 -logplay
3142 -logplay
3094 \family default
3143 \family default
3095 (see below).
3144 (see below).
3096 \layout List
3145 \layout List
3097 \labelwidthstring 00.00.0000
3146 \labelwidthstring 00.00.0000
3098
3147
3099
3148
3100 \family typewriter
3149 \family typewriter
3101 \series bold
3150 \series bold
3102 -logfile|lf\SpecialChar ~
3151 -logfile|lf\SpecialChar ~
3103 <name>
3152 <name>
3104 \series default
3153 \series default
3105 :
3154 :
3106 \family default
3155 \family default
3107 specify the name of your logfile.
3156 specify the name of your logfile.
3108 \layout List
3157 \layout List
3109 \labelwidthstring 00.00.0000
3158 \labelwidthstring 00.00.0000
3110
3159
3111
3160
3112 \family typewriter
3161 \family typewriter
3113 \series bold
3162 \series bold
3114 -logplay|lp\SpecialChar ~
3163 -logplay|lp\SpecialChar ~
3115 <name>
3164 <name>
3116 \series default
3165 \series default
3117 :
3166 :
3118 \family default
3167 \family default
3119 you can replay a previous log.
3168 you can replay a previous log.
3120 For restoring a session as close as possible to the state you left it in,
3169 For restoring a session as close as possible to the state you left it in,
3121 use this option (don't just run the logfile).
3170 use this option (don't just run the logfile).
3122 With
3171 With
3123 \family typewriter
3172 \family typewriter
3124 -logplay
3173 -logplay
3125 \family default
3174 \family default
3126 , IPython will try to reconstruct the previous working environment in full,
3175 , IPython will try to reconstruct the previous working environment in full,
3127 not just execute the commands in the logfile.
3176 not just execute the commands in the logfile.
3128 \layout List
3177 \layout List
3129 \labelwidthstring 00.00.0000
3178 \labelwidthstring 00.00.0000
3130
3179
3131 \SpecialChar ~
3180 \SpecialChar ~
3132 When a session is restored, logging is automatically turned on again with
3181 When a session is restored, logging is automatically turned on again with
3133 the name of the logfile it was invoked with (it is read from the log header).
3182 the name of the logfile it was invoked with (it is read from the log header).
3134 So once you've turned logging on for a session, you can quit IPython and
3183 So once you've turned logging on for a session, you can quit IPython and
3135 reload it as many times as you want and it will continue to log its history
3184 reload it as many times as you want and it will continue to log its history
3136 and restore from the beginning every time.
3185 and restore from the beginning every time.
3137 \layout List
3186 \layout List
3138 \labelwidthstring 00.00.0000
3187 \labelwidthstring 00.00.0000
3139
3188
3140 \SpecialChar ~
3189 \SpecialChar ~
3141 Caveats: there are limitations in this option.
3190 Caveats: there are limitations in this option.
3142 The history variables
3191 The history variables
3143 \family typewriter
3192 \family typewriter
3144 _i*
3193 _i*
3145 \family default
3194 \family default
3146 ,
3195 ,
3147 \family typewriter
3196 \family typewriter
3148 _*
3197 _*
3149 \family default
3198 \family default
3150 and
3199 and
3151 \family typewriter
3200 \family typewriter
3152 _dh
3201 _dh
3153 \family default
3202 \family default
3154 don't get restored properly.
3203 don't get restored properly.
3155 In the future we will try to implement full session saving by writing and
3204 In the future we will try to implement full session saving by writing and
3156 retrieving a 'snapshot' of the memory state of IPython.
3205 retrieving a 'snapshot' of the memory state of IPython.
3157 But our first attempts failed because of inherent limitations of Python's
3206 But our first attempts failed because of inherent limitations of Python's
3158 Pickle module, so this may have to wait.
3207 Pickle module, so this may have to wait.
3159 \layout List
3208 \layout List
3160 \labelwidthstring 00.00.0000
3209 \labelwidthstring 00.00.0000
3161
3210
3162
3211
3163 \family typewriter
3212 \family typewriter
3164 \series bold
3213 \series bold
3165 -[no]messages
3214 -[no]messages
3166 \series default
3215 \series default
3167 :
3216 :
3168 \family default
3217 \family default
3169 Print messages which IPython collects about its startup process (default
3218 Print messages which IPython collects about its startup process (default
3170 on).
3219 on).
3171 \layout List
3220 \layout List
3172 \labelwidthstring 00.00.0000
3221 \labelwidthstring 00.00.0000
3173
3222
3174
3223
3175 \family typewriter
3224 \family typewriter
3176 \series bold
3225 \series bold
3177 -[no]pdb
3226 -[no]pdb
3178 \family default
3227 \family default
3179 \series default
3228 \series default
3180 : Automatically call the pdb debugger after every uncaught exception.
3229 : Automatically call the pdb debugger after every uncaught exception.
3181 If you are used to debugging using pdb, this puts you automatically inside
3230 If you are used to debugging using pdb, this puts you automatically inside
3182 of it after any call (either in IPython or in code called by it) which
3231 of it after any call (either in IPython or in code called by it) which
3183 triggers an exception which goes uncaught.
3232 triggers an exception which goes uncaught.
3184 \layout List
3233 \layout List
3185 \labelwidthstring 00.00.0000
3234 \labelwidthstring 00.00.0000
3186
3235
3187
3236
3188 \family typewriter
3237 \family typewriter
3189 \series bold
3238 \series bold
3190 -[no]pprint
3239 -[no]pprint
3191 \series default
3240 \series default
3192 :
3241 :
3193 \family default
3242 \family default
3194 ipython can optionally use the pprint (pretty printer) module for displaying
3243 ipython can optionally use the pprint (pretty printer) module for displaying
3195 results.
3244 results.
3196 pprint tends to give a nicer display of nested data structures.
3245 pprint tends to give a nicer display of nested data structures.
3197 If you like it, you can turn it on permanently in your config file (default
3246 If you like it, you can turn it on permanently in your config file (default
3198 off).
3247 off).
3199 \layout List
3248 \layout List
3200 \labelwidthstring 00.00.0000
3249 \labelwidthstring 00.00.0000
3201
3250
3202
3251
3203 \family typewriter
3252 \family typewriter
3204 \series bold
3253 \series bold
3205 -profile|p <name>
3254 -profile|p <name>
3206 \series default
3255 \series default
3207 :
3256 :
3208 \family default
3257 \family default
3209 assume that your config file is
3258 assume that your config file is
3210 \family typewriter
3259 \family typewriter
3211 ipythonrc-<name>
3260 ipythonrc-<name>
3212 \family default
3261 \family default
3213 (looks in current dir first, then in
3262 (looks in current dir first, then in
3214 \family typewriter
3263 \family typewriter
3215 IPYTHONDIR
3264 IPYTHONDIR
3216 \family default
3265 \family default
3217 ).
3266 ).
3218 This is a quick way to keep and load multiple config files for different
3267 This is a quick way to keep and load multiple config files for different
3219 tasks, especially if you use the include option of config files.
3268 tasks, especially if you use the include option of config files.
3220 You can keep a basic
3269 You can keep a basic
3221 \family typewriter
3270 \family typewriter
3222 IPYTHONDIR/ipythonrc
3271 IPYTHONDIR/ipythonrc
3223 \family default
3272 \family default
3224 file and then have other 'profiles' which include this one and load extra
3273 file and then have other 'profiles' which include this one and load extra
3225 things for particular tasks.
3274 things for particular tasks.
3226 For example:
3275 For example:
3227 \layout List
3276 \layout List
3228 \labelwidthstring 00.00.0000
3277 \labelwidthstring 00.00.0000
3229
3278
3230
3279
3231 \family typewriter
3280 \family typewriter
3232 \SpecialChar ~
3281 \SpecialChar ~
3233
3282
3234 \family default
3283 \family default
3235 1.
3284 1.
3236
3285
3237 \family typewriter
3286 \family typewriter
3238 $HOME/.ipython/ipythonrc
3287 $HOME/.ipython/ipythonrc
3239 \family default
3288 \family default
3240 : load basic things you always want.
3289 : load basic things you always want.
3241 \layout List
3290 \layout List
3242 \labelwidthstring 00.00.0000
3291 \labelwidthstring 00.00.0000
3243
3292
3244
3293
3245 \family typewriter
3294 \family typewriter
3246 \SpecialChar ~
3295 \SpecialChar ~
3247
3296
3248 \family default
3297 \family default
3249 2.
3298 2.
3250
3299
3251 \family typewriter
3300 \family typewriter
3252 $HOME/.ipython/ipythonrc-math
3301 $HOME/.ipython/ipythonrc-math
3253 \family default
3302 \family default
3254 : load (1) and basic math-related modules.
3303 : load (1) and basic math-related modules.
3255
3304
3256 \layout List
3305 \layout List
3257 \labelwidthstring 00.00.0000
3306 \labelwidthstring 00.00.0000
3258
3307
3259
3308
3260 \family typewriter
3309 \family typewriter
3261 \SpecialChar ~
3310 \SpecialChar ~
3262
3311
3263 \family default
3312 \family default
3264 3.
3313 3.
3265
3314
3266 \family typewriter
3315 \family typewriter
3267 $HOME/.ipython/ipythonrc-numeric
3316 $HOME/.ipython/ipythonrc-numeric
3268 \family default
3317 \family default
3269 : load (1) and Numeric and plotting modules.
3318 : load (1) and Numeric and plotting modules.
3270 \layout List
3319 \layout List
3271 \labelwidthstring 00.00.0000
3320 \labelwidthstring 00.00.0000
3272
3321
3273 \SpecialChar ~
3322 \SpecialChar ~
3274 Since it is possible to create an endless loop by having circular file
3323 Since it is possible to create an endless loop by having circular file
3275 inclusions, IPython will stop if it reaches 15 recursive inclusions.
3324 inclusions, IPython will stop if it reaches 15 recursive inclusions.
3276 \layout List
3325 \layout List
3277 \labelwidthstring 00.00.0000
3326 \labelwidthstring 00.00.0000
3278
3327
3279
3328
3280 \family typewriter
3329 \family typewriter
3281 \series bold
3330 \series bold
3282 -prompt_in1|pi1\SpecialChar ~
3331 -prompt_in1|pi1\SpecialChar ~
3283 <string>:
3332 <string>:
3284 \family default
3333 \family default
3285 \series default
3334 \series default
3286 Specify the string used for input prompts.
3335 Specify the string used for input prompts.
3287 Note that if you are using numbered prompts, the number is represented
3336 Note that if you are using numbered prompts, the number is represented
3288 with a '
3337 with a '
3289 \backslash
3338 \backslash
3290 #' in the string.
3339 #' in the string.
3291 Don't forget to quote strings with spaces embedded in them.
3340 Don't forget to quote strings with spaces embedded in them.
3292 Default: '
3341 Default: '
3293 \family typewriter
3342 \family typewriter
3294 In\SpecialChar ~
3343 In\SpecialChar ~
3295 [
3344 [
3296 \backslash
3345 \backslash
3297 #]:
3346 #]:
3298 \family default
3347 \family default
3299 '.
3348 '.
3300 Sec.\SpecialChar ~
3349 Sec.\SpecialChar ~
3301
3350
3302 \begin_inset LatexCommand \ref{sec:prompts}
3351 \begin_inset LatexCommand \ref{sec:prompts}
3303
3352
3304 \end_inset
3353 \end_inset
3305
3354
3306 discusses in detail all the available escapes to customize your prompts.
3355 discusses in detail all the available escapes to customize your prompts.
3307 \layout List
3356 \layout List
3308 \labelwidthstring 00.00.0000
3357 \labelwidthstring 00.00.0000
3309
3358
3310
3359
3311 \family typewriter
3360 \family typewriter
3312 \series bold
3361 \series bold
3313 -prompt_in2|pi2\SpecialChar ~
3362 -prompt_in2|pi2\SpecialChar ~
3314 <string>:
3363 <string>:
3315 \family default
3364 \family default
3316 \series default
3365 \series default
3317 Similar to the previous option, but used for the continuation prompts.
3366 Similar to the previous option, but used for the continuation prompts.
3318 The special sequence '
3367 The special sequence '
3319 \family typewriter
3368 \family typewriter
3320
3369
3321 \backslash
3370 \backslash
3322 D
3371 D
3323 \family default
3372 \family default
3324 ' is similar to '
3373 ' is similar to '
3325 \family typewriter
3374 \family typewriter
3326
3375
3327 \backslash
3376 \backslash
3328 #
3377 #
3329 \family default
3378 \family default
3330 ', but with all digits replaced dots (so you can have your continuation
3379 ', but with all digits replaced dots (so you can have your continuation
3331 prompt aligned with your input prompt).
3380 prompt aligned with your input prompt).
3332 Default: '
3381 Default: '
3333 \family typewriter
3382 \family typewriter
3334 \SpecialChar ~
3383 \SpecialChar ~
3335 \SpecialChar ~
3384 \SpecialChar ~
3336 \SpecialChar ~
3385 \SpecialChar ~
3337 .
3386 .
3338 \backslash
3387 \backslash
3339 D.:
3388 D.:
3340 \family default
3389 \family default
3341 ' (note three spaces at the start for alignment with '
3390 ' (note three spaces at the start for alignment with '
3342 \family typewriter
3391 \family typewriter
3343 In\SpecialChar ~
3392 In\SpecialChar ~
3344 [
3393 [
3345 \backslash
3394 \backslash
3346 #]
3395 #]
3347 \family default
3396 \family default
3348 ').
3397 ').
3349 \layout List
3398 \layout List
3350 \labelwidthstring 00.00.0000
3399 \labelwidthstring 00.00.0000
3351
3400
3352
3401
3353 \family typewriter
3402 \family typewriter
3354 \series bold
3403 \series bold
3355 -prompt_out|po\SpecialChar ~
3404 -prompt_out|po\SpecialChar ~
3356 <string>:
3405 <string>:
3357 \family default
3406 \family default
3358 \series default
3407 \series default
3359 String used for output prompts, also uses numbers like
3408 String used for output prompts, also uses numbers like
3360 \family typewriter
3409 \family typewriter
3361 prompt_in1
3410 prompt_in1
3362 \family default
3411 \family default
3363 .
3412 .
3364 Default: '
3413 Default: '
3365 \family typewriter
3414 \family typewriter
3366 Out[
3415 Out[
3367 \backslash
3416 \backslash
3368 #]:
3417 #]:
3369 \family default
3418 \family default
3370 '
3419 '
3371 \layout List
3420 \layout List
3372 \labelwidthstring 00.00.0000
3421 \labelwidthstring 00.00.0000
3373
3422
3374
3423
3375 \family typewriter
3424 \family typewriter
3376 \series bold
3425 \series bold
3377 -quick
3426 -quick
3378 \family default
3427 \family default
3379 \series default
3428 \series default
3380 : start in bare bones mode (no config file loaded).
3429 : start in bare bones mode (no config file loaded).
3381 \layout List
3430 \layout List
3382 \labelwidthstring 00.00.0000
3431 \labelwidthstring 00.00.0000
3383
3432
3384
3433
3385 \family typewriter
3434 \family typewriter
3386 \series bold
3435 \series bold
3387 -rcfile\SpecialChar ~
3436 -rcfile\SpecialChar ~
3388 <name>
3437 <name>
3389 \series default
3438 \series default
3390 :
3439 :
3391 \family default
3440 \family default
3392 name of your IPython resource configuration file.
3441 name of your IPython resource configuration file.
3393 Normally IPython loads ipythonrc (from current directory) or
3442 Normally IPython loads ipythonrc (from current directory) or
3394 \family typewriter
3443 \family typewriter
3395 IPYTHONDIR/ipythonrc
3444 IPYTHONDIR/ipythonrc
3396 \family default
3445 \family default
3397 .
3446 .
3398 \layout List
3447 \layout List
3399 \labelwidthstring 00.00.0000
3448 \labelwidthstring 00.00.0000
3400
3449
3401 \SpecialChar ~
3450 \SpecialChar ~
3402 If the loading of your config file fails, IPython starts with a bare bones
3451 If the loading of your config file fails, IPython starts with a bare bones
3403 configuration (no modules loaded at all).
3452 configuration (no modules loaded at all).
3404 \layout List
3453 \layout List
3405 \labelwidthstring 00.00.0000
3454 \labelwidthstring 00.00.0000
3406
3455
3407
3456
3408 \family typewriter
3457 \family typewriter
3409 \series bold
3458 \series bold
3410 -[no]readline
3459 -[no]readline
3411 \family default
3460 \family default
3412 \series default
3461 \series default
3413 : use the readline library, which is needed to support name completion and
3462 : use the readline library, which is needed to support name completion and
3414 command history, among other things.
3463 command history, among other things.
3415 It is enabled by default, but may cause problems for users of X/Emacs in
3464 It is enabled by default, but may cause problems for users of X/Emacs in
3416 Python comint or shell buffers.
3465 Python comint or shell buffers.
3417 \layout List
3466 \layout List
3418 \labelwidthstring 00.00.0000
3467 \labelwidthstring 00.00.0000
3419
3468
3420 \SpecialChar ~
3469 \SpecialChar ~
3421 Note that X/Emacs 'eterm' buffers (opened with
3470 Note that X/Emacs 'eterm' buffers (opened with
3422 \family typewriter
3471 \family typewriter
3423 M-x\SpecialChar ~
3472 M-x\SpecialChar ~
3424 term
3473 term
3425 \family default
3474 \family default
3426 ) support IPython's readline and syntax coloring fine, only 'emacs' (
3475 ) support IPython's readline and syntax coloring fine, only 'emacs' (
3427 \family typewriter
3476 \family typewriter
3428 M-x\SpecialChar ~
3477 M-x\SpecialChar ~
3429 shell
3478 shell
3430 \family default
3479 \family default
3431 and
3480 and
3432 \family typewriter
3481 \family typewriter
3433 C-c\SpecialChar ~
3482 C-c\SpecialChar ~
3434 !
3483 !
3435 \family default
3484 \family default
3436 ) buffers do not.
3485 ) buffers do not.
3437 \layout List
3486 \layout List
3438 \labelwidthstring 00.00.0000
3487 \labelwidthstring 00.00.0000
3439
3488
3440
3489
3441 \family typewriter
3490 \family typewriter
3442 \series bold
3491 \series bold
3443 -screen_length|sl\SpecialChar ~
3492 -screen_length|sl\SpecialChar ~
3444 <n>
3493 <n>
3445 \series default
3494 \series default
3446 :
3495 :
3447 \family default
3496 \family default
3448 number of lines of your screen.
3497 number of lines of your screen.
3449 This is used to control printing of very long strings.
3498 This is used to control printing of very long strings.
3450 Strings longer than this number of lines will be sent through a pager instead
3499 Strings longer than this number of lines will be sent through a pager instead
3451 of directly printed.
3500 of directly printed.
3452 \layout List
3501 \layout List
3453 \labelwidthstring 00.00.0000
3502 \labelwidthstring 00.00.0000
3454
3503
3455 \SpecialChar ~
3504 \SpecialChar ~
3456 The default value for this is 0, which means IPython will auto-detect your
3505 The default value for this is 0, which means IPython will auto-detect your
3457 screen size every time it needs to print certain potentially long strings
3506 screen size every time it needs to print certain potentially long strings
3458 (this doesn't change the behavior of the 'print' keyword, it's only triggered
3507 (this doesn't change the behavior of the 'print' keyword, it's only triggered
3459 internally).
3508 internally).
3460 If for some reason this isn't working well (it needs curses support), specify
3509 If for some reason this isn't working well (it needs curses support), specify
3461 it yourself.
3510 it yourself.
3462 Otherwise don't change the default.
3511 Otherwise don't change the default.
3463 \layout List
3512 \layout List
3464 \labelwidthstring 00.00.0000
3513 \labelwidthstring 00.00.0000
3465
3514
3466
3515
3467 \family typewriter
3516 \family typewriter
3468 \series bold
3517 \series bold
3469 -separate_in|si\SpecialChar ~
3518 -separate_in|si\SpecialChar ~
3470 <string>
3519 <string>
3471 \series default
3520 \series default
3472 :
3521 :
3473 \family default
3522 \family default
3474 separator before input prompts.
3523 separator before input prompts.
3475 Default: '
3524 Default: '
3476 \family typewriter
3525 \family typewriter
3477
3526
3478 \backslash
3527 \backslash
3479 n
3528 n
3480 \family default
3529 \family default
3481 '
3530 '
3482 \layout List
3531 \layout List
3483 \labelwidthstring 00.00.0000
3532 \labelwidthstring 00.00.0000
3484
3533
3485
3534
3486 \family typewriter
3535 \family typewriter
3487 \series bold
3536 \series bold
3488 -separate_out|so\SpecialChar ~
3537 -separate_out|so\SpecialChar ~
3489 <string>
3538 <string>
3490 \family default
3539 \family default
3491 \series default
3540 \series default
3492 : separator before output prompts.
3541 : separator before output prompts.
3493 Default: nothing.
3542 Default: nothing.
3494 \layout List
3543 \layout List
3495 \labelwidthstring 00.00.0000
3544 \labelwidthstring 00.00.0000
3496
3545
3497
3546
3498 \family typewriter
3547 \family typewriter
3499 \series bold
3548 \series bold
3500 -separate_out2|so2\SpecialChar ~
3549 -separate_out2|so2\SpecialChar ~
3501 <string>
3550 <string>
3502 \series default
3551 \series default
3503 :
3552 :
3504 \family default
3553 \family default
3505 separator after output prompts.
3554 separator after output prompts.
3506 Default: nothing.
3555 Default: nothing.
3507 \layout List
3556 \layout List
3508 \labelwidthstring 00.00.0000
3557 \labelwidthstring 00.00.0000
3509
3558
3510 \SpecialChar ~
3559 \SpecialChar ~
3511 For these three options, use the value 0 to specify no separator.
3560 For these three options, use the value 0 to specify no separator.
3512 \layout List
3561 \layout List
3513 \labelwidthstring 00.00.0000
3562 \labelwidthstring 00.00.0000
3514
3563
3515
3564
3516 \family typewriter
3565 \family typewriter
3517 \series bold
3566 \series bold
3518 -nosep
3567 -nosep
3519 \series default
3568 \series default
3520 :
3569 :
3521 \family default
3570 \family default
3522 shorthand for
3571 shorthand for
3523 \family typewriter
3572 \family typewriter
3524 '-SeparateIn 0 -SeparateOut 0 -SeparateOut2 0'
3573 '-SeparateIn 0 -SeparateOut 0 -SeparateOut2 0'
3525 \family default
3574 \family default
3526 .
3575 .
3527 Simply removes all input/output separators.
3576 Simply removes all input/output separators.
3528 \layout List
3577 \layout List
3529 \labelwidthstring 00.00.0000
3578 \labelwidthstring 00.00.0000
3530
3579
3531
3580
3532 \family typewriter
3581 \family typewriter
3533 \series bold
3582 \series bold
3534 -upgrade
3583 -upgrade
3535 \family default
3584 \family default
3536 \series default
3585 \series default
3537 : allows you to upgrade your
3586 : allows you to upgrade your
3538 \family typewriter
3587 \family typewriter
3539 IPYTHONDIR
3588 IPYTHONDIR
3540 \family default
3589 \family default
3541 configuration when you install a new version of IPython.
3590 configuration when you install a new version of IPython.
3542 Since new versions may include new command line options or example files,
3591 Since new versions may include new command line options or example files,
3543 this copies updated ipythonrc-type files.
3592 this copies updated ipythonrc-type files.
3544 However, it backs up (with a
3593 However, it backs up (with a
3545 \family typewriter
3594 \family typewriter
3546 .old
3595 .old
3547 \family default
3596 \family default
3548 extension) all files which it overwrites so that you can merge back any
3597 extension) all files which it overwrites so that you can merge back any
3549 customizations you might have in your personal files.
3598 customizations you might have in your personal files.
3550 \layout List
3599 \layout List
3551 \labelwidthstring 00.00.0000
3600 \labelwidthstring 00.00.0000
3552
3601
3553
3602
3554 \family typewriter
3603 \family typewriter
3555 \series bold
3604 \series bold
3556 -Version
3605 -Version
3557 \series default
3606 \series default
3558 :
3607 :
3559 \family default
3608 \family default
3560 print version information and exit.
3609 print version information and exit.
3561 \layout List
3610 \layout List
3562 \labelwidthstring 00.00.0000
3611 \labelwidthstring 00.00.0000
3563
3612
3564
3613
3565 \family typewriter
3614 \family typewriter
3566 \series bold
3615 \series bold
3567 -wxversion\SpecialChar ~
3616 -wxversion\SpecialChar ~
3568 <string>:
3617 <string>:
3569 \family default
3618 \family default
3570 \series default
3619 \series default
3571 Select a specific version of wxPython (used in conjunction with
3620 Select a specific version of wxPython (used in conjunction with
3572 \family typewriter
3621 \family typewriter
3573 -wthread
3622 -wthread
3574 \family default
3623 \family default
3575 ).
3624 ).
3576 Requires the wxversion module, part of recent wxPython distributions
3625 Requires the wxversion module, part of recent wxPython distributions
3577 \layout List
3626 \layout List
3578 \labelwidthstring 00.00.0000
3627 \labelwidthstring 00.00.0000
3579
3628
3580
3629
3581 \family typewriter
3630 \family typewriter
3582 \series bold
3631 \series bold
3583 -xmode\SpecialChar ~
3632 -xmode\SpecialChar ~
3584 <modename>
3633 <modename>
3585 \series default
3634 \series default
3586 :
3635 :
3587 \family default
3636 \family default
3588 Mode for exception reporting.
3637 Mode for exception reporting.
3589 \layout List
3638 \layout List
3590 \labelwidthstring 00.00.0000
3639 \labelwidthstring 00.00.0000
3591
3640
3592 \SpecialChar ~
3641 \SpecialChar ~
3593 Valid modes: Plain, Context and Verbose.
3642 Valid modes: Plain, Context and Verbose.
3594 \layout List
3643 \layout List
3595 \labelwidthstring 00.00.0000
3644 \labelwidthstring 00.00.0000
3596
3645
3597 \SpecialChar ~
3646 \SpecialChar ~
3598 Plain: similar to python's normal traceback printing.
3647 Plain: similar to python's normal traceback printing.
3599 \layout List
3648 \layout List
3600 \labelwidthstring 00.00.0000
3649 \labelwidthstring 00.00.0000
3601
3650
3602 \SpecialChar ~
3651 \SpecialChar ~
3603 Context: prints 5 lines of context source code around each line in the
3652 Context: prints 5 lines of context source code around each line in the
3604 traceback.
3653 traceback.
3605 \layout List
3654 \layout List
3606 \labelwidthstring 00.00.0000
3655 \labelwidthstring 00.00.0000
3607
3656
3608 \SpecialChar ~
3657 \SpecialChar ~
3609 Verbose: similar to Context, but additionally prints the variables currently
3658 Verbose: similar to Context, but additionally prints the variables currently
3610 visible where the exception happened (shortening their strings if too long).
3659 visible where the exception happened (shortening their strings if too long).
3611 This can potentially be very slow, if you happen to have a huge data structure
3660 This can potentially be very slow, if you happen to have a huge data structure
3612 whose string representation is complex to compute.
3661 whose string representation is complex to compute.
3613 Your computer may appear to freeze for a while with cpu usage at 100%.
3662 Your computer may appear to freeze for a while with cpu usage at 100%.
3614 If this occurs, you can cancel the traceback with Ctrl-C (maybe hitting
3663 If this occurs, you can cancel the traceback with Ctrl-C (maybe hitting
3615 it more than once).
3664 it more than once).
3616 \layout Section
3665 \layout Section
3617
3666
3618 Interactive use
3667 Interactive use
3619 \layout Standard
3668 \layout Standard
3620
3669
3621
3670
3622 \series bold
3671 \series bold
3623 Warning
3672 Warning
3624 \series default
3673 \series default
3625 : IPython relies on the existence of a global variable called
3674 : IPython relies on the existence of a global variable called
3626 \family typewriter
3675 \family typewriter
3627 __IP
3676 __IP
3628 \family default
3677 \family default
3629 which controls the shell itself.
3678 which controls the shell itself.
3630 If you redefine
3679 If you redefine
3631 \family typewriter
3680 \family typewriter
3632 __IP
3681 __IP
3633 \family default
3682 \family default
3634 to anything, bizarre behavior will quickly occur.
3683 to anything, bizarre behavior will quickly occur.
3635 \layout Standard
3684 \layout Standard
3636
3685
3637 Other than the above warning, IPython is meant to work as a drop-in replacement
3686 Other than the above warning, IPython is meant to work as a drop-in replacement
3638 for the standard interactive interpreter.
3687 for the standard interactive interpreter.
3639 As such, any code which is valid python should execute normally under IPython
3688 As such, any code which is valid python should execute normally under IPython
3640 (cases where this is not true should be reported as bugs).
3689 (cases where this is not true should be reported as bugs).
3641 It does, however, offer many features which are not available at a standard
3690 It does, however, offer many features which are not available at a standard
3642 python prompt.
3691 python prompt.
3643 What follows is a list of these.
3692 What follows is a list of these.
3644 \layout Subsection
3693 \layout Subsection
3645
3694
3646 Caution for Windows users
3695 Caution for Windows users
3647 \layout Standard
3696 \layout Standard
3648
3697
3649 Windows, unfortunately, uses the `
3698 Windows, unfortunately, uses the `
3650 \family typewriter
3699 \family typewriter
3651
3700
3652 \backslash
3701 \backslash
3653
3702
3654 \family default
3703 \family default
3655 ' character as a path separator.
3704 ' character as a path separator.
3656 This is a terrible choice, because `
3705 This is a terrible choice, because `
3657 \family typewriter
3706 \family typewriter
3658
3707
3659 \backslash
3708 \backslash
3660
3709
3661 \family default
3710 \family default
3662 ' also represents the escape character in most modern programming languages,
3711 ' also represents the escape character in most modern programming languages,
3663 including Python.
3712 including Python.
3664 For this reason, issuing many of the commands discussed below (especially
3713 For this reason, issuing many of the commands discussed below (especially
3665 magics which affect the filesystem) with `
3714 magics which affect the filesystem) with `
3666 \family typewriter
3715 \family typewriter
3667
3716
3668 \backslash
3717 \backslash
3669
3718
3670 \family default
3719 \family default
3671 ' in them will cause strange errors.
3720 ' in them will cause strange errors.
3672 \layout Standard
3721 \layout Standard
3673
3722
3674 A partial solution is to use instead the `
3723 A partial solution is to use instead the `
3675 \family typewriter
3724 \family typewriter
3676 /
3725 /
3677 \family default
3726 \family default
3678 ' character as a path separator, which Windows recognizes in
3727 ' character as a path separator, which Windows recognizes in
3679 \emph on
3728 \emph on
3680 most
3729 most
3681 \emph default
3730 \emph default
3682 situations.
3731 situations.
3683 However, in Windows commands `
3732 However, in Windows commands `
3684 \family typewriter
3733 \family typewriter
3685 /
3734 /
3686 \family default
3735 \family default
3687 ' flags options, so you can not use it for the root directory.
3736 ' flags options, so you can not use it for the root directory.
3688 This means that paths beginning at the root must be typed in a contrived
3737 This means that paths beginning at the root must be typed in a contrived
3689 manner like:
3738 manner like:
3690 \newline
3739 \newline
3691
3740
3692 \family typewriter
3741 \family typewriter
3693 %copy
3742 %copy
3694 \backslash
3743 \backslash
3695 opt/foo/bar.txt
3744 opt/foo/bar.txt
3696 \backslash
3745 \backslash
3697 tmp
3746 tmp
3698 \layout Standard
3747 \layout Standard
3699
3748
3700 There is no sensible thing IPython can do to truly work around this flaw
3749 There is no sensible thing IPython can do to truly work around this flaw
3701 in Windows
3750 in Windows
3702 \begin_inset Foot
3751 \begin_inset Foot
3703 collapsed true
3752 collapsed true
3704
3753
3705 \layout Standard
3754 \layout Standard
3706
3755
3707 If anyone comes up with a
3756 If anyone comes up with a
3708 \emph on
3757 \emph on
3709 clean
3758 clean
3710 \emph default
3759 \emph default
3711 solution which works consistently and does not negatively impact other
3760 solution which works consistently and does not negatively impact other
3712 platforms at all, I'll gladly accept a patch.
3761 platforms at all, I'll gladly accept a patch.
3713 \end_inset
3762 \end_inset
3714
3763
3715 .
3764 .
3716 \layout Subsection
3765 \layout Subsection
3717
3766
3718
3767
3719 \begin_inset LatexCommand \label{sec:magic}
3768 \begin_inset LatexCommand \label{sec:magic}
3720
3769
3721 \end_inset
3770 \end_inset
3722
3771
3723 Magic command system
3772 Magic command system
3724 \layout Standard
3773 \layout Standard
3725
3774
3726 IPython will treat any line whose first character is a
3775 IPython will treat any line whose first character is a
3727 \family typewriter
3776 \family typewriter
3728 %
3777 %
3729 \family default
3778 \family default
3730 as a special call to a 'magic' function.
3779 as a special call to a 'magic' function.
3731 These allow you to control the behavior of IPython itself, plus a lot of
3780 These allow you to control the behavior of IPython itself, plus a lot of
3732 system-type features.
3781 system-type features.
3733 They are all prefixed with a
3782 They are all prefixed with a
3734 \family typewriter
3783 \family typewriter
3735 %
3784 %
3736 \family default
3785 \family default
3737 character, but parameters are given without parentheses or quotes.
3786 character, but parameters are given without parentheses or quotes.
3738 \layout Standard
3787 \layout Standard
3739
3788
3740 Example: typing
3789 Example: typing
3741 \family typewriter
3790 \family typewriter
3742 '%cd mydir'
3791 '%cd mydir'
3743 \family default
3792 \family default
3744 (without the quotes) changes you working directory to
3793 (without the quotes) changes you working directory to
3745 \family typewriter
3794 \family typewriter
3746 'mydir'
3795 'mydir'
3747 \family default
3796 \family default
3748 , if it exists.
3797 , if it exists.
3749 \layout Standard
3798 \layout Standard
3750
3799
3751 If you have 'automagic' enabled (in your
3800 If you have 'automagic' enabled (in your
3752 \family typewriter
3801 \family typewriter
3753 ipythonrc
3802 ipythonrc
3754 \family default
3803 \family default
3755 file, via the command line option
3804 file, via the command line option
3756 \family typewriter
3805 \family typewriter
3757 -automagic
3806 -automagic
3758 \family default
3807 \family default
3759 or with the
3808 or with the
3760 \family typewriter
3809 \family typewriter
3761 %automagic
3810 %automagic
3762 \family default
3811 \family default
3763 function), you don't need to type in the
3812 function), you don't need to type in the
3764 \family typewriter
3813 \family typewriter
3765 %
3814 %
3766 \family default
3815 \family default
3767 explicitly.
3816 explicitly.
3768 IPython will scan its internal list of magic functions and call one if
3817 IPython will scan its internal list of magic functions and call one if
3769 it exists.
3818 it exists.
3770 With automagic on you can then just type '
3819 With automagic on you can then just type '
3771 \family typewriter
3820 \family typewriter
3772 cd mydir
3821 cd mydir
3773 \family default
3822 \family default
3774 ' to go to directory '
3823 ' to go to directory '
3775 \family typewriter
3824 \family typewriter
3776 mydir
3825 mydir
3777 \family default
3826 \family default
3778 '.
3827 '.
3779 The automagic system has the lowest possible precedence in name searches,
3828 The automagic system has the lowest possible precedence in name searches,
3780 so defining an identifier with the same name as an existing magic function
3829 so defining an identifier with the same name as an existing magic function
3781 will shadow it for automagic use.
3830 will shadow it for automagic use.
3782 You can still access the shadowed magic function by explicitly using the
3831 You can still access the shadowed magic function by explicitly using the
3783
3832
3784 \family typewriter
3833 \family typewriter
3785 %
3834 %
3786 \family default
3835 \family default
3787 character at the beginning of the line.
3836 character at the beginning of the line.
3788 \layout Standard
3837 \layout Standard
3789
3838
3790 An example (with automagic on) should clarify all this:
3839 An example (with automagic on) should clarify all this:
3791 \layout LyX-Code
3840 \layout LyX-Code
3792
3841
3793 In [1]: cd ipython # %cd is called by automagic
3842 In [1]: cd ipython # %cd is called by automagic
3794 \layout LyX-Code
3843 \layout LyX-Code
3795
3844
3796 /home/fperez/ipython
3845 /home/fperez/ipython
3797 \layout LyX-Code
3846 \layout LyX-Code
3798
3847
3799 In [2]: cd=1 # now cd is just a variable
3848 In [2]: cd=1 # now cd is just a variable
3800 \layout LyX-Code
3849 \layout LyX-Code
3801
3850
3802 In [3]: cd ..
3851 In [3]: cd ..
3803 # and doesn't work as a function anymore
3852 # and doesn't work as a function anymore
3804 \layout LyX-Code
3853 \layout LyX-Code
3805
3854
3806 ------------------------------------------------------------
3855 ------------------------------------------------------------
3807 \layout LyX-Code
3856 \layout LyX-Code
3808
3857
3809 File "<console>", line 1
3858 File "<console>", line 1
3810 \layout LyX-Code
3859 \layout LyX-Code
3811
3860
3812 cd ..
3861 cd ..
3813 \layout LyX-Code
3862 \layout LyX-Code
3814
3863
3815 ^
3864 ^
3816 \layout LyX-Code
3865 \layout LyX-Code
3817
3866
3818 SyntaxError: invalid syntax
3867 SyntaxError: invalid syntax
3819 \layout LyX-Code
3868 \layout LyX-Code
3820
3869
3821 \layout LyX-Code
3870 \layout LyX-Code
3822
3871
3823 In [4]: %cd ..
3872 In [4]: %cd ..
3824 # but %cd always works
3873 # but %cd always works
3825 \layout LyX-Code
3874 \layout LyX-Code
3826
3875
3827 /home/fperez
3876 /home/fperez
3828 \layout LyX-Code
3877 \layout LyX-Code
3829
3878
3830 In [5]: del cd # if you remove the cd variable
3879 In [5]: del cd # if you remove the cd variable
3831 \layout LyX-Code
3880 \layout LyX-Code
3832
3881
3833 In [6]: cd ipython # automagic can work again
3882 In [6]: cd ipython # automagic can work again
3834 \layout LyX-Code
3883 \layout LyX-Code
3835
3884
3836 /home/fperez/ipython
3885 /home/fperez/ipython
3837 \layout Standard
3886 \layout Standard
3838
3887
3839 You can define your own magic functions to extend the system.
3888 You can define your own magic functions to extend the system.
3840 The following is a snippet of code which shows how to do it.
3889 The following is a snippet of code which shows how to do it.
3841 It is provided as file
3890 It is provided as file
3842 \family typewriter
3891 \family typewriter
3843 example-magic.py
3892 example-magic.py
3844 \family default
3893 \family default
3845 in the examples directory:
3894 in the examples directory:
3846 \layout Standard
3895 \layout Standard
3847
3896
3848
3897
3849 \begin_inset ERT
3898 \begin_inset ERT
3850 status Open
3899 status Open
3851
3900
3852 \layout Standard
3901 \layout Standard
3853
3902
3854 \backslash
3903 \backslash
3855 codelist{examples/example-magic.py}
3904 codelist{examples/example-magic.py}
3856 \end_inset
3905 \end_inset
3857
3906
3858
3907
3859 \layout Standard
3908 \layout Standard
3860
3909
3861 You can also define your own aliased names for magic functions.
3910 You can also define your own aliased names for magic functions.
3862 In your
3911 In your
3863 \family typewriter
3912 \family typewriter
3864 ipythonrc
3913 ipythonrc
3865 \family default
3914 \family default
3866 file, placing a line like:
3915 file, placing a line like:
3867 \layout Standard
3916 \layout Standard
3868
3917
3869
3918
3870 \family typewriter
3919 \family typewriter
3871 execute __IP.magic_cl = __IP.magic_clear
3920 execute __IP.magic_cl = __IP.magic_clear
3872 \layout Standard
3921 \layout Standard
3873
3922
3874 will define
3923 will define
3875 \family typewriter
3924 \family typewriter
3876 %cl
3925 %cl
3877 \family default
3926 \family default
3878 as a new name for
3927 as a new name for
3879 \family typewriter
3928 \family typewriter
3880 %clear
3929 %clear
3881 \family default
3930 \family default
3882 .
3931 .
3883 \layout Standard
3932 \layout Standard
3884
3933
3885 Type
3934 Type
3886 \family typewriter
3935 \family typewriter
3887 %magic
3936 %magic
3888 \family default
3937 \family default
3889 for more information, including a list of all available magic functions
3938 for more information, including a list of all available magic functions
3890 at any time and their docstrings.
3939 at any time and their docstrings.
3891 You can also type
3940 You can also type
3892 \family typewriter
3941 \family typewriter
3893 %magic_function_name?
3942 %magic_function_name?
3894 \family default
3943 \family default
3895 (see sec.
3944 (see sec.
3896
3945
3897 \begin_inset LatexCommand \ref{sec:dyn-object-info}
3946 \begin_inset LatexCommand \ref{sec:dyn-object-info}
3898
3947
3899 \end_inset
3948 \end_inset
3900
3949
3901 for information on the
3950 for information on the
3902 \family typewriter
3951 \family typewriter
3903 '?'
3952 '?'
3904 \family default
3953 \family default
3905 system) to get information about any particular magic function you are
3954 system) to get information about any particular magic function you are
3906 interested in.
3955 interested in.
3907 \layout Subsubsection
3956 \layout Subsubsection
3908
3957
3909 Magic commands
3958 Magic commands
3910 \layout Standard
3959 \layout Standard
3911
3960
3912 The rest of this section is automatically generated for each release from
3961 The rest of this section is automatically generated for each release from
3913 the docstrings in the IPython code.
3962 the docstrings in the IPython code.
3914 Therefore the formatting is somewhat minimal, but this method has the advantage
3963 Therefore the formatting is somewhat minimal, but this method has the advantage
3915 of having information always in sync with the code.
3964 of having information always in sync with the code.
3916 \layout Standard
3965 \layout Standard
3917
3966
3918 A list of all the magic commands available in IPython's
3967 A list of all the magic commands available in IPython's
3919 \emph on
3968 \emph on
3920 default
3969 default
3921 \emph default
3970 \emph default
3922 installation follows.
3971 installation follows.
3923 This is similar to what you'll see by simply typing
3972 This is similar to what you'll see by simply typing
3924 \family typewriter
3973 \family typewriter
3925 %magic
3974 %magic
3926 \family default
3975 \family default
3927 at the prompt, but that will also give you information about magic commands
3976 at the prompt, but that will also give you information about magic commands
3928 you may have added as part of your personal customizations.
3977 you may have added as part of your personal customizations.
3929 \layout Standard
3978 \layout Standard
3930
3979
3931
3980
3932 \begin_inset Include \input{magic.tex}
3981 \begin_inset Include \input{magic.tex}
3933 preview false
3982 preview false
3934
3983
3935 \end_inset
3984 \end_inset
3936
3985
3937
3986
3938 \layout Subsection
3987 \layout Subsection
3939
3988
3940 Access to the standard Python help
3989 Access to the standard Python help
3941 \layout Standard
3990 \layout Standard
3942
3991
3943 As of Python 2.1, a help system is available with access to object docstrings
3992 As of Python 2.1, a help system is available with access to object docstrings
3944 and the Python manuals.
3993 and the Python manuals.
3945 Simply type
3994 Simply type
3946 \family typewriter
3995 \family typewriter
3947 'help'
3996 'help'
3948 \family default
3997 \family default
3949 (no quotes) to access it.
3998 (no quotes) to access it.
3950 You can also type
3999 You can also type
3951 \family typewriter
4000 \family typewriter
3952 help(object)
4001 help(object)
3953 \family default
4002 \family default
3954 to obtain information about a given object, and
4003 to obtain information about a given object, and
3955 \family typewriter
4004 \family typewriter
3956 help('keyword')
4005 help('keyword')
3957 \family default
4006 \family default
3958 for information on a keyword.
4007 for information on a keyword.
3959 As noted in sec.
4008 As noted in sec.
3960
4009
3961 \begin_inset LatexCommand \ref{sec:help-access}
4010 \begin_inset LatexCommand \ref{sec:help-access}
3962
4011
3963 \end_inset
4012 \end_inset
3964
4013
3965 , you need to properly configure your environment variable
4014 , you need to properly configure your environment variable
3966 \family typewriter
4015 \family typewriter
3967 PYTHONDOCS
4016 PYTHONDOCS
3968 \family default
4017 \family default
3969 for this feature to work correctly.
4018 for this feature to work correctly.
3970 \layout Subsection
4019 \layout Subsection
3971
4020
3972
4021
3973 \begin_inset LatexCommand \label{sec:dyn-object-info}
4022 \begin_inset LatexCommand \label{sec:dyn-object-info}
3974
4023
3975 \end_inset
4024 \end_inset
3976
4025
3977 Dynamic object information
4026 Dynamic object information
3978 \layout Standard
4027 \layout Standard
3979
4028
3980 Typing
4029 Typing
3981 \family typewriter
4030 \family typewriter
3982 ?word
4031 ?word
3983 \family default
4032 \family default
3984 or
4033 or
3985 \family typewriter
4034 \family typewriter
3986 word?
4035 word?
3987 \family default
4036 \family default
3988 prints detailed information about an object.
4037 prints detailed information about an object.
3989 If certain strings in the object are too long (docstrings, code, etc.) they
4038 If certain strings in the object are too long (docstrings, code, etc.) they
3990 get snipped in the center for brevity.
4039 get snipped in the center for brevity.
3991 This system gives access variable types and values, full source code for
4040 This system gives access variable types and values, full source code for
3992 any object (if available), function prototypes and other useful information.
4041 any object (if available), function prototypes and other useful information.
3993 \layout Standard
4042 \layout Standard
3994
4043
3995 Typing
4044 Typing
3996 \family typewriter
4045 \family typewriter
3997 ??word
4046 ??word
3998 \family default
4047 \family default
3999 or
4048 or
4000 \family typewriter
4049 \family typewriter
4001 word??
4050 word??
4002 \family default
4051 \family default
4003 gives access to the full information without snipping long strings.
4052 gives access to the full information without snipping long strings.
4004 Long strings are sent to the screen through the
4053 Long strings are sent to the screen through the
4005 \family typewriter
4054 \family typewriter
4006 less
4055 less
4007 \family default
4056 \family default
4008 pager if longer than the screen and printed otherwise.
4057 pager if longer than the screen and printed otherwise.
4009 On systems lacking the
4058 On systems lacking the
4010 \family typewriter
4059 \family typewriter
4011 less
4060 less
4012 \family default
4061 \family default
4013 command, IPython uses a very basic internal pager.
4062 command, IPython uses a very basic internal pager.
4014 \layout Standard
4063 \layout Standard
4015
4064
4016 The following magic functions are particularly useful for gathering information
4065 The following magic functions are particularly useful for gathering information
4017 about your working environment.
4066 about your working environment.
4018 You can get more details by typing
4067 You can get more details by typing
4019 \family typewriter
4068 \family typewriter
4020 %magic
4069 %magic
4021 \family default
4070 \family default
4022 or querying them individually (use
4071 or querying them individually (use
4023 \family typewriter
4072 \family typewriter
4024 %function_name?
4073 %function_name?
4025 \family default
4074 \family default
4026 with or without the
4075 with or without the
4027 \family typewriter
4076 \family typewriter
4028 %
4077 %
4029 \family default
4078 \family default
4030 ), this is just a summary:
4079 ), this is just a summary:
4031 \layout List
4080 \layout List
4032 \labelwidthstring 00.00.0000
4081 \labelwidthstring 00.00.0000
4033
4082
4034
4083
4035 \family typewriter
4084 \family typewriter
4036 \series bold
4085 \series bold
4037 %pdoc\SpecialChar ~
4086 %pdoc\SpecialChar ~
4038 <object>
4087 <object>
4039 \family default
4088 \family default
4040 \series default
4089 \series default
4041 : Print (or run through a pager if too long) the docstring for an object.
4090 : Print (or run through a pager if too long) the docstring for an object.
4042 If the given object is a class, it will print both the class and the constructo
4091 If the given object is a class, it will print both the class and the constructo
4043 r docstrings.
4092 r docstrings.
4044 \layout List
4093 \layout List
4045 \labelwidthstring 00.00.0000
4094 \labelwidthstring 00.00.0000
4046
4095
4047
4096
4048 \family typewriter
4097 \family typewriter
4049 \series bold
4098 \series bold
4050 %pdef\SpecialChar ~
4099 %pdef\SpecialChar ~
4051 <object>
4100 <object>
4052 \family default
4101 \family default
4053 \series default
4102 \series default
4054 : Print the definition header for any callable object.
4103 : Print the definition header for any callable object.
4055 If the object is a class, print the constructor information.
4104 If the object is a class, print the constructor information.
4056 \layout List
4105 \layout List
4057 \labelwidthstring 00.00.0000
4106 \labelwidthstring 00.00.0000
4058
4107
4059
4108
4060 \family typewriter
4109 \family typewriter
4061 \series bold
4110 \series bold
4062 %psource\SpecialChar ~
4111 %psource\SpecialChar ~
4063 <object>
4112 <object>
4064 \family default
4113 \family default
4065 \series default
4114 \series default
4066 : Print (or run through a pager if too long) the source code for an object.
4115 : Print (or run through a pager if too long) the source code for an object.
4067 \layout List
4116 \layout List
4068 \labelwidthstring 00.00.0000
4117 \labelwidthstring 00.00.0000
4069
4118
4070
4119
4071 \family typewriter
4120 \family typewriter
4072 \series bold
4121 \series bold
4073 %pfile\SpecialChar ~
4122 %pfile\SpecialChar ~
4074 <object>
4123 <object>
4075 \family default
4124 \family default
4076 \series default
4125 \series default
4077 : Show the entire source file where an object was defined via a pager, opening
4126 : Show the entire source file where an object was defined via a pager, opening
4078 it at the line where the object definition begins.
4127 it at the line where the object definition begins.
4079 \layout List
4128 \layout List
4080 \labelwidthstring 00.00.0000
4129 \labelwidthstring 00.00.0000
4081
4130
4082
4131
4083 \family typewriter
4132 \family typewriter
4084 \series bold
4133 \series bold
4085 %who/%whos
4134 %who/%whos
4086 \family default
4135 \family default
4087 \series default
4136 \series default
4088 : These functions give information about identifiers you have defined interactiv
4137 : These functions give information about identifiers you have defined interactiv
4089 ely (not things you loaded or defined in your configuration files).
4138 ely (not things you loaded or defined in your configuration files).
4090
4139
4091 \family typewriter
4140 \family typewriter
4092 %who
4141 %who
4093 \family default
4142 \family default
4094 just prints a list of identifiers and
4143 just prints a list of identifiers and
4095 \family typewriter
4144 \family typewriter
4096 %whos
4145 %whos
4097 \family default
4146 \family default
4098 prints a table with some basic details about each identifier.
4147 prints a table with some basic details about each identifier.
4099 \layout Standard
4148 \layout Standard
4100
4149
4101 Note that the dynamic object information functions (
4150 Note that the dynamic object information functions (
4102 \family typewriter
4151 \family typewriter
4103 ?/??, %pdoc, %pfile, %pdef, %psource
4152 ?/??, %pdoc, %pfile, %pdef, %psource
4104 \family default
4153 \family default
4105 ) give you access to documentation even on things which are not really defined
4154 ) give you access to documentation even on things which are not really defined
4106 as separate identifiers.
4155 as separate identifiers.
4107 Try for example typing
4156 Try for example typing
4108 \family typewriter
4157 \family typewriter
4109 {}.get?
4158 {}.get?
4110 \family default
4159 \family default
4111 or after doing
4160 or after doing
4112 \family typewriter
4161 \family typewriter
4113 import os
4162 import os
4114 \family default
4163 \family default
4115 , type
4164 , type
4116 \family typewriter
4165 \family typewriter
4117 os.path.abspath??
4166 os.path.abspath??
4118 \family default
4167 \family default
4119 .
4168 .
4120 \layout Subsection
4169 \layout Subsection
4121
4170
4122
4171
4123 \begin_inset LatexCommand \label{sec:readline}
4172 \begin_inset LatexCommand \label{sec:readline}
4124
4173
4125 \end_inset
4174 \end_inset
4126
4175
4127 Readline-based features
4176 Readline-based features
4128 \layout Standard
4177 \layout Standard
4129
4178
4130 These features require the GNU readline library, so they won't work if your
4179 These features require the GNU readline library, so they won't work if your
4131 Python installation lacks readline support.
4180 Python installation lacks readline support.
4132 We will first describe the default behavior IPython uses, and then how
4181 We will first describe the default behavior IPython uses, and then how
4133 to change it to suit your preferences.
4182 to change it to suit your preferences.
4134 \layout Subsubsection
4183 \layout Subsubsection
4135
4184
4136 Command line completion
4185 Command line completion
4137 \layout Standard
4186 \layout Standard
4138
4187
4139 At any time, hitting TAB will complete any available python commands or
4188 At any time, hitting TAB will complete any available python commands or
4140 variable names, and show you a list of the possible completions if there's
4189 variable names, and show you a list of the possible completions if there's
4141 no unambiguous one.
4190 no unambiguous one.
4142 It will also complete filenames in the current directory if no python names
4191 It will also complete filenames in the current directory if no python names
4143 match what you've typed so far.
4192 match what you've typed so far.
4144 \layout Subsubsection
4193 \layout Subsubsection
4145
4194
4146 Search command history
4195 Search command history
4147 \layout Standard
4196 \layout Standard
4148
4197
4149 IPython provides two ways for searching through previous input and thus
4198 IPython provides two ways for searching through previous input and thus
4150 reduce the need for repetitive typing:
4199 reduce the need for repetitive typing:
4151 \layout Enumerate
4200 \layout Enumerate
4152
4201
4153 Start typing, and then use
4202 Start typing, and then use
4154 \family typewriter
4203 \family typewriter
4155 Ctrl-p
4204 Ctrl-p
4156 \family default
4205 \family default
4157 (previous,up) and
4206 (previous,up) and
4158 \family typewriter
4207 \family typewriter
4159 Ctrl-n
4208 Ctrl-n
4160 \family default
4209 \family default
4161 (next,down) to search through only the history items that match what you've
4210 (next,down) to search through only the history items that match what you've
4162 typed so far.
4211 typed so far.
4163 If you use
4212 If you use
4164 \family typewriter
4213 \family typewriter
4165 Ctrl-p/Ctrl-n
4214 Ctrl-p/Ctrl-n
4166 \family default
4215 \family default
4167 at a blank prompt, they just behave like normal arrow keys.
4216 at a blank prompt, they just behave like normal arrow keys.
4168 \layout Enumerate
4217 \layout Enumerate
4169
4218
4170 Hit
4219 Hit
4171 \family typewriter
4220 \family typewriter
4172 Ctrl-r
4221 Ctrl-r
4173 \family default
4222 \family default
4174 : opens a search prompt.
4223 : opens a search prompt.
4175 Begin typing and the system searches your history for lines that contain
4224 Begin typing and the system searches your history for lines that contain
4176 what you've typed so far, completing as much as it can.
4225 what you've typed so far, completing as much as it can.
4177 \layout Subsubsection
4226 \layout Subsubsection
4178
4227
4179 Persistent command history across sessions
4228 Persistent command history across sessions
4180 \layout Standard
4229 \layout Standard
4181
4230
4182 IPython will save your input history when it leaves and reload it next time
4231 IPython will save your input history when it leaves and reload it next time
4183 you restart it.
4232 you restart it.
4184 By default, the history file is named
4233 By default, the history file is named
4185 \family typewriter
4234 \family typewriter
4186 $IPYTHONDIR/history
4235 $IPYTHONDIR/history
4187 \family default
4236 \family default
4188 , but if you've loaded a named profile, '
4237 , but if you've loaded a named profile, '
4189 \family typewriter
4238 \family typewriter
4190 -PROFILE_NAME
4239 -PROFILE_NAME
4191 \family default
4240 \family default
4192 ' is appended to the name.
4241 ' is appended to the name.
4193 This allows you to keep separate histories related to various tasks: commands
4242 This allows you to keep separate histories related to various tasks: commands
4194 related to numerical work will not be clobbered by a system shell history,
4243 related to numerical work will not be clobbered by a system shell history,
4195 for example.
4244 for example.
4196 \layout Subsubsection
4245 \layout Subsubsection
4197
4246
4198 Autoindent
4247 Autoindent
4199 \layout Standard
4248 \layout Standard
4200
4249
4201 IPython can recognize lines ending in ':' and indent the next line, while
4250 IPython can recognize lines ending in ':' and indent the next line, while
4202 also un-indenting automatically after 'raise' or 'return'.
4251 also un-indenting automatically after 'raise' or 'return'.
4203
4252
4204 \layout Standard
4253 \layout Standard
4205
4254
4206 This feature uses the readline library, so it will honor your
4255 This feature uses the readline library, so it will honor your
4207 \family typewriter
4256 \family typewriter
4208 ~/.inputrc
4257 ~/.inputrc
4209 \family default
4258 \family default
4210 configuration (or whatever file your
4259 configuration (or whatever file your
4211 \family typewriter
4260 \family typewriter
4212 INPUTRC
4261 INPUTRC
4213 \family default
4262 \family default
4214 variable points to).
4263 variable points to).
4215 Adding the following lines to your
4264 Adding the following lines to your
4216 \family typewriter
4265 \family typewriter
4217 .inputrc
4266 .inputrc
4218 \family default
4267 \family default
4219 file can make indenting/unindenting more convenient (
4268 file can make indenting/unindenting more convenient (
4220 \family typewriter
4269 \family typewriter
4221 M-i
4270 M-i
4222 \family default
4271 \family default
4223 indents,
4272 indents,
4224 \family typewriter
4273 \family typewriter
4225 M-u
4274 M-u
4226 \family default
4275 \family default
4227 unindents):
4276 unindents):
4228 \layout Standard
4277 \layout Standard
4229
4278
4230
4279
4231 \family typewriter
4280 \family typewriter
4232 $if Python
4281 $if Python
4233 \newline
4282 \newline
4234 "
4283 "
4235 \backslash
4284 \backslash
4236 M-i": "\SpecialChar ~
4285 M-i": "\SpecialChar ~
4237 \SpecialChar ~
4286 \SpecialChar ~
4238 \SpecialChar ~
4287 \SpecialChar ~
4239 \SpecialChar ~
4288 \SpecialChar ~
4240 "
4289 "
4241 \newline
4290 \newline
4242 "
4291 "
4243 \backslash
4292 \backslash
4244 M-u": "
4293 M-u": "
4245 \backslash
4294 \backslash
4246 d
4295 d
4247 \backslash
4296 \backslash
4248 d
4297 d
4249 \backslash
4298 \backslash
4250 d
4299 d
4251 \backslash
4300 \backslash
4252 d"
4301 d"
4253 \newline
4302 \newline
4254 $endif
4303 $endif
4255 \layout Standard
4304 \layout Standard
4256
4305
4257 Note that there are 4 spaces between the quote marks after
4306 Note that there are 4 spaces between the quote marks after
4258 \family typewriter
4307 \family typewriter
4259 "M-i"
4308 "M-i"
4260 \family default
4309 \family default
4261 above.
4310 above.
4262 \layout Standard
4311 \layout Standard
4263
4312
4264
4313
4265 \series bold
4314 \series bold
4266 Warning:
4315 Warning:
4267 \series default
4316 \series default
4268 this feature is ON by default, but it can cause problems with the pasting
4317 this feature is ON by default, but it can cause problems with the pasting
4269 of multi-line indented code (the pasted code gets re-indented on each line).
4318 of multi-line indented code (the pasted code gets re-indented on each line).
4270 A magic function
4319 A magic function
4271 \family typewriter
4320 \family typewriter
4272 %autoindent
4321 %autoindent
4273 \family default
4322 \family default
4274 allows you to toggle it on/off at runtime.
4323 allows you to toggle it on/off at runtime.
4275 You can also disable it permanently on in your
4324 You can also disable it permanently on in your
4276 \family typewriter
4325 \family typewriter
4277 ipythonrc
4326 ipythonrc
4278 \family default
4327 \family default
4279 file (set
4328 file (set
4280 \family typewriter
4329 \family typewriter
4281 autoindent 0
4330 autoindent 0
4282 \family default
4331 \family default
4283 ).
4332 ).
4284 \layout Subsubsection
4333 \layout Subsubsection
4285
4334
4286 Customizing readline behavior
4335 Customizing readline behavior
4287 \layout Standard
4336 \layout Standard
4288
4337
4289 All these features are based on the GNU readline library, which has an extremely
4338 All these features are based on the GNU readline library, which has an extremely
4290 customizable interface.
4339 customizable interface.
4291 Normally, readline is configured via a file which defines the behavior
4340 Normally, readline is configured via a file which defines the behavior
4292 of the library; the details of the syntax for this can be found in the
4341 of the library; the details of the syntax for this can be found in the
4293 readline documentation available with your system or on the Internet.
4342 readline documentation available with your system or on the Internet.
4294 IPython doesn't read this file (if it exists) directly, but it does support
4343 IPython doesn't read this file (if it exists) directly, but it does support
4295 passing to readline valid options via a simple interface.
4344 passing to readline valid options via a simple interface.
4296 In brief, you can customize readline by setting the following options in
4345 In brief, you can customize readline by setting the following options in
4297 your
4346 your
4298 \family typewriter
4347 \family typewriter
4299 ipythonrc
4348 ipythonrc
4300 \family default
4349 \family default
4301 configuration file (note that these options can
4350 configuration file (note that these options can
4302 \emph on
4351 \emph on
4303 not
4352 not
4304 \emph default
4353 \emph default
4305 be specified at the command line):
4354 be specified at the command line):
4306 \layout List
4355 \layout List
4307 \labelwidthstring 00.00.0000
4356 \labelwidthstring 00.00.0000
4308
4357
4309
4358
4310 \family typewriter
4359 \family typewriter
4311 \series bold
4360 \series bold
4312 readline_parse_and_bind:
4361 readline_parse_and_bind:
4313 \family default
4362 \family default
4314 \series default
4363 \series default
4315 this option can appear as many times as you want, each time defining a
4364 this option can appear as many times as you want, each time defining a
4316 string to be executed via a
4365 string to be executed via a
4317 \family typewriter
4366 \family typewriter
4318 readline.parse_and_bind()
4367 readline.parse_and_bind()
4319 \family default
4368 \family default
4320 command.
4369 command.
4321 The syntax for valid commands of this kind can be found by reading the
4370 The syntax for valid commands of this kind can be found by reading the
4322 documentation for the GNU readline library, as these commands are of the
4371 documentation for the GNU readline library, as these commands are of the
4323 kind which readline accepts in its configuration file.
4372 kind which readline accepts in its configuration file.
4324 \layout List
4373 \layout List
4325 \labelwidthstring 00.00.0000
4374 \labelwidthstring 00.00.0000
4326
4375
4327
4376
4328 \family typewriter
4377 \family typewriter
4329 \series bold
4378 \series bold
4330 readline_remove_delims:
4379 readline_remove_delims:
4331 \family default
4380 \family default
4332 \series default
4381 \series default
4333 a string of characters to be removed from the default word-delimiters list
4382 a string of characters to be removed from the default word-delimiters list
4334 used by readline, so that completions may be performed on strings which
4383 used by readline, so that completions may be performed on strings which
4335 contain them.
4384 contain them.
4336 Do not change the default value unless you know what you're doing.
4385 Do not change the default value unless you know what you're doing.
4337 \layout List
4386 \layout List
4338 \labelwidthstring 00.00.0000
4387 \labelwidthstring 00.00.0000
4339
4388
4340
4389
4341 \family typewriter
4390 \family typewriter
4342 \series bold
4391 \series bold
4343 readline_omit__names
4392 readline_omit__names
4344 \family default
4393 \family default
4345 \series default
4394 \series default
4346 : when tab-completion is enabled, hitting
4395 : when tab-completion is enabled, hitting
4347 \family typewriter
4396 \family typewriter
4348 <tab>
4397 <tab>
4349 \family default
4398 \family default
4350 after a '
4399 after a '
4351 \family typewriter
4400 \family typewriter
4352 .
4401 .
4353 \family default
4402 \family default
4354 ' in a name will complete all attributes of an object, including all the
4403 ' in a name will complete all attributes of an object, including all the
4355 special methods whose names include double underscores (like
4404 special methods whose names include double underscores (like
4356 \family typewriter
4405 \family typewriter
4357 __getitem__
4406 __getitem__
4358 \family default
4407 \family default
4359 or
4408 or
4360 \family typewriter
4409 \family typewriter
4361 __class__
4410 __class__
4362 \family default
4411 \family default
4363 ).
4412 ).
4364 If you'd rather not see these names by default, you can set this option
4413 If you'd rather not see these names by default, you can set this option
4365 to 1.
4414 to 1.
4366 Note that even when this option is set, you can still see those names by
4415 Note that even when this option is set, you can still see those names by
4367 explicitly typing a
4416 explicitly typing a
4368 \family typewriter
4417 \family typewriter
4369 _
4418 _
4370 \family default
4419 \family default
4371 after the period and hitting
4420 after the period and hitting
4372 \family typewriter
4421 \family typewriter
4373 <tab>
4422 <tab>
4374 \family default
4423 \family default
4375 : '
4424 : '
4376 \family typewriter
4425 \family typewriter
4377 name._<tab>
4426 name._<tab>
4378 \family default
4427 \family default
4379 ' will always complete attribute names starting with '
4428 ' will always complete attribute names starting with '
4380 \family typewriter
4429 \family typewriter
4381 _
4430 _
4382 \family default
4431 \family default
4383 '.
4432 '.
4384 \layout List
4433 \layout List
4385 \labelwidthstring 00.00.0000
4434 \labelwidthstring 00.00.0000
4386
4435
4387 \SpecialChar ~
4436 \SpecialChar ~
4388 This option is off by default so that new users see all attributes of any
4437 This option is off by default so that new users see all attributes of any
4389 objects they are dealing with.
4438 objects they are dealing with.
4390 \layout Standard
4439 \layout Standard
4391
4440
4392 You will find the default values along with a corresponding detailed explanation
4441 You will find the default values along with a corresponding detailed explanation
4393 in your
4442 in your
4394 \family typewriter
4443 \family typewriter
4395 ipythonrc
4444 ipythonrc
4396 \family default
4445 \family default
4397 file.
4446 file.
4398 \layout Subsection
4447 \layout Subsection
4399
4448
4400 Session logging and restoring
4449 Session logging and restoring
4401 \layout Standard
4450 \layout Standard
4402
4451
4403 You can log all input from a session either by starting IPython with the
4452 You can log all input from a session either by starting IPython with the
4404 command line switches
4453 command line switches
4405 \family typewriter
4454 \family typewriter
4406 -log
4455 -log
4407 \family default
4456 \family default
4408 or
4457 or
4409 \family typewriter
4458 \family typewriter
4410 -logfile
4459 -logfile
4411 \family default
4460 \family default
4412 (see sec.
4461 (see sec.
4413
4462
4414 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
4463 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
4415
4464
4416 \end_inset
4465 \end_inset
4417
4466
4418 )or by activating the logging at any moment with the magic function
4467 )or by activating the logging at any moment with the magic function
4419 \family typewriter
4468 \family typewriter
4420 %logstart
4469 %logstart
4421 \family default
4470 \family default
4422 .
4471 .
4423
4472
4424 \layout Standard
4473 \layout Standard
4425
4474
4426 Log files can later be reloaded with the
4475 Log files can later be reloaded with the
4427 \family typewriter
4476 \family typewriter
4428 -logplay
4477 -logplay
4429 \family default
4478 \family default
4430 option and IPython will attempt to 'replay' the log by executing all the
4479 option and IPython will attempt to 'replay' the log by executing all the
4431 lines in it, thus restoring the state of a previous session.
4480 lines in it, thus restoring the state of a previous session.
4432 This feature is not quite perfect, but can still be useful in many cases.
4481 This feature is not quite perfect, but can still be useful in many cases.
4433 \layout Standard
4482 \layout Standard
4434
4483
4435 The log files can also be used as a way to have a permanent record of any
4484 The log files can also be used as a way to have a permanent record of any
4436 code you wrote while experimenting.
4485 code you wrote while experimenting.
4437 Log files are regular text files which you can later open in your favorite
4486 Log files are regular text files which you can later open in your favorite
4438 text editor to extract code or to 'clean them up' before using them to
4487 text editor to extract code or to 'clean them up' before using them to
4439 replay a session.
4488 replay a session.
4440 \layout Standard
4489 \layout Standard
4441
4490
4442 The
4491 The
4443 \family typewriter
4492 \family typewriter
4444 %logstart
4493 %logstart
4445 \family default
4494 \family default
4446 function for activating logging in mid-session is used as follows:
4495 function for activating logging in mid-session is used as follows:
4447 \layout Standard
4496 \layout Standard
4448
4497
4449
4498
4450 \family typewriter
4499 \family typewriter
4451 %logstart [log_name [log_mode]]
4500 %logstart [log_name [log_mode]]
4452 \layout Standard
4501 \layout Standard
4453
4502
4454 If no name is given, it defaults to a file named
4503 If no name is given, it defaults to a file named
4455 \family typewriter
4504 \family typewriter
4456 'log'
4505 'log'
4457 \family default
4506 \family default
4458 in your IPYTHONDIR directory, in
4507 in your IPYTHONDIR directory, in
4459 \family typewriter
4508 \family typewriter
4460 'rotate'
4509 'rotate'
4461 \family default
4510 \family default
4462 mode (see below).
4511 mode (see below).
4463 \layout Standard
4512 \layout Standard
4464
4513
4465 '
4514 '
4466 \family typewriter
4515 \family typewriter
4467 %logstart name
4516 %logstart name
4468 \family default
4517 \family default
4469 ' saves to file
4518 ' saves to file
4470 \family typewriter
4519 \family typewriter
4471 'name'
4520 'name'
4472 \family default
4521 \family default
4473 in
4522 in
4474 \family typewriter
4523 \family typewriter
4475 'backup'
4524 'backup'
4476 \family default
4525 \family default
4477 mode.
4526 mode.
4478 It saves your history up to that point and then continues logging.
4527 It saves your history up to that point and then continues logging.
4479 \layout Standard
4528 \layout Standard
4480
4529
4481
4530
4482 \family typewriter
4531 \family typewriter
4483 %logstart
4532 %logstart
4484 \family default
4533 \family default
4485 takes a second optional parameter: logging mode.
4534 takes a second optional parameter: logging mode.
4486 This can be one of (note that the modes are given unquoted):
4535 This can be one of (note that the modes are given unquoted):
4487 \layout List
4536 \layout List
4488 \labelwidthstring 00.00.0000
4537 \labelwidthstring 00.00.0000
4489
4538
4490
4539
4491 \family typewriter
4540 \family typewriter
4492 over
4541 over
4493 \family default
4542 \family default
4494 : overwrite existing
4543 : overwrite existing
4495 \family typewriter
4544 \family typewriter
4496 log_name
4545 log_name
4497 \family default
4546 \family default
4498 .
4547 .
4499 \layout List
4548 \layout List
4500 \labelwidthstring 00.00.0000
4549 \labelwidthstring 00.00.0000
4501
4550
4502
4551
4503 \family typewriter
4552 \family typewriter
4504 backup
4553 backup
4505 \family default
4554 \family default
4506 : rename (if exists) to
4555 : rename (if exists) to
4507 \family typewriter
4556 \family typewriter
4508 log_name~
4557 log_name~
4509 \family default
4558 \family default
4510 and start
4559 and start
4511 \family typewriter
4560 \family typewriter
4512 log_name
4561 log_name
4513 \family default
4562 \family default
4514 .
4563 .
4515 \layout List
4564 \layout List
4516 \labelwidthstring 00.00.0000
4565 \labelwidthstring 00.00.0000
4517
4566
4518
4567
4519 \family typewriter
4568 \family typewriter
4520 append
4569 append
4521 \family default
4570 \family default
4522 : well, that says it.
4571 : well, that says it.
4523 \layout List
4572 \layout List
4524 \labelwidthstring 00.00.0000
4573 \labelwidthstring 00.00.0000
4525
4574
4526
4575
4527 \family typewriter
4576 \family typewriter
4528 rotate
4577 rotate
4529 \family default
4578 \family default
4530 : create rotating logs
4579 : create rotating logs
4531 \family typewriter
4580 \family typewriter
4532 log_name
4581 log_name
4533 \family default
4582 \family default
4534 .
4583 .
4535 \family typewriter
4584 \family typewriter
4536 1~
4585 1~
4537 \family default
4586 \family default
4538 ,
4587 ,
4539 \family typewriter
4588 \family typewriter
4540 log_name.2~
4589 log_name.2~
4541 \family default
4590 \family default
4542 , etc.
4591 , etc.
4543 \layout Standard
4592 \layout Standard
4544
4593
4545 The
4594 The
4546 \family typewriter
4595 \family typewriter
4547 %logoff
4596 %logoff
4548 \family default
4597 \family default
4549 and
4598 and
4550 \family typewriter
4599 \family typewriter
4551 %logon
4600 %logon
4552 \family default
4601 \family default
4553 functions allow you to temporarily stop and resume logging to a file which
4602 functions allow you to temporarily stop and resume logging to a file which
4554 had previously been started with
4603 had previously been started with
4555 \family typewriter
4604 \family typewriter
4556 %logstart
4605 %logstart
4557 \family default
4606 \family default
4558 .
4607 .
4559 They will fail (with an explanation) if you try to use them before logging
4608 They will fail (with an explanation) if you try to use them before logging
4560 has been started.
4609 has been started.
4561 \layout Subsection
4610 \layout Subsection
4562
4611
4563
4612
4564 \begin_inset LatexCommand \label{sub:System-shell-access}
4613 \begin_inset LatexCommand \label{sub:System-shell-access}
4565
4614
4566 \end_inset
4615 \end_inset
4567
4616
4568 System shell access
4617 System shell access
4569 \layout Standard
4618 \layout Standard
4570
4619
4571 Any input line beginning with a
4620 Any input line beginning with a
4572 \family typewriter
4621 \family typewriter
4573 !
4622 !
4574 \family default
4623 \family default
4575 character is passed verbatim (minus the
4624 character is passed verbatim (minus the
4576 \family typewriter
4625 \family typewriter
4577 !
4626 !
4578 \family default
4627 \family default
4579 , of course) to the underlying operating system.
4628 , of course) to the underlying operating system.
4580 For example, typing
4629 For example, typing
4581 \family typewriter
4630 \family typewriter
4582 !ls
4631 !ls
4583 \family default
4632 \family default
4584 will run
4633 will run
4585 \family typewriter
4634 \family typewriter
4586 'ls'
4635 'ls'
4587 \family default
4636 \family default
4588 in the current directory.
4637 in the current directory.
4589 \layout Subsubsection
4638 \layout Subsubsection
4590
4639
4591 Manual capture of command output
4640 Manual capture of command output
4592 \layout Standard
4641 \layout Standard
4593
4642
4594 If the input line begins with
4643 If the input line begins with
4595 \emph on
4644 \emph on
4596 two
4645 two
4597 \emph default
4646 \emph default
4598 exclamation marks,
4647 exclamation marks,
4599 \family typewriter
4648 \family typewriter
4600 !!
4649 !!
4601 \family default
4650 \family default
4602 , the command is executed but its output is captured and returned as a python
4651 , the command is executed but its output is captured and returned as a python
4603 list, split on newlines.
4652 list, split on newlines.
4604 Any output sent by the subprocess to standard error is printed separately,
4653 Any output sent by the subprocess to standard error is printed separately,
4605 so that the resulting list only captures standard output.
4654 so that the resulting list only captures standard output.
4606 The
4655 The
4607 \family typewriter
4656 \family typewriter
4608 !!
4657 !!
4609 \family default
4658 \family default
4610 syntax is a shorthand for the
4659 syntax is a shorthand for the
4611 \family typewriter
4660 \family typewriter
4612 %sx
4661 %sx
4613 \family default
4662 \family default
4614 magic command.
4663 magic command.
4615 \layout Standard
4664 \layout Standard
4616
4665
4617 Finally, the
4666 Finally, the
4618 \family typewriter
4667 \family typewriter
4619 %sc
4668 %sc
4620 \family default
4669 \family default
4621 magic (short for `shell capture') is similar to
4670 magic (short for `shell capture') is similar to
4622 \family typewriter
4671 \family typewriter
4623 %sx
4672 %sx
4624 \family default
4673 \family default
4625 , but allowing more fine-grained control of the capture details, and storing
4674 , but allowing more fine-grained control of the capture details, and storing
4626 the result directly into a named variable.
4675 the result directly into a named variable.
4627 \layout Standard
4676 \layout Standard
4628
4677
4629 See Sec.\SpecialChar ~
4678 See Sec.\SpecialChar ~
4630
4679
4631 \begin_inset LatexCommand \ref{sec:magic}
4680 \begin_inset LatexCommand \ref{sec:magic}
4632
4681
4633 \end_inset
4682 \end_inset
4634
4683
4635 for details on the magics
4684 for details on the magics
4636 \family typewriter
4685 \family typewriter
4637 %sc
4686 %sc
4638 \family default
4687 \family default
4639 and
4688 and
4640 \family typewriter
4689 \family typewriter
4641 %sx
4690 %sx
4642 \family default
4691 \family default
4643 , or use IPython's own help (
4692 , or use IPython's own help (
4644 \family typewriter
4693 \family typewriter
4645 sc?
4694 sc?
4646 \family default
4695 \family default
4647 and
4696 and
4648 \family typewriter
4697 \family typewriter
4649 sx?
4698 sx?
4650 \family default
4699 \family default
4651 ) for further details.
4700 ) for further details.
4652 \layout Standard
4701 \layout Standard
4653
4702
4654 IPython also allows you to expand the value of python variables when making
4703 IPython also allows you to expand the value of python variables when making
4655 system calls.
4704 system calls.
4656 Any python variable or expression which you prepend with
4705 Any python variable or expression which you prepend with
4657 \family typewriter
4706 \family typewriter
4658 $
4707 $
4659 \family default
4708 \family default
4660 will get expanded before the system call is made.
4709 will get expanded before the system call is made.
4661
4710
4662 \layout Standard
4711 \layout Standard
4663
4712
4664
4713
4665 \family typewriter
4714 \family typewriter
4666 In [1]: pyvar='Hello world'
4715 In [1]: pyvar='Hello world'
4667 \newline
4716 \newline
4668 In [2]: !echo "A python variable: $pyvar"
4717 In [2]: !echo "A python variable: $pyvar"
4669 \newline
4718 \newline
4670 A python variable: Hello world
4719 A python variable: Hello world
4671 \layout Standard
4720 \layout Standard
4672
4721
4673 If you want the shell to actually see a literal
4722 If you want the shell to actually see a literal
4674 \family typewriter
4723 \family typewriter
4675 $
4724 $
4676 \family default
4725 \family default
4677 , you need to type it twice:
4726 , you need to type it twice:
4678 \layout Standard
4727 \layout Standard
4679
4728
4680
4729
4681 \family typewriter
4730 \family typewriter
4682 In [3]: !echo "A system variable: $$HOME"
4731 In [3]: !echo "A system variable: $$HOME"
4683 \newline
4732 \newline
4684 A system variable: /home/fperez
4733 A system variable: /home/fperez
4685 \layout Standard
4734 \layout Standard
4686
4735
4687 You can pass arbitrary expressions, though you'll need to delimit them with
4736 You can pass arbitrary expressions, though you'll need to delimit them with
4688
4737
4689 \family typewriter
4738 \family typewriter
4690 {}
4739 {}
4691 \family default
4740 \family default
4692 if there is ambiguity as to the extent of the expression:
4741 if there is ambiguity as to the extent of the expression:
4693 \layout Standard
4742 \layout Standard
4694
4743
4695
4744
4696 \family typewriter
4745 \family typewriter
4697 In [5]: x=10
4746 In [5]: x=10
4698 \newline
4747 \newline
4699 In [6]: y=20
4748 In [6]: y=20
4700 \newline
4749 \newline
4701 In [13]: !echo $x+y
4750 In [13]: !echo $x+y
4702 \newline
4751 \newline
4703 10+y
4752 10+y
4704 \newline
4753 \newline
4705 In [7]: !echo ${x+y}
4754 In [7]: !echo ${x+y}
4706 \newline
4755 \newline
4707 30
4756 30
4708 \layout Standard
4757 \layout Standard
4709
4758
4710 Even object attributes can be expanded:
4759 Even object attributes can be expanded:
4711 \layout Standard
4760 \layout Standard
4712
4761
4713
4762
4714 \family typewriter
4763 \family typewriter
4715 In [12]: !echo $sys.argv
4764 In [12]: !echo $sys.argv
4716 \newline
4765 \newline
4717 [/home/fperez/usr/bin/ipython]
4766 [/home/fperez/usr/bin/ipython]
4718 \layout Subsection
4767 \layout Subsection
4719
4768
4720 System command aliases
4769 System command aliases
4721 \layout Standard
4770 \layout Standard
4722
4771
4723 The
4772 The
4724 \family typewriter
4773 \family typewriter
4725 %alias
4774 %alias
4726 \family default
4775 \family default
4727 magic function and the
4776 magic function and the
4728 \family typewriter
4777 \family typewriter
4729 alias
4778 alias
4730 \family default
4779 \family default
4731 option in the
4780 option in the
4732 \family typewriter
4781 \family typewriter
4733 ipythonrc
4782 ipythonrc
4734 \family default
4783 \family default
4735 configuration file allow you to define magic functions which are in fact
4784 configuration file allow you to define magic functions which are in fact
4736 system shell commands.
4785 system shell commands.
4737 These aliases can have parameters.
4786 These aliases can have parameters.
4738
4787
4739 \layout Standard
4788 \layout Standard
4740
4789
4741 '
4790 '
4742 \family typewriter
4791 \family typewriter
4743 %alias alias_name cmd
4792 %alias alias_name cmd
4744 \family default
4793 \family default
4745 ' defines '
4794 ' defines '
4746 \family typewriter
4795 \family typewriter
4747 alias_name
4796 alias_name
4748 \family default
4797 \family default
4749 ' as an alias for '
4798 ' as an alias for '
4750 \family typewriter
4799 \family typewriter
4751 cmd
4800 cmd
4752 \family default
4801 \family default
4753 '
4802 '
4754 \layout Standard
4803 \layout Standard
4755
4804
4756 Then, typing '
4805 Then, typing '
4757 \family typewriter
4806 \family typewriter
4758 %alias_name params
4807 %alias_name params
4759 \family default
4808 \family default
4760 ' will execute the system command '
4809 ' will execute the system command '
4761 \family typewriter
4810 \family typewriter
4762 cmd params
4811 cmd params
4763 \family default
4812 \family default
4764 ' (from your underlying operating system).
4813 ' (from your underlying operating system).
4765
4814
4766 \layout Standard
4815 \layout Standard
4767
4816
4768 You can also define aliases with parameters using
4817 You can also define aliases with parameters using
4769 \family typewriter
4818 \family typewriter
4770 %s
4819 %s
4771 \family default
4820 \family default
4772 specifiers (one per parameter).
4821 specifiers (one per parameter).
4773 The following example defines the
4822 The following example defines the
4774 \family typewriter
4823 \family typewriter
4775 %parts
4824 %parts
4776 \family default
4825 \family default
4777 function as an alias to the command '
4826 function as an alias to the command '
4778 \family typewriter
4827 \family typewriter
4779 echo first %s second %s
4828 echo first %s second %s
4780 \family default
4829 \family default
4781 ' where each
4830 ' where each
4782 \family typewriter
4831 \family typewriter
4783 %s
4832 %s
4784 \family default
4833 \family default
4785 will be replaced by a positional parameter to the call to
4834 will be replaced by a positional parameter to the call to
4786 \family typewriter
4835 \family typewriter
4787 %parts:
4836 %parts:
4788 \layout Standard
4837 \layout Standard
4789
4838
4790
4839
4791 \family typewriter
4840 \family typewriter
4792 In [1]: alias parts echo first %s second %s
4841 In [1]: alias parts echo first %s second %s
4793 \newline
4842 \newline
4794 In [2]: %parts A B
4843 In [2]: %parts A B
4795 \newline
4844 \newline
4796 first A second B
4845 first A second B
4797 \newline
4846 \newline
4798 In [3]: %parts A
4847 In [3]: %parts A
4799 \newline
4848 \newline
4800 Incorrect number of arguments: 2 expected.
4849 Incorrect number of arguments: 2 expected.
4801
4850
4802 \newline
4851 \newline
4803 parts is an alias to: 'echo first %s second %s'
4852 parts is an alias to: 'echo first %s second %s'
4804 \layout Standard
4853 \layout Standard
4805
4854
4806 If called with no parameters,
4855 If called with no parameters,
4807 \family typewriter
4856 \family typewriter
4808 %alias
4857 %alias
4809 \family default
4858 \family default
4810 prints the table of currently defined aliases.
4859 prints the table of currently defined aliases.
4811 \layout Standard
4860 \layout Standard
4812
4861
4813 The
4862 The
4814 \family typewriter
4863 \family typewriter
4815 %rehash/rehashx
4864 %rehash/rehashx
4816 \family default
4865 \family default
4817 magics allow you to load your entire
4866 magics allow you to load your entire
4818 \family typewriter
4867 \family typewriter
4819 $PATH
4868 $PATH
4820 \family default
4869 \family default
4821 as ipython aliases.
4870 as ipython aliases.
4822 See their respective docstrings (or sec.\SpecialChar ~
4871 See their respective docstrings (or sec.\SpecialChar ~
4823
4872
4824 \begin_inset LatexCommand \ref{sec:magic}
4873 \begin_inset LatexCommand \ref{sec:magic}
4825
4874
4826 \end_inset
4875 \end_inset
4827
4876
4828 for further details).
4877 for further details).
4829 \layout Subsection
4878 \layout Subsection
4830
4879
4831
4880
4832 \begin_inset LatexCommand \label{sec:dreload}
4881 \begin_inset LatexCommand \label{sec:dreload}
4833
4882
4834 \end_inset
4883 \end_inset
4835
4884
4836 Recursive reload
4885 Recursive reload
4837 \layout Standard
4886 \layout Standard
4838
4887
4839 The
4888 The
4840 \family typewriter
4889 \family typewriter
4841 %dreload
4890 %dreload
4842 \family default
4891 \family default
4843 command does a recursive reload of a module: changes made to the module
4892 command does a recursive reload of a module: changes made to the module
4844 since you imported will actually be available without having to exit.
4893 since you imported will actually be available without having to exit.
4845 \layout Subsection
4894 \layout Subsection
4846
4895
4847 Verbose and colored exception traceback printouts
4896 Verbose and colored exception traceback printouts
4848 \layout Standard
4897 \layout Standard
4849
4898
4850 IPython provides the option to see very detailed exception tracebacks, which
4899 IPython provides the option to see very detailed exception tracebacks, which
4851 can be especially useful when debugging large programs.
4900 can be especially useful when debugging large programs.
4852 You can run any Python file with the
4901 You can run any Python file with the
4853 \family typewriter
4902 \family typewriter
4854 %run
4903 %run
4855 \family default
4904 \family default
4856 function to benefit from these detailed tracebacks.
4905 function to benefit from these detailed tracebacks.
4857 Furthermore, both normal and verbose tracebacks can be colored (if your
4906 Furthermore, both normal and verbose tracebacks can be colored (if your
4858 terminal supports it) which makes them much easier to parse visually.
4907 terminal supports it) which makes them much easier to parse visually.
4859 \layout Standard
4908 \layout Standard
4860
4909
4861 See the magic
4910 See the magic
4862 \family typewriter
4911 \family typewriter
4863 xmode
4912 xmode
4864 \family default
4913 \family default
4865 and
4914 and
4866 \family typewriter
4915 \family typewriter
4867 colors
4916 colors
4868 \family default
4917 \family default
4869 functions for details (just type
4918 functions for details (just type
4870 \family typewriter
4919 \family typewriter
4871 %magic
4920 %magic
4872 \family default
4921 \family default
4873 ).
4922 ).
4874 \layout Standard
4923 \layout Standard
4875
4924
4876 These features are basically a terminal version of Ka-Ping Yee's
4925 These features are basically a terminal version of Ka-Ping Yee's
4877 \family typewriter
4926 \family typewriter
4878 cgitb
4927 cgitb
4879 \family default
4928 \family default
4880 module, now part of the standard Python library.
4929 module, now part of the standard Python library.
4881 \layout Subsection
4930 \layout Subsection
4882
4931
4883
4932
4884 \begin_inset LatexCommand \label{sec:cache_input}
4933 \begin_inset LatexCommand \label{sec:cache_input}
4885
4934
4886 \end_inset
4935 \end_inset
4887
4936
4888 Input caching system
4937 Input caching system
4889 \layout Standard
4938 \layout Standard
4890
4939
4891 IPython offers numbered prompts (In/Out) with input and output caching.
4940 IPython offers numbered prompts (In/Out) with input and output caching.
4892 All input is saved and can be retrieved as variables (besides the usual
4941 All input is saved and can be retrieved as variables (besides the usual
4893 arrow key recall).
4942 arrow key recall).
4894 \layout Standard
4943 \layout Standard
4895
4944
4896 The following GLOBAL variables always exist (so don't overwrite them!):
4945 The following GLOBAL variables always exist (so don't overwrite them!):
4897
4946
4898 \family typewriter
4947 \family typewriter
4899 _i
4948 _i
4900 \family default
4949 \family default
4901 : stores previous input.
4950 : stores previous input.
4902
4951
4903 \family typewriter
4952 \family typewriter
4904 _ii
4953 _ii
4905 \family default
4954 \family default
4906 : next previous.
4955 : next previous.
4907
4956
4908 \family typewriter
4957 \family typewriter
4909 _iii
4958 _iii
4910 \family default
4959 \family default
4911 : next-next previous.
4960 : next-next previous.
4912
4961
4913 \family typewriter
4962 \family typewriter
4914 _ih
4963 _ih
4915 \family default
4964 \family default
4916 : a list of all input
4965 : a list of all input
4917 \family typewriter
4966 \family typewriter
4918 _ih[n]
4967 _ih[n]
4919 \family default
4968 \family default
4920 is the input from line
4969 is the input from line
4921 \family typewriter
4970 \family typewriter
4922 n
4971 n
4923 \family default
4972 \family default
4924 and this list is aliased to the global variable
4973 and this list is aliased to the global variable
4925 \family typewriter
4974 \family typewriter
4926 In
4975 In
4927 \family default
4976 \family default
4928 .
4977 .
4929 If you overwrite
4978 If you overwrite
4930 \family typewriter
4979 \family typewriter
4931 In
4980 In
4932 \family default
4981 \family default
4933 with a variable of your own, you can remake the assignment to the internal
4982 with a variable of your own, you can remake the assignment to the internal
4934 list with a simple
4983 list with a simple
4935 \family typewriter
4984 \family typewriter
4936 'In=_ih'
4985 'In=_ih'
4937 \family default
4986 \family default
4938 .
4987 .
4939 \layout Standard
4988 \layout Standard
4940
4989
4941 Additionally, global variables named
4990 Additionally, global variables named
4942 \family typewriter
4991 \family typewriter
4943 _i<n>
4992 _i<n>
4944 \family default
4993 \family default
4945 are dynamically created (
4994 are dynamically created (
4946 \family typewriter
4995 \family typewriter
4947 <n>
4996 <n>
4948 \family default
4997 \family default
4949 being the prompt counter), such that
4998 being the prompt counter), such that
4950 \newline
4999 \newline
4951
5000
4952 \family typewriter
5001 \family typewriter
4953 _i<n> == _ih[<n>] == In[<n>].
5002 _i<n> == _ih[<n>] == In[<n>].
4954 \layout Standard
5003 \layout Standard
4955
5004
4956 For example, what you typed at prompt 14 is available as
5005 For example, what you typed at prompt 14 is available as
4957 \family typewriter
5006 \family typewriter
4958 _i14,
5007 _i14,
4959 \family default
5008 \family default
4960
5009
4961 \family typewriter
5010 \family typewriter
4962 _ih[14]
5011 _ih[14]
4963 \family default
5012 \family default
4964 and
5013 and
4965 \family typewriter
5014 \family typewriter
4966 In[14]
5015 In[14]
4967 \family default
5016 \family default
4968 .
5017 .
4969 \layout Standard
5018 \layout Standard
4970
5019
4971 This allows you to easily cut and paste multi line interactive prompts by
5020 This allows you to easily cut and paste multi line interactive prompts by
4972 printing them out: they print like a clean string, without prompt characters.
5021 printing them out: they print like a clean string, without prompt characters.
4973 You can also manipulate them like regular variables (they are strings),
5022 You can also manipulate them like regular variables (they are strings),
4974 modify or exec them (typing
5023 modify or exec them (typing
4975 \family typewriter
5024 \family typewriter
4976 'exec _i9'
5025 'exec _i9'
4977 \family default
5026 \family default
4978 will re-execute the contents of input prompt 9, '
5027 will re-execute the contents of input prompt 9, '
4979 \family typewriter
5028 \family typewriter
4980 exec In[9:14]+In[18]
5029 exec In[9:14]+In[18]
4981 \family default
5030 \family default
4982 ' will re-execute lines 9 through 13 and line 18).
5031 ' will re-execute lines 9 through 13 and line 18).
4983 \layout Standard
5032 \layout Standard
4984
5033
4985 You can also re-execute multiple lines of input easily by using the magic
5034 You can also re-execute multiple lines of input easily by using the magic
4986
5035
4987 \family typewriter
5036 \family typewriter
4988 %macro
5037 %macro
4989 \family default
5038 \family default
4990 function (which automates the process and allows re-execution without having
5039 function (which automates the process and allows re-execution without having
4991 to type '
5040 to type '
4992 \family typewriter
5041 \family typewriter
4993 exec
5042 exec
4994 \family default
5043 \family default
4995 ' every time).
5044 ' every time).
4996 The macro system also allows you to re-execute previous lines which include
5045 The macro system also allows you to re-execute previous lines which include
4997 magic function calls (which require special processing).
5046 magic function calls (which require special processing).
4998 Type
5047 Type
4999 \family typewriter
5048 \family typewriter
5000 %macro?
5049 %macro?
5001 \family default
5050 \family default
5002 or see sec.
5051 or see sec.
5003
5052
5004 \begin_inset LatexCommand \ref{sec:magic}
5053 \begin_inset LatexCommand \ref{sec:magic}
5005
5054
5006 \end_inset
5055 \end_inset
5007
5056
5008 for more details on the macro system.
5057 for more details on the macro system.
5009 \layout Standard
5058 \layout Standard
5010
5059
5011 A history function
5060 A history function
5012 \family typewriter
5061 \family typewriter
5013 %hist
5062 %hist
5014 \family default
5063 \family default
5015 allows you to see any part of your input history by printing a range of
5064 allows you to see any part of your input history by printing a range of
5016 the
5065 the
5017 \family typewriter
5066 \family typewriter
5018 _i
5067 _i
5019 \family default
5068 \family default
5020 variables.
5069 variables.
5021 \layout Subsection
5070 \layout Subsection
5022
5071
5023
5072
5024 \begin_inset LatexCommand \label{sec:cache_output}
5073 \begin_inset LatexCommand \label{sec:cache_output}
5025
5074
5026 \end_inset
5075 \end_inset
5027
5076
5028 Output caching system
5077 Output caching system
5029 \layout Standard
5078 \layout Standard
5030
5079
5031 For output that is returned from actions, a system similar to the input
5080 For output that is returned from actions, a system similar to the input
5032 cache exists but using
5081 cache exists but using
5033 \family typewriter
5082 \family typewriter
5034 _
5083 _
5035 \family default
5084 \family default
5036 instead of
5085 instead of
5037 \family typewriter
5086 \family typewriter
5038 _i
5087 _i
5039 \family default
5088 \family default
5040 .
5089 .
5041 Only actions that produce a result (NOT assignments, for example) are cached.
5090 Only actions that produce a result (NOT assignments, for example) are cached.
5042 If you are familiar with Mathematica, IPython's
5091 If you are familiar with Mathematica, IPython's
5043 \family typewriter
5092 \family typewriter
5044 _
5093 _
5045 \family default
5094 \family default
5046 variables behave exactly like Mathematica's
5095 variables behave exactly like Mathematica's
5047 \family typewriter
5096 \family typewriter
5048 %
5097 %
5049 \family default
5098 \family default
5050 variables.
5099 variables.
5051 \layout Standard
5100 \layout Standard
5052
5101
5053 The following GLOBAL variables always exist (so don't overwrite them!):
5102 The following GLOBAL variables always exist (so don't overwrite them!):
5054
5103
5055 \layout List
5104 \layout List
5056 \labelwidthstring 00.00.0000
5105 \labelwidthstring 00.00.0000
5057
5106
5058
5107
5059 \family typewriter
5108 \family typewriter
5060 \series bold
5109 \series bold
5061 _
5110 _
5062 \family default
5111 \family default
5063 \series default
5112 \series default
5064 (a
5113 (a
5065 \emph on
5114 \emph on
5066 single
5115 single
5067 \emph default
5116 \emph default
5068 underscore) : stores previous output, like Python's default interpreter.
5117 underscore) : stores previous output, like Python's default interpreter.
5069 \layout List
5118 \layout List
5070 \labelwidthstring 00.00.0000
5119 \labelwidthstring 00.00.0000
5071
5120
5072
5121
5073 \family typewriter
5122 \family typewriter
5074 \series bold
5123 \series bold
5075 __
5124 __
5076 \family default
5125 \family default
5077 \series default
5126 \series default
5078 (two underscores): next previous.
5127 (two underscores): next previous.
5079 \layout List
5128 \layout List
5080 \labelwidthstring 00.00.0000
5129 \labelwidthstring 00.00.0000
5081
5130
5082
5131
5083 \family typewriter
5132 \family typewriter
5084 \series bold
5133 \series bold
5085 ___
5134 ___
5086 \family default
5135 \family default
5087 \series default
5136 \series default
5088 (three underscores): next-next previous.
5137 (three underscores): next-next previous.
5089 \layout Standard
5138 \layout Standard
5090
5139
5091 Additionally, global variables named
5140 Additionally, global variables named
5092 \family typewriter
5141 \family typewriter
5093 _<n>
5142 _<n>
5094 \family default
5143 \family default
5095 are dynamically created (
5144 are dynamically created (
5096 \family typewriter
5145 \family typewriter
5097 <n>
5146 <n>
5098 \family default
5147 \family default
5099 being the prompt counter), such that the result of output
5148 being the prompt counter), such that the result of output
5100 \family typewriter
5149 \family typewriter
5101 <n>
5150 <n>
5102 \family default
5151 \family default
5103 is always available as
5152 is always available as
5104 \family typewriter
5153 \family typewriter
5105 _<n>
5154 _<n>
5106 \family default
5155 \family default
5107 (don't use the angle brackets, just the number, e.g.
5156 (don't use the angle brackets, just the number, e.g.
5108
5157
5109 \family typewriter
5158 \family typewriter
5110 _21
5159 _21
5111 \family default
5160 \family default
5112 ).
5161 ).
5113 \layout Standard
5162 \layout Standard
5114
5163
5115 These global variables are all stored in a global dictionary (not a list,
5164 These global variables are all stored in a global dictionary (not a list,
5116 since it only has entries for lines which returned a result) available
5165 since it only has entries for lines which returned a result) available
5117 under the names
5166 under the names
5118 \family typewriter
5167 \family typewriter
5119 _oh
5168 _oh
5120 \family default
5169 \family default
5121 and
5170 and
5122 \family typewriter
5171 \family typewriter
5123 Out
5172 Out
5124 \family default
5173 \family default
5125 (similar to
5174 (similar to
5126 \family typewriter
5175 \family typewriter
5127 _ih
5176 _ih
5128 \family default
5177 \family default
5129 and
5178 and
5130 \family typewriter
5179 \family typewriter
5131 In
5180 In
5132 \family default
5181 \family default
5133 ).
5182 ).
5134 So the output from line 12 can be obtained as
5183 So the output from line 12 can be obtained as
5135 \family typewriter
5184 \family typewriter
5136 _12
5185 _12
5137 \family default
5186 \family default
5138 ,
5187 ,
5139 \family typewriter
5188 \family typewriter
5140 Out[12]
5189 Out[12]
5141 \family default
5190 \family default
5142 or
5191 or
5143 \family typewriter
5192 \family typewriter
5144 _oh[12]
5193 _oh[12]
5145 \family default
5194 \family default
5146 .
5195 .
5147 If you accidentally overwrite the
5196 If you accidentally overwrite the
5148 \family typewriter
5197 \family typewriter
5149 Out
5198 Out
5150 \family default
5199 \family default
5151 variable you can recover it by typing
5200 variable you can recover it by typing
5152 \family typewriter
5201 \family typewriter
5153 'Out=_oh
5202 'Out=_oh
5154 \family default
5203 \family default
5155 ' at the prompt.
5204 ' at the prompt.
5156 \layout Standard
5205 \layout Standard
5157
5206
5158 This system obviously can potentially put heavy memory demands on your system,
5207 This system obviously can potentially put heavy memory demands on your system,
5159 since it prevents Python's garbage collector from removing any previously
5208 since it prevents Python's garbage collector from removing any previously
5160 computed results.
5209 computed results.
5161 You can control how many results are kept in memory with the option (at
5210 You can control how many results are kept in memory with the option (at
5162 the command line or in your
5211 the command line or in your
5163 \family typewriter
5212 \family typewriter
5164 ipythonrc
5213 ipythonrc
5165 \family default
5214 \family default
5166 file)
5215 file)
5167 \family typewriter
5216 \family typewriter
5168 cache_size
5217 cache_size
5169 \family default
5218 \family default
5170 .
5219 .
5171 If you set it to 0, the whole system is completely disabled and the prompts
5220 If you set it to 0, the whole system is completely disabled and the prompts
5172 revert to the classic
5221 revert to the classic
5173 \family typewriter
5222 \family typewriter
5174 '>>>'
5223 '>>>'
5175 \family default
5224 \family default
5176 of normal Python.
5225 of normal Python.
5177 \layout Subsection
5226 \layout Subsection
5178
5227
5179 Directory history
5228 Directory history
5180 \layout Standard
5229 \layout Standard
5181
5230
5182 Your history of visited directories is kept in the global list
5231 Your history of visited directories is kept in the global list
5183 \family typewriter
5232 \family typewriter
5184 _dh
5233 _dh
5185 \family default
5234 \family default
5186 , and the magic
5235 , and the magic
5187 \family typewriter
5236 \family typewriter
5188 %cd
5237 %cd
5189 \family default
5238 \family default
5190 command can be used to go to any entry in that list.
5239 command can be used to go to any entry in that list.
5191 The
5240 The
5192 \family typewriter
5241 \family typewriter
5193 %dhist
5242 %dhist
5194 \family default
5243 \family default
5195 command allows you to view this history.
5244 command allows you to view this history.
5196 \layout Subsection
5245 \layout Subsection
5197
5246
5198 Automatic parentheses and quotes
5247 Automatic parentheses and quotes
5199 \layout Standard
5248 \layout Standard
5200
5249
5201 These features were adapted from Nathan Gray's LazyPython.
5250 These features were adapted from Nathan Gray's LazyPython.
5202 They are meant to allow less typing for common situations.
5251 They are meant to allow less typing for common situations.
5203 \layout Subsubsection
5252 \layout Subsubsection
5204
5253
5205 Automatic parentheses
5254 Automatic parentheses
5206 \layout Standard
5255 \layout Standard
5207
5256
5208 Callable objects (i.e.
5257 Callable objects (i.e.
5209 functions, methods, etc) can be invoked like this (notice the commas between
5258 functions, methods, etc) can be invoked like this (notice the commas between
5210 the arguments):
5259 the arguments):
5211 \layout Standard
5260 \layout Standard
5212
5261
5213
5262
5214 \family typewriter
5263 \family typewriter
5215 >>> callable_ob arg1, arg2, arg3
5264 >>> callable_ob arg1, arg2, arg3
5216 \layout Standard
5265 \layout Standard
5217
5266
5218 and the input will be translated to this:
5267 and the input will be translated to this:
5219 \layout Standard
5268 \layout Standard
5220
5269
5221
5270
5222 \family typewriter
5271 \family typewriter
5223 --> callable_ob(arg1, arg2, arg3)
5272 --> callable_ob(arg1, arg2, arg3)
5224 \layout Standard
5273 \layout Standard
5225
5274
5226 You can force automatic parentheses by using '/' as the first character
5275 You can force automatic parentheses by using '/' as the first character
5227 of a line.
5276 of a line.
5228 For example:
5277 For example:
5229 \layout Standard
5278 \layout Standard
5230
5279
5231
5280
5232 \family typewriter
5281 \family typewriter
5233 >>> /globals # becomes 'globals()'
5282 >>> /globals # becomes 'globals()'
5234 \layout Standard
5283 \layout Standard
5235
5284
5236 Note that the '/' MUST be the first character on the line! This won't work:
5285 Note that the '/' MUST be the first character on the line! This won't work:
5237
5286
5238 \layout Standard
5287 \layout Standard
5239
5288
5240
5289
5241 \family typewriter
5290 \family typewriter
5242 >>> print /globals # syntax error
5291 >>> print /globals # syntax error
5243 \layout Standard
5292 \layout Standard
5244
5293
5245 In most cases the automatic algorithm should work, so you should rarely
5294 In most cases the automatic algorithm should work, so you should rarely
5246 need to explicitly invoke /.
5295 need to explicitly invoke /.
5247 One notable exception is if you are trying to call a function with a list
5296 One notable exception is if you are trying to call a function with a list
5248 of tuples as arguments (the parenthesis will confuse IPython):
5297 of tuples as arguments (the parenthesis will confuse IPython):
5249 \layout Standard
5298 \layout Standard
5250
5299
5251
5300
5252 \family typewriter
5301 \family typewriter
5253 In [1]: zip (1,2,3),(4,5,6) # won't work
5302 In [1]: zip (1,2,3),(4,5,6) # won't work
5254 \layout Standard
5303 \layout Standard
5255
5304
5256 but this will work:
5305 but this will work:
5257 \layout Standard
5306 \layout Standard
5258
5307
5259
5308
5260 \family typewriter
5309 \family typewriter
5261 In [2]: /zip (1,2,3),(4,5,6)
5310 In [2]: /zip (1,2,3),(4,5,6)
5262 \newline
5311 \newline
5263 ------> zip ((1,2,3),(4,5,6))
5312 ------> zip ((1,2,3),(4,5,6))
5264 \newline
5313 \newline
5265 Out[2]= [(1, 4), (2, 5), (3, 6)]
5314 Out[2]= [(1, 4), (2, 5), (3, 6)]
5266 \layout Standard
5315 \layout Standard
5267
5316
5268 IPython tells you that it has altered your command line by displaying the
5317 IPython tells you that it has altered your command line by displaying the
5269 new command line preceded by
5318 new command line preceded by
5270 \family typewriter
5319 \family typewriter
5271 -->
5320 -->
5272 \family default
5321 \family default
5273 .
5322 .
5274 e.g.:
5323 e.g.:
5275 \layout Standard
5324 \layout Standard
5276
5325
5277
5326
5278 \family typewriter
5327 \family typewriter
5279 In [18]: callable list
5328 In [18]: callable list
5280 \newline
5329 \newline
5281 -------> callable (list)
5330 -------> callable (list)
5282 \layout Subsubsection
5331 \layout Subsubsection
5283
5332
5284 Automatic quoting
5333 Automatic quoting
5285 \layout Standard
5334 \layout Standard
5286
5335
5287 You can force automatic quoting of a function's arguments by using
5336 You can force automatic quoting of a function's arguments by using
5288 \family typewriter
5337 \family typewriter
5289 `,'
5338 `,'
5290 \family default
5339 \family default
5291 or
5340 or
5292 \family typewriter
5341 \family typewriter
5293 `;'
5342 `;'
5294 \family default
5343 \family default
5295 as the first character of a line.
5344 as the first character of a line.
5296 For example:
5345 For example:
5297 \layout Standard
5346 \layout Standard
5298
5347
5299
5348
5300 \family typewriter
5349 \family typewriter
5301 >>> ,my_function /home/me # becomes my_function("/home/me")
5350 >>> ,my_function /home/me # becomes my_function("/home/me")
5302 \layout Standard
5351 \layout Standard
5303
5352
5304 If you use
5353 If you use
5305 \family typewriter
5354 \family typewriter
5306 `;'
5355 `;'
5307 \family default
5356 \family default
5308 instead, the whole argument is quoted as a single string (while
5357 instead, the whole argument is quoted as a single string (while
5309 \family typewriter
5358 \family typewriter
5310 `,'
5359 `,'
5311 \family default
5360 \family default
5312 splits on whitespace):
5361 splits on whitespace):
5313 \layout Standard
5362 \layout Standard
5314
5363
5315
5364
5316 \family typewriter
5365 \family typewriter
5317 >>> ,my_function a b c # becomes my_function("a","b","c")
5366 >>> ,my_function a b c # becomes my_function("a","b","c")
5318 \layout Standard
5367 \layout Standard
5319
5368
5320
5369
5321 \family typewriter
5370 \family typewriter
5322 >>> ;my_function a b c # becomes my_function("a b c")
5371 >>> ;my_function a b c # becomes my_function("a b c")
5323 \layout Standard
5372 \layout Standard
5324
5373
5325 Note that the `
5374 Note that the `
5326 \family typewriter
5375 \family typewriter
5327 ,
5376 ,
5328 \family default
5377 \family default
5329 ' or `
5378 ' or `
5330 \family typewriter
5379 \family typewriter
5331 ;
5380 ;
5332 \family default
5381 \family default
5333 ' MUST be the first character on the line! This won't work:
5382 ' MUST be the first character on the line! This won't work:
5334 \layout Standard
5383 \layout Standard
5335
5384
5336
5385
5337 \family typewriter
5386 \family typewriter
5338 >>> x = ,my_function /home/me # syntax error
5387 >>> x = ,my_function /home/me # syntax error
5339 \layout Section
5388 \layout Section
5340
5389
5341
5390
5342 \begin_inset LatexCommand \label{sec:customization}
5391 \begin_inset LatexCommand \label{sec:customization}
5343
5392
5344 \end_inset
5393 \end_inset
5345
5394
5346 Customization
5395 Customization
5347 \layout Standard
5396 \layout Standard
5348
5397
5349 As we've already mentioned, IPython reads a configuration file which can
5398 As we've already mentioned, IPython reads a configuration file which can
5350 be specified at the command line (
5399 be specified at the command line (
5351 \family typewriter
5400 \family typewriter
5352 -rcfile
5401 -rcfile
5353 \family default
5402 \family default
5354 ) or which by default is assumed to be called
5403 ) or which by default is assumed to be called
5355 \family typewriter
5404 \family typewriter
5356 ipythonrc
5405 ipythonrc
5357 \family default
5406 \family default
5358 .
5407 .
5359 Such a file is looked for in the current directory where IPython is started
5408 Such a file is looked for in the current directory where IPython is started
5360 and then in your
5409 and then in your
5361 \family typewriter
5410 \family typewriter
5362 IPYTHONDIR
5411 IPYTHONDIR
5363 \family default
5412 \family default
5364 , which allows you to have local configuration files for specific projects.
5413 , which allows you to have local configuration files for specific projects.
5365 In this section we will call these types of configuration files simply
5414 In this section we will call these types of configuration files simply
5366 rcfiles (short for resource configuration file).
5415 rcfiles (short for resource configuration file).
5367 \layout Standard
5416 \layout Standard
5368
5417
5369 The syntax of an rcfile is one of key-value pairs separated by whitespace,
5418 The syntax of an rcfile is one of key-value pairs separated by whitespace,
5370 one per line.
5419 one per line.
5371 Lines beginning with a
5420 Lines beginning with a
5372 \family typewriter
5421 \family typewriter
5373 #
5422 #
5374 \family default
5423 \family default
5375 are ignored as comments, but comments can
5424 are ignored as comments, but comments can
5376 \series bold
5425 \series bold
5377 not
5426 not
5378 \series default
5427 \series default
5379 be put on lines with data (the parser is fairly primitive).
5428 be put on lines with data (the parser is fairly primitive).
5380 Note that these are not python files, and this is deliberate, because it
5429 Note that these are not python files, and this is deliberate, because it
5381 allows us to do some things which would be quite tricky to implement if
5430 allows us to do some things which would be quite tricky to implement if
5382 they were normal python files.
5431 they were normal python files.
5383 \layout Standard
5432 \layout Standard
5384
5433
5385 First, an rcfile can contain permanent default values for almost all command
5434 First, an rcfile can contain permanent default values for almost all command
5386 line options (except things like
5435 line options (except things like
5387 \family typewriter
5436 \family typewriter
5388 -help
5437 -help
5389 \family default
5438 \family default
5390 or
5439 or
5391 \family typewriter
5440 \family typewriter
5392 -Version
5441 -Version
5393 \family default
5442 \family default
5394 ).
5443 ).
5395 Sec\SpecialChar ~
5444 Sec\SpecialChar ~
5396
5445
5397 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
5446 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
5398
5447
5399 \end_inset
5448 \end_inset
5400
5449
5401 contains a description of all command-line options.
5450 contains a description of all command-line options.
5402 However, values you explicitly specify at the command line override the
5451 However, values you explicitly specify at the command line override the
5403 values defined in the rcfile.
5452 values defined in the rcfile.
5404 \layout Standard
5453 \layout Standard
5405
5454
5406 Besides command line option values, the rcfile can specify values for certain
5455 Besides command line option values, the rcfile can specify values for certain
5407 extra special options which are not available at the command line.
5456 extra special options which are not available at the command line.
5408 These options are briefly described below.
5457 These options are briefly described below.
5409
5458
5410 \layout Standard
5459 \layout Standard
5411
5460
5412 Each of these options may appear as many times as you need it in the file.
5461 Each of these options may appear as many times as you need it in the file.
5413 \layout List
5462 \layout List
5414 \labelwidthstring 00.00.0000
5463 \labelwidthstring 00.00.0000
5415
5464
5416
5465
5417 \family typewriter
5466 \family typewriter
5418 \series bold
5467 \series bold
5419 include\SpecialChar ~
5468 include\SpecialChar ~
5420 <file1>\SpecialChar ~
5469 <file1>\SpecialChar ~
5421 <file2>\SpecialChar ~
5470 <file2>\SpecialChar ~
5422 ...
5471 ...
5423 \family default
5472 \family default
5424 \series default
5473 \series default
5425 : you can name
5474 : you can name
5426 \emph on
5475 \emph on
5427 other
5476 other
5428 \emph default
5477 \emph default
5429 rcfiles you want to recursively load up to 15 levels (don't use the
5478 rcfiles you want to recursively load up to 15 levels (don't use the
5430 \family typewriter
5479 \family typewriter
5431 <>
5480 <>
5432 \family default
5481 \family default
5433 brackets in your names!).
5482 brackets in your names!).
5434 This feature allows you to define a 'base' rcfile with general options
5483 This feature allows you to define a 'base' rcfile with general options
5435 and special-purpose files which can be loaded only when needed with particular
5484 and special-purpose files which can be loaded only when needed with particular
5436 configuration options.
5485 configuration options.
5437 To make this more convenient, IPython accepts the
5486 To make this more convenient, IPython accepts the
5438 \family typewriter
5487 \family typewriter
5439 -profile <name>
5488 -profile <name>
5440 \family default
5489 \family default
5441 option (abbreviates to
5490 option (abbreviates to
5442 \family typewriter
5491 \family typewriter
5443 -p <name
5492 -p <name
5444 \family default
5493 \family default
5445 >)
5494 >)
5446 \family typewriter
5495 \family typewriter
5447 which
5496 which
5448 \family default
5497 \family default
5449 tells it to look for an rcfile named
5498 tells it to look for an rcfile named
5450 \family typewriter
5499 \family typewriter
5451 ipythonrc-<name>
5500 ipythonrc-<name>
5452 \family default
5501 \family default
5453 .
5502 .
5454
5503
5455 \layout List
5504 \layout List
5456 \labelwidthstring 00.00.0000
5505 \labelwidthstring 00.00.0000
5457
5506
5458
5507
5459 \family typewriter
5508 \family typewriter
5460 \series bold
5509 \series bold
5461 import_mod\SpecialChar ~
5510 import_mod\SpecialChar ~
5462 <mod1>\SpecialChar ~
5511 <mod1>\SpecialChar ~
5463 <mod2>\SpecialChar ~
5512 <mod2>\SpecialChar ~
5464 ...
5513 ...
5465 \family default
5514 \family default
5466 \series default
5515 \series default
5467 : import modules with '
5516 : import modules with '
5468 \family typewriter
5517 \family typewriter
5469 import
5518 import
5470 \family default
5519 \family default
5471
5520
5472 \family typewriter
5521 \family typewriter
5473 <mod1>,<mod2>,...
5522 <mod1>,<mod2>,...
5474 \family default
5523 \family default
5475 '
5524 '
5476 \layout List
5525 \layout List
5477 \labelwidthstring 00.00.0000
5526 \labelwidthstring 00.00.0000
5478
5527
5479
5528
5480 \family typewriter
5529 \family typewriter
5481 \series bold
5530 \series bold
5482 import_some\SpecialChar ~
5531 import_some\SpecialChar ~
5483 <mod>\SpecialChar ~
5532 <mod>\SpecialChar ~
5484 <f1>\SpecialChar ~
5533 <f1>\SpecialChar ~
5485 <f2>\SpecialChar ~
5534 <f2>\SpecialChar ~
5486 ...
5535 ...
5487 \family default
5536 \family default
5488 \series default
5537 \series default
5489 : import functions with '
5538 : import functions with '
5490 \family typewriter
5539 \family typewriter
5491 from <mod> import
5540 from <mod> import
5492 \family default
5541 \family default
5493
5542
5494 \family typewriter
5543 \family typewriter
5495 <f1>,<f2>,...
5544 <f1>,<f2>,...
5496 \family default
5545 \family default
5497 '
5546 '
5498 \layout List
5547 \layout List
5499 \labelwidthstring 00.00.0000
5548 \labelwidthstring 00.00.0000
5500
5549
5501
5550
5502 \family typewriter
5551 \family typewriter
5503 \series bold
5552 \series bold
5504 import_all\SpecialChar ~
5553 import_all\SpecialChar ~
5505 <mod1>\SpecialChar ~
5554 <mod1>\SpecialChar ~
5506 <mod2>\SpecialChar ~
5555 <mod2>\SpecialChar ~
5507 ...
5556 ...
5508 \family default
5557 \family default
5509 \series default
5558 \series default
5510 : for each module listed import functions with '
5559 : for each module listed import functions with '
5511 \family typewriter
5560 \family typewriter
5512 from <mod> import *
5561 from <mod> import *
5513 \family default
5562 \family default
5514 '
5563 '
5515 \layout List
5564 \layout List
5516 \labelwidthstring 00.00.0000
5565 \labelwidthstring 00.00.0000
5517
5566
5518
5567
5519 \family typewriter
5568 \family typewriter
5520 \series bold
5569 \series bold
5521 execute\SpecialChar ~
5570 execute\SpecialChar ~
5522 <python\SpecialChar ~
5571 <python\SpecialChar ~
5523 code>
5572 code>
5524 \family default
5573 \family default
5525 \series default
5574 \series default
5526 : give any single-line python code to be executed.
5575 : give any single-line python code to be executed.
5527 \layout List
5576 \layout List
5528 \labelwidthstring 00.00.0000
5577 \labelwidthstring 00.00.0000
5529
5578
5530
5579
5531 \family typewriter
5580 \family typewriter
5532 \series bold
5581 \series bold
5533 execfile\SpecialChar ~
5582 execfile\SpecialChar ~
5534 <filename>
5583 <filename>
5535 \family default
5584 \family default
5536 \series default
5585 \series default
5537 : execute the python file given with an '
5586 : execute the python file given with an '
5538 \family typewriter
5587 \family typewriter
5539 execfile(filename)
5588 execfile(filename)
5540 \family default
5589 \family default
5541 ' command.
5590 ' command.
5542 Username expansion is performed on the given names.
5591 Username expansion is performed on the given names.
5543 So if you need any amount of extra fancy customization that won't fit in
5592 So if you need any amount of extra fancy customization that won't fit in
5544 any of the above 'canned' options, you can just put it in a separate python
5593 any of the above 'canned' options, you can just put it in a separate python
5545 file and execute it.
5594 file and execute it.
5546 \layout List
5595 \layout List
5547 \labelwidthstring 00.00.0000
5596 \labelwidthstring 00.00.0000
5548
5597
5549
5598
5550 \family typewriter
5599 \family typewriter
5551 \series bold
5600 \series bold
5552 alias\SpecialChar ~
5601 alias\SpecialChar ~
5553 <alias_def>
5602 <alias_def>
5554 \family default
5603 \family default
5555 \series default
5604 \series default
5556 : this is equivalent to calling '
5605 : this is equivalent to calling '
5557 \family typewriter
5606 \family typewriter
5558 %alias\SpecialChar ~
5607 %alias\SpecialChar ~
5559 <alias_def>
5608 <alias_def>
5560 \family default
5609 \family default
5561 ' at the IPython command line.
5610 ' at the IPython command line.
5562 This way, from within IPython you can do common system tasks without having
5611 This way, from within IPython you can do common system tasks without having
5563 to exit it or use the
5612 to exit it or use the
5564 \family typewriter
5613 \family typewriter
5565 !
5614 !
5566 \family default
5615 \family default
5567 escape.
5616 escape.
5568 IPython isn't meant to be a shell replacement, but it is often very useful
5617 IPython isn't meant to be a shell replacement, but it is often very useful
5569 to be able to do things with files while testing code.
5618 to be able to do things with files while testing code.
5570 This gives you the flexibility to have within IPython any aliases you may
5619 This gives you the flexibility to have within IPython any aliases you may
5571 be used to under your normal system shell.
5620 be used to under your normal system shell.
5572 \layout Subsection
5621 \layout Subsection
5573
5622
5574
5623
5575 \begin_inset LatexCommand \label{sec:ipytonrc-sample}
5624 \begin_inset LatexCommand \label{sec:ipytonrc-sample}
5576
5625
5577 \end_inset
5626 \end_inset
5578
5627
5579 Sample
5628 Sample
5580 \family typewriter
5629 \family typewriter
5581 ipythonrc
5630 ipythonrc
5582 \family default
5631 \family default
5583 file
5632 file
5584 \layout Standard
5633 \layout Standard
5585
5634
5586 The default rcfile, called
5635 The default rcfile, called
5587 \family typewriter
5636 \family typewriter
5588 ipythonrc
5637 ipythonrc
5589 \family default
5638 \family default
5590 and supplied in your
5639 and supplied in your
5591 \family typewriter
5640 \family typewriter
5592 IPYTHONDIR
5641 IPYTHONDIR
5593 \family default
5642 \family default
5594 directory contains lots of comments on all of these options.
5643 directory contains lots of comments on all of these options.
5595 We reproduce it here for reference:
5644 We reproduce it here for reference:
5596 \layout Standard
5645 \layout Standard
5597
5646
5598
5647
5599 \begin_inset ERT
5648 \begin_inset ERT
5600 status Open
5649 status Open
5601
5650
5602 \layout Standard
5651 \layout Standard
5603
5652
5604 \backslash
5653 \backslash
5605 codelist{../IPython/UserConfig/ipythonrc}
5654 codelist{../IPython/UserConfig/ipythonrc}
5606 \end_inset
5655 \end_inset
5607
5656
5608
5657
5609 \layout Subsection
5658 \layout Subsection
5610
5659
5611
5660
5612 \begin_inset LatexCommand \label{sec:prompts}
5661 \begin_inset LatexCommand \label{sec:prompts}
5613
5662
5614 \end_inset
5663 \end_inset
5615
5664
5616 Fine-tuning your prompt
5665 Fine-tuning your prompt
5617 \layout Standard
5666 \layout Standard
5618
5667
5619 IPython's prompts can be customized using a syntax similar to that of the
5668 IPython's prompts can be customized using a syntax similar to that of the
5620
5669
5621 \family typewriter
5670 \family typewriter
5622 bash
5671 bash
5623 \family default
5672 \family default
5624 shell.
5673 shell.
5625 Many of
5674 Many of
5626 \family typewriter
5675 \family typewriter
5627 bash
5676 bash
5628 \family default
5677 \family default
5629 's escapes are supported, as well as a few additional ones.
5678 's escapes are supported, as well as a few additional ones.
5630 We list them below:
5679 We list them below:
5631 \layout Description
5680 \layout Description
5632
5681
5633
5682
5634 \backslash
5683 \backslash
5635 # the prompt/history count number
5684 # the prompt/history count number
5636 \layout Description
5685 \layout Description
5637
5686
5638
5687
5639 \backslash
5688 \backslash
5640 D the prompt/history count, with the actual digits replaced by dots.
5689 D the prompt/history count, with the actual digits replaced by dots.
5641 Used mainly in continuation prompts (prompt_in2)
5690 Used mainly in continuation prompts (prompt_in2)
5642 \layout Description
5691 \layout Description
5643
5692
5644
5693
5645 \backslash
5694 \backslash
5646 w the current working directory
5695 w the current working directory
5647 \layout Description
5696 \layout Description
5648
5697
5649
5698
5650 \backslash
5699 \backslash
5651 W the basename of current working directory
5700 W the basename of current working directory
5652 \layout Description
5701 \layout Description
5653
5702
5654
5703
5655 \backslash
5704 \backslash
5656 X
5705 X
5657 \emph on
5706 \emph on
5658 n
5707 n
5659 \emph default
5708 \emph default
5660 where
5709 where
5661 \begin_inset Formula $n=0\ldots5.$
5710 \begin_inset Formula $n=0\ldots5.$
5662 \end_inset
5711 \end_inset
5663
5712
5664 The current working directory, with
5713 The current working directory, with
5665 \family typewriter
5714 \family typewriter
5666 $HOME
5715 $HOME
5667 \family default
5716 \family default
5668 replaced by
5717 replaced by
5669 \family typewriter
5718 \family typewriter
5670 ~
5719 ~
5671 \family default
5720 \family default
5672 , and filtered out to contain only
5721 , and filtered out to contain only
5673 \begin_inset Formula $n$
5722 \begin_inset Formula $n$
5674 \end_inset
5723 \end_inset
5675
5724
5676 path elements
5725 path elements
5677 \layout Description
5726 \layout Description
5678
5727
5679
5728
5680 \backslash
5729 \backslash
5681 Y
5730 Y
5682 \emph on
5731 \emph on
5683 n
5732 n
5684 \emph default
5733 \emph default
5685 Similar to
5734 Similar to
5686 \backslash
5735 \backslash
5687 X
5736 X
5688 \emph on
5737 \emph on
5689 n
5738 n
5690 \emph default
5739 \emph default
5691 , but with the
5740 , but with the
5692 \begin_inset Formula $n+1$
5741 \begin_inset Formula $n+1$
5693 \end_inset
5742 \end_inset
5694
5743
5695 element included if it is
5744 element included if it is
5696 \family typewriter
5745 \family typewriter
5697 ~
5746 ~
5698 \family default
5747 \family default
5699 (this is similar to the behavior of the %c
5748 (this is similar to the behavior of the %c
5700 \emph on
5749 \emph on
5701 n
5750 n
5702 \emph default
5751 \emph default
5703 escapes in
5752 escapes in
5704 \family typewriter
5753 \family typewriter
5705 tcsh
5754 tcsh
5706 \family default
5755 \family default
5707 )
5756 )
5708 \layout Description
5757 \layout Description
5709
5758
5710
5759
5711 \backslash
5760 \backslash
5712 u the username of the current user
5761 u the username of the current user
5713 \layout Description
5762 \layout Description
5714
5763
5715
5764
5716 \backslash
5765 \backslash
5717 $ if the effective UID is 0, a #, otherwise a $
5766 $ if the effective UID is 0, a #, otherwise a $
5718 \layout Description
5767 \layout Description
5719
5768
5720
5769
5721 \backslash
5770 \backslash
5722 h the hostname up to the first `.'
5771 h the hostname up to the first `.'
5723 \layout Description
5772 \layout Description
5724
5773
5725
5774
5726 \backslash
5775 \backslash
5727 H the hostname
5776 H the hostname
5728 \layout Description
5777 \layout Description
5729
5778
5730
5779
5731 \backslash
5780 \backslash
5732 n a newline
5781 n a newline
5733 \layout Description
5782 \layout Description
5734
5783
5735
5784
5736 \backslash
5785 \backslash
5737 r a carriage return
5786 r a carriage return
5738 \layout Description
5787 \layout Description
5739
5788
5740
5789
5741 \backslash
5790 \backslash
5742 v IPython version string
5791 v IPython version string
5743 \layout Standard
5792 \layout Standard
5744
5793
5745 In addition to these, ANSI color escapes can be insterted into the prompts,
5794 In addition to these, ANSI color escapes can be insterted into the prompts,
5746 as
5795 as
5747 \family typewriter
5796 \family typewriter
5748
5797
5749 \backslash
5798 \backslash
5750 C_
5799 C_
5751 \emph on
5800 \emph on
5752 ColorName
5801 ColorName
5753 \family default
5802 \family default
5754 \emph default
5803 \emph default
5755 .
5804 .
5756 The list of valid color names is: Black, Blue, Brown, Cyan, DarkGray, Green,
5805 The list of valid color names is: Black, Blue, Brown, Cyan, DarkGray, Green,
5757 LightBlue, LightCyan, LightGray, LightGreen, LightPurple, LightRed, NoColor,
5806 LightBlue, LightCyan, LightGray, LightGreen, LightPurple, LightRed, NoColor,
5758 Normal, Purple, Red, White, Yellow.
5807 Normal, Purple, Red, White, Yellow.
5759 \layout Standard
5808 \layout Standard
5760
5809
5761 Finally, IPython supports the evaluation of arbitrary expressions in your
5810 Finally, IPython supports the evaluation of arbitrary expressions in your
5762 prompt string.
5811 prompt string.
5763 The prompt strings are evaluated through the syntax of PEP 215, but basically
5812 The prompt strings are evaluated through the syntax of PEP 215, but basically
5764 you can use
5813 you can use
5765 \family typewriter
5814 \family typewriter
5766 $x.y
5815 $x.y
5767 \family default
5816 \family default
5768 to expand the value of
5817 to expand the value of
5769 \family typewriter
5818 \family typewriter
5770 x.y
5819 x.y
5771 \family default
5820 \family default
5772 , and for more complicated expressions you can use braces:
5821 , and for more complicated expressions you can use braces:
5773 \family typewriter
5822 \family typewriter
5774 ${foo()+x}
5823 ${foo()+x}
5775 \family default
5824 \family default
5776 will call function
5825 will call function
5777 \family typewriter
5826 \family typewriter
5778 foo
5827 foo
5779 \family default
5828 \family default
5780 and add to it the value of
5829 and add to it the value of
5781 \family typewriter
5830 \family typewriter
5782 x
5831 x
5783 \family default
5832 \family default
5784 , before putting the result into your prompt.
5833 , before putting the result into your prompt.
5785 For example, using
5834 For example, using
5786 \newline
5835 \newline
5787
5836
5788 \family typewriter
5837 \family typewriter
5789 prompt_in1 '${commands.getoutput("uptime")}
5838 prompt_in1 '${commands.getoutput("uptime")}
5790 \backslash
5839 \backslash
5791 nIn [
5840 nIn [
5792 \backslash
5841 \backslash
5793 #]: '
5842 #]: '
5794 \newline
5843 \newline
5795
5844
5796 \family default
5845 \family default
5797 will print the result of the uptime command on each prompt (assuming the
5846 will print the result of the uptime command on each prompt (assuming the
5798
5847
5799 \family typewriter
5848 \family typewriter
5800 commands
5849 commands
5801 \family default
5850 \family default
5802 module has been imported in your
5851 module has been imported in your
5803 \family typewriter
5852 \family typewriter
5804 ipythonrc
5853 ipythonrc
5805 \family default
5854 \family default
5806 file).
5855 file).
5807 \layout Subsubsection
5856 \layout Subsubsection
5808
5857
5809 Prompt examples
5858 Prompt examples
5810 \layout Standard
5859 \layout Standard
5811
5860
5812 The following options in an ipythonrc file will give you IPython's default
5861 The following options in an ipythonrc file will give you IPython's default
5813 prompts:
5862 prompts:
5814 \layout Standard
5863 \layout Standard
5815
5864
5816
5865
5817 \family typewriter
5866 \family typewriter
5818 prompt_in1 'In [
5867 prompt_in1 'In [
5819 \backslash
5868 \backslash
5820 #]:'
5869 #]:'
5821 \newline
5870 \newline
5822 prompt_in2 '\SpecialChar ~
5871 prompt_in2 '\SpecialChar ~
5823 \SpecialChar ~
5872 \SpecialChar ~
5824 \SpecialChar ~
5873 \SpecialChar ~
5825 .
5874 .
5826 \backslash
5875 \backslash
5827 D.:'
5876 D.:'
5828 \newline
5877 \newline
5829 prompt_out 'Out[
5878 prompt_out 'Out[
5830 \backslash
5879 \backslash
5831 #]:'
5880 #]:'
5832 \layout Standard
5881 \layout Standard
5833
5882
5834 which look like this:
5883 which look like this:
5835 \layout Standard
5884 \layout Standard
5836
5885
5837
5886
5838 \family typewriter
5887 \family typewriter
5839 In [1]: 1+2
5888 In [1]: 1+2
5840 \newline
5889 \newline
5841 Out[1]: 3
5890 Out[1]: 3
5842 \layout Standard
5891 \layout Standard
5843
5892
5844
5893
5845 \family typewriter
5894 \family typewriter
5846 In [2]: for i in (1,2,3):
5895 In [2]: for i in (1,2,3):
5847 \newline
5896 \newline
5848
5897
5849 \begin_inset ERT
5898 \begin_inset ERT
5850 status Collapsed
5899 status Collapsed
5851
5900
5852 \layout Standard
5901 \layout Standard
5853
5902
5854 \backslash
5903 \backslash
5855 hspace*{0mm}
5904 hspace*{0mm}
5856 \end_inset
5905 \end_inset
5857
5906
5858 \SpecialChar ~
5907 \SpecialChar ~
5859 \SpecialChar ~
5908 \SpecialChar ~
5860 \SpecialChar ~
5909 \SpecialChar ~
5861 ...: \SpecialChar ~
5910 ...: \SpecialChar ~
5862 \SpecialChar ~
5911 \SpecialChar ~
5863 \SpecialChar ~
5912 \SpecialChar ~
5864 \SpecialChar ~
5913 \SpecialChar ~
5865 print i,
5914 print i,
5866 \newline
5915 \newline
5867
5916
5868 \begin_inset ERT
5917 \begin_inset ERT
5869 status Collapsed
5918 status Collapsed
5870
5919
5871 \layout Standard
5920 \layout Standard
5872
5921
5873 \backslash
5922 \backslash
5874 hspace*{0mm}
5923 hspace*{0mm}
5875 \end_inset
5924 \end_inset
5876
5925
5877 \SpecialChar ~
5926 \SpecialChar ~
5878 \SpecialChar ~
5927 \SpecialChar ~
5879 \SpecialChar ~
5928 \SpecialChar ~
5880 ...:
5929 ...:
5881 \newline
5930 \newline
5882 1 2 3
5931 1 2 3
5883 \layout Standard
5932 \layout Standard
5884
5933
5885 These will give you a very colorful prompt with path information:
5934 These will give you a very colorful prompt with path information:
5886 \layout Standard
5935 \layout Standard
5887
5936
5888
5937
5889 \family typewriter
5938 \family typewriter
5890 #prompt_in1 '
5939 #prompt_in1 '
5891 \backslash
5940 \backslash
5892 C_Red
5941 C_Red
5893 \backslash
5942 \backslash
5894 u
5943 u
5895 \backslash
5944 \backslash
5896 C_Blue[
5945 C_Blue[
5897 \backslash
5946 \backslash
5898 C_Cyan
5947 C_Cyan
5899 \backslash
5948 \backslash
5900 Y1
5949 Y1
5901 \backslash
5950 \backslash
5902 C_Blue]
5951 C_Blue]
5903 \backslash
5952 \backslash
5904 C_LightGreen
5953 C_LightGreen
5905 \backslash
5954 \backslash
5906 #>'
5955 #>'
5907 \newline
5956 \newline
5908 prompt_in2 ' ..
5957 prompt_in2 ' ..
5909 \backslash
5958 \backslash
5910 D>'
5959 D>'
5911 \newline
5960 \newline
5912 prompt_out '<
5961 prompt_out '<
5913 \backslash
5962 \backslash
5914 #>'
5963 #>'
5915 \layout Standard
5964 \layout Standard
5916
5965
5917 which look like this:
5966 which look like this:
5918 \layout Standard
5967 \layout Standard
5919
5968
5920
5969
5921 \family typewriter
5970 \family typewriter
5922 \color red
5971 \color red
5923 fperez
5972 fperez
5924 \color blue
5973 \color blue
5925 [
5974 [
5926 \color cyan
5975 \color cyan
5927 ~/ipython
5976 ~/ipython
5928 \color blue
5977 \color blue
5929 ]
5978 ]
5930 \color green
5979 \color green
5931 1>
5980 1>
5932 \color default
5981 \color default
5933 1+2
5982 1+2
5934 \newline
5983 \newline
5935
5984
5936 \begin_inset ERT
5985 \begin_inset ERT
5937 status Collapsed
5986 status Collapsed
5938
5987
5939 \layout Standard
5988 \layout Standard
5940
5989
5941 \backslash
5990 \backslash
5942 hspace*{0mm}
5991 hspace*{0mm}
5943 \end_inset
5992 \end_inset
5944
5993
5945 \SpecialChar ~
5994 \SpecialChar ~
5946 \SpecialChar ~
5995 \SpecialChar ~
5947 \SpecialChar ~
5996 \SpecialChar ~
5948 \SpecialChar ~
5997 \SpecialChar ~
5949 \SpecialChar ~
5998 \SpecialChar ~
5950 \SpecialChar ~
5999 \SpecialChar ~
5951 \SpecialChar ~
6000 \SpecialChar ~
5952 \SpecialChar ~
6001 \SpecialChar ~
5953 \SpecialChar ~
6002 \SpecialChar ~
5954 \SpecialChar ~
6003 \SpecialChar ~
5955 \SpecialChar ~
6004 \SpecialChar ~
5956 \SpecialChar ~
6005 \SpecialChar ~
5957 \SpecialChar ~
6006 \SpecialChar ~
5958 \SpecialChar ~
6007 \SpecialChar ~
5959 \SpecialChar ~
6008 \SpecialChar ~
5960 \SpecialChar ~
6009 \SpecialChar ~
5961
6010
5962 \color red
6011 \color red
5963 <1>
6012 <1>
5964 \color default
6013 \color default
5965 3
6014 3
5966 \newline
6015 \newline
5967
6016
5968 \color red
6017 \color red
5969 fperez
6018 fperez
5970 \color blue
6019 \color blue
5971 [
6020 [
5972 \color cyan
6021 \color cyan
5973 ~/ipython
6022 ~/ipython
5974 \color blue
6023 \color blue
5975 ]
6024 ]
5976 \color green
6025 \color green
5977 2>
6026 2>
5978 \color default
6027 \color default
5979 for i in (1,2,3):
6028 for i in (1,2,3):
5980 \newline
6029 \newline
5981
6030
5982 \begin_inset ERT
6031 \begin_inset ERT
5983 status Collapsed
6032 status Collapsed
5984
6033
5985 \layout Standard
6034 \layout Standard
5986
6035
5987 \backslash
6036 \backslash
5988 hspace*{0mm}
6037 hspace*{0mm}
5989 \end_inset
6038 \end_inset
5990
6039
5991 \SpecialChar ~
6040 \SpecialChar ~
5992 \SpecialChar ~
6041 \SpecialChar ~
5993 \SpecialChar ~
6042 \SpecialChar ~
5994 \SpecialChar ~
6043 \SpecialChar ~
5995 \SpecialChar ~
6044 \SpecialChar ~
5996 \SpecialChar ~
6045 \SpecialChar ~
5997 \SpecialChar ~
6046 \SpecialChar ~
5998 \SpecialChar ~
6047 \SpecialChar ~
5999 \SpecialChar ~
6048 \SpecialChar ~
6000 \SpecialChar ~
6049 \SpecialChar ~
6001 \SpecialChar ~
6050 \SpecialChar ~
6002 \SpecialChar ~
6051 \SpecialChar ~
6003 \SpecialChar ~
6052 \SpecialChar ~
6004 \SpecialChar ~
6053 \SpecialChar ~
6005 \SpecialChar ~
6054 \SpecialChar ~
6006
6055
6007 \color green
6056 \color green
6008 ...>
6057 ...>
6009 \color default
6058 \color default
6010 \SpecialChar ~
6059 \SpecialChar ~
6011 \SpecialChar ~
6060 \SpecialChar ~
6012 \SpecialChar ~
6061 \SpecialChar ~
6013 \SpecialChar ~
6062 \SpecialChar ~
6014 print i,
6063 print i,
6015 \newline
6064 \newline
6016
6065
6017 \begin_inset ERT
6066 \begin_inset ERT
6018 status Collapsed
6067 status Collapsed
6019
6068
6020 \layout Standard
6069 \layout Standard
6021
6070
6022 \backslash
6071 \backslash
6023 hspace*{0mm}
6072 hspace*{0mm}
6024 \end_inset
6073 \end_inset
6025
6074
6026 \SpecialChar ~
6075 \SpecialChar ~
6027 \SpecialChar ~
6076 \SpecialChar ~
6028 \SpecialChar ~
6077 \SpecialChar ~
6029 \SpecialChar ~
6078 \SpecialChar ~
6030 \SpecialChar ~
6079 \SpecialChar ~
6031 \SpecialChar ~
6080 \SpecialChar ~
6032 \SpecialChar ~
6081 \SpecialChar ~
6033 \SpecialChar ~
6082 \SpecialChar ~
6034 \SpecialChar ~
6083 \SpecialChar ~
6035 \SpecialChar ~
6084 \SpecialChar ~
6036 \SpecialChar ~
6085 \SpecialChar ~
6037 \SpecialChar ~
6086 \SpecialChar ~
6038 \SpecialChar ~
6087 \SpecialChar ~
6039 \SpecialChar ~
6088 \SpecialChar ~
6040 \SpecialChar ~
6089 \SpecialChar ~
6041
6090
6042 \color green
6091 \color green
6043 ...>
6092 ...>
6044 \color default
6093 \color default
6045
6094
6046 \newline
6095 \newline
6047 1 2 3
6096 1 2 3
6048 \layout Standard
6097 \layout Standard
6049
6098
6050 The following shows the usage of dynamic expression evaluation:
6099 The following shows the usage of dynamic expression evaluation:
6051 \layout Subsection
6100 \layout Subsection
6052
6101
6053
6102
6054 \begin_inset LatexCommand \label{sec:profiles}
6103 \begin_inset LatexCommand \label{sec:profiles}
6055
6104
6056 \end_inset
6105 \end_inset
6057
6106
6058 IPython profiles
6107 IPython profiles
6059 \layout Standard
6108 \layout Standard
6060
6109
6061 As we already mentioned, IPython supports the
6110 As we already mentioned, IPython supports the
6062 \family typewriter
6111 \family typewriter
6063 -profile
6112 -profile
6064 \family default
6113 \family default
6065 command-line option (see sec.
6114 command-line option (see sec.
6066
6115
6067 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
6116 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
6068
6117
6069 \end_inset
6118 \end_inset
6070
6119
6071 ).
6120 ).
6072 A profile is nothing more than a particular configuration file like your
6121 A profile is nothing more than a particular configuration file like your
6073 basic
6122 basic
6074 \family typewriter
6123 \family typewriter
6075 ipythonrc
6124 ipythonrc
6076 \family default
6125 \family default
6077 one, but with particular customizations for a specific purpose.
6126 one, but with particular customizations for a specific purpose.
6078 When you start IPython with '
6127 When you start IPython with '
6079 \family typewriter
6128 \family typewriter
6080 ipython -profile <name>
6129 ipython -profile <name>
6081 \family default
6130 \family default
6082 ', it assumes that in your
6131 ', it assumes that in your
6083 \family typewriter
6132 \family typewriter
6084 IPYTHONDIR
6133 IPYTHONDIR
6085 \family default
6134 \family default
6086 there is a file called
6135 there is a file called
6087 \family typewriter
6136 \family typewriter
6088 ipythonrc-<name>
6137 ipythonrc-<name>
6089 \family default
6138 \family default
6090 , and loads it instead of the normal
6139 , and loads it instead of the normal
6091 \family typewriter
6140 \family typewriter
6092 ipythonrc
6141 ipythonrc
6093 \family default
6142 \family default
6094 .
6143 .
6095 \layout Standard
6144 \layout Standard
6096
6145
6097 This system allows you to maintain multiple configurations which load modules,
6146 This system allows you to maintain multiple configurations which load modules,
6098 set options, define functions, etc.
6147 set options, define functions, etc.
6099 suitable for different tasks and activate them in a very simple manner.
6148 suitable for different tasks and activate them in a very simple manner.
6100 In order to avoid having to repeat all of your basic options (common things
6149 In order to avoid having to repeat all of your basic options (common things
6101 that don't change such as your color preferences, for example), any profile
6150 that don't change such as your color preferences, for example), any profile
6102 can include another configuration file.
6151 can include another configuration file.
6103 The most common way to use profiles is then to have each one include your
6152 The most common way to use profiles is then to have each one include your
6104 basic
6153 basic
6105 \family typewriter
6154 \family typewriter
6106 ipythonrc
6155 ipythonrc
6107 \family default
6156 \family default
6108 file as a starting point, and then add further customizations.
6157 file as a starting point, and then add further customizations.
6109 \layout Standard
6158 \layout Standard
6110
6159
6111 In sections
6160 In sections
6112 \begin_inset LatexCommand \ref{sec:syntax-extensions}
6161 \begin_inset LatexCommand \ref{sec:syntax-extensions}
6113
6162
6114 \end_inset
6163 \end_inset
6115
6164
6116 and
6165 and
6117 \begin_inset LatexCommand \ref{sec:Gnuplot}
6166 \begin_inset LatexCommand \ref{sec:Gnuplot}
6118
6167
6119 \end_inset
6168 \end_inset
6120
6169
6121 we discuss some particular profiles which come as part of the standard
6170 we discuss some particular profiles which come as part of the standard
6122 IPython distribution.
6171 IPython distribution.
6123 You may also look in your
6172 You may also look in your
6124 \family typewriter
6173 \family typewriter
6125 IPYTHONDIR
6174 IPYTHONDIR
6126 \family default
6175 \family default
6127 directory, any file whose name begins with
6176 directory, any file whose name begins with
6128 \family typewriter
6177 \family typewriter
6129 ipythonrc-
6178 ipythonrc-
6130 \family default
6179 \family default
6131 is a profile.
6180 is a profile.
6132 You can use those as examples for further customizations to suit your own
6181 You can use those as examples for further customizations to suit your own
6133 needs.
6182 needs.
6134 \layout Section
6183 \layout Section
6135
6184
6136
6185
6137 \begin_inset OptArg
6186 \begin_inset OptArg
6138 collapsed false
6187 collapsed false
6139
6188
6140 \layout Standard
6189 \layout Standard
6141
6190
6142 IPython as default...
6191 IPython as default...
6143 \end_inset
6192 \end_inset
6144
6193
6145 IPython as your default Python environment
6194 IPython as your default Python environment
6146 \layout Standard
6195 \layout Standard
6147
6196
6148 Python honors the environment variable
6197 Python honors the environment variable
6149 \family typewriter
6198 \family typewriter
6150 PYTHONSTARTUP
6199 PYTHONSTARTUP
6151 \family default
6200 \family default
6152 and will execute at startup the file referenced by this variable.
6201 and will execute at startup the file referenced by this variable.
6153 If you put at the end of this file the following two lines of code:
6202 If you put at the end of this file the following two lines of code:
6154 \layout Standard
6203 \layout Standard
6155
6204
6156
6205
6157 \family typewriter
6206 \family typewriter
6158 import IPython
6207 import IPython
6159 \newline
6208 \newline
6160 IPython.Shell.IPShell().mainloop(sys_exit=1)
6209 IPython.Shell.IPShell().mainloop(sys_exit=1)
6161 \layout Standard
6210 \layout Standard
6162
6211
6163 then IPython will be your working environment anytime you start Python.
6212 then IPython will be your working environment anytime you start Python.
6164 The
6213 The
6165 \family typewriter
6214 \family typewriter
6166 sys_exit=1
6215 sys_exit=1
6167 \family default
6216 \family default
6168 is needed to have IPython issue a call to
6217 is needed to have IPython issue a call to
6169 \family typewriter
6218 \family typewriter
6170 sys.exit()
6219 sys.exit()
6171 \family default
6220 \family default
6172 when it finishes, otherwise you'll be back at the normal Python '
6221 when it finishes, otherwise you'll be back at the normal Python '
6173 \family typewriter
6222 \family typewriter
6174 >>>
6223 >>>
6175 \family default
6224 \family default
6176 ' prompt
6225 ' prompt
6177 \begin_inset Foot
6226 \begin_inset Foot
6178 collapsed true
6227 collapsed true
6179
6228
6180 \layout Standard
6229 \layout Standard
6181
6230
6182 Based on an idea by Holger Krekel.
6231 Based on an idea by Holger Krekel.
6183 \end_inset
6232 \end_inset
6184
6233
6185 .
6234 .
6186 \layout Standard
6235 \layout Standard
6187
6236
6188 This is probably useful to developers who manage multiple Python versions
6237 This is probably useful to developers who manage multiple Python versions
6189 and don't want to have correspondingly multiple IPython versions.
6238 and don't want to have correspondingly multiple IPython versions.
6190 Note that in this mode, there is no way to pass IPython any command-line
6239 Note that in this mode, there is no way to pass IPython any command-line
6191 options, as those are trapped first by Python itself.
6240 options, as those are trapped first by Python itself.
6192 \layout Section
6241 \layout Section
6193
6242
6194
6243
6195 \begin_inset LatexCommand \label{sec:embed}
6244 \begin_inset LatexCommand \label{sec:embed}
6196
6245
6197 \end_inset
6246 \end_inset
6198
6247
6199 Embedding IPython
6248 Embedding IPython
6200 \layout Standard
6249 \layout Standard
6201
6250
6202 It is possible to start an IPython instance
6251 It is possible to start an IPython instance
6203 \emph on
6252 \emph on
6204 inside
6253 inside
6205 \emph default
6254 \emph default
6206 your own Python programs.
6255 your own Python programs.
6207 This allows you to evaluate dynamically the state of your code, operate
6256 This allows you to evaluate dynamically the state of your code, operate
6208 with your variables, analyze them, etc.
6257 with your variables, analyze them, etc.
6209 Note however that any changes you make to values while in the shell do
6258 Note however that any changes you make to values while in the shell do
6210
6259
6211 \emph on
6260 \emph on
6212 not
6261 not
6213 \emph default
6262 \emph default
6214 propagate back to the running code, so it is safe to modify your values
6263 propagate back to the running code, so it is safe to modify your values
6215 because you won't break your code in bizarre ways by doing so.
6264 because you won't break your code in bizarre ways by doing so.
6216 \layout Standard
6265 \layout Standard
6217
6266
6218 This feature allows you to easily have a fully functional python environment
6267 This feature allows you to easily have a fully functional python environment
6219 for doing object introspection anywhere in your code with a simple function
6268 for doing object introspection anywhere in your code with a simple function
6220 call.
6269 call.
6221 In some cases a simple print statement is enough, but if you need to do
6270 In some cases a simple print statement is enough, but if you need to do
6222 more detailed analysis of a code fragment this feature can be very valuable.
6271 more detailed analysis of a code fragment this feature can be very valuable.
6223 \layout Standard
6272 \layout Standard
6224
6273
6225 It can also be useful in scientific computing situations where it is common
6274 It can also be useful in scientific computing situations where it is common
6226 to need to do some automatic, computationally intensive part and then stop
6275 to need to do some automatic, computationally intensive part and then stop
6227 to look at data, plots, etc
6276 to look at data, plots, etc
6228 \begin_inset Foot
6277 \begin_inset Foot
6229 collapsed true
6278 collapsed true
6230
6279
6231 \layout Standard
6280 \layout Standard
6232
6281
6233 This functionality was inspired by IDL's combination of the
6282 This functionality was inspired by IDL's combination of the
6234 \family typewriter
6283 \family typewriter
6235 stop
6284 stop
6236 \family default
6285 \family default
6237 keyword and the
6286 keyword and the
6238 \family typewriter
6287 \family typewriter
6239 .continue
6288 .continue
6240 \family default
6289 \family default
6241 executive command, which I have found very useful in the past, and by a
6290 executive command, which I have found very useful in the past, and by a
6242 posting on comp.lang.python by cmkl <cmkleffner-AT-gmx.de> on Dec.
6291 posting on comp.lang.python by cmkl <cmkleffner-AT-gmx.de> on Dec.
6243 06/01 concerning similar uses of pyrepl.
6292 06/01 concerning similar uses of pyrepl.
6244 \end_inset
6293 \end_inset
6245
6294
6246 .
6295 .
6247 Opening an IPython instance will give you full access to your data and
6296 Opening an IPython instance will give you full access to your data and
6248 functions, and you can resume program execution once you are done with
6297 functions, and you can resume program execution once you are done with
6249 the interactive part (perhaps to stop again later, as many times as needed).
6298 the interactive part (perhaps to stop again later, as many times as needed).
6250 \layout Standard
6299 \layout Standard
6251
6300
6252 The following code snippet is the bare minimum you need to include in your
6301 The following code snippet is the bare minimum you need to include in your
6253 Python programs for this to work (detailed examples follow later):
6302 Python programs for this to work (detailed examples follow later):
6254 \layout LyX-Code
6303 \layout LyX-Code
6255
6304
6256 from IPython.Shell import IPShellEmbed
6305 from IPython.Shell import IPShellEmbed
6257 \layout LyX-Code
6306 \layout LyX-Code
6258
6307
6259 ipshell = IPShellEmbed()
6308 ipshell = IPShellEmbed()
6260 \layout LyX-Code
6309 \layout LyX-Code
6261
6310
6262 ipshell() # this call anywhere in your program will start IPython
6311 ipshell() # this call anywhere in your program will start IPython
6263 \layout Standard
6312 \layout Standard
6264
6313
6265 You can run embedded instances even in code which is itself being run at
6314 You can run embedded instances even in code which is itself being run at
6266 the IPython interactive prompt with '
6315 the IPython interactive prompt with '
6267 \family typewriter
6316 \family typewriter
6268 %run\SpecialChar ~
6317 %run\SpecialChar ~
6269 <filename>
6318 <filename>
6270 \family default
6319 \family default
6271 '.
6320 '.
6272 Since it's easy to get lost as to where you are (in your top-level IPython
6321 Since it's easy to get lost as to where you are (in your top-level IPython
6273 or in your embedded one), it's a good idea in such cases to set the in/out
6322 or in your embedded one), it's a good idea in such cases to set the in/out
6274 prompts to something different for the embedded instances.
6323 prompts to something different for the embedded instances.
6275 The code examples below illustrate this.
6324 The code examples below illustrate this.
6276 \layout Standard
6325 \layout Standard
6277
6326
6278 You can also have multiple IPython instances in your program and open them
6327 You can also have multiple IPython instances in your program and open them
6279 separately, for example with different options for data presentation.
6328 separately, for example with different options for data presentation.
6280 If you close and open the same instance multiple times, its prompt counters
6329 If you close and open the same instance multiple times, its prompt counters
6281 simply continue from each execution to the next.
6330 simply continue from each execution to the next.
6282 \layout Standard
6331 \layout Standard
6283
6332
6284 Please look at the docstrings in the
6333 Please look at the docstrings in the
6285 \family typewriter
6334 \family typewriter
6286 Shell.py
6335 Shell.py
6287 \family default
6336 \family default
6288 module for more details on the use of this system.
6337 module for more details on the use of this system.
6289 \layout Standard
6338 \layout Standard
6290
6339
6291 The following sample file illustrating how to use the embedding functionality
6340 The following sample file illustrating how to use the embedding functionality
6292 is provided in the examples directory as
6341 is provided in the examples directory as
6293 \family typewriter
6342 \family typewriter
6294 example-embed.py
6343 example-embed.py
6295 \family default
6344 \family default
6296 .
6345 .
6297 It should be fairly self-explanatory:
6346 It should be fairly self-explanatory:
6298 \layout Standard
6347 \layout Standard
6299
6348
6300
6349
6301 \begin_inset ERT
6350 \begin_inset ERT
6302 status Open
6351 status Open
6303
6352
6304 \layout Standard
6353 \layout Standard
6305
6354
6306 \backslash
6355 \backslash
6307 codelist{examples/example-embed.py}
6356 codelist{examples/example-embed.py}
6308 \end_inset
6357 \end_inset
6309
6358
6310
6359
6311 \layout Standard
6360 \layout Standard
6312
6361
6313 Once you understand how the system functions, you can use the following
6362 Once you understand how the system functions, you can use the following
6314 code fragments in your programs which are ready for cut and paste:
6363 code fragments in your programs which are ready for cut and paste:
6315 \layout Standard
6364 \layout Standard
6316
6365
6317
6366
6318 \begin_inset ERT
6367 \begin_inset ERT
6319 status Open
6368 status Open
6320
6369
6321 \layout Standard
6370 \layout Standard
6322
6371
6323 \backslash
6372 \backslash
6324 codelist{examples/example-embed-short.py}
6373 codelist{examples/example-embed-short.py}
6325 \end_inset
6374 \end_inset
6326
6375
6327
6376
6328 \layout Section
6377 \layout Section
6329
6378
6330
6379
6331 \begin_inset LatexCommand \label{sec:using-pdb}
6380 \begin_inset LatexCommand \label{sec:using-pdb}
6332
6381
6333 \end_inset
6382 \end_inset
6334
6383
6335 Using the Python debugger (
6384 Using the Python debugger (
6336 \family typewriter
6385 \family typewriter
6337 pdb
6386 pdb
6338 \family default
6387 \family default
6339 )
6388 )
6340 \layout Subsection
6389 \layout Subsection
6341
6390
6342 Running entire programs via
6391 Running entire programs via
6343 \family typewriter
6392 \family typewriter
6344 pdb
6393 pdb
6345 \layout Standard
6394 \layout Standard
6346
6395
6347
6396
6348 \family typewriter
6397 \family typewriter
6349 pdb
6398 pdb
6350 \family default
6399 \family default
6351 , the Python debugger, is a powerful interactive debugger which allows you
6400 , the Python debugger, is a powerful interactive debugger which allows you
6352 to step through code, set breakpoints, watch variables, etc.
6401 to step through code, set breakpoints, watch variables, etc.
6353 IPython makes it very easy to start any script under the control of
6402 IPython makes it very easy to start any script under the control of
6354 \family typewriter
6403 \family typewriter
6355 pdb
6404 pdb
6356 \family default
6405 \family default
6357 , regardless of whether you have wrapped it into a
6406 , regardless of whether you have wrapped it into a
6358 \family typewriter
6407 \family typewriter
6359 `main()'
6408 `main()'
6360 \family default
6409 \family default
6361 function or not.
6410 function or not.
6362 For this, simply type
6411 For this, simply type
6363 \family typewriter
6412 \family typewriter
6364 `%run -d myscript'
6413 `%run -d myscript'
6365 \family default
6414 \family default
6366 at an IPython prompt.
6415 at an IPython prompt.
6367 See the
6416 See the
6368 \family typewriter
6417 \family typewriter
6369 %run
6418 %run
6370 \family default
6419 \family default
6371 command's documentation (via
6420 command's documentation (via
6372 \family typewriter
6421 \family typewriter
6373 `%run?'
6422 `%run?'
6374 \family default
6423 \family default
6375 or in Sec.\SpecialChar ~
6424 or in Sec.\SpecialChar ~
6376
6425
6377 \begin_inset LatexCommand \ref{sec:magic}
6426 \begin_inset LatexCommand \ref{sec:magic}
6378
6427
6379 \end_inset
6428 \end_inset
6380
6429
6381 ) for more details, including how to control where
6430 ) for more details, including how to control where
6382 \family typewriter
6431 \family typewriter
6383 pdb
6432 pdb
6384 \family default
6433 \family default
6385 will stop execution first.
6434 will stop execution first.
6386 \layout Standard
6435 \layout Standard
6387
6436
6388 For more information on the use of the
6437 For more information on the use of the
6389 \family typewriter
6438 \family typewriter
6390 pdb
6439 pdb
6391 \family default
6440 \family default
6392 debugger, read the included
6441 debugger, read the included
6393 \family typewriter
6442 \family typewriter
6394 pdb.doc
6443 pdb.doc
6395 \family default
6444 \family default
6396 file (part of the standard Python distribution).
6445 file (part of the standard Python distribution).
6397 On a stock Linux system it is located at
6446 On a stock Linux system it is located at
6398 \family typewriter
6447 \family typewriter
6399 /usr/lib/python2.3/pdb.doc
6448 /usr/lib/python2.3/pdb.doc
6400 \family default
6449 \family default
6401 , but the easiest way to read it is by using the
6450 , but the easiest way to read it is by using the
6402 \family typewriter
6451 \family typewriter
6403 help()
6452 help()
6404 \family default
6453 \family default
6405 function of the
6454 function of the
6406 \family typewriter
6455 \family typewriter
6407 pdb
6456 pdb
6408 \family default
6457 \family default
6409 module as follows (in an IPython prompt):
6458 module as follows (in an IPython prompt):
6410 \layout Standard
6459 \layout Standard
6411
6460
6412
6461
6413 \family typewriter
6462 \family typewriter
6414 In [1]: import pdb
6463 In [1]: import pdb
6415 \newline
6464 \newline
6416 In [2]: pdb.help()
6465 In [2]: pdb.help()
6417 \layout Standard
6466 \layout Standard
6418
6467
6419 This will load the
6468 This will load the
6420 \family typewriter
6469 \family typewriter
6421 pdb.doc
6470 pdb.doc
6422 \family default
6471 \family default
6423 document in a file viewer for you automatically.
6472 document in a file viewer for you automatically.
6424 \layout Subsection
6473 \layout Subsection
6425
6474
6426 Automatic invocation of
6475 Automatic invocation of
6427 \family typewriter
6476 \family typewriter
6428 pdb
6477 pdb
6429 \family default
6478 \family default
6430 on exceptions
6479 on exceptions
6431 \layout Standard
6480 \layout Standard
6432
6481
6433 IPython, if started with the
6482 IPython, if started with the
6434 \family typewriter
6483 \family typewriter
6435 -pdb
6484 -pdb
6436 \family default
6485 \family default
6437 option (or if the option is set in your rc file) can call the Python
6486 option (or if the option is set in your rc file) can call the Python
6438 \family typewriter
6487 \family typewriter
6439 pdb
6488 pdb
6440 \family default
6489 \family default
6441 debugger every time your code triggers an uncaught exception
6490 debugger every time your code triggers an uncaught exception
6442 \begin_inset Foot
6491 \begin_inset Foot
6443 collapsed true
6492 collapsed true
6444
6493
6445 \layout Standard
6494 \layout Standard
6446
6495
6447 Many thanks to Christopher Hart for the request which prompted adding this
6496 Many thanks to Christopher Hart for the request which prompted adding this
6448 feature to IPython.
6497 feature to IPython.
6449 \end_inset
6498 \end_inset
6450
6499
6451 .
6500 .
6452 This feature can also be toggled at any time with the
6501 This feature can also be toggled at any time with the
6453 \family typewriter
6502 \family typewriter
6454 %pdb
6503 %pdb
6455 \family default
6504 \family default
6456 magic command.
6505 magic command.
6457 This can be extremely useful in order to find the origin of subtle bugs,
6506 This can be extremely useful in order to find the origin of subtle bugs,
6458 because
6507 because
6459 \family typewriter
6508 \family typewriter
6460 pdb
6509 pdb
6461 \family default
6510 \family default
6462 opens up at the point in your code which triggered the exception, and while
6511 opens up at the point in your code which triggered the exception, and while
6463 your program is at this point `dead', all the data is still available and
6512 your program is at this point `dead', all the data is still available and
6464 you can walk up and down the stack frame and understand the origin of the
6513 you can walk up and down the stack frame and understand the origin of the
6465 problem.
6514 problem.
6466 \layout Standard
6515 \layout Standard
6467
6516
6468 Furthermore, you can use these debugging facilities both with the embedded
6517 Furthermore, you can use these debugging facilities both with the embedded
6469 IPython mode and without IPython at all.
6518 IPython mode and without IPython at all.
6470 For an embedded shell (see sec.
6519 For an embedded shell (see sec.
6471
6520
6472 \begin_inset LatexCommand \ref{sec:embed}
6521 \begin_inset LatexCommand \ref{sec:embed}
6473
6522
6474 \end_inset
6523 \end_inset
6475
6524
6476 ), simply call the constructor with
6525 ), simply call the constructor with
6477 \family typewriter
6526 \family typewriter
6478 `-pdb'
6527 `-pdb'
6479 \family default
6528 \family default
6480 in the argument string and automatically
6529 in the argument string and automatically
6481 \family typewriter
6530 \family typewriter
6482 pdb
6531 pdb
6483 \family default
6532 \family default
6484 will be called if an uncaught exception is triggered by your code.
6533 will be called if an uncaught exception is triggered by your code.
6485
6534
6486 \layout Standard
6535 \layout Standard
6487
6536
6488 For stand-alone use of the feature in your programs which do not use IPython
6537 For stand-alone use of the feature in your programs which do not use IPython
6489 at all, put the following lines toward the top of your `main' routine:
6538 at all, put the following lines toward the top of your `main' routine:
6490 \layout Standard
6539 \layout Standard
6491 \align left
6540 \align left
6492
6541
6493 \family typewriter
6542 \family typewriter
6494 import sys,IPython.ultraTB
6543 import sys,IPython.ultraTB
6495 \newline
6544 \newline
6496 sys.excepthook = IPython.ultraTB.FormattedTB(mode=`Verbose', color_scheme=`Linux',
6545 sys.excepthook = IPython.ultraTB.FormattedTB(mode=`Verbose', color_scheme=`Linux',
6497 call_pdb=1)
6546 call_pdb=1)
6498 \layout Standard
6547 \layout Standard
6499
6548
6500 The
6549 The
6501 \family typewriter
6550 \family typewriter
6502 mode
6551 mode
6503 \family default
6552 \family default
6504 keyword can be either
6553 keyword can be either
6505 \family typewriter
6554 \family typewriter
6506 `Verbose'
6555 `Verbose'
6507 \family default
6556 \family default
6508 or
6557 or
6509 \family typewriter
6558 \family typewriter
6510 `Plain'
6559 `Plain'
6511 \family default
6560 \family default
6512 , giving either very detailed or normal tracebacks respectively.
6561 , giving either very detailed or normal tracebacks respectively.
6513 The
6562 The
6514 \family typewriter
6563 \family typewriter
6515 color_scheme
6564 color_scheme
6516 \family default
6565 \family default
6517 keyword can be one of
6566 keyword can be one of
6518 \family typewriter
6567 \family typewriter
6519 `NoColor'
6568 `NoColor'
6520 \family default
6569 \family default
6521 ,
6570 ,
6522 \family typewriter
6571 \family typewriter
6523 `Linux'
6572 `Linux'
6524 \family default
6573 \family default
6525 (default) or
6574 (default) or
6526 \family typewriter
6575 \family typewriter
6527 `LightBG'
6576 `LightBG'
6528 \family default
6577 \family default
6529 .
6578 .
6530 These are the same options which can be set in IPython with
6579 These are the same options which can be set in IPython with
6531 \family typewriter
6580 \family typewriter
6532 -colors
6581 -colors
6533 \family default
6582 \family default
6534 and
6583 and
6535 \family typewriter
6584 \family typewriter
6536 -xmode
6585 -xmode
6537 \family default
6586 \family default
6538 .
6587 .
6539 \layout Standard
6588 \layout Standard
6540
6589
6541 This will give any of your programs detailed, colored tracebacks with automatic
6590 This will give any of your programs detailed, colored tracebacks with automatic
6542 invocation of
6591 invocation of
6543 \family typewriter
6592 \family typewriter
6544 pdb
6593 pdb
6545 \family default
6594 \family default
6546 .
6595 .
6547 \layout Section
6596 \layout Section
6548
6597
6549
6598
6550 \begin_inset LatexCommand \label{sec:syntax-extensions}
6599 \begin_inset LatexCommand \label{sec:syntax-extensions}
6551
6600
6552 \end_inset
6601 \end_inset
6553
6602
6554 Extensions for syntax processing
6603 Extensions for syntax processing
6555 \layout Standard
6604 \layout Standard
6556
6605
6557 This isn't for the faint of heart, because the potential for breaking things
6606 This isn't for the faint of heart, because the potential for breaking things
6558 is quite high.
6607 is quite high.
6559 But it can be a very powerful and useful feature.
6608 But it can be a very powerful and useful feature.
6560 In a nutshell, you can redefine the way IPython processes the user input
6609 In a nutshell, you can redefine the way IPython processes the user input
6561 line to accept new, special extensions to the syntax without needing to
6610 line to accept new, special extensions to the syntax without needing to
6562 change any of IPython's own code.
6611 change any of IPython's own code.
6563 \layout Standard
6612 \layout Standard
6564
6613
6565 In the
6614 In the
6566 \family typewriter
6615 \family typewriter
6567 IPython/Extensions
6616 IPython/Extensions
6568 \family default
6617 \family default
6569 directory you will find some examples supplied, which we will briefly describe
6618 directory you will find some examples supplied, which we will briefly describe
6570 now.
6619 now.
6571 These can be used `as is' (and both provide very useful functionality),
6620 These can be used `as is' (and both provide very useful functionality),
6572 or you can use them as a starting point for writing your own extensions.
6621 or you can use them as a starting point for writing your own extensions.
6573 \layout Subsection
6622 \layout Subsection
6574
6623
6575 Pasting of code starting with
6624 Pasting of code starting with
6576 \family typewriter
6625 \family typewriter
6577 `>>>
6626 `>>>
6578 \family default
6627 \family default
6579 ' or
6628 ' or
6580 \family typewriter
6629 \family typewriter
6581 `...
6630 `...
6582
6631
6583 \family default
6632 \family default
6584 '
6633 '
6585 \layout Standard
6634 \layout Standard
6586
6635
6587 In the python tutorial it is common to find code examples which have been
6636 In the python tutorial it is common to find code examples which have been
6588 taken from real python sessions.
6637 taken from real python sessions.
6589 The problem with those is that all the lines begin with either
6638 The problem with those is that all the lines begin with either
6590 \family typewriter
6639 \family typewriter
6591 `>>>
6640 `>>>
6592 \family default
6641 \family default
6593 ' or
6642 ' or
6594 \family typewriter
6643 \family typewriter
6595 `...
6644 `...
6596
6645
6597 \family default
6646 \family default
6598 ', which makes it impossible to paste them all at once.
6647 ', which makes it impossible to paste them all at once.
6599 One must instead do a line by line manual copying, carefully removing the
6648 One must instead do a line by line manual copying, carefully removing the
6600 leading extraneous characters.
6649 leading extraneous characters.
6601 \layout Standard
6650 \layout Standard
6602
6651
6603 This extension identifies those starting characters and removes them from
6652 This extension identifies those starting characters and removes them from
6604 the input automatically, so that one can paste multi-line examples directly
6653 the input automatically, so that one can paste multi-line examples directly
6605 into IPython, saving a lot of time.
6654 into IPython, saving a lot of time.
6606 Please look at the file
6655 Please look at the file
6607 \family typewriter
6656 \family typewriter
6608 InterpreterPasteInput.py
6657 InterpreterPasteInput.py
6609 \family default
6658 \family default
6610 in the
6659 in the
6611 \family typewriter
6660 \family typewriter
6612 IPython/Extensions
6661 IPython/Extensions
6613 \family default
6662 \family default
6614 directory for details on how this is done.
6663 directory for details on how this is done.
6615 \layout Standard
6664 \layout Standard
6616
6665
6617 IPython comes with a special profile enabling this feature, called
6666 IPython comes with a special profile enabling this feature, called
6618 \family typewriter
6667 \family typewriter
6619 tutorial
6668 tutorial
6620 \family default
6669 \family default
6621 \emph on
6670 \emph on
6622 .
6671 .
6623
6672
6624 \emph default
6673 \emph default
6625 Simply start IPython via
6674 Simply start IPython via
6626 \family typewriter
6675 \family typewriter
6627 `ipython\SpecialChar ~
6676 `ipython\SpecialChar ~
6628 -p\SpecialChar ~
6677 -p\SpecialChar ~
6629 tutorial'
6678 tutorial'
6630 \family default
6679 \family default
6631 and the feature will be available.
6680 and the feature will be available.
6632 In a normal IPython session you can activate the feature by importing the
6681 In a normal IPython session you can activate the feature by importing the
6633 corresponding module with:
6682 corresponding module with:
6634 \newline
6683 \newline
6635
6684
6636 \family typewriter
6685 \family typewriter
6637 In [1]: import IPython.Extensions.InterpreterPasteInput
6686 In [1]: import IPython.Extensions.InterpreterPasteInput
6638 \layout Standard
6687 \layout Standard
6639
6688
6640 The following is a 'screenshot' of how things work when this extension is
6689 The following is a 'screenshot' of how things work when this extension is
6641 on, copying an example from the standard tutorial:
6690 on, copying an example from the standard tutorial:
6642 \layout Standard
6691 \layout Standard
6643
6692
6644
6693
6645 \family typewriter
6694 \family typewriter
6646 IPython profile: tutorial
6695 IPython profile: tutorial
6647 \newline
6696 \newline
6648 \SpecialChar ~
6697 \SpecialChar ~
6649
6698
6650 \newline
6699 \newline
6651 *** Pasting of code with ">>>" or "..." has been enabled.
6700 *** Pasting of code with ">>>" or "..." has been enabled.
6652 \newline
6701 \newline
6653 \SpecialChar ~
6702 \SpecialChar ~
6654
6703
6655 \newline
6704 \newline
6656 In [1]: >>> def fib2(n): # return Fibonacci series up to n
6705 In [1]: >>> def fib2(n): # return Fibonacci series up to n
6657 \newline
6706 \newline
6658
6707
6659 \begin_inset ERT
6708 \begin_inset ERT
6660 status Collapsed
6709 status Collapsed
6661
6710
6662 \layout Standard
6711 \layout Standard
6663
6712
6664 \backslash
6713 \backslash
6665 hspace*{0mm}
6714 hspace*{0mm}
6666 \end_inset
6715 \end_inset
6667
6716
6668 \SpecialChar ~
6717 \SpecialChar ~
6669 \SpecialChar ~
6718 \SpecialChar ~
6670 ...: ...\SpecialChar ~
6719 ...: ...\SpecialChar ~
6671 \SpecialChar ~
6720 \SpecialChar ~
6672 \SpecialChar ~
6721 \SpecialChar ~
6673 \SpecialChar ~
6722 \SpecialChar ~
6674 """Return a list containing the Fibonacci series up to n."""
6723 """Return a list containing the Fibonacci series up to n."""
6675 \newline
6724 \newline
6676
6725
6677 \begin_inset ERT
6726 \begin_inset ERT
6678 status Collapsed
6727 status Collapsed
6679
6728
6680 \layout Standard
6729 \layout Standard
6681
6730
6682 \backslash
6731 \backslash
6683 hspace*{0mm}
6732 hspace*{0mm}
6684 \end_inset
6733 \end_inset
6685
6734
6686 \SpecialChar ~
6735 \SpecialChar ~
6687 \SpecialChar ~
6736 \SpecialChar ~
6688 ...: ...\SpecialChar ~
6737 ...: ...\SpecialChar ~
6689 \SpecialChar ~
6738 \SpecialChar ~
6690 \SpecialChar ~
6739 \SpecialChar ~
6691 \SpecialChar ~
6740 \SpecialChar ~
6692 result = []
6741 result = []
6693 \newline
6742 \newline
6694
6743
6695 \begin_inset ERT
6744 \begin_inset ERT
6696 status Collapsed
6745 status Collapsed
6697
6746
6698 \layout Standard
6747 \layout Standard
6699
6748
6700 \backslash
6749 \backslash
6701 hspace*{0mm}
6750 hspace*{0mm}
6702 \end_inset
6751 \end_inset
6703
6752
6704 \SpecialChar ~
6753 \SpecialChar ~
6705 \SpecialChar ~
6754 \SpecialChar ~
6706 ...: ...\SpecialChar ~
6755 ...: ...\SpecialChar ~
6707 \SpecialChar ~
6756 \SpecialChar ~
6708 \SpecialChar ~
6757 \SpecialChar ~
6709 \SpecialChar ~
6758 \SpecialChar ~
6710 a, b = 0, 1
6759 a, b = 0, 1
6711 \newline
6760 \newline
6712
6761
6713 \begin_inset ERT
6762 \begin_inset ERT
6714 status Collapsed
6763 status Collapsed
6715
6764
6716 \layout Standard
6765 \layout Standard
6717
6766
6718 \backslash
6767 \backslash
6719 hspace*{0mm}
6768 hspace*{0mm}
6720 \end_inset
6769 \end_inset
6721
6770
6722 \SpecialChar ~
6771 \SpecialChar ~
6723 \SpecialChar ~
6772 \SpecialChar ~
6724 ...: ...\SpecialChar ~
6773 ...: ...\SpecialChar ~
6725 \SpecialChar ~
6774 \SpecialChar ~
6726 \SpecialChar ~
6775 \SpecialChar ~
6727 \SpecialChar ~
6776 \SpecialChar ~
6728 while b < n:
6777 while b < n:
6729 \newline
6778 \newline
6730
6779
6731 \begin_inset ERT
6780 \begin_inset ERT
6732 status Collapsed
6781 status Collapsed
6733
6782
6734 \layout Standard
6783 \layout Standard
6735
6784
6736 \backslash
6785 \backslash
6737 hspace*{0mm}
6786 hspace*{0mm}
6738 \end_inset
6787 \end_inset
6739
6788
6740 \SpecialChar ~
6789 \SpecialChar ~
6741 \SpecialChar ~
6790 \SpecialChar ~
6742 ...: ...\SpecialChar ~
6791 ...: ...\SpecialChar ~
6743 \SpecialChar ~
6792 \SpecialChar ~
6744 \SpecialChar ~
6793 \SpecialChar ~
6745 \SpecialChar ~
6794 \SpecialChar ~
6746 \SpecialChar ~
6795 \SpecialChar ~
6747 \SpecialChar ~
6796 \SpecialChar ~
6748 \SpecialChar ~
6797 \SpecialChar ~
6749 \SpecialChar ~
6798 \SpecialChar ~
6750 result.append(b)\SpecialChar ~
6799 result.append(b)\SpecialChar ~
6751 \SpecialChar ~
6800 \SpecialChar ~
6752 \SpecialChar ~
6801 \SpecialChar ~
6753 # see below
6802 # see below
6754 \newline
6803 \newline
6755
6804
6756 \begin_inset ERT
6805 \begin_inset ERT
6757 status Collapsed
6806 status Collapsed
6758
6807
6759 \layout Standard
6808 \layout Standard
6760
6809
6761 \backslash
6810 \backslash
6762 hspace*{0mm}
6811 hspace*{0mm}
6763 \end_inset
6812 \end_inset
6764
6813
6765 \SpecialChar ~
6814 \SpecialChar ~
6766 \SpecialChar ~
6815 \SpecialChar ~
6767 ...: ...\SpecialChar ~
6816 ...: ...\SpecialChar ~
6768 \SpecialChar ~
6817 \SpecialChar ~
6769 \SpecialChar ~
6818 \SpecialChar ~
6770 \SpecialChar ~
6819 \SpecialChar ~
6771 \SpecialChar ~
6820 \SpecialChar ~
6772 \SpecialChar ~
6821 \SpecialChar ~
6773 \SpecialChar ~
6822 \SpecialChar ~
6774 \SpecialChar ~
6823 \SpecialChar ~
6775 a, b = b, a+b
6824 a, b = b, a+b
6776 \newline
6825 \newline
6777
6826
6778 \begin_inset ERT
6827 \begin_inset ERT
6779 status Collapsed
6828 status Collapsed
6780
6829
6781 \layout Standard
6830 \layout Standard
6782
6831
6783 \backslash
6832 \backslash
6784 hspace*{0mm}
6833 hspace*{0mm}
6785 \end_inset
6834 \end_inset
6786
6835
6787 \SpecialChar ~
6836 \SpecialChar ~
6788 \SpecialChar ~
6837 \SpecialChar ~
6789 ...: ...\SpecialChar ~
6838 ...: ...\SpecialChar ~
6790 \SpecialChar ~
6839 \SpecialChar ~
6791 \SpecialChar ~
6840 \SpecialChar ~
6792 \SpecialChar ~
6841 \SpecialChar ~
6793 return result
6842 return result
6794 \newline
6843 \newline
6795
6844
6796 \begin_inset ERT
6845 \begin_inset ERT
6797 status Collapsed
6846 status Collapsed
6798
6847
6799 \layout Standard
6848 \layout Standard
6800
6849
6801 \backslash
6850 \backslash
6802 hspace*{0mm}
6851 hspace*{0mm}
6803 \end_inset
6852 \end_inset
6804
6853
6805 \SpecialChar ~
6854 \SpecialChar ~
6806 \SpecialChar ~
6855 \SpecialChar ~
6807 ...:
6856 ...:
6808 \newline
6857 \newline
6809 \SpecialChar ~
6858 \SpecialChar ~
6810
6859
6811 \newline
6860 \newline
6812 In [2]: fib2(10)
6861 In [2]: fib2(10)
6813 \newline
6862 \newline
6814 Out[2]: [1, 1, 2, 3, 5, 8]
6863 Out[2]: [1, 1, 2, 3, 5, 8]
6815 \layout Standard
6864 \layout Standard
6816
6865
6817 Note that as currently written, this extension does
6866 Note that as currently written, this extension does
6818 \emph on
6867 \emph on
6819 not
6868 not
6820 \emph default
6869 \emph default
6821 recognize IPython's prompts for pasting.
6870 recognize IPython's prompts for pasting.
6822 Those are more complicated, since the user can change them very easily,
6871 Those are more complicated, since the user can change them very easily,
6823 they involve numbers and can vary in length.
6872 they involve numbers and can vary in length.
6824 One could however extract all the relevant information from the IPython
6873 One could however extract all the relevant information from the IPython
6825 instance and build an appropriate regular expression.
6874 instance and build an appropriate regular expression.
6826 This is left as an exercise for the reader.
6875 This is left as an exercise for the reader.
6827 \layout Subsection
6876 \layout Subsection
6828
6877
6829 Input of physical quantities with units
6878 Input of physical quantities with units
6830 \layout Standard
6879 \layout Standard
6831
6880
6832 The module
6881 The module
6833 \family typewriter
6882 \family typewriter
6834 PhysicalQInput
6883 PhysicalQInput
6835 \family default
6884 \family default
6836 allows a simplified form of input for physical quantities with units.
6885 allows a simplified form of input for physical quantities with units.
6837 This file is meant to be used in conjunction with the
6886 This file is meant to be used in conjunction with the
6838 \family typewriter
6887 \family typewriter
6839 PhysicalQInteractive
6888 PhysicalQInteractive
6840 \family default
6889 \family default
6841 module (in the same directory) and
6890 module (in the same directory) and
6842 \family typewriter
6891 \family typewriter
6843 Physics.PhysicalQuantities
6892 Physics.PhysicalQuantities
6844 \family default
6893 \family default
6845 from Konrad Hinsen's ScientificPython (
6894 from Konrad Hinsen's ScientificPython (
6846 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/hinsen/scientific.html}
6895 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/hinsen/scientific.html}
6847
6896
6848 \end_inset
6897 \end_inset
6849
6898
6850 ).
6899 ).
6851 \layout Standard
6900 \layout Standard
6852
6901
6853 The
6902 The
6854 \family typewriter
6903 \family typewriter
6855 Physics.PhysicalQuantities
6904 Physics.PhysicalQuantities
6856 \family default
6905 \family default
6857 module defines
6906 module defines
6858 \family typewriter
6907 \family typewriter
6859 PhysicalQuantity
6908 PhysicalQuantity
6860 \family default
6909 \family default
6861 objects, but these must be declared as instances of a class.
6910 objects, but these must be declared as instances of a class.
6862 For example, to define
6911 For example, to define
6863 \family typewriter
6912 \family typewriter
6864 v
6913 v
6865 \family default
6914 \family default
6866 as a velocity of 3\SpecialChar ~
6915 as a velocity of 3\SpecialChar ~
6867 m/s, normally you would write:
6916 m/s, normally you would write:
6868 \family typewriter
6917 \family typewriter
6869
6918
6870 \newline
6919 \newline
6871 In [1]: v = PhysicalQuantity(3,'m/s')
6920 In [1]: v = PhysicalQuantity(3,'m/s')
6872 \layout Standard
6921 \layout Standard
6873
6922
6874 Using the
6923 Using the
6875 \family typewriter
6924 \family typewriter
6876 PhysicalQ_Input
6925 PhysicalQ_Input
6877 \family default
6926 \family default
6878 extension this can be input instead as:
6927 extension this can be input instead as:
6879 \family typewriter
6928 \family typewriter
6880
6929
6881 \newline
6930 \newline
6882 In [1]: v = 3 m/s
6931 In [1]: v = 3 m/s
6883 \family default
6932 \family default
6884
6933
6885 \newline
6934 \newline
6886 which is much more convenient for interactive use (even though it is blatantly
6935 which is much more convenient for interactive use (even though it is blatantly
6887 invalid Python syntax).
6936 invalid Python syntax).
6888 \layout Standard
6937 \layout Standard
6889
6938
6890 The
6939 The
6891 \family typewriter
6940 \family typewriter
6892 physics
6941 physics
6893 \family default
6942 \family default
6894 profile supplied with IPython (enabled via
6943 profile supplied with IPython (enabled via
6895 \family typewriter
6944 \family typewriter
6896 'ipython -p physics'
6945 'ipython -p physics'
6897 \family default
6946 \family default
6898 ) uses these extensions, which you can also activate with:
6947 ) uses these extensions, which you can also activate with:
6899 \layout Standard
6948 \layout Standard
6900
6949
6901
6950
6902 \family typewriter
6951 \family typewriter
6903 from math import * # math MUST be imported BEFORE PhysicalQInteractive
6952 from math import * # math MUST be imported BEFORE PhysicalQInteractive
6904 \newline
6953 \newline
6905 from IPython.Extensions.PhysicalQInteractive import *
6954 from IPython.Extensions.PhysicalQInteractive import *
6906 \newline
6955 \newline
6907 import IPython.Extensions.PhysicalQInput
6956 import IPython.Extensions.PhysicalQInput
6908 \layout Section
6957 \layout Section
6909
6958
6910
6959
6911 \begin_inset LatexCommand \label{sec:IPython-as-shell}
6960 \begin_inset LatexCommand \label{sec:IPython-as-shell}
6912
6961
6913 \end_inset
6962 \end_inset
6914
6963
6915 IPython as a system shell
6964 IPython as a system shell
6916 \layout Standard
6965 \layout Standard
6917
6966
6918 IPython ships with a special profile called
6967 IPython ships with a special profile called
6919 \family typewriter
6968 \family typewriter
6920 pysh
6969 pysh
6921 \family default
6970 \family default
6922 , which you can activate at the command line as
6971 , which you can activate at the command line as
6923 \family typewriter
6972 \family typewriter
6924 `ipython -p pysh'
6973 `ipython -p pysh'
6925 \family default
6974 \family default
6926 .
6975 .
6927 This loads
6976 This loads
6928 \family typewriter
6977 \family typewriter
6929 InterpreterExec
6978 InterpreterExec
6930 \family default
6979 \family default
6931 , along with some additional facilities and a prompt customized for filesystem
6980 , along with some additional facilities and a prompt customized for filesystem
6932 navigation.
6981 navigation.
6933 \layout Standard
6982 \layout Standard
6934
6983
6935 Note that this does
6984 Note that this does
6936 \emph on
6985 \emph on
6937 not
6986 not
6938 \emph default
6987 \emph default
6939 make IPython a full-fledged system shell.
6988 make IPython a full-fledged system shell.
6940 In particular, it has no job control, so if you type Ctrl-Z (under Unix),
6989 In particular, it has no job control, so if you type Ctrl-Z (under Unix),
6941 you'll suspend pysh itself, not the process you just started.
6990 you'll suspend pysh itself, not the process you just started.
6942
6991
6943 \layout Standard
6992 \layout Standard
6944
6993
6945 What the shell profile allows you to do is to use the convenient and powerful
6994 What the shell profile allows you to do is to use the convenient and powerful
6946 syntax of Python to do quick scripting at the command line.
6995 syntax of Python to do quick scripting at the command line.
6947 Below we describe some of its features.
6996 Below we describe some of its features.
6948 \layout Subsection
6997 \layout Subsection
6949
6998
6950 Aliases
6999 Aliases
6951 \layout Standard
7000 \layout Standard
6952
7001
6953 All of your
7002 All of your
6954 \family typewriter
7003 \family typewriter
6955 $PATH
7004 $PATH
6956 \family default
7005 \family default
6957 has been loaded as IPython aliases, so you should be able to type any normal
7006 has been loaded as IPython aliases, so you should be able to type any normal
6958 system command and have it executed.
7007 system command and have it executed.
6959 See
7008 See
6960 \family typewriter
7009 \family typewriter
6961 %alias?
7010 %alias?
6962 \family default
7011 \family default
6963 and
7012 and
6964 \family typewriter
7013 \family typewriter
6965 %unalias?
7014 %unalias?
6966 \family default
7015 \family default
6967 for details on the alias facilities.
7016 for details on the alias facilities.
6968 See also
7017 See also
6969 \family typewriter
7018 \family typewriter
6970 %rehash?
7019 %rehash?
6971 \family default
7020 \family default
6972 and
7021 and
6973 \family typewriter
7022 \family typewriter
6974 %rehashx?
7023 %rehashx?
6975 \family default
7024 \family default
6976 for details on the mechanism used to load
7025 for details on the mechanism used to load
6977 \family typewriter
7026 \family typewriter
6978 $PATH
7027 $PATH
6979 \family default
7028 \family default
6980 .
7029 .
6981 \layout Subsection
7030 \layout Subsection
6982
7031
6983 Special syntax
7032 Special syntax
6984 \layout Standard
7033 \layout Standard
6985
7034
6986 Any lines which begin with
7035 Any lines which begin with
6987 \family typewriter
7036 \family typewriter
6988 `~'
7037 `~'
6989 \family default
7038 \family default
6990 ,
7039 ,
6991 \family typewriter
7040 \family typewriter
6992 `/'
7041 `/'
6993 \family default
7042 \family default
6994 and
7043 and
6995 \family typewriter
7044 \family typewriter
6996 `.'
7045 `.'
6997 \family default
7046 \family default
6998 will be executed as shell commands instead of as Python code.
7047 will be executed as shell commands instead of as Python code.
6999 The special escapes below are also recognized.
7048 The special escapes below are also recognized.
7000
7049
7001 \family typewriter
7050 \family typewriter
7002 !cmd
7051 !cmd
7003 \family default
7052 \family default
7004 is valid in single or multi-line input, all others are only valid in single-lin
7053 is valid in single or multi-line input, all others are only valid in single-lin
7005 e input:
7054 e input:
7006 \layout Description
7055 \layout Description
7007
7056
7008
7057
7009 \family typewriter
7058 \family typewriter
7010 !cmd
7059 !cmd
7011 \family default
7060 \family default
7012 pass `cmd' directly to the shell
7061 pass `cmd' directly to the shell
7013 \layout Description
7062 \layout Description
7014
7063
7015
7064
7016 \family typewriter
7065 \family typewriter
7017 !!cmd
7066 !!cmd
7018 \family default
7067 \family default
7019 execute `cmd' and return output as a list (split on `
7068 execute `cmd' and return output as a list (split on `
7020 \backslash
7069 \backslash
7021 n')
7070 n')
7022 \layout Description
7071 \layout Description
7023
7072
7024
7073
7025 \family typewriter
7074 \family typewriter
7026 $var=cmd
7075 $var=cmd
7027 \family default
7076 \family default
7028 capture output of cmd into var, as a string
7077 capture output of cmd into var, as a string
7029 \layout Description
7078 \layout Description
7030
7079
7031
7080
7032 \family typewriter
7081 \family typewriter
7033 $$var=cmd
7082 $$var=cmd
7034 \family default
7083 \family default
7035 capture output of cmd into var, as a list (split on `
7084 capture output of cmd into var, as a list (split on `
7036 \backslash
7085 \backslash
7037 n')
7086 n')
7038 \layout Standard
7087 \layout Standard
7039
7088
7040 The
7089 The
7041 \family typewriter
7090 \family typewriter
7042 $
7091 $
7043 \family default
7092 \family default
7044 /
7093 /
7045 \family typewriter
7094 \family typewriter
7046 $$
7095 $$
7047 \family default
7096 \family default
7048 syntaxes make Python variables from system output, which you can later
7097 syntaxes make Python variables from system output, which you can later
7049 use for further scripting.
7098 use for further scripting.
7050 The converse is also possible: when executing an alias or calling to the
7099 The converse is also possible: when executing an alias or calling to the
7051 system via
7100 system via
7052 \family typewriter
7101 \family typewriter
7053 !
7102 !
7054 \family default
7103 \family default
7055 /
7104 /
7056 \family typewriter
7105 \family typewriter
7057 !!
7106 !!
7058 \family default
7107 \family default
7059 , you can expand any python variable or expression by prepending it with
7108 , you can expand any python variable or expression by prepending it with
7060
7109
7061 \family typewriter
7110 \family typewriter
7062 $
7111 $
7063 \family default
7112 \family default
7064 .
7113 .
7065 Full details of the allowed syntax can be found in Python's PEP 215.
7114 Full details of the allowed syntax can be found in Python's PEP 215.
7066 \layout Standard
7115 \layout Standard
7067
7116
7068 A few brief examples will illustrate these (note that the indentation below
7117 A few brief examples will illustrate these (note that the indentation below
7069 may be incorrectly displayed):
7118 may be incorrectly displayed):
7070 \layout Standard
7119 \layout Standard
7071
7120
7072
7121
7073 \family typewriter
7122 \family typewriter
7074 fperez[~/test]|3> !ls *s.py
7123 fperez[~/test]|3> !ls *s.py
7075 \newline
7124 \newline
7076 scopes.py strings.py
7125 scopes.py strings.py
7077 \layout Standard
7126 \layout Standard
7078
7127
7079 ls is an internal alias, so there's no need to use
7128 ls is an internal alias, so there's no need to use
7080 \family typewriter
7129 \family typewriter
7081 !
7130 !
7082 \family default
7131 \family default
7083 :
7132 :
7084 \layout Standard
7133 \layout Standard
7085
7134
7086
7135
7087 \family typewriter
7136 \family typewriter
7088 fperez[~/test]|4> ls *s.py
7137 fperez[~/test]|4> ls *s.py
7089 \newline
7138 \newline
7090 scopes.py* strings.py
7139 scopes.py* strings.py
7091 \layout Standard
7140 \layout Standard
7092
7141
7093 !!ls will return the output into a Python variable:
7142 !!ls will return the output into a Python variable:
7094 \layout Standard
7143 \layout Standard
7095
7144
7096
7145
7097 \family typewriter
7146 \family typewriter
7098 fperez[~/test]|5> !!ls *s.py
7147 fperez[~/test]|5> !!ls *s.py
7099 \newline
7148 \newline
7100
7149
7101 \begin_inset ERT
7150 \begin_inset ERT
7102 status Collapsed
7151 status Collapsed
7103
7152
7104 \layout Standard
7153 \layout Standard
7105
7154
7106 \backslash
7155 \backslash
7107 hspace*{0mm}
7156 hspace*{0mm}
7108 \end_inset
7157 \end_inset
7109
7158
7110 \SpecialChar ~
7159 \SpecialChar ~
7111 \SpecialChar ~
7160 \SpecialChar ~
7112 \SpecialChar ~
7161 \SpecialChar ~
7113 \SpecialChar ~
7162 \SpecialChar ~
7114 \SpecialChar ~
7163 \SpecialChar ~
7115 \SpecialChar ~
7164 \SpecialChar ~
7116 \SpecialChar ~
7165 \SpecialChar ~
7117 \SpecialChar ~
7166 \SpecialChar ~
7118 \SpecialChar ~
7167 \SpecialChar ~
7119 \SpecialChar ~
7168 \SpecialChar ~
7120 \SpecialChar ~
7169 \SpecialChar ~
7121 \SpecialChar ~
7170 \SpecialChar ~
7122 \SpecialChar ~
7171 \SpecialChar ~
7123 \SpecialChar ~
7172 \SpecialChar ~
7124 <5> ['scopes.py', 'strings.py']
7173 <5> ['scopes.py', 'strings.py']
7125 \newline
7174 \newline
7126 fperez[~/test]|6> print _5
7175 fperez[~/test]|6> print _5
7127 \newline
7176 \newline
7128 ['scopes.py', 'strings.py']
7177 ['scopes.py', 'strings.py']
7129 \layout Standard
7178 \layout Standard
7130
7179
7131
7180
7132 \family typewriter
7181 \family typewriter
7133 $
7182 $
7134 \family default
7183 \family default
7135 and
7184 and
7136 \family typewriter
7185 \family typewriter
7137 $$
7186 $$
7138 \family default
7187 \family default
7139 allow direct capture to named variables:
7188 allow direct capture to named variables:
7140 \layout Standard
7189 \layout Standard
7141
7190
7142
7191
7143 \family typewriter
7192 \family typewriter
7144 fperez[~/test]|7> $astr = ls *s.py
7193 fperez[~/test]|7> $astr = ls *s.py
7145 \newline
7194 \newline
7146 fperez[~/test]|8> astr
7195 fperez[~/test]|8> astr
7147 \newline
7196 \newline
7148
7197
7149 \begin_inset ERT
7198 \begin_inset ERT
7150 status Collapsed
7199 status Collapsed
7151
7200
7152 \layout Standard
7201 \layout Standard
7153
7202
7154 \backslash
7203 \backslash
7155 hspace*{0mm}
7204 hspace*{0mm}
7156 \end_inset
7205 \end_inset
7157
7206
7158 \SpecialChar ~
7207 \SpecialChar ~
7159 \SpecialChar ~
7208 \SpecialChar ~
7160 \SpecialChar ~
7209 \SpecialChar ~
7161 \SpecialChar ~
7210 \SpecialChar ~
7162 \SpecialChar ~
7211 \SpecialChar ~
7163 \SpecialChar ~
7212 \SpecialChar ~
7164 \SpecialChar ~
7213 \SpecialChar ~
7165 \SpecialChar ~
7214 \SpecialChar ~
7166 \SpecialChar ~
7215 \SpecialChar ~
7167 \SpecialChar ~
7216 \SpecialChar ~
7168 \SpecialChar ~
7217 \SpecialChar ~
7169 \SpecialChar ~
7218 \SpecialChar ~
7170 \SpecialChar ~
7219 \SpecialChar ~
7171 \SpecialChar ~
7220 \SpecialChar ~
7172 <8> 'scopes.py
7221 <8> 'scopes.py
7173 \backslash
7222 \backslash
7174 nstrings.py'
7223 nstrings.py'
7175 \layout Standard
7224 \layout Standard
7176
7225
7177
7226
7178 \family typewriter
7227 \family typewriter
7179 fperez[~/test]|9> $$alist = ls *s.py
7228 fperez[~/test]|9> $$alist = ls *s.py
7180 \newline
7229 \newline
7181 fperez[~/test]|10> alist
7230 fperez[~/test]|10> alist
7182 \newline
7231 \newline
7183
7232
7184 \begin_inset ERT
7233 \begin_inset ERT
7185 status Collapsed
7234 status Collapsed
7186
7235
7187 \layout Standard
7236 \layout Standard
7188
7237
7189 \backslash
7238 \backslash
7190 hspace*{0mm}
7239 hspace*{0mm}
7191 \end_inset
7240 \end_inset
7192
7241
7193 \SpecialChar ~
7242 \SpecialChar ~
7194 \SpecialChar ~
7243 \SpecialChar ~
7195 \SpecialChar ~
7244 \SpecialChar ~
7196 \SpecialChar ~
7245 \SpecialChar ~
7197 \SpecialChar ~
7246 \SpecialChar ~
7198 \SpecialChar ~
7247 \SpecialChar ~
7199 \SpecialChar ~
7248 \SpecialChar ~
7200 \SpecialChar ~
7249 \SpecialChar ~
7201 \SpecialChar ~
7250 \SpecialChar ~
7202 \SpecialChar ~
7251 \SpecialChar ~
7203 \SpecialChar ~
7252 \SpecialChar ~
7204 \SpecialChar ~
7253 \SpecialChar ~
7205 \SpecialChar ~
7254 \SpecialChar ~
7206 \SpecialChar ~
7255 \SpecialChar ~
7207 <10> ['scopes.py', 'strings.py']
7256 <10> ['scopes.py', 'strings.py']
7208 \layout Standard
7257 \layout Standard
7209
7258
7210 alist is now a normal python list you can loop over.
7259 alist is now a normal python list you can loop over.
7211 Using
7260 Using
7212 \family typewriter
7261 \family typewriter
7213 $
7262 $
7214 \family default
7263 \family default
7215 will expand back the python values when alias calls are made:
7264 will expand back the python values when alias calls are made:
7216 \layout Standard
7265 \layout Standard
7217
7266
7218
7267
7219 \family typewriter
7268 \family typewriter
7220 fperez[~/test]|11> for f in alist:
7269 fperez[~/test]|11> for f in alist:
7221 \newline
7270 \newline
7222
7271
7223 \begin_inset ERT
7272 \begin_inset ERT
7224 status Collapsed
7273 status Collapsed
7225
7274
7226 \layout Standard
7275 \layout Standard
7227
7276
7228 \backslash
7277 \backslash
7229 hspace*{0mm}
7278 hspace*{0mm}
7230 \end_inset
7279 \end_inset
7231
7280
7232 \SpecialChar ~
7281 \SpecialChar ~
7233 \SpecialChar ~
7282 \SpecialChar ~
7234 \SpecialChar ~
7283 \SpecialChar ~
7235 \SpecialChar ~
7284 \SpecialChar ~
7236 \SpecialChar ~
7285 \SpecialChar ~
7237 \SpecialChar ~
7286 \SpecialChar ~
7238 \SpecialChar ~
7287 \SpecialChar ~
7239 \SpecialChar ~
7288 \SpecialChar ~
7240 \SpecialChar ~
7289 \SpecialChar ~
7241 \SpecialChar ~
7290 \SpecialChar ~
7242 \SpecialChar ~
7291 \SpecialChar ~
7243 \SpecialChar ~
7292 \SpecialChar ~
7244 \SpecialChar ~
7293 \SpecialChar ~
7245 \SpecialChar ~
7294 \SpecialChar ~
7246 |..> \SpecialChar ~
7295 |..> \SpecialChar ~
7247 \SpecialChar ~
7296 \SpecialChar ~
7248 \SpecialChar ~
7297 \SpecialChar ~
7249 \SpecialChar ~
7298 \SpecialChar ~
7250 print 'file',f,
7299 print 'file',f,
7251 \newline
7300 \newline
7252
7301
7253 \begin_inset ERT
7302 \begin_inset ERT
7254 status Collapsed
7303 status Collapsed
7255
7304
7256 \layout Standard
7305 \layout Standard
7257
7306
7258 \backslash
7307 \backslash
7259 hspace*{0mm}
7308 hspace*{0mm}
7260 \end_inset
7309 \end_inset
7261
7310
7262 \SpecialChar ~
7311 \SpecialChar ~
7263 \SpecialChar ~
7312 \SpecialChar ~
7264 \SpecialChar ~
7313 \SpecialChar ~
7265 \SpecialChar ~
7314 \SpecialChar ~
7266 \SpecialChar ~
7315 \SpecialChar ~
7267 \SpecialChar ~
7316 \SpecialChar ~
7268 \SpecialChar ~
7317 \SpecialChar ~
7269 \SpecialChar ~
7318 \SpecialChar ~
7270 \SpecialChar ~
7319 \SpecialChar ~
7271 \SpecialChar ~
7320 \SpecialChar ~
7272 \SpecialChar ~
7321 \SpecialChar ~
7273 \SpecialChar ~
7322 \SpecialChar ~
7274 \SpecialChar ~
7323 \SpecialChar ~
7275 \SpecialChar ~
7324 \SpecialChar ~
7276 |..> \SpecialChar ~
7325 |..> \SpecialChar ~
7277 \SpecialChar ~
7326 \SpecialChar ~
7278 \SpecialChar ~
7327 \SpecialChar ~
7279 \SpecialChar ~
7328 \SpecialChar ~
7280 wc -l $f
7329 wc -l $f
7281 \newline
7330 \newline
7282
7331
7283 \begin_inset ERT
7332 \begin_inset ERT
7284 status Collapsed
7333 status Collapsed
7285
7334
7286 \layout Standard
7335 \layout Standard
7287
7336
7288 \backslash
7337 \backslash
7289 hspace*{0mm}
7338 hspace*{0mm}
7290 \end_inset
7339 \end_inset
7291
7340
7292 \SpecialChar ~
7341 \SpecialChar ~
7293 \SpecialChar ~
7342 \SpecialChar ~
7294 \SpecialChar ~
7343 \SpecialChar ~
7295 \SpecialChar ~
7344 \SpecialChar ~
7296 \SpecialChar ~
7345 \SpecialChar ~
7297 \SpecialChar ~
7346 \SpecialChar ~
7298 \SpecialChar ~
7347 \SpecialChar ~
7299 \SpecialChar ~
7348 \SpecialChar ~
7300 \SpecialChar ~
7349 \SpecialChar ~
7301 \SpecialChar ~
7350 \SpecialChar ~
7302 \SpecialChar ~
7351 \SpecialChar ~
7303 \SpecialChar ~
7352 \SpecialChar ~
7304 \SpecialChar ~
7353 \SpecialChar ~
7305 \SpecialChar ~
7354 \SpecialChar ~
7306 |..>
7355 |..>
7307 \newline
7356 \newline
7308 file scopes.py 13 scopes.py
7357 file scopes.py 13 scopes.py
7309 \newline
7358 \newline
7310 file strings.py 4 strings.py
7359 file strings.py 4 strings.py
7311 \layout Standard
7360 \layout Standard
7312
7361
7313 Note that you may need to protect your variables with braces if you want
7362 Note that you may need to protect your variables with braces if you want
7314 to append strings to their names.
7363 to append strings to their names.
7315 To copy all files in alist to
7364 To copy all files in alist to
7316 \family typewriter
7365 \family typewriter
7317 .bak
7366 .bak
7318 \family default
7367 \family default
7319 extensions, you must use:
7368 extensions, you must use:
7320 \layout Standard
7369 \layout Standard
7321
7370
7322
7371
7323 \family typewriter
7372 \family typewriter
7324 fperez[~/test]|12> for f in alist:
7373 fperez[~/test]|12> for f in alist:
7325 \newline
7374 \newline
7326
7375
7327 \begin_inset ERT
7376 \begin_inset ERT
7328 status Collapsed
7377 status Collapsed
7329
7378
7330 \layout Standard
7379 \layout Standard
7331
7380
7332 \backslash
7381 \backslash
7333 hspace*{0mm}
7382 hspace*{0mm}
7334 \end_inset
7383 \end_inset
7335
7384
7336 \SpecialChar ~
7385 \SpecialChar ~
7337 \SpecialChar ~
7386 \SpecialChar ~
7338 \SpecialChar ~
7387 \SpecialChar ~
7339 \SpecialChar ~
7388 \SpecialChar ~
7340 \SpecialChar ~
7389 \SpecialChar ~
7341 \SpecialChar ~
7390 \SpecialChar ~
7342 \SpecialChar ~
7391 \SpecialChar ~
7343 \SpecialChar ~
7392 \SpecialChar ~
7344 \SpecialChar ~
7393 \SpecialChar ~
7345 \SpecialChar ~
7394 \SpecialChar ~
7346 \SpecialChar ~
7395 \SpecialChar ~
7347 \SpecialChar ~
7396 \SpecialChar ~
7348 \SpecialChar ~
7397 \SpecialChar ~
7349 \SpecialChar ~
7398 \SpecialChar ~
7350 |..> \SpecialChar ~
7399 |..> \SpecialChar ~
7351 \SpecialChar ~
7400 \SpecialChar ~
7352 \SpecialChar ~
7401 \SpecialChar ~
7353 \SpecialChar ~
7402 \SpecialChar ~
7354 cp $f ${f}.bak
7403 cp $f ${f}.bak
7355 \layout Standard
7404 \layout Standard
7356
7405
7357 If you try using
7406 If you try using
7358 \family typewriter
7407 \family typewriter
7359 $f.bak
7408 $f.bak
7360 \family default
7409 \family default
7361 , you'll get an AttributeError exception saying that your string object
7410 , you'll get an AttributeError exception saying that your string object
7362 doesn't have a
7411 doesn't have a
7363 \family typewriter
7412 \family typewriter
7364 .bak
7413 .bak
7365 \family default
7414 \family default
7366 attribute.
7415 attribute.
7367 This is because the
7416 This is because the
7368 \family typewriter
7417 \family typewriter
7369 $
7418 $
7370 \family default
7419 \family default
7371 expansion mechanism allows you to expand full Python expressions:
7420 expansion mechanism allows you to expand full Python expressions:
7372 \layout Standard
7421 \layout Standard
7373
7422
7374
7423
7375 \family typewriter
7424 \family typewriter
7376 fperez[~/test]|13> echo "sys.platform is: $sys.platform"
7425 fperez[~/test]|13> echo "sys.platform is: $sys.platform"
7377 \newline
7426 \newline
7378 sys.platform is: linux2
7427 sys.platform is: linux2
7379 \layout Standard
7428 \layout Standard
7380
7429
7381 IPython's input history handling is still active, which allows you to rerun
7430 IPython's input history handling is still active, which allows you to rerun
7382 a single block of multi-line input by simply using exec:
7431 a single block of multi-line input by simply using exec:
7383 \newline
7432 \newline
7384
7433
7385 \family typewriter
7434 \family typewriter
7386 fperez[~/test]|14> $$alist = ls *.eps
7435 fperez[~/test]|14> $$alist = ls *.eps
7387 \newline
7436 \newline
7388 fperez[~/test]|15> exec _i11
7437 fperez[~/test]|15> exec _i11
7389 \newline
7438 \newline
7390 file image2.eps 921 image2.eps
7439 file image2.eps 921 image2.eps
7391 \newline
7440 \newline
7392 file image.eps 921 image.eps
7441 file image.eps 921 image.eps
7393 \layout Standard
7442 \layout Standard
7394
7443
7395 While these are new special-case syntaxes, they are designed to allow very
7444 While these are new special-case syntaxes, they are designed to allow very
7396 efficient use of the shell with minimal typing.
7445 efficient use of the shell with minimal typing.
7397 At an interactive shell prompt, conciseness of expression wins over readability.
7446 At an interactive shell prompt, conciseness of expression wins over readability.
7398 \layout Subsection
7447 \layout Subsection
7399
7448
7400 Useful functions and modules
7449 Useful functions and modules
7401 \layout Standard
7450 \layout Standard
7402
7451
7403 The os, sys and shutil modules from the Python standard library are automaticall
7452 The os, sys and shutil modules from the Python standard library are automaticall
7404 y loaded.
7453 y loaded.
7405 Some additional functions, useful for shell usage, are listed below.
7454 Some additional functions, useful for shell usage, are listed below.
7406 You can request more help about them with `
7455 You can request more help about them with `
7407 \family typewriter
7456 \family typewriter
7408 ?
7457 ?
7409 \family default
7458 \family default
7410 '.
7459 '.
7411 \layout Description
7460 \layout Description
7412
7461
7413
7462
7414 \family typewriter
7463 \family typewriter
7415 shell
7464 shell
7416 \family default
7465 \family default
7417 - execute a command in the underlying system shell
7466 - execute a command in the underlying system shell
7418 \layout Description
7467 \layout Description
7419
7468
7420
7469
7421 \family typewriter
7470 \family typewriter
7422 system
7471 system
7423 \family default
7472 \family default
7424 - like
7473 - like
7425 \family typewriter
7474 \family typewriter
7426 shell()
7475 shell()
7427 \family default
7476 \family default
7428 , but return the exit status of the command
7477 , but return the exit status of the command
7429 \layout Description
7478 \layout Description
7430
7479
7431
7480
7432 \family typewriter
7481 \family typewriter
7433 sout
7482 sout
7434 \family default
7483 \family default
7435 - capture the output of a command as a string
7484 - capture the output of a command as a string
7436 \layout Description
7485 \layout Description
7437
7486
7438
7487
7439 \family typewriter
7488 \family typewriter
7440 lout
7489 lout
7441 \family default
7490 \family default
7442 - capture the output of a command as a list (split on `
7491 - capture the output of a command as a list (split on `
7443 \backslash
7492 \backslash
7444 n')
7493 n')
7445 \layout Description
7494 \layout Description
7446
7495
7447
7496
7448 \family typewriter
7497 \family typewriter
7449 getoutputerror
7498 getoutputerror
7450 \family default
7499 \family default
7451 - capture (output,error) of a shell commandss
7500 - capture (output,error) of a shell commandss
7452 \layout Standard
7501 \layout Standard
7453
7502
7454
7503
7455 \family typewriter
7504 \family typewriter
7456 sout
7505 sout
7457 \family default
7506 \family default
7458 /
7507 /
7459 \family typewriter
7508 \family typewriter
7460 lout
7509 lout
7461 \family default
7510 \family default
7462 are the functional equivalents of
7511 are the functional equivalents of
7463 \family typewriter
7512 \family typewriter
7464 $
7513 $
7465 \family default
7514 \family default
7466 /
7515 /
7467 \family typewriter
7516 \family typewriter
7468 $$
7517 $$
7469 \family default
7518 \family default
7470 .
7519 .
7471 They are provided to allow you to capture system output in the middle of
7520 They are provided to allow you to capture system output in the middle of
7472 true python code, function definitions, etc (where
7521 true python code, function definitions, etc (where
7473 \family typewriter
7522 \family typewriter
7474 $
7523 $
7475 \family default
7524 \family default
7476 and
7525 and
7477 \family typewriter
7526 \family typewriter
7478 $$
7527 $$
7479 \family default
7528 \family default
7480 are invalid).
7529 are invalid).
7481 \layout Subsection
7530 \layout Subsection
7482
7531
7483 Directory management
7532 Directory management
7484 \layout Standard
7533 \layout Standard
7485
7534
7486 Since each command passed by pysh to the underlying system is executed in
7535 Since each command passed by pysh to the underlying system is executed in
7487 a subshell which exits immediately, you can NOT use !cd to navigate the
7536 a subshell which exits immediately, you can NOT use !cd to navigate the
7488 filesystem.
7537 filesystem.
7489 \layout Standard
7538 \layout Standard
7490
7539
7491 Pysh provides its own builtin
7540 Pysh provides its own builtin
7492 \family typewriter
7541 \family typewriter
7493 `%cd
7542 `%cd
7494 \family default
7543 \family default
7495 ' magic command to move in the filesystem (the
7544 ' magic command to move in the filesystem (the
7496 \family typewriter
7545 \family typewriter
7497 %
7546 %
7498 \family default
7547 \family default
7499 is not required with automagic on).
7548 is not required with automagic on).
7500 It also maintains a list of visited directories (use
7549 It also maintains a list of visited directories (use
7501 \family typewriter
7550 \family typewriter
7502 %dhist
7551 %dhist
7503 \family default
7552 \family default
7504 to see it) and allows direct switching to any of them.
7553 to see it) and allows direct switching to any of them.
7505 Type
7554 Type
7506 \family typewriter
7555 \family typewriter
7507 `cd?
7556 `cd?
7508 \family default
7557 \family default
7509 ' for more details.
7558 ' for more details.
7510 \layout Standard
7559 \layout Standard
7511
7560
7512
7561
7513 \family typewriter
7562 \family typewriter
7514 %pushd
7563 %pushd
7515 \family default
7564 \family default
7516 ,
7565 ,
7517 \family typewriter
7566 \family typewriter
7518 %popd
7567 %popd
7519 \family default
7568 \family default
7520 and
7569 and
7521 \family typewriter
7570 \family typewriter
7522 %dirs
7571 %dirs
7523 \family default
7572 \family default
7524 are provided for directory stack handling.
7573 are provided for directory stack handling.
7525 \layout Subsection
7574 \layout Subsection
7526
7575
7527 Prompt customization
7576 Prompt customization
7528 \layout Standard
7577 \layout Standard
7529
7578
7530 The supplied
7579 The supplied
7531 \family typewriter
7580 \family typewriter
7532 ipythonrc-pysh
7581 ipythonrc-pysh
7533 \family default
7582 \family default
7534 profile comes with an example of a very colored and detailed prompt, mainly
7583 profile comes with an example of a very colored and detailed prompt, mainly
7535 to serve as an illustration.
7584 to serve as an illustration.
7536 The valid escape sequences, besides color names, are:
7585 The valid escape sequences, besides color names, are:
7537 \layout Description
7586 \layout Description
7538
7587
7539
7588
7540 \backslash
7589 \backslash
7541 # - Prompt number.
7590 # - Prompt number.
7542 \layout Description
7591 \layout Description
7543
7592
7544
7593
7545 \backslash
7594 \backslash
7546 D - Dots, as many as there are digits in
7595 D - Dots, as many as there are digits in
7547 \backslash
7596 \backslash
7548 # (so they align).
7597 # (so they align).
7549 \layout Description
7598 \layout Description
7550
7599
7551
7600
7552 \backslash
7601 \backslash
7553 w - Current working directory (cwd).
7602 w - Current working directory (cwd).
7554 \layout Description
7603 \layout Description
7555
7604
7556
7605
7557 \backslash
7606 \backslash
7558 W - Basename of current working directory.
7607 W - Basename of current working directory.
7559 \layout Description
7608 \layout Description
7560
7609
7561
7610
7562 \backslash
7611 \backslash
7563 X
7612 X
7564 \emph on
7613 \emph on
7565 N
7614 N
7566 \emph default
7615 \emph default
7567 - Where
7616 - Where
7568 \emph on
7617 \emph on
7569 N
7618 N
7570 \emph default
7619 \emph default
7571 =0..5.
7620 =0..5.
7572 N terms of the cwd, with $HOME written as ~.
7621 N terms of the cwd, with $HOME written as ~.
7573 \layout Description
7622 \layout Description
7574
7623
7575
7624
7576 \backslash
7625 \backslash
7577 Y
7626 Y
7578 \emph on
7627 \emph on
7579 N
7628 N
7580 \emph default
7629 \emph default
7581 - Where
7630 - Where
7582 \emph on
7631 \emph on
7583 N
7632 N
7584 \emph default
7633 \emph default
7585 =0..5.
7634 =0..5.
7586 Like X
7635 Like X
7587 \emph on
7636 \emph on
7588 N
7637 N
7589 \emph default
7638 \emph default
7590 , but if ~ is term
7639 , but if ~ is term
7591 \emph on
7640 \emph on
7592 N
7641 N
7593 \emph default
7642 \emph default
7594 +1 it's also shown.
7643 +1 it's also shown.
7595 \layout Description
7644 \layout Description
7596
7645
7597
7646
7598 \backslash
7647 \backslash
7599 u - Username.
7648 u - Username.
7600 \layout Description
7649 \layout Description
7601
7650
7602
7651
7603 \backslash
7652 \backslash
7604 H - Full hostname.
7653 H - Full hostname.
7605 \layout Description
7654 \layout Description
7606
7655
7607
7656
7608 \backslash
7657 \backslash
7609 h - Hostname up to first '.'
7658 h - Hostname up to first '.'
7610 \layout Description
7659 \layout Description
7611
7660
7612
7661
7613 \backslash
7662 \backslash
7614 $ - Root symbol ($ or #).
7663 $ - Root symbol ($ or #).
7615
7664
7616 \layout Description
7665 \layout Description
7617
7666
7618
7667
7619 \backslash
7668 \backslash
7620 t - Current time, in H:M:S format.
7669 t - Current time, in H:M:S format.
7621 \layout Description
7670 \layout Description
7622
7671
7623
7672
7624 \backslash
7673 \backslash
7625 v - IPython release version.
7674 v - IPython release version.
7626
7675
7627 \layout Description
7676 \layout Description
7628
7677
7629
7678
7630 \backslash
7679 \backslash
7631 n - Newline.
7680 n - Newline.
7632
7681
7633 \layout Description
7682 \layout Description
7634
7683
7635
7684
7636 \backslash
7685 \backslash
7637 r - Carriage return.
7686 r - Carriage return.
7638
7687
7639 \layout Description
7688 \layout Description
7640
7689
7641
7690
7642 \backslash
7691 \backslash
7643
7692
7644 \backslash
7693 \backslash
7645 - An explicitly escaped '
7694 - An explicitly escaped '
7646 \backslash
7695 \backslash
7647 '.
7696 '.
7648 \layout Standard
7697 \layout Standard
7649
7698
7650 You can configure your prompt colors using any ANSI color escape.
7699 You can configure your prompt colors using any ANSI color escape.
7651 Each color escape sets the color for any subsequent text, until another
7700 Each color escape sets the color for any subsequent text, until another
7652 escape comes in and changes things.
7701 escape comes in and changes things.
7653 The valid color escapes are:
7702 The valid color escapes are:
7654 \layout Description
7703 \layout Description
7655
7704
7656
7705
7657 \backslash
7706 \backslash
7658 C_Black
7707 C_Black
7659 \layout Description
7708 \layout Description
7660
7709
7661
7710
7662 \backslash
7711 \backslash
7663 C_Blue
7712 C_Blue
7664 \layout Description
7713 \layout Description
7665
7714
7666
7715
7667 \backslash
7716 \backslash
7668 C_Brown
7717 C_Brown
7669 \layout Description
7718 \layout Description
7670
7719
7671
7720
7672 \backslash
7721 \backslash
7673 C_Cyan
7722 C_Cyan
7674 \layout Description
7723 \layout Description
7675
7724
7676
7725
7677 \backslash
7726 \backslash
7678 C_DarkGray
7727 C_DarkGray
7679 \layout Description
7728 \layout Description
7680
7729
7681
7730
7682 \backslash
7731 \backslash
7683 C_Green
7732 C_Green
7684 \layout Description
7733 \layout Description
7685
7734
7686
7735
7687 \backslash
7736 \backslash
7688 C_LightBlue
7737 C_LightBlue
7689 \layout Description
7738 \layout Description
7690
7739
7691
7740
7692 \backslash
7741 \backslash
7693 C_LightCyan
7742 C_LightCyan
7694 \layout Description
7743 \layout Description
7695
7744
7696
7745
7697 \backslash
7746 \backslash
7698 C_LightGray
7747 C_LightGray
7699 \layout Description
7748 \layout Description
7700
7749
7701
7750
7702 \backslash
7751 \backslash
7703 C_LightGreen
7752 C_LightGreen
7704 \layout Description
7753 \layout Description
7705
7754
7706
7755
7707 \backslash
7756 \backslash
7708 C_LightPurple
7757 C_LightPurple
7709 \layout Description
7758 \layout Description
7710
7759
7711
7760
7712 \backslash
7761 \backslash
7713 C_LightRed
7762 C_LightRed
7714 \layout Description
7763 \layout Description
7715
7764
7716
7765
7717 \backslash
7766 \backslash
7718 C_Purple
7767 C_Purple
7719 \layout Description
7768 \layout Description
7720
7769
7721
7770
7722 \backslash
7771 \backslash
7723 C_Red
7772 C_Red
7724 \layout Description
7773 \layout Description
7725
7774
7726
7775
7727 \backslash
7776 \backslash
7728 C_White
7777 C_White
7729 \layout Description
7778 \layout Description
7730
7779
7731
7780
7732 \backslash
7781 \backslash
7733 C_Yellow
7782 C_Yellow
7734 \layout Description
7783 \layout Description
7735
7784
7736
7785
7737 \backslash
7786 \backslash
7738 C_Normal Stop coloring, defaults to your terminal settings.
7787 C_Normal Stop coloring, defaults to your terminal settings.
7739 \layout Section
7788 \layout Section
7740
7789
7741
7790
7742 \begin_inset LatexCommand \label{sec:Threading-support}
7791 \begin_inset LatexCommand \label{sec:Threading-support}
7743
7792
7744 \end_inset
7793 \end_inset
7745
7794
7746 Threading support
7795 Threading support
7747 \layout Standard
7796 \layout Standard
7748
7797
7749
7798
7750 \series bold
7799 \series bold
7751 WARNING:
7800 WARNING:
7752 \series default
7801 \series default
7753 The threading support is still somewhat experimental, and it has only seen
7802 The threading support is still somewhat experimental, and it has only seen
7754 reasonable testing under Linux.
7803 reasonable testing under Linux.
7755 Threaded code is particularly tricky to debug, and it tends to show extremely
7804 Threaded code is particularly tricky to debug, and it tends to show extremely
7756 platform-dependent behavior.
7805 platform-dependent behavior.
7757 Since I only have access to Linux machines, I will have to rely on user's
7806 Since I only have access to Linux machines, I will have to rely on user's
7758 experiences and assistance for this area of IPython to improve under other
7807 experiences and assistance for this area of IPython to improve under other
7759 platforms.
7808 platforms.
7760 \layout Standard
7809 \layout Standard
7761
7810
7762 IPython, via the
7811 IPython, via the
7763 \family typewriter
7812 \family typewriter
7764 -gthread
7813 -gthread
7765 \family default
7814 \family default
7766 ,
7815 ,
7767 \family typewriter
7816 \family typewriter
7768 -qthread
7817 -qthread
7769 \family default
7818 \family default
7770 and
7819 and
7771 \family typewriter
7820 \family typewriter
7772 -wthread
7821 -wthread
7773 \family default
7822 \family default
7774 options (described in Sec.\SpecialChar ~
7823 options (described in Sec.\SpecialChar ~
7775
7824
7776 \begin_inset LatexCommand \ref{sec:threading-opts}
7825 \begin_inset LatexCommand \ref{sec:threading-opts}
7777
7826
7778 \end_inset
7827 \end_inset
7779
7828
7780 ), can run in multithreaded mode to support pyGTK, Qt and WXPython applications
7829 ), can run in multithreaded mode to support pyGTK, Qt and WXPython applications
7781 respectively.
7830 respectively.
7782 These GUI toolkits need to control the python main loop of execution, so
7831 These GUI toolkits need to control the python main loop of execution, so
7783 under a normal Python interpreter, starting a pyGTK, Qt or WXPython application
7832 under a normal Python interpreter, starting a pyGTK, Qt or WXPython application
7784 will immediately freeze the shell.
7833 will immediately freeze the shell.
7785
7834
7786 \layout Standard
7835 \layout Standard
7787
7836
7788 IPython, with one of these options (you can only use one at a time), separates
7837 IPython, with one of these options (you can only use one at a time), separates
7789 the graphical loop and IPython's code execution run into different threads.
7838 the graphical loop and IPython's code execution run into different threads.
7790 This allows you to test interactively (with
7839 This allows you to test interactively (with
7791 \family typewriter
7840 \family typewriter
7792 %run
7841 %run
7793 \family default
7842 \family default
7794 , for example) your GUI code without blocking.
7843 , for example) your GUI code without blocking.
7795 \layout Standard
7844 \layout Standard
7796
7845
7797 A nice mini-tutorial on using IPython along with the Qt Designer application
7846 A nice mini-tutorial on using IPython along with the Qt Designer application
7798 is available at the SciPy wiki:
7847 is available at the SciPy wiki:
7799 \begin_inset LatexCommand \htmlurl{http://www.scipy.org/wikis/topical_software/QtWithIPythonAndDesigner}
7848 \begin_inset LatexCommand \htmlurl{http://www.scipy.org/wikis/topical_software/QtWithIPythonAndDesigner}
7800
7849
7801 \end_inset
7850 \end_inset
7802
7851
7803 .
7852 .
7804 \layout Subsection
7853 \layout Subsection
7805
7854
7806 Tk issues
7855 Tk issues
7807 \layout Standard
7856 \layout Standard
7808
7857
7809 As indicated in Sec.\SpecialChar ~
7858 As indicated in Sec.\SpecialChar ~
7810
7859
7811 \begin_inset LatexCommand \ref{sec:threading-opts}
7860 \begin_inset LatexCommand \ref{sec:threading-opts}
7812
7861
7813 \end_inset
7862 \end_inset
7814
7863
7815 , a special
7864 , a special
7816 \family typewriter
7865 \family typewriter
7817 -tk
7866 -tk
7818 \family default
7867 \family default
7819 option is provided to try and allow Tk graphical applications to coexist
7868 option is provided to try and allow Tk graphical applications to coexist
7820 interactively with WX, Qt or GTK ones.
7869 interactively with WX, Qt or GTK ones.
7821 Whether this works at all, however, is very platform and configuration
7870 Whether this works at all, however, is very platform and configuration
7822 dependent.
7871 dependent.
7823 Please experiment with simple test cases before committing to using this
7872 Please experiment with simple test cases before committing to using this
7824 combination of Tk and GTK/Qt/WX threading in a production environment.
7873 combination of Tk and GTK/Qt/WX threading in a production environment.
7825 \layout Subsection
7874 \layout Subsection
7826
7875
7827 Signals and Threads
7876 Signals and Threads
7828 \layout Standard
7877 \layout Standard
7829
7878
7830 When any of the thread systems (GTK, Qt or WX) are active, either directly
7879 When any of the thread systems (GTK, Qt or WX) are active, either directly
7831 or via
7880 or via
7832 \family typewriter
7881 \family typewriter
7833 -pylab
7882 -pylab
7834 \family default
7883 \family default
7835 with a threaded backend, it is impossible to interrupt long-running Python
7884 with a threaded backend, it is impossible to interrupt long-running Python
7836 code via
7885 code via
7837 \family typewriter
7886 \family typewriter
7838 Ctrl-C
7887 Ctrl-C
7839 \family default
7888 \family default
7840 .
7889 .
7841 IPython can not pass the KeyboardInterrupt exception (or the underlying
7890 IPython can not pass the KeyboardInterrupt exception (or the underlying
7842
7891
7843 \family typewriter
7892 \family typewriter
7844 SIGINT
7893 SIGINT
7845 \family default
7894 \family default
7846 ) across threads, so any long-running process started from IPython will
7895 ) across threads, so any long-running process started from IPython will
7847 run to completion, or will have to be killed via an external (OS-based)
7896 run to completion, or will have to be killed via an external (OS-based)
7848 mechanism.
7897 mechanism.
7849 \layout Standard
7898 \layout Standard
7850
7899
7851 To the best of my knowledge, this limitation is imposed by the Python interprete
7900 To the best of my knowledge, this limitation is imposed by the Python interprete
7852 r itself, and it comes from the difficulty of writing portable signal/threaded
7901 r itself, and it comes from the difficulty of writing portable signal/threaded
7853 code.
7902 code.
7854 If any user is an expert on this topic and can suggest a better solution,
7903 If any user is an expert on this topic and can suggest a better solution,
7855 I would love to hear about it.
7904 I would love to hear about it.
7856 In the IPython sources, look at the
7905 In the IPython sources, look at the
7857 \family typewriter
7906 \family typewriter
7858 Shell.py
7907 Shell.py
7859 \family default
7908 \family default
7860 module, and in particular at the
7909 module, and in particular at the
7861 \family typewriter
7910 \family typewriter
7862 runcode()
7911 runcode()
7863 \family default
7912 \family default
7864 method.
7913 method.
7865
7914
7866 \layout Subsection
7915 \layout Subsection
7867
7916
7868 I/O pitfalls
7917 I/O pitfalls
7869 \layout Standard
7918 \layout Standard
7870
7919
7871 Be mindful that the Python interpreter switches between threads every
7920 Be mindful that the Python interpreter switches between threads every
7872 \begin_inset Formula $N$
7921 \begin_inset Formula $N$
7873 \end_inset
7922 \end_inset
7874
7923
7875 bytecodes, where the default value as of Python\SpecialChar ~
7924 bytecodes, where the default value as of Python\SpecialChar ~
7876 2.3 is
7925 2.3 is
7877 \begin_inset Formula $N=100.$
7926 \begin_inset Formula $N=100.$
7878 \end_inset
7927 \end_inset
7879
7928
7880 This value can be read by using the
7929 This value can be read by using the
7881 \family typewriter
7930 \family typewriter
7882 sys.getcheckinterval()
7931 sys.getcheckinterval()
7883 \family default
7932 \family default
7884 function, and it can be reset via
7933 function, and it can be reset via
7885 \family typewriter
7934 \family typewriter
7886 sys.setcheckinterval(
7935 sys.setcheckinterval(
7887 \emph on
7936 \emph on
7888 N
7937 N
7889 \emph default
7938 \emph default
7890 )
7939 )
7891 \family default
7940 \family default
7892 .
7941 .
7893 This switching of threads can cause subtly confusing effects if one of
7942 This switching of threads can cause subtly confusing effects if one of
7894 your threads is doing file I/O.
7943 your threads is doing file I/O.
7895 In text mode, most systems only flush file buffers when they encounter
7944 In text mode, most systems only flush file buffers when they encounter
7896 a
7945 a
7897 \family typewriter
7946 \family typewriter
7898 `
7947 `
7899 \backslash
7948 \backslash
7900 n'
7949 n'
7901 \family default
7950 \family default
7902 .
7951 .
7903 An instruction as simple as
7952 An instruction as simple as
7904 \family typewriter
7953 \family typewriter
7905
7954
7906 \newline
7955 \newline
7907 \SpecialChar ~
7956 \SpecialChar ~
7908 \SpecialChar ~
7957 \SpecialChar ~
7909 print >> filehandle,
7958 print >> filehandle,
7910 \begin_inset Quotes eld
7959 \begin_inset Quotes eld
7911 \end_inset
7960 \end_inset
7912
7961
7913 hello world
7962 hello world
7914 \begin_inset Quotes erd
7963 \begin_inset Quotes erd
7915 \end_inset
7964 \end_inset
7916
7965
7917
7966
7918 \family default
7967 \family default
7919
7968
7920 \newline
7969 \newline
7921 actually consists of several bytecodes, so it is possible that the newline
7970 actually consists of several bytecodes, so it is possible that the newline
7922 does not reach your file before the next thread switch.
7971 does not reach your file before the next thread switch.
7923 Similarly, if you are writing to a file in binary mode, the file won't
7972 Similarly, if you are writing to a file in binary mode, the file won't
7924 be flushed until the buffer fills, and your other thread may see apparently
7973 be flushed until the buffer fills, and your other thread may see apparently
7925 truncated files.
7974 truncated files.
7926
7975
7927 \layout Standard
7976 \layout Standard
7928
7977
7929 For this reason, if you are using IPython's thread support and have (for
7978 For this reason, if you are using IPython's thread support and have (for
7930 example) a GUI application which will read data generated by files written
7979 example) a GUI application which will read data generated by files written
7931 to from the IPython thread, the safest approach is to open all of your
7980 to from the IPython thread, the safest approach is to open all of your
7932 files in unbuffered mode (the third argument to the
7981 files in unbuffered mode (the third argument to the
7933 \family typewriter
7982 \family typewriter
7934 file/open
7983 file/open
7935 \family default
7984 \family default
7936 function is the buffering value):
7985 function is the buffering value):
7937 \newline
7986 \newline
7938
7987
7939 \family typewriter
7988 \family typewriter
7940 \SpecialChar ~
7989 \SpecialChar ~
7941 \SpecialChar ~
7990 \SpecialChar ~
7942 filehandle = open(filename,mode,0)
7991 filehandle = open(filename,mode,0)
7943 \layout Standard
7992 \layout Standard
7944
7993
7945 This is obviously a brute force way of avoiding race conditions with the
7994 This is obviously a brute force way of avoiding race conditions with the
7946 file buffering.
7995 file buffering.
7947 If you want to do it cleanly, and you have a resource which is being shared
7996 If you want to do it cleanly, and you have a resource which is being shared
7948 by the interactive IPython loop and your GUI thread, you should really
7997 by the interactive IPython loop and your GUI thread, you should really
7949 handle it with thread locking and syncrhonization properties.
7998 handle it with thread locking and syncrhonization properties.
7950 The Python documentation discusses these.
7999 The Python documentation discusses these.
7951 \layout Section
8000 \layout Section
7952
8001
7953
8002
7954 \begin_inset LatexCommand \label{sec:interactive-demos}
8003 \begin_inset LatexCommand \label{sec:interactive-demos}
7955
8004
7956 \end_inset
8005 \end_inset
7957
8006
7958 Interactive demos with IPython
8007 Interactive demos with IPython
7959 \layout Standard
8008 \layout Standard
7960
8009
7961 IPython ships with a basic system for running scripts interactively in sections,
8010 IPython ships with a basic system for running scripts interactively in sections,
7962 useful when presenting code to audiences.
8011 useful when presenting code to audiences.
7963 A few tags embedded in comments (so that the script remains valid Python
8012 A few tags embedded in comments (so that the script remains valid Python
7964 code) divide a file into separate blocks, and the demo can be run one block
8013 code) divide a file into separate blocks, and the demo can be run one block
7965 at a time, with IPython printing (with syntax highlighting) the block before
8014 at a time, with IPython printing (with syntax highlighting) the block before
7966 executing it, and returning to the interactive prompt after each block.
8015 executing it, and returning to the interactive prompt after each block.
7967 The interactive namespace is updated after each block is run with the contents
8016 The interactive namespace is updated after each block is run with the contents
7968 of the demo's namespace.
8017 of the demo's namespace.
7969 \layout Standard
8018 \layout Standard
7970
8019
7971 This allows you to show a piece of code, run it and then execute interactively
8020 This allows you to show a piece of code, run it and then execute interactively
7972 commands based on the variables just created.
8021 commands based on the variables just created.
7973 Once you want to continue, you simply execute the next block of the demo.
8022 Once you want to continue, you simply execute the next block of the demo.
7974 The following listing shows the markup necessary for dividing a script
8023 The following listing shows the markup necessary for dividing a script
7975 into sections for execution as a demo.
8024 into sections for execution as a demo.
7976 \layout Standard
8025 \layout Standard
7977
8026
7978
8027
7979 \begin_inset ERT
8028 \begin_inset ERT
7980 status Open
8029 status Open
7981
8030
7982 \layout Standard
8031 \layout Standard
7983
8032
7984 \backslash
8033 \backslash
7985 codelist{examples/example-demo.py}
8034 codelist{examples/example-demo.py}
7986 \end_inset
8035 \end_inset
7987
8036
7988
8037
7989 \layout Standard
8038 \layout Standard
7990
8039
7991 In order to run a file as a demo, you must first make a
8040 In order to run a file as a demo, you must first make a
7992 \family typewriter
8041 \family typewriter
7993 Demo
8042 Demo
7994 \family default
8043 \family default
7995 object out of it.
8044 object out of it.
7996 If the file is named
8045 If the file is named
7997 \family typewriter
8046 \family typewriter
7998 myscript.py
8047 myscript.py
7999 \family default
8048 \family default
8000 , the following code will make a demo:
8049 , the following code will make a demo:
8001 \layout LyX-Code
8050 \layout LyX-Code
8002
8051
8003 from IPython.demo import Demo
8052 from IPython.demo import Demo
8004 \layout LyX-Code
8053 \layout LyX-Code
8005
8054
8006 mydemo = Demo('myscript.py')
8055 mydemo = Demo('myscript.py')
8007 \layout Standard
8056 \layout Standard
8008
8057
8009 This creates the
8058 This creates the
8010 \family typewriter
8059 \family typewriter
8011 mydemo
8060 mydemo
8012 \family default
8061 \family default
8013 object, whose blocks you run one at a time by simply calling the object
8062 object, whose blocks you run one at a time by simply calling the object
8014 with no arguments.
8063 with no arguments.
8015 If you have autocall active in IPython (the default), all you need to do
8064 If you have autocall active in IPython (the default), all you need to do
8016 is type
8065 is type
8017 \layout LyX-Code
8066 \layout LyX-Code
8018
8067
8019 mydemo
8068 mydemo
8020 \layout Standard
8069 \layout Standard
8021
8070
8022 and IPython will call it, executing each block.
8071 and IPython will call it, executing each block.
8023 Demo objects can be restarted, you can move forward or back skipping blocks,
8072 Demo objects can be restarted, you can move forward or back skipping blocks,
8024 re-execute the last block, etc.
8073 re-execute the last block, etc.
8025 Simply use the Tab key on a demo object to see its methods, and call
8074 Simply use the Tab key on a demo object to see its methods, and call
8026 \family typewriter
8075 \family typewriter
8027 `?'
8076 `?'
8028 \family default
8077 \family default
8029 on them to see their docstrings for more usage details.
8078 on them to see their docstrings for more usage details.
8030 In addition, the
8079 In addition, the
8031 \family typewriter
8080 \family typewriter
8032 demo
8081 demo
8033 \family default
8082 \family default
8034 module itself contains a comprehensive docstring, which you can access
8083 module itself contains a comprehensive docstring, which you can access
8035 via
8084 via
8036 \layout LyX-Code
8085 \layout LyX-Code
8037
8086
8038 from IPython import demo
8087 from IPython import demo
8039 \layout LyX-Code
8088 \layout LyX-Code
8040
8089
8041 demo?
8090 demo?
8042 \layout Standard
8091 \layout Standard
8043
8092
8044
8093
8045 \series bold
8094 \series bold
8046 Limitations:
8095 Limitations:
8047 \series default
8096 \series default
8048 It is important to note that these demos are limited to fairly simple uses.
8097 It is important to note that these demos are limited to fairly simple uses.
8049 In particular, you can
8098 In particular, you can
8050 \emph on
8099 \emph on
8051 not
8100 not
8052 \emph default
8101 \emph default
8053 put division marks in indented code (loops, if statements, function definitions
8102 put division marks in indented code (loops, if statements, function definitions
8054 , etc.) Supporting something like this would basically require tracking the
8103 , etc.) Supporting something like this would basically require tracking the
8055 internal execution state of the Python interpreter, so only top-level divisions
8104 internal execution state of the Python interpreter, so only top-level divisions
8056 are allowed.
8105 are allowed.
8057 If you want to be able to open an IPython instance at an arbitrary point
8106 If you want to be able to open an IPython instance at an arbitrary point
8058 in a program, you can use IPython's embedding facilities, described in
8107 in a program, you can use IPython's embedding facilities, described in
8059 detail in Sec\SpecialChar \@.
8108 detail in Sec\SpecialChar \@.
8060 \SpecialChar ~
8109 \SpecialChar ~
8061
8110
8062 \begin_inset LatexCommand \ref{sec:embed}
8111 \begin_inset LatexCommand \ref{sec:embed}
8063
8112
8064 \end_inset
8113 \end_inset
8065
8114
8066 .
8115 .
8067 \layout Section
8116 \layout Section
8068
8117
8069
8118
8070 \begin_inset LatexCommand \label{sec:matplotlib-support}
8119 \begin_inset LatexCommand \label{sec:matplotlib-support}
8071
8120
8072 \end_inset
8121 \end_inset
8073
8122
8074 Plotting with
8123 Plotting with
8075 \family typewriter
8124 \family typewriter
8076 matplotlib
8125 matplotlib
8077 \family default
8126 \family default
8078
8127
8079 \layout Standard
8128 \layout Standard
8080
8129
8081 The matplotlib library (
8130 The matplotlib library (
8082 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
8131 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
8083
8132
8084 \end_inset
8133 \end_inset
8085
8134
8086 ) provides high quality 2D plotting for Python.
8135 ) provides high quality 2D plotting for Python.
8087 Matplotlib can produce plots on screen using a variety of GUI toolkits,
8136 Matplotlib can produce plots on screen using a variety of GUI toolkits,
8088 including Tk, GTK and WXPython.
8137 including Tk, GTK and WXPython.
8089 It also provides a number of commands useful for scientific computing,
8138 It also provides a number of commands useful for scientific computing,
8090 all with a syntax compatible with that of the popular Matlab program.
8139 all with a syntax compatible with that of the popular Matlab program.
8091 \layout Standard
8140 \layout Standard
8092
8141
8093 IPython accepts the special option
8142 IPython accepts the special option
8094 \family typewriter
8143 \family typewriter
8095 -pylab
8144 -pylab
8096 \family default
8145 \family default
8097 (Sec.\SpecialChar ~
8146 (Sec.\SpecialChar ~
8098
8147
8099 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
8148 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
8100
8149
8101 \end_inset
8150 \end_inset
8102
8151
8103 ).
8152 ).
8104 This configures it to support matplotlib, honoring the settings in the
8153 This configures it to support matplotlib, honoring the settings in the
8105
8154
8106 \family typewriter
8155 \family typewriter
8107 .matplotlibrc
8156 .matplotlibrc
8108 \family default
8157 \family default
8109 file.
8158 file.
8110 IPython will detect the user's choice of matplotlib GUI backend, and automatica
8159 IPython will detect the user's choice of matplotlib GUI backend, and automatica
8111 lly select the proper threading model to prevent blocking.
8160 lly select the proper threading model to prevent blocking.
8112 It also sets matplotlib in interactive mode and modifies
8161 It also sets matplotlib in interactive mode and modifies
8113 \family typewriter
8162 \family typewriter
8114 %run
8163 %run
8115 \family default
8164 \family default
8116 slightly, so that any matplotlib-based script can be executed using
8165 slightly, so that any matplotlib-based script can be executed using
8117 \family typewriter
8166 \family typewriter
8118 %run
8167 %run
8119 \family default
8168 \family default
8120 and the final
8169 and the final
8121 \family typewriter
8170 \family typewriter
8122 show()
8171 show()
8123 \family default
8172 \family default
8124 command does not block the interactive shell.
8173 command does not block the interactive shell.
8125 \layout Standard
8174 \layout Standard
8126
8175
8127 The
8176 The
8128 \family typewriter
8177 \family typewriter
8129 -pylab
8178 -pylab
8130 \family default
8179 \family default
8131 option must be given first in order for IPython to configure its threading
8180 option must be given first in order for IPython to configure its threading
8132 mode.
8181 mode.
8133 However, you can still issue other options afterwards.
8182 However, you can still issue other options afterwards.
8134 This allows you to have a matplotlib-based environment customized with
8183 This allows you to have a matplotlib-based environment customized with
8135 additional modules using the standard IPython profile mechanism (Sec.\SpecialChar ~
8184 additional modules using the standard IPython profile mechanism (Sec.\SpecialChar ~
8136
8185
8137 \begin_inset LatexCommand \ref{sec:profiles}
8186 \begin_inset LatexCommand \ref{sec:profiles}
8138
8187
8139 \end_inset
8188 \end_inset
8140
8189
8141 ): ``
8190 ): ``
8142 \family typewriter
8191 \family typewriter
8143 ipython -pylab -p myprofile
8192 ipython -pylab -p myprofile
8144 \family default
8193 \family default
8145 '' will load the profile defined in
8194 '' will load the profile defined in
8146 \family typewriter
8195 \family typewriter
8147 ipythonrc-myprofile
8196 ipythonrc-myprofile
8148 \family default
8197 \family default
8149 after configuring matplotlib.
8198 after configuring matplotlib.
8150 \layout Section
8199 \layout Section
8151
8200
8152
8201
8153 \begin_inset LatexCommand \label{sec:Gnuplot}
8202 \begin_inset LatexCommand \label{sec:Gnuplot}
8154
8203
8155 \end_inset
8204 \end_inset
8156
8205
8157 Plotting with
8206 Plotting with
8158 \family typewriter
8207 \family typewriter
8159 Gnuplot
8208 Gnuplot
8160 \layout Standard
8209 \layout Standard
8161
8210
8162 Through the magic extension system described in sec.
8211 Through the magic extension system described in sec.
8163
8212
8164 \begin_inset LatexCommand \ref{sec:magic}
8213 \begin_inset LatexCommand \ref{sec:magic}
8165
8214
8166 \end_inset
8215 \end_inset
8167
8216
8168 , IPython incorporates a mechanism for conveniently interfacing with the
8217 , IPython incorporates a mechanism for conveniently interfacing with the
8169 Gnuplot system (
8218 Gnuplot system (
8170 \begin_inset LatexCommand \htmlurl{http://www.gnuplot.info}
8219 \begin_inset LatexCommand \htmlurl{http://www.gnuplot.info}
8171
8220
8172 \end_inset
8221 \end_inset
8173
8222
8174 ).
8223 ).
8175 Gnuplot is a very complete 2D and 3D plotting package available for many
8224 Gnuplot is a very complete 2D and 3D plotting package available for many
8176 operating systems and commonly included in modern Linux distributions.
8225 operating systems and commonly included in modern Linux distributions.
8177
8226
8178 \layout Standard
8227 \layout Standard
8179
8228
8180 Besides having Gnuplot installed, this functionality requires the
8229 Besides having Gnuplot installed, this functionality requires the
8181 \family typewriter
8230 \family typewriter
8182 Gnuplot.py
8231 Gnuplot.py
8183 \family default
8232 \family default
8184 module for interfacing python with Gnuplot.
8233 module for interfacing python with Gnuplot.
8185 It can be downloaded from:
8234 It can be downloaded from:
8186 \begin_inset LatexCommand \htmlurl{http://gnuplot-py.sourceforge.net}
8235 \begin_inset LatexCommand \htmlurl{http://gnuplot-py.sourceforge.net}
8187
8236
8188 \end_inset
8237 \end_inset
8189
8238
8190 .
8239 .
8191 \layout Subsection
8240 \layout Subsection
8192
8241
8193 Proper Gnuplot configuration
8242 Proper Gnuplot configuration
8194 \layout Standard
8243 \layout Standard
8195
8244
8196 As of version 4.0, Gnuplot has excellent mouse and interactive keyboard support.
8245 As of version 4.0, Gnuplot has excellent mouse and interactive keyboard support.
8197 However, as of
8246 However, as of
8198 \family typewriter
8247 \family typewriter
8199 Gnuplot.py
8248 Gnuplot.py
8200 \family default
8249 \family default
8201 version 1.7, a new option was added to communicate between Python and Gnuplot
8250 version 1.7, a new option was added to communicate between Python and Gnuplot
8202 via FIFOs (pipes).
8251 via FIFOs (pipes).
8203 This mechanism, while fast, also breaks the mouse system.
8252 This mechanism, while fast, also breaks the mouse system.
8204 You must therefore set the variable
8253 You must therefore set the variable
8205 \family typewriter
8254 \family typewriter
8206 prefer_fifo_data
8255 prefer_fifo_data
8207 \family default
8256 \family default
8208 to
8257 to
8209 \family typewriter
8258 \family typewriter
8210 0
8259 0
8211 \family default
8260 \family default
8212 in file
8261 in file
8213 \family typewriter
8262 \family typewriter
8214 gp_unix.py
8263 gp_unix.py
8215 \family default
8264 \family default
8216 if you wish to keep the interactive mouse and keyboard features working
8265 if you wish to keep the interactive mouse and keyboard features working
8217 properly (
8266 properly (
8218 \family typewriter
8267 \family typewriter
8219 prefer_inline_data
8268 prefer_inline_data
8220 \family default
8269 \family default
8221 also must be
8270 also must be
8222 \family typewriter
8271 \family typewriter
8223 0
8272 0
8224 \family default
8273 \family default
8225 , but this is the default so unless you've changed it manually you should
8274 , but this is the default so unless you've changed it manually you should
8226 be fine).
8275 be fine).
8227 \layout Standard
8276 \layout Standard
8228
8277
8229 'Out of the box', Gnuplot is configured with a rather poor set of size,
8278 'Out of the box', Gnuplot is configured with a rather poor set of size,
8230 color and linewidth choices which make the graphs fairly hard to read on
8279 color and linewidth choices which make the graphs fairly hard to read on
8231 modern high-resolution displays (although they work fine on old 640x480
8280 modern high-resolution displays (although they work fine on old 640x480
8232 ones).
8281 ones).
8233 Below is a section of my
8282 Below is a section of my
8234 \family typewriter
8283 \family typewriter
8235 .Xdefaults
8284 .Xdefaults
8236 \family default
8285 \family default
8237 file which I use for having a more convenient Gnuplot setup.
8286 file which I use for having a more convenient Gnuplot setup.
8238 Remember to load it by running
8287 Remember to load it by running
8239 \family typewriter
8288 \family typewriter
8240 `xrdb .Xdefaults`
8289 `xrdb .Xdefaults`
8241 \family default
8290 \family default
8242 :
8291 :
8243 \layout Standard
8292 \layout Standard
8244
8293
8245
8294
8246 \family typewriter
8295 \family typewriter
8247 !******************************************************************
8296 !******************************************************************
8248 \newline
8297 \newline
8249 ! gnuplot options
8298 ! gnuplot options
8250 \newline
8299 \newline
8251 ! modify this for a convenient window size
8300 ! modify this for a convenient window size
8252 \newline
8301 \newline
8253 gnuplot*geometry: 780x580
8302 gnuplot*geometry: 780x580
8254 \layout Standard
8303 \layout Standard
8255
8304
8256
8305
8257 \family typewriter
8306 \family typewriter
8258 ! on-screen font (not for PostScript)
8307 ! on-screen font (not for PostScript)
8259 \newline
8308 \newline
8260 gnuplot*font: -misc-fixed-bold-r-normal--15-120-100-100-c-90-iso8859-1
8309 gnuplot*font: -misc-fixed-bold-r-normal--15-120-100-100-c-90-iso8859-1
8261 \layout Standard
8310 \layout Standard
8262
8311
8263
8312
8264 \family typewriter
8313 \family typewriter
8265 ! color options
8314 ! color options
8266 \newline
8315 \newline
8267 gnuplot*background: black
8316 gnuplot*background: black
8268 \newline
8317 \newline
8269 gnuplot*textColor: white
8318 gnuplot*textColor: white
8270 \newline
8319 \newline
8271 gnuplot*borderColor: white
8320 gnuplot*borderColor: white
8272 \newline
8321 \newline
8273 gnuplot*axisColor: white
8322 gnuplot*axisColor: white
8274 \newline
8323 \newline
8275 gnuplot*line1Color: red
8324 gnuplot*line1Color: red
8276 \newline
8325 \newline
8277 gnuplot*line2Color: green
8326 gnuplot*line2Color: green
8278 \newline
8327 \newline
8279 gnuplot*line3Color: blue
8328 gnuplot*line3Color: blue
8280 \newline
8329 \newline
8281 gnuplot*line4Color: magenta
8330 gnuplot*line4Color: magenta
8282 \newline
8331 \newline
8283 gnuplot*line5Color: cyan
8332 gnuplot*line5Color: cyan
8284 \newline
8333 \newline
8285 gnuplot*line6Color: sienna
8334 gnuplot*line6Color: sienna
8286 \newline
8335 \newline
8287 gnuplot*line7Color: orange
8336 gnuplot*line7Color: orange
8288 \newline
8337 \newline
8289 gnuplot*line8Color: coral
8338 gnuplot*line8Color: coral
8290 \layout Standard
8339 \layout Standard
8291
8340
8292
8341
8293 \family typewriter
8342 \family typewriter
8294 ! multiplicative factor for point styles
8343 ! multiplicative factor for point styles
8295 \newline
8344 \newline
8296 gnuplot*pointsize: 2
8345 gnuplot*pointsize: 2
8297 \layout Standard
8346 \layout Standard
8298
8347
8299
8348
8300 \family typewriter
8349 \family typewriter
8301 ! line width options (in pixels)
8350 ! line width options (in pixels)
8302 \newline
8351 \newline
8303 gnuplot*borderWidth: 2
8352 gnuplot*borderWidth: 2
8304 \newline
8353 \newline
8305 gnuplot*axisWidth: 2
8354 gnuplot*axisWidth: 2
8306 \newline
8355 \newline
8307 gnuplot*line1Width: 2
8356 gnuplot*line1Width: 2
8308 \newline
8357 \newline
8309 gnuplot*line2Width: 2
8358 gnuplot*line2Width: 2
8310 \newline
8359 \newline
8311 gnuplot*line3Width: 2
8360 gnuplot*line3Width: 2
8312 \newline
8361 \newline
8313 gnuplot*line4Width: 2
8362 gnuplot*line4Width: 2
8314 \newline
8363 \newline
8315 gnuplot*line5Width: 2
8364 gnuplot*line5Width: 2
8316 \newline
8365 \newline
8317 gnuplot*line6Width: 2
8366 gnuplot*line6Width: 2
8318 \newline
8367 \newline
8319 gnuplot*line7Width: 2
8368 gnuplot*line7Width: 2
8320 \newline
8369 \newline
8321 gnuplot*line8Width: 2
8370 gnuplot*line8Width: 2
8322 \layout Subsection
8371 \layout Subsection
8323
8372
8324 The
8373 The
8325 \family typewriter
8374 \family typewriter
8326 IPython.GnuplotRuntime
8375 IPython.GnuplotRuntime
8327 \family default
8376 \family default
8328 module
8377 module
8329 \layout Standard
8378 \layout Standard
8330
8379
8331 IPython includes a module called
8380 IPython includes a module called
8332 \family typewriter
8381 \family typewriter
8333 Gnuplot2.py
8382 Gnuplot2.py
8334 \family default
8383 \family default
8335 which extends and improves the default
8384 which extends and improves the default
8336 \family typewriter
8385 \family typewriter
8337 Gnuplot
8386 Gnuplot
8338 \family default
8387 \family default
8339 .
8388 .
8340 \family typewriter
8389 \family typewriter
8341 py
8390 py
8342 \family default
8391 \family default
8343 (which it still relies upon).
8392 (which it still relies upon).
8344 For example, the new
8393 For example, the new
8345 \family typewriter
8394 \family typewriter
8346 plot
8395 plot
8347 \family default
8396 \family default
8348 function adds several improvements to the original making it more convenient
8397 function adds several improvements to the original making it more convenient
8349 for interactive use, and
8398 for interactive use, and
8350 \family typewriter
8399 \family typewriter
8351 hardcopy
8400 hardcopy
8352 \family default
8401 \family default
8353 fixes a bug in the original which under some circumstances blocks the creation
8402 fixes a bug in the original which under some circumstances blocks the creation
8354 of PostScript output.
8403 of PostScript output.
8355 \layout Standard
8404 \layout Standard
8356
8405
8357 For scripting use,
8406 For scripting use,
8358 \family typewriter
8407 \family typewriter
8359 GnuplotRuntime.py
8408 GnuplotRuntime.py
8360 \family default
8409 \family default
8361 is provided, which wraps
8410 is provided, which wraps
8362 \family typewriter
8411 \family typewriter
8363 Gnuplot2.py
8412 Gnuplot2.py
8364 \family default
8413 \family default
8365 and creates a series of global aliases.
8414 and creates a series of global aliases.
8366 These make it easy to control Gnuplot plotting jobs through the Python
8415 These make it easy to control Gnuplot plotting jobs through the Python
8367 language.
8416 language.
8368 \layout Standard
8417 \layout Standard
8369
8418
8370 Below is some example code which illustrates how to configure Gnuplot inside
8419 Below is some example code which illustrates how to configure Gnuplot inside
8371 your own programs but have it available for further interactive use through
8420 your own programs but have it available for further interactive use through
8372 an embedded IPython instance.
8421 an embedded IPython instance.
8373 Simply run this file at a system prompt.
8422 Simply run this file at a system prompt.
8374 This file is provided as
8423 This file is provided as
8375 \family typewriter
8424 \family typewriter
8376 example-gnuplot.py
8425 example-gnuplot.py
8377 \family default
8426 \family default
8378 in the examples directory:
8427 in the examples directory:
8379 \layout Standard
8428 \layout Standard
8380
8429
8381
8430
8382 \begin_inset ERT
8431 \begin_inset ERT
8383 status Open
8432 status Open
8384
8433
8385 \layout Standard
8434 \layout Standard
8386
8435
8387 \backslash
8436 \backslash
8388 codelist{examples/example-gnuplot.py}
8437 codelist{examples/example-gnuplot.py}
8389 \end_inset
8438 \end_inset
8390
8439
8391
8440
8392 \layout Subsection
8441 \layout Subsection
8393
8442
8394 The
8443 The
8395 \family typewriter
8444 \family typewriter
8396 numeric
8445 numeric
8397 \family default
8446 \family default
8398 profile: a scientific computing environment
8447 profile: a scientific computing environment
8399 \layout Standard
8448 \layout Standard
8400
8449
8401 The
8450 The
8402 \family typewriter
8451 \family typewriter
8403 numeric
8452 numeric
8404 \family default
8453 \family default
8405 IPython profile, which you can activate with
8454 IPython profile, which you can activate with
8406 \family typewriter
8455 \family typewriter
8407 `ipython -p numeric
8456 `ipython -p numeric
8408 \family default
8457 \family default
8409 ' will automatically load the IPython Gnuplot extensions (plus Numeric and
8458 ' will automatically load the IPython Gnuplot extensions (plus Numeric and
8410 other useful things for numerical computing), contained in the
8459 other useful things for numerical computing), contained in the
8411 \family typewriter
8460 \family typewriter
8412 IPython.GnuplotInteractive
8461 IPython.GnuplotInteractive
8413 \family default
8462 \family default
8414 module.
8463 module.
8415 This will create the globals
8464 This will create the globals
8416 \family typewriter
8465 \family typewriter
8417 Gnuplot
8466 Gnuplot
8418 \family default
8467 \family default
8419 (an alias to the improved Gnuplot2 module),
8468 (an alias to the improved Gnuplot2 module),
8420 \family typewriter
8469 \family typewriter
8421 gp
8470 gp
8422 \family default
8471 \family default
8423 (a Gnuplot active instance), the new magic commands
8472 (a Gnuplot active instance), the new magic commands
8424 \family typewriter
8473 \family typewriter
8425 %gpc
8474 %gpc
8426 \family default
8475 \family default
8427 and
8476 and
8428 \family typewriter
8477 \family typewriter
8429 %gp_set_instance
8478 %gp_set_instance
8430 \family default
8479 \family default
8431 and several other convenient globals.
8480 and several other convenient globals.
8432 Type
8481 Type
8433 \family typewriter
8482 \family typewriter
8434 gphelp()
8483 gphelp()
8435 \family default
8484 \family default
8436 for further details.
8485 for further details.
8437 \layout Standard
8486 \layout Standard
8438
8487
8439 This should turn IPython into a convenient environment for numerical computing,
8488 This should turn IPython into a convenient environment for numerical computing,
8440 with all the functions in the NumPy library and the Gnuplot facilities
8489 with all the functions in the NumPy library and the Gnuplot facilities
8441 for plotting.
8490 for plotting.
8442 Further improvements can be obtained by loading the SciPy libraries for
8491 Further improvements can be obtained by loading the SciPy libraries for
8443 scientific computing, available at
8492 scientific computing, available at
8444 \begin_inset LatexCommand \htmlurl{http://scipy.org}
8493 \begin_inset LatexCommand \htmlurl{http://scipy.org}
8445
8494
8446 \end_inset
8495 \end_inset
8447
8496
8448 .
8497 .
8449 \layout Standard
8498 \layout Standard
8450
8499
8451 If you are in the middle of a working session with numerical objects and
8500 If you are in the middle of a working session with numerical objects and
8452 need to plot them but you didn't start the
8501 need to plot them but you didn't start the
8453 \family typewriter
8502 \family typewriter
8454 numeric
8503 numeric
8455 \family default
8504 \family default
8456 profile, you can load these extensions at any time by typing
8505 profile, you can load these extensions at any time by typing
8457 \newline
8506 \newline
8458
8507
8459 \family typewriter
8508 \family typewriter
8460 from IPython.GnuplotInteractive import *
8509 from IPython.GnuplotInteractive import *
8461 \newline
8510 \newline
8462
8511
8463 \family default
8512 \family default
8464 at the IPython prompt.
8513 at the IPython prompt.
8465 This will allow you to keep your objects intact and start using Gnuplot
8514 This will allow you to keep your objects intact and start using Gnuplot
8466 to view them.
8515 to view them.
8467 \layout Section
8516 \layout Section
8468
8517
8469 Reporting bugs
8518 Reporting bugs
8470 \layout Subsection*
8519 \layout Subsection*
8471
8520
8472 Automatic crash reports
8521 Automatic crash reports
8473 \layout Standard
8522 \layout Standard
8474
8523
8475 Ideally, IPython itself shouldn't crash.
8524 Ideally, IPython itself shouldn't crash.
8476 It will catch exceptions produced by you, but bugs in its internals will
8525 It will catch exceptions produced by you, but bugs in its internals will
8477 still crash it.
8526 still crash it.
8478 \layout Standard
8527 \layout Standard
8479
8528
8480 In such a situation, IPython will leave a file named
8529 In such a situation, IPython will leave a file named
8481 \family typewriter
8530 \family typewriter
8482 IPython_crash_report.txt
8531 IPython_crash_report.txt
8483 \family default
8532 \family default
8484 in your IPYTHONDIR directory (that way if crashes happen several times
8533 in your IPYTHONDIR directory (that way if crashes happen several times
8485 it won't litter many directories, the post-mortem file is always located
8534 it won't litter many directories, the post-mortem file is always located
8486 in the same place and new occurrences just overwrite the previous one).
8535 in the same place and new occurrences just overwrite the previous one).
8487 If you can mail this file to the developers (see sec.
8536 If you can mail this file to the developers (see sec.
8488
8537
8489 \begin_inset LatexCommand \ref{sec:credits}
8538 \begin_inset LatexCommand \ref{sec:credits}
8490
8539
8491 \end_inset
8540 \end_inset
8492
8541
8493 for names and addresses), it will help us
8542 for names and addresses), it will help us
8494 \emph on
8543 \emph on
8495 a lot
8544 a lot
8496 \emph default
8545 \emph default
8497 in understanding the cause of the problem and fixing it sooner.
8546 in understanding the cause of the problem and fixing it sooner.
8498 \layout Subsection*
8547 \layout Subsection*
8499
8548
8500 The bug tracker
8549 The bug tracker
8501 \layout Standard
8550 \layout Standard
8502
8551
8503 IPython also has an online bug-tracker, located at
8552 IPython also has an online bug-tracker, located at
8504 \begin_inset LatexCommand \htmlurl{http://www.scipy.net/roundup/ipython}
8553 \begin_inset LatexCommand \htmlurl{http://www.scipy.net/roundup/ipython}
8505
8554
8506 \end_inset
8555 \end_inset
8507
8556
8508 .
8557 .
8509 In addition to mailing the developers, it would be a good idea to file
8558 In addition to mailing the developers, it would be a good idea to file
8510 a bug report here.
8559 a bug report here.
8511 This will ensure that the issue is properly followed to conclusion.
8560 This will ensure that the issue is properly followed to conclusion.
8512 \layout Standard
8561 \layout Standard
8513
8562
8514 You can also use this bug tracker to file feature requests.
8563 You can also use this bug tracker to file feature requests.
8515 \layout Section
8564 \layout Section
8516
8565
8517 Brief history
8566 Brief history
8518 \layout Subsection
8567 \layout Subsection
8519
8568
8520 Origins
8569 Origins
8521 \layout Standard
8570 \layout Standard
8522
8571
8523 The current IPython system grew out of the following three projects:
8572 The current IPython system grew out of the following three projects:
8524 \layout List
8573 \layout List
8525 \labelwidthstring 00.00.0000
8574 \labelwidthstring 00.00.0000
8526
8575
8527 ipython by Fernando Pérez.
8576 ipython by Fernando P
8577 \begin_inset ERT
8578 status Collapsed
8579
8580 \layout Standard
8581
8582 \backslash
8583 '{e}
8584 \end_inset
8585
8586 rez.
8528 I was working on adding Mathematica-type prompts and a flexible configuration
8587 I was working on adding Mathematica-type prompts and a flexible configuration
8529 system (something better than
8588 system (something better than
8530 \family typewriter
8589 \family typewriter
8531 $PYTHONSTARTUP
8590 $PYTHONSTARTUP
8532 \family default
8591 \family default
8533 ) to the standard Python interactive interpreter.
8592 ) to the standard Python interactive interpreter.
8534 \layout List
8593 \layout List
8535 \labelwidthstring 00.00.0000
8594 \labelwidthstring 00.00.0000
8536
8595
8537 IPP by Janko Hauser.
8596 IPP by Janko Hauser.
8538 Very well organized, great usability.
8597 Very well organized, great usability.
8539 Had an old help system.
8598 Had an old help system.
8540 IPP was used as the `container' code into which I added the functionality
8599 IPP was used as the `container' code into which I added the functionality
8541 from ipython and LazyPython.
8600 from ipython and LazyPython.
8542 \layout List
8601 \layout List
8543 \labelwidthstring 00.00.0000
8602 \labelwidthstring 00.00.0000
8544
8603
8545 LazyPython by Nathan Gray.
8604 LazyPython by Nathan Gray.
8546 Simple but
8605 Simple but
8547 \emph on
8606 \emph on
8548 very
8607 very
8549 \emph default
8608 \emph default
8550 powerful.
8609 powerful.
8551 The quick syntax (auto parens, auto quotes) and verbose/colored tracebacks
8610 The quick syntax (auto parens, auto quotes) and verbose/colored tracebacks
8552 were all taken from here.
8611 were all taken from here.
8553 \layout Standard
8612 \layout Standard
8554
8613
8555 When I found out (see sec.
8614 When I found out (see sec.
8556
8615
8557 \begin_inset LatexCommand \ref{figgins}
8616 \begin_inset LatexCommand \ref{figgins}
8558
8617
8559 \end_inset
8618 \end_inset
8560
8619
8561 ) about IPP and LazyPython I tried to join all three into a unified system.
8620 ) about IPP and LazyPython I tried to join all three into a unified system.
8562 I thought this could provide a very nice working environment, both for
8621 I thought this could provide a very nice working environment, both for
8563 regular programming and scientific computing: shell-like features, IDL/Matlab
8622 regular programming and scientific computing: shell-like features, IDL/Matlab
8564 numerics, Mathematica-type prompt history and great object introspection
8623 numerics, Mathematica-type prompt history and great object introspection
8565 and help facilities.
8624 and help facilities.
8566 I think it worked reasonably well, though it was a lot more work than I
8625 I think it worked reasonably well, though it was a lot more work than I
8567 had initially planned.
8626 had initially planned.
8568 \layout Subsection
8627 \layout Subsection
8569
8628
8570 Current status
8629 Current status
8571 \layout Standard
8630 \layout Standard
8572
8631
8573 The above listed features work, and quite well for the most part.
8632 The above listed features work, and quite well for the most part.
8574 But until a major internal restructuring is done (see below), only bug
8633 But until a major internal restructuring is done (see below), only bug
8575 fixing will be done, no other features will be added (unless very minor
8634 fixing will be done, no other features will be added (unless very minor
8576 and well localized in the cleaner parts of the code).
8635 and well localized in the cleaner parts of the code).
8577 \layout Standard
8636 \layout Standard
8578
8637
8579 IPython consists of some 12000 lines of pure python code, of which roughly
8638 IPython consists of some 18000 lines of pure python code, of which roughly
8580 50% are fairly clean.
8639 two thirds is reasonably clean.
8581 The other 50% are fragile, messy code which needs a massive restructuring
8640 The rest is, messy code which needs a massive restructuring before any
8582 before any further major work is done.
8641 further major work is done.
8583 Even the messy code is fairly well documented though, and most of the problems
8642 Even the messy code is fairly well documented though, and most of the problems
8584 in the (non-existent) class design are well pointed to by a PyChecker run.
8643 in the (non-existent) class design are well pointed to by a PyChecker run.
8585 So the rewriting work isn't that bad, it will just be time-consuming.
8644 So the rewriting work isn't that bad, it will just be time-consuming.
8586 \layout Subsection
8645 \layout Subsection
8587
8646
8588 Future
8647 Future
8589 \layout Standard
8648 \layout Standard
8590
8649
8591 See the separate
8650 See the separate
8592 \family typewriter
8651 \family typewriter
8593 new_design
8652 new_design
8594 \family default
8653 \family default
8595 document for details.
8654 document for details.
8596 Ultimately, I would like to see IPython become part of the standard Python
8655 Ultimately, I would like to see IPython become part of the standard Python
8597 distribution as a `big brother with batteries' to the standard Python interacti
8656 distribution as a `big brother with batteries' to the standard Python interacti
8598 ve interpreter.
8657 ve interpreter.
8599 But that will never happen with the current state of the code, so all contribut
8658 But that will never happen with the current state of the code, so all contribut
8600 ions are welcome.
8659 ions are welcome.
8601 \layout Section
8660 \layout Section
8602
8661
8603 License
8662 License
8604 \layout Standard
8663 \layout Standard
8605
8664
8606 IPython is released under the terms of the BSD license, whose general form
8665 IPython is released under the terms of the BSD license, whose general form
8607 can be found at:
8666 can be found at:
8608 \begin_inset LatexCommand \htmlurl{http://www.opensource.org/licenses/bsd-license.php}
8667 \begin_inset LatexCommand \htmlurl{http://www.opensource.org/licenses/bsd-license.php}
8609
8668
8610 \end_inset
8669 \end_inset
8611
8670
8612 .
8671 .
8613 The full text of the IPython license is reproduced below:
8672 The full text of the IPython license is reproduced below:
8614 \layout Quote
8673 \layout Quote
8615
8674
8616
8675
8617 \family typewriter
8676 \family typewriter
8618 \size small
8677 \size small
8619 IPython is released under a BSD-type license.
8678 IPython is released under a BSD-type license.
8620 \layout Quote
8679 \layout Quote
8621
8680
8622
8681
8623 \family typewriter
8682 \family typewriter
8624 \size small
8683 \size small
8625 Copyright (c) 2001, 2002, 2003, 2004 Fernando Perez <fperez@colorado.edu>.
8684 Copyright (c) 2001, 2002, 2003, 2004 Fernando Perez <fperez@colorado.edu>.
8626 \layout Quote
8685 \layout Quote
8627
8686
8628
8687
8629 \family typewriter
8688 \family typewriter
8630 \size small
8689 \size small
8631 Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and
8690 Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and
8632 \newline
8691 \newline
8633 Nathaniel Gray <n8gray@caltech.edu>.
8692 Nathaniel Gray <n8gray@caltech.edu>.
8634 \layout Quote
8693 \layout Quote
8635
8694
8636
8695
8637 \family typewriter
8696 \family typewriter
8638 \size small
8697 \size small
8639 All rights reserved.
8698 All rights reserved.
8640 \layout Quote
8699 \layout Quote
8641
8700
8642
8701
8643 \family typewriter
8702 \family typewriter
8644 \size small
8703 \size small
8645 Redistribution and use in source and binary forms, with or without modification,
8704 Redistribution and use in source and binary forms, with or without modification,
8646 are permitted provided that the following conditions are met:
8705 are permitted provided that the following conditions are met:
8647 \layout Quote
8706 \layout Quote
8648
8707
8649
8708
8650 \family typewriter
8709 \family typewriter
8651 \size small
8710 \size small
8652 a.
8711 a.
8653 Redistributions of source code must retain the above copyright notice,
8712 Redistributions of source code must retain the above copyright notice,
8654 this list of conditions and the following disclaimer.
8713 this list of conditions and the following disclaimer.
8655 \layout Quote
8714 \layout Quote
8656
8715
8657
8716
8658 \family typewriter
8717 \family typewriter
8659 \size small
8718 \size small
8660 b.
8719 b.
8661 Redistributions in binary form must reproduce the above copyright notice,
8720 Redistributions in binary form must reproduce the above copyright notice,
8662 this list of conditions and the following disclaimer in the documentation
8721 this list of conditions and the following disclaimer in the documentation
8663 and/or other materials provided with the distribution.
8722 and/or other materials provided with the distribution.
8664 \layout Quote
8723 \layout Quote
8665
8724
8666
8725
8667 \family typewriter
8726 \family typewriter
8668 \size small
8727 \size small
8669 c.
8728 c.
8670 Neither the name of the copyright holders nor the names of any contributors
8729 Neither the name of the copyright holders nor the names of any contributors
8671 to this software may be used to endorse or promote products derived from
8730 to this software may be used to endorse or promote products derived from
8672 this software without specific prior written permission.
8731 this software without specific prior written permission.
8673 \layout Quote
8732 \layout Quote
8674
8733
8675
8734
8676 \family typewriter
8735 \family typewriter
8677 \size small
8736 \size small
8678 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
8737 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
8679 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
8738 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
8680 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
8739 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
8681 PURPOSE ARE DISCLAIMED.
8740 PURPOSE ARE DISCLAIMED.
8682 IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
8741 IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
8683 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
8742 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
8684 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
8743 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
8685 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
8744 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
8686 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
8745 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
8687 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
8746 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
8688 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8747 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8689
8748
8690 \layout Standard
8749 \layout Standard
8691
8750
8692 Individual authors are the holders of the copyright for their code and are
8751 Individual authors are the holders of the copyright for their code and are
8693 listed in each file.
8752 listed in each file.
8694 \layout Standard
8753 \layout Standard
8695
8754
8696 Some files (
8755 Some files (
8697 \family typewriter
8756 \family typewriter
8698 DPyGetOpt.py
8757 DPyGetOpt.py
8699 \family default
8758 \family default
8700 , for example) may be licensed under different conditions.
8759 , for example) may be licensed under different conditions.
8701 Ultimately each file indicates clearly the conditions under which its author/au
8760 Ultimately each file indicates clearly the conditions under which its author/au
8702 thors have decided to publish the code.
8761 thors have decided to publish the code.
8703 \layout Standard
8762 \layout Standard
8704
8763
8705 Versions of IPython up to and including 0.6.3 were released under the GNU
8764 Versions of IPython up to and including 0.6.3 were released under the GNU
8706 Lesser General Public License (LGPL), available at
8765 Lesser General Public License (LGPL), available at
8707 \begin_inset LatexCommand \htmlurl{http://www.gnu.org/copyleft/lesser.html}
8766 \begin_inset LatexCommand \htmlurl{http://www.gnu.org/copyleft/lesser.html}
8708
8767
8709 \end_inset
8768 \end_inset
8710
8769
8711 .
8770 .
8712 \layout Section
8771 \layout Section
8713
8772
8714
8773
8715 \begin_inset LatexCommand \label{sec:credits}
8774 \begin_inset LatexCommand \label{sec:credits}
8716
8775
8717 \end_inset
8776 \end_inset
8718
8777
8719 Credits
8778 Credits
8720 \layout Standard
8779 \layout Standard
8721
8780
8722 IPython is mainly developed by Fernando Pérez
8781 IPython is mainly developed by Fernando P
8782 \begin_inset ERT
8783 status Collapsed
8784
8785 \layout Standard
8786
8787 \backslash
8788 '{e}
8789 \end_inset
8790
8791 rez
8723 \family typewriter
8792 \family typewriter
8724 <fperez@colorado.edu>
8793 <fperez@colorado.edu>
8725 \family default
8794 \family default
8726 , but the project was born from mixing in Fernando's code with the IPP project
8795 , but the project was born from mixing in Fernando's code with the IPP project
8727 by Janko Hauser
8796 by Janko Hauser
8728 \family typewriter
8797 \family typewriter
8729 <jhauser-AT-zscout.de>
8798 <jhauser-AT-zscout.de>
8730 \family default
8799 \family default
8731 and LazyPython by Nathan Gray
8800 and LazyPython by Nathan Gray
8732 \family typewriter
8801 \family typewriter
8733 <n8gray-AT-caltech.edu>
8802 <n8gray-AT-caltech.edu>
8734 \family default
8803 \family default
8735 .
8804 .
8736 For all IPython-related requests, please contact Fernando.
8805 For all IPython-related requests, please contact Fernando.
8737
8806
8738 \layout Standard
8807 \layout Standard
8739
8808
8740 As of late 2005, the following developers have joined the core team:
8809 As of late 2005, the following developers have joined the core team:
8741 \layout List
8810 \layout List
8742 \labelwidthstring 00.00.0000
8811 \labelwidthstring 00.00.0000
8743
8812
8744 Robert\SpecialChar ~
8813 Robert\SpecialChar ~
8745 Kern
8814 Kern
8746 \family typewriter
8815 \family typewriter
8747 <rkern-AT-enthought.com>
8816 <rkern-AT-enthought.com>
8748 \family default
8817 \family default
8749 : co-mentored the 2005 Google Summer of Code project to develop python interacti
8818 : co-mentored the 2005 Google Summer of Code project to develop python interacti
8750 ve notebooks (XML documents) and graphical interface.
8819 ve notebooks (XML documents) and graphical interface.
8751 This project was awarded to the students Tzanko Matev
8820 This project was awarded to the students Tzanko Matev
8752 \family typewriter
8821 \family typewriter
8753 <tsanko-AT-gmail.com>
8822 <tsanko-AT-gmail.com>
8754 \family default
8823 \family default
8755 and Toni Alatalo
8824 and Toni Alatalo
8756 \family typewriter
8825 \family typewriter
8757 <antont-AT-an.org>
8826 <antont-AT-an.org>
8758 \layout List
8827 \layout List
8759 \labelwidthstring 00.00.0000
8828 \labelwidthstring 00.00.0000
8760
8829
8761 Brian\SpecialChar ~
8830 Brian\SpecialChar ~
8762 Granger
8831 Granger
8763 \family typewriter
8832 \family typewriter
8764 <bgranger-AT-scu.edu>
8833 <bgranger-AT-scu.edu>
8765 \family default
8834 \family default
8766 : extending IPython to allow support for interactive parallel computing.
8835 : extending IPython to allow support for interactive parallel computing.
8767 \layout Standard
8836 \layout Standard
8768
8837
8769 User or development help should be requested via the IPython mailing lists:
8838 User or development help should be requested via the IPython mailing lists:
8770 \layout Description
8839 \layout Description
8771
8840
8772 User\SpecialChar ~
8841 User\SpecialChar ~
8773 list:
8842 list:
8774 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-user}
8843 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-user}
8775
8844
8776 \end_inset
8845 \end_inset
8777
8846
8778
8847
8779 \layout Description
8848 \layout Description
8780
8849
8781 Developer's\SpecialChar ~
8850 Developer's\SpecialChar ~
8782 list:
8851 list:
8783 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-dev}
8852 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-dev}
8784
8853
8785 \end_inset
8854 \end_inset
8786
8855
8787
8856
8788 \layout Standard
8857 \layout Standard
8789
8858
8790 The IPython project is also very grateful to
8859 The IPython project is also very grateful to
8791 \begin_inset Foot
8860 \begin_inset Foot
8792 collapsed true
8861 collapsed true
8793
8862
8794 \layout Standard
8863 \layout Standard
8795
8864
8796 I've mangled email addresses to reduce spam, since the IPython manuals can
8865 I've mangled email addresses to reduce spam, since the IPython manuals can
8797 be accessed online.
8866 be accessed online.
8798 \end_inset
8867 \end_inset
8799
8868
8800 :
8869 :
8801 \layout Standard
8870 \layout Standard
8802
8871
8803 Bill Bumgarner
8872 Bill Bumgarner
8804 \family typewriter
8873 \family typewriter
8805 <bbum-AT-friday.com>
8874 <bbum-AT-friday.com>
8806 \family default
8875 \family default
8807 : for providing the DPyGetOpt module which gives very powerful and convenient
8876 : for providing the DPyGetOpt module which gives very powerful and convenient
8808 handling of command-line options (light years ahead of what Python 2.1.1's
8877 handling of command-line options (light years ahead of what Python 2.1.1's
8809 getopt module does).
8878 getopt module does).
8810 \layout Standard
8879 \layout Standard
8811
8880
8812 Ka-Ping Yee
8881 Ka-Ping Yee
8813 \family typewriter
8882 \family typewriter
8814 <ping-AT-lfw.org>
8883 <ping-AT-lfw.org>
8815 \family default
8884 \family default
8816 : for providing the Itpl module for convenient and powerful string interpolation
8885 : for providing the Itpl module for convenient and powerful string interpolation
8817 with a much nicer syntax than formatting through the '%' operator.
8886 with a much nicer syntax than formatting through the '%' operator.
8818 \layout Standard
8887 \layout Standard
8819
8888
8820 Arnd Bäcker
8889 Arnd Baecker
8821 \family typewriter
8890 \family typewriter
8822 <baecker-AT-physik.tu-dresden.de>
8891 <baecker-AT-physik.tu-dresden.de>
8823 \family default
8892 \family default
8824 : for his many very useful suggestions and comments, and lots of help with
8893 : for his many very useful suggestions and comments, and lots of help with
8825 testing and documentation checking.
8894 testing and documentation checking.
8826 Many of IPython's newer features are a result of discussions with him (bugs
8895 Many of IPython's newer features are a result of discussions with him (bugs
8827 are still my fault, not his).
8896 are still my fault, not his).
8828 \layout Standard
8897 \layout Standard
8829
8898
8830 Obviously Guido van\SpecialChar ~
8899 Obviously Guido van\SpecialChar ~
8831 Rossum and the whole Python development team, that goes
8900 Rossum and the whole Python development team, that goes
8832 without saying.
8901 without saying.
8833 \layout Standard
8902 \layout Standard
8834
8903
8835 IPython's website is generously hosted at
8904 IPython's website is generously hosted at
8836 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
8905 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
8837
8906
8838 \end_inset
8907 \end_inset
8839
8908
8840 by Enthought (
8909 by Enthought (
8841 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
8910 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
8842
8911
8843 \end_inset
8912 \end_inset
8844
8913
8845 ).
8914 ).
8846 I am very grateful to them and all of the SciPy team for their contribution.
8915 I am very grateful to them and all of the SciPy team for their contribution.
8847 \layout Standard
8916 \layout Standard
8848
8917
8849
8918
8850 \begin_inset LatexCommand \label{figgins}
8919 \begin_inset LatexCommand \label{figgins}
8851
8920
8852 \end_inset
8921 \end_inset
8853
8922
8854 Fernando would also like to thank Stephen Figgins
8923 Fernando would also like to thank Stephen Figgins
8855 \family typewriter
8924 \family typewriter
8856 <fig-AT-monitor.net>
8925 <fig-AT-monitor.net>
8857 \family default
8926 \family default
8858 , an O'Reilly Python editor.
8927 , an O'Reilly Python editor.
8859 His Oct/11/2001 article about IPP and LazyPython, was what got this project
8928 His Oct/11/2001 article about IPP and LazyPython, was what got this project
8860 started.
8929 started.
8861 You can read it at:
8930 You can read it at:
8862 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2001/10/11/pythonnews.html}
8931 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2001/10/11/pythonnews.html}
8863
8932
8864 \end_inset
8933 \end_inset
8865
8934
8866 .
8935 .
8867 \layout Standard
8936 \layout Standard
8868
8937
8869 And last but not least, all the kind IPython users who have emailed new
8938 And last but not least, all the kind IPython users who have emailed new
8870 code, bug reports, fixes, comments and ideas.
8939 code, bug reports, fixes, comments and ideas.
8871 A brief list follows, please let me know if I have ommitted your name by
8940 A brief list follows, please let me know if I have ommitted your name by
8872 accident:
8941 accident:
8873 \layout List
8942 \layout List
8874 \labelwidthstring 00.00.0000
8943 \labelwidthstring 00.00.0000
8875
8944
8876 Jack\SpecialChar ~
8945 Jack\SpecialChar ~
8877 Moffit
8946 Moffit
8878 \family typewriter
8947 \family typewriter
8879 <jack-AT-xiph.org>
8948 <jack-AT-xiph.org>
8880 \family default
8949 \family default
8881 Bug fixes, including the infamous color problem.
8950 Bug fixes, including the infamous color problem.
8882 This bug alone caused many lost hours and frustration, many thanks to him
8951 This bug alone caused many lost hours and frustration, many thanks to him
8883 for the fix.
8952 for the fix.
8884 I've always been a fan of Ogg & friends, now I have one more reason to
8953 I've always been a fan of Ogg & friends, now I have one more reason to
8885 like these folks.
8954 like these folks.
8886 \newline
8955 \newline
8887 Jack is also contributing with Debian packaging and many other things.
8956 Jack is also contributing with Debian packaging and many other things.
8888 \layout List
8957 \layout List
8889 \labelwidthstring 00.00.0000
8958 \labelwidthstring 00.00.0000
8890
8959
8891 Alexander\SpecialChar ~
8960 Alexander\SpecialChar ~
8892 Schmolck
8961 Schmolck
8893 \family typewriter
8962 \family typewriter
8894 <a.schmolck-AT-gmx.net>
8963 <a.schmolck-AT-gmx.net>
8895 \family default
8964 \family default
8896 Emacs work, bug reports, bug fixes, ideas, lots more.
8965 Emacs work, bug reports, bug fixes, ideas, lots more.
8897 The ipython.el mode for (X)Emacs is Alex's code, providing full support
8966 The ipython.el mode for (X)Emacs is Alex's code, providing full support
8898 for IPython under (X)Emacs.
8967 for IPython under (X)Emacs.
8899 \layout List
8968 \layout List
8900 \labelwidthstring 00.00.0000
8969 \labelwidthstring 00.00.0000
8901
8970
8902 Andrea\SpecialChar ~
8971 Andrea\SpecialChar ~
8903 Riciputi
8972 Riciputi
8904 \family typewriter
8973 \family typewriter
8905 <andrea.riciputi-AT-libero.it>
8974 <andrea.riciputi-AT-libero.it>
8906 \family default
8975 \family default
8907 Mac OSX information, Fink package management.
8976 Mac OSX information, Fink package management.
8908 \layout List
8977 \layout List
8909 \labelwidthstring 00.00.0000
8978 \labelwidthstring 00.00.0000
8910
8979
8911 Gary\SpecialChar ~
8980 Gary\SpecialChar ~
8912 Bishop
8981 Bishop
8913 \family typewriter
8982 \family typewriter
8914 <gb-AT-cs.unc.edu>
8983 <gb-AT-cs.unc.edu>
8915 \family default
8984 \family default
8916 Bug reports, and patches to work around the exception handling idiosyncracies
8985 Bug reports, and patches to work around the exception handling idiosyncracies
8917 of WxPython.
8986 of WxPython.
8918 Readline and color support for Windows.
8987 Readline and color support for Windows.
8919 \layout List
8988 \layout List
8920 \labelwidthstring 00.00.0000
8989 \labelwidthstring 00.00.0000
8921
8990
8922 Jeffrey\SpecialChar ~
8991 Jeffrey\SpecialChar ~
8923 Collins
8992 Collins
8924 \family typewriter
8993 \family typewriter
8925 <Jeff.Collins-AT-vexcel.com>
8994 <Jeff.Collins-AT-vexcel.com>
8926 \family default
8995 \family default
8927 Bug reports.
8996 Bug reports.
8928 Much improved readline support, including fixes for Python 2.3.
8997 Much improved readline support, including fixes for Python 2.3.
8929 \layout List
8998 \layout List
8930 \labelwidthstring 00.00.0000
8999 \labelwidthstring 00.00.0000
8931
9000
8932 Dryice\SpecialChar ~
9001 Dryice\SpecialChar ~
8933 Liu
9002 Liu
8934 \family typewriter
9003 \family typewriter
8935 <dryice-AT-liu.com.cn>
9004 <dryice-AT-liu.com.cn>
8936 \family default
9005 \family default
8937 FreeBSD port.
9006 FreeBSD port.
8938 \layout List
9007 \layout List
8939 \labelwidthstring 00.00.0000
9008 \labelwidthstring 00.00.0000
8940
9009
8941 Mike\SpecialChar ~
9010 Mike\SpecialChar ~
8942 Heeter
9011 Heeter
8943 \family typewriter
9012 \family typewriter
8944 <korora-AT-SDF.LONESTAR.ORG>
9013 <korora-AT-SDF.LONESTAR.ORG>
8945 \layout List
9014 \layout List
8946 \labelwidthstring 00.00.0000
9015 \labelwidthstring 00.00.0000
8947
9016
8948 Christopher\SpecialChar ~
9017 Christopher\SpecialChar ~
8949 Hart
9018 Hart
8950 \family typewriter
9019 \family typewriter
8951 <hart-AT-caltech.edu>
9020 <hart-AT-caltech.edu>
8952 \family default
9021 \family default
8953 PDB integration.
9022 PDB integration.
8954 \layout List
9023 \layout List
8955 \labelwidthstring 00.00.0000
9024 \labelwidthstring 00.00.0000
8956
9025
8957 Milan\SpecialChar ~
9026 Milan\SpecialChar ~
8958 Zamazal
9027 Zamazal
8959 \family typewriter
9028 \family typewriter
8960 <pdm-AT-zamazal.org>
9029 <pdm-AT-zamazal.org>
8961 \family default
9030 \family default
8962 Emacs info.
9031 Emacs info.
8963 \layout List
9032 \layout List
8964 \labelwidthstring 00.00.0000
9033 \labelwidthstring 00.00.0000
8965
9034
8966 Philip\SpecialChar ~
9035 Philip\SpecialChar ~
8967 Hisley
9036 Hisley
8968 \family typewriter
9037 \family typewriter
8969 <compsys-AT-starpower.net>
9038 <compsys-AT-starpower.net>
8970 \layout List
9039 \layout List
8971 \labelwidthstring 00.00.0000
9040 \labelwidthstring 00.00.0000
8972
9041
8973 Holger\SpecialChar ~
9042 Holger\SpecialChar ~
8974 Krekel
9043 Krekel
8975 \family typewriter
9044 \family typewriter
8976 <pyth-AT-devel.trillke.net>
9045 <pyth-AT-devel.trillke.net>
8977 \family default
9046 \family default
8978 Tab completion, lots more.
9047 Tab completion, lots more.
8979 \layout List
9048 \layout List
8980 \labelwidthstring 00.00.0000
9049 \labelwidthstring 00.00.0000
8981
9050
8982 Robin\SpecialChar ~
9051 Robin\SpecialChar ~
8983 Siebler
9052 Siebler
8984 \family typewriter
9053 \family typewriter
8985 <robinsiebler-AT-starband.net>
9054 <robinsiebler-AT-starband.net>
8986 \layout List
9055 \layout List
8987 \labelwidthstring 00.00.0000
9056 \labelwidthstring 00.00.0000
8988
9057
8989 Ralf\SpecialChar ~
9058 Ralf\SpecialChar ~
8990 Ahlbrink
9059 Ahlbrink
8991 \family typewriter
9060 \family typewriter
8992 <ralf_ahlbrink-AT-web.de>
9061 <ralf_ahlbrink-AT-web.de>
8993 \layout List
9062 \layout List
8994 \labelwidthstring 00.00.0000
9063 \labelwidthstring 00.00.0000
8995
9064
8996 Thorsten\SpecialChar ~
9065 Thorsten\SpecialChar ~
8997 Kampe
9066 Kampe
8998 \family typewriter
9067 \family typewriter
8999 <thorsten-AT-thorstenkampe.de>
9068 <thorsten-AT-thorstenkampe.de>
9000 \layout List
9069 \layout List
9001 \labelwidthstring 00.00.0000
9070 \labelwidthstring 00.00.0000
9002
9071
9003 Fredrik\SpecialChar ~
9072 Fredrik\SpecialChar ~
9004 Kant
9073 Kant
9005 \family typewriter
9074 \family typewriter
9006 <fredrik.kant-AT-front.com>
9075 <fredrik.kant-AT-front.com>
9007 \family default
9076 \family default
9008 Windows setup.
9077 Windows setup.
9009 \layout List
9078 \layout List
9010 \labelwidthstring 00.00.0000
9079 \labelwidthstring 00.00.0000
9011
9080
9012 Syver\SpecialChar ~
9081 Syver\SpecialChar ~
9013 Enstad
9082 Enstad
9014 \family typewriter
9083 \family typewriter
9015 <syver-en-AT-online.no>
9084 <syver-en-AT-online.no>
9016 \family default
9085 \family default
9017 Windows setup.
9086 Windows setup.
9018 \layout List
9087 \layout List
9019 \labelwidthstring 00.00.0000
9088 \labelwidthstring 00.00.0000
9020
9089
9021 Richard
9090 Richard
9022 \family typewriter
9091 \family typewriter
9023 <rxe-AT-renre-europe.com>
9092 <rxe-AT-renre-europe.com>
9024 \family default
9093 \family default
9025 Global embedding.
9094 Global embedding.
9026 \layout List
9095 \layout List
9027 \labelwidthstring 00.00.0000
9096 \labelwidthstring 00.00.0000
9028
9097
9029 Hayden\SpecialChar ~
9098 Hayden\SpecialChar ~
9030 Callow
9099 Callow
9031 \family typewriter
9100 \family typewriter
9032 <h.callow-AT-elec.canterbury.ac.nz>
9101 <h.callow-AT-elec.canterbury.ac.nz>
9033 \family default
9102 \family default
9034 Gnuplot.py 1.6 compatibility.
9103 Gnuplot.py 1.6 compatibility.
9035 \layout List
9104 \layout List
9036 \labelwidthstring 00.00.0000
9105 \labelwidthstring 00.00.0000
9037
9106
9038 Leonardo\SpecialChar ~
9107 Leonardo\SpecialChar ~
9039 Santagada
9108 Santagada
9040 \family typewriter
9109 \family typewriter
9041 <retype-AT-terra.com.br>
9110 <retype-AT-terra.com.br>
9042 \family default
9111 \family default
9043 Fixes for Windows installation.
9112 Fixes for Windows installation.
9044 \layout List
9113 \layout List
9045 \labelwidthstring 00.00.0000
9114 \labelwidthstring 00.00.0000
9046
9115
9047 Christopher\SpecialChar ~
9116 Christopher\SpecialChar ~
9048 Armstrong
9117 Armstrong
9049 \family typewriter
9118 \family typewriter
9050 <radix-AT-twistedmatrix.com>
9119 <radix-AT-twistedmatrix.com>
9051 \family default
9120 \family default
9052 Bugfixes.
9121 Bugfixes.
9053 \layout List
9122 \layout List
9054 \labelwidthstring 00.00.0000
9123 \labelwidthstring 00.00.0000
9055
9124
9056 Francois\SpecialChar ~
9125 Francois\SpecialChar ~
9057 Pinard
9126 Pinard
9058 \family typewriter
9127 \family typewriter
9059 <pinard-AT-iro.umontreal.ca>
9128 <pinard-AT-iro.umontreal.ca>
9060 \family default
9129 \family default
9061 Code and documentation fixes.
9130 Code and documentation fixes.
9062 \layout List
9131 \layout List
9063 \labelwidthstring 00.00.0000
9132 \labelwidthstring 00.00.0000
9064
9133
9065 Cory\SpecialChar ~
9134 Cory\SpecialChar ~
9066 Dodt
9135 Dodt
9067 \family typewriter
9136 \family typewriter
9068 <cdodt-AT-fcoe.k12.ca.us>
9137 <cdodt-AT-fcoe.k12.ca.us>
9069 \family default
9138 \family default
9070 Bug reports and Windows ideas.
9139 Bug reports and Windows ideas.
9071 Patches for Windows installer.
9140 Patches for Windows installer.
9072 \layout List
9141 \layout List
9073 \labelwidthstring 00.00.0000
9142 \labelwidthstring 00.00.0000
9074
9143
9075 Olivier\SpecialChar ~
9144 Olivier\SpecialChar ~
9076 Aubert
9145 Aubert
9077 \family typewriter
9146 \family typewriter
9078 <oaubert-AT-bat710.univ-lyon1.fr>
9147 <oaubert-AT-bat710.univ-lyon1.fr>
9079 \family default
9148 \family default
9080 New magics.
9149 New magics.
9081 \layout List
9150 \layout List
9082 \labelwidthstring 00.00.0000
9151 \labelwidthstring 00.00.0000
9083
9152
9084 King\SpecialChar ~
9153 King\SpecialChar ~
9085 C.\SpecialChar ~
9154 C.\SpecialChar ~
9086 Shu
9155 Shu
9087 \family typewriter
9156 \family typewriter
9088 <kingshu-AT-myrealbox.com>
9157 <kingshu-AT-myrealbox.com>
9089 \family default
9158 \family default
9090 Autoindent patch.
9159 Autoindent patch.
9091 \layout List
9160 \layout List
9092 \labelwidthstring 00.00.0000
9161 \labelwidthstring 00.00.0000
9093
9162
9094 Chris\SpecialChar ~
9163 Chris\SpecialChar ~
9095 Drexler
9164 Drexler
9096 \family typewriter
9165 \family typewriter
9097 <chris-AT-ac-drexler.de>
9166 <chris-AT-ac-drexler.de>
9098 \family default
9167 \family default
9099 Readline packages for Win32/CygWin.
9168 Readline packages for Win32/CygWin.
9100 \layout List
9169 \layout List
9101 \labelwidthstring 00.00.0000
9170 \labelwidthstring 00.00.0000
9102
9171
9103 Gustavo\SpecialChar ~
9172 Gustavo\SpecialChar ~
9104 Córdova\SpecialChar ~
9173 Cordova\SpecialChar ~
9105 Avila
9174 Avila
9106 \family typewriter
9175 \family typewriter
9107 <gcordova-AT-sismex.com>
9176 <gcordova-AT-sismex.com>
9108 \family default
9177 \family default
9109 EvalDict code for nice, lightweight string interpolation.
9178 EvalDict code for nice, lightweight string interpolation.
9110 \layout List
9179 \layout List
9111 \labelwidthstring 00.00.0000
9180 \labelwidthstring 00.00.0000
9112
9181
9113 Kasper\SpecialChar ~
9182 Kasper\SpecialChar ~
9114 Souren
9183 Souren
9115 \family typewriter
9184 \family typewriter
9116 <Kasper.Souren-AT-ircam.fr>
9185 <Kasper.Souren-AT-ircam.fr>
9117 \family default
9186 \family default
9118 Bug reports, ideas.
9187 Bug reports, ideas.
9119 \layout List
9188 \layout List
9120 \labelwidthstring 00.00.0000
9189 \labelwidthstring 00.00.0000
9121
9190
9122 Gever\SpecialChar ~
9191 Gever\SpecialChar ~
9123 Tulley
9192 Tulley
9124 \family typewriter
9193 \family typewriter
9125 <gever-AT-helium.com>
9194 <gever-AT-helium.com>
9126 \family default
9195 \family default
9127 Code contributions.
9196 Code contributions.
9128 \layout List
9197 \layout List
9129 \labelwidthstring 00.00.0000
9198 \labelwidthstring 00.00.0000
9130
9199
9131 Ralf\SpecialChar ~
9200 Ralf\SpecialChar ~
9132 Schmitt
9201 Schmitt
9133 \family typewriter
9202 \family typewriter
9134 <ralf-AT-brainbot.com>
9203 <ralf-AT-brainbot.com>
9135 \family default
9204 \family default
9136 Bug reports & fixes.
9205 Bug reports & fixes.
9137 \layout List
9206 \layout List
9138 \labelwidthstring 00.00.0000
9207 \labelwidthstring 00.00.0000
9139
9208
9140 Oliver\SpecialChar ~
9209 Oliver\SpecialChar ~
9141 Sander
9210 Sander
9142 \family typewriter
9211 \family typewriter
9143 <osander-AT-gmx.de>
9212 <osander-AT-gmx.de>
9144 \family default
9213 \family default
9145 Bug reports.
9214 Bug reports.
9146 \layout List
9215 \layout List
9147 \labelwidthstring 00.00.0000
9216 \labelwidthstring 00.00.0000
9148
9217
9149 Rod\SpecialChar ~
9218 Rod\SpecialChar ~
9150 Holland
9219 Holland
9151 \family typewriter
9220 \family typewriter
9152 <rhh-AT-structurelabs.com>
9221 <rhh-AT-structurelabs.com>
9153 \family default
9222 \family default
9154 Bug reports and fixes to logging module.
9223 Bug reports and fixes to logging module.
9155 \layout List
9224 \layout List
9156 \labelwidthstring 00.00.0000
9225 \labelwidthstring 00.00.0000
9157
9226
9158 Daniel\SpecialChar ~
9227 Daniel\SpecialChar ~
9159 'Dang'\SpecialChar ~
9228 'Dang'\SpecialChar ~
9160 Griffith
9229 Griffith
9161 \family typewriter
9230 \family typewriter
9162 <pythondev-dang-AT-lazytwinacres.net>
9231 <pythondev-dang-AT-lazytwinacres.net>
9163 \family default
9232 \family default
9164 Fixes, enhancement suggestions for system shell use.
9233 Fixes, enhancement suggestions for system shell use.
9165 \layout List
9234 \layout List
9166 \labelwidthstring 00.00.0000
9235 \labelwidthstring 00.00.0000
9167
9236
9168 Viktor\SpecialChar ~
9237 Viktor\SpecialChar ~
9169 Ransmayr
9238 Ransmayr
9170 \family typewriter
9239 \family typewriter
9171 <viktor.ransmayr-AT-t-online.de>
9240 <viktor.ransmayr-AT-t-online.de>
9172 \family default
9241 \family default
9173 Tests and reports on Windows installation issues.
9242 Tests and reports on Windows installation issues.
9174 Contributed a true Windows binary installer.
9243 Contributed a true Windows binary installer.
9175 \layout List
9244 \layout List
9176 \labelwidthstring 00.00.0000
9245 \labelwidthstring 00.00.0000
9177
9246
9178 Mike\SpecialChar ~
9247 Mike\SpecialChar ~
9179 Salib
9248 Salib
9180 \family typewriter
9249 \family typewriter
9181 <msalib-AT-mit.edu>
9250 <msalib-AT-mit.edu>
9182 \family default
9251 \family default
9183 Help fixing a subtle bug related to traceback printing.
9252 Help fixing a subtle bug related to traceback printing.
9184 \layout List
9253 \layout List
9185 \labelwidthstring 00.00.0000
9254 \labelwidthstring 00.00.0000
9186
9255
9187 W.J.\SpecialChar ~
9256 W.J.\SpecialChar ~
9188 van\SpecialChar ~
9257 van\SpecialChar ~
9189 der\SpecialChar ~
9258 der\SpecialChar ~
9190 Laan
9259 Laan
9191 \family typewriter
9260 \family typewriter
9192 <gnufnork-AT-hetdigitalegat.nl>
9261 <gnufnork-AT-hetdigitalegat.nl>
9193 \family default
9262 \family default
9194 Bash-like prompt specials.
9263 Bash-like prompt specials.
9195 \layout List
9264 \layout List
9196 \labelwidthstring 00.00.0000
9265 \labelwidthstring 00.00.0000
9197
9266
9198 Ville\SpecialChar ~
9267 Ville\SpecialChar ~
9199 Vainio
9268 Vainio
9200 \family typewriter
9269 \family typewriter
9201 <vivainio-AT-kolumbus.fi>
9270 <vivainio-AT-kolumbus.fi>
9202 \family default
9271 \family default
9203 Bugfixes and suggestions.
9272 Bugfixes and suggestions.
9204 Excellent patches for many new features.
9273 Excellent patches for many new features.
9205 \layout List
9274 \layout List
9206 \labelwidthstring 00.00.0000
9275 \labelwidthstring 00.00.0000
9207
9276
9208 Antoon\SpecialChar ~
9277 Antoon\SpecialChar ~
9209 Pardon
9278 Pardon
9210 \family typewriter
9279 \family typewriter
9211 <Antoon.Pardon-AT-rece.vub.ac.be>
9280 <Antoon.Pardon-AT-rece.vub.ac.be>
9212 \family default
9281 \family default
9213 Critical fix for the multithreaded IPython.
9282 Critical fix for the multithreaded IPython.
9214 \layout List
9283 \layout List
9215 \labelwidthstring 00.00.0000
9284 \labelwidthstring 00.00.0000
9216
9285
9217 John\SpecialChar ~
9286 John\SpecialChar ~
9218 Hunter
9287 Hunter
9219 \family typewriter
9288 \family typewriter
9220 <jdhunter-AT-nitace.bsd.uchicago.edu>
9289 <jdhunter-AT-nitace.bsd.uchicago.edu>
9221 \family default
9290 \family default
9222 Matplotlib author, helped with all the development of support for matplotlib
9291 Matplotlib author, helped with all the development of support for matplotlib
9223 in IPyhton, including making necessary changes to matplotlib itself.
9292 in IPyhton, including making necessary changes to matplotlib itself.
9224 \layout List
9293 \layout List
9225 \labelwidthstring 00.00.0000
9294 \labelwidthstring 00.00.0000
9226
9295
9227 Matthew\SpecialChar ~
9296 Matthew\SpecialChar ~
9228 Arnison
9297 Arnison
9229 \family typewriter
9298 \family typewriter
9230 <maffew-AT-cat.org.au>
9299 <maffew-AT-cat.org.au>
9231 \family default
9300 \family default
9232 Bug reports, `
9301 Bug reports, `
9233 \family typewriter
9302 \family typewriter
9234 %run -d
9303 %run -d
9235 \family default
9304 \family default
9236 ' idea.
9305 ' idea.
9237 \layout List
9306 \layout List
9238 \labelwidthstring 00.00.0000
9307 \labelwidthstring 00.00.0000
9239
9308
9240 Prabhu\SpecialChar ~
9309 Prabhu\SpecialChar ~
9241 Ramachandran
9310 Ramachandran
9242 \family typewriter
9311 \family typewriter
9243 <prabhu_r-AT-users.sourceforge.net>
9312 <prabhu_r-AT-users.sourceforge.net>
9244 \family default
9313 \family default
9245 Help with (X)Emacs support, threading patches, ideas...
9314 Help with (X)Emacs support, threading patches, ideas...
9246 \layout List
9315 \layout List
9247 \labelwidthstring 00.00.0000
9316 \labelwidthstring 00.00.0000
9248
9317
9249 Norbert\SpecialChar ~
9318 Norbert\SpecialChar ~
9250 Tretkowski
9319 Tretkowski
9251 \family typewriter
9320 \family typewriter
9252 <tretkowski-AT-inittab.de>
9321 <tretkowski-AT-inittab.de>
9253 \family default
9322 \family default
9254 help with Debian packaging and distribution.
9323 help with Debian packaging and distribution.
9255 \layout List
9324 \layout List
9256 \labelwidthstring 00.00.0000
9325 \labelwidthstring 00.00.0000
9257
9326
9258 George\SpecialChar ~
9327 George\SpecialChar ~
9259 Sakkis <
9328 Sakkis <
9260 \family typewriter
9329 \family typewriter
9261 gsakkis-AT-eden.rutgers.edu>
9330 gsakkis-AT-eden.rutgers.edu>
9262 \family default
9331 \family default
9263 New matcher for tab-completing named arguments of user-defined functions.
9332 New matcher for tab-completing named arguments of user-defined functions.
9264 \layout List
9333 \layout List
9265 \labelwidthstring 00.00.0000
9334 \labelwidthstring 00.00.0000
9266
9335
9267 J�rgen\SpecialChar ~
9336 J�rgen\SpecialChar ~
9268 Stenarson
9337 Stenarson
9269 \family typewriter
9338 \family typewriter
9270 <jorgen.stenarson-AT-bostream.nu>
9339 <jorgen.stenarson-AT-bostream.nu>
9271 \family default
9340 \family default
9272 Wildcard support implementation for searching namespaces.
9341 Wildcard support implementation for searching namespaces.
9273 \layout List
9342 \layout List
9274 \labelwidthstring 00.00.0000
9343 \labelwidthstring 00.00.0000
9275
9344
9276 Vivian\SpecialChar ~
9345 Vivian\SpecialChar ~
9277 De\SpecialChar ~
9346 De\SpecialChar ~
9278 Smedt
9347 Smedt
9279 \family typewriter
9348 \family typewriter
9280 <vivian-AT-vdesmedt.com>
9349 <vivian-AT-vdesmedt.com>
9281 \family default
9350 \family default
9282 Debugger enhancements, so that when pdb is activated from within IPython,
9351 Debugger enhancements, so that when pdb is activated from within IPython,
9283 coloring, tab completion and other features continue to work seamlessly.
9352 coloring, tab completion and other features continue to work seamlessly.
9284 \layout List
9353 \layout List
9285 \labelwidthstring 00.00.0000
9354 \labelwidthstring 00.00.0000
9286
9355
9287 Scott\SpecialChar ~
9356 Scott\SpecialChar ~
9288 Tsai
9357 Tsai
9289 \family typewriter
9358 \family typewriter
9290 <scottt958-AT-yahoo.com.tw>
9359 <scottt958-AT-yahoo.com.tw>
9291 \family default
9360 \family default
9292 Support for automatic editor invocation on syntax errors (see
9361 Support for automatic editor invocation on syntax errors (see
9293 \begin_inset LatexCommand \htmlurl{http://www.scipy.net/roundup/ipython/issue36}
9362 \begin_inset LatexCommand \htmlurl{http://www.scipy.net/roundup/ipython/issue36}
9294
9363
9295 \end_inset
9364 \end_inset
9296
9365
9297 ).
9366 ).
9298 \layout List
9367 \layout List
9299 \labelwidthstring 00.00.0000
9368 \labelwidthstring 00.00.0000
9300
9369
9301 Alexander\SpecialChar ~
9370 Alexander\SpecialChar ~
9302 Belchenko
9371 Belchenko
9303 \family typewriter
9372 \family typewriter
9304 <bialix-AT-ukr.net>
9373 <bialix-AT-ukr.net>
9305 \family default
9374 \family default
9306 Improvements for win32 paging system.
9375 Improvements for win32 paging system.
9307 \the_end
9376 \the_end
@@ -1,11 +1,19 b''
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 """Simple wrapper to build IPython as an egg (setuptools format)."""
2 """Wrapper to build IPython as an egg (setuptools format)."""
3
3
4 import os
4 import sys
5 import sys
5
6
6 import pkg_resources
7 # Add my local path to sys.path
7 pkg_resources.require("setuptools")
8 home = os.environ['HOME']
9 sys.path.insert(0,'%s/usr/local/lib/python%s/site-packages' %
10 (home,sys.version[:3]))
11
12 # now, import setuptools and build the actual egg
8 import setuptools
13 import setuptools
9
14
10 sys.argv=['','bdist_egg']
15 sys.argv=['','bdist_egg']
11 execfile('setup.py')
16 execfile('setup.py')
17
18 # clean up the junk left around by setuptools
19 os.system('rm -rf ipython.egg-info')
General Comments 0
You need to be logged in to leave comments. Login now