##// END OF EJS Templates
Turn quit/exit into magics instead of special-cased strings
fperez -
Show More
@@ -1,2579 +1,2592 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 960 2005-12-28 06:51:01Z fperez $"""
4 $Id: Magic.py 962 2005-12-28 18:04:59Z fperez $"""
5
5
6 #*****************************************************************************
6 #*****************************************************************************
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
8 # Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu>
8 # Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu>
9 #
9 #
10 # Distributed under the terms of the BSD License. The full license is in
10 # Distributed under the terms of the BSD License. The full license is in
11 # the file COPYING, distributed as part of this software.
11 # the file COPYING, distributed as part of this software.
12 #*****************************************************************************
12 #*****************************************************************************
13
13
14 #****************************************************************************
14 #****************************************************************************
15 # Modules and globals
15 # Modules and globals
16
16
17 from IPython import Release
17 from IPython import Release
18 __author__ = '%s <%s>\n%s <%s>' % \
18 __author__ = '%s <%s>\n%s <%s>' % \
19 ( Release.authors['Janko'] + Release.authors['Fernando'] )
19 ( Release.authors['Janko'] + Release.authors['Fernando'] )
20 __license__ = Release.license
20 __license__ = Release.license
21
21
22 # Python standard modules
22 # Python standard modules
23 import __builtin__
23 import __builtin__
24 import 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 from cStringIO import StringIO
33 from cStringIO import StringIO
34 from getopt import getopt
34 from getopt import getopt
35 from pprint import pprint, pformat
35 from pprint import pprint, pformat
36
36
37 # profile isn't bundled by default in Debian for license reasons
37 # profile isn't bundled by default in Debian for license reasons
38 try:
38 try:
39 import profile,pstats
39 import profile,pstats
40 except ImportError:
40 except ImportError:
41 profile = pstats = None
41 profile = pstats = None
42
42
43 # Homebrewed
43 # Homebrewed
44 from IPython import Debugger, OInspect, wildcard
44 from IPython import Debugger, OInspect, wildcard
45 from IPython.FakeModule import FakeModule
45 from IPython.FakeModule import FakeModule
46 from IPython.Itpl import Itpl, itpl, printpl,itplns
46 from IPython.Itpl import Itpl, itpl, printpl,itplns
47 from IPython.PyColorize import Parser
47 from IPython.PyColorize import Parser
48 from IPython.Struct import Struct
48 from IPython.Struct import Struct
49 from IPython.genutils import *
49 from IPython.genutils import *
50
50
51 # Globals to be set later by Magic constructor
51 # Globals to be set later by Magic constructor
52 MAGIC_PREFIX = ''
52 MAGIC_PREFIX = ''
53 MAGIC_ESCAPE = ''
53 MAGIC_ESCAPE = ''
54
54
55 #***************************************************************************
55 #***************************************************************************
56 # Utility functions
56 # Utility functions
57 def magic2python(cmd):
57 def magic2python(cmd):
58 """Convert a command string of magic syntax to valid Python code."""
58 """Convert a command string of magic syntax to valid Python code."""
59
59
60 if cmd.startswith('#'+MAGIC_ESCAPE) or \
60 if cmd.startswith('#'+MAGIC_ESCAPE) or \
61 cmd.startswith(MAGIC_ESCAPE):
61 cmd.startswith(MAGIC_ESCAPE):
62 if cmd[0]=='#':
62 if cmd[0]=='#':
63 cmd = cmd[1:]
63 cmd = cmd[1:]
64 # we need to return the proper line end later
64 # we need to return the proper line end later
65 if cmd[-1] == '\n':
65 if cmd[-1] == '\n':
66 endl = '\n'
66 endl = '\n'
67 else:
67 else:
68 endl = ''
68 endl = ''
69 try:
69 try:
70 func,args = cmd[1:].split(' ',1)
70 func,args = cmd[1:].split(' ',1)
71 except:
71 except:
72 func,args = cmd[1:].rstrip(),''
72 func,args = cmd[1:].rstrip(),''
73 args = args.replace('"','\\"').replace("'","\\'").rstrip()
73 args = args.replace('"','\\"').replace("'","\\'").rstrip()
74 return '%s%s ("%s")%s' % (MAGIC_PREFIX,func,args,endl)
74 return '%s%s ("%s")%s' % (MAGIC_PREFIX,func,args,endl)
75 else:
75 else:
76 return cmd
76 return cmd
77
77
78 def on_off(tag):
78 def on_off(tag):
79 """Return an ON/OFF string for a 1/0 input. Simple utility function."""
79 """Return an ON/OFF string for a 1/0 input. Simple utility function."""
80 return ['OFF','ON'][tag]
80 return ['OFF','ON'][tag]
81
81
82
82
83 #****************************************************************************
83 #****************************************************************************
84 # Utility classes
84 # Utility classes
85 class Macro:
85 class Macro:
86 """Simple class to store the value of macros as strings.
86 """Simple class to store the value of macros as strings.
87
87
88 This allows us to later exec them by checking when something is an
88 This allows us to later exec them by checking when something is an
89 instance of this class."""
89 instance of this class."""
90
90
91 def __init__(self,cmds):
91 def __init__(self,cmds):
92 """Build a macro from a list of commands."""
92 """Build a macro from a list of commands."""
93
93
94 # Since the list may include multi-line entries, first make sure that
94 # Since the list may include multi-line entries, first make sure that
95 # they've been all broken up before passing it to magic2python
95 # they've been all broken up before passing it to magic2python
96 cmdlist = map(magic2python,''.join(cmds).split('\n'))
96 cmdlist = map(magic2python,''.join(cmds).split('\n'))
97 self.value = '\n'.join(cmdlist)
97 self.value = '\n'.join(cmdlist)
98
98
99 def __str__(self):
99 def __str__(self):
100 return self.value
100 return self.value
101
101
102 #***************************************************************************
102 #***************************************************************************
103 # Main class implementing Magic functionality
103 # Main class implementing Magic functionality
104 class Magic:
104 class Magic:
105 """Magic functions for InteractiveShell.
105 """Magic functions for InteractiveShell.
106
106
107 Shell functions which can be reached as %function_name. All magic
107 Shell functions which can be reached as %function_name. All magic
108 functions should accept a string, which they can parse for their own
108 functions should accept a string, which they can parse for their own
109 needs. This can make some functions easier to type, eg `%cd ../`
109 needs. This can make some functions easier to type, eg `%cd ../`
110 vs. `%cd("../")`
110 vs. `%cd("../")`
111
111
112 ALL definitions MUST begin with the prefix magic_. The user won't need it
112 ALL definitions MUST begin with the prefix magic_. The user won't need it
113 at the command line, but it is is needed in the definition. """
113 at the command line, but it is is needed in the definition. """
114
114
115 # class globals
115 # class globals
116 auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.',
116 auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.',
117 'Automagic is ON, % prefix NOT needed for magic functions.']
117 'Automagic is ON, % prefix NOT needed for magic functions.']
118
118
119 #......................................................................
119 #......................................................................
120 # some utility functions
120 # some utility functions
121
121
122 def __init__(self,shell):
122 def __init__(self,shell):
123 # XXX This is hackish, clean up later to avoid these messy globals
123 # XXX This is hackish, clean up later to avoid these messy globals
124 global MAGIC_PREFIX, MAGIC_ESCAPE
124 global MAGIC_PREFIX, MAGIC_ESCAPE
125
125
126 self.options_table = {}
126 self.options_table = {}
127 MAGIC_PREFIX = shell.name+'.magic_'
127 MAGIC_PREFIX = shell.name+'.magic_'
128 MAGIC_ESCAPE = shell.ESC_MAGIC
128 MAGIC_ESCAPE = shell.ESC_MAGIC
129 if profile is None:
129 if profile is None:
130 self.magic_prun = self.profile_missing_notice
130 self.magic_prun = self.profile_missing_notice
131
131
132 def profile_missing_notice(self, *args, **kwargs):
132 def profile_missing_notice(self, *args, **kwargs):
133 error("""\
133 error("""\
134 The profile module could not be found. If you are a Debian user,
134 The profile module could not be found. If you are a Debian user,
135 it has been removed from the standard Debian package because of its non-free
135 it has been removed from the standard Debian package because of its non-free
136 license. To use profiling, please install"python2.3-profiler" from non-free.""")
136 license. To use profiling, please install"python2.3-profiler" from non-free.""")
137
137
138 def default_option(self,fn,optstr):
138 def default_option(self,fn,optstr):
139 """Make an entry in the options_table for fn, with value optstr"""
139 """Make an entry in the options_table for fn, with value optstr"""
140
140
141 if fn not in self.lsmagic():
141 if fn not in self.lsmagic():
142 error("%s is not a magic function" % fn)
142 error("%s is not a magic function" % fn)
143 self.options_table[fn] = optstr
143 self.options_table[fn] = optstr
144
144
145 def lsmagic(self):
145 def lsmagic(self):
146 """Return a list of currently available magic functions.
146 """Return a list of currently available magic functions.
147
147
148 Gives a list of the bare names after mangling (['ls','cd', ...], not
148 Gives a list of the bare names after mangling (['ls','cd', ...], not
149 ['magic_ls','magic_cd',...]"""
149 ['magic_ls','magic_cd',...]"""
150
150
151 # FIXME. This needs a cleanup, in the way the magics list is built.
151 # FIXME. This needs a cleanup, in the way the magics list is built.
152
152
153 # magics in class definition
153 # magics in class definition
154 class_magic = lambda fn: fn.startswith('magic_') and \
154 class_magic = lambda fn: fn.startswith('magic_') and \
155 callable(Magic.__dict__[fn])
155 callable(Magic.__dict__[fn])
156 # in instance namespace (run-time user additions)
156 # in instance namespace (run-time user additions)
157 inst_magic = lambda fn: fn.startswith('magic_') and \
157 inst_magic = lambda fn: fn.startswith('magic_') and \
158 callable(self.__dict__[fn])
158 callable(self.__dict__[fn])
159 # and bound magics by user (so they can access self):
159 # and bound magics by user (so they can access self):
160 inst_bound_magic = lambda fn: fn.startswith('magic_') and \
160 inst_bound_magic = lambda fn: fn.startswith('magic_') and \
161 callable(self.__class__.__dict__[fn])
161 callable(self.__class__.__dict__[fn])
162 magics = filter(class_magic,Magic.__dict__.keys()) + \
162 magics = filter(class_magic,Magic.__dict__.keys()) + \
163 filter(inst_magic,self.__dict__.keys()) + \
163 filter(inst_magic,self.__dict__.keys()) + \
164 filter(inst_bound_magic,self.__class__.__dict__.keys())
164 filter(inst_bound_magic,self.__class__.__dict__.keys())
165 out = []
165 out = []
166 for fn in magics:
166 for fn in magics:
167 out.append(fn.replace('magic_','',1))
167 out.append(fn.replace('magic_','',1))
168 out.sort()
168 out.sort()
169 return out
169 return out
170
170
171 def set_shell(self,shell):
171 def set_shell(self,shell):
172 self.shell = shell
172 self.shell = shell
173 self.alias_table = shell.alias_table
173 self.alias_table = shell.alias_table
174
174
175 def extract_input_slices(self,slices):
175 def extract_input_slices(self,slices):
176 """Return as a string a set of input history slices.
176 """Return as a string a set of input history slices.
177
177
178 The set of slices is given as a list of strings (like ['1','4:8','9'],
178 The set of slices is given as a list of strings (like ['1','4:8','9'],
179 since this function is for use by magic functions which get their
179 since this function is for use by magic functions which get their
180 arguments as strings."""
180 arguments as strings."""
181
181
182 cmds = []
182 cmds = []
183 for chunk in slices:
183 for chunk in slices:
184 if ':' in chunk:
184 if ':' in chunk:
185 ini,fin = map(int,chunk.split(':'))
185 ini,fin = map(int,chunk.split(':'))
186 else:
186 else:
187 ini = int(chunk)
187 ini = int(chunk)
188 fin = ini+1
188 fin = ini+1
189 cmds.append(self.shell.input_hist[ini:fin])
189 cmds.append(self.shell.input_hist[ini:fin])
190 return cmds
190 return cmds
191
191
192 def _ofind(self,oname):
192 def _ofind(self,oname):
193 """Find an object in the available namespaces.
193 """Find an object in the available namespaces.
194
194
195 self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic
195 self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic
196
196
197 Has special code to detect magic functions.
197 Has special code to detect magic functions.
198 """
198 """
199
199
200 oname = oname.strip()
200 oname = oname.strip()
201
201
202 # Namespaces to search in:
202 # Namespaces to search in:
203 user_ns = self.shell.user_ns
203 user_ns = self.shell.user_ns
204 internal_ns = self.shell.internal_ns
204 internal_ns = self.shell.internal_ns
205 builtin_ns = __builtin__.__dict__
205 builtin_ns = __builtin__.__dict__
206 alias_ns = self.shell.alias_table
206 alias_ns = self.shell.alias_table
207
207
208 # Put them in a list. The order is important so that we find things in
208 # Put them in a list. The order is important so that we find things in
209 # the same order that Python finds them.
209 # the same order that Python finds them.
210 namespaces = [ ('Interactive',user_ns),
210 namespaces = [ ('Interactive',user_ns),
211 ('IPython internal',internal_ns),
211 ('IPython internal',internal_ns),
212 ('Python builtin',builtin_ns),
212 ('Python builtin',builtin_ns),
213 ('Alias',alias_ns),
213 ('Alias',alias_ns),
214 ]
214 ]
215
215
216 # initialize results to 'null'
216 # initialize results to 'null'
217 found = 0; obj = None; ospace = None; ds = None;
217 found = 0; obj = None; ospace = None; ds = None;
218 ismagic = 0; isalias = 0
218 ismagic = 0; isalias = 0
219
219
220 # Look for the given name by splitting it in parts. If the head is
220 # Look for the given name by splitting it in parts. If the head is
221 # found, then we look for all the remaining parts as members, and only
221 # found, then we look for all the remaining parts as members, and only
222 # declare success if we can find them all.
222 # declare success if we can find them all.
223 oname_parts = oname.split('.')
223 oname_parts = oname.split('.')
224 oname_head, oname_rest = oname_parts[0],oname_parts[1:]
224 oname_head, oname_rest = oname_parts[0],oname_parts[1:]
225 for nsname,ns in namespaces:
225 for nsname,ns in namespaces:
226 try:
226 try:
227 obj = ns[oname_head]
227 obj = ns[oname_head]
228 except KeyError:
228 except KeyError:
229 continue
229 continue
230 else:
230 else:
231 for part in oname_rest:
231 for part in oname_rest:
232 try:
232 try:
233 obj = getattr(obj,part)
233 obj = getattr(obj,part)
234 except:
234 except:
235 # Blanket except b/c some badly implemented objects
235 # Blanket except b/c some badly implemented objects
236 # allow __getattr__ to raise exceptions other than
236 # allow __getattr__ to raise exceptions other than
237 # AttributeError, which then crashes IPython.
237 # AttributeError, which then crashes IPython.
238 break
238 break
239 else:
239 else:
240 # If we finish the for loop (no break), we got all members
240 # If we finish the for loop (no break), we got all members
241 found = 1
241 found = 1
242 ospace = nsname
242 ospace = nsname
243 if ns == alias_ns:
243 if ns == alias_ns:
244 isalias = 1
244 isalias = 1
245 break # namespace loop
245 break # namespace loop
246
246
247 # Try to see if it's magic
247 # Try to see if it's magic
248 if not found:
248 if not found:
249 if oname.startswith(self.shell.ESC_MAGIC):
249 if oname.startswith(self.shell.ESC_MAGIC):
250 oname = oname[1:]
250 oname = oname[1:]
251 obj = getattr(self,'magic_'+oname,None)
251 obj = getattr(self,'magic_'+oname,None)
252 if obj is not None:
252 if obj is not None:
253 found = 1
253 found = 1
254 ospace = 'IPython internal'
254 ospace = 'IPython internal'
255 ismagic = 1
255 ismagic = 1
256
256
257 # Last try: special-case some literals like '', [], {}, etc:
257 # Last try: special-case some literals like '', [], {}, etc:
258 if not found and oname_head in ["''",'""','[]','{}','()']:
258 if not found and oname_head in ["''",'""','[]','{}','()']:
259 obj = eval(oname_head)
259 obj = eval(oname_head)
260 found = 1
260 found = 1
261 ospace = 'Interactive'
261 ospace = 'Interactive'
262
262
263 return {'found':found, 'obj':obj, 'namespace':ospace,
263 return {'found':found, 'obj':obj, 'namespace':ospace,
264 'ismagic':ismagic, 'isalias':isalias}
264 'ismagic':ismagic, 'isalias':isalias}
265
265
266 def arg_err(self,func):
266 def arg_err(self,func):
267 """Print docstring if incorrect arguments were passed"""
267 """Print docstring if incorrect arguments were passed"""
268 print 'Error in arguments:'
268 print 'Error in arguments:'
269 print OInspect.getdoc(func)
269 print OInspect.getdoc(func)
270
270
271
271
272 def format_latex(self,str):
272 def format_latex(self,str):
273 """Format a string for latex inclusion."""
273 """Format a string for latex inclusion."""
274
274
275 # Characters that need to be escaped for latex:
275 # Characters that need to be escaped for latex:
276 escape_re = re.compile(r'(%|_|\$)',re.MULTILINE)
276 escape_re = re.compile(r'(%|_|\$)',re.MULTILINE)
277 # Magic command names as headers:
277 # Magic command names as headers:
278 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
278 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
279 re.MULTILINE)
279 re.MULTILINE)
280 # Magic commands
280 # Magic commands
281 cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC,
281 cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC,
282 re.MULTILINE)
282 re.MULTILINE)
283 # Paragraph continue
283 # Paragraph continue
284 par_re = re.compile(r'\\$',re.MULTILINE)
284 par_re = re.compile(r'\\$',re.MULTILINE)
285
285
286 str = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',str)
286 str = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',str)
287 str = cmd_re.sub(r'\\texttt{\g<cmd>}',str)
287 str = cmd_re.sub(r'\\texttt{\g<cmd>}',str)
288 str = par_re.sub(r'\\\\',str)
288 str = par_re.sub(r'\\\\',str)
289 str = escape_re.sub(r'\\\1',str)
289 str = escape_re.sub(r'\\\1',str)
290 return str
290 return str
291
291
292 def format_screen(self,str):
292 def format_screen(self,str):
293 """Format a string for screen printing.
293 """Format a string for screen printing.
294
294
295 This removes some latex-type format codes."""
295 This removes some latex-type format codes."""
296 # Paragraph continue
296 # Paragraph continue
297 par_re = re.compile(r'\\$',re.MULTILINE)
297 par_re = re.compile(r'\\$',re.MULTILINE)
298 str = par_re.sub('',str)
298 str = par_re.sub('',str)
299 return str
299 return str
300
300
301 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
301 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
302 """Parse options passed to an argument string.
302 """Parse options passed to an argument string.
303
303
304 The interface is similar to that of getopt(), but it returns back a
304 The interface is similar to that of getopt(), but it returns back a
305 Struct with the options as keys and the stripped argument string still
305 Struct with the options as keys and the stripped argument string still
306 as a string.
306 as a string.
307
307
308 arg_str is quoted as a true sys.argv vector by using shlex.split.
308 arg_str is quoted as a true sys.argv vector by using shlex.split.
309 This allows us to easily expand variables, glob files, quote
309 This allows us to easily expand variables, glob files, quote
310 arguments, etc.
310 arguments, etc.
311
311
312 Options:
312 Options:
313 -mode: default 'string'. If given as 'list', the argument string is
313 -mode: default 'string'. If given as 'list', the argument string is
314 returned as a list (split on whitespace) instead of a string.
314 returned as a list (split on whitespace) instead of a string.
315
315
316 -list_all: put all option values in lists. Normally only options
316 -list_all: put all option values in lists. Normally only options
317 appearing more than once are put in a list."""
317 appearing more than once are put in a list."""
318
318
319 # inject default options at the beginning of the input line
319 # inject default options at the beginning of the input line
320 caller = sys._getframe(1).f_code.co_name.replace('magic_','')
320 caller = sys._getframe(1).f_code.co_name.replace('magic_','')
321 arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str)
321 arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str)
322
322
323 mode = kw.get('mode','string')
323 mode = kw.get('mode','string')
324 if mode not in ['string','list']:
324 if mode not in ['string','list']:
325 raise ValueError,'incorrect mode given: %s' % mode
325 raise ValueError,'incorrect mode given: %s' % mode
326 # Get options
326 # Get options
327 list_all = kw.get('list_all',0)
327 list_all = kw.get('list_all',0)
328
328
329 # Check if we have more than one argument to warrant extra processing:
329 # Check if we have more than one argument to warrant extra processing:
330 odict = {} # Dictionary with options
330 odict = {} # Dictionary with options
331 args = arg_str.split()
331 args = arg_str.split()
332 if len(args) >= 1:
332 if len(args) >= 1:
333 # If the list of inputs only has 0 or 1 thing in it, there's no
333 # If the list of inputs only has 0 or 1 thing in it, there's no
334 # need to look for options
334 # need to look for options
335 argv = shlex_split(arg_str)
335 argv = shlex_split(arg_str)
336 # Do regular option processing
336 # Do regular option processing
337 opts,args = getopt(argv,opt_str,*long_opts)
337 opts,args = getopt(argv,opt_str,*long_opts)
338 for o,a in opts:
338 for o,a in opts:
339 if o.startswith('--'):
339 if o.startswith('--'):
340 o = o[2:]
340 o = o[2:]
341 else:
341 else:
342 o = o[1:]
342 o = o[1:]
343 try:
343 try:
344 odict[o].append(a)
344 odict[o].append(a)
345 except AttributeError:
345 except AttributeError:
346 odict[o] = [odict[o],a]
346 odict[o] = [odict[o],a]
347 except KeyError:
347 except KeyError:
348 if list_all:
348 if list_all:
349 odict[o] = [a]
349 odict[o] = [a]
350 else:
350 else:
351 odict[o] = a
351 odict[o] = a
352
352
353 # Prepare opts,args for return
353 # Prepare opts,args for return
354 opts = Struct(odict)
354 opts = Struct(odict)
355 if mode == 'string':
355 if mode == 'string':
356 args = ' '.join(args)
356 args = ' '.join(args)
357
357
358 return opts,args
358 return opts,args
359
359
360 #......................................................................
360 #......................................................................
361 # And now the actual magic functions
361 # And now the actual magic functions
362
362
363 # Functions for IPython shell work (vars,funcs, config, etc)
363 # Functions for IPython shell work (vars,funcs, config, etc)
364 def magic_lsmagic(self, parameter_s = ''):
364 def magic_lsmagic(self, parameter_s = ''):
365 """List currently available magic functions."""
365 """List currently available magic functions."""
366 mesc = self.shell.ESC_MAGIC
366 mesc = self.shell.ESC_MAGIC
367 print 'Available magic functions:\n'+mesc+\
367 print 'Available magic functions:\n'+mesc+\
368 (' '+mesc).join(self.lsmagic())
368 (' '+mesc).join(self.lsmagic())
369 print '\n' + Magic.auto_status[self.shell.rc.automagic]
369 print '\n' + Magic.auto_status[self.shell.rc.automagic]
370 return None
370 return None
371
371
372 def magic_magic(self, parameter_s = ''):
372 def magic_magic(self, parameter_s = ''):
373 """Print information about the magic function system."""
373 """Print information about the magic function system."""
374
374
375 mode = ''
375 mode = ''
376 try:
376 try:
377 if parameter_s.split()[0] == '-latex':
377 if parameter_s.split()[0] == '-latex':
378 mode = 'latex'
378 mode = 'latex'
379 except:
379 except:
380 pass
380 pass
381
381
382 magic_docs = []
382 magic_docs = []
383 for fname in self.lsmagic():
383 for fname in self.lsmagic():
384 mname = 'magic_' + fname
384 mname = 'magic_' + fname
385 for space in (Magic,self,self.__class__):
385 for space in (Magic,self,self.__class__):
386 try:
386 try:
387 fn = space.__dict__[mname]
387 fn = space.__dict__[mname]
388 except KeyError:
388 except KeyError:
389 pass
389 pass
390 else:
390 else:
391 break
391 break
392 magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC,
392 magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC,
393 fname,fn.__doc__))
393 fname,fn.__doc__))
394 magic_docs = ''.join(magic_docs)
394 magic_docs = ''.join(magic_docs)
395
395
396 if mode == 'latex':
396 if mode == 'latex':
397 print self.format_latex(magic_docs)
397 print self.format_latex(magic_docs)
398 return
398 return
399 else:
399 else:
400 magic_docs = self.format_screen(magic_docs)
400 magic_docs = self.format_screen(magic_docs)
401
401
402 outmsg = """
402 outmsg = """
403 IPython's 'magic' functions
403 IPython's 'magic' functions
404 ===========================
404 ===========================
405
405
406 The magic function system provides a series of functions which allow you to
406 The magic function system provides a series of functions which allow you to
407 control the behavior of IPython itself, plus a lot of system-type
407 control the behavior of IPython itself, plus a lot of system-type
408 features. All these functions are prefixed with a % character, but parameters
408 features. All these functions are prefixed with a % character, but parameters
409 are given without parentheses or quotes.
409 are given without parentheses or quotes.
410
410
411 NOTE: If you have 'automagic' enabled (via the command line option or with the
411 NOTE: If you have 'automagic' enabled (via the command line option or with the
412 %automagic function), you don't need to type in the % explicitly. By default,
412 %automagic function), you don't need to type in the % explicitly. By default,
413 IPython ships with automagic on, so you should only rarely need the % escape.
413 IPython ships with automagic on, so you should only rarely need the % escape.
414
414
415 Example: typing '%cd mydir' (without the quotes) changes you working directory
415 Example: typing '%cd mydir' (without the quotes) changes you working directory
416 to 'mydir', if it exists.
416 to 'mydir', if it exists.
417
417
418 You can define your own magic functions to extend the system. See the supplied
418 You can define your own magic functions to extend the system. See the supplied
419 ipythonrc and example-magic.py files for details (in your ipython
419 ipythonrc and example-magic.py files for details (in your ipython
420 configuration directory, typically $HOME/.ipython/).
420 configuration directory, typically $HOME/.ipython/).
421
421
422 You can also define your own aliased names for magic functions. In your
422 You can also define your own aliased names for magic functions. In your
423 ipythonrc file, placing a line like:
423 ipythonrc file, placing a line like:
424
424
425 execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
425 execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
426
426
427 will define %pf as a new name for %profile.
427 will define %pf as a new name for %profile.
428
428
429 You can also call magics in code using the ipmagic() function, which IPython
429 You can also call magics in code using the ipmagic() function, which IPython
430 automatically adds to the builtin namespace. Type 'ipmagic?' for details.
430 automatically adds to the builtin namespace. Type 'ipmagic?' for details.
431
431
432 For a list of the available magic functions, use %lsmagic. For a description
432 For a list of the available magic functions, use %lsmagic. For a description
433 of any of them, type %magic_name?, e.g. '%cd?'.
433 of any of them, type %magic_name?, e.g. '%cd?'.
434
434
435 Currently the magic system has the following functions:\n"""
435 Currently the magic system has the following functions:\n"""
436
436
437 mesc = self.shell.ESC_MAGIC
437 mesc = self.shell.ESC_MAGIC
438 outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):"
438 outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):"
439 "\n\n%s%s\n\n%s" % (outmsg,
439 "\n\n%s%s\n\n%s" % (outmsg,
440 magic_docs,mesc,mesc,
440 magic_docs,mesc,mesc,
441 (' '+mesc).join(self.lsmagic()),
441 (' '+mesc).join(self.lsmagic()),
442 Magic.auto_status[self.shell.rc.automagic] ) )
442 Magic.auto_status[self.shell.rc.automagic] ) )
443
443
444 page(outmsg,screen_lines=self.shell.rc.screen_length)
444 page(outmsg,screen_lines=self.shell.rc.screen_length)
445
445
446 def magic_automagic(self, parameter_s = ''):
446 def magic_automagic(self, parameter_s = ''):
447 """Make magic functions callable without having to type the initial %.
447 """Make magic functions callable without having to type the initial %.
448
448
449 Toggles on/off (when off, you must call it as %automagic, of
449 Toggles on/off (when off, you must call it as %automagic, of
450 course). Note that magic functions have lowest priority, so if there's
450 course). Note that magic functions have lowest priority, so if there's
451 a variable whose name collides with that of a magic fn, automagic
451 a variable whose name collides with that of a magic fn, automagic
452 won't work for that function (you get the variable instead). However,
452 won't work for that function (you get the variable instead). However,
453 if you delete the variable (del var), the previously shadowed magic
453 if you delete the variable (del var), the previously shadowed magic
454 function becomes visible to automagic again."""
454 function becomes visible to automagic again."""
455
455
456 rc = self.shell.rc
456 rc = self.shell.rc
457 rc.automagic = not rc.automagic
457 rc.automagic = not rc.automagic
458 print '\n' + Magic.auto_status[rc.automagic]
458 print '\n' + Magic.auto_status[rc.automagic]
459
459
460 def magic_autocall(self, parameter_s = ''):
460 def magic_autocall(self, parameter_s = ''):
461 """Make functions callable without having to type parentheses.
461 """Make functions callable without having to type parentheses.
462
462
463 This toggles the autocall command line option on and off."""
463 This toggles the autocall command line option on and off."""
464
464
465 rc = self.shell.rc
465 rc = self.shell.rc
466 rc.autocall = not rc.autocall
466 rc.autocall = not rc.autocall
467 print "Automatic calling is:",['OFF','ON'][rc.autocall]
467 print "Automatic calling is:",['OFF','ON'][rc.autocall]
468
468
469 def magic_autoindent(self, parameter_s = ''):
469 def magic_autoindent(self, parameter_s = ''):
470 """Toggle autoindent on/off (if available)."""
470 """Toggle autoindent on/off (if available)."""
471
471
472 self.shell.set_autoindent()
472 self.shell.set_autoindent()
473 print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent]
473 print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent]
474
474
475 def magic_system_verbose(self, parameter_s = ''):
475 def magic_system_verbose(self, parameter_s = ''):
476 """Toggle verbose printing of system calls on/off."""
476 """Toggle verbose printing of system calls on/off."""
477
477
478 self.shell.rc_set_toggle('system_verbose')
478 self.shell.rc_set_toggle('system_verbose')
479 print "System verbose printing is:",\
479 print "System verbose printing is:",\
480 ['OFF','ON'][self.shell.rc.system_verbose]
480 ['OFF','ON'][self.shell.rc.system_verbose]
481
481
482 def magic_history(self, parameter_s = ''):
482 def magic_history(self, parameter_s = ''):
483 """Print input history (_i<n> variables), with most recent last.
483 """Print input history (_i<n> variables), with most recent last.
484
484
485 %history [-n] -> print at most 40 inputs (some may be multi-line)\\
485 %history [-n] -> print at most 40 inputs (some may be multi-line)\\
486 %history [-n] n -> print at most n inputs\\
486 %history [-n] n -> print at most n inputs\\
487 %history [-n] n1 n2 -> print inputs between n1 and n2 (n2 not included)\\
487 %history [-n] n1 n2 -> print inputs between n1 and n2 (n2 not included)\\
488
488
489 Each input's number <n> is shown, and is accessible as the
489 Each input's number <n> is shown, and is accessible as the
490 automatically generated variable _i<n>. Multi-line statements are
490 automatically generated variable _i<n>. Multi-line statements are
491 printed starting at a new line for easy copy/paste.
491 printed starting at a new line for easy copy/paste.
492
492
493 If option -n is used, input numbers are not printed. This is useful if
493 If option -n is used, input numbers are not printed. This is useful if
494 you want to get a printout of many lines which can be directly pasted
494 you want to get a printout of many lines which can be directly pasted
495 into a text editor.
495 into a text editor.
496
496
497 This feature is only available if numbered prompts are in use."""
497 This feature is only available if numbered prompts are in use."""
498
498
499 if not self.do_full_cache:
499 if not self.do_full_cache:
500 print 'This feature is only available if numbered prompts are in use.'
500 print 'This feature is only available if numbered prompts are in use.'
501 return
501 return
502 opts,args = self.parse_options(parameter_s,'n',mode='list')
502 opts,args = self.parse_options(parameter_s,'n',mode='list')
503
503
504 default_length = 40
504 default_length = 40
505 if len(args) == 0:
505 if len(args) == 0:
506 final = self.outputcache.prompt_count
506 final = self.outputcache.prompt_count
507 init = max(1,final-default_length)
507 init = max(1,final-default_length)
508 elif len(args) == 1:
508 elif len(args) == 1:
509 final = self.outputcache.prompt_count
509 final = self.outputcache.prompt_count
510 init = max(1,final-int(args[0]))
510 init = max(1,final-int(args[0]))
511 elif len(args) == 2:
511 elif len(args) == 2:
512 init,final = map(int,args)
512 init,final = map(int,args)
513 else:
513 else:
514 warn('%hist takes 0, 1 or 2 arguments separated by spaces.')
514 warn('%hist takes 0, 1 or 2 arguments separated by spaces.')
515 print self.magic_hist.__doc__
515 print self.magic_hist.__doc__
516 return
516 return
517 width = len(str(final))
517 width = len(str(final))
518 line_sep = ['','\n']
518 line_sep = ['','\n']
519 input_hist = self.shell.input_hist
519 input_hist = self.shell.input_hist
520 print_nums = not opts.has_key('n')
520 print_nums = not opts.has_key('n')
521 for in_num in range(init,final):
521 for in_num in range(init,final):
522 inline = input_hist[in_num]
522 inline = input_hist[in_num]
523 multiline = inline.count('\n') > 1
523 multiline = inline.count('\n') > 1
524 if print_nums:
524 if print_nums:
525 print str(in_num).ljust(width)+':'+ line_sep[multiline],
525 print str(in_num).ljust(width)+':'+ line_sep[multiline],
526 if inline.startswith('#'+self.shell.ESC_MAGIC) or \
526 if inline.startswith('#'+self.shell.ESC_MAGIC) or \
527 inline.startswith('#!'):
527 inline.startswith('#!'):
528 print inline[1:],
528 print inline[1:],
529 else:
529 else:
530 print inline,
530 print inline,
531
531
532 def magic_hist(self, parameter_s=''):
532 def magic_hist(self, parameter_s=''):
533 """Alternate name for %history."""
533 """Alternate name for %history."""
534 return self.magic_history(parameter_s)
534 return self.magic_history(parameter_s)
535
535
536 def magic_p(self, parameter_s=''):
536 def magic_p(self, parameter_s=''):
537 """Just a short alias for Python's 'print'."""
537 """Just a short alias for Python's 'print'."""
538 exec 'print ' + parameter_s in self.shell.user_ns
538 exec 'print ' + parameter_s in self.shell.user_ns
539
539
540 def magic_r(self, parameter_s=''):
540 def magic_r(self, parameter_s=''):
541 """Repeat previous input.
541 """Repeat previous input.
542
542
543 If given an argument, repeats the previous command which starts with
543 If given an argument, repeats the previous command which starts with
544 the same string, otherwise it just repeats the previous input.
544 the same string, otherwise it just repeats the previous input.
545
545
546 Shell escaped commands (with ! as first character) are not recognized
546 Shell escaped commands (with ! as first character) are not recognized
547 by this system, only pure python code and magic commands.
547 by this system, only pure python code and magic commands.
548 """
548 """
549
549
550 start = parameter_s.strip()
550 start = parameter_s.strip()
551 esc_magic = self.shell.ESC_MAGIC
551 esc_magic = self.shell.ESC_MAGIC
552 # Identify magic commands even if automagic is on (which means
552 # Identify magic commands even if automagic is on (which means
553 # the in-memory version is different from that typed by the user).
553 # the in-memory version is different from that typed by the user).
554 if self.shell.rc.automagic:
554 if self.shell.rc.automagic:
555 start_magic = esc_magic+start
555 start_magic = esc_magic+start
556 else:
556 else:
557 start_magic = start
557 start_magic = start
558 # Look through the input history in reverse
558 # Look through the input history in reverse
559 for n in range(len(self.shell.input_hist)-2,0,-1):
559 for n in range(len(self.shell.input_hist)-2,0,-1):
560 input = self.shell.input_hist[n]
560 input = self.shell.input_hist[n]
561 # skip plain 'r' lines so we don't recurse to infinity
561 # skip plain 'r' lines so we don't recurse to infinity
562 if input != 'ipmagic("r")\n' and \
562 if input != 'ipmagic("r")\n' and \
563 (input.startswith(start) or input.startswith(start_magic)):
563 (input.startswith(start) or input.startswith(start_magic)):
564 #print 'match',`input` # dbg
564 #print 'match',`input` # dbg
565 if input.startswith(esc_magic):
565 if input.startswith(esc_magic):
566 input = magic2python(input)
566 input = magic2python(input)
567 #print 'modified',`input` # dbg
567 #print 'modified',`input` # dbg
568 print 'Executing:',input,
568 print 'Executing:',input,
569 exec input in self.shell.user_ns
569 exec input in self.shell.user_ns
570 return
570 return
571 print 'No previous input matching `%s` found.' % start
571 print 'No previous input matching `%s` found.' % start
572
572
573 def magic_page(self, parameter_s=''):
573 def magic_page(self, parameter_s=''):
574 """Pretty print the object and display it through a pager.
574 """Pretty print the object and display it through a pager.
575
575
576 If no parameter is given, use _ (last output)."""
576 If no parameter is given, use _ (last output)."""
577 # After a function contributed by Olivier Aubert, slightly modified.
577 # After a function contributed by Olivier Aubert, slightly modified.
578
578
579 oname = parameter_s and parameter_s or '_'
579 oname = parameter_s and parameter_s or '_'
580 info = self._ofind(oname)
580 info = self._ofind(oname)
581 if info['found']:
581 if info['found']:
582 page(pformat(info['obj']))
582 page(pformat(info['obj']))
583 else:
583 else:
584 print 'Object `%s` not found' % oname
584 print 'Object `%s` not found' % oname
585
585
586 def magic_profile(self, parameter_s=''):
586 def magic_profile(self, parameter_s=''):
587 """Print your currently active IPyhton profile."""
587 """Print your currently active IPyhton profile."""
588 if self.shell.rc.profile:
588 if self.shell.rc.profile:
589 printpl('Current IPython profile: $self.shell.rc.profile.')
589 printpl('Current IPython profile: $self.shell.rc.profile.')
590 else:
590 else:
591 print 'No profile active.'
591 print 'No profile active.'
592
592
593 def _inspect(self,meth,oname,**kw):
593 def _inspect(self,meth,oname,**kw):
594 """Generic interface to the inspector system.
594 """Generic interface to the inspector system.
595
595
596 This function is meant to be called by pdef, pdoc & friends."""
596 This function is meant to be called by pdef, pdoc & friends."""
597
597
598 oname = oname.strip()
598 oname = oname.strip()
599 info = Struct(self._ofind(oname))
599 info = Struct(self._ofind(oname))
600 if info.found:
600 if info.found:
601 pmethod = getattr(self.shell.inspector,meth)
601 pmethod = getattr(self.shell.inspector,meth)
602 formatter = info.ismagic and self.format_screen or None
602 formatter = info.ismagic and self.format_screen or None
603 if meth == 'pdoc':
603 if meth == 'pdoc':
604 pmethod(info.obj,oname,formatter)
604 pmethod(info.obj,oname,formatter)
605 elif meth == 'pinfo':
605 elif meth == 'pinfo':
606 pmethod(info.obj,oname,formatter,info,**kw)
606 pmethod(info.obj,oname,formatter,info,**kw)
607 else:
607 else:
608 pmethod(info.obj,oname)
608 pmethod(info.obj,oname)
609 else:
609 else:
610 print 'Object `%s` not found.' % oname
610 print 'Object `%s` not found.' % oname
611 return 'not found' # so callers can take other action
611 return 'not found' # so callers can take other action
612
612
613 def magic_pdef(self, parameter_s=''):
613 def magic_pdef(self, parameter_s=''):
614 """Print the definition header for any callable object.
614 """Print the definition header for any callable object.
615
615
616 If the object is a class, print the constructor information."""
616 If the object is a class, print the constructor information."""
617 self._inspect('pdef',parameter_s)
617 self._inspect('pdef',parameter_s)
618
618
619 def magic_pdoc(self, parameter_s=''):
619 def magic_pdoc(self, parameter_s=''):
620 """Print the docstring for an object.
620 """Print the docstring for an object.
621
621
622 If the given object is a class, it will print both the class and the
622 If the given object is a class, it will print both the class and the
623 constructor docstrings."""
623 constructor docstrings."""
624 self._inspect('pdoc',parameter_s)
624 self._inspect('pdoc',parameter_s)
625
625
626 def magic_psource(self, parameter_s=''):
626 def magic_psource(self, parameter_s=''):
627 """Print (or run through pager) the source code for an object."""
627 """Print (or run through pager) the source code for an object."""
628 self._inspect('psource',parameter_s)
628 self._inspect('psource',parameter_s)
629
629
630 def magic_pfile(self, parameter_s=''):
630 def magic_pfile(self, parameter_s=''):
631 """Print (or run through pager) the file where an object is defined.
631 """Print (or run through pager) the file where an object is defined.
632
632
633 The file opens at the line where the object definition begins. IPython
633 The file opens at the line where the object definition begins. IPython
634 will honor the environment variable PAGER if set, and otherwise will
634 will honor the environment variable PAGER if set, and otherwise will
635 do its best to print the file in a convenient form.
635 do its best to print the file in a convenient form.
636
636
637 If the given argument is not an object currently defined, IPython will
637 If the given argument is not an object currently defined, IPython will
638 try to interpret it as a filename (automatically adding a .py extension
638 try to interpret it as a filename (automatically adding a .py extension
639 if needed). You can thus use %pfile as a syntax highlighting code
639 if needed). You can thus use %pfile as a syntax highlighting code
640 viewer."""
640 viewer."""
641
641
642 # first interpret argument as an object name
642 # first interpret argument as an object name
643 out = self._inspect('pfile',parameter_s)
643 out = self._inspect('pfile',parameter_s)
644 # if not, try the input as a filename
644 # if not, try the input as a filename
645 if out == 'not found':
645 if out == 'not found':
646 try:
646 try:
647 filename = get_py_filename(parameter_s)
647 filename = get_py_filename(parameter_s)
648 except IOError,msg:
648 except IOError,msg:
649 print msg
649 print msg
650 return
650 return
651 page(self.shell.inspector.format(file(filename).read()))
651 page(self.shell.inspector.format(file(filename).read()))
652
652
653 def magic_pinfo(self, parameter_s=''):
653 def magic_pinfo(self, parameter_s=''):
654 """Provide detailed information about an object.
654 """Provide detailed information about an object.
655
655
656 '%pinfo object' is just a synonym for object? or ?object."""
656 '%pinfo object' is just a synonym for object? or ?object."""
657
657
658 #print 'pinfo par: <%s>' % parameter_s # dbg
658 #print 'pinfo par: <%s>' % parameter_s # dbg
659
659
660 # detail_level: 0 -> obj? , 1 -> obj??
660 # detail_level: 0 -> obj? , 1 -> obj??
661 detail_level = 0
661 detail_level = 0
662 # We need to detect if we got called as 'pinfo pinfo foo', which can
662 # We need to detect if we got called as 'pinfo pinfo foo', which can
663 # happen if the user types 'pinfo foo?' at the cmd line.
663 # happen if the user types 'pinfo foo?' at the cmd line.
664 pinfo,qmark1,oname,qmark2 = \
664 pinfo,qmark1,oname,qmark2 = \
665 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
665 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
666 if pinfo or qmark1 or qmark2:
666 if pinfo or qmark1 or qmark2:
667 detail_level = 1
667 detail_level = 1
668 if "*" in oname:
668 if "*" in oname:
669 self.magic_psearch(oname)
669 self.magic_psearch(oname)
670 else:
670 else:
671 self._inspect('pinfo',oname,detail_level=detail_level)
671 self._inspect('pinfo',oname,detail_level=detail_level)
672
672
673 def magic_psearch(self, parameter_s=''):
673 def magic_psearch(self, parameter_s=''):
674 """Search for object in namespaces by wildcard.
674 """Search for object in namespaces by wildcard.
675
675
676 %psearch [options] PATTERN [OBJECT TYPE]
676 %psearch [options] PATTERN [OBJECT TYPE]
677
677
678 Note: ? can be used as a synonym for %psearch, at the beginning or at
678 Note: ? can be used as a synonym for %psearch, at the beginning or at
679 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
679 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
680 rest of the command line must be unchanged (options come first), so
680 rest of the command line must be unchanged (options come first), so
681 for example the following forms are equivalent
681 for example the following forms are equivalent
682
682
683 %psearch -i a* function
683 %psearch -i a* function
684 -i a* function?
684 -i a* function?
685 ?-i a* function
685 ?-i a* function
686
686
687 Arguments:
687 Arguments:
688
688
689 PATTERN
689 PATTERN
690
690
691 where PATTERN is a string containing * as a wildcard similar to its
691 where PATTERN is a string containing * as a wildcard similar to its
692 use in a shell. The pattern is matched in all namespaces on the
692 use in a shell. The pattern is matched in all namespaces on the
693 search path. By default objects starting with a single _ are not
693 search path. By default objects starting with a single _ are not
694 matched, many IPython generated objects have a single
694 matched, many IPython generated objects have a single
695 underscore. The default is case insensitive matching. Matching is
695 underscore. The default is case insensitive matching. Matching is
696 also done on the attributes of objects and not only on the objects
696 also done on the attributes of objects and not only on the objects
697 in a module.
697 in a module.
698
698
699 [OBJECT TYPE]
699 [OBJECT TYPE]
700
700
701 Is the name of a python type from the types module. The name is
701 Is the name of a python type from the types module. The name is
702 given in lowercase without the ending type, ex. StringType is
702 given in lowercase without the ending type, ex. StringType is
703 written string. By adding a type here only objects matching the
703 written string. By adding a type here only objects matching the
704 given type are matched. Using all here makes the pattern match all
704 given type are matched. Using all here makes the pattern match all
705 types (this is the default).
705 types (this is the default).
706
706
707 Options:
707 Options:
708
708
709 -a: makes the pattern match even objects whose names start with a
709 -a: makes the pattern match even objects whose names start with a
710 single underscore. These names are normally ommitted from the
710 single underscore. These names are normally ommitted from the
711 search.
711 search.
712
712
713 -i/-c: make the pattern case insensitive/sensitive. If neither of
713 -i/-c: make the pattern case insensitive/sensitive. If neither of
714 these options is given, the default is read from your ipythonrc
714 these options is given, the default is read from your ipythonrc
715 file. The option name which sets this value is
715 file. The option name which sets this value is
716 'wildcards_case_sensitive'. If this option is not specified in your
716 'wildcards_case_sensitive'. If this option is not specified in your
717 ipythonrc file, IPython's internal default is to do a case sensitive
717 ipythonrc file, IPython's internal default is to do a case sensitive
718 search.
718 search.
719
719
720 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
720 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
721 specifiy can be searched in any of the following namespaces:
721 specifiy can be searched in any of the following namespaces:
722 'builtin', 'user', 'user_global','internal', 'alias', where
722 'builtin', 'user', 'user_global','internal', 'alias', where
723 'builtin' and 'user' are the search defaults. Note that you should
723 'builtin' and 'user' are the search defaults. Note that you should
724 not use quotes when specifying namespaces.
724 not use quotes when specifying namespaces.
725
725
726 'Builtin' contains the python module builtin, 'user' contains all
726 'Builtin' contains the python module builtin, 'user' contains all
727 user data, 'alias' only contain the shell aliases and no python
727 user data, 'alias' only contain the shell aliases and no python
728 objects, 'internal' contains objects used by IPython. The
728 objects, 'internal' contains objects used by IPython. The
729 'user_global' namespace is only used by embedded IPython instances,
729 'user_global' namespace is only used by embedded IPython instances,
730 and it contains module-level globals. You can add namespaces to the
730 and it contains module-level globals. You can add namespaces to the
731 search with -s or exclude them with -e (these options can be given
731 search with -s or exclude them with -e (these options can be given
732 more than once).
732 more than once).
733
733
734 Examples:
734 Examples:
735
735
736 %psearch a* -> objects beginning with an a
736 %psearch a* -> objects beginning with an a
737 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
737 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
738 %psearch a* function -> all functions beginning with an a
738 %psearch a* function -> all functions beginning with an a
739 %psearch re.e* -> objects beginning with an e in module re
739 %psearch re.e* -> objects beginning with an e in module re
740 %psearch r*.e* -> objects that start with e in modules starting in r
740 %psearch r*.e* -> objects that start with e in modules starting in r
741 %psearch r*.* string -> all strings in modules beginning with r
741 %psearch r*.* string -> all strings in modules beginning with r
742
742
743 Case sensitve search:
743 Case sensitve search:
744
744
745 %psearch -c a* list all object beginning with lower case a
745 %psearch -c a* list all object beginning with lower case a
746
746
747 Show objects beginning with a single _:
747 Show objects beginning with a single _:
748
748
749 %psearch -a _* list objects beginning with a single underscore"""
749 %psearch -a _* list objects beginning with a single underscore"""
750
750
751 # default namespaces to be searched
751 # default namespaces to be searched
752 def_search = ['user','builtin']
752 def_search = ['user','builtin']
753
753
754 # Process options/args
754 # Process options/args
755 opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
755 opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
756 opt = opts.get
756 opt = opts.get
757 shell = self.shell
757 shell = self.shell
758 psearch = shell.inspector.psearch
758 psearch = shell.inspector.psearch
759
759
760 # select case options
760 # select case options
761 if opts.has_key('i'):
761 if opts.has_key('i'):
762 ignore_case = True
762 ignore_case = True
763 elif opts.has_key('c'):
763 elif opts.has_key('c'):
764 ignore_case = False
764 ignore_case = False
765 else:
765 else:
766 ignore_case = not shell.rc.wildcards_case_sensitive
766 ignore_case = not shell.rc.wildcards_case_sensitive
767
767
768 # Build list of namespaces to search from user options
768 # Build list of namespaces to search from user options
769 def_search.extend(opt('s',[]))
769 def_search.extend(opt('s',[]))
770 ns_exclude = ns_exclude=opt('e',[])
770 ns_exclude = ns_exclude=opt('e',[])
771 ns_search = [nm for nm in def_search if nm not in ns_exclude]
771 ns_search = [nm for nm in def_search if nm not in ns_exclude]
772
772
773 # Call the actual search
773 # Call the actual search
774 try:
774 try:
775 psearch(args,shell.ns_table,ns_search,
775 psearch(args,shell.ns_table,ns_search,
776 show_all=opt('a'),ignore_case=ignore_case)
776 show_all=opt('a'),ignore_case=ignore_case)
777 except:
777 except:
778 shell.showtraceback()
778 shell.showtraceback()
779
779
780 def magic_who_ls(self, parameter_s=''):
780 def magic_who_ls(self, parameter_s=''):
781 """Return a sorted list of all interactive variables.
781 """Return a sorted list of all interactive variables.
782
782
783 If arguments are given, only variables of types matching these
783 If arguments are given, only variables of types matching these
784 arguments are returned."""
784 arguments are returned."""
785
785
786 user_ns = self.shell.user_ns
786 user_ns = self.shell.user_ns
787 out = []
787 out = []
788 typelist = parameter_s.split()
788 typelist = parameter_s.split()
789 for i in self.shell.user_ns.keys():
789 for i in self.shell.user_ns.keys():
790 if not (i.startswith('_') or i.startswith('_i')) \
790 if not (i.startswith('_') or i.startswith('_i')) \
791 and not (self.internal_ns.has_key(i) or
791 and not (self.internal_ns.has_key(i) or
792 self.user_config_ns.has_key(i)):
792 self.user_config_ns.has_key(i)):
793 if typelist:
793 if typelist:
794 if type(user_ns[i]).__name__ in typelist:
794 if type(user_ns[i]).__name__ in typelist:
795 out.append(i)
795 out.append(i)
796 else:
796 else:
797 out.append(i)
797 out.append(i)
798 out.sort()
798 out.sort()
799 return out
799 return out
800
800
801 def magic_who(self, parameter_s=''):
801 def magic_who(self, parameter_s=''):
802 """Print all interactive variables, with some minimal formatting.
802 """Print all interactive variables, with some minimal formatting.
803
803
804 If any arguments are given, only variables whose type matches one of
804 If any arguments are given, only variables whose type matches one of
805 these are printed. For example:
805 these are printed. For example:
806
806
807 %who function str
807 %who function str
808
808
809 will only list functions and strings, excluding all other types of
809 will only list functions and strings, excluding all other types of
810 variables. To find the proper type names, simply use type(var) at a
810 variables. To find the proper type names, simply use type(var) at a
811 command line to see how python prints type names. For example:
811 command line to see how python prints type names. For example:
812
812
813 In [1]: type('hello')\\
813 In [1]: type('hello')\\
814 Out[1]: <type 'str'>
814 Out[1]: <type 'str'>
815
815
816 indicates that the type name for strings is 'str'.
816 indicates that the type name for strings is 'str'.
817
817
818 %who always excludes executed names loaded through your configuration
818 %who always excludes executed names loaded through your configuration
819 file and things which are internal to IPython.
819 file and things which are internal to IPython.
820
820
821 This is deliberate, as typically you may load many modules and the
821 This is deliberate, as typically you may load many modules and the
822 purpose of %who is to show you only what you've manually defined."""
822 purpose of %who is to show you only what you've manually defined."""
823
823
824 varlist = self.magic_who_ls(parameter_s)
824 varlist = self.magic_who_ls(parameter_s)
825 if not varlist:
825 if not varlist:
826 print 'Interactive namespace is empty.'
826 print 'Interactive namespace is empty.'
827 return
827 return
828
828
829 # if we have variables, move on...
829 # if we have variables, move on...
830
830
831 # stupid flushing problem: when prompts have no separators, stdout is
831 # stupid flushing problem: when prompts have no separators, stdout is
832 # getting lost. I'm starting to think this is a python bug. I'm having
832 # getting lost. I'm starting to think this is a python bug. I'm having
833 # to force a flush with a print because even a sys.stdout.flush
833 # to force a flush with a print because even a sys.stdout.flush
834 # doesn't seem to do anything!
834 # doesn't seem to do anything!
835
835
836 count = 0
836 count = 0
837 for i in varlist:
837 for i in varlist:
838 print i+'\t',
838 print i+'\t',
839 count += 1
839 count += 1
840 if count > 8:
840 if count > 8:
841 count = 0
841 count = 0
842 print
842 print
843 sys.stdout.flush() # FIXME. Why the hell isn't this flushing???
843 sys.stdout.flush() # FIXME. Why the hell isn't this flushing???
844
844
845 print # well, this does force a flush at the expense of an extra \n
845 print # well, this does force a flush at the expense of an extra \n
846
846
847 def magic_whos(self, parameter_s=''):
847 def magic_whos(self, parameter_s=''):
848 """Like %who, but gives some extra information about each variable.
848 """Like %who, but gives some extra information about each variable.
849
849
850 The same type filtering of %who can be applied here.
850 The same type filtering of %who can be applied here.
851
851
852 For all variables, the type is printed. Additionally it prints:
852 For all variables, the type is printed. Additionally it prints:
853
853
854 - For {},[],(): their length.
854 - For {},[],(): their length.
855
855
856 - For Numeric arrays, a summary with shape, number of elements,
856 - For Numeric arrays, a summary with shape, number of elements,
857 typecode and size in memory.
857 typecode and size in memory.
858
858
859 - Everything else: a string representation, snipping their middle if
859 - Everything else: a string representation, snipping their middle if
860 too long."""
860 too long."""
861
861
862 varnames = self.magic_who_ls(parameter_s)
862 varnames = self.magic_who_ls(parameter_s)
863 if not varnames:
863 if not varnames:
864 print 'Interactive namespace is empty.'
864 print 'Interactive namespace is empty.'
865 return
865 return
866
866
867 # if we have variables, move on...
867 # if we have variables, move on...
868
868
869 # for these types, show len() instead of data:
869 # for these types, show len() instead of data:
870 seq_types = [types.DictType,types.ListType,types.TupleType]
870 seq_types = [types.DictType,types.ListType,types.TupleType]
871
871
872 # for Numeric arrays, display summary info
872 # for Numeric arrays, display summary info
873 try:
873 try:
874 import Numeric
874 import Numeric
875 except ImportError:
875 except ImportError:
876 array_type = None
876 array_type = None
877 else:
877 else:
878 array_type = Numeric.ArrayType.__name__
878 array_type = Numeric.ArrayType.__name__
879
879
880 # Find all variable names and types so we can figure out column sizes
880 # Find all variable names and types so we can figure out column sizes
881 get_vars = lambda i: self.shell.user_ns[i]
881 get_vars = lambda i: self.shell.user_ns[i]
882 type_name = lambda v: type(v).__name__
882 type_name = lambda v: type(v).__name__
883 varlist = map(get_vars,varnames)
883 varlist = map(get_vars,varnames)
884 typelist = map(type_name,varlist)
884 typelist = map(type_name,varlist)
885 # column labels and # of spaces as separator
885 # column labels and # of spaces as separator
886 varlabel = 'Variable'
886 varlabel = 'Variable'
887 typelabel = 'Type'
887 typelabel = 'Type'
888 datalabel = 'Data/Info'
888 datalabel = 'Data/Info'
889 colsep = 3
889 colsep = 3
890 # variable format strings
890 # variable format strings
891 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
891 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
892 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
892 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
893 aformat = "%s: %s elems, type `%s`, %s bytes"
893 aformat = "%s: %s elems, type `%s`, %s bytes"
894 # find the size of the columns to format the output nicely
894 # find the size of the columns to format the output nicely
895 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
895 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
896 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
896 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
897 # table header
897 # table header
898 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
898 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
899 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
899 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
900 # and the table itself
900 # and the table itself
901 kb = 1024
901 kb = 1024
902 Mb = 1048576 # kb**2
902 Mb = 1048576 # kb**2
903 for vname,var,vtype in zip(varnames,varlist,typelist):
903 for vname,var,vtype in zip(varnames,varlist,typelist):
904 print itpl(vformat),
904 print itpl(vformat),
905 if vtype in seq_types:
905 if vtype in seq_types:
906 print len(var)
906 print len(var)
907 elif vtype==array_type:
907 elif vtype==array_type:
908 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
908 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
909 vsize = Numeric.size(var)
909 vsize = Numeric.size(var)
910 vbytes = vsize*var.itemsize()
910 vbytes = vsize*var.itemsize()
911 if vbytes < 100000:
911 if vbytes < 100000:
912 print aformat % (vshape,vsize,var.typecode(),vbytes)
912 print aformat % (vshape,vsize,var.typecode(),vbytes)
913 else:
913 else:
914 print aformat % (vshape,vsize,var.typecode(),vbytes),
914 print aformat % (vshape,vsize,var.typecode(),vbytes),
915 if vbytes < Mb:
915 if vbytes < Mb:
916 print '(%s kb)' % (vbytes/kb,)
916 print '(%s kb)' % (vbytes/kb,)
917 else:
917 else:
918 print '(%s Mb)' % (vbytes/Mb,)
918 print '(%s Mb)' % (vbytes/Mb,)
919 else:
919 else:
920 vstr = str(var)
920 vstr = str(var)
921 if len(vstr) < 50:
921 if len(vstr) < 50:
922 print vstr
922 print vstr
923 else:
923 else:
924 printpl(vfmt_short)
924 printpl(vfmt_short)
925
925
926 def magic_reset(self, parameter_s=''):
926 def magic_reset(self, parameter_s=''):
927 """Resets the namespace by removing all names defined by the user.
927 """Resets the namespace by removing all names defined by the user.
928
928
929 Input/Output history are left around in case you need them."""
929 Input/Output history are left around in case you need them."""
930
930
931 ans = raw_input(
931 ans = raw_input(
932 "Once deleted, variables cannot be recovered. Proceed (y/n)? ")
932 "Once deleted, variables cannot be recovered. Proceed (y/n)? ")
933 if not ans.lower() == 'y':
933 if not ans.lower() == 'y':
934 print 'Nothing done.'
934 print 'Nothing done.'
935 return
935 return
936 user_ns = self.shell.user_ns
936 user_ns = self.shell.user_ns
937 for i in self.magic_who_ls():
937 for i in self.magic_who_ls():
938 del(user_ns[i])
938 del(user_ns[i])
939
939
940 def magic_config(self,parameter_s=''):
940 def magic_config(self,parameter_s=''):
941 """Show IPython's internal configuration."""
941 """Show IPython's internal configuration."""
942
942
943 page('Current configuration structure:\n'+
943 page('Current configuration structure:\n'+
944 pformat(self.shell.rc.dict()))
944 pformat(self.shell.rc.dict()))
945
945
946 def magic_logstart(self,parameter_s=''):
946 def magic_logstart(self,parameter_s=''):
947 """Start logging anywhere in a session.
947 """Start logging anywhere in a session.
948
948
949 %logstart [log_name [log_mode]]
949 %logstart [log_name [log_mode]]
950
950
951 If no name is given, it defaults to a file named 'ipython.log' in your
951 If no name is given, it defaults to a file named 'ipython.log' in your
952 current directory, in 'rotate' mode (see below).
952 current directory, in 'rotate' mode (see below).
953
953
954 '%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
955 history up to that point and then continues logging.
955 history up to that point and then continues logging.
956
956
957 %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
958 of (note that the modes are given unquoted):\\
958 of (note that the modes are given unquoted):\\
959 over: overwrite existing log.\\
959 over: overwrite existing log.\\
960 backup: rename (if exists) to name~ and start name.\\
960 backup: rename (if exists) to name~ and start name.\\
961 append: well, that says it.\\
961 append: well, that says it.\\
962 rotate: create rotating logs name.1~, name.2~, etc.
962 rotate: create rotating logs name.1~, name.2~, etc.
963 """
963 """
964
964
965 #FIXME. This function should all be moved to the Logger class.
965 #FIXME. This function should all be moved to the Logger class.
966
966
967 valid_modes = qw('over backup append rotate')
967 valid_modes = qw('over backup append rotate')
968 if self.LOG:
968 if self.LOG:
969 print 'Logging is already in place. Logfile:',self.LOG
969 print 'Logging is already in place. Logfile:',self.LOG
970 return
970 return
971
971
972 par = parameter_s.strip()
972 par = parameter_s.strip()
973 if not par:
973 if not par:
974 logname = self.LOGDEF
974 logname = self.LOGDEF
975 logmode = 'rotate' # use rotate for the auto-generated logs
975 logmode = 'rotate' # use rotate for the auto-generated logs
976 else:
976 else:
977 try:
977 try:
978 logname,logmode = par.split()
978 logname,logmode = par.split()
979 except:
979 except:
980 try:
980 try:
981 logname = par
981 logname = par
982 logmode = 'backup'
982 logmode = 'backup'
983 except:
983 except:
984 warn('Usage: %log [log_name [log_mode]]')
984 warn('Usage: %log [log_name [log_mode]]')
985 return
985 return
986 if not logmode in valid_modes:
986 if not logmode in valid_modes:
987 warn('Logging NOT activated.\n'
987 warn('Logging NOT activated.\n'
988 'Usage: %log [log_name [log_mode]]\n'
988 'Usage: %log [log_name [log_mode]]\n'
989 'Valid modes: '+str(valid_modes))
989 'Valid modes: '+str(valid_modes))
990 return
990 return
991
991
992 # If we made it this far, I think we're ok:
992 # If we made it this far, I think we're ok:
993 print 'Activating auto-logging.'
993 print 'Activating auto-logging.'
994 print 'Current session state plus future input saved to:',logname
994 print 'Current session state plus future input saved to:',logname
995 print 'Logging mode: ',logmode
995 print 'Logging mode: ',logmode
996 # put logname into rc struct as if it had been called on the command line,
996 # put logname into rc struct as if it had been called on the command line,
997 # so it ends up saved in the log header
997 # so it ends up saved in the log header
998 # Save it in case we need to restore it...
998 # Save it in case we need to restore it...
999 old_logfile = self.shell.rc.opts.get('logfile','')
999 old_logfile = self.shell.rc.opts.get('logfile','')
1000 logname = os.path.expanduser(logname)
1000 logname = os.path.expanduser(logname)
1001 self.shell.rc.opts.logfile = logname
1001 self.shell.rc.opts.logfile = logname
1002 self.LOGMODE = logmode # FIXME: this should be set through a function.
1002 self.LOGMODE = logmode # FIXME: this should be set through a function.
1003 try:
1003 try:
1004 header = str(self.LOGHEAD)
1004 header = str(self.LOGHEAD)
1005 self.create_log(header,logname)
1005 self.create_log(header,logname)
1006 self.logstart(header,logname)
1006 self.logstart(header,logname)
1007 except:
1007 except:
1008 self.LOG = '' # we are NOT logging, something went wrong
1008 self.LOG = '' # we are NOT logging, something went wrong
1009 self.shell.rc.opts.logfile = old_logfile
1009 self.shell.rc.opts.logfile = old_logfile
1010 warn("Couldn't start log: "+str(sys.exc_info()[1]))
1010 warn("Couldn't start log: "+str(sys.exc_info()[1]))
1011 else: # log input history up to this point
1011 else: # log input history up to this point
1012 self.logfile.write(self.shell.user_ns['_ih'][1:])
1012 self.logfile.write(self.shell.user_ns['_ih'][1:])
1013 self.logfile.flush()
1013 self.logfile.flush()
1014
1014
1015 def magic_logoff(self,parameter_s=''):
1015 def magic_logoff(self,parameter_s=''):
1016 """Temporarily stop logging.
1016 """Temporarily stop logging.
1017
1017
1018 You must have previously started logging."""
1018 You must have previously started logging."""
1019 self.switch_log(0)
1019 self.switch_log(0)
1020
1020
1021 def magic_logon(self,parameter_s=''):
1021 def magic_logon(self,parameter_s=''):
1022 """Restart logging.
1022 """Restart logging.
1023
1023
1024 This function is for restarting logging which you've temporarily
1024 This function is for restarting logging which you've temporarily
1025 stopped with %logoff. For starting logging for the first time, you
1025 stopped with %logoff. For starting logging for the first time, you
1026 must use the %logstart function, which allows you to specify an
1026 must use the %logstart function, which allows you to specify an
1027 optional log filename."""
1027 optional log filename."""
1028
1028
1029 self.switch_log(1)
1029 self.switch_log(1)
1030
1030
1031 def magic_logstate(self,parameter_s=''):
1031 def magic_logstate(self,parameter_s=''):
1032 """Print the status of the logging system."""
1032 """Print the status of the logging system."""
1033
1033
1034 self.logstate()
1034 self.logstate()
1035
1035
1036 def magic_pdb(self, parameter_s=''):
1036 def magic_pdb(self, parameter_s=''):
1037 """Control the calling of the pdb interactive debugger.
1037 """Control the calling of the pdb interactive debugger.
1038
1038
1039 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1039 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1040 argument it works as a toggle.
1040 argument it works as a toggle.
1041
1041
1042 When an exception is triggered, IPython can optionally call the
1042 When an exception is triggered, IPython can optionally call the
1043 interactive pdb debugger after the traceback printout. %pdb toggles
1043 interactive pdb debugger after the traceback printout. %pdb toggles
1044 this feature on and off."""
1044 this feature on and off."""
1045
1045
1046 par = parameter_s.strip().lower()
1046 par = parameter_s.strip().lower()
1047
1047
1048 if par:
1048 if par:
1049 try:
1049 try:
1050 pdb = {'off':0,'0':0,'on':1,'1':1}[par]
1050 pdb = {'off':0,'0':0,'on':1,'1':1}[par]
1051 except KeyError:
1051 except KeyError:
1052 print 'Incorrect argument. Use on/1, off/0 or nothing for a toggle.'
1052 print 'Incorrect argument. Use on/1, off/0 or nothing for a toggle.'
1053 return
1053 return
1054 else:
1054 else:
1055 self.shell.InteractiveTB.call_pdb = pdb
1055 self.shell.InteractiveTB.call_pdb = pdb
1056 else:
1056 else:
1057 self.shell.InteractiveTB.call_pdb = 1 - self.shell.InteractiveTB.call_pdb
1057 self.shell.InteractiveTB.call_pdb = 1 - self.shell.InteractiveTB.call_pdb
1058 print 'Automatic pdb calling has been turned',\
1058 print 'Automatic pdb calling has been turned',\
1059 on_off(self.shell.InteractiveTB.call_pdb)
1059 on_off(self.shell.InteractiveTB.call_pdb)
1060
1060
1061
1061
1062 def magic_prun(self, parameter_s ='',user_mode=1,
1062 def magic_prun(self, parameter_s ='',user_mode=1,
1063 opts=None,arg_lst=None,prog_ns=None):
1063 opts=None,arg_lst=None,prog_ns=None):
1064
1064
1065 """Run a statement through the python code profiler.
1065 """Run a statement through the python code profiler.
1066
1066
1067 Usage:\\
1067 Usage:\\
1068 %prun [options] statement
1068 %prun [options] statement
1069
1069
1070 The given statement (which doesn't require quote marks) is run via the
1070 The given statement (which doesn't require quote marks) is run via the
1071 python profiler in a manner similar to the profile.run() function.
1071 python profiler in a manner similar to the profile.run() function.
1072 Namespaces are internally managed to work correctly; profile.run
1072 Namespaces are internally managed to work correctly; profile.run
1073 cannot be used in IPython because it makes certain assumptions about
1073 cannot be used in IPython because it makes certain assumptions about
1074 namespaces which do not hold under IPython.
1074 namespaces which do not hold under IPython.
1075
1075
1076 Options:
1076 Options:
1077
1077
1078 -l <limit>: you can place restrictions on what or how much of the
1078 -l <limit>: you can place restrictions on what or how much of the
1079 profile gets printed. The limit value can be:
1079 profile gets printed. The limit value can be:
1080
1080
1081 * A string: only information for function names containing this string
1081 * A string: only information for function names containing this string
1082 is printed.
1082 is printed.
1083
1083
1084 * An integer: only these many lines are printed.
1084 * An integer: only these many lines are printed.
1085
1085
1086 * A float (between 0 and 1): this fraction of the report is printed
1086 * A float (between 0 and 1): this fraction of the report is printed
1087 (for example, use a limit of 0.4 to see the topmost 40% only).
1087 (for example, use a limit of 0.4 to see the topmost 40% only).
1088
1088
1089 You can combine several limits with repeated use of the option. For
1089 You can combine several limits with repeated use of the option. For
1090 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1090 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1091 information about class constructors.
1091 information about class constructors.
1092
1092
1093 -r: return the pstats.Stats object generated by the profiling. This
1093 -r: return the pstats.Stats object generated by the profiling. This
1094 object has all the information about the profile in it, and you can
1094 object has all the information about the profile in it, and you can
1095 later use it for further analysis or in other functions.
1095 later use it for further analysis or in other functions.
1096
1096
1097 Since magic functions have a particular form of calling which prevents
1097 Since magic functions have a particular form of calling which prevents
1098 you from writing something like:\\
1098 you from writing something like:\\
1099 In [1]: p = %prun -r print 4 # invalid!\\
1099 In [1]: p = %prun -r print 4 # invalid!\\
1100 you must instead use IPython's automatic variables to assign this:\\
1100 you must instead use IPython's automatic variables to assign this:\\
1101 In [1]: %prun -r print 4 \\
1101 In [1]: %prun -r print 4 \\
1102 Out[1]: <pstats.Stats instance at 0x8222cec>\\
1102 Out[1]: <pstats.Stats instance at 0x8222cec>\\
1103 In [2]: stats = _
1103 In [2]: stats = _
1104
1104
1105 If you really need to assign this value via an explicit function call,
1105 If you really need to assign this value via an explicit function call,
1106 you can always tap directly into the true name of the magic function
1106 you can always tap directly into the true name of the magic function
1107 by using the ipmagic function (which IPython automatically adds to the
1107 by using the ipmagic function (which IPython automatically adds to the
1108 builtins):\\
1108 builtins):\\
1109 In [3]: stats = ipmagic('prun','-r print 4')
1109 In [3]: stats = ipmagic('prun','-r print 4')
1110
1110
1111 You can type ipmagic? for more details on ipmagic.
1111 You can type ipmagic? for more details on ipmagic.
1112
1112
1113 -s <key>: sort profile by given key. You can provide more than one key
1113 -s <key>: sort profile by given key. You can provide more than one key
1114 by using the option several times: '-s key1 -s key2 -s key3...'. The
1114 by using the option several times: '-s key1 -s key2 -s key3...'. The
1115 default sorting key is 'time'.
1115 default sorting key is 'time'.
1116
1116
1117 The following is copied verbatim from the profile documentation
1117 The following is copied verbatim from the profile documentation
1118 referenced below:
1118 referenced below:
1119
1119
1120 When more than one key is provided, additional keys are used as
1120 When more than one key is provided, additional keys are used as
1121 secondary criteria when the there is equality in all keys selected
1121 secondary criteria when the there is equality in all keys selected
1122 before them.
1122 before them.
1123
1123
1124 Abbreviations can be used for any key names, as long as the
1124 Abbreviations can be used for any key names, as long as the
1125 abbreviation is unambiguous. The following are the keys currently
1125 abbreviation is unambiguous. The following are the keys currently
1126 defined:
1126 defined:
1127
1127
1128 Valid Arg Meaning\\
1128 Valid Arg Meaning\\
1129 "calls" call count\\
1129 "calls" call count\\
1130 "cumulative" cumulative time\\
1130 "cumulative" cumulative time\\
1131 "file" file name\\
1131 "file" file name\\
1132 "module" file name\\
1132 "module" file name\\
1133 "pcalls" primitive call count\\
1133 "pcalls" primitive call count\\
1134 "line" line number\\
1134 "line" line number\\
1135 "name" function name\\
1135 "name" function name\\
1136 "nfl" name/file/line\\
1136 "nfl" name/file/line\\
1137 "stdname" standard name\\
1137 "stdname" standard name\\
1138 "time" internal time
1138 "time" internal time
1139
1139
1140 Note that all sorts on statistics are in descending order (placing
1140 Note that all sorts on statistics are in descending order (placing
1141 most time consuming items first), where as name, file, and line number
1141 most time consuming items first), where as name, file, and line number
1142 searches are in ascending order (i.e., alphabetical). The subtle
1142 searches are in ascending order (i.e., alphabetical). The subtle
1143 distinction between "nfl" and "stdname" is that the standard name is a
1143 distinction between "nfl" and "stdname" is that the standard name is a
1144 sort of the name as printed, which means that the embedded line
1144 sort of the name as printed, which means that the embedded line
1145 numbers get compared in an odd way. For example, lines 3, 20, and 40
1145 numbers get compared in an odd way. For example, lines 3, 20, and 40
1146 would (if the file names were the same) appear in the string order
1146 would (if the file names were the same) appear in the string order
1147 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1147 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1148 line numbers. In fact, sort_stats("nfl") is the same as
1148 line numbers. In fact, sort_stats("nfl") is the same as
1149 sort_stats("name", "file", "line").
1149 sort_stats("name", "file", "line").
1150
1150
1151 -T <filename>: save profile results as shown on screen to a text
1151 -T <filename>: save profile results as shown on screen to a text
1152 file. The profile is still shown on screen.
1152 file. The profile is still shown on screen.
1153
1153
1154 -D <filename>: save (via dump_stats) profile statistics to given
1154 -D <filename>: save (via dump_stats) profile statistics to given
1155 filename. This data is in a format understod by the pstats module, and
1155 filename. This data is in a format understod by the pstats module, and
1156 is generated by a call to the dump_stats() method of profile
1156 is generated by a call to the dump_stats() method of profile
1157 objects. The profile is still shown on screen.
1157 objects. The profile is still shown on screen.
1158
1158
1159 If you want to run complete programs under the profiler's control, use
1159 If you want to run complete programs under the profiler's control, use
1160 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1160 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1161 contains profiler specific options as described here.
1161 contains profiler specific options as described here.
1162
1162
1163 You can read the complete documentation for the profile module with:\\
1163 You can read the complete documentation for the profile module with:\\
1164 In [1]: import profile; profile.help() """
1164 In [1]: import profile; profile.help() """
1165
1165
1166 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1166 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1167 # protect user quote marks
1167 # protect user quote marks
1168 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1168 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1169
1169
1170 if user_mode: # regular user call
1170 if user_mode: # regular user call
1171 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1171 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1172 list_all=1)
1172 list_all=1)
1173 namespace = self.shell.user_ns
1173 namespace = self.shell.user_ns
1174 else: # called to run a program by %run -p
1174 else: # called to run a program by %run -p
1175 try:
1175 try:
1176 filename = get_py_filename(arg_lst[0])
1176 filename = get_py_filename(arg_lst[0])
1177 except IOError,msg:
1177 except IOError,msg:
1178 error(msg)
1178 error(msg)
1179 return
1179 return
1180
1180
1181 arg_str = 'execfile(filename,prog_ns)'
1181 arg_str = 'execfile(filename,prog_ns)'
1182 namespace = locals()
1182 namespace = locals()
1183
1183
1184 opts.merge(opts_def)
1184 opts.merge(opts_def)
1185
1185
1186 prof = profile.Profile()
1186 prof = profile.Profile()
1187 try:
1187 try:
1188 prof = prof.runctx(arg_str,namespace,namespace)
1188 prof = prof.runctx(arg_str,namespace,namespace)
1189 sys_exit = ''
1189 sys_exit = ''
1190 except SystemExit:
1190 except SystemExit:
1191 sys_exit = """*** SystemExit exception caught in code being profiled."""
1191 sys_exit = """*** SystemExit exception caught in code being profiled."""
1192
1192
1193 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1193 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1194
1194
1195 lims = opts.l
1195 lims = opts.l
1196 if lims:
1196 if lims:
1197 lims = [] # rebuild lims with ints/floats/strings
1197 lims = [] # rebuild lims with ints/floats/strings
1198 for lim in opts.l:
1198 for lim in opts.l:
1199 try:
1199 try:
1200 lims.append(int(lim))
1200 lims.append(int(lim))
1201 except ValueError:
1201 except ValueError:
1202 try:
1202 try:
1203 lims.append(float(lim))
1203 lims.append(float(lim))
1204 except ValueError:
1204 except ValueError:
1205 lims.append(lim)
1205 lims.append(lim)
1206
1206
1207 # trap output
1207 # trap output
1208 sys_stdout = sys.stdout
1208 sys_stdout = sys.stdout
1209 stdout_trap = StringIO()
1209 stdout_trap = StringIO()
1210 try:
1210 try:
1211 sys.stdout = stdout_trap
1211 sys.stdout = stdout_trap
1212 stats.print_stats(*lims)
1212 stats.print_stats(*lims)
1213 finally:
1213 finally:
1214 sys.stdout = sys_stdout
1214 sys.stdout = sys_stdout
1215 output = stdout_trap.getvalue()
1215 output = stdout_trap.getvalue()
1216 output = output.rstrip()
1216 output = output.rstrip()
1217
1217
1218 page(output,screen_lines=self.shell.rc.screen_length)
1218 page(output,screen_lines=self.shell.rc.screen_length)
1219 print sys_exit,
1219 print sys_exit,
1220
1220
1221 dump_file = opts.D[0]
1221 dump_file = opts.D[0]
1222 text_file = opts.T[0]
1222 text_file = opts.T[0]
1223 if dump_file:
1223 if dump_file:
1224 prof.dump_stats(dump_file)
1224 prof.dump_stats(dump_file)
1225 print '\n*** Profile stats marshalled to file',\
1225 print '\n*** Profile stats marshalled to file',\
1226 `dump_file`+'.',sys_exit
1226 `dump_file`+'.',sys_exit
1227 if text_file:
1227 if text_file:
1228 file(text_file,'w').write(output)
1228 file(text_file,'w').write(output)
1229 print '\n*** Profile printout saved to text file',\
1229 print '\n*** Profile printout saved to text file',\
1230 `text_file`+'.',sys_exit
1230 `text_file`+'.',sys_exit
1231
1231
1232 if opts.has_key('r'):
1232 if opts.has_key('r'):
1233 return stats
1233 return stats
1234 else:
1234 else:
1235 return None
1235 return None
1236
1236
1237 def magic_run(self, parameter_s ='',runner=None):
1237 def magic_run(self, parameter_s ='',runner=None):
1238 """Run the named file inside IPython as a program.
1238 """Run the named file inside IPython as a program.
1239
1239
1240 Usage:\\
1240 Usage:\\
1241 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1241 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1242
1242
1243 Parameters after the filename are passed as command-line arguments to
1243 Parameters after the filename are passed as command-line arguments to
1244 the program (put in sys.argv). Then, control returns to IPython's
1244 the program (put in sys.argv). Then, control returns to IPython's
1245 prompt.
1245 prompt.
1246
1246
1247 This is similar to running at a system prompt:\\
1247 This is similar to running at a system prompt:\\
1248 $ python file args\\
1248 $ python file args\\
1249 but with the advantage of giving you IPython's tracebacks, and of
1249 but with the advantage of giving you IPython's tracebacks, and of
1250 loading all variables into your interactive namespace for further use
1250 loading all variables into your interactive namespace for further use
1251 (unless -p is used, see below).
1251 (unless -p is used, see below).
1252
1252
1253 The file is executed in a namespace initially consisting only of
1253 The file is executed in a namespace initially consisting only of
1254 __name__=='__main__' and sys.argv constructed as indicated. It thus
1254 __name__=='__main__' and sys.argv constructed as indicated. It thus
1255 sees its environment as if it were being run as a stand-alone
1255 sees its environment as if it were being run as a stand-alone
1256 program. But after execution, the IPython interactive namespace gets
1256 program. But after execution, the IPython interactive namespace gets
1257 updated with all variables defined in the program (except for __name__
1257 updated with all variables defined in the program (except for __name__
1258 and sys.argv). This allows for very convenient loading of code for
1258 and sys.argv). This allows for very convenient loading of code for
1259 interactive work, while giving each program a 'clean sheet' to run in.
1259 interactive work, while giving each program a 'clean sheet' to run in.
1260
1260
1261 Options:
1261 Options:
1262
1262
1263 -n: __name__ is NOT set to '__main__', but to the running file's name
1263 -n: __name__ is NOT set to '__main__', but to the running file's name
1264 without extension (as python does under import). This allows running
1264 without extension (as python does under import). This allows running
1265 scripts and reloading the definitions in them without calling code
1265 scripts and reloading the definitions in them without calling code
1266 protected by an ' if __name__ == "__main__" ' clause.
1266 protected by an ' if __name__ == "__main__" ' clause.
1267
1267
1268 -i: run the file in IPython's namespace instead of an empty one. This
1268 -i: run the file in IPython's namespace instead of an empty one. This
1269 is useful if you are experimenting with code written in a text editor
1269 is useful if you are experimenting with code written in a text editor
1270 which depends on variables defined interactively.
1270 which depends on variables defined interactively.
1271
1271
1272 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1272 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1273 being run. This is particularly useful if IPython is being used to
1273 being run. This is particularly useful if IPython is being used to
1274 run unittests, which always exit with a sys.exit() call. In such
1274 run unittests, which always exit with a sys.exit() call. In such
1275 cases you are interested in the output of the test results, not in
1275 cases you are interested in the output of the test results, not in
1276 seeing a traceback of the unittest module.
1276 seeing a traceback of the unittest module.
1277
1277
1278 -t: print timing information at the end of the run. IPython will give
1278 -t: print timing information at the end of the run. IPython will give
1279 you an estimated CPU time consumption for your script, which under
1279 you an estimated CPU time consumption for your script, which under
1280 Unix uses the resource module to avoid the wraparound problems of
1280 Unix uses the resource module to avoid the wraparound problems of
1281 time.clock(). Under Unix, an estimate of time spent on system tasks
1281 time.clock(). Under Unix, an estimate of time spent on system tasks
1282 is also given (for Windows platforms this is reported as 0.0).
1282 is also given (for Windows platforms this is reported as 0.0).
1283
1283
1284 If -t is given, an additional -N<N> option can be given, where <N>
1284 If -t is given, an additional -N<N> option can be given, where <N>
1285 must be an integer indicating how many times you want the script to
1285 must be an integer indicating how many times you want the script to
1286 run. The final timing report will include total and per run results.
1286 run. The final timing report will include total and per run results.
1287
1287
1288 For example (testing the script uniq_stable.py):
1288 For example (testing the script uniq_stable.py):
1289
1289
1290 In [1]: run -t uniq_stable
1290 In [1]: run -t uniq_stable
1291
1291
1292 IPython CPU timings (estimated):\\
1292 IPython CPU timings (estimated):\\
1293 User : 0.19597 s.\\
1293 User : 0.19597 s.\\
1294 System: 0.0 s.\\
1294 System: 0.0 s.\\
1295
1295
1296 In [2]: run -t -N5 uniq_stable
1296 In [2]: run -t -N5 uniq_stable
1297
1297
1298 IPython CPU timings (estimated):\\
1298 IPython CPU timings (estimated):\\
1299 Total runs performed: 5\\
1299 Total runs performed: 5\\
1300 Times : Total Per run\\
1300 Times : Total Per run\\
1301 User : 0.910862 s, 0.1821724 s.\\
1301 User : 0.910862 s, 0.1821724 s.\\
1302 System: 0.0 s, 0.0 s.
1302 System: 0.0 s, 0.0 s.
1303
1303
1304 -d: run your program under the control of pdb, the Python debugger.
1304 -d: run your program under the control of pdb, the Python debugger.
1305 This allows you to execute your program step by step, watch variables,
1305 This allows you to execute your program step by step, watch variables,
1306 etc. Internally, what IPython does is similar to calling:
1306 etc. Internally, what IPython does is similar to calling:
1307
1307
1308 pdb.run('execfile("YOURFILENAME")')
1308 pdb.run('execfile("YOURFILENAME")')
1309
1309
1310 with a breakpoint set on line 1 of your file. You can change the line
1310 with a breakpoint set on line 1 of your file. You can change the line
1311 number for this automatic breakpoint to be <N> by using the -bN option
1311 number for this automatic breakpoint to be <N> by using the -bN option
1312 (where N must be an integer). For example:
1312 (where N must be an integer). For example:
1313
1313
1314 %run -d -b40 myscript
1314 %run -d -b40 myscript
1315
1315
1316 will set the first breakpoint at line 40 in myscript.py. Note that
1316 will set the first breakpoint at line 40 in myscript.py. Note that
1317 the first breakpoint must be set on a line which actually does
1317 the first breakpoint must be set on a line which actually does
1318 something (not a comment or docstring) for it to stop execution.
1318 something (not a comment or docstring) for it to stop execution.
1319
1319
1320 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1320 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1321 first enter 'c' (without qoutes) to start execution up to the first
1321 first enter 'c' (without qoutes) to start execution up to the first
1322 breakpoint.
1322 breakpoint.
1323
1323
1324 Entering 'help' gives information about the use of the debugger. You
1324 Entering 'help' gives information about the use of the debugger. You
1325 can easily see pdb's full documentation with "import pdb;pdb.help()"
1325 can easily see pdb's full documentation with "import pdb;pdb.help()"
1326 at a prompt.
1326 at a prompt.
1327
1327
1328 -p: run program under the control of the Python profiler module (which
1328 -p: run program under the control of the Python profiler module (which
1329 prints a detailed report of execution times, function calls, etc).
1329 prints a detailed report of execution times, function calls, etc).
1330
1330
1331 You can pass other options after -p which affect the behavior of the
1331 You can pass other options after -p which affect the behavior of the
1332 profiler itself. See the docs for %prun for details.
1332 profiler itself. See the docs for %prun for details.
1333
1333
1334 In this mode, the program's variables do NOT propagate back to the
1334 In this mode, the program's variables do NOT propagate back to the
1335 IPython interactive namespace (because they remain in the namespace
1335 IPython interactive namespace (because they remain in the namespace
1336 where the profiler executes them).
1336 where the profiler executes them).
1337
1337
1338 Internally this triggers a call to %prun, see its documentation for
1338 Internally this triggers a call to %prun, see its documentation for
1339 details on the options available specifically for profiling."""
1339 details on the options available specifically for profiling."""
1340
1340
1341 # get arguments and set sys.argv for program to be run.
1341 # get arguments and set sys.argv for program to be run.
1342 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1342 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1343 mode='list',list_all=1)
1343 mode='list',list_all=1)
1344
1344
1345 try:
1345 try:
1346 filename = get_py_filename(arg_lst[0])
1346 filename = get_py_filename(arg_lst[0])
1347 except IndexError:
1347 except IndexError:
1348 warn('you must provide at least a filename.')
1348 warn('you must provide at least a filename.')
1349 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1349 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1350 return
1350 return
1351 except IOError,msg:
1351 except IOError,msg:
1352 error(msg)
1352 error(msg)
1353 return
1353 return
1354
1354
1355 # Control the response to exit() calls made by the script being run
1355 # Control the response to exit() calls made by the script being run
1356 exit_ignore = opts.has_key('e')
1356 exit_ignore = opts.has_key('e')
1357
1357
1358 # Make sure that the running script gets a proper sys.argv as if it
1358 # Make sure that the running script gets a proper sys.argv as if it
1359 # were run from a system shell.
1359 # were run from a system shell.
1360 save_argv = sys.argv # save it for later restoring
1360 save_argv = sys.argv # save it for later restoring
1361 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1361 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1362
1362
1363 if opts.has_key('i'):
1363 if opts.has_key('i'):
1364 prog_ns = self.shell.user_ns
1364 prog_ns = self.shell.user_ns
1365 __name__save = self.shell.user_ns['__name__']
1365 __name__save = self.shell.user_ns['__name__']
1366 prog_ns['__name__'] = '__main__'
1366 prog_ns['__name__'] = '__main__'
1367 else:
1367 else:
1368 if opts.has_key('n'):
1368 if opts.has_key('n'):
1369 name = os.path.splitext(os.path.basename(filename))[0]
1369 name = os.path.splitext(os.path.basename(filename))[0]
1370 else:
1370 else:
1371 name = '__main__'
1371 name = '__main__'
1372 prog_ns = {'__name__':name}
1372 prog_ns = {'__name__':name}
1373
1373
1374 # pickle fix. See iplib for an explanation
1374 # pickle fix. See iplib for an explanation
1375 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1375 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1376
1376
1377 stats = None
1377 stats = None
1378 try:
1378 try:
1379 if opts.has_key('p'):
1379 if opts.has_key('p'):
1380 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1380 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1381 else:
1381 else:
1382 if opts.has_key('d'):
1382 if opts.has_key('d'):
1383 deb = Debugger.Pdb(self.shell.rc.colors)
1383 deb = Debugger.Pdb(self.shell.rc.colors)
1384 # reset Breakpoint state, which is moronically kept
1384 # reset Breakpoint state, which is moronically kept
1385 # in a class
1385 # in a class
1386 bdb.Breakpoint.next = 1
1386 bdb.Breakpoint.next = 1
1387 bdb.Breakpoint.bplist = {}
1387 bdb.Breakpoint.bplist = {}
1388 bdb.Breakpoint.bpbynumber = [None]
1388 bdb.Breakpoint.bpbynumber = [None]
1389 # Set an initial breakpoint to stop execution
1389 # Set an initial breakpoint to stop execution
1390 maxtries = 10
1390 maxtries = 10
1391 bp = int(opts.get('b',[1])[0])
1391 bp = int(opts.get('b',[1])[0])
1392 checkline = deb.checkline(filename,bp)
1392 checkline = deb.checkline(filename,bp)
1393 if not checkline:
1393 if not checkline:
1394 for bp in range(bp+1,bp+maxtries+1):
1394 for bp in range(bp+1,bp+maxtries+1):
1395 if deb.checkline(filename,bp):
1395 if deb.checkline(filename,bp):
1396 break
1396 break
1397 else:
1397 else:
1398 msg = ("\nI failed to find a valid line to set "
1398 msg = ("\nI failed to find a valid line to set "
1399 "a breakpoint\n"
1399 "a breakpoint\n"
1400 "after trying up to line: %s.\n"
1400 "after trying up to line: %s.\n"
1401 "Please set a valid breakpoint manually "
1401 "Please set a valid breakpoint manually "
1402 "with the -b option." % bp)
1402 "with the -b option." % bp)
1403 error(msg)
1403 error(msg)
1404 return
1404 return
1405 # if we find a good linenumber, set the breakpoint
1405 # if we find a good linenumber, set the breakpoint
1406 deb.do_break('%s:%s' % (filename,bp))
1406 deb.do_break('%s:%s' % (filename,bp))
1407 # Start file run
1407 # Start file run
1408 print "NOTE: Enter 'c' at the",
1408 print "NOTE: Enter 'c' at the",
1409 print "ipdb> prompt to start your script."
1409 print "ipdb> prompt to start your script."
1410 try:
1410 try:
1411 deb.run('execfile("%s")' % filename,prog_ns)
1411 deb.run('execfile("%s")' % filename,prog_ns)
1412 except:
1412 except:
1413 etype, value, tb = sys.exc_info()
1413 etype, value, tb = sys.exc_info()
1414 # Skip three frames in the traceback: the %run one,
1414 # Skip three frames in the traceback: the %run one,
1415 # one inside bdb.py, and the command-line typed by the
1415 # one inside bdb.py, and the command-line typed by the
1416 # user (run by exec in pdb itself).
1416 # user (run by exec in pdb itself).
1417 self.shell.InteractiveTB(etype,value,tb,tb_offset=3)
1417 self.shell.InteractiveTB(etype,value,tb,tb_offset=3)
1418 else:
1418 else:
1419 if runner is None:
1419 if runner is None:
1420 runner = self.shell.safe_execfile
1420 runner = self.shell.safe_execfile
1421 if opts.has_key('t'):
1421 if opts.has_key('t'):
1422 try:
1422 try:
1423 nruns = int(opts['N'][0])
1423 nruns = int(opts['N'][0])
1424 if nruns < 1:
1424 if nruns < 1:
1425 error('Number of runs must be >=1')
1425 error('Number of runs must be >=1')
1426 return
1426 return
1427 except (KeyError):
1427 except (KeyError):
1428 nruns = 1
1428 nruns = 1
1429 if nruns == 1:
1429 if nruns == 1:
1430 t0 = clock2()
1430 t0 = clock2()
1431 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1431 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1432 t1 = clock2()
1432 t1 = clock2()
1433 t_usr = t1[0]-t0[0]
1433 t_usr = t1[0]-t0[0]
1434 t_sys = t1[1]-t1[1]
1434 t_sys = t1[1]-t1[1]
1435 print "\nIPython CPU timings (estimated):"
1435 print "\nIPython CPU timings (estimated):"
1436 print " User : %10s s." % t_usr
1436 print " User : %10s s." % t_usr
1437 print " System: %10s s." % t_sys
1437 print " System: %10s s." % t_sys
1438 else:
1438 else:
1439 runs = range(nruns)
1439 runs = range(nruns)
1440 t0 = clock2()
1440 t0 = clock2()
1441 for nr in runs:
1441 for nr in runs:
1442 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1442 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1443 t1 = clock2()
1443 t1 = clock2()
1444 t_usr = t1[0]-t0[0]
1444 t_usr = t1[0]-t0[0]
1445 t_sys = t1[1]-t1[1]
1445 t_sys = t1[1]-t1[1]
1446 print "\nIPython CPU timings (estimated):"
1446 print "\nIPython CPU timings (estimated):"
1447 print "Total runs performed:",nruns
1447 print "Total runs performed:",nruns
1448 print " Times : %10s %10s" % ('Total','Per run')
1448 print " Times : %10s %10s" % ('Total','Per run')
1449 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1449 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1450 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1450 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1451
1451
1452 else:
1452 else:
1453 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1453 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1454 if opts.has_key('i'):
1454 if opts.has_key('i'):
1455 self.shell.user_ns['__name__'] = __name__save
1455 self.shell.user_ns['__name__'] = __name__save
1456 else:
1456 else:
1457 # update IPython interactive namespace
1457 # update IPython interactive namespace
1458 del prog_ns['__name__']
1458 del prog_ns['__name__']
1459 self.shell.user_ns.update(prog_ns)
1459 self.shell.user_ns.update(prog_ns)
1460 finally:
1460 finally:
1461 sys.argv = save_argv
1461 sys.argv = save_argv
1462 return stats
1462 return stats
1463
1463
1464 def magic_runlog(self, parameter_s =''):
1464 def magic_runlog(self, parameter_s =''):
1465 """Run files as logs.
1465 """Run files as logs.
1466
1466
1467 Usage:\\
1467 Usage:\\
1468 %runlog file1 file2 ...
1468 %runlog file1 file2 ...
1469
1469
1470 Run the named files (treating them as log files) in sequence inside
1470 Run the named files (treating them as log files) in sequence inside
1471 the interpreter, and return to the prompt. This is much slower than
1471 the interpreter, and return to the prompt. This is much slower than
1472 %run because each line is executed in a try/except block, but it
1472 %run because each line is executed in a try/except block, but it
1473 allows running files with syntax errors in them.
1473 allows running files with syntax errors in them.
1474
1474
1475 Normally IPython will guess when a file is one of its own logfiles, so
1475 Normally IPython will guess when a file is one of its own logfiles, so
1476 you can typically use %run even for logs. This shorthand allows you to
1476 you can typically use %run even for logs. This shorthand allows you to
1477 force any file to be treated as a log file."""
1477 force any file to be treated as a log file."""
1478
1478
1479 for f in parameter_s.split():
1479 for f in parameter_s.split():
1480 self.shell.safe_execfile(f,self.shell.user_ns,
1480 self.shell.safe_execfile(f,self.shell.user_ns,
1481 self.shell.user_ns,islog=1)
1481 self.shell.user_ns,islog=1)
1482
1482
1483 def magic_time(self,parameter_s = ''):
1483 def magic_time(self,parameter_s = ''):
1484 """Time execution of a Python statement or expression.
1484 """Time execution of a Python statement or expression.
1485
1485
1486 The CPU and wall clock times are printed, and the value of the
1486 The CPU and wall clock times are printed, and the value of the
1487 expression (if any) is returned. Note that under Win32, system time
1487 expression (if any) is returned. Note that under Win32, system time
1488 is always reported as 0, since it can not be measured.
1488 is always reported as 0, since it can not be measured.
1489
1489
1490 This function provides very basic timing functionality. In Python
1490 This function provides very basic timing functionality. In Python
1491 2.3, the timeit module offers more control and sophistication, but for
1491 2.3, the timeit module offers more control and sophistication, but for
1492 now IPython supports Python 2.2, so we can not rely on timeit being
1492 now IPython supports Python 2.2, so we can not rely on timeit being
1493 present.
1493 present.
1494
1494
1495 Some examples:
1495 Some examples:
1496
1496
1497 In [1]: time 2**128
1497 In [1]: time 2**128
1498 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1498 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1499 Wall time: 0.00
1499 Wall time: 0.00
1500 Out[1]: 340282366920938463463374607431768211456L
1500 Out[1]: 340282366920938463463374607431768211456L
1501
1501
1502 In [2]: n = 1000000
1502 In [2]: n = 1000000
1503
1503
1504 In [3]: time sum(range(n))
1504 In [3]: time sum(range(n))
1505 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1505 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1506 Wall time: 1.37
1506 Wall time: 1.37
1507 Out[3]: 499999500000L
1507 Out[3]: 499999500000L
1508
1508
1509 In [4]: time print 'hello world'
1509 In [4]: time print 'hello world'
1510 hello world
1510 hello world
1511 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1511 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1512 Wall time: 0.00
1512 Wall time: 0.00
1513 """
1513 """
1514
1514
1515 # fail immediately if the given expression can't be compiled
1515 # fail immediately if the given expression can't be compiled
1516 try:
1516 try:
1517 mode = 'eval'
1517 mode = 'eval'
1518 code = compile(parameter_s,'<timed eval>',mode)
1518 code = compile(parameter_s,'<timed eval>',mode)
1519 except SyntaxError:
1519 except SyntaxError:
1520 mode = 'exec'
1520 mode = 'exec'
1521 code = compile(parameter_s,'<timed exec>',mode)
1521 code = compile(parameter_s,'<timed exec>',mode)
1522 # skew measurement as little as possible
1522 # skew measurement as little as possible
1523 glob = self.shell.user_ns
1523 glob = self.shell.user_ns
1524 clk = clock2
1524 clk = clock2
1525 wtime = time.time
1525 wtime = time.time
1526 # time execution
1526 # time execution
1527 wall_st = wtime()
1527 wall_st = wtime()
1528 if mode=='eval':
1528 if mode=='eval':
1529 st = clk()
1529 st = clk()
1530 out = eval(code,glob)
1530 out = eval(code,glob)
1531 end = clk()
1531 end = clk()
1532 else:
1532 else:
1533 st = clk()
1533 st = clk()
1534 exec code in glob
1534 exec code in glob
1535 end = clk()
1535 end = clk()
1536 out = None
1536 out = None
1537 wall_end = wtime()
1537 wall_end = wtime()
1538 # Compute actual times and report
1538 # Compute actual times and report
1539 wall_time = wall_end-wall_st
1539 wall_time = wall_end-wall_st
1540 cpu_user = end[0]-st[0]
1540 cpu_user = end[0]-st[0]
1541 cpu_sys = end[1]-st[1]
1541 cpu_sys = end[1]-st[1]
1542 cpu_tot = cpu_user+cpu_sys
1542 cpu_tot = cpu_user+cpu_sys
1543 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1543 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1544 (cpu_user,cpu_sys,cpu_tot)
1544 (cpu_user,cpu_sys,cpu_tot)
1545 print "Wall time: %.2f" % wall_time
1545 print "Wall time: %.2f" % wall_time
1546 return out
1546 return out
1547
1547
1548 def magic_macro(self,parameter_s = ''):
1548 def magic_macro(self,parameter_s = ''):
1549 """Define a set of input lines as a macro for future re-execution.
1549 """Define a set of input lines as a macro for future re-execution.
1550
1550
1551 Usage:\\
1551 Usage:\\
1552 %macro name n1:n2 n3:n4 ... n5 .. n6 ...
1552 %macro name n1:n2 n3:n4 ... n5 .. n6 ...
1553
1553
1554 This will define a global variable called `name` which is a string
1554 This will define a global variable called `name` which is a string
1555 made of joining the slices and lines you specify (n1,n2,... numbers
1555 made of joining the slices and lines you specify (n1,n2,... numbers
1556 above) from your input history into a single string. This variable
1556 above) from your input history into a single string. This variable
1557 acts like an automatic function which re-executes those lines as if
1557 acts like an automatic function which re-executes those lines as if
1558 you had typed them. You just type 'name' at the prompt and the code
1558 you had typed them. You just type 'name' at the prompt and the code
1559 executes.
1559 executes.
1560
1560
1561 Note that the slices use the standard Python slicing notation (5:8
1561 Note that the slices use the standard Python slicing notation (5:8
1562 means include lines numbered 5,6,7).
1562 means include lines numbered 5,6,7).
1563
1563
1564 For example, if your history contains (%hist prints it):
1564 For example, if your history contains (%hist prints it):
1565
1565
1566 44: x=1\\
1566 44: x=1\\
1567 45: y=3\\
1567 45: y=3\\
1568 46: z=x+y\\
1568 46: z=x+y\\
1569 47: print x\\
1569 47: print x\\
1570 48: a=5\\
1570 48: a=5\\
1571 49: print 'x',x,'y',y\\
1571 49: print 'x',x,'y',y\\
1572
1572
1573 you can create a macro with lines 44 through 47 (included) and line 49
1573 you can create a macro with lines 44 through 47 (included) and line 49
1574 called my_macro with:
1574 called my_macro with:
1575
1575
1576 In [51]: %macro my_macro 44:48 49
1576 In [51]: %macro my_macro 44:48 49
1577
1577
1578 Now, typing `my_macro` (without quotes) will re-execute all this code
1578 Now, typing `my_macro` (without quotes) will re-execute all this code
1579 in one pass.
1579 in one pass.
1580
1580
1581 You don't need to give the line-numbers in order, and any given line
1581 You don't need to give the line-numbers in order, and any given line
1582 number can appear multiple times. You can assemble macros with any
1582 number can appear multiple times. You can assemble macros with any
1583 lines from your input history in any order.
1583 lines from your input history in any order.
1584
1584
1585 The macro is a simple object which holds its value in an attribute,
1585 The macro is a simple object which holds its value in an attribute,
1586 but IPython's display system checks for macros and executes them as
1586 but IPython's display system checks for macros and executes them as
1587 code instead of printing them when you type their name.
1587 code instead of printing them when you type their name.
1588
1588
1589 You can view a macro's contents by explicitly printing it with:
1589 You can view a macro's contents by explicitly printing it with:
1590
1590
1591 'print macro_name'.
1591 'print macro_name'.
1592
1592
1593 For one-off cases which DON'T contain magic function calls in them you
1593 For one-off cases which DON'T contain magic function calls in them you
1594 can obtain similar results by explicitly executing slices from your
1594 can obtain similar results by explicitly executing slices from your
1595 input history with:
1595 input history with:
1596
1596
1597 In [60]: exec In[44:48]+In[49]"""
1597 In [60]: exec In[44:48]+In[49]"""
1598
1598
1599 args = parameter_s.split()
1599 args = parameter_s.split()
1600 name,ranges = args[0], args[1:]
1600 name,ranges = args[0], args[1:]
1601 #print 'rng',ranges # dbg
1601 #print 'rng',ranges # dbg
1602 cmds = self.extract_input_slices(ranges)
1602 cmds = self.extract_input_slices(ranges)
1603 macro = Macro(cmds)
1603 macro = Macro(cmds)
1604 self.shell.user_ns.update({name:macro})
1604 self.shell.user_ns.update({name:macro})
1605 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1605 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1606 print 'Macro contents:'
1606 print 'Macro contents:'
1607 print str(macro).rstrip(),
1607 print str(macro).rstrip(),
1608
1608
1609 def magic_save(self,parameter_s = ''):
1609 def magic_save(self,parameter_s = ''):
1610 """Save a set of lines to a given filename.
1610 """Save a set of lines to a given filename.
1611
1611
1612 Usage:\\
1612 Usage:\\
1613 %save filename n1:n2 n3:n4 ... n5 .. n6 ...
1613 %save filename n1:n2 n3:n4 ... n5 .. n6 ...
1614
1614
1615 This function uses the same syntax as %macro for line extraction, but
1615 This function uses the same syntax as %macro for line extraction, but
1616 instead of creating a macro it saves the resulting string to the
1616 instead of creating a macro it saves the resulting string to the
1617 filename you specify.
1617 filename you specify.
1618
1618
1619 It adds a '.py' extension to the file if you don't do so yourself, and
1619 It adds a '.py' extension to the file if you don't do so yourself, and
1620 it asks for confirmation before overwriting existing files."""
1620 it asks for confirmation before overwriting existing files."""
1621
1621
1622 args = parameter_s.split()
1622 args = parameter_s.split()
1623 fname,ranges = args[0], args[1:]
1623 fname,ranges = args[0], args[1:]
1624 if not fname.endswith('.py'):
1624 if not fname.endswith('.py'):
1625 fname += '.py'
1625 fname += '.py'
1626 if os.path.isfile(fname):
1626 if os.path.isfile(fname):
1627 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1627 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1628 if ans.lower() not in ['y','yes']:
1628 if ans.lower() not in ['y','yes']:
1629 print 'Operation cancelled.'
1629 print 'Operation cancelled.'
1630 return
1630 return
1631 cmds = ''.join(self.extract_input_slices(ranges))
1631 cmds = ''.join(self.extract_input_slices(ranges))
1632 f = file(fname,'w')
1632 f = file(fname,'w')
1633 f.write(cmds)
1633 f.write(cmds)
1634 f.close()
1634 f.close()
1635 print 'The following commands were written to file `%s`:' % fname
1635 print 'The following commands were written to file `%s`:' % fname
1636 print cmds
1636 print cmds
1637
1637
1638 def magic_ed(self,parameter_s = ''):
1638 def magic_ed(self,parameter_s = ''):
1639 """Alias to %edit."""
1639 """Alias to %edit."""
1640 return self.magic_edit(parameter_s)
1640 return self.magic_edit(parameter_s)
1641
1641
1642 def magic_edit(self,parameter_s = '',last_call=['','']):
1642 def magic_edit(self,parameter_s = '',last_call=['','']):
1643 """Bring up an editor and execute the resulting code.
1643 """Bring up an editor and execute the resulting code.
1644
1644
1645 Usage:
1645 Usage:
1646 %edit [options] [args]
1646 %edit [options] [args]
1647
1647
1648 %edit runs IPython's editor hook. The default version of this hook is
1648 %edit runs IPython's editor hook. The default version of this hook is
1649 set to call the __IPYTHON__.rc.editor command. This is read from your
1649 set to call the __IPYTHON__.rc.editor command. This is read from your
1650 environment variable $EDITOR. If this isn't found, it will default to
1650 environment variable $EDITOR. If this isn't found, it will default to
1651 vi under Linux/Unix and to notepad under Windows. See the end of this
1651 vi under Linux/Unix and to notepad under Windows. See the end of this
1652 docstring for how to change the editor hook.
1652 docstring for how to change the editor hook.
1653
1653
1654 You can also set the value of this editor via the command line option
1654 You can also set the value of this editor via the command line option
1655 '-editor' or in your ipythonrc file. This is useful if you wish to use
1655 '-editor' or in your ipythonrc file. This is useful if you wish to use
1656 specifically for IPython an editor different from your typical default
1656 specifically for IPython an editor different from your typical default
1657 (and for Windows users who typically don't set environment variables).
1657 (and for Windows users who typically don't set environment variables).
1658
1658
1659 This command allows you to conveniently edit multi-line code right in
1659 This command allows you to conveniently edit multi-line code right in
1660 your IPython session.
1660 your IPython session.
1661
1661
1662 If called without arguments, %edit opens up an empty editor with a
1662 If called without arguments, %edit opens up an empty editor with a
1663 temporary file and will execute the contents of this file when you
1663 temporary file and will execute the contents of this file when you
1664 close it (don't forget to save it!).
1664 close it (don't forget to save it!).
1665
1665
1666 Options:
1666 Options:
1667
1667
1668 -p: this will call the editor with the same data as the previous time
1668 -p: this will call the editor with the same data as the previous time
1669 it was used, regardless of how long ago (in your current session) it
1669 it was used, regardless of how long ago (in your current session) it
1670 was.
1670 was.
1671
1671
1672 -x: do not execute the edited code immediately upon exit. This is
1672 -x: do not execute the edited code immediately upon exit. This is
1673 mainly useful if you are editing programs which need to be called with
1673 mainly useful if you are editing programs which need to be called with
1674 command line arguments, which you can then do using %run.
1674 command line arguments, which you can then do using %run.
1675
1675
1676 Arguments:
1676 Arguments:
1677
1677
1678 If arguments are given, the following possibilites exist:
1678 If arguments are given, the following possibilites exist:
1679
1679
1680 - The arguments are numbers or pairs of colon-separated numbers (like
1680 - The arguments are numbers or pairs of colon-separated numbers (like
1681 1 4:8 9). These are interpreted as lines of previous input to be
1681 1 4:8 9). These are interpreted as lines of previous input to be
1682 loaded into the editor. The syntax is the same of the %macro command.
1682 loaded into the editor. The syntax is the same of the %macro command.
1683
1683
1684 - If the argument doesn't start with a number, it is evaluated as a
1684 - If the argument doesn't start with a number, it is evaluated as a
1685 variable and its contents loaded into the editor. You can thus edit
1685 variable and its contents loaded into the editor. You can thus edit
1686 any string which contains python code (including the result of
1686 any string which contains python code (including the result of
1687 previous edits).
1687 previous edits).
1688
1688
1689 - If the argument is the name of an object (other than a string),
1689 - If the argument is the name of an object (other than a string),
1690 IPython will try to locate the file where it was defined and open the
1690 IPython will try to locate the file where it was defined and open the
1691 editor at the point where it is defined. You can use `%edit function`
1691 editor at the point where it is defined. You can use `%edit function`
1692 to load an editor exactly at the point where 'function' is defined,
1692 to load an editor exactly at the point where 'function' is defined,
1693 edit it and have the file be executed automatically.
1693 edit it and have the file be executed automatically.
1694
1694
1695 Note: opening at an exact line is only supported under Unix, and some
1695 Note: opening at an exact line is only supported under Unix, and some
1696 editors (like kedit and gedit up to Gnome 2.8) do not understand the
1696 editors (like kedit and gedit up to Gnome 2.8) do not understand the
1697 '+NUMBER' parameter necessary for this feature. Good editors like
1697 '+NUMBER' parameter necessary for this feature. Good editors like
1698 (X)Emacs, vi, jed, pico and joe all do.
1698 (X)Emacs, vi, jed, pico and joe all do.
1699
1699
1700 - If the argument is not found as a variable, IPython will look for a
1700 - If the argument is not found as a variable, IPython will look for a
1701 file with that name (adding .py if necessary) and load it into the
1701 file with that name (adding .py if necessary) and load it into the
1702 editor. It will execute its contents with execfile() when you exit,
1702 editor. It will execute its contents with execfile() when you exit,
1703 loading any code in the file into your interactive namespace.
1703 loading any code in the file into your interactive namespace.
1704
1704
1705 After executing your code, %edit will return as output the code you
1705 After executing your code, %edit will return as output the code you
1706 typed in the editor (except when it was an existing file). This way
1706 typed in the editor (except when it was an existing file). This way
1707 you can reload the code in further invocations of %edit as a variable,
1707 you can reload the code in further invocations of %edit as a variable,
1708 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
1708 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
1709 the output.
1709 the output.
1710
1710
1711 Note that %edit is also available through the alias %ed.
1711 Note that %edit is also available through the alias %ed.
1712
1712
1713 This is an example of creating a simple function inside the editor and
1713 This is an example of creating a simple function inside the editor and
1714 then modifying it. First, start up the editor:
1714 then modifying it. First, start up the editor:
1715
1715
1716 In [1]: ed\\
1716 In [1]: ed\\
1717 Editing... done. Executing edited code...\\
1717 Editing... done. Executing edited code...\\
1718 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
1718 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
1719
1719
1720 We can then call the function foo():
1720 We can then call the function foo():
1721
1721
1722 In [2]: foo()\\
1722 In [2]: foo()\\
1723 foo() was defined in an editing session
1723 foo() was defined in an editing session
1724
1724
1725 Now we edit foo. IPython automatically loads the editor with the
1725 Now we edit foo. IPython automatically loads the editor with the
1726 (temporary) file where foo() was previously defined:
1726 (temporary) file where foo() was previously defined:
1727
1727
1728 In [3]: ed foo\\
1728 In [3]: ed foo\\
1729 Editing... done. Executing edited code...
1729 Editing... done. Executing edited code...
1730
1730
1731 And if we call foo() again we get the modified version:
1731 And if we call foo() again we get the modified version:
1732
1732
1733 In [4]: foo()\\
1733 In [4]: foo()\\
1734 foo() has now been changed!
1734 foo() has now been changed!
1735
1735
1736 Here is an example of how to edit a code snippet successive
1736 Here is an example of how to edit a code snippet successive
1737 times. First we call the editor:
1737 times. First we call the editor:
1738
1738
1739 In [8]: ed\\
1739 In [8]: ed\\
1740 Editing... done. Executing edited code...\\
1740 Editing... done. Executing edited code...\\
1741 hello\\
1741 hello\\
1742 Out[8]: "print 'hello'\\n"
1742 Out[8]: "print 'hello'\\n"
1743
1743
1744 Now we call it again with the previous output (stored in _):
1744 Now we call it again with the previous output (stored in _):
1745
1745
1746 In [9]: ed _\\
1746 In [9]: ed _\\
1747 Editing... done. Executing edited code...\\
1747 Editing... done. Executing edited code...\\
1748 hello world\\
1748 hello world\\
1749 Out[9]: "print 'hello world'\\n"
1749 Out[9]: "print 'hello world'\\n"
1750
1750
1751 Now we call it with the output #8 (stored in _8, also as Out[8]):
1751 Now we call it with the output #8 (stored in _8, also as Out[8]):
1752
1752
1753 In [10]: ed _8\\
1753 In [10]: ed _8\\
1754 Editing... done. Executing edited code...\\
1754 Editing... done. Executing edited code...\\
1755 hello again\\
1755 hello again\\
1756 Out[10]: "print 'hello again'\\n"
1756 Out[10]: "print 'hello again'\\n"
1757
1757
1758
1758
1759 Changing the default editor hook:
1759 Changing the default editor hook:
1760
1760
1761 If you wish to write your own editor hook, you can put it in a
1761 If you wish to write your own editor hook, you can put it in a
1762 configuration file which you load at startup time. The default hook
1762 configuration file which you load at startup time. The default hook
1763 is defined in the IPython.hooks module, and you can use that as a
1763 is defined in the IPython.hooks module, and you can use that as a
1764 starting example for further modifications. That file also has
1764 starting example for further modifications. That file also has
1765 general instructions on how to set a new hook for use once you've
1765 general instructions on how to set a new hook for use once you've
1766 defined it."""
1766 defined it."""
1767
1767
1768 # FIXME: This function has become a convoluted mess. It needs a
1768 # FIXME: This function has become a convoluted mess. It needs a
1769 # ground-up rewrite with clean, simple logic.
1769 # ground-up rewrite with clean, simple logic.
1770
1770
1771 def make_filename(arg):
1771 def make_filename(arg):
1772 "Make a filename from the given args"
1772 "Make a filename from the given args"
1773 try:
1773 try:
1774 filename = get_py_filename(arg)
1774 filename = get_py_filename(arg)
1775 except IOError:
1775 except IOError:
1776 if args.endswith('.py'):
1776 if args.endswith('.py'):
1777 filename = arg
1777 filename = arg
1778 else:
1778 else:
1779 filename = None
1779 filename = None
1780 return filename
1780 return filename
1781
1781
1782 # custom exceptions
1782 # custom exceptions
1783 class DataIsObject(Exception): pass
1783 class DataIsObject(Exception): pass
1784
1784
1785 opts,args = self.parse_options(parameter_s,'px')
1785 opts,args = self.parse_options(parameter_s,'px')
1786
1786
1787 # Default line number value
1787 # Default line number value
1788 lineno = None
1788 lineno = None
1789 if opts.has_key('p'):
1789 if opts.has_key('p'):
1790 args = '_%s' % last_call[0]
1790 args = '_%s' % last_call[0]
1791 if not self.shell.user_ns.has_key(args):
1791 if not self.shell.user_ns.has_key(args):
1792 args = last_call[1]
1792 args = last_call[1]
1793
1793
1794 # use last_call to remember the state of the previous call, but don't
1794 # use last_call to remember the state of the previous call, but don't
1795 # let it be clobbered by successive '-p' calls.
1795 # let it be clobbered by successive '-p' calls.
1796 try:
1796 try:
1797 last_call[0] = self.shell.outputcache.prompt_count
1797 last_call[0] = self.shell.outputcache.prompt_count
1798 if not opts.has_key('p'):
1798 if not opts.has_key('p'):
1799 last_call[1] = parameter_s
1799 last_call[1] = parameter_s
1800 except:
1800 except:
1801 pass
1801 pass
1802
1802
1803 # by default this is done with temp files, except when the given
1803 # by default this is done with temp files, except when the given
1804 # arg is a filename
1804 # arg is a filename
1805 use_temp = 1
1805 use_temp = 1
1806
1806
1807 if re.match(r'\d',args):
1807 if re.match(r'\d',args):
1808 # Mode where user specifies ranges of lines, like in %macro.
1808 # Mode where user specifies ranges of lines, like in %macro.
1809 # This means that you can't edit files whose names begin with
1809 # This means that you can't edit files whose names begin with
1810 # numbers this way. Tough.
1810 # numbers this way. Tough.
1811 ranges = args.split()
1811 ranges = args.split()
1812 data = ''.join(self.extract_input_slices(ranges))
1812 data = ''.join(self.extract_input_slices(ranges))
1813 elif args.endswith('.py'):
1813 elif args.endswith('.py'):
1814 filename = make_filename(args)
1814 filename = make_filename(args)
1815 data = ''
1815 data = ''
1816 use_temp = 0
1816 use_temp = 0
1817 elif args:
1817 elif args:
1818 try:
1818 try:
1819 # Load the parameter given as a variable. If not a string,
1819 # Load the parameter given as a variable. If not a string,
1820 # process it as an object instead (below)
1820 # process it as an object instead (below)
1821
1821
1822 #print '*** args',args,'type',type(args) # dbg
1822 #print '*** args',args,'type',type(args) # dbg
1823 data = eval(args,self.shell.user_ns)
1823 data = eval(args,self.shell.user_ns)
1824 if not type(data) in StringTypes:
1824 if not type(data) in StringTypes:
1825 raise DataIsObject
1825 raise DataIsObject
1826 except (NameError,SyntaxError):
1826 except (NameError,SyntaxError):
1827 # given argument is not a variable, try as a filename
1827 # given argument is not a variable, try as a filename
1828 filename = make_filename(args)
1828 filename = make_filename(args)
1829 if filename is None:
1829 if filename is None:
1830 warn("Argument given (%s) can't be found as a variable "
1830 warn("Argument given (%s) can't be found as a variable "
1831 "or as a filename." % args)
1831 "or as a filename." % args)
1832 return
1832 return
1833 data = ''
1833 data = ''
1834 use_temp = 0
1834 use_temp = 0
1835 except DataIsObject:
1835 except DataIsObject:
1836 # For objects, try to edit the file where they are defined
1836 # For objects, try to edit the file where they are defined
1837 try:
1837 try:
1838 filename = inspect.getabsfile(data)
1838 filename = inspect.getabsfile(data)
1839 datafile = 1
1839 datafile = 1
1840 except TypeError:
1840 except TypeError:
1841 filename = make_filename(args)
1841 filename = make_filename(args)
1842 datafile = 1
1842 datafile = 1
1843 warn('Could not find file where `%s` is defined.\n'
1843 warn('Could not find file where `%s` is defined.\n'
1844 'Opening a file named `%s`' % (args,filename))
1844 'Opening a file named `%s`' % (args,filename))
1845 # Now, make sure we can actually read the source (if it was in
1845 # Now, make sure we can actually read the source (if it was in
1846 # a temp file it's gone by now).
1846 # a temp file it's gone by now).
1847 if datafile:
1847 if datafile:
1848 try:
1848 try:
1849 lineno = inspect.getsourcelines(data)[1]
1849 lineno = inspect.getsourcelines(data)[1]
1850 except IOError:
1850 except IOError:
1851 filename = make_filename(args)
1851 filename = make_filename(args)
1852 if filename is None:
1852 if filename is None:
1853 warn('The file `%s` where `%s` was defined cannot '
1853 warn('The file `%s` where `%s` was defined cannot '
1854 'be read.' % (filename,data))
1854 'be read.' % (filename,data))
1855 return
1855 return
1856 use_temp = 0
1856 use_temp = 0
1857 else:
1857 else:
1858 data = ''
1858 data = ''
1859
1859
1860 if use_temp:
1860 if use_temp:
1861 filename = tempfile.mktemp('.py')
1861 filename = tempfile.mktemp('.py')
1862 self.shell.tempfiles.append(filename)
1862 self.shell.tempfiles.append(filename)
1863
1863
1864 if data and use_temp:
1864 if data and use_temp:
1865 tmp_file = open(filename,'w')
1865 tmp_file = open(filename,'w')
1866 tmp_file.write(data)
1866 tmp_file.write(data)
1867 tmp_file.close()
1867 tmp_file.close()
1868
1868
1869 # do actual editing here
1869 # do actual editing here
1870 print 'Editing...',
1870 print 'Editing...',
1871 sys.stdout.flush()
1871 sys.stdout.flush()
1872 self.shell.hooks.editor(filename,lineno)
1872 self.shell.hooks.editor(filename,lineno)
1873 if opts.has_key('x'): # -x prevents actual execution
1873 if opts.has_key('x'): # -x prevents actual execution
1874 print
1874 print
1875 else:
1875 else:
1876 print 'done. Executing edited code...'
1876 print 'done. Executing edited code...'
1877 try:
1877 try:
1878 self.shell.safe_execfile(filename,self.shell.user_ns)
1878 self.shell.safe_execfile(filename,self.shell.user_ns)
1879 except IOError,msg:
1879 except IOError,msg:
1880 if msg.filename == filename:
1880 if msg.filename == filename:
1881 warn('File not found. Did you forget to save?')
1881 warn('File not found. Did you forget to save?')
1882 return
1882 return
1883 else:
1883 else:
1884 self.shell.showtraceback()
1884 self.shell.showtraceback()
1885 except:
1885 except:
1886 self.shell.showtraceback()
1886 self.shell.showtraceback()
1887 if use_temp:
1887 if use_temp:
1888 contents = open(filename).read()
1888 contents = open(filename).read()
1889 return contents
1889 return contents
1890
1890
1891 def magic_xmode(self,parameter_s = ''):
1891 def magic_xmode(self,parameter_s = ''):
1892 """Switch modes for the exception handlers.
1892 """Switch modes for the exception handlers.
1893
1893
1894 Valid modes: Plain, Context and Verbose.
1894 Valid modes: Plain, Context and Verbose.
1895
1895
1896 If called without arguments, acts as a toggle."""
1896 If called without arguments, acts as a toggle."""
1897
1897
1898 new_mode = parameter_s.strip().capitalize()
1898 new_mode = parameter_s.strip().capitalize()
1899 try:
1899 try:
1900 self.InteractiveTB.set_mode(mode = new_mode)
1900 self.InteractiveTB.set_mode(mode = new_mode)
1901 print 'Exception reporting mode:',self.InteractiveTB.mode
1901 print 'Exception reporting mode:',self.InteractiveTB.mode
1902 except:
1902 except:
1903 warn('Error changing exception modes.\n' + str(sys.exc_info()[1]))
1903 warn('Error changing exception modes.\n' + str(sys.exc_info()[1]))
1904
1904
1905 def magic_colors(self,parameter_s = ''):
1905 def magic_colors(self,parameter_s = ''):
1906 """Switch color scheme for prompts, info system and exception handlers.
1906 """Switch color scheme for prompts, info system and exception handlers.
1907
1907
1908 Currently implemented schemes: NoColor, Linux, LightBG.
1908 Currently implemented schemes: NoColor, Linux, LightBG.
1909
1909
1910 Color scheme names are not case-sensitive."""
1910 Color scheme names are not case-sensitive."""
1911
1911
1912 new_scheme = parameter_s.strip()
1912 new_scheme = parameter_s.strip()
1913 if not new_scheme:
1913 if not new_scheme:
1914 print 'You must specify a color scheme.'
1914 print 'You must specify a color scheme.'
1915 return
1915 return
1916 # Under Windows, check for Gary Bishop's readline, which is necessary
1916 # Under Windows, check for Gary Bishop's readline, which is necessary
1917 # for ANSI coloring
1917 # for ANSI coloring
1918 if os.name in ['nt','dos']:
1918 if os.name in ['nt','dos']:
1919 try:
1919 try:
1920 import readline
1920 import readline
1921 except ImportError:
1921 except ImportError:
1922 has_readline = 0
1922 has_readline = 0
1923 else:
1923 else:
1924 try:
1924 try:
1925 readline.GetOutputFile()
1925 readline.GetOutputFile()
1926 except AttributeError:
1926 except AttributeError:
1927 has_readline = 0
1927 has_readline = 0
1928 else:
1928 else:
1929 has_readline = 1
1929 has_readline = 1
1930 if not has_readline:
1930 if not has_readline:
1931 msg = """\
1931 msg = """\
1932 Proper color support under MS Windows requires Gary Bishop's readline library.
1932 Proper color support under MS Windows requires Gary Bishop's readline library.
1933 You can find it at:
1933 You can find it at:
1934 http://sourceforge.net/projects/uncpythontools
1934 http://sourceforge.net/projects/uncpythontools
1935 Gary's readline needs the ctypes module, from:
1935 Gary's readline needs the ctypes module, from:
1936 http://starship.python.net/crew/theller/ctypes
1936 http://starship.python.net/crew/theller/ctypes
1937
1937
1938 Defaulting color scheme to 'NoColor'"""
1938 Defaulting color scheme to 'NoColor'"""
1939 new_scheme = 'NoColor'
1939 new_scheme = 'NoColor'
1940 warn(msg)
1940 warn(msg)
1941
1941
1942 # Set prompt colors
1942 # Set prompt colors
1943 try:
1943 try:
1944 self.shell.outputcache.set_colors(new_scheme)
1944 self.shell.outputcache.set_colors(new_scheme)
1945 except:
1945 except:
1946 warn('Error changing prompt color schemes.\n'
1946 warn('Error changing prompt color schemes.\n'
1947 + str(sys.exc_info()[1]))
1947 + str(sys.exc_info()[1]))
1948 else:
1948 else:
1949 self.shell.rc.colors = \
1949 self.shell.rc.colors = \
1950 self.shell.outputcache.color_table.active_scheme_name
1950 self.shell.outputcache.color_table.active_scheme_name
1951 # Set exception colors
1951 # Set exception colors
1952 try:
1952 try:
1953 self.shell.InteractiveTB.set_colors(scheme = new_scheme)
1953 self.shell.InteractiveTB.set_colors(scheme = new_scheme)
1954 self.shell.SyntaxTB.set_colors(scheme = new_scheme)
1954 self.shell.SyntaxTB.set_colors(scheme = new_scheme)
1955 except:
1955 except:
1956 warn('Error changing exception color schemes.\n'
1956 warn('Error changing exception color schemes.\n'
1957 + str(sys.exc_info()[1]))
1957 + str(sys.exc_info()[1]))
1958 # Set info (for 'object?') colors
1958 # Set info (for 'object?') colors
1959 if self.shell.rc.color_info:
1959 if self.shell.rc.color_info:
1960 try:
1960 try:
1961 self.shell.inspector.set_active_scheme(new_scheme)
1961 self.shell.inspector.set_active_scheme(new_scheme)
1962 except:
1962 except:
1963 warn('Error changing object inspector color schemes.\n'
1963 warn('Error changing object inspector color schemes.\n'
1964 + str(sys.exc_info()[1]))
1964 + str(sys.exc_info()[1]))
1965 else:
1965 else:
1966 self.shell.inspector.set_active_scheme('NoColor')
1966 self.shell.inspector.set_active_scheme('NoColor')
1967
1967
1968 def magic_color_info(self,parameter_s = ''):
1968 def magic_color_info(self,parameter_s = ''):
1969 """Toggle color_info.
1969 """Toggle color_info.
1970
1970
1971 The color_info configuration parameter controls whether colors are
1971 The color_info configuration parameter controls whether colors are
1972 used for displaying object details (by things like %psource, %pfile or
1972 used for displaying object details (by things like %psource, %pfile or
1973 the '?' system). This function toggles this value with each call.
1973 the '?' system). This function toggles this value with each call.
1974
1974
1975 Note that unless you have a fairly recent pager (less works better
1975 Note that unless you have a fairly recent pager (less works better
1976 than more) in your system, using colored object information displays
1976 than more) in your system, using colored object information displays
1977 will not work properly. Test it and see."""
1977 will not work properly. Test it and see."""
1978
1978
1979 self.shell.rc.color_info = 1 - self.shell.rc.color_info
1979 self.shell.rc.color_info = 1 - self.shell.rc.color_info
1980 self.magic_colors(self.shell.rc.colors)
1980 self.magic_colors(self.shell.rc.colors)
1981 print 'Object introspection functions have now coloring:',
1981 print 'Object introspection functions have now coloring:',
1982 print ['OFF','ON'][self.shell.rc.color_info]
1982 print ['OFF','ON'][self.shell.rc.color_info]
1983
1983
1984 def magic_Pprint(self, parameter_s=''):
1984 def magic_Pprint(self, parameter_s=''):
1985 """Toggle pretty printing on/off."""
1985 """Toggle pretty printing on/off."""
1986
1986
1987 self.shell.outputcache.Pprint = 1 - self.shell.outputcache.Pprint
1987 self.shell.outputcache.Pprint = 1 - self.shell.outputcache.Pprint
1988 print 'Pretty printing has been turned', \
1988 print 'Pretty printing has been turned', \
1989 ['OFF','ON'][self.shell.outputcache.Pprint]
1989 ['OFF','ON'][self.shell.outputcache.Pprint]
1990
1990
1991 def magic_exit(self, parameter_s=''):
1992 """Exit IPython, confirming if configured to do so.
1993
1994 You can configure whether IPython asks for confirmation upon exit by
1995 setting the confirm_exit flag in the ipythonrc file."""
1996
1997 self.shell.exit()
1998
1999 def magic_quit(self, parameter_s=''):
2000 """Exit IPython, confirming if configured to do so (like %exit)"""
2001
2002 self.shell.exit()
2003
1991 def magic_Exit(self, parameter_s=''):
2004 def magic_Exit(self, parameter_s=''):
1992 """Exit IPython without confirmation."""
2005 """Exit IPython without confirmation."""
1993
2006
1994 self.shell.exit_now = True
2007 self.shell.exit_now = True
1995
2008
1996 def magic_Quit(self, parameter_s=''):
2009 def magic_Quit(self, parameter_s=''):
1997 """Exit IPython without confirmation (like %Exit)."""
2010 """Exit IPython without confirmation (like %Exit)."""
1998
2011
1999 self.shell.exit_now = True
2012 self.shell.exit_now = True
2000
2013
2001 #......................................................................
2014 #......................................................................
2002 # Functions to implement unix shell-type things
2015 # Functions to implement unix shell-type things
2003
2016
2004 def magic_alias(self, parameter_s = ''):
2017 def magic_alias(self, parameter_s = ''):
2005 """Define an alias for a system command.
2018 """Define an alias for a system command.
2006
2019
2007 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2020 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2008
2021
2009 Then, typing 'alias_name params' will execute the system command 'cmd
2022 Then, typing 'alias_name params' will execute the system command 'cmd
2010 params' (from your underlying operating system).
2023 params' (from your underlying operating system).
2011
2024
2012 Aliases have lower precedence than magic functions and Python normal
2025 Aliases have lower precedence than magic functions and Python normal
2013 variables, so if 'foo' is both a Python variable and an alias, the
2026 variables, so if 'foo' is both a Python variable and an alias, the
2014 alias can not be executed until 'del foo' removes the Python variable.
2027 alias can not be executed until 'del foo' removes the Python variable.
2015
2028
2016 You can use the %l specifier in an alias definition to represent the
2029 You can use the %l specifier in an alias definition to represent the
2017 whole line when the alias is called. For example:
2030 whole line when the alias is called. For example:
2018
2031
2019 In [2]: alias all echo "Input in brackets: <%l>"\\
2032 In [2]: alias all echo "Input in brackets: <%l>"\\
2020 In [3]: all hello world\\
2033 In [3]: all hello world\\
2021 Input in brackets: <hello world>
2034 Input in brackets: <hello world>
2022
2035
2023 You can also define aliases with parameters using %s specifiers (one
2036 You can also define aliases with parameters using %s specifiers (one
2024 per parameter):
2037 per parameter):
2025
2038
2026 In [1]: alias parts echo first %s second %s\\
2039 In [1]: alias parts echo first %s second %s\\
2027 In [2]: %parts A B\\
2040 In [2]: %parts A B\\
2028 first A second B\\
2041 first A second B\\
2029 In [3]: %parts A\\
2042 In [3]: %parts A\\
2030 Incorrect number of arguments: 2 expected.\\
2043 Incorrect number of arguments: 2 expected.\\
2031 parts is an alias to: 'echo first %s second %s'
2044 parts is an alias to: 'echo first %s second %s'
2032
2045
2033 Note that %l and %s are mutually exclusive. You can only use one or
2046 Note that %l and %s are mutually exclusive. You can only use one or
2034 the other in your aliases.
2047 the other in your aliases.
2035
2048
2036 Aliases expand Python variables just like system calls using ! or !!
2049 Aliases expand Python variables just like system calls using ! or !!
2037 do: all expressions prefixed with '$' get expanded. For details of
2050 do: all expressions prefixed with '$' get expanded. For details of
2038 the semantic rules, see PEP-215:
2051 the semantic rules, see PEP-215:
2039 http://www.python.org/peps/pep-0215.html. This is the library used by
2052 http://www.python.org/peps/pep-0215.html. This is the library used by
2040 IPython for variable expansion. If you want to access a true shell
2053 IPython for variable expansion. If you want to access a true shell
2041 variable, an extra $ is necessary to prevent its expansion by IPython:
2054 variable, an extra $ is necessary to prevent its expansion by IPython:
2042
2055
2043 In [6]: alias show echo\\
2056 In [6]: alias show echo\\
2044 In [7]: PATH='A Python string'\\
2057 In [7]: PATH='A Python string'\\
2045 In [8]: show $PATH\\
2058 In [8]: show $PATH\\
2046 A Python string\\
2059 A Python string\\
2047 In [9]: show $$PATH\\
2060 In [9]: show $$PATH\\
2048 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2061 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2049
2062
2050 You can use the alias facility to acess all of $PATH. See the %rehash
2063 You can use the alias facility to acess all of $PATH. See the %rehash
2051 and %rehashx functions, which automatically create aliases for the
2064 and %rehashx functions, which automatically create aliases for the
2052 contents of your $PATH.
2065 contents of your $PATH.
2053
2066
2054 If called with no parameters, %alias prints the current alias table."""
2067 If called with no parameters, %alias prints the current alias table."""
2055
2068
2056 par = parameter_s.strip()
2069 par = parameter_s.strip()
2057 if not par:
2070 if not par:
2058 if self.shell.rc.automagic:
2071 if self.shell.rc.automagic:
2059 prechar = ''
2072 prechar = ''
2060 else:
2073 else:
2061 prechar = self.shell.ESC_MAGIC
2074 prechar = self.shell.ESC_MAGIC
2062 print 'Alias\t\tSystem Command\n'+'-'*30
2075 print 'Alias\t\tSystem Command\n'+'-'*30
2063 atab = self.shell.alias_table
2076 atab = self.shell.alias_table
2064 aliases = atab.keys()
2077 aliases = atab.keys()
2065 aliases.sort()
2078 aliases.sort()
2066 for alias in aliases:
2079 for alias in aliases:
2067 print prechar+alias+'\t\t'+atab[alias][1]
2080 print prechar+alias+'\t\t'+atab[alias][1]
2068 print '-'*30+'\nTotal number of aliases:',len(aliases)
2081 print '-'*30+'\nTotal number of aliases:',len(aliases)
2069 return
2082 return
2070 try:
2083 try:
2071 alias,cmd = par.split(None,1)
2084 alias,cmd = par.split(None,1)
2072 except:
2085 except:
2073 print OInspect.getdoc(self.magic_alias)
2086 print OInspect.getdoc(self.magic_alias)
2074 else:
2087 else:
2075 nargs = cmd.count('%s')
2088 nargs = cmd.count('%s')
2076 if nargs>0 and cmd.find('%l')>=0:
2089 if nargs>0 and cmd.find('%l')>=0:
2077 error('The %s and %l specifiers are mutually exclusive '
2090 error('The %s and %l specifiers are mutually exclusive '
2078 'in alias definitions.')
2091 'in alias definitions.')
2079 else: # all looks OK
2092 else: # all looks OK
2080 self.shell.alias_table[alias] = (nargs,cmd)
2093 self.shell.alias_table[alias] = (nargs,cmd)
2081 self.shell.alias_table_validate(verbose=1)
2094 self.shell.alias_table_validate(verbose=1)
2082 # end magic_alias
2095 # end magic_alias
2083
2096
2084 def magic_unalias(self, parameter_s = ''):
2097 def magic_unalias(self, parameter_s = ''):
2085 """Remove an alias"""
2098 """Remove an alias"""
2086
2099
2087 aname = parameter_s.strip()
2100 aname = parameter_s.strip()
2088 if aname in self.shell.alias_table:
2101 if aname in self.shell.alias_table:
2089 del self.shell.alias_table[aname]
2102 del self.shell.alias_table[aname]
2090
2103
2091 def magic_rehash(self, parameter_s = ''):
2104 def magic_rehash(self, parameter_s = ''):
2092 """Update the alias table with all entries in $PATH.
2105 """Update the alias table with all entries in $PATH.
2093
2106
2094 This version does no checks on execute permissions or whether the
2107 This version does no checks on execute permissions or whether the
2095 contents of $PATH are truly files (instead of directories or something
2108 contents of $PATH are truly files (instead of directories or something
2096 else). For such a safer (but slower) version, use %rehashx."""
2109 else). For such a safer (but slower) version, use %rehashx."""
2097
2110
2098 # This function (and rehashx) manipulate the alias_table directly
2111 # This function (and rehashx) manipulate the alias_table directly
2099 # rather than calling magic_alias, for speed reasons. A rehash on a
2112 # rather than calling magic_alias, for speed reasons. A rehash on a
2100 # typical Linux box involves several thousand entries, so efficiency
2113 # typical Linux box involves several thousand entries, so efficiency
2101 # here is a top concern.
2114 # here is a top concern.
2102
2115
2103 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2116 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2104 alias_table = self.shell.alias_table
2117 alias_table = self.shell.alias_table
2105 for pdir in path:
2118 for pdir in path:
2106 for ff in os.listdir(pdir):
2119 for ff in os.listdir(pdir):
2107 # each entry in the alias table must be (N,name), where
2120 # each entry in the alias table must be (N,name), where
2108 # N is the number of positional arguments of the alias.
2121 # N is the number of positional arguments of the alias.
2109 alias_table[ff] = (0,ff)
2122 alias_table[ff] = (0,ff)
2110 # Make sure the alias table doesn't contain keywords or builtins
2123 # Make sure the alias table doesn't contain keywords or builtins
2111 self.shell.alias_table_validate()
2124 self.shell.alias_table_validate()
2112 # Call again init_auto_alias() so we get 'rm -i' and other modified
2125 # Call again init_auto_alias() so we get 'rm -i' and other modified
2113 # aliases since %rehash will probably clobber them
2126 # aliases since %rehash will probably clobber them
2114 self.shell.init_auto_alias()
2127 self.shell.init_auto_alias()
2115
2128
2116 def magic_rehashx(self, parameter_s = ''):
2129 def magic_rehashx(self, parameter_s = ''):
2117 """Update the alias table with all executable files in $PATH.
2130 """Update the alias table with all executable files in $PATH.
2118
2131
2119 This version explicitly checks that every entry in $PATH is a file
2132 This version explicitly checks that every entry in $PATH is a file
2120 with execute access (os.X_OK), so it is much slower than %rehash.
2133 with execute access (os.X_OK), so it is much slower than %rehash.
2121
2134
2122 Under Windows, it checks executability as a match agains a
2135 Under Windows, it checks executability as a match agains a
2123 '|'-separated string of extensions, stored in the IPython config
2136 '|'-separated string of extensions, stored in the IPython config
2124 variable win_exec_ext. This defaults to 'exe|com|bat'. """
2137 variable win_exec_ext. This defaults to 'exe|com|bat'. """
2125
2138
2126 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2139 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2127 alias_table = self.shell.alias_table
2140 alias_table = self.shell.alias_table
2128
2141
2129 if os.name == 'posix':
2142 if os.name == 'posix':
2130 isexec = lambda fname:os.path.isfile(fname) and \
2143 isexec = lambda fname:os.path.isfile(fname) and \
2131 os.access(fname,os.X_OK)
2144 os.access(fname,os.X_OK)
2132 else:
2145 else:
2133
2146
2134 try:
2147 try:
2135 winext = os.environ['pathext'].replace(';','|').replace('.','')
2148 winext = os.environ['pathext'].replace(';','|').replace('.','')
2136 except KeyError:
2149 except KeyError:
2137 winext = 'exe|com|bat'
2150 winext = 'exe|com|bat'
2138
2151
2139 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2152 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2140 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2153 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2141 savedir = os.getcwd()
2154 savedir = os.getcwd()
2142 try:
2155 try:
2143 # write the whole loop for posix/Windows so we don't have an if in
2156 # write the whole loop for posix/Windows so we don't have an if in
2144 # the innermost part
2157 # the innermost part
2145 if os.name == 'posix':
2158 if os.name == 'posix':
2146 for pdir in path:
2159 for pdir in path:
2147 os.chdir(pdir)
2160 os.chdir(pdir)
2148 for ff in os.listdir(pdir):
2161 for ff in os.listdir(pdir):
2149 if isexec(ff):
2162 if isexec(ff):
2150 # each entry in the alias table must be (N,name),
2163 # each entry in the alias table must be (N,name),
2151 # where N is the number of positional arguments of the
2164 # where N is the number of positional arguments of the
2152 # alias.
2165 # alias.
2153 alias_table[ff] = (0,ff)
2166 alias_table[ff] = (0,ff)
2154 else:
2167 else:
2155 for pdir in path:
2168 for pdir in path:
2156 os.chdir(pdir)
2169 os.chdir(pdir)
2157 for ff in os.listdir(pdir):
2170 for ff in os.listdir(pdir):
2158 if isexec(ff):
2171 if isexec(ff):
2159 alias_table[execre.sub(r'\1',ff)] = (0,ff)
2172 alias_table[execre.sub(r'\1',ff)] = (0,ff)
2160 # Make sure the alias table doesn't contain keywords or builtins
2173 # Make sure the alias table doesn't contain keywords or builtins
2161 self.shell.alias_table_validate()
2174 self.shell.alias_table_validate()
2162 # Call again init_auto_alias() so we get 'rm -i' and other
2175 # Call again init_auto_alias() so we get 'rm -i' and other
2163 # modified aliases since %rehashx will probably clobber them
2176 # modified aliases since %rehashx will probably clobber them
2164 self.shell.init_auto_alias()
2177 self.shell.init_auto_alias()
2165 finally:
2178 finally:
2166 os.chdir(savedir)
2179 os.chdir(savedir)
2167
2180
2168 def magic_pwd(self, parameter_s = ''):
2181 def magic_pwd(self, parameter_s = ''):
2169 """Return the current working directory path."""
2182 """Return the current working directory path."""
2170 return os.getcwd()
2183 return os.getcwd()
2171
2184
2172 def magic_cd(self, parameter_s=''):
2185 def magic_cd(self, parameter_s=''):
2173 """Change the current working directory.
2186 """Change the current working directory.
2174
2187
2175 This command automatically maintains an internal list of directories
2188 This command automatically maintains an internal list of directories
2176 you visit during your IPython session, in the variable _dh. The
2189 you visit during your IPython session, in the variable _dh. The
2177 command %dhist shows this history nicely formatted.
2190 command %dhist shows this history nicely formatted.
2178
2191
2179 Usage:
2192 Usage:
2180
2193
2181 cd 'dir': changes to directory 'dir'.
2194 cd 'dir': changes to directory 'dir'.
2182
2195
2183 cd -: changes to the last visited directory.
2196 cd -: changes to the last visited directory.
2184
2197
2185 cd -<n>: changes to the n-th directory in the directory history.
2198 cd -<n>: changes to the n-th directory in the directory history.
2186
2199
2187 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2200 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2188 (note: cd <bookmark_name> is enough if there is no
2201 (note: cd <bookmark_name> is enough if there is no
2189 directory <bookmark_name>, but a bookmark with the name exists.)
2202 directory <bookmark_name>, but a bookmark with the name exists.)
2190
2203
2191 Options:
2204 Options:
2192
2205
2193 -q: quiet. Do not print the working directory after the cd command is
2206 -q: quiet. Do not print the working directory after the cd command is
2194 executed. By default IPython's cd command does print this directory,
2207 executed. By default IPython's cd command does print this directory,
2195 since the default prompts do not display path information.
2208 since the default prompts do not display path information.
2196
2209
2197 Note that !cd doesn't work for this purpose because the shell where
2210 Note that !cd doesn't work for this purpose because the shell where
2198 !command runs is immediately discarded after executing 'command'."""
2211 !command runs is immediately discarded after executing 'command'."""
2199
2212
2200 parameter_s = parameter_s.strip()
2213 parameter_s = parameter_s.strip()
2201 bkms = self.shell.persist.get("bookmarks",{})
2214 bkms = self.shell.persist.get("bookmarks",{})
2202
2215
2203 numcd = re.match(r'(-)(\d+)$',parameter_s)
2216 numcd = re.match(r'(-)(\d+)$',parameter_s)
2204 # jump in directory history by number
2217 # jump in directory history by number
2205 if numcd:
2218 if numcd:
2206 nn = int(numcd.group(2))
2219 nn = int(numcd.group(2))
2207 try:
2220 try:
2208 ps = self.shell.user_ns['_dh'][nn]
2221 ps = self.shell.user_ns['_dh'][nn]
2209 except IndexError:
2222 except IndexError:
2210 print 'The requested directory does not exist in history.'
2223 print 'The requested directory does not exist in history.'
2211 return
2224 return
2212 else:
2225 else:
2213 opts = {}
2226 opts = {}
2214 else:
2227 else:
2215 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2228 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2216 # jump to previous
2229 # jump to previous
2217 if ps == '-':
2230 if ps == '-':
2218 try:
2231 try:
2219 ps = self.shell.user_ns['_dh'][-2]
2232 ps = self.shell.user_ns['_dh'][-2]
2220 except IndexError:
2233 except IndexError:
2221 print 'No previous directory to change to.'
2234 print 'No previous directory to change to.'
2222 return
2235 return
2223 # jump to bookmark
2236 # jump to bookmark
2224 elif opts.has_key('b') or (bkms.has_key(ps) and not os.path.isdir(ps)):
2237 elif opts.has_key('b') or (bkms.has_key(ps) and not os.path.isdir(ps)):
2225 if bkms.has_key(ps):
2238 if bkms.has_key(ps):
2226 target = bkms[ps]
2239 target = bkms[ps]
2227 print '(bookmark:%s) -> %s' % (ps,target)
2240 print '(bookmark:%s) -> %s' % (ps,target)
2228 ps = target
2241 ps = target
2229 else:
2242 else:
2230 if bkms:
2243 if bkms:
2231 error("Bookmark '%s' not found. "
2244 error("Bookmark '%s' not found. "
2232 "Use '%bookmark -l' to see your bookmarks." % ps)
2245 "Use '%bookmark -l' to see your bookmarks." % ps)
2233 else:
2246 else:
2234 print "Bookmarks not set - use %bookmark <bookmarkname>"
2247 print "Bookmarks not set - use %bookmark <bookmarkname>"
2235 return
2248 return
2236
2249
2237 # at this point ps should point to the target dir
2250 # at this point ps should point to the target dir
2238 if ps:
2251 if ps:
2239 try:
2252 try:
2240 os.chdir(os.path.expanduser(ps))
2253 os.chdir(os.path.expanduser(ps))
2241 except OSError:
2254 except OSError:
2242 print sys.exc_info()[1]
2255 print sys.exc_info()[1]
2243 else:
2256 else:
2244 self.shell.user_ns['_dh'].append(os.getcwd())
2257 self.shell.user_ns['_dh'].append(os.getcwd())
2245 else:
2258 else:
2246 os.chdir(self.home_dir)
2259 os.chdir(self.home_dir)
2247 self.shell.user_ns['_dh'].append(os.getcwd())
2260 self.shell.user_ns['_dh'].append(os.getcwd())
2248 if not 'q' in opts:
2261 if not 'q' in opts:
2249 print self.shell.user_ns['_dh'][-1]
2262 print self.shell.user_ns['_dh'][-1]
2250
2263
2251 def magic_dhist(self, parameter_s=''):
2264 def magic_dhist(self, parameter_s=''):
2252 """Print your history of visited directories.
2265 """Print your history of visited directories.
2253
2266
2254 %dhist -> print full history\\
2267 %dhist -> print full history\\
2255 %dhist n -> print last n entries only\\
2268 %dhist n -> print last n entries only\\
2256 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2269 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2257
2270
2258 This history is automatically maintained by the %cd command, and
2271 This history is automatically maintained by the %cd command, and
2259 always available as the global list variable _dh. You can use %cd -<n>
2272 always available as the global list variable _dh. You can use %cd -<n>
2260 to go to directory number <n>."""
2273 to go to directory number <n>."""
2261
2274
2262 dh = self.shell.user_ns['_dh']
2275 dh = self.shell.user_ns['_dh']
2263 if parameter_s:
2276 if parameter_s:
2264 try:
2277 try:
2265 args = map(int,parameter_s.split())
2278 args = map(int,parameter_s.split())
2266 except:
2279 except:
2267 self.arg_err(Magic.magic_dhist)
2280 self.arg_err(Magic.magic_dhist)
2268 return
2281 return
2269 if len(args) == 1:
2282 if len(args) == 1:
2270 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2283 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2271 elif len(args) == 2:
2284 elif len(args) == 2:
2272 ini,fin = args
2285 ini,fin = args
2273 else:
2286 else:
2274 self.arg_err(Magic.magic_dhist)
2287 self.arg_err(Magic.magic_dhist)
2275 return
2288 return
2276 else:
2289 else:
2277 ini,fin = 0,len(dh)
2290 ini,fin = 0,len(dh)
2278 nlprint(dh,
2291 nlprint(dh,
2279 header = 'Directory history (kept in _dh)',
2292 header = 'Directory history (kept in _dh)',
2280 start=ini,stop=fin)
2293 start=ini,stop=fin)
2281
2294
2282 def magic_env(self, parameter_s=''):
2295 def magic_env(self, parameter_s=''):
2283 """List environment variables."""
2296 """List environment variables."""
2284
2297
2285 # environ is an instance of UserDict
2298 # environ is an instance of UserDict
2286 return os.environ.data
2299 return os.environ.data
2287
2300
2288 def magic_pushd(self, parameter_s=''):
2301 def magic_pushd(self, parameter_s=''):
2289 """Place the current dir on stack and change directory.
2302 """Place the current dir on stack and change directory.
2290
2303
2291 Usage:\\
2304 Usage:\\
2292 %pushd ['dirname']
2305 %pushd ['dirname']
2293
2306
2294 %pushd with no arguments does a %pushd to your home directory.
2307 %pushd with no arguments does a %pushd to your home directory.
2295 """
2308 """
2296 if parameter_s == '': parameter_s = '~'
2309 if parameter_s == '': parameter_s = '~'
2297 if len(self.dir_stack)>0 and os.path.expanduser(parameter_s) != \
2310 if len(self.dir_stack)>0 and os.path.expanduser(parameter_s) != \
2298 os.path.expanduser(self.dir_stack[0]):
2311 os.path.expanduser(self.dir_stack[0]):
2299 try:
2312 try:
2300 self.magic_cd(parameter_s)
2313 self.magic_cd(parameter_s)
2301 self.dir_stack.insert(0,os.getcwd().replace(self.home_dir,'~'))
2314 self.dir_stack.insert(0,os.getcwd().replace(self.home_dir,'~'))
2302 self.magic_dirs()
2315 self.magic_dirs()
2303 except:
2316 except:
2304 print 'Invalid directory'
2317 print 'Invalid directory'
2305 else:
2318 else:
2306 print 'You are already there!'
2319 print 'You are already there!'
2307
2320
2308 def magic_popd(self, parameter_s=''):
2321 def magic_popd(self, parameter_s=''):
2309 """Change to directory popped off the top of the stack.
2322 """Change to directory popped off the top of the stack.
2310 """
2323 """
2311 if len (self.dir_stack) > 1:
2324 if len (self.dir_stack) > 1:
2312 self.dir_stack.pop(0)
2325 self.dir_stack.pop(0)
2313 self.magic_cd(self.dir_stack[0])
2326 self.magic_cd(self.dir_stack[0])
2314 print self.dir_stack[0]
2327 print self.dir_stack[0]
2315 else:
2328 else:
2316 print "You can't remove the starting directory from the stack:",\
2329 print "You can't remove the starting directory from the stack:",\
2317 self.dir_stack
2330 self.dir_stack
2318
2331
2319 def magic_dirs(self, parameter_s=''):
2332 def magic_dirs(self, parameter_s=''):
2320 """Return the current directory stack."""
2333 """Return the current directory stack."""
2321
2334
2322 return self.dir_stack[:]
2335 return self.dir_stack[:]
2323
2336
2324 def magic_sc(self, parameter_s=''):
2337 def magic_sc(self, parameter_s=''):
2325 """Shell capture - execute a shell command and capture its output.
2338 """Shell capture - execute a shell command and capture its output.
2326
2339
2327 %sc [options] varname=command
2340 %sc [options] varname=command
2328
2341
2329 IPython will run the given command using commands.getoutput(), and
2342 IPython will run the given command using commands.getoutput(), and
2330 will then update the user's interactive namespace with a variable
2343 will then update the user's interactive namespace with a variable
2331 called varname, containing the value of the call. Your command can
2344 called varname, containing the value of the call. Your command can
2332 contain shell wildcards, pipes, etc.
2345 contain shell wildcards, pipes, etc.
2333
2346
2334 The '=' sign in the syntax is mandatory, and the variable name you
2347 The '=' sign in the syntax is mandatory, and the variable name you
2335 supply must follow Python's standard conventions for valid names.
2348 supply must follow Python's standard conventions for valid names.
2336
2349
2337 Options:
2350 Options:
2338
2351
2339 -l: list output. Split the output on newlines into a list before
2352 -l: list output. Split the output on newlines into a list before
2340 assigning it to the given variable. By default the output is stored
2353 assigning it to the given variable. By default the output is stored
2341 as a single string.
2354 as a single string.
2342
2355
2343 -v: verbose. Print the contents of the variable.
2356 -v: verbose. Print the contents of the variable.
2344
2357
2345 In most cases you should not need to split as a list, because the
2358 In most cases you should not need to split as a list, because the
2346 returned value is a special type of string which can automatically
2359 returned value is a special type of string which can automatically
2347 provide its contents either as a list (split on newlines) or as a
2360 provide its contents either as a list (split on newlines) or as a
2348 space-separated string. These are convenient, respectively, either
2361 space-separated string. These are convenient, respectively, either
2349 for sequential processing or to be passed to a shell command.
2362 for sequential processing or to be passed to a shell command.
2350
2363
2351 For example:
2364 For example:
2352
2365
2353 # Capture into variable a
2366 # Capture into variable a
2354 In [9]: sc a=ls *py
2367 In [9]: sc a=ls *py
2355
2368
2356 # a is a string with embedded newlines
2369 # a is a string with embedded newlines
2357 In [10]: a
2370 In [10]: a
2358 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2371 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2359
2372
2360 # which can be seen as a list:
2373 # which can be seen as a list:
2361 In [11]: a.l
2374 In [11]: a.l
2362 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2375 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2363
2376
2364 # or as a whitespace-separated string:
2377 # or as a whitespace-separated string:
2365 In [12]: a.s
2378 In [12]: a.s
2366 Out[12]: 'setup.py win32_manual_post_install.py'
2379 Out[12]: 'setup.py win32_manual_post_install.py'
2367
2380
2368 # a.s is useful to pass as a single command line:
2381 # a.s is useful to pass as a single command line:
2369 In [13]: !wc -l $a.s
2382 In [13]: !wc -l $a.s
2370 146 setup.py
2383 146 setup.py
2371 130 win32_manual_post_install.py
2384 130 win32_manual_post_install.py
2372 276 total
2385 276 total
2373
2386
2374 # while the list form is useful to loop over:
2387 # while the list form is useful to loop over:
2375 In [14]: for f in a.l:
2388 In [14]: for f in a.l:
2376 ....: !wc -l $f
2389 ....: !wc -l $f
2377 ....:
2390 ....:
2378 146 setup.py
2391 146 setup.py
2379 130 win32_manual_post_install.py
2392 130 win32_manual_post_install.py
2380
2393
2381 Similiarly, the lists returned by the -l option are also special, in
2394 Similiarly, the lists returned by the -l option are also special, in
2382 the sense that you can equally invoke the .s attribute on them to
2395 the sense that you can equally invoke the .s attribute on them to
2383 automatically get a whitespace-separated string from their contents:
2396 automatically get a whitespace-separated string from their contents:
2384
2397
2385 In [1]: sc -l b=ls *py
2398 In [1]: sc -l b=ls *py
2386
2399
2387 In [2]: b
2400 In [2]: b
2388 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2401 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2389
2402
2390 In [3]: b.s
2403 In [3]: b.s
2391 Out[3]: 'setup.py win32_manual_post_install.py'
2404 Out[3]: 'setup.py win32_manual_post_install.py'
2392
2405
2393 In summary, both the lists and strings used for ouptut capture have
2406 In summary, both the lists and strings used for ouptut capture have
2394 the following special attributes:
2407 the following special attributes:
2395
2408
2396 .l (or .list) : value as list.
2409 .l (or .list) : value as list.
2397 .n (or .nlstr): value as newline-separated string.
2410 .n (or .nlstr): value as newline-separated string.
2398 .s (or .spstr): value as space-separated string.
2411 .s (or .spstr): value as space-separated string.
2399 """
2412 """
2400
2413
2401 opts,args = self.parse_options(parameter_s,'lv')
2414 opts,args = self.parse_options(parameter_s,'lv')
2402 # Try to get a variable name and command to run
2415 # Try to get a variable name and command to run
2403 try:
2416 try:
2404 # the variable name must be obtained from the parse_options
2417 # the variable name must be obtained from the parse_options
2405 # output, which uses shlex.split to strip options out.
2418 # output, which uses shlex.split to strip options out.
2406 var,_ = args.split('=',1)
2419 var,_ = args.split('=',1)
2407 var = var.strip()
2420 var = var.strip()
2408 # But the the command has to be extracted from the original input
2421 # But the the command has to be extracted from the original input
2409 # parameter_s, not on what parse_options returns, to avoid the
2422 # parameter_s, not on what parse_options returns, to avoid the
2410 # quote stripping which shlex.split performs on it.
2423 # quote stripping which shlex.split performs on it.
2411 _,cmd = parameter_s.split('=',1)
2424 _,cmd = parameter_s.split('=',1)
2412 except ValueError:
2425 except ValueError:
2413 var,cmd = '',''
2426 var,cmd = '',''
2414 if not var:
2427 if not var:
2415 error('you must specify a variable to assign the command to.')
2428 error('you must specify a variable to assign the command to.')
2416 return
2429 return
2417 # If all looks ok, proceed
2430 # If all looks ok, proceed
2418 out,err = self.shell.getoutputerror(cmd)
2431 out,err = self.shell.getoutputerror(cmd)
2419 if err:
2432 if err:
2420 print >> Term.cerr,err
2433 print >> Term.cerr,err
2421 if opts.has_key('l'):
2434 if opts.has_key('l'):
2422 out = SList(out.split('\n'))
2435 out = SList(out.split('\n'))
2423 else:
2436 else:
2424 out = LSString(out)
2437 out = LSString(out)
2425 if opts.has_key('v'):
2438 if opts.has_key('v'):
2426 print '%s ==\n%s' % (var,pformat(out))
2439 print '%s ==\n%s' % (var,pformat(out))
2427 self.shell.user_ns.update({var:out})
2440 self.shell.user_ns.update({var:out})
2428
2441
2429 def magic_sx(self, parameter_s=''):
2442 def magic_sx(self, parameter_s=''):
2430 """Shell execute - run a shell command and capture its output.
2443 """Shell execute - run a shell command and capture its output.
2431
2444
2432 %sx command
2445 %sx command
2433
2446
2434 IPython will run the given command using commands.getoutput(), and
2447 IPython will run the given command using commands.getoutput(), and
2435 return the result formatted as a list (split on '\\n'). Since the
2448 return the result formatted as a list (split on '\\n'). Since the
2436 output is _returned_, it will be stored in ipython's regular output
2449 output is _returned_, it will be stored in ipython's regular output
2437 cache Out[N] and in the '_N' automatic variables.
2450 cache Out[N] and in the '_N' automatic variables.
2438
2451
2439 Notes:
2452 Notes:
2440
2453
2441 1) If an input line begins with '!!', then %sx is automatically
2454 1) If an input line begins with '!!', then %sx is automatically
2442 invoked. That is, while:
2455 invoked. That is, while:
2443 !ls
2456 !ls
2444 causes ipython to simply issue system('ls'), typing
2457 causes ipython to simply issue system('ls'), typing
2445 !!ls
2458 !!ls
2446 is a shorthand equivalent to:
2459 is a shorthand equivalent to:
2447 %sx ls
2460 %sx ls
2448
2461
2449 2) %sx differs from %sc in that %sx automatically splits into a list,
2462 2) %sx differs from %sc in that %sx automatically splits into a list,
2450 like '%sc -l'. The reason for this is to make it as easy as possible
2463 like '%sc -l'. The reason for this is to make it as easy as possible
2451 to process line-oriented shell output via further python commands.
2464 to process line-oriented shell output via further python commands.
2452 %sc is meant to provide much finer control, but requires more
2465 %sc is meant to provide much finer control, but requires more
2453 typing.
2466 typing.
2454
2467
2455 3) Just like %sc -l, this is a list with special attributes:
2468 3) Just like %sc -l, this is a list with special attributes:
2456
2469
2457 .l (or .list) : value as list.
2470 .l (or .list) : value as list.
2458 .n (or .nlstr): value as newline-separated string.
2471 .n (or .nlstr): value as newline-separated string.
2459 .s (or .spstr): value as whitespace-separated string.
2472 .s (or .spstr): value as whitespace-separated string.
2460
2473
2461 This is very useful when trying to use such lists as arguments to
2474 This is very useful when trying to use such lists as arguments to
2462 system commands."""
2475 system commands."""
2463
2476
2464 if parameter_s:
2477 if parameter_s:
2465 out,err = self.shell.getoutputerror(parameter_s)
2478 out,err = self.shell.getoutputerror(parameter_s)
2466 if err:
2479 if err:
2467 print >> Term.cerr,err
2480 print >> Term.cerr,err
2468 return SList(out.split('\n'))
2481 return SList(out.split('\n'))
2469
2482
2470 def magic_bg(self, parameter_s=''):
2483 def magic_bg(self, parameter_s=''):
2471 """Run a job in the background, in a separate thread.
2484 """Run a job in the background, in a separate thread.
2472
2485
2473 For example,
2486 For example,
2474
2487
2475 %bg myfunc(x,y,z=1)
2488 %bg myfunc(x,y,z=1)
2476
2489
2477 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2490 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2478 execution starts, a message will be printed indicating the job
2491 execution starts, a message will be printed indicating the job
2479 number. If your job number is 5, you can use
2492 number. If your job number is 5, you can use
2480
2493
2481 myvar = jobs.result(5) or myvar = jobs[5].result
2494 myvar = jobs.result(5) or myvar = jobs[5].result
2482
2495
2483 to assign this result to variable 'myvar'.
2496 to assign this result to variable 'myvar'.
2484
2497
2485 IPython has a job manager, accessible via the 'jobs' object. You can
2498 IPython has a job manager, accessible via the 'jobs' object. You can
2486 type jobs? to get more information about it, and use jobs.<TAB> to see
2499 type jobs? to get more information about it, and use jobs.<TAB> to see
2487 its attributes. All attributes not starting with an underscore are
2500 its attributes. All attributes not starting with an underscore are
2488 meant for public use.
2501 meant for public use.
2489
2502
2490 In particular, look at the jobs.new() method, which is used to create
2503 In particular, look at the jobs.new() method, which is used to create
2491 new jobs. This magic %bg function is just a convenience wrapper
2504 new jobs. This magic %bg function is just a convenience wrapper
2492 around jobs.new(), for expression-based jobs. If you want to create a
2505 around jobs.new(), for expression-based jobs. If you want to create a
2493 new job with an explicit function object and arguments, you must call
2506 new job with an explicit function object and arguments, you must call
2494 jobs.new() directly.
2507 jobs.new() directly.
2495
2508
2496 The jobs.new docstring also describes in detail several important
2509 The jobs.new docstring also describes in detail several important
2497 caveats associated with a thread-based model for background job
2510 caveats associated with a thread-based model for background job
2498 execution. Type jobs.new? for details.
2511 execution. Type jobs.new? for details.
2499
2512
2500 You can check the status of all jobs with jobs.status().
2513 You can check the status of all jobs with jobs.status().
2501
2514
2502 The jobs variable is set by IPython into the Python builtin namespace.
2515 The jobs variable is set by IPython into the Python builtin namespace.
2503 If you ever declare a variable named 'jobs', you will shadow this
2516 If you ever declare a variable named 'jobs', you will shadow this
2504 name. You can either delete your global jobs variable to regain
2517 name. You can either delete your global jobs variable to regain
2505 access to the job manager, or make a new name and assign it manually
2518 access to the job manager, or make a new name and assign it manually
2506 to the manager (stored in IPython's namespace). For example, to
2519 to the manager (stored in IPython's namespace). For example, to
2507 assign the job manager to the Jobs name, use:
2520 assign the job manager to the Jobs name, use:
2508
2521
2509 Jobs = __builtins__.jobs"""
2522 Jobs = __builtins__.jobs"""
2510
2523
2511 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2524 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2512
2525
2513 def magic_bookmark(self, parameter_s=''):
2526 def magic_bookmark(self, parameter_s=''):
2514 """Manage IPython's bookmark system.
2527 """Manage IPython's bookmark system.
2515
2528
2516 %bookmark <name> - set bookmark to current dir
2529 %bookmark <name> - set bookmark to current dir
2517 %bookmark <name> <dir> - set bookmark to <dir>
2530 %bookmark <name> <dir> - set bookmark to <dir>
2518 %bookmark -l - list all bookmarks
2531 %bookmark -l - list all bookmarks
2519 %bookmark -d <name> - remove bookmark
2532 %bookmark -d <name> - remove bookmark
2520 %bookmark -r - remove all bookmarks
2533 %bookmark -r - remove all bookmarks
2521
2534
2522 You can later on access a bookmarked folder with:
2535 You can later on access a bookmarked folder with:
2523 %cd -b <name>
2536 %cd -b <name>
2524 or simply '%cd <name>' if there is no directory called <name> AND
2537 or simply '%cd <name>' if there is no directory called <name> AND
2525 there is such a bookmark defined.
2538 there is such a bookmark defined.
2526
2539
2527 Your bookmarks persist through IPython sessions, but they are
2540 Your bookmarks persist through IPython sessions, but they are
2528 associated with each profile."""
2541 associated with each profile."""
2529
2542
2530 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2543 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2531 if len(args) > 2:
2544 if len(args) > 2:
2532 error('You can only give at most two arguments')
2545 error('You can only give at most two arguments')
2533 return
2546 return
2534
2547
2535 bkms = self.shell.persist.get('bookmarks',{})
2548 bkms = self.shell.persist.get('bookmarks',{})
2536
2549
2537 if opts.has_key('d'):
2550 if opts.has_key('d'):
2538 try:
2551 try:
2539 todel = args[0]
2552 todel = args[0]
2540 except IndexError:
2553 except IndexError:
2541 error('You must provide a bookmark to delete')
2554 error('You must provide a bookmark to delete')
2542 else:
2555 else:
2543 try:
2556 try:
2544 del bkms[todel]
2557 del bkms[todel]
2545 except:
2558 except:
2546 error("Can't delete bookmark '%s'" % todel)
2559 error("Can't delete bookmark '%s'" % todel)
2547 elif opts.has_key('r'):
2560 elif opts.has_key('r'):
2548 bkms = {}
2561 bkms = {}
2549 elif opts.has_key('l'):
2562 elif opts.has_key('l'):
2550 bks = bkms.keys()
2563 bks = bkms.keys()
2551 bks.sort()
2564 bks.sort()
2552 if bks:
2565 if bks:
2553 size = max(map(len,bks))
2566 size = max(map(len,bks))
2554 else:
2567 else:
2555 size = 0
2568 size = 0
2556 fmt = '%-'+str(size)+'s -> %s'
2569 fmt = '%-'+str(size)+'s -> %s'
2557 print 'Current bookmarks:'
2570 print 'Current bookmarks:'
2558 for bk in bks:
2571 for bk in bks:
2559 print fmt % (bk,bkms[bk])
2572 print fmt % (bk,bkms[bk])
2560 else:
2573 else:
2561 if not args:
2574 if not args:
2562 error("You must specify the bookmark name")
2575 error("You must specify the bookmark name")
2563 elif len(args)==1:
2576 elif len(args)==1:
2564 bkms[args[0]] = os.getcwd()
2577 bkms[args[0]] = os.getcwd()
2565 elif len(args)==2:
2578 elif len(args)==2:
2566 bkms[args[0]] = args[1]
2579 bkms[args[0]] = args[1]
2567 self.persist['bookmarks'] = bkms
2580 self.persist['bookmarks'] = bkms
2568
2581
2569 def magic_pycat(self, parameter_s=''):
2582 def magic_pycat(self, parameter_s=''):
2570 """Show a syntax-highlighted file through a pager.
2583 """Show a syntax-highlighted file through a pager.
2571
2584
2572 This magic is similar to the cat utility, but it will assume the file
2585 This magic is similar to the cat utility, but it will assume the file
2573 to be Python source and will show it with syntax highlighting. """
2586 to be Python source and will show it with syntax highlighting. """
2574
2587
2575 filename = get_py_filename(parameter_s)
2588 filename = get_py_filename(parameter_s)
2576 page(self.shell.colorize(file_read(filename)),
2589 page(self.shell.colorize(file_read(filename)),
2577 screen_lines=self.shell.rc.screen_length)
2590 screen_lines=self.shell.rc.screen_length)
2578
2591
2579 # end Magic
2592 # end Magic
@@ -1,1964 +1,1958 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 960 2005-12-28 06:51:01Z fperez $
9 $Id: iplib.py 962 2005-12-28 18:04:59Z 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-2005 Fernando Perez. <fperez@colorado.edu>
14 # Copyright (C) 2001-2005 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 traceback
58 import traceback
59 import types
59 import types
60
60
61 from pprint import pprint, pformat
61 from pprint import pprint, pformat
62
62
63 # IPython's own modules
63 # IPython's own modules
64 import IPython
64 import IPython
65 from IPython import OInspect,PyColorize,ultraTB
65 from IPython import OInspect,PyColorize,ultraTB
66 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
66 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
67 from IPython.FakeModule import FakeModule
67 from IPython.FakeModule import FakeModule
68 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
68 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
69 from IPython.Logger import Logger
69 from IPython.Logger import Logger
70 from IPython.Magic import Magic,magic2python
70 from IPython.Magic import Magic,magic2python
71 from IPython.Struct import Struct
71 from IPython.Struct import Struct
72 from IPython.background_jobs import BackgroundJobManager
72 from IPython.background_jobs import BackgroundJobManager
73 from IPython.usage import cmd_line_usage,interactive_usage
73 from IPython.usage import cmd_line_usage,interactive_usage
74 from IPython.genutils import *
74 from IPython.genutils import *
75
75
76 # store the builtin raw_input globally, and use this always, in case user code
76 # store the builtin raw_input globally, and use this always, in case user code
77 # overwrites it (like wx.py.PyShell does)
77 # overwrites it (like wx.py.PyShell does)
78 raw_input_original = raw_input
78 raw_input_original = raw_input
79
79
80 #****************************************************************************
80 #****************************************************************************
81 # Some utility function definitions
81 # Some utility function definitions
82
82
83 # This can be replaced with an isspace() call once we drop 2.2 compatibility
83 # This can be replaced with an isspace() call once we drop 2.2 compatibility
84 _isspace_match = re.compile(r'^\s+$').match
84 _isspace_match = re.compile(r'^\s+$').match
85 def isspace(s):
85 def isspace(s):
86 return bool(_isspace_match(s))
86 return bool(_isspace_match(s))
87
87
88 def esc_quotes(strng):
88 def esc_quotes(strng):
89 """Return the input string with single and double quotes escaped out"""
89 """Return the input string with single and double quotes escaped out"""
90
90
91 return strng.replace('"','\\"').replace("'","\\'")
91 return strng.replace('"','\\"').replace("'","\\'")
92
92
93 def import_fail_info(mod_name,fns=None):
93 def import_fail_info(mod_name,fns=None):
94 """Inform load failure for a module."""
94 """Inform load failure for a module."""
95
95
96 if fns == None:
96 if fns == None:
97 warn("Loading of %s failed.\n" % (mod_name,))
97 warn("Loading of %s failed.\n" % (mod_name,))
98 else:
98 else:
99 warn("Loading of %s from %s failed.\n" % (fns,mod_name))
99 warn("Loading of %s from %s failed.\n" % (fns,mod_name))
100
100
101 def qw_lol(indata):
101 def qw_lol(indata):
102 """qw_lol('a b') -> [['a','b']],
102 """qw_lol('a b') -> [['a','b']],
103 otherwise it's just a call to qw().
103 otherwise it's just a call to qw().
104
104
105 We need this to make sure the modules_some keys *always* end up as a
105 We need this to make sure the modules_some keys *always* end up as a
106 list of lists."""
106 list of lists."""
107
107
108 if type(indata) in StringTypes:
108 if type(indata) in StringTypes:
109 return [qw(indata)]
109 return [qw(indata)]
110 else:
110 else:
111 return qw(indata)
111 return qw(indata)
112
112
113 def ipmagic(arg_s):
113 def ipmagic(arg_s):
114 """Call a magic function by name.
114 """Call a magic function by name.
115
115
116 Input: a string containing the name of the magic function to call and any
116 Input: a string containing the name of the magic function to call and any
117 additional arguments to be passed to the magic.
117 additional arguments to be passed to the magic.
118
118
119 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
119 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
120 prompt:
120 prompt:
121
121
122 In[1]: %name -opt foo bar
122 In[1]: %name -opt foo bar
123
123
124 To call a magic without arguments, simply use ipmagic('name').
124 To call a magic without arguments, simply use ipmagic('name').
125
125
126 This provides a proper Python function to call IPython's magics in any
126 This provides a proper Python function to call IPython's magics in any
127 valid Python code you can type at the interpreter, including loops and
127 valid Python code you can type at the interpreter, including loops and
128 compound statements. It is added by IPython to the Python builtin
128 compound statements. It is added by IPython to the Python builtin
129 namespace upon initialization."""
129 namespace upon initialization."""
130
130
131 args = arg_s.split(' ',1)
131 args = arg_s.split(' ',1)
132 magic_name = args[0]
132 magic_name = args[0]
133 if magic_name.startswith(__IPYTHON__.ESC_MAGIC):
133 if magic_name.startswith(__IPYTHON__.ESC_MAGIC):
134 magic_name = magic_name[1:]
134 magic_name = magic_name[1:]
135 try:
135 try:
136 magic_args = args[1]
136 magic_args = args[1]
137 except IndexError:
137 except IndexError:
138 magic_args = ''
138 magic_args = ''
139 fn = getattr(__IPYTHON__,'magic_'+magic_name,None)
139 fn = getattr(__IPYTHON__,'magic_'+magic_name,None)
140 if fn is None:
140 if fn is None:
141 error("Magic function `%s` not found." % magic_name)
141 error("Magic function `%s` not found." % magic_name)
142 else:
142 else:
143 magic_args = __IPYTHON__.var_expand(magic_args)
143 magic_args = __IPYTHON__.var_expand(magic_args)
144 return fn(magic_args)
144 return fn(magic_args)
145
145
146 def ipalias(arg_s):
146 def ipalias(arg_s):
147 """Call an alias by name.
147 """Call an alias by name.
148
148
149 Input: a string containing the name of the alias to call and any
149 Input: a string containing the name of the alias to call and any
150 additional arguments to be passed to the magic.
150 additional arguments to be passed to the magic.
151
151
152 ipalias('name -opt foo bar') is equivalent to typing at the ipython
152 ipalias('name -opt foo bar') is equivalent to typing at the ipython
153 prompt:
153 prompt:
154
154
155 In[1]: name -opt foo bar
155 In[1]: name -opt foo bar
156
156
157 To call an alias without arguments, simply use ipalias('name').
157 To call an alias without arguments, simply use ipalias('name').
158
158
159 This provides a proper Python function to call IPython's aliases in any
159 This provides a proper Python function to call IPython's aliases in any
160 valid Python code you can type at the interpreter, including loops and
160 valid Python code you can type at the interpreter, including loops and
161 compound statements. It is added by IPython to the Python builtin
161 compound statements. It is added by IPython to the Python builtin
162 namespace upon initialization."""
162 namespace upon initialization."""
163
163
164 args = arg_s.split(' ',1)
164 args = arg_s.split(' ',1)
165 alias_name = args[0]
165 alias_name = args[0]
166 try:
166 try:
167 alias_args = args[1]
167 alias_args = args[1]
168 except IndexError:
168 except IndexError:
169 alias_args = ''
169 alias_args = ''
170 if alias_name in __IPYTHON__.alias_table:
170 if alias_name in __IPYTHON__.alias_table:
171 __IPYTHON__.call_alias(alias_name,alias_args)
171 __IPYTHON__.call_alias(alias_name,alias_args)
172 else:
172 else:
173 error("Alias `%s` not found." % alias_name)
173 error("Alias `%s` not found." % alias_name)
174
174
175 def softspace(file, newvalue):
175 def softspace(file, newvalue):
176 """Copied from code.py, to remove the dependency"""
176 """Copied from code.py, to remove the dependency"""
177 oldvalue = 0
177 oldvalue = 0
178 try:
178 try:
179 oldvalue = file.softspace
179 oldvalue = file.softspace
180 except AttributeError:
180 except AttributeError:
181 pass
181 pass
182 try:
182 try:
183 file.softspace = newvalue
183 file.softspace = newvalue
184 except (AttributeError, TypeError):
184 except (AttributeError, TypeError):
185 # "attribute-less object" or "read-only attributes"
185 # "attribute-less object" or "read-only attributes"
186 pass
186 pass
187 return oldvalue
187 return oldvalue
188
188
189
189
190 #****************************************************************************
190 #****************************************************************************
191 # Local use exceptions
191 # Local use exceptions
192 class SpaceInInput(exceptions.Exception): pass
192 class SpaceInInput(exceptions.Exception): pass
193
193
194 class IPythonExit(exceptions.Exception): pass
195
196 #****************************************************************************
194 #****************************************************************************
197 # Local use classes
195 # Local use classes
198 class Bunch: pass
196 class Bunch: pass
199
197
200 class InputList(list):
198 class InputList(list):
201 """Class to store user input.
199 """Class to store user input.
202
200
203 It's basically a list, but slices return a string instead of a list, thus
201 It's basically a list, but slices return a string instead of a list, thus
204 allowing things like (assuming 'In' is an instance):
202 allowing things like (assuming 'In' is an instance):
205
203
206 exec In[4:7]
204 exec In[4:7]
207
205
208 or
206 or
209
207
210 exec In[5:9] + In[14] + In[21:25]"""
208 exec In[5:9] + In[14] + In[21:25]"""
211
209
212 def __getslice__(self,i,j):
210 def __getslice__(self,i,j):
213 return ''.join(list.__getslice__(self,i,j))
211 return ''.join(list.__getslice__(self,i,j))
214
212
215 class SyntaxTB(ultraTB.ListTB):
213 class SyntaxTB(ultraTB.ListTB):
216 """Extension which holds some state: the last exception value"""
214 """Extension which holds some state: the last exception value"""
217
215
218 def __init__(self,color_scheme = 'NoColor'):
216 def __init__(self,color_scheme = 'NoColor'):
219 ultraTB.ListTB.__init__(self,color_scheme)
217 ultraTB.ListTB.__init__(self,color_scheme)
220 self.last_syntax_error = None
218 self.last_syntax_error = None
221
219
222 def __call__(self, etype, value, elist):
220 def __call__(self, etype, value, elist):
223 self.last_syntax_error = value
221 self.last_syntax_error = value
224 ultraTB.ListTB.__call__(self,etype,value,elist)
222 ultraTB.ListTB.__call__(self,etype,value,elist)
225
223
226 def clear_err_state(self):
224 def clear_err_state(self):
227 """Return the current error state and clear it"""
225 """Return the current error state and clear it"""
228 e = self.last_syntax_error
226 e = self.last_syntax_error
229 self.last_syntax_error = None
227 self.last_syntax_error = None
230 return e
228 return e
231
229
232 #****************************************************************************
230 #****************************************************************************
233 # Main IPython class
231 # Main IPython class
234 class InteractiveShell(Logger, Magic):
232 class InteractiveShell(Logger, Magic):
235 """An enhanced console for Python."""
233 """An enhanced console for Python."""
236
234
237 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
235 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
238 user_ns = None,user_global_ns=None,banner2='',
236 user_ns = None,user_global_ns=None,banner2='',
239 custom_exceptions=((),None),embedded=False):
237 custom_exceptions=((),None),embedded=False):
240
238
241 # Put a reference to self in builtins so that any form of embedded or
239 # Put a reference to self in builtins so that any form of embedded or
242 # imported code can test for being inside IPython.
240 # imported code can test for being inside IPython.
243 __builtin__.__IPYTHON__ = self
241 __builtin__.__IPYTHON__ = self
244
242
245 # And load into builtins ipmagic/ipalias as well
243 # And load into builtins ipmagic/ipalias as well
246 __builtin__.ipmagic = ipmagic
244 __builtin__.ipmagic = ipmagic
247 __builtin__.ipalias = ipalias
245 __builtin__.ipalias = ipalias
248
246
249 # Add to __builtin__ other parts of IPython's public API
247 # Add to __builtin__ other parts of IPython's public API
250 __builtin__.ip_set_hook = self.set_hook
248 __builtin__.ip_set_hook = self.set_hook
251
249
252 # Keep in the builtins a flag for when IPython is active. We set it
250 # Keep in the builtins a flag for when IPython is active. We set it
253 # with setdefault so that multiple nested IPythons don't clobber one
251 # with setdefault so that multiple nested IPythons don't clobber one
254 # another. Each will increase its value by one upon being activated,
252 # another. Each will increase its value by one upon being activated,
255 # which also gives us a way to determine the nesting level.
253 # which also gives us a way to determine the nesting level.
256 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
254 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
257
255
258 # Do the intuitively correct thing for quit/exit: we remove the
256 # Do the intuitively correct thing for quit/exit: we remove the
259 # builtins if they exist, and our own prefilter routine will handle
257 # builtins if they exist, and our own prefilter routine will handle
260 # these special cases
258 # these special cases
261 try:
259 try:
262 del __builtin__.exit, __builtin__.quit
260 del __builtin__.exit, __builtin__.quit
263 except AttributeError:
261 except AttributeError:
264 pass
262 pass
265
263
266 # We need to know whether the instance is meant for embedding, since
264 # We need to know whether the instance is meant for embedding, since
267 # global/local namespaces need to be handled differently in that case
265 # global/local namespaces need to be handled differently in that case
268 self.embedded = embedded
266 self.embedded = embedded
269
267
270 # command compiler
268 # command compiler
271 self.compile = codeop.CommandCompiler()
269 self.compile = codeop.CommandCompiler()
272
270
273 # User input buffer
271 # User input buffer
274 self.buffer = []
272 self.buffer = []
275
273
276 # Default name given in compilation of code
274 # Default name given in compilation of code
277 self.filename = '<ipython console>'
275 self.filename = '<ipython console>'
278
276
279 # Create the namespace where the user will operate. user_ns is
277 # Create the namespace where the user will operate. user_ns is
280 # normally the only one used, and it is passed to the exec calls as
278 # normally the only one used, and it is passed to the exec calls as
281 # the locals argument. But we do carry a user_global_ns namespace
279 # the locals argument. But we do carry a user_global_ns namespace
282 # given as the exec 'globals' argument, This is useful in embedding
280 # given as the exec 'globals' argument, This is useful in embedding
283 # situations where the ipython shell opens in a context where the
281 # situations where the ipython shell opens in a context where the
284 # distinction between locals and globals is meaningful.
282 # distinction between locals and globals is meaningful.
285
283
286 # FIXME. For some strange reason, __builtins__ is showing up at user
284 # FIXME. For some strange reason, __builtins__ is showing up at user
287 # level as a dict instead of a module. This is a manual fix, but I
285 # level as a dict instead of a module. This is a manual fix, but I
288 # should really track down where the problem is coming from. Alex
286 # should really track down where the problem is coming from. Alex
289 # Schmolck reported this problem first.
287 # Schmolck reported this problem first.
290
288
291 # A useful post by Alex Martelli on this topic:
289 # A useful post by Alex Martelli on this topic:
292 # Re: inconsistent value from __builtins__
290 # Re: inconsistent value from __builtins__
293 # Von: Alex Martelli <aleaxit@yahoo.com>
291 # Von: Alex Martelli <aleaxit@yahoo.com>
294 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
292 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
295 # Gruppen: comp.lang.python
293 # Gruppen: comp.lang.python
296 # Referenzen: 1
294 # Referenzen: 1
297
295
298 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
296 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
299 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
297 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
300 # > <type 'dict'>
298 # > <type 'dict'>
301 # > >>> print type(__builtins__)
299 # > >>> print type(__builtins__)
302 # > <type 'module'>
300 # > <type 'module'>
303 # > Is this difference in return value intentional?
301 # > Is this difference in return value intentional?
304
302
305 # Well, it's documented that '__builtins__' can be either a dictionary
303 # Well, it's documented that '__builtins__' can be either a dictionary
306 # or a module, and it's been that way for a long time. Whether it's
304 # or a module, and it's been that way for a long time. Whether it's
307 # intentional (or sensible), I don't know. In any case, the idea is
305 # intentional (or sensible), I don't know. In any case, the idea is
308 # that if you need to access the built-in namespace directly, you
306 # that if you need to access the built-in namespace directly, you
309 # should start with "import __builtin__" (note, no 's') which will
307 # should start with "import __builtin__" (note, no 's') which will
310 # definitely give you a module. Yeah, it's somewhat confusing:-(.
308 # definitely give you a module. Yeah, it's somewhat confusing:-(.
311
309
312 if user_ns is None:
310 if user_ns is None:
313 # Set __name__ to __main__ to better match the behavior of the
311 # Set __name__ to __main__ to better match the behavior of the
314 # normal interpreter.
312 # normal interpreter.
315 user_ns = {'__name__' :'__main__',
313 user_ns = {'__name__' :'__main__',
316 '__builtins__' : __builtin__,
314 '__builtins__' : __builtin__,
317 }
315 }
318
316
319 if user_global_ns is None:
317 if user_global_ns is None:
320 user_global_ns = {}
318 user_global_ns = {}
321
319
322 # Assign namespaces
320 # Assign namespaces
323 # This is the namespace where all normal user variables live
321 # This is the namespace where all normal user variables live
324 self.user_ns = user_ns
322 self.user_ns = user_ns
325 # Embedded instances require a separate namespace for globals.
323 # Embedded instances require a separate namespace for globals.
326 # Normally this one is unused by non-embedded instances.
324 # Normally this one is unused by non-embedded instances.
327 self.user_global_ns = user_global_ns
325 self.user_global_ns = user_global_ns
328 # A namespace to keep track of internal data structures to prevent
326 # A namespace to keep track of internal data structures to prevent
329 # them from cluttering user-visible stuff. Will be updated later
327 # them from cluttering user-visible stuff. Will be updated later
330 self.internal_ns = {}
328 self.internal_ns = {}
331
329
332 # Namespace of system aliases. Each entry in the alias
330 # Namespace of system aliases. Each entry in the alias
333 # table must be a 2-tuple of the form (N,name), where N is the number
331 # table must be a 2-tuple of the form (N,name), where N is the number
334 # of positional arguments of the alias.
332 # of positional arguments of the alias.
335 self.alias_table = {}
333 self.alias_table = {}
336
334
337 # A table holding all the namespaces IPython deals with, so that
335 # A table holding all the namespaces IPython deals with, so that
338 # introspection facilities can search easily.
336 # introspection facilities can search easily.
339 self.ns_table = {'user':user_ns,
337 self.ns_table = {'user':user_ns,
340 'user_global':user_global_ns,
338 'user_global':user_global_ns,
341 'alias':self.alias_table,
339 'alias':self.alias_table,
342 'internal':self.internal_ns,
340 'internal':self.internal_ns,
343 'builtin':__builtin__.__dict__
341 'builtin':__builtin__.__dict__
344 }
342 }
345
343
346 # The user namespace MUST have a pointer to the shell itself.
344 # The user namespace MUST have a pointer to the shell itself.
347 self.user_ns[name] = self
345 self.user_ns[name] = self
348
346
349 # We need to insert into sys.modules something that looks like a
347 # We need to insert into sys.modules something that looks like a
350 # module but which accesses the IPython namespace, for shelve and
348 # module but which accesses the IPython namespace, for shelve and
351 # pickle to work interactively. Normally they rely on getting
349 # pickle to work interactively. Normally they rely on getting
352 # everything out of __main__, but for embedding purposes each IPython
350 # everything out of __main__, but for embedding purposes each IPython
353 # instance has its own private namespace, so we can't go shoving
351 # instance has its own private namespace, so we can't go shoving
354 # everything into __main__.
352 # everything into __main__.
355
353
356 # note, however, that we should only do this for non-embedded
354 # note, however, that we should only do this for non-embedded
357 # ipythons, which really mimic the __main__.__dict__ with their own
355 # ipythons, which really mimic the __main__.__dict__ with their own
358 # namespace. Embedded instances, on the other hand, should not do
356 # namespace. Embedded instances, on the other hand, should not do
359 # this because they need to manage the user local/global namespaces
357 # this because they need to manage the user local/global namespaces
360 # only, but they live within a 'normal' __main__ (meaning, they
358 # only, but they live within a 'normal' __main__ (meaning, they
361 # shouldn't overtake the execution environment of the script they're
359 # shouldn't overtake the execution environment of the script they're
362 # embedded in).
360 # embedded in).
363
361
364 if not embedded:
362 if not embedded:
365 try:
363 try:
366 main_name = self.user_ns['__name__']
364 main_name = self.user_ns['__name__']
367 except KeyError:
365 except KeyError:
368 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
366 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
369 else:
367 else:
370 #print "pickle hack in place" # dbg
368 #print "pickle hack in place" # dbg
371 sys.modules[main_name] = FakeModule(self.user_ns)
369 sys.modules[main_name] = FakeModule(self.user_ns)
372
370
373 # List of input with multi-line handling.
371 # List of input with multi-line handling.
374 # Fill its zero entry, user counter starts at 1
372 # Fill its zero entry, user counter starts at 1
375 self.input_hist = InputList(['\n'])
373 self.input_hist = InputList(['\n'])
376
374
377 # list of visited directories
375 # list of visited directories
378 try:
376 try:
379 self.dir_hist = [os.getcwd()]
377 self.dir_hist = [os.getcwd()]
380 except IOError, e:
378 except IOError, e:
381 self.dir_hist = []
379 self.dir_hist = []
382
380
383 # dict of output history
381 # dict of output history
384 self.output_hist = {}
382 self.output_hist = {}
385
383
386 # dict of things NOT to alias (keywords, builtins and some magics)
384 # dict of things NOT to alias (keywords, builtins and some magics)
387 no_alias = {}
385 no_alias = {}
388 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
386 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
389 for key in keyword.kwlist + no_alias_magics:
387 for key in keyword.kwlist + no_alias_magics:
390 no_alias[key] = 1
388 no_alias[key] = 1
391 no_alias.update(__builtin__.__dict__)
389 no_alias.update(__builtin__.__dict__)
392 self.no_alias = no_alias
390 self.no_alias = no_alias
393
391
394 # make global variables for user access to these
392 # make global variables for user access to these
395 self.user_ns['_ih'] = self.input_hist
393 self.user_ns['_ih'] = self.input_hist
396 self.user_ns['_oh'] = self.output_hist
394 self.user_ns['_oh'] = self.output_hist
397 self.user_ns['_dh'] = self.dir_hist
395 self.user_ns['_dh'] = self.dir_hist
398
396
399 # user aliases to input and output histories
397 # user aliases to input and output histories
400 self.user_ns['In'] = self.input_hist
398 self.user_ns['In'] = self.input_hist
401 self.user_ns['Out'] = self.output_hist
399 self.user_ns['Out'] = self.output_hist
402
400
403 # Store the actual shell's name
401 # Store the actual shell's name
404 self.name = name
402 self.name = name
405
403
406 # Object variable to store code object waiting execution. This is
404 # Object variable to store code object waiting execution. This is
407 # used mainly by the multithreaded shells, but it can come in handy in
405 # used mainly by the multithreaded shells, but it can come in handy in
408 # other situations. No need to use a Queue here, since it's a single
406 # other situations. No need to use a Queue here, since it's a single
409 # item which gets cleared once run.
407 # item which gets cleared once run.
410 self.code_to_run = None
408 self.code_to_run = None
411
409
412 # Job manager (for jobs run as background threads)
410 # Job manager (for jobs run as background threads)
413 self.jobs = BackgroundJobManager()
411 self.jobs = BackgroundJobManager()
414 # Put the job manager into builtins so it's always there.
412 # Put the job manager into builtins so it's always there.
415 __builtin__.jobs = self.jobs
413 __builtin__.jobs = self.jobs
416
414
417 # escapes for automatic behavior on the command line
415 # escapes for automatic behavior on the command line
418 self.ESC_SHELL = '!'
416 self.ESC_SHELL = '!'
419 self.ESC_HELP = '?'
417 self.ESC_HELP = '?'
420 self.ESC_MAGIC = '%'
418 self.ESC_MAGIC = '%'
421 self.ESC_QUOTE = ','
419 self.ESC_QUOTE = ','
422 self.ESC_QUOTE2 = ';'
420 self.ESC_QUOTE2 = ';'
423 self.ESC_PAREN = '/'
421 self.ESC_PAREN = '/'
424
422
425 # And their associated handlers
423 # And their associated handlers
426 self.esc_handlers = {self.ESC_PAREN:self.handle_auto,
424 self.esc_handlers = {self.ESC_PAREN:self.handle_auto,
427 self.ESC_QUOTE:self.handle_auto,
425 self.ESC_QUOTE:self.handle_auto,
428 self.ESC_QUOTE2:self.handle_auto,
426 self.ESC_QUOTE2:self.handle_auto,
429 self.ESC_MAGIC:self.handle_magic,
427 self.ESC_MAGIC:self.handle_magic,
430 self.ESC_HELP:self.handle_help,
428 self.ESC_HELP:self.handle_help,
431 self.ESC_SHELL:self.handle_shell_escape,
429 self.ESC_SHELL:self.handle_shell_escape,
432 }
430 }
433
431
434 # class initializations
432 # class initializations
435 Logger.__init__(self,log_ns = self.user_ns)
433 Logger.__init__(self,log_ns = self.user_ns)
436 Magic.__init__(self,self)
434 Magic.__init__(self,self)
437
435
438 # an ugly hack to get a pointer to the shell, so I can start writing
436 # an ugly hack to get a pointer to the shell, so I can start writing
439 # magic code via this pointer instead of the current mixin salad.
437 # magic code via this pointer instead of the current mixin salad.
440 Magic.set_shell(self,self)
438 Magic.set_shell(self,self)
441
439
442 # Python source parser/formatter for syntax highlighting
440 # Python source parser/formatter for syntax highlighting
443 pyformat = PyColorize.Parser().format
441 pyformat = PyColorize.Parser().format
444 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
442 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
445
443
446 # hooks holds pointers used for user-side customizations
444 # hooks holds pointers used for user-side customizations
447 self.hooks = Struct()
445 self.hooks = Struct()
448
446
449 # Set all default hooks, defined in the IPython.hooks module.
447 # Set all default hooks, defined in the IPython.hooks module.
450 hooks = IPython.hooks
448 hooks = IPython.hooks
451 for hook_name in hooks.__all__:
449 for hook_name in hooks.__all__:
452 self.set_hook(hook_name,getattr(hooks,hook_name))
450 self.set_hook(hook_name,getattr(hooks,hook_name))
453
451
454 # Flag to mark unconditional exit
452 # Flag to mark unconditional exit
455 self.exit_now = False
453 self.exit_now = False
456
454
457 self.usage_min = """\
455 self.usage_min = """\
458 An enhanced console for Python.
456 An enhanced console for Python.
459 Some of its features are:
457 Some of its features are:
460 - Readline support if the readline library is present.
458 - Readline support if the readline library is present.
461 - Tab completion in the local namespace.
459 - Tab completion in the local namespace.
462 - Logging of input, see command-line options.
460 - Logging of input, see command-line options.
463 - System shell escape via ! , eg !ls.
461 - System shell escape via ! , eg !ls.
464 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
462 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
465 - Keeps track of locally defined variables via %who, %whos.
463 - Keeps track of locally defined variables via %who, %whos.
466 - Show object information with a ? eg ?x or x? (use ?? for more info).
464 - Show object information with a ? eg ?x or x? (use ?? for more info).
467 """
465 """
468 if usage: self.usage = usage
466 if usage: self.usage = usage
469 else: self.usage = self.usage_min
467 else: self.usage = self.usage_min
470
468
471 # Storage
469 # Storage
472 self.rc = rc # This will hold all configuration information
470 self.rc = rc # This will hold all configuration information
473 self.inputcache = []
471 self.inputcache = []
474 self._boundcache = []
472 self._boundcache = []
475 self.pager = 'less'
473 self.pager = 'less'
476 # temporary files used for various purposes. Deleted at exit.
474 # temporary files used for various purposes. Deleted at exit.
477 self.tempfiles = []
475 self.tempfiles = []
478
476
479 # Keep track of readline usage (later set by init_readline)
477 # Keep track of readline usage (later set by init_readline)
480 self.has_readline = False
478 self.has_readline = False
481
479
482 # for pushd/popd management
480 # for pushd/popd management
483 try:
481 try:
484 self.home_dir = get_home_dir()
482 self.home_dir = get_home_dir()
485 except HomeDirError,msg:
483 except HomeDirError,msg:
486 fatal(msg)
484 fatal(msg)
487
485
488 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
486 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
489
487
490 # Functions to call the underlying shell.
488 # Functions to call the underlying shell.
491
489
492 # utility to expand user variables via Itpl
490 # utility to expand user variables via Itpl
493 self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'),
491 self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'),
494 self.user_ns))
492 self.user_ns))
495 # The first is similar to os.system, but it doesn't return a value,
493 # The first is similar to os.system, but it doesn't return a value,
496 # and it allows interpolation of variables in the user's namespace.
494 # and it allows interpolation of variables in the user's namespace.
497 self.system = lambda cmd: shell(self.var_expand(cmd),
495 self.system = lambda cmd: shell(self.var_expand(cmd),
498 header='IPython system call: ',
496 header='IPython system call: ',
499 verbose=self.rc.system_verbose)
497 verbose=self.rc.system_verbose)
500 # These are for getoutput and getoutputerror:
498 # These are for getoutput and getoutputerror:
501 self.getoutput = lambda cmd: \
499 self.getoutput = lambda cmd: \
502 getoutput(self.var_expand(cmd),
500 getoutput(self.var_expand(cmd),
503 header='IPython system call: ',
501 header='IPython system call: ',
504 verbose=self.rc.system_verbose)
502 verbose=self.rc.system_verbose)
505 self.getoutputerror = lambda cmd: \
503 self.getoutputerror = lambda cmd: \
506 getoutputerror(str(ItplNS(cmd.replace('#','\#'),
504 getoutputerror(str(ItplNS(cmd.replace('#','\#'),
507 self.user_ns)),
505 self.user_ns)),
508 header='IPython system call: ',
506 header='IPython system call: ',
509 verbose=self.rc.system_verbose)
507 verbose=self.rc.system_verbose)
510
508
511 # RegExp for splitting line contents into pre-char//first
509 # RegExp for splitting line contents into pre-char//first
512 # word-method//rest. For clarity, each group in on one line.
510 # word-method//rest. For clarity, each group in on one line.
513
511
514 # WARNING: update the regexp if the above escapes are changed, as they
512 # WARNING: update the regexp if the above escapes are changed, as they
515 # are hardwired in.
513 # are hardwired in.
516
514
517 # Don't get carried away with trying to make the autocalling catch too
515 # Don't get carried away with trying to make the autocalling catch too
518 # much: it's better to be conservative rather than to trigger hidden
516 # much: it's better to be conservative rather than to trigger hidden
519 # evals() somewhere and end up causing side effects.
517 # evals() somewhere and end up causing side effects.
520
518
521 self.line_split = re.compile(r'^([\s*,;/])'
519 self.line_split = re.compile(r'^([\s*,;/])'
522 r'([\?\w\.]+\w*\s*)'
520 r'([\?\w\.]+\w*\s*)'
523 r'(\(?.*$)')
521 r'(\(?.*$)')
524
522
525 # Original re, keep around for a while in case changes break something
523 # Original re, keep around for a while in case changes break something
526 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
524 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
527 # r'(\s*[\?\w\.]+\w*\s*)'
525 # r'(\s*[\?\w\.]+\w*\s*)'
528 # r'(\(?.*$)')
526 # r'(\(?.*$)')
529
527
530 # RegExp to identify potential function names
528 # RegExp to identify potential function names
531 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
529 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
532 # RegExp to exclude strings with this start from autocalling
530 # RegExp to exclude strings with this start from autocalling
533 self.re_exclude_auto = re.compile('^[!=()<>,\*/\+-]|^is ')
531 self.re_exclude_auto = re.compile('^[!=()<>,\*/\+-]|^is ')
534
532
535 # try to catch also methods for stuff in lists/tuples/dicts: off
533 # try to catch also methods for stuff in lists/tuples/dicts: off
536 # (experimental). For this to work, the line_split regexp would need
534 # (experimental). For this to work, the line_split regexp would need
537 # to be modified so it wouldn't break things at '['. That line is
535 # to be modified so it wouldn't break things at '['. That line is
538 # nasty enough that I shouldn't change it until I can test it _well_.
536 # nasty enough that I shouldn't change it until I can test it _well_.
539 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
537 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
540
538
541 # keep track of where we started running (mainly for crash post-mortem)
539 # keep track of where we started running (mainly for crash post-mortem)
542 self.starting_dir = os.getcwd()
540 self.starting_dir = os.getcwd()
543
541
544 # Attributes for Logger mixin class, make defaults here
542 # Attributes for Logger mixin class, make defaults here
545 self._dolog = False
543 self._dolog = False
546 self.LOG = ''
544 self.LOG = ''
547 self.LOGDEF = '.InteractiveShell.log'
545 self.LOGDEF = '.InteractiveShell.log'
548 self.LOGMODE = 'over'
546 self.LOGMODE = 'over'
549 self.LOGHEAD = Itpl(
547 self.LOGHEAD = Itpl(
550 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
548 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
551 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
549 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
552 #log# opts = $self.rc.opts
550 #log# opts = $self.rc.opts
553 #log# args = $self.rc.args
551 #log# args = $self.rc.args
554 #log# It is safe to make manual edits below here.
552 #log# It is safe to make manual edits below here.
555 #log#-----------------------------------------------------------------------
553 #log#-----------------------------------------------------------------------
556 """)
554 """)
557 # Various switches which can be set
555 # Various switches which can be set
558 self.CACHELENGTH = 5000 # this is cheap, it's just text
556 self.CACHELENGTH = 5000 # this is cheap, it's just text
559 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
557 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
560 self.banner2 = banner2
558 self.banner2 = banner2
561
559
562 # TraceBack handlers:
560 # TraceBack handlers:
563 # Need two, one for syntax errors and one for other exceptions.
561 # Need two, one for syntax errors and one for other exceptions.
564 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
562 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
565 # The interactive one is initialized with an offset, meaning we always
563 # The interactive one is initialized with an offset, meaning we always
566 # want to remove the topmost item in the traceback, which is our own
564 # want to remove the topmost item in the traceback, which is our own
567 # internal code. Valid modes: ['Plain','Context','Verbose']
565 # internal code. Valid modes: ['Plain','Context','Verbose']
568 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
566 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
569 color_scheme='NoColor',
567 color_scheme='NoColor',
570 tb_offset = 1)
568 tb_offset = 1)
571 # and add any custom exception handlers the user may have specified
569 # and add any custom exception handlers the user may have specified
572 self.set_custom_exc(*custom_exceptions)
570 self.set_custom_exc(*custom_exceptions)
573
571
574 # Object inspector
572 # Object inspector
575 self.inspector = OInspect.Inspector(OInspect.InspectColors,
573 self.inspector = OInspect.Inspector(OInspect.InspectColors,
576 PyColorize.ANSICodeColors,
574 PyColorize.ANSICodeColors,
577 'NoColor')
575 'NoColor')
578 # indentation management
576 # indentation management
579 self.autoindent = False
577 self.autoindent = False
580 self.indent_current_nsp = 0
578 self.indent_current_nsp = 0
581 self.indent_current = '' # actual indent string
579 self.indent_current = '' # actual indent string
582
580
583 # Make some aliases automatically
581 # Make some aliases automatically
584 # Prepare list of shell aliases to auto-define
582 # Prepare list of shell aliases to auto-define
585 if os.name == 'posix':
583 if os.name == 'posix':
586 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
584 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
587 'mv mv -i','rm rm -i','cp cp -i',
585 'mv mv -i','rm rm -i','cp cp -i',
588 'cat cat','less less','clear clear',
586 'cat cat','less less','clear clear',
589 # a better ls
587 # a better ls
590 'ls ls -F',
588 'ls ls -F',
591 # long ls
589 # long ls
592 'll ls -lF',
590 'll ls -lF',
593 # color ls
591 # color ls
594 'lc ls -F -o --color',
592 'lc ls -F -o --color',
595 # ls normal files only
593 # ls normal files only
596 'lf ls -F -o --color %l | grep ^-',
594 'lf ls -F -o --color %l | grep ^-',
597 # ls symbolic links
595 # ls symbolic links
598 'lk ls -F -o --color %l | grep ^l',
596 'lk ls -F -o --color %l | grep ^l',
599 # directories or links to directories,
597 # directories or links to directories,
600 'ldir ls -F -o --color %l | grep /$',
598 'ldir ls -F -o --color %l | grep /$',
601 # things which are executable
599 # things which are executable
602 'lx ls -F -o --color %l | grep ^-..x',
600 'lx ls -F -o --color %l | grep ^-..x',
603 )
601 )
604 elif os.name in ['nt','dos']:
602 elif os.name in ['nt','dos']:
605 auto_alias = ('dir dir /on', 'ls dir /on',
603 auto_alias = ('dir dir /on', 'ls dir /on',
606 'ddir dir /ad /on', 'ldir dir /ad /on',
604 'ddir dir /ad /on', 'ldir dir /ad /on',
607 'mkdir mkdir','rmdir rmdir','echo echo',
605 'mkdir mkdir','rmdir rmdir','echo echo',
608 'ren ren','cls cls','copy copy')
606 'ren ren','cls cls','copy copy')
609 else:
607 else:
610 auto_alias = ()
608 auto_alias = ()
611 self.auto_alias = map(lambda s:s.split(None,1),auto_alias)
609 self.auto_alias = map(lambda s:s.split(None,1),auto_alias)
612 # Call the actual (public) initializer
610 # Call the actual (public) initializer
613 self.init_auto_alias()
611 self.init_auto_alias()
614 # end __init__
612 # end __init__
615
613
616 def set_hook(self,name,hook):
614 def set_hook(self,name,hook):
617 """set_hook(name,hook) -> sets an internal IPython hook.
615 """set_hook(name,hook) -> sets an internal IPython hook.
618
616
619 IPython exposes some of its internal API as user-modifiable hooks. By
617 IPython exposes some of its internal API as user-modifiable hooks. By
620 resetting one of these hooks, you can modify IPython's behavior to
618 resetting one of these hooks, you can modify IPython's behavior to
621 call at runtime your own routines."""
619 call at runtime your own routines."""
622
620
623 # At some point in the future, this should validate the hook before it
621 # At some point in the future, this should validate the hook before it
624 # accepts it. Probably at least check that the hook takes the number
622 # accepts it. Probably at least check that the hook takes the number
625 # of args it's supposed to.
623 # of args it's supposed to.
626 setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
624 setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
627
625
628 def set_custom_exc(self,exc_tuple,handler):
626 def set_custom_exc(self,exc_tuple,handler):
629 """set_custom_exc(exc_tuple,handler)
627 """set_custom_exc(exc_tuple,handler)
630
628
631 Set a custom exception handler, which will be called if any of the
629 Set a custom exception handler, which will be called if any of the
632 exceptions in exc_tuple occur in the mainloop (specifically, in the
630 exceptions in exc_tuple occur in the mainloop (specifically, in the
633 runcode() method.
631 runcode() method.
634
632
635 Inputs:
633 Inputs:
636
634
637 - exc_tuple: a *tuple* of valid exceptions to call the defined
635 - exc_tuple: a *tuple* of valid exceptions to call the defined
638 handler for. It is very important that you use a tuple, and NOT A
636 handler for. It is very important that you use a tuple, and NOT A
639 LIST here, because of the way Python's except statement works. If
637 LIST here, because of the way Python's except statement works. If
640 you only want to trap a single exception, use a singleton tuple:
638 you only want to trap a single exception, use a singleton tuple:
641
639
642 exc_tuple == (MyCustomException,)
640 exc_tuple == (MyCustomException,)
643
641
644 - handler: this must be defined as a function with the following
642 - handler: this must be defined as a function with the following
645 basic interface: def my_handler(self,etype,value,tb).
643 basic interface: def my_handler(self,etype,value,tb).
646
644
647 This will be made into an instance method (via new.instancemethod)
645 This will be made into an instance method (via new.instancemethod)
648 of IPython itself, and it will be called if any of the exceptions
646 of IPython itself, and it will be called if any of the exceptions
649 listed in the exc_tuple are caught. If the handler is None, an
647 listed in the exc_tuple are caught. If the handler is None, an
650 internal basic one is used, which just prints basic info.
648 internal basic one is used, which just prints basic info.
651
649
652 WARNING: by putting in your own exception handler into IPython's main
650 WARNING: by putting in your own exception handler into IPython's main
653 execution loop, you run a very good chance of nasty crashes. This
651 execution loop, you run a very good chance of nasty crashes. This
654 facility should only be used if you really know what you are doing."""
652 facility should only be used if you really know what you are doing."""
655
653
656 assert type(exc_tuple)==type(()) , \
654 assert type(exc_tuple)==type(()) , \
657 "The custom exceptions must be given AS A TUPLE."
655 "The custom exceptions must be given AS A TUPLE."
658
656
659 def dummy_handler(self,etype,value,tb):
657 def dummy_handler(self,etype,value,tb):
660 print '*** Simple custom exception handler ***'
658 print '*** Simple custom exception handler ***'
661 print 'Exception type :',etype
659 print 'Exception type :',etype
662 print 'Exception value:',value
660 print 'Exception value:',value
663 print 'Traceback :',tb
661 print 'Traceback :',tb
664 print 'Source code :','\n'.join(self.buffer)
662 print 'Source code :','\n'.join(self.buffer)
665
663
666 if handler is None: handler = dummy_handler
664 if handler is None: handler = dummy_handler
667
665
668 self.CustomTB = new.instancemethod(handler,self,self.__class__)
666 self.CustomTB = new.instancemethod(handler,self,self.__class__)
669 self.custom_exceptions = exc_tuple
667 self.custom_exceptions = exc_tuple
670
668
671 def set_custom_completer(self,completer,pos=0):
669 def set_custom_completer(self,completer,pos=0):
672 """set_custom_completer(completer,pos=0)
670 """set_custom_completer(completer,pos=0)
673
671
674 Adds a new custom completer function.
672 Adds a new custom completer function.
675
673
676 The position argument (defaults to 0) is the index in the completers
674 The position argument (defaults to 0) is the index in the completers
677 list where you want the completer to be inserted."""
675 list where you want the completer to be inserted."""
678
676
679 newcomp = new.instancemethod(completer,self.Completer,
677 newcomp = new.instancemethod(completer,self.Completer,
680 self.Completer.__class__)
678 self.Completer.__class__)
681 self.Completer.matchers.insert(pos,newcomp)
679 self.Completer.matchers.insert(pos,newcomp)
682
680
683 def complete(self,text):
681 def complete(self,text):
684 """Return a sorted list of all possible completions on text.
682 """Return a sorted list of all possible completions on text.
685
683
686 Inputs:
684 Inputs:
687
685
688 - text: a string of text to be completed on.
686 - text: a string of text to be completed on.
689
687
690 This is a wrapper around the completion mechanism, similar to what
688 This is a wrapper around the completion mechanism, similar to what
691 readline does at the command line when the TAB key is hit. By
689 readline does at the command line when the TAB key is hit. By
692 exposing it as a method, it can be used by other non-readline
690 exposing it as a method, it can be used by other non-readline
693 environments (such as GUIs) for text completion.
691 environments (such as GUIs) for text completion.
694
692
695 Simple usage example:
693 Simple usage example:
696
694
697 In [1]: x = 'hello'
695 In [1]: x = 'hello'
698
696
699 In [2]: __IP.complete('x.l')
697 In [2]: __IP.complete('x.l')
700 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
698 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
701
699
702 complete = self.Completer.complete
700 complete = self.Completer.complete
703 state = 0
701 state = 0
704 # use a dict so we get unique keys, since ipyhton's multiple
702 # use a dict so we get unique keys, since ipyhton's multiple
705 # completers can return duplicates.
703 # completers can return duplicates.
706 comps = {}
704 comps = {}
707 while True:
705 while True:
708 newcomp = complete(text,state)
706 newcomp = complete(text,state)
709 if newcomp is None:
707 if newcomp is None:
710 break
708 break
711 comps[newcomp] = 1
709 comps[newcomp] = 1
712 state += 1
710 state += 1
713 outcomps = comps.keys()
711 outcomps = comps.keys()
714 outcomps.sort()
712 outcomps.sort()
715 return outcomps
713 return outcomps
716
714
717 def set_completer_frame(self, frame):
715 def set_completer_frame(self, frame):
718 if frame:
716 if frame:
719 self.Completer.namespace = frame.f_locals
717 self.Completer.namespace = frame.f_locals
720 self.Completer.global_namespace = frame.f_globals
718 self.Completer.global_namespace = frame.f_globals
721 else:
719 else:
722 self.Completer.namespace = self.user_ns
720 self.Completer.namespace = self.user_ns
723 self.Completer.global_namespace = self.user_global_ns
721 self.Completer.global_namespace = self.user_global_ns
724
722
725 def post_config_initialization(self):
723 def post_config_initialization(self):
726 """Post configuration init method
724 """Post configuration init method
727
725
728 This is called after the configuration files have been processed to
726 This is called after the configuration files have been processed to
729 'finalize' the initialization."""
727 'finalize' the initialization."""
730
728
731 rc = self.rc
729 rc = self.rc
732
730
733 # Load readline proper
731 # Load readline proper
734 if rc.readline:
732 if rc.readline:
735 self.init_readline()
733 self.init_readline()
736
734
737 # Set user colors (don't do it in the constructor above so that it
735 # Set user colors (don't do it in the constructor above so that it
738 # doesn't crash if colors option is invalid)
736 # doesn't crash if colors option is invalid)
739 self.magic_colors(rc.colors)
737 self.magic_colors(rc.colors)
740
738
741 # Load user aliases
739 # Load user aliases
742 for alias in rc.alias:
740 for alias in rc.alias:
743 self.magic_alias(alias)
741 self.magic_alias(alias)
744
742
745 # dynamic data that survives through sessions
743 # dynamic data that survives through sessions
746 # XXX make the filename a config option?
744 # XXX make the filename a config option?
747 persist_base = 'persist'
745 persist_base = 'persist'
748 if rc.profile:
746 if rc.profile:
749 persist_base += '_%s' % rc.profile
747 persist_base += '_%s' % rc.profile
750 self.persist_fname = os.path.join(rc.ipythondir,persist_base)
748 self.persist_fname = os.path.join(rc.ipythondir,persist_base)
751
749
752 try:
750 try:
753 self.persist = pickle.load(file(self.persist_fname))
751 self.persist = pickle.load(file(self.persist_fname))
754 except:
752 except:
755 self.persist = {}
753 self.persist = {}
756
754
757 def init_auto_alias(self):
755 def init_auto_alias(self):
758 """Define some aliases automatically.
756 """Define some aliases automatically.
759
757
760 These are ALL parameter-less aliases"""
758 These are ALL parameter-less aliases"""
761 for alias,cmd in self.auto_alias:
759 for alias,cmd in self.auto_alias:
762 self.alias_table[alias] = (0,cmd)
760 self.alias_table[alias] = (0,cmd)
763
761
764 def alias_table_validate(self,verbose=0):
762 def alias_table_validate(self,verbose=0):
765 """Update information about the alias table.
763 """Update information about the alias table.
766
764
767 In particular, make sure no Python keywords/builtins are in it."""
765 In particular, make sure no Python keywords/builtins are in it."""
768
766
769 no_alias = self.no_alias
767 no_alias = self.no_alias
770 for k in self.alias_table.keys():
768 for k in self.alias_table.keys():
771 if k in no_alias:
769 if k in no_alias:
772 del self.alias_table[k]
770 del self.alias_table[k]
773 if verbose:
771 if verbose:
774 print ("Deleting alias <%s>, it's a Python "
772 print ("Deleting alias <%s>, it's a Python "
775 "keyword or builtin." % k)
773 "keyword or builtin." % k)
776
774
777 def set_autoindent(self,value=None):
775 def set_autoindent(self,value=None):
778 """Set the autoindent flag, checking for readline support.
776 """Set the autoindent flag, checking for readline support.
779
777
780 If called with no arguments, it acts as a toggle."""
778 If called with no arguments, it acts as a toggle."""
781
779
782 if not self.has_readline:
780 if not self.has_readline:
783 if os.name == 'posix':
781 if os.name == 'posix':
784 warn("The auto-indent feature requires the readline library")
782 warn("The auto-indent feature requires the readline library")
785 self.autoindent = 0
783 self.autoindent = 0
786 return
784 return
787 if value is None:
785 if value is None:
788 self.autoindent = not self.autoindent
786 self.autoindent = not self.autoindent
789 else:
787 else:
790 self.autoindent = value
788 self.autoindent = value
791
789
792 def rc_set_toggle(self,rc_field,value=None):
790 def rc_set_toggle(self,rc_field,value=None):
793 """Set or toggle a field in IPython's rc config. structure.
791 """Set or toggle a field in IPython's rc config. structure.
794
792
795 If called with no arguments, it acts as a toggle.
793 If called with no arguments, it acts as a toggle.
796
794
797 If called with a non-existent field, the resulting AttributeError
795 If called with a non-existent field, the resulting AttributeError
798 exception will propagate out."""
796 exception will propagate out."""
799
797
800 rc_val = getattr(self.rc,rc_field)
798 rc_val = getattr(self.rc,rc_field)
801 if value is None:
799 if value is None:
802 value = not rc_val
800 value = not rc_val
803 setattr(self.rc,rc_field,value)
801 setattr(self.rc,rc_field,value)
804
802
805 def user_setup(self,ipythondir,rc_suffix,mode='install'):
803 def user_setup(self,ipythondir,rc_suffix,mode='install'):
806 """Install the user configuration directory.
804 """Install the user configuration directory.
807
805
808 Can be called when running for the first time or to upgrade the user's
806 Can be called when running for the first time or to upgrade the user's
809 .ipython/ directory with the mode parameter. Valid modes are 'install'
807 .ipython/ directory with the mode parameter. Valid modes are 'install'
810 and 'upgrade'."""
808 and 'upgrade'."""
811
809
812 def wait():
810 def wait():
813 try:
811 try:
814 raw_input("Please press <RETURN> to start IPython.")
812 raw_input("Please press <RETURN> to start IPython.")
815 except EOFError:
813 except EOFError:
816 print >> Term.cout
814 print >> Term.cout
817 print '*'*70
815 print '*'*70
818
816
819 cwd = os.getcwd() # remember where we started
817 cwd = os.getcwd() # remember where we started
820 glb = glob.glob
818 glb = glob.glob
821 print '*'*70
819 print '*'*70
822 if mode == 'install':
820 if mode == 'install':
823 print \
821 print \
824 """Welcome to IPython. I will try to create a personal configuration directory
822 """Welcome to IPython. I will try to create a personal configuration directory
825 where you can customize many aspects of IPython's functionality in:\n"""
823 where you can customize many aspects of IPython's functionality in:\n"""
826 else:
824 else:
827 print 'I am going to upgrade your configuration in:'
825 print 'I am going to upgrade your configuration in:'
828
826
829 print ipythondir
827 print ipythondir
830
828
831 rcdirend = os.path.join('IPython','UserConfig')
829 rcdirend = os.path.join('IPython','UserConfig')
832 cfg = lambda d: os.path.join(d,rcdirend)
830 cfg = lambda d: os.path.join(d,rcdirend)
833 try:
831 try:
834 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
832 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
835 except IOError:
833 except IOError:
836 warning = """
834 warning = """
837 Installation error. IPython's directory was not found.
835 Installation error. IPython's directory was not found.
838
836
839 Check the following:
837 Check the following:
840
838
841 The ipython/IPython directory should be in a directory belonging to your
839 The ipython/IPython directory should be in a directory belonging to your
842 PYTHONPATH environment variable (that is, it should be in a directory
840 PYTHONPATH environment variable (that is, it should be in a directory
843 belonging to sys.path). You can copy it explicitly there or just link to it.
841 belonging to sys.path). You can copy it explicitly there or just link to it.
844
842
845 IPython will proceed with builtin defaults.
843 IPython will proceed with builtin defaults.
846 """
844 """
847 warn(warning)
845 warn(warning)
848 wait()
846 wait()
849 return
847 return
850
848
851 if mode == 'install':
849 if mode == 'install':
852 try:
850 try:
853 shutil.copytree(rcdir,ipythondir)
851 shutil.copytree(rcdir,ipythondir)
854 os.chdir(ipythondir)
852 os.chdir(ipythondir)
855 rc_files = glb("ipythonrc*")
853 rc_files = glb("ipythonrc*")
856 for rc_file in rc_files:
854 for rc_file in rc_files:
857 os.rename(rc_file,rc_file+rc_suffix)
855 os.rename(rc_file,rc_file+rc_suffix)
858 except:
856 except:
859 warning = """
857 warning = """
860
858
861 There was a problem with the installation:
859 There was a problem with the installation:
862 %s
860 %s
863 Try to correct it or contact the developers if you think it's a bug.
861 Try to correct it or contact the developers if you think it's a bug.
864 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
862 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
865 warn(warning)
863 warn(warning)
866 wait()
864 wait()
867 return
865 return
868
866
869 elif mode == 'upgrade':
867 elif mode == 'upgrade':
870 try:
868 try:
871 os.chdir(ipythondir)
869 os.chdir(ipythondir)
872 except:
870 except:
873 print """
871 print """
874 Can not upgrade: changing to directory %s failed. Details:
872 Can not upgrade: changing to directory %s failed. Details:
875 %s
873 %s
876 """ % (ipythondir,sys.exc_info()[1])
874 """ % (ipythondir,sys.exc_info()[1])
877 wait()
875 wait()
878 return
876 return
879 else:
877 else:
880 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
878 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
881 for new_full_path in sources:
879 for new_full_path in sources:
882 new_filename = os.path.basename(new_full_path)
880 new_filename = os.path.basename(new_full_path)
883 if new_filename.startswith('ipythonrc'):
881 if new_filename.startswith('ipythonrc'):
884 new_filename = new_filename + rc_suffix
882 new_filename = new_filename + rc_suffix
885 # The config directory should only contain files, skip any
883 # The config directory should only contain files, skip any
886 # directories which may be there (like CVS)
884 # directories which may be there (like CVS)
887 if os.path.isdir(new_full_path):
885 if os.path.isdir(new_full_path):
888 continue
886 continue
889 if os.path.exists(new_filename):
887 if os.path.exists(new_filename):
890 old_file = new_filename+'.old'
888 old_file = new_filename+'.old'
891 if os.path.exists(old_file):
889 if os.path.exists(old_file):
892 os.remove(old_file)
890 os.remove(old_file)
893 os.rename(new_filename,old_file)
891 os.rename(new_filename,old_file)
894 shutil.copy(new_full_path,new_filename)
892 shutil.copy(new_full_path,new_filename)
895 else:
893 else:
896 raise ValueError,'unrecognized mode for install:',`mode`
894 raise ValueError,'unrecognized mode for install:',`mode`
897
895
898 # Fix line-endings to those native to each platform in the config
896 # Fix line-endings to those native to each platform in the config
899 # directory.
897 # directory.
900 try:
898 try:
901 os.chdir(ipythondir)
899 os.chdir(ipythondir)
902 except:
900 except:
903 print """
901 print """
904 Problem: changing to directory %s failed.
902 Problem: changing to directory %s failed.
905 Details:
903 Details:
906 %s
904 %s
907
905
908 Some configuration files may have incorrect line endings. This should not
906 Some configuration files may have incorrect line endings. This should not
909 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
907 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
910 wait()
908 wait()
911 else:
909 else:
912 for fname in glb('ipythonrc*'):
910 for fname in glb('ipythonrc*'):
913 try:
911 try:
914 native_line_ends(fname,backup=0)
912 native_line_ends(fname,backup=0)
915 except IOError:
913 except IOError:
916 pass
914 pass
917
915
918 if mode == 'install':
916 if mode == 'install':
919 print """
917 print """
920 Successful installation!
918 Successful installation!
921
919
922 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
920 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
923 IPython manual (there are both HTML and PDF versions supplied with the
921 IPython manual (there are both HTML and PDF versions supplied with the
924 distribution) to make sure that your system environment is properly configured
922 distribution) to make sure that your system environment is properly configured
925 to take advantage of IPython's features."""
923 to take advantage of IPython's features."""
926 else:
924 else:
927 print """
925 print """
928 Successful upgrade!
926 Successful upgrade!
929
927
930 All files in your directory:
928 All files in your directory:
931 %(ipythondir)s
929 %(ipythondir)s
932 which would have been overwritten by the upgrade were backed up with a .old
930 which would have been overwritten by the upgrade were backed up with a .old
933 extension. If you had made particular customizations in those files you may
931 extension. If you had made particular customizations in those files you may
934 want to merge them back into the new files.""" % locals()
932 want to merge them back into the new files.""" % locals()
935 wait()
933 wait()
936 os.chdir(cwd)
934 os.chdir(cwd)
937 # end user_setup()
935 # end user_setup()
938
936
939 def atexit_operations(self):
937 def atexit_operations(self):
940 """This will be executed at the time of exit.
938 """This will be executed at the time of exit.
941
939
942 Saving of persistent data should be performed here. """
940 Saving of persistent data should be performed here. """
943
941
944 # input history
942 # input history
945 self.savehist()
943 self.savehist()
946
944
947 # Cleanup all tempfiles left around
945 # Cleanup all tempfiles left around
948 for tfile in self.tempfiles:
946 for tfile in self.tempfiles:
949 try:
947 try:
950 os.unlink(tfile)
948 os.unlink(tfile)
951 except OSError:
949 except OSError:
952 pass
950 pass
953
951
954 # save the "persistent data" catch-all dictionary
952 # save the "persistent data" catch-all dictionary
955 try:
953 try:
956 pickle.dump(self.persist, open(self.persist_fname,"w"))
954 pickle.dump(self.persist, open(self.persist_fname,"w"))
957 except:
955 except:
958 print "*** ERROR *** persistent data saving failed."
956 print "*** ERROR *** persistent data saving failed."
959
957
960 def savehist(self):
958 def savehist(self):
961 """Save input history to a file (via readline library)."""
959 """Save input history to a file (via readline library)."""
962 try:
960 try:
963 self.readline.write_history_file(self.histfile)
961 self.readline.write_history_file(self.histfile)
964 except:
962 except:
965 print 'Unable to save IPython command history to file: ' + \
963 print 'Unable to save IPython command history to file: ' + \
966 `self.histfile`
964 `self.histfile`
967
965
968 def pre_readline(self):
966 def pre_readline(self):
969 """readline hook to be used at the start of each line.
967 """readline hook to be used at the start of each line.
970
968
971 Currently it handles auto-indent only."""
969 Currently it handles auto-indent only."""
972
970
973 self.readline.insert_text(self.indent_current)
971 self.readline.insert_text(self.indent_current)
974
972
975 def init_readline(self):
973 def init_readline(self):
976 """Command history completion/saving/reloading."""
974 """Command history completion/saving/reloading."""
977 try:
975 try:
978 import readline
976 import readline
979 except ImportError:
977 except ImportError:
980 self.has_readline = 0
978 self.has_readline = 0
981 self.readline = None
979 self.readline = None
982 # no point in bugging windows users with this every time:
980 # no point in bugging windows users with this every time:
983 if os.name == 'posix':
981 if os.name == 'posix':
984 warn('Readline services not available on this platform.')
982 warn('Readline services not available on this platform.')
985 else:
983 else:
986 import atexit
984 import atexit
987 from IPython.completer import IPCompleter
985 from IPython.completer import IPCompleter
988 self.Completer = IPCompleter(self,
986 self.Completer = IPCompleter(self,
989 self.user_ns,
987 self.user_ns,
990 self.user_global_ns,
988 self.user_global_ns,
991 self.rc.readline_omit__names,
989 self.rc.readline_omit__names,
992 self.alias_table)
990 self.alias_table)
993
991
994 # Platform-specific configuration
992 # Platform-specific configuration
995 if os.name == 'nt':
993 if os.name == 'nt':
996 self.readline_startup_hook = readline.set_pre_input_hook
994 self.readline_startup_hook = readline.set_pre_input_hook
997 else:
995 else:
998 self.readline_startup_hook = readline.set_startup_hook
996 self.readline_startup_hook = readline.set_startup_hook
999
997
1000 # Load user's initrc file (readline config)
998 # Load user's initrc file (readline config)
1001 inputrc_name = os.environ.get('INPUTRC')
999 inputrc_name = os.environ.get('INPUTRC')
1002 if inputrc_name is None:
1000 if inputrc_name is None:
1003 home_dir = get_home_dir()
1001 home_dir = get_home_dir()
1004 if home_dir is not None:
1002 if home_dir is not None:
1005 inputrc_name = os.path.join(home_dir,'.inputrc')
1003 inputrc_name = os.path.join(home_dir,'.inputrc')
1006 if os.path.isfile(inputrc_name):
1004 if os.path.isfile(inputrc_name):
1007 try:
1005 try:
1008 readline.read_init_file(inputrc_name)
1006 readline.read_init_file(inputrc_name)
1009 except:
1007 except:
1010 warn('Problems reading readline initialization file <%s>'
1008 warn('Problems reading readline initialization file <%s>'
1011 % inputrc_name)
1009 % inputrc_name)
1012
1010
1013 self.has_readline = 1
1011 self.has_readline = 1
1014 self.readline = readline
1012 self.readline = readline
1015 # save this in sys so embedded copies can restore it properly
1013 # save this in sys so embedded copies can restore it properly
1016 sys.ipcompleter = self.Completer.complete
1014 sys.ipcompleter = self.Completer.complete
1017 readline.set_completer(self.Completer.complete)
1015 readline.set_completer(self.Completer.complete)
1018
1016
1019 # Configure readline according to user's prefs
1017 # Configure readline according to user's prefs
1020 for rlcommand in self.rc.readline_parse_and_bind:
1018 for rlcommand in self.rc.readline_parse_and_bind:
1021 readline.parse_and_bind(rlcommand)
1019 readline.parse_and_bind(rlcommand)
1022
1020
1023 # remove some chars from the delimiters list
1021 # remove some chars from the delimiters list
1024 delims = readline.get_completer_delims()
1022 delims = readline.get_completer_delims()
1025 delims = delims.translate(string._idmap,
1023 delims = delims.translate(string._idmap,
1026 self.rc.readline_remove_delims)
1024 self.rc.readline_remove_delims)
1027 readline.set_completer_delims(delims)
1025 readline.set_completer_delims(delims)
1028 # otherwise we end up with a monster history after a while:
1026 # otherwise we end up with a monster history after a while:
1029 readline.set_history_length(1000)
1027 readline.set_history_length(1000)
1030 try:
1028 try:
1031 #print '*** Reading readline history' # dbg
1029 #print '*** Reading readline history' # dbg
1032 readline.read_history_file(self.histfile)
1030 readline.read_history_file(self.histfile)
1033 except IOError:
1031 except IOError:
1034 pass # It doesn't exist yet.
1032 pass # It doesn't exist yet.
1035
1033
1036 atexit.register(self.atexit_operations)
1034 atexit.register(self.atexit_operations)
1037 del atexit
1035 del atexit
1038
1036
1039 # Configure auto-indent for all platforms
1037 # Configure auto-indent for all platforms
1040 self.set_autoindent(self.rc.autoindent)
1038 self.set_autoindent(self.rc.autoindent)
1041
1039
1042 def _should_recompile(self,e):
1040 def _should_recompile(self,e):
1043 """Utility routine for edit_syntax_error"""
1041 """Utility routine for edit_syntax_error"""
1044
1042
1045 if e.filename in ('<ipython console>','<input>','<string>',
1043 if e.filename in ('<ipython console>','<input>','<string>',
1046 '<console>'):
1044 '<console>'):
1047 return False
1045 return False
1048 try:
1046 try:
1049 if not ask_yes_no('Return to editor to correct syntax error? '
1047 if not ask_yes_no('Return to editor to correct syntax error? '
1050 '[Y/n] ','y'):
1048 '[Y/n] ','y'):
1051 return False
1049 return False
1052 except EOFError:
1050 except EOFError:
1053 return False
1051 return False
1054 self.hooks.fix_error_editor(e.filename,e.lineno,e.offset,e.msg)
1052 self.hooks.fix_error_editor(e.filename,e.lineno,e.offset,e.msg)
1055 return True
1053 return True
1056
1054
1057 def edit_syntax_error(self):
1055 def edit_syntax_error(self):
1058 """The bottom half of the syntax error handler called in the main loop.
1056 """The bottom half of the syntax error handler called in the main loop.
1059
1057
1060 Loop until syntax error is fixed or user cancels.
1058 Loop until syntax error is fixed or user cancels.
1061 """
1059 """
1062
1060
1063 while self.SyntaxTB.last_syntax_error:
1061 while self.SyntaxTB.last_syntax_error:
1064 # copy and clear last_syntax_error
1062 # copy and clear last_syntax_error
1065 err = self.SyntaxTB.clear_err_state()
1063 err = self.SyntaxTB.clear_err_state()
1066 if not self._should_recompile(err):
1064 if not self._should_recompile(err):
1067 return
1065 return
1068 try:
1066 try:
1069 # may set last_syntax_error again if a SyntaxError is raised
1067 # may set last_syntax_error again if a SyntaxError is raised
1070 self.safe_execfile(err.filename,self.shell.user_ns)
1068 self.safe_execfile(err.filename,self.shell.user_ns)
1071 except:
1069 except:
1072 self.showtraceback()
1070 self.showtraceback()
1073 else:
1071 else:
1074 f = file(err.filename)
1072 f = file(err.filename)
1075 try:
1073 try:
1076 sys.displayhook(f.read())
1074 sys.displayhook(f.read())
1077 finally:
1075 finally:
1078 f.close()
1076 f.close()
1079
1077
1080 def showsyntaxerror(self, filename=None):
1078 def showsyntaxerror(self, filename=None):
1081 """Display the syntax error that just occurred.
1079 """Display the syntax error that just occurred.
1082
1080
1083 This doesn't display a stack trace because there isn't one.
1081 This doesn't display a stack trace because there isn't one.
1084
1082
1085 If a filename is given, it is stuffed in the exception instead
1083 If a filename is given, it is stuffed in the exception instead
1086 of what was there before (because Python's parser always uses
1084 of what was there before (because Python's parser always uses
1087 "<string>" when reading from a string).
1085 "<string>" when reading from a string).
1088 """
1086 """
1089 type, value, sys.last_traceback = sys.exc_info()
1087 type, value, sys.last_traceback = sys.exc_info()
1090 sys.last_type = type
1088 sys.last_type = type
1091 sys.last_value = value
1089 sys.last_value = value
1092 if filename and type is SyntaxError:
1090 if filename and type is SyntaxError:
1093 # Work hard to stuff the correct filename in the exception
1091 # Work hard to stuff the correct filename in the exception
1094 try:
1092 try:
1095 msg, (dummy_filename, lineno, offset, line) = value
1093 msg, (dummy_filename, lineno, offset, line) = value
1096 except:
1094 except:
1097 # Not the format we expect; leave it alone
1095 # Not the format we expect; leave it alone
1098 pass
1096 pass
1099 else:
1097 else:
1100 # Stuff in the right filename
1098 # Stuff in the right filename
1101 try:
1099 try:
1102 # Assume SyntaxError is a class exception
1100 # Assume SyntaxError is a class exception
1103 value = SyntaxError(msg, (filename, lineno, offset, line))
1101 value = SyntaxError(msg, (filename, lineno, offset, line))
1104 except:
1102 except:
1105 # If that failed, assume SyntaxError is a string
1103 # If that failed, assume SyntaxError is a string
1106 value = msg, (filename, lineno, offset, line)
1104 value = msg, (filename, lineno, offset, line)
1107 self.SyntaxTB(type,value,[])
1105 self.SyntaxTB(type,value,[])
1108
1106
1109 def debugger(self):
1107 def debugger(self):
1110 """Call the pdb debugger."""
1108 """Call the pdb debugger."""
1111
1109
1112 if not self.rc.pdb:
1110 if not self.rc.pdb:
1113 return
1111 return
1114 pdb.pm()
1112 pdb.pm()
1115
1113
1116 def showtraceback(self,exc_tuple = None,filename=None):
1114 def showtraceback(self,exc_tuple = None,filename=None):
1117 """Display the exception that just occurred."""
1115 """Display the exception that just occurred."""
1118
1116
1119 # Though this won't be called by syntax errors in the input line,
1117 # Though this won't be called by syntax errors in the input line,
1120 # there may be SyntaxError cases whith imported code.
1118 # there may be SyntaxError cases whith imported code.
1121 if exc_tuple is None:
1119 if exc_tuple is None:
1122 type, value, tb = sys.exc_info()
1120 type, value, tb = sys.exc_info()
1123 else:
1121 else:
1124 type, value, tb = exc_tuple
1122 type, value, tb = exc_tuple
1125 if type is SyntaxError:
1123 if type is SyntaxError:
1126 self.showsyntaxerror(filename)
1124 self.showsyntaxerror(filename)
1127 else:
1125 else:
1128 sys.last_type = type
1126 sys.last_type = type
1129 sys.last_value = value
1127 sys.last_value = value
1130 sys.last_traceback = tb
1128 sys.last_traceback = tb
1131 self.InteractiveTB()
1129 self.InteractiveTB()
1132 if self.InteractiveTB.call_pdb and self.has_readline:
1130 if self.InteractiveTB.call_pdb and self.has_readline:
1133 # pdb mucks up readline, fix it back
1131 # pdb mucks up readline, fix it back
1134 self.readline.set_completer(self.Completer.complete)
1132 self.readline.set_completer(self.Completer.complete)
1135
1133
1136 def update_cache(self, line):
1134 def update_cache(self, line):
1137 """puts line into cache"""
1135 """puts line into cache"""
1138 self.inputcache.insert(0, line) # This copies the cache every time ... :-(
1136 self.inputcache.insert(0, line) # This copies the cache every time ... :-(
1139 if len(self.inputcache) >= self.CACHELENGTH:
1137 if len(self.inputcache) >= self.CACHELENGTH:
1140 self.inputcache.pop() # This doesn't :-)
1138 self.inputcache.pop() # This doesn't :-)
1141
1139
1142 def mainloop(self,banner=None):
1140 def mainloop(self,banner=None):
1143 """Creates the local namespace and starts the mainloop.
1141 """Creates the local namespace and starts the mainloop.
1144
1142
1145 If an optional banner argument is given, it will override the
1143 If an optional banner argument is given, it will override the
1146 internally created default banner."""
1144 internally created default banner."""
1147
1145
1148 if self.rc.c: # Emulate Python's -c option
1146 if self.rc.c: # Emulate Python's -c option
1149 self.exec_init_cmd()
1147 self.exec_init_cmd()
1150 if banner is None:
1148 if banner is None:
1151 if self.rc.banner:
1149 if self.rc.banner:
1152 banner = self.BANNER+self.banner2
1150 banner = self.BANNER+self.banner2
1153 else:
1151 else:
1154 banner = ''
1152 banner = ''
1155 self.interact(banner)
1153 self.interact(banner)
1156
1154
1157 def exec_init_cmd(self):
1155 def exec_init_cmd(self):
1158 """Execute a command given at the command line.
1156 """Execute a command given at the command line.
1159
1157
1160 This emulates Python's -c option."""
1158 This emulates Python's -c option."""
1161
1159
1162 sys.argv = ['-c']
1160 sys.argv = ['-c']
1163 self.push(self.rc.c)
1161 self.push(self.rc.c)
1164
1162
1165 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1163 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1166 """Embeds IPython into a running python program.
1164 """Embeds IPython into a running python program.
1167
1165
1168 Input:
1166 Input:
1169
1167
1170 - header: An optional header message can be specified.
1168 - header: An optional header message can be specified.
1171
1169
1172 - local_ns, global_ns: working namespaces. If given as None, the
1170 - local_ns, global_ns: working namespaces. If given as None, the
1173 IPython-initialized one is updated with __main__.__dict__, so that
1171 IPython-initialized one is updated with __main__.__dict__, so that
1174 program variables become visible but user-specific configuration
1172 program variables become visible but user-specific configuration
1175 remains possible.
1173 remains possible.
1176
1174
1177 - stack_depth: specifies how many levels in the stack to go to
1175 - stack_depth: specifies how many levels in the stack to go to
1178 looking for namespaces (when local_ns and global_ns are None). This
1176 looking for namespaces (when local_ns and global_ns are None). This
1179 allows an intermediate caller to make sure that this function gets
1177 allows an intermediate caller to make sure that this function gets
1180 the namespace from the intended level in the stack. By default (0)
1178 the namespace from the intended level in the stack. By default (0)
1181 it will get its locals and globals from the immediate caller.
1179 it will get its locals and globals from the immediate caller.
1182
1180
1183 Warning: it's possible to use this in a program which is being run by
1181 Warning: it's possible to use this in a program which is being run by
1184 IPython itself (via %run), but some funny things will happen (a few
1182 IPython itself (via %run), but some funny things will happen (a few
1185 globals get overwritten). In the future this will be cleaned up, as
1183 globals get overwritten). In the future this will be cleaned up, as
1186 there is no fundamental reason why it can't work perfectly."""
1184 there is no fundamental reason why it can't work perfectly."""
1187
1185
1188 # Get locals and globals from caller
1186 # Get locals and globals from caller
1189 if local_ns is None or global_ns is None:
1187 if local_ns is None or global_ns is None:
1190 call_frame = sys._getframe(stack_depth).f_back
1188 call_frame = sys._getframe(stack_depth).f_back
1191
1189
1192 if local_ns is None:
1190 if local_ns is None:
1193 local_ns = call_frame.f_locals
1191 local_ns = call_frame.f_locals
1194 if global_ns is None:
1192 if global_ns is None:
1195 global_ns = call_frame.f_globals
1193 global_ns = call_frame.f_globals
1196
1194
1197 # Update namespaces and fire up interpreter
1195 # Update namespaces and fire up interpreter
1198 self.user_ns = local_ns
1196 self.user_ns = local_ns
1199 self.user_global_ns = global_ns
1197 self.user_global_ns = global_ns
1200
1198
1201 # Patch for global embedding to make sure that things don't overwrite
1199 # Patch for global embedding to make sure that things don't overwrite
1202 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1200 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1203 # FIXME. Test this a bit more carefully (the if.. is new)
1201 # FIXME. Test this a bit more carefully (the if.. is new)
1204 if local_ns is None and global_ns is None:
1202 if local_ns is None and global_ns is None:
1205 self.user_global_ns.update(__main__.__dict__)
1203 self.user_global_ns.update(__main__.__dict__)
1206
1204
1207 # make sure the tab-completer has the correct frame information, so it
1205 # make sure the tab-completer has the correct frame information, so it
1208 # actually completes using the frame's locals/globals
1206 # actually completes using the frame's locals/globals
1209 self.set_completer_frame(call_frame)
1207 self.set_completer_frame(call_frame)
1210
1208
1211 self.interact(header)
1209 self.interact(header)
1212
1210
1213 def interact(self, banner=None):
1211 def interact(self, banner=None):
1214 """Closely emulate the interactive Python console.
1212 """Closely emulate the interactive Python console.
1215
1213
1216 The optional banner argument specify the banner to print
1214 The optional banner argument specify the banner to print
1217 before the first interaction; by default it prints a banner
1215 before the first interaction; by default it prints a banner
1218 similar to the one printed by the real Python interpreter,
1216 similar to the one printed by the real Python interpreter,
1219 followed by the current class name in parentheses (so as not
1217 followed by the current class name in parentheses (so as not
1220 to confuse this with the real interpreter -- since it's so
1218 to confuse this with the real interpreter -- since it's so
1221 close!).
1219 close!).
1222
1220
1223 """
1221 """
1224 cprt = 'Type "copyright", "credits" or "license" for more information.'
1222 cprt = 'Type "copyright", "credits" or "license" for more information.'
1225 if banner is None:
1223 if banner is None:
1226 self.write("Python %s on %s\n%s\n(%s)\n" %
1224 self.write("Python %s on %s\n%s\n(%s)\n" %
1227 (sys.version, sys.platform, cprt,
1225 (sys.version, sys.platform, cprt,
1228 self.__class__.__name__))
1226 self.__class__.__name__))
1229 else:
1227 else:
1230 self.write(banner)
1228 self.write(banner)
1231
1229
1232 more = 0
1230 more = 0
1233
1231
1234 # Mark activity in the builtins
1232 # Mark activity in the builtins
1235 __builtin__.__dict__['__IPYTHON__active'] += 1
1233 __builtin__.__dict__['__IPYTHON__active'] += 1
1236
1234
1237 # compiled regexps for autoindent management
1235 # compiled regexps for autoindent management
1238 ini_spaces_re = re.compile(r'^(\s+)')
1236 ini_spaces_re = re.compile(r'^(\s+)')
1239 dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass')
1237 dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass')
1240
1238
1241 # exit_now is set by a call to %Exit or %Quit
1239 # exit_now is set by a call to %Exit or %Quit
1242 while not self.exit_now:
1240 while not self.exit_now:
1243 try:
1241 try:
1244 if more:
1242 if more:
1245 prompt = self.outputcache.prompt2
1243 prompt = self.outputcache.prompt2
1246 if self.autoindent:
1244 if self.autoindent:
1247 self.readline_startup_hook(self.pre_readline)
1245 self.readline_startup_hook(self.pre_readline)
1248 else:
1246 else:
1249 prompt = self.outputcache.prompt1
1247 prompt = self.outputcache.prompt1
1250 try:
1248 try:
1251 line = self.raw_input(prompt,more)
1249 line = self.raw_input(prompt,more)
1252 if self.autoindent:
1250 if self.autoindent:
1253 self.readline_startup_hook(None)
1251 self.readline_startup_hook(None)
1254 except EOFError:
1252 except EOFError:
1255 if self.autoindent:
1253 if self.autoindent:
1256 self.readline_startup_hook(None)
1254 self.readline_startup_hook(None)
1257 self.write("\n")
1255 self.write("\n")
1258 self.exit()
1256 self.exit()
1259 except IPythonExit:
1260 self.exit()
1261 else:
1257 else:
1262 more = self.push(line)
1258 more = self.push(line)
1263 # Auto-indent management
1259 # Auto-indent management
1264 if self.autoindent:
1260 if self.autoindent:
1265 if line:
1261 if line:
1266 ini_spaces = ini_spaces_re.match(line)
1262 ini_spaces = ini_spaces_re.match(line)
1267 if ini_spaces:
1263 if ini_spaces:
1268 nspaces = ini_spaces.end()
1264 nspaces = ini_spaces.end()
1269 else:
1265 else:
1270 nspaces = 0
1266 nspaces = 0
1271 self.indent_current_nsp = nspaces
1267 self.indent_current_nsp = nspaces
1272
1268
1273 if line[-1] == ':':
1269 if line[-1] == ':':
1274 self.indent_current_nsp += 4
1270 self.indent_current_nsp += 4
1275 elif dedent_re.match(line):
1271 elif dedent_re.match(line):
1276 self.indent_current_nsp -= 4
1272 self.indent_current_nsp -= 4
1277 else:
1273 else:
1278 self.indent_current_nsp = 0
1274 self.indent_current_nsp = 0
1279
1275
1280 # indent_current is the actual string to be inserted
1276 # indent_current is the actual string to be inserted
1281 # by the readline hooks for indentation
1277 # by the readline hooks for indentation
1282 self.indent_current = ' '* self.indent_current_nsp
1278 self.indent_current = ' '* self.indent_current_nsp
1283
1279
1284 if (self.SyntaxTB.last_syntax_error and
1280 if (self.SyntaxTB.last_syntax_error and
1285 self.rc.autoedit_syntax):
1281 self.rc.autoedit_syntax):
1286 self.edit_syntax_error()
1282 self.edit_syntax_error()
1287
1283
1288 except KeyboardInterrupt:
1284 except KeyboardInterrupt:
1289 self.write("\nKeyboardInterrupt\n")
1285 self.write("\nKeyboardInterrupt\n")
1290 self.resetbuffer()
1286 self.resetbuffer()
1291 more = 0
1287 more = 0
1292 # keep cache in sync with the prompt counter:
1288 # keep cache in sync with the prompt counter:
1293 self.outputcache.prompt_count -= 1
1289 self.outputcache.prompt_count -= 1
1294
1290
1295 if self.autoindent:
1291 if self.autoindent:
1296 self.indent_current_nsp = 0
1292 self.indent_current_nsp = 0
1297 self.indent_current = ' '* self.indent_current_nsp
1293 self.indent_current = ' '* self.indent_current_nsp
1298
1294
1299 except bdb.BdbQuit:
1295 except bdb.BdbQuit:
1300 warn("The Python debugger has exited with a BdbQuit exception.\n"
1296 warn("The Python debugger has exited with a BdbQuit exception.\n"
1301 "Because of how pdb handles the stack, it is impossible\n"
1297 "Because of how pdb handles the stack, it is impossible\n"
1302 "for IPython to properly format this particular exception.\n"
1298 "for IPython to properly format this particular exception.\n"
1303 "IPython will resume normal operation.")
1299 "IPython will resume normal operation.")
1304
1300
1305 # We are off again...
1301 # We are off again...
1306 __builtin__.__dict__['__IPYTHON__active'] -= 1
1302 __builtin__.__dict__['__IPYTHON__active'] -= 1
1307
1303
1308 def excepthook(self, type, value, tb):
1304 def excepthook(self, type, value, tb):
1309 """One more defense for GUI apps that call sys.excepthook.
1305 """One more defense for GUI apps that call sys.excepthook.
1310
1306
1311 GUI frameworks like wxPython trap exceptions and call
1307 GUI frameworks like wxPython trap exceptions and call
1312 sys.excepthook themselves. I guess this is a feature that
1308 sys.excepthook themselves. I guess this is a feature that
1313 enables them to keep running after exceptions that would
1309 enables them to keep running after exceptions that would
1314 otherwise kill their mainloop. This is a bother for IPython
1310 otherwise kill their mainloop. This is a bother for IPython
1315 which excepts to catch all of the program exceptions with a try:
1311 which excepts to catch all of the program exceptions with a try:
1316 except: statement.
1312 except: statement.
1317
1313
1318 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1314 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1319 any app directly invokes sys.excepthook, it will look to the user like
1315 any app directly invokes sys.excepthook, it will look to the user like
1320 IPython crashed. In order to work around this, we can disable the
1316 IPython crashed. In order to work around this, we can disable the
1321 CrashHandler and replace it with this excepthook instead, which prints a
1317 CrashHandler and replace it with this excepthook instead, which prints a
1322 regular traceback using our InteractiveTB. In this fashion, apps which
1318 regular traceback using our InteractiveTB. In this fashion, apps which
1323 call sys.excepthook will generate a regular-looking exception from
1319 call sys.excepthook will generate a regular-looking exception from
1324 IPython, and the CrashHandler will only be triggered by real IPython
1320 IPython, and the CrashHandler will only be triggered by real IPython
1325 crashes.
1321 crashes.
1326
1322
1327 This hook should be used sparingly, only in places which are not likely
1323 This hook should be used sparingly, only in places which are not likely
1328 to be true IPython errors.
1324 to be true IPython errors.
1329 """
1325 """
1330
1326
1331 self.InteractiveTB(type, value, tb, tb_offset=0)
1327 self.InteractiveTB(type, value, tb, tb_offset=0)
1332 if self.InteractiveTB.call_pdb and self.has_readline:
1328 if self.InteractiveTB.call_pdb and self.has_readline:
1333 self.readline.set_completer(self.Completer.complete)
1329 self.readline.set_completer(self.Completer.complete)
1334
1330
1335 def call_alias(self,alias,rest=''):
1331 def call_alias(self,alias,rest=''):
1336 """Call an alias given its name and the rest of the line.
1332 """Call an alias given its name and the rest of the line.
1337
1333
1338 This function MUST be given a proper alias, because it doesn't make
1334 This function MUST be given a proper alias, because it doesn't make
1339 any checks when looking up into the alias table. The caller is
1335 any checks when looking up into the alias table. The caller is
1340 responsible for invoking it only with a valid alias."""
1336 responsible for invoking it only with a valid alias."""
1341
1337
1342 #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg
1338 #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg
1343 nargs,cmd = self.alias_table[alias]
1339 nargs,cmd = self.alias_table[alias]
1344 # Expand the %l special to be the user's input line
1340 # Expand the %l special to be the user's input line
1345 if cmd.find('%l') >= 0:
1341 if cmd.find('%l') >= 0:
1346 cmd = cmd.replace('%l',rest)
1342 cmd = cmd.replace('%l',rest)
1347 rest = ''
1343 rest = ''
1348 if nargs==0:
1344 if nargs==0:
1349 # Simple, argument-less aliases
1345 # Simple, argument-less aliases
1350 cmd = '%s %s' % (cmd,rest)
1346 cmd = '%s %s' % (cmd,rest)
1351 else:
1347 else:
1352 # Handle aliases with positional arguments
1348 # Handle aliases with positional arguments
1353 args = rest.split(None,nargs)
1349 args = rest.split(None,nargs)
1354 if len(args)< nargs:
1350 if len(args)< nargs:
1355 error('Alias <%s> requires %s arguments, %s given.' %
1351 error('Alias <%s> requires %s arguments, %s given.' %
1356 (alias,nargs,len(args)))
1352 (alias,nargs,len(args)))
1357 return
1353 return
1358 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1354 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1359 # Now call the macro, evaluating in the user's namespace
1355 # Now call the macro, evaluating in the user's namespace
1360 try:
1356 try:
1361 self.system(cmd)
1357 self.system(cmd)
1362 except:
1358 except:
1363 self.showtraceback()
1359 self.showtraceback()
1364
1360
1365 def runlines(self,lines):
1361 def runlines(self,lines):
1366 """Run a string of one or more lines of source.
1362 """Run a string of one or more lines of source.
1367
1363
1368 This method is capable of running a string containing multiple source
1364 This method is capable of running a string containing multiple source
1369 lines, as if they had been entered at the IPython prompt. Since it
1365 lines, as if they had been entered at the IPython prompt. Since it
1370 exposes IPython's processing machinery, the given strings can contain
1366 exposes IPython's processing machinery, the given strings can contain
1371 magic calls (%magic), special shell access (!cmd), etc."""
1367 magic calls (%magic), special shell access (!cmd), etc."""
1372
1368
1373 # We must start with a clean buffer, in case this is run from an
1369 # We must start with a clean buffer, in case this is run from an
1374 # interactive IPython session (via a magic, for example).
1370 # interactive IPython session (via a magic, for example).
1375 self.resetbuffer()
1371 self.resetbuffer()
1376 lines = lines.split('\n')
1372 lines = lines.split('\n')
1377 more = 0
1373 more = 0
1378 for line in lines:
1374 for line in lines:
1379 # skip blank lines so we don't mess up the prompt counter, but do
1375 # skip blank lines so we don't mess up the prompt counter, but do
1380 # NOT skip even a blank line if we are in a code block (more is
1376 # NOT skip even a blank line if we are in a code block (more is
1381 # true)
1377 # true)
1382 if line or more:
1378 if line or more:
1383 more = self.push((self.prefilter(line,more)))
1379 more = self.push((self.prefilter(line,more)))
1384 # IPython's runsource returns None if there was an error
1380 # IPython's runsource returns None if there was an error
1385 # compiling the code. This allows us to stop processing right
1381 # compiling the code. This allows us to stop processing right
1386 # away, so the user gets the error message at the right place.
1382 # away, so the user gets the error message at the right place.
1387 if more is None:
1383 if more is None:
1388 break
1384 break
1389 # final newline in case the input didn't have it, so that the code
1385 # final newline in case the input didn't have it, so that the code
1390 # actually does get executed
1386 # actually does get executed
1391 if more:
1387 if more:
1392 self.push('\n')
1388 self.push('\n')
1393
1389
1394 def runsource(self, source, filename='<input>', symbol='single'):
1390 def runsource(self, source, filename='<input>', symbol='single'):
1395 """Compile and run some source in the interpreter.
1391 """Compile and run some source in the interpreter.
1396
1392
1397 Arguments are as for compile_command().
1393 Arguments are as for compile_command().
1398
1394
1399 One several things can happen:
1395 One several things can happen:
1400
1396
1401 1) The input is incorrect; compile_command() raised an
1397 1) The input is incorrect; compile_command() raised an
1402 exception (SyntaxError or OverflowError). A syntax traceback
1398 exception (SyntaxError or OverflowError). A syntax traceback
1403 will be printed by calling the showsyntaxerror() method.
1399 will be printed by calling the showsyntaxerror() method.
1404
1400
1405 2) The input is incomplete, and more input is required;
1401 2) The input is incomplete, and more input is required;
1406 compile_command() returned None. Nothing happens.
1402 compile_command() returned None. Nothing happens.
1407
1403
1408 3) The input is complete; compile_command() returned a code
1404 3) The input is complete; compile_command() returned a code
1409 object. The code is executed by calling self.runcode() (which
1405 object. The code is executed by calling self.runcode() (which
1410 also handles run-time exceptions, except for SystemExit).
1406 also handles run-time exceptions, except for SystemExit).
1411
1407
1412 The return value is:
1408 The return value is:
1413
1409
1414 - True in case 2
1410 - True in case 2
1415
1411
1416 - False in the other cases, unless an exception is raised, where
1412 - False in the other cases, unless an exception is raised, where
1417 None is returned instead. This can be used by external callers to
1413 None is returned instead. This can be used by external callers to
1418 know whether to continue feeding input or not.
1414 know whether to continue feeding input or not.
1419
1415
1420 The return value can be used to decide whether to use sys.ps1 or
1416 The return value can be used to decide whether to use sys.ps1 or
1421 sys.ps2 to prompt the next line."""
1417 sys.ps2 to prompt the next line."""
1422
1418
1423 try:
1419 try:
1424 code = self.compile(source,filename,symbol)
1420 code = self.compile(source,filename,symbol)
1425 except (OverflowError, SyntaxError, ValueError):
1421 except (OverflowError, SyntaxError, ValueError):
1426 # Case 1
1422 # Case 1
1427 self.showsyntaxerror(filename)
1423 self.showsyntaxerror(filename)
1428 return None
1424 return None
1429
1425
1430 if code is None:
1426 if code is None:
1431 # Case 2
1427 # Case 2
1432 return True
1428 return True
1433
1429
1434 # Case 3
1430 # Case 3
1435 # We store the code object so that threaded shells and
1431 # We store the code object so that threaded shells and
1436 # custom exception handlers can access all this info if needed.
1432 # custom exception handlers can access all this info if needed.
1437 # The source corresponding to this can be obtained from the
1433 # The source corresponding to this can be obtained from the
1438 # buffer attribute as '\n'.join(self.buffer).
1434 # buffer attribute as '\n'.join(self.buffer).
1439 self.code_to_run = code
1435 self.code_to_run = code
1440 # now actually execute the code object
1436 # now actually execute the code object
1441 if self.runcode(code) == 0:
1437 if self.runcode(code) == 0:
1442 return False
1438 return False
1443 else:
1439 else:
1444 return None
1440 return None
1445
1441
1446 def runcode(self,code_obj):
1442 def runcode(self,code_obj):
1447 """Execute a code object.
1443 """Execute a code object.
1448
1444
1449 When an exception occurs, self.showtraceback() is called to display a
1445 When an exception occurs, self.showtraceback() is called to display a
1450 traceback.
1446 traceback.
1451
1447
1452 Return value: a flag indicating whether the code to be run completed
1448 Return value: a flag indicating whether the code to be run completed
1453 successfully:
1449 successfully:
1454
1450
1455 - 0: successful execution.
1451 - 0: successful execution.
1456 - 1: an error occurred.
1452 - 1: an error occurred.
1457 """
1453 """
1458
1454
1459 # Set our own excepthook in case the user code tries to call it
1455 # Set our own excepthook in case the user code tries to call it
1460 # directly, so that the IPython crash handler doesn't get triggered
1456 # directly, so that the IPython crash handler doesn't get triggered
1461 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1457 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1462 outflag = 1 # happens in more places, so it's easier as default
1458 outflag = 1 # happens in more places, so it's easier as default
1463 try:
1459 try:
1464 try:
1460 try:
1465 # Embedded instances require separate global/local namespaces
1461 # Embedded instances require separate global/local namespaces
1466 # so they can see both the surrounding (local) namespace and
1462 # so they can see both the surrounding (local) namespace and
1467 # the module-level globals when called inside another function.
1463 # the module-level globals when called inside another function.
1468 if self.embedded:
1464 if self.embedded:
1469 exec code_obj in self.user_global_ns, self.user_ns
1465 exec code_obj in self.user_global_ns, self.user_ns
1470 # Normal (non-embedded) instances should only have a single
1466 # Normal (non-embedded) instances should only have a single
1471 # namespace for user code execution, otherwise functions won't
1467 # namespace for user code execution, otherwise functions won't
1472 # see interactive top-level globals.
1468 # see interactive top-level globals.
1473 else:
1469 else:
1474 exec code_obj in self.user_ns
1470 exec code_obj in self.user_ns
1475 finally:
1471 finally:
1476 # Reset our crash handler in place
1472 # Reset our crash handler in place
1477 sys.excepthook = old_excepthook
1473 sys.excepthook = old_excepthook
1478 except SystemExit:
1474 except SystemExit:
1479 self.resetbuffer()
1475 self.resetbuffer()
1480 self.showtraceback()
1476 self.showtraceback()
1481 warn("Type exit or quit to exit IPython "
1477 warn("Type exit or quit to exit IPython "
1482 "(%Exit or %Quit do so unconditionally).",level=1)
1478 "(%Exit or %Quit do so unconditionally).",level=1)
1483 except self.custom_exceptions:
1479 except self.custom_exceptions:
1484 etype,value,tb = sys.exc_info()
1480 etype,value,tb = sys.exc_info()
1485 self.CustomTB(etype,value,tb)
1481 self.CustomTB(etype,value,tb)
1486 except:
1482 except:
1487 self.showtraceback()
1483 self.showtraceback()
1488 else:
1484 else:
1489 outflag = 0
1485 outflag = 0
1490 if softspace(sys.stdout, 0):
1486 if softspace(sys.stdout, 0):
1491 print
1487 print
1492 # Flush out code object which has been run (and source)
1488 # Flush out code object which has been run (and source)
1493 self.code_to_run = None
1489 self.code_to_run = None
1494 return outflag
1490 return outflag
1495
1491
1496 def push(self, line):
1492 def push(self, line):
1497 """Push a line to the interpreter.
1493 """Push a line to the interpreter.
1498
1494
1499 The line should not have a trailing newline; it may have
1495 The line should not have a trailing newline; it may have
1500 internal newlines. The line is appended to a buffer and the
1496 internal newlines. The line is appended to a buffer and the
1501 interpreter's runsource() method is called with the
1497 interpreter's runsource() method is called with the
1502 concatenated contents of the buffer as source. If this
1498 concatenated contents of the buffer as source. If this
1503 indicates that the command was executed or invalid, the buffer
1499 indicates that the command was executed or invalid, the buffer
1504 is reset; otherwise, the command is incomplete, and the buffer
1500 is reset; otherwise, the command is incomplete, and the buffer
1505 is left as it was after the line was appended. The return
1501 is left as it was after the line was appended. The return
1506 value is 1 if more input is required, 0 if the line was dealt
1502 value is 1 if more input is required, 0 if the line was dealt
1507 with in some way (this is the same as runsource()).
1503 with in some way (this is the same as runsource()).
1508
1504
1509 """
1505 """
1510 self.buffer.append(line)
1506 self.buffer.append(line)
1511 more = self.runsource('\n'.join(self.buffer), self.filename)
1507 more = self.runsource('\n'.join(self.buffer), self.filename)
1512 if not more:
1508 if not more:
1513 self.resetbuffer()
1509 self.resetbuffer()
1514 return more
1510 return more
1515
1511
1516 def resetbuffer(self):
1512 def resetbuffer(self):
1517 """Reset the input buffer."""
1513 """Reset the input buffer."""
1518 self.buffer[:] = []
1514 self.buffer[:] = []
1519
1515
1520 def raw_input(self,prompt='',continue_prompt=False):
1516 def raw_input(self,prompt='',continue_prompt=False):
1521 """Write a prompt and read a line.
1517 """Write a prompt and read a line.
1522
1518
1523 The returned line does not include the trailing newline.
1519 The returned line does not include the trailing newline.
1524 When the user enters the EOF key sequence, EOFError is raised.
1520 When the user enters the EOF key sequence, EOFError is raised.
1525
1521
1526 Optional inputs:
1522 Optional inputs:
1527
1523
1528 - prompt(''): a string to be printed to prompt the user.
1524 - prompt(''): a string to be printed to prompt the user.
1529
1525
1530 - continue_prompt(False): whether this line is the first one or a
1526 - continue_prompt(False): whether this line is the first one or a
1531 continuation in a sequence of inputs.
1527 continuation in a sequence of inputs.
1532 """
1528 """
1533
1529
1534 line = raw_input_original(prompt)
1530 line = raw_input_original(prompt)
1535 # Try to be reasonably smart about not re-indenting pasted input more
1531 # Try to be reasonably smart about not re-indenting pasted input more
1536 # than necessary. We do this by trimming out the auto-indent initial
1532 # than necessary. We do this by trimming out the auto-indent initial
1537 # spaces, if the user's actual input started itself with whitespace.
1533 # spaces, if the user's actual input started itself with whitespace.
1538 if self.autoindent:
1534 if self.autoindent:
1539 line2 = line[self.indent_current_nsp:]
1535 line2 = line[self.indent_current_nsp:]
1540 if line2[0:1] in (' ','\t'):
1536 if line2[0:1] in (' ','\t'):
1541 line = line2
1537 line = line2
1542 return self.prefilter(line,continue_prompt)
1538 return self.prefilter(line,continue_prompt)
1543
1539
1544 def split_user_input(self,line):
1540 def split_user_input(self,line):
1545 """Split user input into pre-char, function part and rest."""
1541 """Split user input into pre-char, function part and rest."""
1546
1542
1547 lsplit = self.line_split.match(line)
1543 lsplit = self.line_split.match(line)
1548 if lsplit is None: # no regexp match returns None
1544 if lsplit is None: # no regexp match returns None
1549 try:
1545 try:
1550 iFun,theRest = line.split(None,1)
1546 iFun,theRest = line.split(None,1)
1551 except ValueError:
1547 except ValueError:
1552 iFun,theRest = line,''
1548 iFun,theRest = line,''
1553 pre = re.match('^(\s*)(.*)',line).groups()[0]
1549 pre = re.match('^(\s*)(.*)',line).groups()[0]
1554 else:
1550 else:
1555 pre,iFun,theRest = lsplit.groups()
1551 pre,iFun,theRest = lsplit.groups()
1556
1552
1557 #print 'line:<%s>' % line # dbg
1553 #print 'line:<%s>' % line # dbg
1558 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
1554 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
1559 return pre,iFun.strip(),theRest
1555 return pre,iFun.strip(),theRest
1560
1556
1561 def _prefilter(self, line, continue_prompt):
1557 def _prefilter(self, line, continue_prompt):
1562 """Calls different preprocessors, depending on the form of line."""
1558 """Calls different preprocessors, depending on the form of line."""
1563
1559
1564 # All handlers *must* return a value, even if it's blank ('').
1560 # All handlers *must* return a value, even if it's blank ('').
1565
1561
1566 # Lines are NOT logged here. Handlers should process the line as
1562 # Lines are NOT logged here. Handlers should process the line as
1567 # needed, update the cache AND log it (so that the input cache array
1563 # needed, update the cache AND log it (so that the input cache array
1568 # stays synced).
1564 # stays synced).
1569
1565
1570 # This function is _very_ delicate, and since it's also the one which
1566 # This function is _very_ delicate, and since it's also the one which
1571 # determines IPython's response to user input, it must be as efficient
1567 # determines IPython's response to user input, it must be as efficient
1572 # as possible. For this reason it has _many_ returns in it, trying
1568 # as possible. For this reason it has _many_ returns in it, trying
1573 # always to exit as quickly as it can figure out what it needs to do.
1569 # always to exit as quickly as it can figure out what it needs to do.
1574
1570
1575 # This function is the main responsible for maintaining IPython's
1571 # This function is the main responsible for maintaining IPython's
1576 # behavior respectful of Python's semantics. So be _very_ careful if
1572 # behavior respectful of Python's semantics. So be _very_ careful if
1577 # making changes to anything here.
1573 # making changes to anything here.
1578
1574
1579 #.....................................................................
1575 #.....................................................................
1580 # Code begins
1576 # Code begins
1581
1577
1582 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
1578 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
1583
1579
1584 # save the line away in case we crash, so the post-mortem handler can
1580 # save the line away in case we crash, so the post-mortem handler can
1585 # record it
1581 # record it
1586 self._last_input_line = line
1582 self._last_input_line = line
1587
1583
1588 #print '***line: <%s>' % line # dbg
1584 #print '***line: <%s>' % line # dbg
1589
1585
1590 # the input history needs to track even empty lines
1586 # the input history needs to track even empty lines
1591 if not line.strip():
1587 if not line.strip():
1592 if not continue_prompt:
1588 if not continue_prompt:
1593 self.outputcache.prompt_count -= 1
1589 self.outputcache.prompt_count -= 1
1594 return self.handle_normal(line,continue_prompt)
1590 return self.handle_normal(line,continue_prompt)
1595 #return self.handle_normal('',continue_prompt)
1591 #return self.handle_normal('',continue_prompt)
1596
1592
1597 # print '***cont',continue_prompt # dbg
1593 # print '***cont',continue_prompt # dbg
1598 # special handlers are only allowed for single line statements
1594 # special handlers are only allowed for single line statements
1599 if continue_prompt and not self.rc.multi_line_specials:
1595 if continue_prompt and not self.rc.multi_line_specials:
1600 return self.handle_normal(line,continue_prompt)
1596 return self.handle_normal(line,continue_prompt)
1601
1597
1602 # For the rest, we need the structure of the input
1598 # For the rest, we need the structure of the input
1603 pre,iFun,theRest = self.split_user_input(line)
1599 pre,iFun,theRest = self.split_user_input(line)
1604 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1600 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1605
1601
1606 # First check for explicit escapes in the last/first character
1602 # First check for explicit escapes in the last/first character
1607 handler = None
1603 handler = None
1608 if line[-1] == self.ESC_HELP:
1604 if line[-1] == self.ESC_HELP:
1609 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
1605 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
1610 if handler is None:
1606 if handler is None:
1611 # look at the first character of iFun, NOT of line, so we skip
1607 # look at the first character of iFun, NOT of line, so we skip
1612 # leading whitespace in multiline input
1608 # leading whitespace in multiline input
1613 handler = self.esc_handlers.get(iFun[0:1])
1609 handler = self.esc_handlers.get(iFun[0:1])
1614 if handler is not None:
1610 if handler is not None:
1615 return handler(line,continue_prompt,pre,iFun,theRest)
1611 return handler(line,continue_prompt,pre,iFun,theRest)
1616 # Emacs ipython-mode tags certain input lines
1612 # Emacs ipython-mode tags certain input lines
1617 if line.endswith('# PYTHON-MODE'):
1613 if line.endswith('# PYTHON-MODE'):
1618 return self.handle_emacs(line,continue_prompt)
1614 return self.handle_emacs(line,continue_prompt)
1619
1615
1620 # Next, check if we can automatically execute this thing
1616 # Next, check if we can automatically execute this thing
1621
1617
1622 # Allow ! in multi-line statements if multi_line_specials is on:
1618 # Allow ! in multi-line statements if multi_line_specials is on:
1623 if continue_prompt and self.rc.multi_line_specials and \
1619 if continue_prompt and self.rc.multi_line_specials and \
1624 iFun.startswith(self.ESC_SHELL):
1620 iFun.startswith(self.ESC_SHELL):
1625 return self.handle_shell_escape(line,continue_prompt,
1621 return self.handle_shell_escape(line,continue_prompt,
1626 pre=pre,iFun=iFun,
1622 pre=pre,iFun=iFun,
1627 theRest=theRest)
1623 theRest=theRest)
1628
1624
1629 # Let's try to find if the input line is a magic fn
1625 # Let's try to find if the input line is a magic fn
1630 oinfo = None
1626 oinfo = None
1631 if hasattr(self,'magic_'+iFun):
1627 if hasattr(self,'magic_'+iFun):
1632 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1628 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1633 if oinfo['ismagic']:
1629 if oinfo['ismagic']:
1634 # Be careful not to call magics when a variable assignment is
1630 # Be careful not to call magics when a variable assignment is
1635 # being made (ls='hi', for example)
1631 # being made (ls='hi', for example)
1636 if self.rc.automagic and \
1632 if self.rc.automagic and \
1637 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
1633 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
1638 (self.rc.multi_line_specials or not continue_prompt):
1634 (self.rc.multi_line_specials or not continue_prompt):
1639 return self.handle_magic(line,continue_prompt,
1635 return self.handle_magic(line,continue_prompt,
1640 pre,iFun,theRest)
1636 pre,iFun,theRest)
1641 else:
1637 else:
1642 return self.handle_normal(line,continue_prompt)
1638 return self.handle_normal(line,continue_prompt)
1643
1639
1644 # If the rest of the line begins with an (in)equality, assginment or
1640 # If the rest of the line begins with an (in)equality, assginment or
1645 # function call, we should not call _ofind but simply execute it.
1641 # function call, we should not call _ofind but simply execute it.
1646 # This avoids spurious geattr() accesses on objects upon assignment.
1642 # This avoids spurious geattr() accesses on objects upon assignment.
1647 #
1643 #
1648 # It also allows users to assign to either alias or magic names true
1644 # It also allows users to assign to either alias or magic names true
1649 # python variables (the magic/alias systems always take second seat to
1645 # python variables (the magic/alias systems always take second seat to
1650 # true python code).
1646 # true python code).
1651 if theRest and theRest[0] in '!=()':
1647 if theRest and theRest[0] in '!=()':
1652 return self.handle_normal(line,continue_prompt)
1648 return self.handle_normal(line,continue_prompt)
1653
1649
1654 if oinfo is None:
1650 if oinfo is None:
1655 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1651 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1656
1652
1657 if not oinfo['found']:
1653 if not oinfo['found']:
1658 if iFun in ('quit','exit'):
1659 raise IPythonExit
1660 return self.handle_normal(line,continue_prompt)
1654 return self.handle_normal(line,continue_prompt)
1661 else:
1655 else:
1662 #print 'iFun <%s> rest <%s>' % (iFun,theRest) # dbg
1656 #print 'iFun <%s> rest <%s>' % (iFun,theRest) # dbg
1663 if oinfo['isalias']:
1657 if oinfo['isalias']:
1664 return self.handle_alias(line,continue_prompt,
1658 return self.handle_alias(line,continue_prompt,
1665 pre,iFun,theRest)
1659 pre,iFun,theRest)
1666
1660
1667 if self.rc.autocall and \
1661 if self.rc.autocall and \
1668 not self.re_exclude_auto.match(theRest) and \
1662 not self.re_exclude_auto.match(theRest) and \
1669 self.re_fun_name.match(iFun) and \
1663 self.re_fun_name.match(iFun) and \
1670 callable(oinfo['obj']) :
1664 callable(oinfo['obj']) :
1671 #print 'going auto' # dbg
1665 #print 'going auto' # dbg
1672 return self.handle_auto(line,continue_prompt,pre,iFun,theRest)
1666 return self.handle_auto(line,continue_prompt,pre,iFun,theRest)
1673 else:
1667 else:
1674 #print 'was callable?', callable(oinfo['obj']) # dbg
1668 #print 'was callable?', callable(oinfo['obj']) # dbg
1675 return self.handle_normal(line,continue_prompt)
1669 return self.handle_normal(line,continue_prompt)
1676
1670
1677 # If we get here, we have a normal Python line. Log and return.
1671 # If we get here, we have a normal Python line. Log and return.
1678 return self.handle_normal(line,continue_prompt)
1672 return self.handle_normal(line,continue_prompt)
1679
1673
1680 def _prefilter_dumb(self, line, continue_prompt):
1674 def _prefilter_dumb(self, line, continue_prompt):
1681 """simple prefilter function, for debugging"""
1675 """simple prefilter function, for debugging"""
1682 return self.handle_normal(line,continue_prompt)
1676 return self.handle_normal(line,continue_prompt)
1683
1677
1684 # Set the default prefilter() function (this can be user-overridden)
1678 # Set the default prefilter() function (this can be user-overridden)
1685 prefilter = _prefilter
1679 prefilter = _prefilter
1686
1680
1687 def handle_normal(self,line,continue_prompt=None,
1681 def handle_normal(self,line,continue_prompt=None,
1688 pre=None,iFun=None,theRest=None):
1682 pre=None,iFun=None,theRest=None):
1689 """Handle normal input lines. Use as a template for handlers."""
1683 """Handle normal input lines. Use as a template for handlers."""
1690
1684
1691 # With autoindent on, we need some way to exit the input loop, and I
1685 # With autoindent on, we need some way to exit the input loop, and I
1692 # don't want to force the user to have to backspace all the way to
1686 # don't want to force the user to have to backspace all the way to
1693 # clear the line. The rule will be in this case, that either two
1687 # clear the line. The rule will be in this case, that either two
1694 # lines of pure whitespace in a row, or a line of pure whitespace but
1688 # lines of pure whitespace in a row, or a line of pure whitespace but
1695 # of a size different to the indent level, will exit the input loop.
1689 # of a size different to the indent level, will exit the input loop.
1696 if (continue_prompt and self.autoindent and isspace(line) and
1690 if (continue_prompt and self.autoindent and isspace(line) and
1697 (line != self.indent_current or isspace(self.buffer[-1]))):
1691 (line != self.indent_current or isspace(self.buffer[-1]))):
1698 line = ''
1692 line = ''
1699
1693
1700 self.log(line,continue_prompt)
1694 self.log(line,continue_prompt)
1701 self.update_cache(line)
1695 self.update_cache(line)
1702 return line
1696 return line
1703
1697
1704 def handle_alias(self,line,continue_prompt=None,
1698 def handle_alias(self,line,continue_prompt=None,
1705 pre=None,iFun=None,theRest=None):
1699 pre=None,iFun=None,theRest=None):
1706 """Handle alias input lines. """
1700 """Handle alias input lines. """
1707
1701
1708 theRest = esc_quotes(theRest)
1702 theRest = esc_quotes(theRest)
1709 line_out = "%s%s.call_alias('%s','%s')" % (pre,self.name,iFun,theRest)
1703 line_out = "%s%s.call_alias('%s','%s')" % (pre,self.name,iFun,theRest)
1710 self.log(line_out,continue_prompt)
1704 self.log(line_out,continue_prompt)
1711 self.update_cache(line_out)
1705 self.update_cache(line_out)
1712 return line_out
1706 return line_out
1713
1707
1714 def handle_shell_escape(self, line, continue_prompt=None,
1708 def handle_shell_escape(self, line, continue_prompt=None,
1715 pre=None,iFun=None,theRest=None):
1709 pre=None,iFun=None,theRest=None):
1716 """Execute the line in a shell, empty return value"""
1710 """Execute the line in a shell, empty return value"""
1717
1711
1718 #print 'line in :', `line` # dbg
1712 #print 'line in :', `line` # dbg
1719 # Example of a special handler. Others follow a similar pattern.
1713 # Example of a special handler. Others follow a similar pattern.
1720 if continue_prompt: # multi-line statements
1714 if continue_prompt: # multi-line statements
1721 if iFun.startswith('!!'):
1715 if iFun.startswith('!!'):
1722 print 'SyntaxError: !! is not allowed in multiline statements'
1716 print 'SyntaxError: !! is not allowed in multiline statements'
1723 return pre
1717 return pre
1724 else:
1718 else:
1725 cmd = ("%s %s" % (iFun[1:],theRest)).replace('"','\\"')
1719 cmd = ("%s %s" % (iFun[1:],theRest)).replace('"','\\"')
1726 line_out = '%s%s.system("%s")' % (pre,self.name,cmd)
1720 line_out = '%s%s.system("%s")' % (pre,self.name,cmd)
1727 #line_out = ('%s%s.system(' % (pre,self.name)) + repr(cmd) + ')'
1721 #line_out = ('%s%s.system(' % (pre,self.name)) + repr(cmd) + ')'
1728 else: # single-line input
1722 else: # single-line input
1729 if line.startswith('!!'):
1723 if line.startswith('!!'):
1730 # rewrite iFun/theRest to properly hold the call to %sx and
1724 # rewrite iFun/theRest to properly hold the call to %sx and
1731 # the actual command to be executed, so handle_magic can work
1725 # the actual command to be executed, so handle_magic can work
1732 # correctly
1726 # correctly
1733 theRest = '%s %s' % (iFun[2:],theRest)
1727 theRest = '%s %s' % (iFun[2:],theRest)
1734 iFun = 'sx'
1728 iFun = 'sx'
1735 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,line[2:]),
1729 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,line[2:]),
1736 continue_prompt,pre,iFun,theRest)
1730 continue_prompt,pre,iFun,theRest)
1737 else:
1731 else:
1738 cmd = esc_quotes(line[1:])
1732 cmd = esc_quotes(line[1:])
1739 line_out = '%s.system("%s")' % (self.name,cmd)
1733 line_out = '%s.system("%s")' % (self.name,cmd)
1740 #line_out = ('%s.system(' % self.name) + repr(cmd)+ ')'
1734 #line_out = ('%s.system(' % self.name) + repr(cmd)+ ')'
1741 # update cache/log and return
1735 # update cache/log and return
1742 self.log(line_out,continue_prompt)
1736 self.log(line_out,continue_prompt)
1743 self.update_cache(line_out) # readline cache gets normal line
1737 self.update_cache(line_out) # readline cache gets normal line
1744 #print 'line out r:', `line_out` # dbg
1738 #print 'line out r:', `line_out` # dbg
1745 #print 'line out s:', line_out # dbg
1739 #print 'line out s:', line_out # dbg
1746 return line_out
1740 return line_out
1747
1741
1748 def handle_magic(self, line, continue_prompt=None,
1742 def handle_magic(self, line, continue_prompt=None,
1749 pre=None,iFun=None,theRest=None):
1743 pre=None,iFun=None,theRest=None):
1750 """Execute magic functions.
1744 """Execute magic functions.
1751
1745
1752 Also log them with a prepended # so the log is clean Python."""
1746 Also log them with a prepended # so the log is clean Python."""
1753
1747
1754 cmd = '%sipmagic("%s")' % (pre,esc_quotes('%s %s' % (iFun,theRest)))
1748 cmd = '%sipmagic("%s")' % (pre,esc_quotes('%s %s' % (iFun,theRest)))
1755 self.log(cmd,continue_prompt)
1749 self.log(cmd,continue_prompt)
1756 self.update_cache(line)
1750 self.update_cache(line)
1757 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
1751 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
1758 return cmd
1752 return cmd
1759
1753
1760 def handle_auto(self, line, continue_prompt=None,
1754 def handle_auto(self, line, continue_prompt=None,
1761 pre=None,iFun=None,theRest=None):
1755 pre=None,iFun=None,theRest=None):
1762 """Hande lines which can be auto-executed, quoting if requested."""
1756 """Hande lines which can be auto-executed, quoting if requested."""
1763
1757
1764 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1758 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1765
1759
1766 # This should only be active for single-line input!
1760 # This should only be active for single-line input!
1767 if continue_prompt:
1761 if continue_prompt:
1768 return line
1762 return line
1769
1763
1770 if pre == self.ESC_QUOTE:
1764 if pre == self.ESC_QUOTE:
1771 # Auto-quote splitting on whitespace
1765 # Auto-quote splitting on whitespace
1772 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
1766 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
1773 elif pre == self.ESC_QUOTE2:
1767 elif pre == self.ESC_QUOTE2:
1774 # Auto-quote whole string
1768 # Auto-quote whole string
1775 newcmd = '%s("%s")' % (iFun,theRest)
1769 newcmd = '%s("%s")' % (iFun,theRest)
1776 else:
1770 else:
1777 # Auto-paren
1771 # Auto-paren
1778 if theRest[0:1] in ('=','['):
1772 if theRest[0:1] in ('=','['):
1779 # Don't autocall in these cases. They can be either
1773 # Don't autocall in these cases. They can be either
1780 # rebindings of an existing callable's name, or item access
1774 # rebindings of an existing callable's name, or item access
1781 # for an object which is BOTH callable and implements
1775 # for an object which is BOTH callable and implements
1782 # __getitem__.
1776 # __getitem__.
1783 return '%s %s' % (iFun,theRest)
1777 return '%s %s' % (iFun,theRest)
1784 if theRest.endswith(';'):
1778 if theRest.endswith(';'):
1785 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
1779 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
1786 else:
1780 else:
1787 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
1781 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
1788
1782
1789 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
1783 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
1790 # log what is now valid Python, not the actual user input (without the
1784 # log what is now valid Python, not the actual user input (without the
1791 # final newline)
1785 # final newline)
1792 self.log(newcmd,continue_prompt)
1786 self.log(newcmd,continue_prompt)
1793 return newcmd
1787 return newcmd
1794
1788
1795 def handle_help(self, line, continue_prompt=None,
1789 def handle_help(self, line, continue_prompt=None,
1796 pre=None,iFun=None,theRest=None):
1790 pre=None,iFun=None,theRest=None):
1797 """Try to get some help for the object.
1791 """Try to get some help for the object.
1798
1792
1799 obj? or ?obj -> basic information.
1793 obj? or ?obj -> basic information.
1800 obj?? or ??obj -> more details.
1794 obj?? or ??obj -> more details.
1801 """
1795 """
1802
1796
1803 # We need to make sure that we don't process lines which would be
1797 # We need to make sure that we don't process lines which would be
1804 # otherwise valid python, such as "x=1 # what?"
1798 # otherwise valid python, such as "x=1 # what?"
1805 try:
1799 try:
1806 codeop.compile_command(line)
1800 codeop.compile_command(line)
1807 except SyntaxError:
1801 except SyntaxError:
1808 # We should only handle as help stuff which is NOT valid syntax
1802 # We should only handle as help stuff which is NOT valid syntax
1809 if line[0]==self.ESC_HELP:
1803 if line[0]==self.ESC_HELP:
1810 line = line[1:]
1804 line = line[1:]
1811 elif line[-1]==self.ESC_HELP:
1805 elif line[-1]==self.ESC_HELP:
1812 line = line[:-1]
1806 line = line[:-1]
1813 self.log('#?'+line)
1807 self.log('#?'+line)
1814 self.update_cache(line)
1808 self.update_cache(line)
1815 if line:
1809 if line:
1816 self.magic_pinfo(line)
1810 self.magic_pinfo(line)
1817 else:
1811 else:
1818 page(self.usage,screen_lines=self.rc.screen_length)
1812 page(self.usage,screen_lines=self.rc.screen_length)
1819 return '' # Empty string is needed here!
1813 return '' # Empty string is needed here!
1820 except:
1814 except:
1821 # Pass any other exceptions through to the normal handler
1815 # Pass any other exceptions through to the normal handler
1822 return self.handle_normal(line,continue_prompt)
1816 return self.handle_normal(line,continue_prompt)
1823 else:
1817 else:
1824 # If the code compiles ok, we should handle it normally
1818 # If the code compiles ok, we should handle it normally
1825 return self.handle_normal(line,continue_prompt)
1819 return self.handle_normal(line,continue_prompt)
1826
1820
1827 def handle_emacs(self,line,continue_prompt=None,
1821 def handle_emacs(self,line,continue_prompt=None,
1828 pre=None,iFun=None,theRest=None):
1822 pre=None,iFun=None,theRest=None):
1829 """Handle input lines marked by python-mode."""
1823 """Handle input lines marked by python-mode."""
1830
1824
1831 # Currently, nothing is done. Later more functionality can be added
1825 # Currently, nothing is done. Later more functionality can be added
1832 # here if needed.
1826 # here if needed.
1833
1827
1834 # The input cache shouldn't be updated
1828 # The input cache shouldn't be updated
1835
1829
1836 return line
1830 return line
1837
1831
1838 def write(self,data):
1832 def write(self,data):
1839 """Write a string to the default output"""
1833 """Write a string to the default output"""
1840 Term.cout.write(data)
1834 Term.cout.write(data)
1841
1835
1842 def write_err(self,data):
1836 def write_err(self,data):
1843 """Write a string to the default error output"""
1837 """Write a string to the default error output"""
1844 Term.cerr.write(data)
1838 Term.cerr.write(data)
1845
1839
1846 def exit(self):
1840 def exit(self):
1847 """Handle interactive exit.
1841 """Handle interactive exit.
1848
1842
1849 This method sets the exit_now attribute."""
1843 This method sets the exit_now attribute."""
1850
1844
1851 if self.rc.confirm_exit:
1845 if self.rc.confirm_exit:
1852 if ask_yes_no('Do you really want to exit ([y]/n)?','y'):
1846 if ask_yes_no('Do you really want to exit ([y]/n)?','y'):
1853 self.exit_now = True
1847 self.exit_now = True
1854 else:
1848 else:
1855 self.exit_now = True
1849 self.exit_now = True
1856 return self.exit_now
1850 return self.exit_now
1857
1851
1858 def safe_execfile(self,fname,*where,**kw):
1852 def safe_execfile(self,fname,*where,**kw):
1859 fname = os.path.expanduser(fname)
1853 fname = os.path.expanduser(fname)
1860
1854
1861 # find things also in current directory
1855 # find things also in current directory
1862 dname = os.path.dirname(fname)
1856 dname = os.path.dirname(fname)
1863 if not sys.path.count(dname):
1857 if not sys.path.count(dname):
1864 sys.path.append(dname)
1858 sys.path.append(dname)
1865
1859
1866 try:
1860 try:
1867 xfile = open(fname)
1861 xfile = open(fname)
1868 except:
1862 except:
1869 print >> Term.cerr, \
1863 print >> Term.cerr, \
1870 'Could not open file <%s> for safe execution.' % fname
1864 'Could not open file <%s> for safe execution.' % fname
1871 return None
1865 return None
1872
1866
1873 kw.setdefault('islog',0)
1867 kw.setdefault('islog',0)
1874 kw.setdefault('quiet',1)
1868 kw.setdefault('quiet',1)
1875 kw.setdefault('exit_ignore',0)
1869 kw.setdefault('exit_ignore',0)
1876 first = xfile.readline()
1870 first = xfile.readline()
1877 _LOGHEAD = str(self.LOGHEAD).split('\n',1)[0].strip()
1871 _LOGHEAD = str(self.LOGHEAD).split('\n',1)[0].strip()
1878 xfile.close()
1872 xfile.close()
1879 # line by line execution
1873 # line by line execution
1880 if first.startswith(_LOGHEAD) or kw['islog']:
1874 if first.startswith(_LOGHEAD) or kw['islog']:
1881 print 'Loading log file <%s> one line at a time...' % fname
1875 print 'Loading log file <%s> one line at a time...' % fname
1882 if kw['quiet']:
1876 if kw['quiet']:
1883 stdout_save = sys.stdout
1877 stdout_save = sys.stdout
1884 sys.stdout = StringIO.StringIO()
1878 sys.stdout = StringIO.StringIO()
1885 try:
1879 try:
1886 globs,locs = where[0:2]
1880 globs,locs = where[0:2]
1887 except:
1881 except:
1888 try:
1882 try:
1889 globs = locs = where[0]
1883 globs = locs = where[0]
1890 except:
1884 except:
1891 globs = locs = globals()
1885 globs = locs = globals()
1892 badblocks = []
1886 badblocks = []
1893
1887
1894 # we also need to identify indented blocks of code when replaying
1888 # we also need to identify indented blocks of code when replaying
1895 # logs and put them together before passing them to an exec
1889 # logs and put them together before passing them to an exec
1896 # statement. This takes a bit of regexp and look-ahead work in the
1890 # statement. This takes a bit of regexp and look-ahead work in the
1897 # file. It's easiest if we swallow the whole thing in memory
1891 # file. It's easiest if we swallow the whole thing in memory
1898 # first, and manually walk through the lines list moving the
1892 # first, and manually walk through the lines list moving the
1899 # counter ourselves.
1893 # counter ourselves.
1900 indent_re = re.compile('\s+\S')
1894 indent_re = re.compile('\s+\S')
1901 xfile = open(fname)
1895 xfile = open(fname)
1902 filelines = xfile.readlines()
1896 filelines = xfile.readlines()
1903 xfile.close()
1897 xfile.close()
1904 nlines = len(filelines)
1898 nlines = len(filelines)
1905 lnum = 0
1899 lnum = 0
1906 while lnum < nlines:
1900 while lnum < nlines:
1907 line = filelines[lnum]
1901 line = filelines[lnum]
1908 lnum += 1
1902 lnum += 1
1909 # don't re-insert logger status info into cache
1903 # don't re-insert logger status info into cache
1910 if line.startswith('#log#'):
1904 if line.startswith('#log#'):
1911 continue
1905 continue
1912 elif line.startswith('#%s'% self.ESC_MAGIC):
1906 elif line.startswith('#%s'% self.ESC_MAGIC):
1913 self.update_cache(line[1:])
1907 self.update_cache(line[1:])
1914 line = magic2python(line)
1908 line = magic2python(line)
1915 elif line.startswith('#!'):
1909 elif line.startswith('#!'):
1916 self.update_cache(line[1:])
1910 self.update_cache(line[1:])
1917 else:
1911 else:
1918 # build a block of code (maybe a single line) for execution
1912 # build a block of code (maybe a single line) for execution
1919 block = line
1913 block = line
1920 try:
1914 try:
1921 next = filelines[lnum] # lnum has already incremented
1915 next = filelines[lnum] # lnum has already incremented
1922 except:
1916 except:
1923 next = None
1917 next = None
1924 while next and indent_re.match(next):
1918 while next and indent_re.match(next):
1925 block += next
1919 block += next
1926 lnum += 1
1920 lnum += 1
1927 try:
1921 try:
1928 next = filelines[lnum]
1922 next = filelines[lnum]
1929 except:
1923 except:
1930 next = None
1924 next = None
1931 # now execute the block of one or more lines
1925 # now execute the block of one or more lines
1932 try:
1926 try:
1933 exec block in globs,locs
1927 exec block in globs,locs
1934 self.update_cache(block.rstrip())
1928 self.update_cache(block.rstrip())
1935 except SystemExit:
1929 except SystemExit:
1936 pass
1930 pass
1937 except:
1931 except:
1938 badblocks.append(block.rstrip())
1932 badblocks.append(block.rstrip())
1939 if kw['quiet']: # restore stdout
1933 if kw['quiet']: # restore stdout
1940 sys.stdout.close()
1934 sys.stdout.close()
1941 sys.stdout = stdout_save
1935 sys.stdout = stdout_save
1942 print 'Finished replaying log file <%s>' % fname
1936 print 'Finished replaying log file <%s>' % fname
1943 if badblocks:
1937 if badblocks:
1944 print >> sys.stderr, ('\nThe following lines/blocks in file '
1938 print >> sys.stderr, ('\nThe following lines/blocks in file '
1945 '<%s> reported errors:' % fname)
1939 '<%s> reported errors:' % fname)
1946
1940
1947 for badline in badblocks:
1941 for badline in badblocks:
1948 print >> sys.stderr, badline
1942 print >> sys.stderr, badline
1949 else: # regular file execution
1943 else: # regular file execution
1950 try:
1944 try:
1951 execfile(fname,*where)
1945 execfile(fname,*where)
1952 except SyntaxError:
1946 except SyntaxError:
1953 etype, evalue = sys.exc_info()[0:2]
1947 etype, evalue = sys.exc_info()[0:2]
1954 self.SyntaxTB(etype,evalue,[])
1948 self.SyntaxTB(etype,evalue,[])
1955 warn('Failure executing file: <%s>' % fname)
1949 warn('Failure executing file: <%s>' % fname)
1956 except SystemExit,status:
1950 except SystemExit,status:
1957 if not kw['exit_ignore']:
1951 if not kw['exit_ignore']:
1958 self.InteractiveTB()
1952 self.InteractiveTB()
1959 warn('Failure executing file: <%s>' % fname)
1953 warn('Failure executing file: <%s>' % fname)
1960 except:
1954 except:
1961 self.InteractiveTB()
1955 self.InteractiveTB()
1962 warn('Failure executing file: <%s>' % fname)
1956 warn('Failure executing file: <%s>' % fname)
1963
1957
1964 #************************* end of file <iplib.py> *****************************
1958 #************************* end of file <iplib.py> *****************************
@@ -1,4568 +1,4575 b''
1 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
2
3 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
4 of the previous special-casing of input in the eval loop. I think
5 this is cleaner, as they really are commands and shouldn't have
6 a special role in the middle of the core code.
7
1 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
8 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
2
9
3 * IPython/iplib.py (edit_syntax_error): added support for
10 * IPython/iplib.py (edit_syntax_error): added support for
4 automatically reopening the editor if the file had a syntax error
11 automatically reopening the editor if the file had a syntax error
5 in it. Thanks to scottt who provided the patch at:
12 in it. Thanks to scottt who provided the patch at:
6 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
13 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
7 version committed).
14 version committed).
8
15
9 * IPython/iplib.py (handle_normal): add suport for multi-line
16 * IPython/iplib.py (handle_normal): add suport for multi-line
10 input with emtpy lines. This fixes
17 input with emtpy lines. This fixes
11 http://www.scipy.net/roundup/ipython/issue43 and a similar
18 http://www.scipy.net/roundup/ipython/issue43 and a similar
12 discussion on the user list.
19 discussion on the user list.
13
20
14 WARNING: a behavior change is necessarily introduced to support
21 WARNING: a behavior change is necessarily introduced to support
15 blank lines: now a single blank line with whitespace does NOT
22 blank lines: now a single blank line with whitespace does NOT
16 break the input loop, which means that when autoindent is on, by
23 break the input loop, which means that when autoindent is on, by
17 default hitting return on the next (indented) line does NOT exit.
24 default hitting return on the next (indented) line does NOT exit.
18
25
19 Instead, to exit a multiline input you can either have:
26 Instead, to exit a multiline input you can either have:
20
27
21 - TWO whitespace lines (just hit return again), or
28 - TWO whitespace lines (just hit return again), or
22 - a single whitespace line of a different length than provided
29 - a single whitespace line of a different length than provided
23 by the autoindent (add or remove a space).
30 by the autoindent (add or remove a space).
24
31
25 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
32 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
26 module to better organize all readline-related functionality.
33 module to better organize all readline-related functionality.
27 I've deleted FlexCompleter and put all completion clases here.
34 I've deleted FlexCompleter and put all completion clases here.
28
35
29 * IPython/iplib.py (raw_input): improve indentation management.
36 * IPython/iplib.py (raw_input): improve indentation management.
30 It is now possible to paste indented code with autoindent on, and
37 It is now possible to paste indented code with autoindent on, and
31 the code is interpreted correctly (though it still looks bad on
38 the code is interpreted correctly (though it still looks bad on
32 screen, due to the line-oriented nature of ipython).
39 screen, due to the line-oriented nature of ipython).
33 (MagicCompleter.complete): change behavior so that a TAB key on an
40 (MagicCompleter.complete): change behavior so that a TAB key on an
34 otherwise empty line actually inserts a tab, instead of completing
41 otherwise empty line actually inserts a tab, instead of completing
35 on the entire global namespace. This makes it easier to use the
42 on the entire global namespace. This makes it easier to use the
36 TAB key for indentation. After a request by Hans Meine
43 TAB key for indentation. After a request by Hans Meine
37 <hans_meine-AT-gmx.net>
44 <hans_meine-AT-gmx.net>
38 (_prefilter): add support so that typing plain 'exit' or 'quit'
45 (_prefilter): add support so that typing plain 'exit' or 'quit'
39 does a sensible thing. Originally I tried to deviate as little as
46 does a sensible thing. Originally I tried to deviate as little as
40 possible from the default python behavior, but even that one may
47 possible from the default python behavior, but even that one may
41 change in this direction (thread on python-dev to that effect).
48 change in this direction (thread on python-dev to that effect).
42 Regardless, ipython should do the right thing even if CPython's
49 Regardless, ipython should do the right thing even if CPython's
43 '>>>' prompt doesn't.
50 '>>>' prompt doesn't.
44 (InteractiveShell): removed subclassing code.InteractiveConsole
51 (InteractiveShell): removed subclassing code.InteractiveConsole
45 class. By now we'd overridden just about all of its methods: I've
52 class. By now we'd overridden just about all of its methods: I've
46 copied the remaining two over, and now ipython is a standalone
53 copied the remaining two over, and now ipython is a standalone
47 class. This will provide a clearer picture for the chainsaw
54 class. This will provide a clearer picture for the chainsaw
48 branch refactoring.
55 branch refactoring.
49
56
50 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
57 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
51
58
52 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
59 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
53 failures for objects which break when dir() is called on them.
60 failures for objects which break when dir() is called on them.
54
61
55 * IPython/FlexCompleter.py (Completer.__init__): Added support for
62 * IPython/FlexCompleter.py (Completer.__init__): Added support for
56 distinct local and global namespaces in the completer API. This
63 distinct local and global namespaces in the completer API. This
57 change allows us top properly handle completion with distinct
64 change allows us top properly handle completion with distinct
58 scopes, including in embedded instances (this had never really
65 scopes, including in embedded instances (this had never really
59 worked correctly).
66 worked correctly).
60
67
61 Note: this introduces a change in the constructor for
68 Note: this introduces a change in the constructor for
62 MagicCompleter, as a new global_namespace parameter is now the
69 MagicCompleter, as a new global_namespace parameter is now the
63 second argument (the others were bumped one position).
70 second argument (the others were bumped one position).
64
71
65 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
72 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
66
73
67 * IPython/iplib.py (embed_mainloop): fix tab-completion in
74 * IPython/iplib.py (embed_mainloop): fix tab-completion in
68 embedded instances (which can be done now thanks to Vivian's
75 embedded instances (which can be done now thanks to Vivian's
69 frame-handling fixes for pdb).
76 frame-handling fixes for pdb).
70 (InteractiveShell.__init__): Fix namespace handling problem in
77 (InteractiveShell.__init__): Fix namespace handling problem in
71 embedded instances. We were overwriting __main__ unconditionally,
78 embedded instances. We were overwriting __main__ unconditionally,
72 and this should only be done for 'full' (non-embedded) IPython;
79 and this should only be done for 'full' (non-embedded) IPython;
73 embedded instances must respect the caller's __main__. Thanks to
80 embedded instances must respect the caller's __main__. Thanks to
74 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
81 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
75
82
76 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
83 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
77
84
78 * setup.py: added download_url to setup(). This registers the
85 * setup.py: added download_url to setup(). This registers the
79 download address at PyPI, which is not only useful to humans
86 download address at PyPI, which is not only useful to humans
80 browsing the site, but is also picked up by setuptools (the Eggs
87 browsing the site, but is also picked up by setuptools (the Eggs
81 machinery). Thanks to Ville and R. Kern for the info/discussion
88 machinery). Thanks to Ville and R. Kern for the info/discussion
82 on this.
89 on this.
83
90
84 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
91 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
85
92
86 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
93 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
87 This brings a lot of nice functionality to the pdb mode, which now
94 This brings a lot of nice functionality to the pdb mode, which now
88 has tab-completion, syntax highlighting, and better stack handling
95 has tab-completion, syntax highlighting, and better stack handling
89 than before. Many thanks to Vivian De Smedt
96 than before. Many thanks to Vivian De Smedt
90 <vivian-AT-vdesmedt.com> for the original patches.
97 <vivian-AT-vdesmedt.com> for the original patches.
91
98
92 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
99 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
93
100
94 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
101 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
95 sequence to consistently accept the banner argument. The
102 sequence to consistently accept the banner argument. The
96 inconsistency was tripping SAGE, thanks to Gary Zablackis
103 inconsistency was tripping SAGE, thanks to Gary Zablackis
97 <gzabl-AT-yahoo.com> for the report.
104 <gzabl-AT-yahoo.com> for the report.
98
105
99 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
106 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
100
107
101 * IPython/iplib.py (InteractiveShell.post_config_initialization):
108 * IPython/iplib.py (InteractiveShell.post_config_initialization):
102 Fix bug where a naked 'alias' call in the ipythonrc file would
109 Fix bug where a naked 'alias' call in the ipythonrc file would
103 cause a crash. Bug reported by Jorgen Stenarson.
110 cause a crash. Bug reported by Jorgen Stenarson.
104
111
105 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
112 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
106
113
107 * IPython/ipmaker.py (make_IPython): cleanups which should improve
114 * IPython/ipmaker.py (make_IPython): cleanups which should improve
108 startup time.
115 startup time.
109
116
110 * IPython/iplib.py (runcode): my globals 'fix' for embedded
117 * IPython/iplib.py (runcode): my globals 'fix' for embedded
111 instances had introduced a bug with globals in normal code. Now
118 instances had introduced a bug with globals in normal code. Now
112 it's working in all cases.
119 it's working in all cases.
113
120
114 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
121 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
115 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
122 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
116 has been introduced to set the default case sensitivity of the
123 has been introduced to set the default case sensitivity of the
117 searches. Users can still select either mode at runtime on a
124 searches. Users can still select either mode at runtime on a
118 per-search basis.
125 per-search basis.
119
126
120 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
127 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
121
128
122 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
129 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
123 attributes in wildcard searches for subclasses. Modified version
130 attributes in wildcard searches for subclasses. Modified version
124 of a patch by Jorgen.
131 of a patch by Jorgen.
125
132
126 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
133 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
127
134
128 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
135 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
129 embedded instances. I added a user_global_ns attribute to the
136 embedded instances. I added a user_global_ns attribute to the
130 InteractiveShell class to handle this.
137 InteractiveShell class to handle this.
131
138
132 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
139 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
133
140
134 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
141 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
135 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
142 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
136 (reported under win32, but may happen also in other platforms).
143 (reported under win32, but may happen also in other platforms).
137 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
144 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
138
145
139 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
146 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
140
147
141 * IPython/Magic.py (magic_psearch): new support for wildcard
148 * IPython/Magic.py (magic_psearch): new support for wildcard
142 patterns. Now, typing ?a*b will list all names which begin with a
149 patterns. Now, typing ?a*b will list all names which begin with a
143 and end in b, for example. The %psearch magic has full
150 and end in b, for example. The %psearch magic has full
144 docstrings. Many thanks to Jörgen Stenarson
151 docstrings. Many thanks to Jörgen Stenarson
145 <jorgen.stenarson-AT-bostream.nu>, author of the patches
152 <jorgen.stenarson-AT-bostream.nu>, author of the patches
146 implementing this functionality.
153 implementing this functionality.
147
154
148 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
155 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
149
156
150 * Manual: fixed long-standing annoyance of double-dashes (as in
157 * Manual: fixed long-standing annoyance of double-dashes (as in
151 --prefix=~, for example) being stripped in the HTML version. This
158 --prefix=~, for example) being stripped in the HTML version. This
152 is a latex2html bug, but a workaround was provided. Many thanks
159 is a latex2html bug, but a workaround was provided. Many thanks
153 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
160 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
154 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
161 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
155 rolling. This seemingly small issue had tripped a number of users
162 rolling. This seemingly small issue had tripped a number of users
156 when first installing, so I'm glad to see it gone.
163 when first installing, so I'm glad to see it gone.
157
164
158 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
165 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
159
166
160 * IPython/Extensions/numeric_formats.py: fix missing import,
167 * IPython/Extensions/numeric_formats.py: fix missing import,
161 reported by Stephen Walton.
168 reported by Stephen Walton.
162
169
163 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
170 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
164
171
165 * IPython/demo.py: finish demo module, fully documented now.
172 * IPython/demo.py: finish demo module, fully documented now.
166
173
167 * IPython/genutils.py (file_read): simple little utility to read a
174 * IPython/genutils.py (file_read): simple little utility to read a
168 file and ensure it's closed afterwards.
175 file and ensure it's closed afterwards.
169
176
170 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
177 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
171
178
172 * IPython/demo.py (Demo.__init__): added support for individually
179 * IPython/demo.py (Demo.__init__): added support for individually
173 tagging blocks for automatic execution.
180 tagging blocks for automatic execution.
174
181
175 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
182 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
176 syntax-highlighted python sources, requested by John.
183 syntax-highlighted python sources, requested by John.
177
184
178 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
185 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
179
186
180 * IPython/demo.py (Demo.again): fix bug where again() blocks after
187 * IPython/demo.py (Demo.again): fix bug where again() blocks after
181 finishing.
188 finishing.
182
189
183 * IPython/genutils.py (shlex_split): moved from Magic to here,
190 * IPython/genutils.py (shlex_split): moved from Magic to here,
184 where all 2.2 compatibility stuff lives. I needed it for demo.py.
191 where all 2.2 compatibility stuff lives. I needed it for demo.py.
185
192
186 * IPython/demo.py (Demo.__init__): added support for silent
193 * IPython/demo.py (Demo.__init__): added support for silent
187 blocks, improved marks as regexps, docstrings written.
194 blocks, improved marks as regexps, docstrings written.
188 (Demo.__init__): better docstring, added support for sys.argv.
195 (Demo.__init__): better docstring, added support for sys.argv.
189
196
190 * IPython/genutils.py (marquee): little utility used by the demo
197 * IPython/genutils.py (marquee): little utility used by the demo
191 code, handy in general.
198 code, handy in general.
192
199
193 * IPython/demo.py (Demo.__init__): new class for interactive
200 * IPython/demo.py (Demo.__init__): new class for interactive
194 demos. Not documented yet, I just wrote it in a hurry for
201 demos. Not documented yet, I just wrote it in a hurry for
195 scipy'05. Will docstring later.
202 scipy'05. Will docstring later.
196
203
197 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
204 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
198
205
199 * IPython/Shell.py (sigint_handler): Drastic simplification which
206 * IPython/Shell.py (sigint_handler): Drastic simplification which
200 also seems to make Ctrl-C work correctly across threads! This is
207 also seems to make Ctrl-C work correctly across threads! This is
201 so simple, that I can't beleive I'd missed it before. Needs more
208 so simple, that I can't beleive I'd missed it before. Needs more
202 testing, though.
209 testing, though.
203 (KBINT): Never mind, revert changes. I'm sure I'd tried something
210 (KBINT): Never mind, revert changes. I'm sure I'd tried something
204 like this before...
211 like this before...
205
212
206 * IPython/genutils.py (get_home_dir): add protection against
213 * IPython/genutils.py (get_home_dir): add protection against
207 non-dirs in win32 registry.
214 non-dirs in win32 registry.
208
215
209 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
216 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
210 bug where dict was mutated while iterating (pysh crash).
217 bug where dict was mutated while iterating (pysh crash).
211
218
212 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
219 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
213
220
214 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
221 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
215 spurious newlines added by this routine. After a report by
222 spurious newlines added by this routine. After a report by
216 F. Mantegazza.
223 F. Mantegazza.
217
224
218 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
225 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
219
226
220 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
227 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
221 calls. These were a leftover from the GTK 1.x days, and can cause
228 calls. These were a leftover from the GTK 1.x days, and can cause
222 problems in certain cases (after a report by John Hunter).
229 problems in certain cases (after a report by John Hunter).
223
230
224 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
231 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
225 os.getcwd() fails at init time. Thanks to patch from David Remahl
232 os.getcwd() fails at init time. Thanks to patch from David Remahl
226 <chmod007-AT-mac.com>.
233 <chmod007-AT-mac.com>.
227 (InteractiveShell.__init__): prevent certain special magics from
234 (InteractiveShell.__init__): prevent certain special magics from
228 being shadowed by aliases. Closes
235 being shadowed by aliases. Closes
229 http://www.scipy.net/roundup/ipython/issue41.
236 http://www.scipy.net/roundup/ipython/issue41.
230
237
231 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
238 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
232
239
233 * IPython/iplib.py (InteractiveShell.complete): Added new
240 * IPython/iplib.py (InteractiveShell.complete): Added new
234 top-level completion method to expose the completion mechanism
241 top-level completion method to expose the completion mechanism
235 beyond readline-based environments.
242 beyond readline-based environments.
236
243
237 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
244 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
238
245
239 * tools/ipsvnc (svnversion): fix svnversion capture.
246 * tools/ipsvnc (svnversion): fix svnversion capture.
240
247
241 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
248 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
242 attribute to self, which was missing. Before, it was set by a
249 attribute to self, which was missing. Before, it was set by a
243 routine which in certain cases wasn't being called, so the
250 routine which in certain cases wasn't being called, so the
244 instance could end up missing the attribute. This caused a crash.
251 instance could end up missing the attribute. This caused a crash.
245 Closes http://www.scipy.net/roundup/ipython/issue40.
252 Closes http://www.scipy.net/roundup/ipython/issue40.
246
253
247 2005-08-16 Fernando Perez <fperez@colorado.edu>
254 2005-08-16 Fernando Perez <fperez@colorado.edu>
248
255
249 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
256 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
250 contains non-string attribute. Closes
257 contains non-string attribute. Closes
251 http://www.scipy.net/roundup/ipython/issue38.
258 http://www.scipy.net/roundup/ipython/issue38.
252
259
253 2005-08-14 Fernando Perez <fperez@colorado.edu>
260 2005-08-14 Fernando Perez <fperez@colorado.edu>
254
261
255 * tools/ipsvnc: Minor improvements, to add changeset info.
262 * tools/ipsvnc: Minor improvements, to add changeset info.
256
263
257 2005-08-12 Fernando Perez <fperez@colorado.edu>
264 2005-08-12 Fernando Perez <fperez@colorado.edu>
258
265
259 * IPython/iplib.py (runsource): remove self.code_to_run_src
266 * IPython/iplib.py (runsource): remove self.code_to_run_src
260 attribute. I realized this is nothing more than
267 attribute. I realized this is nothing more than
261 '\n'.join(self.buffer), and having the same data in two different
268 '\n'.join(self.buffer), and having the same data in two different
262 places is just asking for synchronization bugs. This may impact
269 places is just asking for synchronization bugs. This may impact
263 people who have custom exception handlers, so I need to warn
270 people who have custom exception handlers, so I need to warn
264 ipython-dev about it (F. Mantegazza may use them).
271 ipython-dev about it (F. Mantegazza may use them).
265
272
266 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
273 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
267
274
268 * IPython/genutils.py: fix 2.2 compatibility (generators)
275 * IPython/genutils.py: fix 2.2 compatibility (generators)
269
276
270 2005-07-18 Fernando Perez <fperez@colorado.edu>
277 2005-07-18 Fernando Perez <fperez@colorado.edu>
271
278
272 * IPython/genutils.py (get_home_dir): fix to help users with
279 * IPython/genutils.py (get_home_dir): fix to help users with
273 invalid $HOME under win32.
280 invalid $HOME under win32.
274
281
275 2005-07-17 Fernando Perez <fperez@colorado.edu>
282 2005-07-17 Fernando Perez <fperez@colorado.edu>
276
283
277 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
284 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
278 some old hacks and clean up a bit other routines; code should be
285 some old hacks and clean up a bit other routines; code should be
279 simpler and a bit faster.
286 simpler and a bit faster.
280
287
281 * IPython/iplib.py (interact): removed some last-resort attempts
288 * IPython/iplib.py (interact): removed some last-resort attempts
282 to survive broken stdout/stderr. That code was only making it
289 to survive broken stdout/stderr. That code was only making it
283 harder to abstract out the i/o (necessary for gui integration),
290 harder to abstract out the i/o (necessary for gui integration),
284 and the crashes it could prevent were extremely rare in practice
291 and the crashes it could prevent were extremely rare in practice
285 (besides being fully user-induced in a pretty violent manner).
292 (besides being fully user-induced in a pretty violent manner).
286
293
287 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
294 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
288 Nothing major yet, but the code is simpler to read; this should
295 Nothing major yet, but the code is simpler to read; this should
289 make it easier to do more serious modifications in the future.
296 make it easier to do more serious modifications in the future.
290
297
291 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
298 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
292 which broke in .15 (thanks to a report by Ville).
299 which broke in .15 (thanks to a report by Ville).
293
300
294 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
301 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
295 be quite correct, I know next to nothing about unicode). This
302 be quite correct, I know next to nothing about unicode). This
296 will allow unicode strings to be used in prompts, amongst other
303 will allow unicode strings to be used in prompts, amongst other
297 cases. It also will prevent ipython from crashing when unicode
304 cases. It also will prevent ipython from crashing when unicode
298 shows up unexpectedly in many places. If ascii encoding fails, we
305 shows up unexpectedly in many places. If ascii encoding fails, we
299 assume utf_8. Currently the encoding is not a user-visible
306 assume utf_8. Currently the encoding is not a user-visible
300 setting, though it could be made so if there is demand for it.
307 setting, though it could be made so if there is demand for it.
301
308
302 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
309 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
303
310
304 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
311 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
305
312
306 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
313 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
307
314
308 * IPython/genutils.py: Add 2.2 compatibility here, so all other
315 * IPython/genutils.py: Add 2.2 compatibility here, so all other
309 code can work transparently for 2.2/2.3.
316 code can work transparently for 2.2/2.3.
310
317
311 2005-07-16 Fernando Perez <fperez@colorado.edu>
318 2005-07-16 Fernando Perez <fperez@colorado.edu>
312
319
313 * IPython/ultraTB.py (ExceptionColors): Make a global variable
320 * IPython/ultraTB.py (ExceptionColors): Make a global variable
314 out of the color scheme table used for coloring exception
321 out of the color scheme table used for coloring exception
315 tracebacks. This allows user code to add new schemes at runtime.
322 tracebacks. This allows user code to add new schemes at runtime.
316 This is a minimally modified version of the patch at
323 This is a minimally modified version of the patch at
317 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
324 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
318 for the contribution.
325 for the contribution.
319
326
320 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
327 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
321 slightly modified version of the patch in
328 slightly modified version of the patch in
322 http://www.scipy.net/roundup/ipython/issue34, which also allows me
329 http://www.scipy.net/roundup/ipython/issue34, which also allows me
323 to remove the previous try/except solution (which was costlier).
330 to remove the previous try/except solution (which was costlier).
324 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
331 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
325
332
326 2005-06-08 Fernando Perez <fperez@colorado.edu>
333 2005-06-08 Fernando Perez <fperez@colorado.edu>
327
334
328 * IPython/iplib.py (write/write_err): Add methods to abstract all
335 * IPython/iplib.py (write/write_err): Add methods to abstract all
329 I/O a bit more.
336 I/O a bit more.
330
337
331 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
338 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
332 warning, reported by Aric Hagberg, fix by JD Hunter.
339 warning, reported by Aric Hagberg, fix by JD Hunter.
333
340
334 2005-06-02 *** Released version 0.6.15
341 2005-06-02 *** Released version 0.6.15
335
342
336 2005-06-01 Fernando Perez <fperez@colorado.edu>
343 2005-06-01 Fernando Perez <fperez@colorado.edu>
337
344
338 * IPython/iplib.py (MagicCompleter.file_matches): Fix
345 * IPython/iplib.py (MagicCompleter.file_matches): Fix
339 tab-completion of filenames within open-quoted strings. Note that
346 tab-completion of filenames within open-quoted strings. Note that
340 this requires that in ~/.ipython/ipythonrc, users change the
347 this requires that in ~/.ipython/ipythonrc, users change the
341 readline delimiters configuration to read:
348 readline delimiters configuration to read:
342
349
343 readline_remove_delims -/~
350 readline_remove_delims -/~
344
351
345
352
346 2005-05-31 *** Released version 0.6.14
353 2005-05-31 *** Released version 0.6.14
347
354
348 2005-05-29 Fernando Perez <fperez@colorado.edu>
355 2005-05-29 Fernando Perez <fperez@colorado.edu>
349
356
350 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
357 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
351 with files not on the filesystem. Reported by Eliyahu Sandler
358 with files not on the filesystem. Reported by Eliyahu Sandler
352 <eli@gondolin.net>
359 <eli@gondolin.net>
353
360
354 2005-05-22 Fernando Perez <fperez@colorado.edu>
361 2005-05-22 Fernando Perez <fperez@colorado.edu>
355
362
356 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
363 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
357 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
364 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
358
365
359 2005-05-19 Fernando Perez <fperez@colorado.edu>
366 2005-05-19 Fernando Perez <fperez@colorado.edu>
360
367
361 * IPython/iplib.py (safe_execfile): close a file which could be
368 * IPython/iplib.py (safe_execfile): close a file which could be
362 left open (causing problems in win32, which locks open files).
369 left open (causing problems in win32, which locks open files).
363 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
370 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
364
371
365 2005-05-18 Fernando Perez <fperez@colorado.edu>
372 2005-05-18 Fernando Perez <fperez@colorado.edu>
366
373
367 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
374 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
368 keyword arguments correctly to safe_execfile().
375 keyword arguments correctly to safe_execfile().
369
376
370 2005-05-13 Fernando Perez <fperez@colorado.edu>
377 2005-05-13 Fernando Perez <fperez@colorado.edu>
371
378
372 * ipython.1: Added info about Qt to manpage, and threads warning
379 * ipython.1: Added info about Qt to manpage, and threads warning
373 to usage page (invoked with --help).
380 to usage page (invoked with --help).
374
381
375 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
382 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
376 new matcher (it goes at the end of the priority list) to do
383 new matcher (it goes at the end of the priority list) to do
377 tab-completion on named function arguments. Submitted by George
384 tab-completion on named function arguments. Submitted by George
378 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
385 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
379 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
386 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
380 for more details.
387 for more details.
381
388
382 * IPython/Magic.py (magic_run): Added new -e flag to ignore
389 * IPython/Magic.py (magic_run): Added new -e flag to ignore
383 SystemExit exceptions in the script being run. Thanks to a report
390 SystemExit exceptions in the script being run. Thanks to a report
384 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
391 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
385 producing very annoying behavior when running unit tests.
392 producing very annoying behavior when running unit tests.
386
393
387 2005-05-12 Fernando Perez <fperez@colorado.edu>
394 2005-05-12 Fernando Perez <fperez@colorado.edu>
388
395
389 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
396 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
390 which I'd broken (again) due to a changed regexp. In the process,
397 which I'd broken (again) due to a changed regexp. In the process,
391 added ';' as an escape to auto-quote the whole line without
398 added ';' as an escape to auto-quote the whole line without
392 splitting its arguments. Thanks to a report by Jerry McRae
399 splitting its arguments. Thanks to a report by Jerry McRae
393 <qrs0xyc02-AT-sneakemail.com>.
400 <qrs0xyc02-AT-sneakemail.com>.
394
401
395 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
402 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
396 possible crashes caused by a TokenError. Reported by Ed Schofield
403 possible crashes caused by a TokenError. Reported by Ed Schofield
397 <schofield-AT-ftw.at>.
404 <schofield-AT-ftw.at>.
398
405
399 2005-05-06 Fernando Perez <fperez@colorado.edu>
406 2005-05-06 Fernando Perez <fperez@colorado.edu>
400
407
401 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
408 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
402
409
403 2005-04-29 Fernando Perez <fperez@colorado.edu>
410 2005-04-29 Fernando Perez <fperez@colorado.edu>
404
411
405 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
412 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
406 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
413 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
407 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
414 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
408 which provides support for Qt interactive usage (similar to the
415 which provides support for Qt interactive usage (similar to the
409 existing one for WX and GTK). This had been often requested.
416 existing one for WX and GTK). This had been often requested.
410
417
411 2005-04-14 *** Released version 0.6.13
418 2005-04-14 *** Released version 0.6.13
412
419
413 2005-04-08 Fernando Perez <fperez@colorado.edu>
420 2005-04-08 Fernando Perez <fperez@colorado.edu>
414
421
415 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
422 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
416 from _ofind, which gets called on almost every input line. Now,
423 from _ofind, which gets called on almost every input line. Now,
417 we only try to get docstrings if they are actually going to be
424 we only try to get docstrings if they are actually going to be
418 used (the overhead of fetching unnecessary docstrings can be
425 used (the overhead of fetching unnecessary docstrings can be
419 noticeable for certain objects, such as Pyro proxies).
426 noticeable for certain objects, such as Pyro proxies).
420
427
421 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
428 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
422 for completers. For some reason I had been passing them the state
429 for completers. For some reason I had been passing them the state
423 variable, which completers never actually need, and was in
430 variable, which completers never actually need, and was in
424 conflict with the rlcompleter API. Custom completers ONLY need to
431 conflict with the rlcompleter API. Custom completers ONLY need to
425 take the text parameter.
432 take the text parameter.
426
433
427 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
434 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
428 work correctly in pysh. I've also moved all the logic which used
435 work correctly in pysh. I've also moved all the logic which used
429 to be in pysh.py here, which will prevent problems with future
436 to be in pysh.py here, which will prevent problems with future
430 upgrades. However, this time I must warn users to update their
437 upgrades. However, this time I must warn users to update their
431 pysh profile to include the line
438 pysh profile to include the line
432
439
433 import_all IPython.Extensions.InterpreterExec
440 import_all IPython.Extensions.InterpreterExec
434
441
435 because otherwise things won't work for them. They MUST also
442 because otherwise things won't work for them. They MUST also
436 delete pysh.py and the line
443 delete pysh.py and the line
437
444
438 execfile pysh.py
445 execfile pysh.py
439
446
440 from their ipythonrc-pysh.
447 from their ipythonrc-pysh.
441
448
442 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
449 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
443 robust in the face of objects whose dir() returns non-strings
450 robust in the face of objects whose dir() returns non-strings
444 (which it shouldn't, but some broken libs like ITK do). Thanks to
451 (which it shouldn't, but some broken libs like ITK do). Thanks to
445 a patch by John Hunter (implemented differently, though). Also
452 a patch by John Hunter (implemented differently, though). Also
446 minor improvements by using .extend instead of + on lists.
453 minor improvements by using .extend instead of + on lists.
447
454
448 * pysh.py:
455 * pysh.py:
449
456
450 2005-04-06 Fernando Perez <fperez@colorado.edu>
457 2005-04-06 Fernando Perez <fperez@colorado.edu>
451
458
452 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
459 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
453 by default, so that all users benefit from it. Those who don't
460 by default, so that all users benefit from it. Those who don't
454 want it can still turn it off.
461 want it can still turn it off.
455
462
456 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
463 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
457 config file, I'd forgotten about this, so users were getting it
464 config file, I'd forgotten about this, so users were getting it
458 off by default.
465 off by default.
459
466
460 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
467 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
461 consistency. Now magics can be called in multiline statements,
468 consistency. Now magics can be called in multiline statements,
462 and python variables can be expanded in magic calls via $var.
469 and python variables can be expanded in magic calls via $var.
463 This makes the magic system behave just like aliases or !system
470 This makes the magic system behave just like aliases or !system
464 calls.
471 calls.
465
472
466 2005-03-28 Fernando Perez <fperez@colorado.edu>
473 2005-03-28 Fernando Perez <fperez@colorado.edu>
467
474
468 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
475 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
469 expensive string additions for building command. Add support for
476 expensive string additions for building command. Add support for
470 trailing ';' when autocall is used.
477 trailing ';' when autocall is used.
471
478
472 2005-03-26 Fernando Perez <fperez@colorado.edu>
479 2005-03-26 Fernando Perez <fperez@colorado.edu>
473
480
474 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
481 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
475 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
482 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
476 ipython.el robust against prompts with any number of spaces
483 ipython.el robust against prompts with any number of spaces
477 (including 0) after the ':' character.
484 (including 0) after the ':' character.
478
485
479 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
486 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
480 continuation prompt, which misled users to think the line was
487 continuation prompt, which misled users to think the line was
481 already indented. Closes debian Bug#300847, reported to me by
488 already indented. Closes debian Bug#300847, reported to me by
482 Norbert Tretkowski <tretkowski-AT-inittab.de>.
489 Norbert Tretkowski <tretkowski-AT-inittab.de>.
483
490
484 2005-03-23 Fernando Perez <fperez@colorado.edu>
491 2005-03-23 Fernando Perez <fperez@colorado.edu>
485
492
486 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
493 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
487 properly aligned if they have embedded newlines.
494 properly aligned if they have embedded newlines.
488
495
489 * IPython/iplib.py (runlines): Add a public method to expose
496 * IPython/iplib.py (runlines): Add a public method to expose
490 IPython's code execution machinery, so that users can run strings
497 IPython's code execution machinery, so that users can run strings
491 as if they had been typed at the prompt interactively.
498 as if they had been typed at the prompt interactively.
492 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
499 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
493 methods which can call the system shell, but with python variable
500 methods which can call the system shell, but with python variable
494 expansion. The three such methods are: __IPYTHON__.system,
501 expansion. The three such methods are: __IPYTHON__.system,
495 .getoutput and .getoutputerror. These need to be documented in a
502 .getoutput and .getoutputerror. These need to be documented in a
496 'public API' section (to be written) of the manual.
503 'public API' section (to be written) of the manual.
497
504
498 2005-03-20 Fernando Perez <fperez@colorado.edu>
505 2005-03-20 Fernando Perez <fperez@colorado.edu>
499
506
500 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
507 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
501 for custom exception handling. This is quite powerful, and it
508 for custom exception handling. This is quite powerful, and it
502 allows for user-installable exception handlers which can trap
509 allows for user-installable exception handlers which can trap
503 custom exceptions at runtime and treat them separately from
510 custom exceptions at runtime and treat them separately from
504 IPython's default mechanisms. At the request of Frédéric
511 IPython's default mechanisms. At the request of Frédéric
505 Mantegazza <mantegazza-AT-ill.fr>.
512 Mantegazza <mantegazza-AT-ill.fr>.
506 (InteractiveShell.set_custom_completer): public API function to
513 (InteractiveShell.set_custom_completer): public API function to
507 add new completers at runtime.
514 add new completers at runtime.
508
515
509 2005-03-19 Fernando Perez <fperez@colorado.edu>
516 2005-03-19 Fernando Perez <fperez@colorado.edu>
510
517
511 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
518 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
512 allow objects which provide their docstrings via non-standard
519 allow objects which provide their docstrings via non-standard
513 mechanisms (like Pyro proxies) to still be inspected by ipython's
520 mechanisms (like Pyro proxies) to still be inspected by ipython's
514 ? system.
521 ? system.
515
522
516 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
523 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
517 automatic capture system. I tried quite hard to make it work
524 automatic capture system. I tried quite hard to make it work
518 reliably, and simply failed. I tried many combinations with the
525 reliably, and simply failed. I tried many combinations with the
519 subprocess module, but eventually nothing worked in all needed
526 subprocess module, but eventually nothing worked in all needed
520 cases (not blocking stdin for the child, duplicating stdout
527 cases (not blocking stdin for the child, duplicating stdout
521 without blocking, etc). The new %sc/%sx still do capture to these
528 without blocking, etc). The new %sc/%sx still do capture to these
522 magical list/string objects which make shell use much more
529 magical list/string objects which make shell use much more
523 conveninent, so not all is lost.
530 conveninent, so not all is lost.
524
531
525 XXX - FIX MANUAL for the change above!
532 XXX - FIX MANUAL for the change above!
526
533
527 (runsource): I copied code.py's runsource() into ipython to modify
534 (runsource): I copied code.py's runsource() into ipython to modify
528 it a bit. Now the code object and source to be executed are
535 it a bit. Now the code object and source to be executed are
529 stored in ipython. This makes this info accessible to third-party
536 stored in ipython. This makes this info accessible to third-party
530 tools, like custom exception handlers. After a request by Frédéric
537 tools, like custom exception handlers. After a request by Frédéric
531 Mantegazza <mantegazza-AT-ill.fr>.
538 Mantegazza <mantegazza-AT-ill.fr>.
532
539
533 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
540 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
534 history-search via readline (like C-p/C-n). I'd wanted this for a
541 history-search via readline (like C-p/C-n). I'd wanted this for a
535 long time, but only recently found out how to do it. For users
542 long time, but only recently found out how to do it. For users
536 who already have their ipythonrc files made and want this, just
543 who already have their ipythonrc files made and want this, just
537 add:
544 add:
538
545
539 readline_parse_and_bind "\e[A": history-search-backward
546 readline_parse_and_bind "\e[A": history-search-backward
540 readline_parse_and_bind "\e[B": history-search-forward
547 readline_parse_and_bind "\e[B": history-search-forward
541
548
542 2005-03-18 Fernando Perez <fperez@colorado.edu>
549 2005-03-18 Fernando Perez <fperez@colorado.edu>
543
550
544 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
551 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
545 LSString and SList classes which allow transparent conversions
552 LSString and SList classes which allow transparent conversions
546 between list mode and whitespace-separated string.
553 between list mode and whitespace-separated string.
547 (magic_r): Fix recursion problem in %r.
554 (magic_r): Fix recursion problem in %r.
548
555
549 * IPython/genutils.py (LSString): New class to be used for
556 * IPython/genutils.py (LSString): New class to be used for
550 automatic storage of the results of all alias/system calls in _o
557 automatic storage of the results of all alias/system calls in _o
551 and _e (stdout/err). These provide a .l/.list attribute which
558 and _e (stdout/err). These provide a .l/.list attribute which
552 does automatic splitting on newlines. This means that for most
559 does automatic splitting on newlines. This means that for most
553 uses, you'll never need to do capturing of output with %sc/%sx
560 uses, you'll never need to do capturing of output with %sc/%sx
554 anymore, since ipython keeps this always done for you. Note that
561 anymore, since ipython keeps this always done for you. Note that
555 only the LAST results are stored, the _o/e variables are
562 only the LAST results are stored, the _o/e variables are
556 overwritten on each call. If you need to save their contents
563 overwritten on each call. If you need to save their contents
557 further, simply bind them to any other name.
564 further, simply bind them to any other name.
558
565
559 2005-03-17 Fernando Perez <fperez@colorado.edu>
566 2005-03-17 Fernando Perez <fperez@colorado.edu>
560
567
561 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
568 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
562 prompt namespace handling.
569 prompt namespace handling.
563
570
564 2005-03-16 Fernando Perez <fperez@colorado.edu>
571 2005-03-16 Fernando Perez <fperez@colorado.edu>
565
572
566 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
573 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
567 classic prompts to be '>>> ' (final space was missing, and it
574 classic prompts to be '>>> ' (final space was missing, and it
568 trips the emacs python mode).
575 trips the emacs python mode).
569 (BasePrompt.__str__): Added safe support for dynamic prompt
576 (BasePrompt.__str__): Added safe support for dynamic prompt
570 strings. Now you can set your prompt string to be '$x', and the
577 strings. Now you can set your prompt string to be '$x', and the
571 value of x will be printed from your interactive namespace. The
578 value of x will be printed from your interactive namespace. The
572 interpolation syntax includes the full Itpl support, so
579 interpolation syntax includes the full Itpl support, so
573 ${foo()+x+bar()} is a valid prompt string now, and the function
580 ${foo()+x+bar()} is a valid prompt string now, and the function
574 calls will be made at runtime.
581 calls will be made at runtime.
575
582
576 2005-03-15 Fernando Perez <fperez@colorado.edu>
583 2005-03-15 Fernando Perez <fperez@colorado.edu>
577
584
578 * IPython/Magic.py (magic_history): renamed %hist to %history, to
585 * IPython/Magic.py (magic_history): renamed %hist to %history, to
579 avoid name clashes in pylab. %hist still works, it just forwards
586 avoid name clashes in pylab. %hist still works, it just forwards
580 the call to %history.
587 the call to %history.
581
588
582 2005-03-02 *** Released version 0.6.12
589 2005-03-02 *** Released version 0.6.12
583
590
584 2005-03-02 Fernando Perez <fperez@colorado.edu>
591 2005-03-02 Fernando Perez <fperez@colorado.edu>
585
592
586 * IPython/iplib.py (handle_magic): log magic calls properly as
593 * IPython/iplib.py (handle_magic): log magic calls properly as
587 ipmagic() function calls.
594 ipmagic() function calls.
588
595
589 * IPython/Magic.py (magic_time): Improved %time to support
596 * IPython/Magic.py (magic_time): Improved %time to support
590 statements and provide wall-clock as well as CPU time.
597 statements and provide wall-clock as well as CPU time.
591
598
592 2005-02-27 Fernando Perez <fperez@colorado.edu>
599 2005-02-27 Fernando Perez <fperez@colorado.edu>
593
600
594 * IPython/hooks.py: New hooks module, to expose user-modifiable
601 * IPython/hooks.py: New hooks module, to expose user-modifiable
595 IPython functionality in a clean manner. For now only the editor
602 IPython functionality in a clean manner. For now only the editor
596 hook is actually written, and other thigns which I intend to turn
603 hook is actually written, and other thigns which I intend to turn
597 into proper hooks aren't yet there. The display and prefilter
604 into proper hooks aren't yet there. The display and prefilter
598 stuff, for example, should be hooks. But at least now the
605 stuff, for example, should be hooks. But at least now the
599 framework is in place, and the rest can be moved here with more
606 framework is in place, and the rest can be moved here with more
600 time later. IPython had had a .hooks variable for a long time for
607 time later. IPython had had a .hooks variable for a long time for
601 this purpose, but I'd never actually used it for anything.
608 this purpose, but I'd never actually used it for anything.
602
609
603 2005-02-26 Fernando Perez <fperez@colorado.edu>
610 2005-02-26 Fernando Perez <fperez@colorado.edu>
604
611
605 * IPython/ipmaker.py (make_IPython): make the default ipython
612 * IPython/ipmaker.py (make_IPython): make the default ipython
606 directory be called _ipython under win32, to follow more the
613 directory be called _ipython under win32, to follow more the
607 naming peculiarities of that platform (where buggy software like
614 naming peculiarities of that platform (where buggy software like
608 Visual Sourcesafe breaks with .named directories). Reported by
615 Visual Sourcesafe breaks with .named directories). Reported by
609 Ville Vainio.
616 Ville Vainio.
610
617
611 2005-02-23 Fernando Perez <fperez@colorado.edu>
618 2005-02-23 Fernando Perez <fperez@colorado.edu>
612
619
613 * IPython/iplib.py (InteractiveShell.__init__): removed a few
620 * IPython/iplib.py (InteractiveShell.__init__): removed a few
614 auto_aliases for win32 which were causing problems. Users can
621 auto_aliases for win32 which were causing problems. Users can
615 define the ones they personally like.
622 define the ones they personally like.
616
623
617 2005-02-21 Fernando Perez <fperez@colorado.edu>
624 2005-02-21 Fernando Perez <fperez@colorado.edu>
618
625
619 * IPython/Magic.py (magic_time): new magic to time execution of
626 * IPython/Magic.py (magic_time): new magic to time execution of
620 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
627 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
621
628
622 2005-02-19 Fernando Perez <fperez@colorado.edu>
629 2005-02-19 Fernando Perez <fperez@colorado.edu>
623
630
624 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
631 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
625 into keys (for prompts, for example).
632 into keys (for prompts, for example).
626
633
627 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
634 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
628 prompts in case users want them. This introduces a small behavior
635 prompts in case users want them. This introduces a small behavior
629 change: ipython does not automatically add a space to all prompts
636 change: ipython does not automatically add a space to all prompts
630 anymore. To get the old prompts with a space, users should add it
637 anymore. To get the old prompts with a space, users should add it
631 manually to their ipythonrc file, so for example prompt_in1 should
638 manually to their ipythonrc file, so for example prompt_in1 should
632 now read 'In [\#]: ' instead of 'In [\#]:'.
639 now read 'In [\#]: ' instead of 'In [\#]:'.
633 (BasePrompt.__init__): New option prompts_pad_left (only in rc
640 (BasePrompt.__init__): New option prompts_pad_left (only in rc
634 file) to control left-padding of secondary prompts.
641 file) to control left-padding of secondary prompts.
635
642
636 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
643 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
637 the profiler can't be imported. Fix for Debian, which removed
644 the profiler can't be imported. Fix for Debian, which removed
638 profile.py because of License issues. I applied a slightly
645 profile.py because of License issues. I applied a slightly
639 modified version of the original Debian patch at
646 modified version of the original Debian patch at
640 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
647 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
641
648
642 2005-02-17 Fernando Perez <fperez@colorado.edu>
649 2005-02-17 Fernando Perez <fperez@colorado.edu>
643
650
644 * IPython/genutils.py (native_line_ends): Fix bug which would
651 * IPython/genutils.py (native_line_ends): Fix bug which would
645 cause improper line-ends under win32 b/c I was not opening files
652 cause improper line-ends under win32 b/c I was not opening files
646 in binary mode. Bug report and fix thanks to Ville.
653 in binary mode. Bug report and fix thanks to Ville.
647
654
648 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
655 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
649 trying to catch spurious foo[1] autocalls. My fix actually broke
656 trying to catch spurious foo[1] autocalls. My fix actually broke
650 ',/' autoquote/call with explicit escape (bad regexp).
657 ',/' autoquote/call with explicit escape (bad regexp).
651
658
652 2005-02-15 *** Released version 0.6.11
659 2005-02-15 *** Released version 0.6.11
653
660
654 2005-02-14 Fernando Perez <fperez@colorado.edu>
661 2005-02-14 Fernando Perez <fperez@colorado.edu>
655
662
656 * IPython/background_jobs.py: New background job management
663 * IPython/background_jobs.py: New background job management
657 subsystem. This is implemented via a new set of classes, and
664 subsystem. This is implemented via a new set of classes, and
658 IPython now provides a builtin 'jobs' object for background job
665 IPython now provides a builtin 'jobs' object for background job
659 execution. A convenience %bg magic serves as a lightweight
666 execution. A convenience %bg magic serves as a lightweight
660 frontend for starting the more common type of calls. This was
667 frontend for starting the more common type of calls. This was
661 inspired by discussions with B. Granger and the BackgroundCommand
668 inspired by discussions with B. Granger and the BackgroundCommand
662 class described in the book Python Scripting for Computational
669 class described in the book Python Scripting for Computational
663 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
670 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
664 (although ultimately no code from this text was used, as IPython's
671 (although ultimately no code from this text was used, as IPython's
665 system is a separate implementation).
672 system is a separate implementation).
666
673
667 * IPython/iplib.py (MagicCompleter.python_matches): add new option
674 * IPython/iplib.py (MagicCompleter.python_matches): add new option
668 to control the completion of single/double underscore names
675 to control the completion of single/double underscore names
669 separately. As documented in the example ipytonrc file, the
676 separately. As documented in the example ipytonrc file, the
670 readline_omit__names variable can now be set to 2, to omit even
677 readline_omit__names variable can now be set to 2, to omit even
671 single underscore names. Thanks to a patch by Brian Wong
678 single underscore names. Thanks to a patch by Brian Wong
672 <BrianWong-AT-AirgoNetworks.Com>.
679 <BrianWong-AT-AirgoNetworks.Com>.
673 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
680 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
674 be autocalled as foo([1]) if foo were callable. A problem for
681 be autocalled as foo([1]) if foo were callable. A problem for
675 things which are both callable and implement __getitem__.
682 things which are both callable and implement __getitem__.
676 (init_readline): Fix autoindentation for win32. Thanks to a patch
683 (init_readline): Fix autoindentation for win32. Thanks to a patch
677 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
684 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
678
685
679 2005-02-12 Fernando Perez <fperez@colorado.edu>
686 2005-02-12 Fernando Perez <fperez@colorado.edu>
680
687
681 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
688 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
682 which I had written long ago to sort out user error messages which
689 which I had written long ago to sort out user error messages which
683 may occur during startup. This seemed like a good idea initially,
690 may occur during startup. This seemed like a good idea initially,
684 but it has proven a disaster in retrospect. I don't want to
691 but it has proven a disaster in retrospect. I don't want to
685 change much code for now, so my fix is to set the internal 'debug'
692 change much code for now, so my fix is to set the internal 'debug'
686 flag to true everywhere, whose only job was precisely to control
693 flag to true everywhere, whose only job was precisely to control
687 this subsystem. This closes issue 28 (as well as avoiding all
694 this subsystem. This closes issue 28 (as well as avoiding all
688 sorts of strange hangups which occur from time to time).
695 sorts of strange hangups which occur from time to time).
689
696
690 2005-02-07 Fernando Perez <fperez@colorado.edu>
697 2005-02-07 Fernando Perez <fperez@colorado.edu>
691
698
692 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
699 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
693 previous call produced a syntax error.
700 previous call produced a syntax error.
694
701
695 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
702 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
696 classes without constructor.
703 classes without constructor.
697
704
698 2005-02-06 Fernando Perez <fperez@colorado.edu>
705 2005-02-06 Fernando Perez <fperez@colorado.edu>
699
706
700 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
707 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
701 completions with the results of each matcher, so we return results
708 completions with the results of each matcher, so we return results
702 to the user from all namespaces. This breaks with ipython
709 to the user from all namespaces. This breaks with ipython
703 tradition, but I think it's a nicer behavior. Now you get all
710 tradition, but I think it's a nicer behavior. Now you get all
704 possible completions listed, from all possible namespaces (python,
711 possible completions listed, from all possible namespaces (python,
705 filesystem, magics...) After a request by John Hunter
712 filesystem, magics...) After a request by John Hunter
706 <jdhunter-AT-nitace.bsd.uchicago.edu>.
713 <jdhunter-AT-nitace.bsd.uchicago.edu>.
707
714
708 2005-02-05 Fernando Perez <fperez@colorado.edu>
715 2005-02-05 Fernando Perez <fperez@colorado.edu>
709
716
710 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
717 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
711 the call had quote characters in it (the quotes were stripped).
718 the call had quote characters in it (the quotes were stripped).
712
719
713 2005-01-31 Fernando Perez <fperez@colorado.edu>
720 2005-01-31 Fernando Perez <fperez@colorado.edu>
714
721
715 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
722 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
716 Itpl.itpl() to make the code more robust against psyco
723 Itpl.itpl() to make the code more robust against psyco
717 optimizations.
724 optimizations.
718
725
719 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
726 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
720 of causing an exception. Quicker, cleaner.
727 of causing an exception. Quicker, cleaner.
721
728
722 2005-01-28 Fernando Perez <fperez@colorado.edu>
729 2005-01-28 Fernando Perez <fperez@colorado.edu>
723
730
724 * scripts/ipython_win_post_install.py (install): hardcode
731 * scripts/ipython_win_post_install.py (install): hardcode
725 sys.prefix+'python.exe' as the executable path. It turns out that
732 sys.prefix+'python.exe' as the executable path. It turns out that
726 during the post-installation run, sys.executable resolves to the
733 during the post-installation run, sys.executable resolves to the
727 name of the binary installer! I should report this as a distutils
734 name of the binary installer! I should report this as a distutils
728 bug, I think. I updated the .10 release with this tiny fix, to
735 bug, I think. I updated the .10 release with this tiny fix, to
729 avoid annoying the lists further.
736 avoid annoying the lists further.
730
737
731 2005-01-27 *** Released version 0.6.10
738 2005-01-27 *** Released version 0.6.10
732
739
733 2005-01-27 Fernando Perez <fperez@colorado.edu>
740 2005-01-27 Fernando Perez <fperez@colorado.edu>
734
741
735 * IPython/numutils.py (norm): Added 'inf' as optional name for
742 * IPython/numutils.py (norm): Added 'inf' as optional name for
736 L-infinity norm, included references to mathworld.com for vector
743 L-infinity norm, included references to mathworld.com for vector
737 norm definitions.
744 norm definitions.
738 (amin/amax): added amin/amax for array min/max. Similar to what
745 (amin/amax): added amin/amax for array min/max. Similar to what
739 pylab ships with after the recent reorganization of names.
746 pylab ships with after the recent reorganization of names.
740 (spike/spike_odd): removed deprecated spike/spike_odd functions.
747 (spike/spike_odd): removed deprecated spike/spike_odd functions.
741
748
742 * ipython.el: committed Alex's recent fixes and improvements.
749 * ipython.el: committed Alex's recent fixes and improvements.
743 Tested with python-mode from CVS, and it looks excellent. Since
750 Tested with python-mode from CVS, and it looks excellent. Since
744 python-mode hasn't released anything in a while, I'm temporarily
751 python-mode hasn't released anything in a while, I'm temporarily
745 putting a copy of today's CVS (v 4.70) of python-mode in:
752 putting a copy of today's CVS (v 4.70) of python-mode in:
746 http://ipython.scipy.org/tmp/python-mode.el
753 http://ipython.scipy.org/tmp/python-mode.el
747
754
748 * scripts/ipython_win_post_install.py (install): Win32 fix to use
755 * scripts/ipython_win_post_install.py (install): Win32 fix to use
749 sys.executable for the executable name, instead of assuming it's
756 sys.executable for the executable name, instead of assuming it's
750 called 'python.exe' (the post-installer would have produced broken
757 called 'python.exe' (the post-installer would have produced broken
751 setups on systems with a differently named python binary).
758 setups on systems with a differently named python binary).
752
759
753 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
760 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
754 references to os.linesep, to make the code more
761 references to os.linesep, to make the code more
755 platform-independent. This is also part of the win32 coloring
762 platform-independent. This is also part of the win32 coloring
756 fixes.
763 fixes.
757
764
758 * IPython/genutils.py (page_dumb): Remove attempts to chop long
765 * IPython/genutils.py (page_dumb): Remove attempts to chop long
759 lines, which actually cause coloring bugs because the length of
766 lines, which actually cause coloring bugs because the length of
760 the line is very difficult to correctly compute with embedded
767 the line is very difficult to correctly compute with embedded
761 escapes. This was the source of all the coloring problems under
768 escapes. This was the source of all the coloring problems under
762 Win32. I think that _finally_, Win32 users have a properly
769 Win32. I think that _finally_, Win32 users have a properly
763 working ipython in all respects. This would never have happened
770 working ipython in all respects. This would never have happened
764 if not for Gary Bishop and Viktor Ransmayr's great help and work.
771 if not for Gary Bishop and Viktor Ransmayr's great help and work.
765
772
766 2005-01-26 *** Released version 0.6.9
773 2005-01-26 *** Released version 0.6.9
767
774
768 2005-01-25 Fernando Perez <fperez@colorado.edu>
775 2005-01-25 Fernando Perez <fperez@colorado.edu>
769
776
770 * setup.py: finally, we have a true Windows installer, thanks to
777 * setup.py: finally, we have a true Windows installer, thanks to
771 the excellent work of Viktor Ransmayr
778 the excellent work of Viktor Ransmayr
772 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
779 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
773 Windows users. The setup routine is quite a bit cleaner thanks to
780 Windows users. The setup routine is quite a bit cleaner thanks to
774 this, and the post-install script uses the proper functions to
781 this, and the post-install script uses the proper functions to
775 allow a clean de-installation using the standard Windows Control
782 allow a clean de-installation using the standard Windows Control
776 Panel.
783 Panel.
777
784
778 * IPython/genutils.py (get_home_dir): changed to use the $HOME
785 * IPython/genutils.py (get_home_dir): changed to use the $HOME
779 environment variable under all OSes (including win32) if
786 environment variable under all OSes (including win32) if
780 available. This will give consistency to win32 users who have set
787 available. This will give consistency to win32 users who have set
781 this variable for any reason. If os.environ['HOME'] fails, the
788 this variable for any reason. If os.environ['HOME'] fails, the
782 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
789 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
783
790
784 2005-01-24 Fernando Perez <fperez@colorado.edu>
791 2005-01-24 Fernando Perez <fperez@colorado.edu>
785
792
786 * IPython/numutils.py (empty_like): add empty_like(), similar to
793 * IPython/numutils.py (empty_like): add empty_like(), similar to
787 zeros_like() but taking advantage of the new empty() Numeric routine.
794 zeros_like() but taking advantage of the new empty() Numeric routine.
788
795
789 2005-01-23 *** Released version 0.6.8
796 2005-01-23 *** Released version 0.6.8
790
797
791 2005-01-22 Fernando Perez <fperez@colorado.edu>
798 2005-01-22 Fernando Perez <fperez@colorado.edu>
792
799
793 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
800 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
794 automatic show() calls. After discussing things with JDH, it
801 automatic show() calls. After discussing things with JDH, it
795 turns out there are too many corner cases where this can go wrong.
802 turns out there are too many corner cases where this can go wrong.
796 It's best not to try to be 'too smart', and simply have ipython
803 It's best not to try to be 'too smart', and simply have ipython
797 reproduce as much as possible the default behavior of a normal
804 reproduce as much as possible the default behavior of a normal
798 python shell.
805 python shell.
799
806
800 * IPython/iplib.py (InteractiveShell.__init__): Modified the
807 * IPython/iplib.py (InteractiveShell.__init__): Modified the
801 line-splitting regexp and _prefilter() to avoid calling getattr()
808 line-splitting regexp and _prefilter() to avoid calling getattr()
802 on assignments. This closes
809 on assignments. This closes
803 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
810 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
804 readline uses getattr(), so a simple <TAB> keypress is still
811 readline uses getattr(), so a simple <TAB> keypress is still
805 enough to trigger getattr() calls on an object.
812 enough to trigger getattr() calls on an object.
806
813
807 2005-01-21 Fernando Perez <fperez@colorado.edu>
814 2005-01-21 Fernando Perez <fperez@colorado.edu>
808
815
809 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
816 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
810 docstring under pylab so it doesn't mask the original.
817 docstring under pylab so it doesn't mask the original.
811
818
812 2005-01-21 *** Released version 0.6.7
819 2005-01-21 *** Released version 0.6.7
813
820
814 2005-01-21 Fernando Perez <fperez@colorado.edu>
821 2005-01-21 Fernando Perez <fperez@colorado.edu>
815
822
816 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
823 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
817 signal handling for win32 users in multithreaded mode.
824 signal handling for win32 users in multithreaded mode.
818
825
819 2005-01-17 Fernando Perez <fperez@colorado.edu>
826 2005-01-17 Fernando Perez <fperez@colorado.edu>
820
827
821 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
828 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
822 instances with no __init__. After a crash report by Norbert Nemec
829 instances with no __init__. After a crash report by Norbert Nemec
823 <Norbert-AT-nemec-online.de>.
830 <Norbert-AT-nemec-online.de>.
824
831
825 2005-01-14 Fernando Perez <fperez@colorado.edu>
832 2005-01-14 Fernando Perez <fperez@colorado.edu>
826
833
827 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
834 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
828 names for verbose exceptions, when multiple dotted names and the
835 names for verbose exceptions, when multiple dotted names and the
829 'parent' object were present on the same line.
836 'parent' object were present on the same line.
830
837
831 2005-01-11 Fernando Perez <fperez@colorado.edu>
838 2005-01-11 Fernando Perez <fperez@colorado.edu>
832
839
833 * IPython/genutils.py (flag_calls): new utility to trap and flag
840 * IPython/genutils.py (flag_calls): new utility to trap and flag
834 calls in functions. I need it to clean up matplotlib support.
841 calls in functions. I need it to clean up matplotlib support.
835 Also removed some deprecated code in genutils.
842 Also removed some deprecated code in genutils.
836
843
837 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
844 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
838 that matplotlib scripts called with %run, which don't call show()
845 that matplotlib scripts called with %run, which don't call show()
839 themselves, still have their plotting windows open.
846 themselves, still have their plotting windows open.
840
847
841 2005-01-05 Fernando Perez <fperez@colorado.edu>
848 2005-01-05 Fernando Perez <fperez@colorado.edu>
842
849
843 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
850 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
844 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
851 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
845
852
846 2004-12-19 Fernando Perez <fperez@colorado.edu>
853 2004-12-19 Fernando Perez <fperez@colorado.edu>
847
854
848 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
855 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
849 parent_runcode, which was an eyesore. The same result can be
856 parent_runcode, which was an eyesore. The same result can be
850 obtained with Python's regular superclass mechanisms.
857 obtained with Python's regular superclass mechanisms.
851
858
852 2004-12-17 Fernando Perez <fperez@colorado.edu>
859 2004-12-17 Fernando Perez <fperez@colorado.edu>
853
860
854 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
861 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
855 reported by Prabhu.
862 reported by Prabhu.
856 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
863 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
857 sys.stderr) instead of explicitly calling sys.stderr. This helps
864 sys.stderr) instead of explicitly calling sys.stderr. This helps
858 maintain our I/O abstractions clean, for future GUI embeddings.
865 maintain our I/O abstractions clean, for future GUI embeddings.
859
866
860 * IPython/genutils.py (info): added new utility for sys.stderr
867 * IPython/genutils.py (info): added new utility for sys.stderr
861 unified info message handling (thin wrapper around warn()).
868 unified info message handling (thin wrapper around warn()).
862
869
863 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
870 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
864 composite (dotted) names on verbose exceptions.
871 composite (dotted) names on verbose exceptions.
865 (VerboseTB.nullrepr): harden against another kind of errors which
872 (VerboseTB.nullrepr): harden against another kind of errors which
866 Python's inspect module can trigger, and which were crashing
873 Python's inspect module can trigger, and which were crashing
867 IPython. Thanks to a report by Marco Lombardi
874 IPython. Thanks to a report by Marco Lombardi
868 <mlombard-AT-ma010192.hq.eso.org>.
875 <mlombard-AT-ma010192.hq.eso.org>.
869
876
870 2004-12-13 *** Released version 0.6.6
877 2004-12-13 *** Released version 0.6.6
871
878
872 2004-12-12 Fernando Perez <fperez@colorado.edu>
879 2004-12-12 Fernando Perez <fperez@colorado.edu>
873
880
874 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
881 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
875 generated by pygtk upon initialization if it was built without
882 generated by pygtk upon initialization if it was built without
876 threads (for matplotlib users). After a crash reported by
883 threads (for matplotlib users). After a crash reported by
877 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
884 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
878
885
879 * IPython/ipmaker.py (make_IPython): fix small bug in the
886 * IPython/ipmaker.py (make_IPython): fix small bug in the
880 import_some parameter for multiple imports.
887 import_some parameter for multiple imports.
881
888
882 * IPython/iplib.py (ipmagic): simplified the interface of
889 * IPython/iplib.py (ipmagic): simplified the interface of
883 ipmagic() to take a single string argument, just as it would be
890 ipmagic() to take a single string argument, just as it would be
884 typed at the IPython cmd line.
891 typed at the IPython cmd line.
885 (ipalias): Added new ipalias() with an interface identical to
892 (ipalias): Added new ipalias() with an interface identical to
886 ipmagic(). This completes exposing a pure python interface to the
893 ipmagic(). This completes exposing a pure python interface to the
887 alias and magic system, which can be used in loops or more complex
894 alias and magic system, which can be used in loops or more complex
888 code where IPython's automatic line mangling is not active.
895 code where IPython's automatic line mangling is not active.
889
896
890 * IPython/genutils.py (timing): changed interface of timing to
897 * IPython/genutils.py (timing): changed interface of timing to
891 simply run code once, which is the most common case. timings()
898 simply run code once, which is the most common case. timings()
892 remains unchanged, for the cases where you want multiple runs.
899 remains unchanged, for the cases where you want multiple runs.
893
900
894 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
901 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
895 bug where Python2.2 crashes with exec'ing code which does not end
902 bug where Python2.2 crashes with exec'ing code which does not end
896 in a single newline. Python 2.3 is OK, so I hadn't noticed this
903 in a single newline. Python 2.3 is OK, so I hadn't noticed this
897 before.
904 before.
898
905
899 2004-12-10 Fernando Perez <fperez@colorado.edu>
906 2004-12-10 Fernando Perez <fperez@colorado.edu>
900
907
901 * IPython/Magic.py (Magic.magic_prun): changed name of option from
908 * IPython/Magic.py (Magic.magic_prun): changed name of option from
902 -t to -T, to accomodate the new -t flag in %run (the %run and
909 -t to -T, to accomodate the new -t flag in %run (the %run and
903 %prun options are kind of intermixed, and it's not easy to change
910 %prun options are kind of intermixed, and it's not easy to change
904 this with the limitations of python's getopt).
911 this with the limitations of python's getopt).
905
912
906 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
913 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
907 the execution of scripts. It's not as fine-tuned as timeit.py,
914 the execution of scripts. It's not as fine-tuned as timeit.py,
908 but it works from inside ipython (and under 2.2, which lacks
915 but it works from inside ipython (and under 2.2, which lacks
909 timeit.py). Optionally a number of runs > 1 can be given for
916 timeit.py). Optionally a number of runs > 1 can be given for
910 timing very short-running code.
917 timing very short-running code.
911
918
912 * IPython/genutils.py (uniq_stable): new routine which returns a
919 * IPython/genutils.py (uniq_stable): new routine which returns a
913 list of unique elements in any iterable, but in stable order of
920 list of unique elements in any iterable, but in stable order of
914 appearance. I needed this for the ultraTB fixes, and it's a handy
921 appearance. I needed this for the ultraTB fixes, and it's a handy
915 utility.
922 utility.
916
923
917 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
924 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
918 dotted names in Verbose exceptions. This had been broken since
925 dotted names in Verbose exceptions. This had been broken since
919 the very start, now x.y will properly be printed in a Verbose
926 the very start, now x.y will properly be printed in a Verbose
920 traceback, instead of x being shown and y appearing always as an
927 traceback, instead of x being shown and y appearing always as an
921 'undefined global'. Getting this to work was a bit tricky,
928 'undefined global'. Getting this to work was a bit tricky,
922 because by default python tokenizers are stateless. Saved by
929 because by default python tokenizers are stateless. Saved by
923 python's ability to easily add a bit of state to an arbitrary
930 python's ability to easily add a bit of state to an arbitrary
924 function (without needing to build a full-blown callable object).
931 function (without needing to build a full-blown callable object).
925
932
926 Also big cleanup of this code, which had horrendous runtime
933 Also big cleanup of this code, which had horrendous runtime
927 lookups of zillions of attributes for colorization. Moved all
934 lookups of zillions of attributes for colorization. Moved all
928 this code into a few templates, which make it cleaner and quicker.
935 this code into a few templates, which make it cleaner and quicker.
929
936
930 Printout quality was also improved for Verbose exceptions: one
937 Printout quality was also improved for Verbose exceptions: one
931 variable per line, and memory addresses are printed (this can be
938 variable per line, and memory addresses are printed (this can be
932 quite handy in nasty debugging situations, which is what Verbose
939 quite handy in nasty debugging situations, which is what Verbose
933 is for).
940 is for).
934
941
935 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
942 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
936 the command line as scripts to be loaded by embedded instances.
943 the command line as scripts to be loaded by embedded instances.
937 Doing so has the potential for an infinite recursion if there are
944 Doing so has the potential for an infinite recursion if there are
938 exceptions thrown in the process. This fixes a strange crash
945 exceptions thrown in the process. This fixes a strange crash
939 reported by Philippe MULLER <muller-AT-irit.fr>.
946 reported by Philippe MULLER <muller-AT-irit.fr>.
940
947
941 2004-12-09 Fernando Perez <fperez@colorado.edu>
948 2004-12-09 Fernando Perez <fperez@colorado.edu>
942
949
943 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
950 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
944 to reflect new names in matplotlib, which now expose the
951 to reflect new names in matplotlib, which now expose the
945 matlab-compatible interface via a pylab module instead of the
952 matlab-compatible interface via a pylab module instead of the
946 'matlab' name. The new code is backwards compatible, so users of
953 'matlab' name. The new code is backwards compatible, so users of
947 all matplotlib versions are OK. Patch by J. Hunter.
954 all matplotlib versions are OK. Patch by J. Hunter.
948
955
949 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
956 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
950 of __init__ docstrings for instances (class docstrings are already
957 of __init__ docstrings for instances (class docstrings are already
951 automatically printed). Instances with customized docstrings
958 automatically printed). Instances with customized docstrings
952 (indep. of the class) are also recognized and all 3 separate
959 (indep. of the class) are also recognized and all 3 separate
953 docstrings are printed (instance, class, constructor). After some
960 docstrings are printed (instance, class, constructor). After some
954 comments/suggestions by J. Hunter.
961 comments/suggestions by J. Hunter.
955
962
956 2004-12-05 Fernando Perez <fperez@colorado.edu>
963 2004-12-05 Fernando Perez <fperez@colorado.edu>
957
964
958 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
965 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
959 warnings when tab-completion fails and triggers an exception.
966 warnings when tab-completion fails and triggers an exception.
960
967
961 2004-12-03 Fernando Perez <fperez@colorado.edu>
968 2004-12-03 Fernando Perez <fperez@colorado.edu>
962
969
963 * IPython/Magic.py (magic_prun): Fix bug where an exception would
970 * IPython/Magic.py (magic_prun): Fix bug where an exception would
964 be triggered when using 'run -p'. An incorrect option flag was
971 be triggered when using 'run -p'. An incorrect option flag was
965 being set ('d' instead of 'D').
972 being set ('d' instead of 'D').
966 (manpage): fix missing escaped \- sign.
973 (manpage): fix missing escaped \- sign.
967
974
968 2004-11-30 *** Released version 0.6.5
975 2004-11-30 *** Released version 0.6.5
969
976
970 2004-11-30 Fernando Perez <fperez@colorado.edu>
977 2004-11-30 Fernando Perez <fperez@colorado.edu>
971
978
972 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
979 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
973 setting with -d option.
980 setting with -d option.
974
981
975 * setup.py (docfiles): Fix problem where the doc glob I was using
982 * setup.py (docfiles): Fix problem where the doc glob I was using
976 was COMPLETELY BROKEN. It was giving the right files by pure
983 was COMPLETELY BROKEN. It was giving the right files by pure
977 accident, but failed once I tried to include ipython.el. Note:
984 accident, but failed once I tried to include ipython.el. Note:
978 glob() does NOT allow you to do exclusion on multiple endings!
985 glob() does NOT allow you to do exclusion on multiple endings!
979
986
980 2004-11-29 Fernando Perez <fperez@colorado.edu>
987 2004-11-29 Fernando Perez <fperez@colorado.edu>
981
988
982 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
989 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
983 the manpage as the source. Better formatting & consistency.
990 the manpage as the source. Better formatting & consistency.
984
991
985 * IPython/Magic.py (magic_run): Added new -d option, to run
992 * IPython/Magic.py (magic_run): Added new -d option, to run
986 scripts under the control of the python pdb debugger. Note that
993 scripts under the control of the python pdb debugger. Note that
987 this required changing the %prun option -d to -D, to avoid a clash
994 this required changing the %prun option -d to -D, to avoid a clash
988 (since %run must pass options to %prun, and getopt is too dumb to
995 (since %run must pass options to %prun, and getopt is too dumb to
989 handle options with string values with embedded spaces). Thanks
996 handle options with string values with embedded spaces). Thanks
990 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
997 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
991 (magic_who_ls): added type matching to %who and %whos, so that one
998 (magic_who_ls): added type matching to %who and %whos, so that one
992 can filter their output to only include variables of certain
999 can filter their output to only include variables of certain
993 types. Another suggestion by Matthew.
1000 types. Another suggestion by Matthew.
994 (magic_whos): Added memory summaries in kb and Mb for arrays.
1001 (magic_whos): Added memory summaries in kb and Mb for arrays.
995 (magic_who): Improve formatting (break lines every 9 vars).
1002 (magic_who): Improve formatting (break lines every 9 vars).
996
1003
997 2004-11-28 Fernando Perez <fperez@colorado.edu>
1004 2004-11-28 Fernando Perez <fperez@colorado.edu>
998
1005
999 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
1006 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
1000 cache when empty lines were present.
1007 cache when empty lines were present.
1001
1008
1002 2004-11-24 Fernando Perez <fperez@colorado.edu>
1009 2004-11-24 Fernando Perez <fperez@colorado.edu>
1003
1010
1004 * IPython/usage.py (__doc__): document the re-activated threading
1011 * IPython/usage.py (__doc__): document the re-activated threading
1005 options for WX and GTK.
1012 options for WX and GTK.
1006
1013
1007 2004-11-23 Fernando Perez <fperez@colorado.edu>
1014 2004-11-23 Fernando Perez <fperez@colorado.edu>
1008
1015
1009 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
1016 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
1010 the -wthread and -gthread options, along with a new -tk one to try
1017 the -wthread and -gthread options, along with a new -tk one to try
1011 and coordinate Tk threading with wx/gtk. The tk support is very
1018 and coordinate Tk threading with wx/gtk. The tk support is very
1012 platform dependent, since it seems to require Tcl and Tk to be
1019 platform dependent, since it seems to require Tcl and Tk to be
1013 built with threads (Fedora1/2 appears NOT to have it, but in
1020 built with threads (Fedora1/2 appears NOT to have it, but in
1014 Prabhu's Debian boxes it works OK). But even with some Tk
1021 Prabhu's Debian boxes it works OK). But even with some Tk
1015 limitations, this is a great improvement.
1022 limitations, this is a great improvement.
1016
1023
1017 * IPython/Prompts.py (prompt_specials_color): Added \t for time
1024 * IPython/Prompts.py (prompt_specials_color): Added \t for time
1018 info in user prompts. Patch by Prabhu.
1025 info in user prompts. Patch by Prabhu.
1019
1026
1020 2004-11-18 Fernando Perez <fperez@colorado.edu>
1027 2004-11-18 Fernando Perez <fperez@colorado.edu>
1021
1028
1022 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
1029 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
1023 EOFErrors and bail, to avoid infinite loops if a non-terminating
1030 EOFErrors and bail, to avoid infinite loops if a non-terminating
1024 file is fed into ipython. Patch submitted in issue 19 by user,
1031 file is fed into ipython. Patch submitted in issue 19 by user,
1025 many thanks.
1032 many thanks.
1026
1033
1027 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
1034 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
1028 autoquote/parens in continuation prompts, which can cause lots of
1035 autoquote/parens in continuation prompts, which can cause lots of
1029 problems. Closes roundup issue 20.
1036 problems. Closes roundup issue 20.
1030
1037
1031 2004-11-17 Fernando Perez <fperez@colorado.edu>
1038 2004-11-17 Fernando Perez <fperez@colorado.edu>
1032
1039
1033 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
1040 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
1034 reported as debian bug #280505. I'm not sure my local changelog
1041 reported as debian bug #280505. I'm not sure my local changelog
1035 entry has the proper debian format (Jack?).
1042 entry has the proper debian format (Jack?).
1036
1043
1037 2004-11-08 *** Released version 0.6.4
1044 2004-11-08 *** Released version 0.6.4
1038
1045
1039 2004-11-08 Fernando Perez <fperez@colorado.edu>
1046 2004-11-08 Fernando Perez <fperez@colorado.edu>
1040
1047
1041 * IPython/iplib.py (init_readline): Fix exit message for Windows
1048 * IPython/iplib.py (init_readline): Fix exit message for Windows
1042 when readline is active. Thanks to a report by Eric Jones
1049 when readline is active. Thanks to a report by Eric Jones
1043 <eric-AT-enthought.com>.
1050 <eric-AT-enthought.com>.
1044
1051
1045 2004-11-07 Fernando Perez <fperez@colorado.edu>
1052 2004-11-07 Fernando Perez <fperez@colorado.edu>
1046
1053
1047 * IPython/genutils.py (page): Add a trap for OSError exceptions,
1054 * IPython/genutils.py (page): Add a trap for OSError exceptions,
1048 sometimes seen by win2k/cygwin users.
1055 sometimes seen by win2k/cygwin users.
1049
1056
1050 2004-11-06 Fernando Perez <fperez@colorado.edu>
1057 2004-11-06 Fernando Perez <fperez@colorado.edu>
1051
1058
1052 * IPython/iplib.py (interact): Change the handling of %Exit from
1059 * IPython/iplib.py (interact): Change the handling of %Exit from
1053 trying to propagate a SystemExit to an internal ipython flag.
1060 trying to propagate a SystemExit to an internal ipython flag.
1054 This is less elegant than using Python's exception mechanism, but
1061 This is less elegant than using Python's exception mechanism, but
1055 I can't get that to work reliably with threads, so under -pylab
1062 I can't get that to work reliably with threads, so under -pylab
1056 %Exit was hanging IPython. Cross-thread exception handling is
1063 %Exit was hanging IPython. Cross-thread exception handling is
1057 really a bitch. Thaks to a bug report by Stephen Walton
1064 really a bitch. Thaks to a bug report by Stephen Walton
1058 <stephen.walton-AT-csun.edu>.
1065 <stephen.walton-AT-csun.edu>.
1059
1066
1060 2004-11-04 Fernando Perez <fperez@colorado.edu>
1067 2004-11-04 Fernando Perez <fperez@colorado.edu>
1061
1068
1062 * IPython/iplib.py (raw_input_original): store a pointer to the
1069 * IPython/iplib.py (raw_input_original): store a pointer to the
1063 true raw_input to harden against code which can modify it
1070 true raw_input to harden against code which can modify it
1064 (wx.py.PyShell does this and would otherwise crash ipython).
1071 (wx.py.PyShell does this and would otherwise crash ipython).
1065 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
1072 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
1066
1073
1067 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
1074 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
1068 Ctrl-C problem, which does not mess up the input line.
1075 Ctrl-C problem, which does not mess up the input line.
1069
1076
1070 2004-11-03 Fernando Perez <fperez@colorado.edu>
1077 2004-11-03 Fernando Perez <fperez@colorado.edu>
1071
1078
1072 * IPython/Release.py: Changed licensing to BSD, in all files.
1079 * IPython/Release.py: Changed licensing to BSD, in all files.
1073 (name): lowercase name for tarball/RPM release.
1080 (name): lowercase name for tarball/RPM release.
1074
1081
1075 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
1082 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
1076 use throughout ipython.
1083 use throughout ipython.
1077
1084
1078 * IPython/Magic.py (Magic._ofind): Switch to using the new
1085 * IPython/Magic.py (Magic._ofind): Switch to using the new
1079 OInspect.getdoc() function.
1086 OInspect.getdoc() function.
1080
1087
1081 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
1088 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
1082 of the line currently being canceled via Ctrl-C. It's extremely
1089 of the line currently being canceled via Ctrl-C. It's extremely
1083 ugly, but I don't know how to do it better (the problem is one of
1090 ugly, but I don't know how to do it better (the problem is one of
1084 handling cross-thread exceptions).
1091 handling cross-thread exceptions).
1085
1092
1086 2004-10-28 Fernando Perez <fperez@colorado.edu>
1093 2004-10-28 Fernando Perez <fperez@colorado.edu>
1087
1094
1088 * IPython/Shell.py (signal_handler): add signal handlers to trap
1095 * IPython/Shell.py (signal_handler): add signal handlers to trap
1089 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
1096 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
1090 report by Francesc Alted.
1097 report by Francesc Alted.
1091
1098
1092 2004-10-21 Fernando Perez <fperez@colorado.edu>
1099 2004-10-21 Fernando Perez <fperez@colorado.edu>
1093
1100
1094 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
1101 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
1095 to % for pysh syntax extensions.
1102 to % for pysh syntax extensions.
1096
1103
1097 2004-10-09 Fernando Perez <fperez@colorado.edu>
1104 2004-10-09 Fernando Perez <fperez@colorado.edu>
1098
1105
1099 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
1106 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
1100 arrays to print a more useful summary, without calling str(arr).
1107 arrays to print a more useful summary, without calling str(arr).
1101 This avoids the problem of extremely lengthy computations which
1108 This avoids the problem of extremely lengthy computations which
1102 occur if arr is large, and appear to the user as a system lockup
1109 occur if arr is large, and appear to the user as a system lockup
1103 with 100% cpu activity. After a suggestion by Kristian Sandberg
1110 with 100% cpu activity. After a suggestion by Kristian Sandberg
1104 <Kristian.Sandberg@colorado.edu>.
1111 <Kristian.Sandberg@colorado.edu>.
1105 (Magic.__init__): fix bug in global magic escapes not being
1112 (Magic.__init__): fix bug in global magic escapes not being
1106 correctly set.
1113 correctly set.
1107
1114
1108 2004-10-08 Fernando Perez <fperez@colorado.edu>
1115 2004-10-08 Fernando Perez <fperez@colorado.edu>
1109
1116
1110 * IPython/Magic.py (__license__): change to absolute imports of
1117 * IPython/Magic.py (__license__): change to absolute imports of
1111 ipython's own internal packages, to start adapting to the absolute
1118 ipython's own internal packages, to start adapting to the absolute
1112 import requirement of PEP-328.
1119 import requirement of PEP-328.
1113
1120
1114 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
1121 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
1115 files, and standardize author/license marks through the Release
1122 files, and standardize author/license marks through the Release
1116 module instead of having per/file stuff (except for files with
1123 module instead of having per/file stuff (except for files with
1117 particular licenses, like the MIT/PSF-licensed codes).
1124 particular licenses, like the MIT/PSF-licensed codes).
1118
1125
1119 * IPython/Debugger.py: remove dead code for python 2.1
1126 * IPython/Debugger.py: remove dead code for python 2.1
1120
1127
1121 2004-10-04 Fernando Perez <fperez@colorado.edu>
1128 2004-10-04 Fernando Perez <fperez@colorado.edu>
1122
1129
1123 * IPython/iplib.py (ipmagic): New function for accessing magics
1130 * IPython/iplib.py (ipmagic): New function for accessing magics
1124 via a normal python function call.
1131 via a normal python function call.
1125
1132
1126 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
1133 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
1127 from '@' to '%', to accomodate the new @decorator syntax of python
1134 from '@' to '%', to accomodate the new @decorator syntax of python
1128 2.4.
1135 2.4.
1129
1136
1130 2004-09-29 Fernando Perez <fperez@colorado.edu>
1137 2004-09-29 Fernando Perez <fperez@colorado.edu>
1131
1138
1132 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
1139 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
1133 matplotlib.use to prevent running scripts which try to switch
1140 matplotlib.use to prevent running scripts which try to switch
1134 interactive backends from within ipython. This will just crash
1141 interactive backends from within ipython. This will just crash
1135 the python interpreter, so we can't allow it (but a detailed error
1142 the python interpreter, so we can't allow it (but a detailed error
1136 is given to the user).
1143 is given to the user).
1137
1144
1138 2004-09-28 Fernando Perez <fperez@colorado.edu>
1145 2004-09-28 Fernando Perez <fperez@colorado.edu>
1139
1146
1140 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
1147 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
1141 matplotlib-related fixes so that using @run with non-matplotlib
1148 matplotlib-related fixes so that using @run with non-matplotlib
1142 scripts doesn't pop up spurious plot windows. This requires
1149 scripts doesn't pop up spurious plot windows. This requires
1143 matplotlib >= 0.63, where I had to make some changes as well.
1150 matplotlib >= 0.63, where I had to make some changes as well.
1144
1151
1145 * IPython/ipmaker.py (make_IPython): update version requirement to
1152 * IPython/ipmaker.py (make_IPython): update version requirement to
1146 python 2.2.
1153 python 2.2.
1147
1154
1148 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
1155 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
1149 banner arg for embedded customization.
1156 banner arg for embedded customization.
1150
1157
1151 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
1158 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
1152 explicit uses of __IP as the IPython's instance name. Now things
1159 explicit uses of __IP as the IPython's instance name. Now things
1153 are properly handled via the shell.name value. The actual code
1160 are properly handled via the shell.name value. The actual code
1154 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
1161 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
1155 is much better than before. I'll clean things completely when the
1162 is much better than before. I'll clean things completely when the
1156 magic stuff gets a real overhaul.
1163 magic stuff gets a real overhaul.
1157
1164
1158 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
1165 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
1159 minor changes to debian dir.
1166 minor changes to debian dir.
1160
1167
1161 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
1168 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
1162 pointer to the shell itself in the interactive namespace even when
1169 pointer to the shell itself in the interactive namespace even when
1163 a user-supplied dict is provided. This is needed for embedding
1170 a user-supplied dict is provided. This is needed for embedding
1164 purposes (found by tests with Michel Sanner).
1171 purposes (found by tests with Michel Sanner).
1165
1172
1166 2004-09-27 Fernando Perez <fperez@colorado.edu>
1173 2004-09-27 Fernando Perez <fperez@colorado.edu>
1167
1174
1168 * IPython/UserConfig/ipythonrc: remove []{} from
1175 * IPython/UserConfig/ipythonrc: remove []{} from
1169 readline_remove_delims, so that things like [modname.<TAB> do
1176 readline_remove_delims, so that things like [modname.<TAB> do
1170 proper completion. This disables [].TAB, but that's a less common
1177 proper completion. This disables [].TAB, but that's a less common
1171 case than module names in list comprehensions, for example.
1178 case than module names in list comprehensions, for example.
1172 Thanks to a report by Andrea Riciputi.
1179 Thanks to a report by Andrea Riciputi.
1173
1180
1174 2004-09-09 Fernando Perez <fperez@colorado.edu>
1181 2004-09-09 Fernando Perez <fperez@colorado.edu>
1175
1182
1176 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1183 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1177 blocking problems in win32 and osx. Fix by John.
1184 blocking problems in win32 and osx. Fix by John.
1178
1185
1179 2004-09-08 Fernando Perez <fperez@colorado.edu>
1186 2004-09-08 Fernando Perez <fperez@colorado.edu>
1180
1187
1181 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1188 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1182 for Win32 and OSX. Fix by John Hunter.
1189 for Win32 and OSX. Fix by John Hunter.
1183
1190
1184 2004-08-30 *** Released version 0.6.3
1191 2004-08-30 *** Released version 0.6.3
1185
1192
1186 2004-08-30 Fernando Perez <fperez@colorado.edu>
1193 2004-08-30 Fernando Perez <fperez@colorado.edu>
1187
1194
1188 * setup.py (isfile): Add manpages to list of dependent files to be
1195 * setup.py (isfile): Add manpages to list of dependent files to be
1189 updated.
1196 updated.
1190
1197
1191 2004-08-27 Fernando Perez <fperez@colorado.edu>
1198 2004-08-27 Fernando Perez <fperez@colorado.edu>
1192
1199
1193 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1200 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1194 for now. They don't really work with standalone WX/GTK code
1201 for now. They don't really work with standalone WX/GTK code
1195 (though matplotlib IS working fine with both of those backends).
1202 (though matplotlib IS working fine with both of those backends).
1196 This will neeed much more testing. I disabled most things with
1203 This will neeed much more testing. I disabled most things with
1197 comments, so turning it back on later should be pretty easy.
1204 comments, so turning it back on later should be pretty easy.
1198
1205
1199 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1206 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1200 autocalling of expressions like r'foo', by modifying the line
1207 autocalling of expressions like r'foo', by modifying the line
1201 split regexp. Closes
1208 split regexp. Closes
1202 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1209 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1203 Riley <ipythonbugs-AT-sabi.net>.
1210 Riley <ipythonbugs-AT-sabi.net>.
1204 (InteractiveShell.mainloop): honor --nobanner with banner
1211 (InteractiveShell.mainloop): honor --nobanner with banner
1205 extensions.
1212 extensions.
1206
1213
1207 * IPython/Shell.py: Significant refactoring of all classes, so
1214 * IPython/Shell.py: Significant refactoring of all classes, so
1208 that we can really support ALL matplotlib backends and threading
1215 that we can really support ALL matplotlib backends and threading
1209 models (John spotted a bug with Tk which required this). Now we
1216 models (John spotted a bug with Tk which required this). Now we
1210 should support single-threaded, WX-threads and GTK-threads, both
1217 should support single-threaded, WX-threads and GTK-threads, both
1211 for generic code and for matplotlib.
1218 for generic code and for matplotlib.
1212
1219
1213 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1220 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1214 -pylab, to simplify things for users. Will also remove the pylab
1221 -pylab, to simplify things for users. Will also remove the pylab
1215 profile, since now all of matplotlib configuration is directly
1222 profile, since now all of matplotlib configuration is directly
1216 handled here. This also reduces startup time.
1223 handled here. This also reduces startup time.
1217
1224
1218 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1225 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1219 shell wasn't being correctly called. Also in IPShellWX.
1226 shell wasn't being correctly called. Also in IPShellWX.
1220
1227
1221 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1228 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1222 fine-tune banner.
1229 fine-tune banner.
1223
1230
1224 * IPython/numutils.py (spike): Deprecate these spike functions,
1231 * IPython/numutils.py (spike): Deprecate these spike functions,
1225 delete (long deprecated) gnuplot_exec handler.
1232 delete (long deprecated) gnuplot_exec handler.
1226
1233
1227 2004-08-26 Fernando Perez <fperez@colorado.edu>
1234 2004-08-26 Fernando Perez <fperez@colorado.edu>
1228
1235
1229 * ipython.1: Update for threading options, plus some others which
1236 * ipython.1: Update for threading options, plus some others which
1230 were missing.
1237 were missing.
1231
1238
1232 * IPython/ipmaker.py (__call__): Added -wthread option for
1239 * IPython/ipmaker.py (__call__): Added -wthread option for
1233 wxpython thread handling. Make sure threading options are only
1240 wxpython thread handling. Make sure threading options are only
1234 valid at the command line.
1241 valid at the command line.
1235
1242
1236 * scripts/ipython: moved shell selection into a factory function
1243 * scripts/ipython: moved shell selection into a factory function
1237 in Shell.py, to keep the starter script to a minimum.
1244 in Shell.py, to keep the starter script to a minimum.
1238
1245
1239 2004-08-25 Fernando Perez <fperez@colorado.edu>
1246 2004-08-25 Fernando Perez <fperez@colorado.edu>
1240
1247
1241 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1248 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1242 John. Along with some recent changes he made to matplotlib, the
1249 John. Along with some recent changes he made to matplotlib, the
1243 next versions of both systems should work very well together.
1250 next versions of both systems should work very well together.
1244
1251
1245 2004-08-24 Fernando Perez <fperez@colorado.edu>
1252 2004-08-24 Fernando Perez <fperez@colorado.edu>
1246
1253
1247 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1254 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1248 tried to switch the profiling to using hotshot, but I'm getting
1255 tried to switch the profiling to using hotshot, but I'm getting
1249 strange errors from prof.runctx() there. I may be misreading the
1256 strange errors from prof.runctx() there. I may be misreading the
1250 docs, but it looks weird. For now the profiling code will
1257 docs, but it looks weird. For now the profiling code will
1251 continue to use the standard profiler.
1258 continue to use the standard profiler.
1252
1259
1253 2004-08-23 Fernando Perez <fperez@colorado.edu>
1260 2004-08-23 Fernando Perez <fperez@colorado.edu>
1254
1261
1255 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1262 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1256 threaded shell, by John Hunter. It's not quite ready yet, but
1263 threaded shell, by John Hunter. It's not quite ready yet, but
1257 close.
1264 close.
1258
1265
1259 2004-08-22 Fernando Perez <fperez@colorado.edu>
1266 2004-08-22 Fernando Perez <fperez@colorado.edu>
1260
1267
1261 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1268 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1262 in Magic and ultraTB.
1269 in Magic and ultraTB.
1263
1270
1264 * ipython.1: document threading options in manpage.
1271 * ipython.1: document threading options in manpage.
1265
1272
1266 * scripts/ipython: Changed name of -thread option to -gthread,
1273 * scripts/ipython: Changed name of -thread option to -gthread,
1267 since this is GTK specific. I want to leave the door open for a
1274 since this is GTK specific. I want to leave the door open for a
1268 -wthread option for WX, which will most likely be necessary. This
1275 -wthread option for WX, which will most likely be necessary. This
1269 change affects usage and ipmaker as well.
1276 change affects usage and ipmaker as well.
1270
1277
1271 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1278 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1272 handle the matplotlib shell issues. Code by John Hunter
1279 handle the matplotlib shell issues. Code by John Hunter
1273 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1280 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1274 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1281 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1275 broken (and disabled for end users) for now, but it puts the
1282 broken (and disabled for end users) for now, but it puts the
1276 infrastructure in place.
1283 infrastructure in place.
1277
1284
1278 2004-08-21 Fernando Perez <fperez@colorado.edu>
1285 2004-08-21 Fernando Perez <fperez@colorado.edu>
1279
1286
1280 * ipythonrc-pylab: Add matplotlib support.
1287 * ipythonrc-pylab: Add matplotlib support.
1281
1288
1282 * matplotlib_config.py: new files for matplotlib support, part of
1289 * matplotlib_config.py: new files for matplotlib support, part of
1283 the pylab profile.
1290 the pylab profile.
1284
1291
1285 * IPython/usage.py (__doc__): documented the threading options.
1292 * IPython/usage.py (__doc__): documented the threading options.
1286
1293
1287 2004-08-20 Fernando Perez <fperez@colorado.edu>
1294 2004-08-20 Fernando Perez <fperez@colorado.edu>
1288
1295
1289 * ipython: Modified the main calling routine to handle the -thread
1296 * ipython: Modified the main calling routine to handle the -thread
1290 and -mpthread options. This needs to be done as a top-level hack,
1297 and -mpthread options. This needs to be done as a top-level hack,
1291 because it determines which class to instantiate for IPython
1298 because it determines which class to instantiate for IPython
1292 itself.
1299 itself.
1293
1300
1294 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1301 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1295 classes to support multithreaded GTK operation without blocking,
1302 classes to support multithreaded GTK operation without blocking,
1296 and matplotlib with all backends. This is a lot of still very
1303 and matplotlib with all backends. This is a lot of still very
1297 experimental code, and threads are tricky. So it may still have a
1304 experimental code, and threads are tricky. So it may still have a
1298 few rough edges... This code owes a lot to
1305 few rough edges... This code owes a lot to
1299 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1306 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1300 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1307 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1301 to John Hunter for all the matplotlib work.
1308 to John Hunter for all the matplotlib work.
1302
1309
1303 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1310 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1304 options for gtk thread and matplotlib support.
1311 options for gtk thread and matplotlib support.
1305
1312
1306 2004-08-16 Fernando Perez <fperez@colorado.edu>
1313 2004-08-16 Fernando Perez <fperez@colorado.edu>
1307
1314
1308 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1315 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1309 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1316 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1310 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1317 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1311
1318
1312 2004-08-11 Fernando Perez <fperez@colorado.edu>
1319 2004-08-11 Fernando Perez <fperez@colorado.edu>
1313
1320
1314 * setup.py (isfile): Fix build so documentation gets updated for
1321 * setup.py (isfile): Fix build so documentation gets updated for
1315 rpms (it was only done for .tgz builds).
1322 rpms (it was only done for .tgz builds).
1316
1323
1317 2004-08-10 Fernando Perez <fperez@colorado.edu>
1324 2004-08-10 Fernando Perez <fperez@colorado.edu>
1318
1325
1319 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1326 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1320
1327
1321 * iplib.py : Silence syntax error exceptions in tab-completion.
1328 * iplib.py : Silence syntax error exceptions in tab-completion.
1322
1329
1323 2004-08-05 Fernando Perez <fperez@colorado.edu>
1330 2004-08-05 Fernando Perez <fperez@colorado.edu>
1324
1331
1325 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1332 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1326 'color off' mark for continuation prompts. This was causing long
1333 'color off' mark for continuation prompts. This was causing long
1327 continuation lines to mis-wrap.
1334 continuation lines to mis-wrap.
1328
1335
1329 2004-08-01 Fernando Perez <fperez@colorado.edu>
1336 2004-08-01 Fernando Perez <fperez@colorado.edu>
1330
1337
1331 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1338 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1332 for building ipython to be a parameter. All this is necessary
1339 for building ipython to be a parameter. All this is necessary
1333 right now to have a multithreaded version, but this insane
1340 right now to have a multithreaded version, but this insane
1334 non-design will be cleaned up soon. For now, it's a hack that
1341 non-design will be cleaned up soon. For now, it's a hack that
1335 works.
1342 works.
1336
1343
1337 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1344 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1338 args in various places. No bugs so far, but it's a dangerous
1345 args in various places. No bugs so far, but it's a dangerous
1339 practice.
1346 practice.
1340
1347
1341 2004-07-31 Fernando Perez <fperez@colorado.edu>
1348 2004-07-31 Fernando Perez <fperez@colorado.edu>
1342
1349
1343 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1350 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1344 fix completion of files with dots in their names under most
1351 fix completion of files with dots in their names under most
1345 profiles (pysh was OK because the completion order is different).
1352 profiles (pysh was OK because the completion order is different).
1346
1353
1347 2004-07-27 Fernando Perez <fperez@colorado.edu>
1354 2004-07-27 Fernando Perez <fperez@colorado.edu>
1348
1355
1349 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1356 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1350 keywords manually, b/c the one in keyword.py was removed in python
1357 keywords manually, b/c the one in keyword.py was removed in python
1351 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1358 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1352 This is NOT a bug under python 2.3 and earlier.
1359 This is NOT a bug under python 2.3 and earlier.
1353
1360
1354 2004-07-26 Fernando Perez <fperez@colorado.edu>
1361 2004-07-26 Fernando Perez <fperez@colorado.edu>
1355
1362
1356 * IPython/ultraTB.py (VerboseTB.text): Add another
1363 * IPython/ultraTB.py (VerboseTB.text): Add another
1357 linecache.checkcache() call to try to prevent inspect.py from
1364 linecache.checkcache() call to try to prevent inspect.py from
1358 crashing under python 2.3. I think this fixes
1365 crashing under python 2.3. I think this fixes
1359 http://www.scipy.net/roundup/ipython/issue17.
1366 http://www.scipy.net/roundup/ipython/issue17.
1360
1367
1361 2004-07-26 *** Released version 0.6.2
1368 2004-07-26 *** Released version 0.6.2
1362
1369
1363 2004-07-26 Fernando Perez <fperez@colorado.edu>
1370 2004-07-26 Fernando Perez <fperez@colorado.edu>
1364
1371
1365 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1372 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1366 fail for any number.
1373 fail for any number.
1367 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1374 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1368 empty bookmarks.
1375 empty bookmarks.
1369
1376
1370 2004-07-26 *** Released version 0.6.1
1377 2004-07-26 *** Released version 0.6.1
1371
1378
1372 2004-07-26 Fernando Perez <fperez@colorado.edu>
1379 2004-07-26 Fernando Perez <fperez@colorado.edu>
1373
1380
1374 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1381 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1375
1382
1376 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1383 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1377 escaping '()[]{}' in filenames.
1384 escaping '()[]{}' in filenames.
1378
1385
1379 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1386 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1380 Python 2.2 users who lack a proper shlex.split.
1387 Python 2.2 users who lack a proper shlex.split.
1381
1388
1382 2004-07-19 Fernando Perez <fperez@colorado.edu>
1389 2004-07-19 Fernando Perez <fperez@colorado.edu>
1383
1390
1384 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1391 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1385 for reading readline's init file. I follow the normal chain:
1392 for reading readline's init file. I follow the normal chain:
1386 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1393 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1387 report by Mike Heeter. This closes
1394 report by Mike Heeter. This closes
1388 http://www.scipy.net/roundup/ipython/issue16.
1395 http://www.scipy.net/roundup/ipython/issue16.
1389
1396
1390 2004-07-18 Fernando Perez <fperez@colorado.edu>
1397 2004-07-18 Fernando Perez <fperez@colorado.edu>
1391
1398
1392 * IPython/iplib.py (__init__): Add better handling of '\' under
1399 * IPython/iplib.py (__init__): Add better handling of '\' under
1393 Win32 for filenames. After a patch by Ville.
1400 Win32 for filenames. After a patch by Ville.
1394
1401
1395 2004-07-17 Fernando Perez <fperez@colorado.edu>
1402 2004-07-17 Fernando Perez <fperez@colorado.edu>
1396
1403
1397 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1404 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1398 autocalling would be triggered for 'foo is bar' if foo is
1405 autocalling would be triggered for 'foo is bar' if foo is
1399 callable. I also cleaned up the autocall detection code to use a
1406 callable. I also cleaned up the autocall detection code to use a
1400 regexp, which is faster. Bug reported by Alexander Schmolck.
1407 regexp, which is faster. Bug reported by Alexander Schmolck.
1401
1408
1402 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1409 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1403 '?' in them would confuse the help system. Reported by Alex
1410 '?' in them would confuse the help system. Reported by Alex
1404 Schmolck.
1411 Schmolck.
1405
1412
1406 2004-07-16 Fernando Perez <fperez@colorado.edu>
1413 2004-07-16 Fernando Perez <fperez@colorado.edu>
1407
1414
1408 * IPython/GnuplotInteractive.py (__all__): added plot2.
1415 * IPython/GnuplotInteractive.py (__all__): added plot2.
1409
1416
1410 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1417 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1411 plotting dictionaries, lists or tuples of 1d arrays.
1418 plotting dictionaries, lists or tuples of 1d arrays.
1412
1419
1413 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1420 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1414 optimizations.
1421 optimizations.
1415
1422
1416 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1423 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1417 the information which was there from Janko's original IPP code:
1424 the information which was there from Janko's original IPP code:
1418
1425
1419 03.05.99 20:53 porto.ifm.uni-kiel.de
1426 03.05.99 20:53 porto.ifm.uni-kiel.de
1420 --Started changelog.
1427 --Started changelog.
1421 --make clear do what it say it does
1428 --make clear do what it say it does
1422 --added pretty output of lines from inputcache
1429 --added pretty output of lines from inputcache
1423 --Made Logger a mixin class, simplifies handling of switches
1430 --Made Logger a mixin class, simplifies handling of switches
1424 --Added own completer class. .string<TAB> expands to last history
1431 --Added own completer class. .string<TAB> expands to last history
1425 line which starts with string. The new expansion is also present
1432 line which starts with string. The new expansion is also present
1426 with Ctrl-r from the readline library. But this shows, who this
1433 with Ctrl-r from the readline library. But this shows, who this
1427 can be done for other cases.
1434 can be done for other cases.
1428 --Added convention that all shell functions should accept a
1435 --Added convention that all shell functions should accept a
1429 parameter_string This opens the door for different behaviour for
1436 parameter_string This opens the door for different behaviour for
1430 each function. @cd is a good example of this.
1437 each function. @cd is a good example of this.
1431
1438
1432 04.05.99 12:12 porto.ifm.uni-kiel.de
1439 04.05.99 12:12 porto.ifm.uni-kiel.de
1433 --added logfile rotation
1440 --added logfile rotation
1434 --added new mainloop method which freezes first the namespace
1441 --added new mainloop method which freezes first the namespace
1435
1442
1436 07.05.99 21:24 porto.ifm.uni-kiel.de
1443 07.05.99 21:24 porto.ifm.uni-kiel.de
1437 --added the docreader classes. Now there is a help system.
1444 --added the docreader classes. Now there is a help system.
1438 -This is only a first try. Currently it's not easy to put new
1445 -This is only a first try. Currently it's not easy to put new
1439 stuff in the indices. But this is the way to go. Info would be
1446 stuff in the indices. But this is the way to go. Info would be
1440 better, but HTML is every where and not everybody has an info
1447 better, but HTML is every where and not everybody has an info
1441 system installed and it's not so easy to change html-docs to info.
1448 system installed and it's not so easy to change html-docs to info.
1442 --added global logfile option
1449 --added global logfile option
1443 --there is now a hook for object inspection method pinfo needs to
1450 --there is now a hook for object inspection method pinfo needs to
1444 be provided for this. Can be reached by two '??'.
1451 be provided for this. Can be reached by two '??'.
1445
1452
1446 08.05.99 20:51 porto.ifm.uni-kiel.de
1453 08.05.99 20:51 porto.ifm.uni-kiel.de
1447 --added a README
1454 --added a README
1448 --bug in rc file. Something has changed so functions in the rc
1455 --bug in rc file. Something has changed so functions in the rc
1449 file need to reference the shell and not self. Not clear if it's a
1456 file need to reference the shell and not self. Not clear if it's a
1450 bug or feature.
1457 bug or feature.
1451 --changed rc file for new behavior
1458 --changed rc file for new behavior
1452
1459
1453 2004-07-15 Fernando Perez <fperez@colorado.edu>
1460 2004-07-15 Fernando Perez <fperez@colorado.edu>
1454
1461
1455 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1462 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1456 cache was falling out of sync in bizarre manners when multi-line
1463 cache was falling out of sync in bizarre manners when multi-line
1457 input was present. Minor optimizations and cleanup.
1464 input was present. Minor optimizations and cleanup.
1458
1465
1459 (Logger): Remove old Changelog info for cleanup. This is the
1466 (Logger): Remove old Changelog info for cleanup. This is the
1460 information which was there from Janko's original code:
1467 information which was there from Janko's original code:
1461
1468
1462 Changes to Logger: - made the default log filename a parameter
1469 Changes to Logger: - made the default log filename a parameter
1463
1470
1464 - put a check for lines beginning with !@? in log(). Needed
1471 - put a check for lines beginning with !@? in log(). Needed
1465 (even if the handlers properly log their lines) for mid-session
1472 (even if the handlers properly log their lines) for mid-session
1466 logging activation to work properly. Without this, lines logged
1473 logging activation to work properly. Without this, lines logged
1467 in mid session, which get read from the cache, would end up
1474 in mid session, which get read from the cache, would end up
1468 'bare' (with !@? in the open) in the log. Now they are caught
1475 'bare' (with !@? in the open) in the log. Now they are caught
1469 and prepended with a #.
1476 and prepended with a #.
1470
1477
1471 * IPython/iplib.py (InteractiveShell.init_readline): added check
1478 * IPython/iplib.py (InteractiveShell.init_readline): added check
1472 in case MagicCompleter fails to be defined, so we don't crash.
1479 in case MagicCompleter fails to be defined, so we don't crash.
1473
1480
1474 2004-07-13 Fernando Perez <fperez@colorado.edu>
1481 2004-07-13 Fernando Perez <fperez@colorado.edu>
1475
1482
1476 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1483 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1477 of EPS if the requested filename ends in '.eps'.
1484 of EPS if the requested filename ends in '.eps'.
1478
1485
1479 2004-07-04 Fernando Perez <fperez@colorado.edu>
1486 2004-07-04 Fernando Perez <fperez@colorado.edu>
1480
1487
1481 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1488 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1482 escaping of quotes when calling the shell.
1489 escaping of quotes when calling the shell.
1483
1490
1484 2004-07-02 Fernando Perez <fperez@colorado.edu>
1491 2004-07-02 Fernando Perez <fperez@colorado.edu>
1485
1492
1486 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1493 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1487 gettext not working because we were clobbering '_'. Fixes
1494 gettext not working because we were clobbering '_'. Fixes
1488 http://www.scipy.net/roundup/ipython/issue6.
1495 http://www.scipy.net/roundup/ipython/issue6.
1489
1496
1490 2004-07-01 Fernando Perez <fperez@colorado.edu>
1497 2004-07-01 Fernando Perez <fperez@colorado.edu>
1491
1498
1492 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1499 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1493 into @cd. Patch by Ville.
1500 into @cd. Patch by Ville.
1494
1501
1495 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1502 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1496 new function to store things after ipmaker runs. Patch by Ville.
1503 new function to store things after ipmaker runs. Patch by Ville.
1497 Eventually this will go away once ipmaker is removed and the class
1504 Eventually this will go away once ipmaker is removed and the class
1498 gets cleaned up, but for now it's ok. Key functionality here is
1505 gets cleaned up, but for now it's ok. Key functionality here is
1499 the addition of the persistent storage mechanism, a dict for
1506 the addition of the persistent storage mechanism, a dict for
1500 keeping data across sessions (for now just bookmarks, but more can
1507 keeping data across sessions (for now just bookmarks, but more can
1501 be implemented later).
1508 be implemented later).
1502
1509
1503 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
1510 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
1504 persistent across sections. Patch by Ville, I modified it
1511 persistent across sections. Patch by Ville, I modified it
1505 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
1512 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
1506 added a '-l' option to list all bookmarks.
1513 added a '-l' option to list all bookmarks.
1507
1514
1508 * IPython/iplib.py (InteractiveShell.atexit_operations): new
1515 * IPython/iplib.py (InteractiveShell.atexit_operations): new
1509 center for cleanup. Registered with atexit.register(). I moved
1516 center for cleanup. Registered with atexit.register(). I moved
1510 here the old exit_cleanup(). After a patch by Ville.
1517 here the old exit_cleanup(). After a patch by Ville.
1511
1518
1512 * IPython/Magic.py (get_py_filename): added '~' to the accepted
1519 * IPython/Magic.py (get_py_filename): added '~' to the accepted
1513 characters in the hacked shlex_split for python 2.2.
1520 characters in the hacked shlex_split for python 2.2.
1514
1521
1515 * IPython/iplib.py (file_matches): more fixes to filenames with
1522 * IPython/iplib.py (file_matches): more fixes to filenames with
1516 whitespace in them. It's not perfect, but limitations in python's
1523 whitespace in them. It's not perfect, but limitations in python's
1517 readline make it impossible to go further.
1524 readline make it impossible to go further.
1518
1525
1519 2004-06-29 Fernando Perez <fperez@colorado.edu>
1526 2004-06-29 Fernando Perez <fperez@colorado.edu>
1520
1527
1521 * IPython/iplib.py (file_matches): escape whitespace correctly in
1528 * IPython/iplib.py (file_matches): escape whitespace correctly in
1522 filename completions. Bug reported by Ville.
1529 filename completions. Bug reported by Ville.
1523
1530
1524 2004-06-28 Fernando Perez <fperez@colorado.edu>
1531 2004-06-28 Fernando Perez <fperez@colorado.edu>
1525
1532
1526 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
1533 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
1527 the history file will be called 'history-PROFNAME' (or just
1534 the history file will be called 'history-PROFNAME' (or just
1528 'history' if no profile is loaded). I was getting annoyed at
1535 'history' if no profile is loaded). I was getting annoyed at
1529 getting my Numerical work history clobbered by pysh sessions.
1536 getting my Numerical work history clobbered by pysh sessions.
1530
1537
1531 * IPython/iplib.py (InteractiveShell.__init__): Internal
1538 * IPython/iplib.py (InteractiveShell.__init__): Internal
1532 getoutputerror() function so that we can honor the system_verbose
1539 getoutputerror() function so that we can honor the system_verbose
1533 flag for _all_ system calls. I also added escaping of #
1540 flag for _all_ system calls. I also added escaping of #
1534 characters here to avoid confusing Itpl.
1541 characters here to avoid confusing Itpl.
1535
1542
1536 * IPython/Magic.py (shlex_split): removed call to shell in
1543 * IPython/Magic.py (shlex_split): removed call to shell in
1537 parse_options and replaced it with shlex.split(). The annoying
1544 parse_options and replaced it with shlex.split(). The annoying
1538 part was that in Python 2.2, shlex.split() doesn't exist, so I had
1545 part was that in Python 2.2, shlex.split() doesn't exist, so I had
1539 to backport it from 2.3, with several frail hacks (the shlex
1546 to backport it from 2.3, with several frail hacks (the shlex
1540 module is rather limited in 2.2). Thanks to a suggestion by Ville
1547 module is rather limited in 2.2). Thanks to a suggestion by Ville
1541 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
1548 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
1542 problem.
1549 problem.
1543
1550
1544 (Magic.magic_system_verbose): new toggle to print the actual
1551 (Magic.magic_system_verbose): new toggle to print the actual
1545 system calls made by ipython. Mainly for debugging purposes.
1552 system calls made by ipython. Mainly for debugging purposes.
1546
1553
1547 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
1554 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
1548 doesn't support persistence. Reported (and fix suggested) by
1555 doesn't support persistence. Reported (and fix suggested) by
1549 Travis Caldwell <travis_caldwell2000@yahoo.com>.
1556 Travis Caldwell <travis_caldwell2000@yahoo.com>.
1550
1557
1551 2004-06-26 Fernando Perez <fperez@colorado.edu>
1558 2004-06-26 Fernando Perez <fperez@colorado.edu>
1552
1559
1553 * IPython/Logger.py (Logger.log): fix to handle correctly empty
1560 * IPython/Logger.py (Logger.log): fix to handle correctly empty
1554 continue prompts.
1561 continue prompts.
1555
1562
1556 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
1563 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
1557 function (basically a big docstring) and a few more things here to
1564 function (basically a big docstring) and a few more things here to
1558 speedup startup. pysh.py is now very lightweight. We want because
1565 speedup startup. pysh.py is now very lightweight. We want because
1559 it gets execfile'd, while InterpreterExec gets imported, so
1566 it gets execfile'd, while InterpreterExec gets imported, so
1560 byte-compilation saves time.
1567 byte-compilation saves time.
1561
1568
1562 2004-06-25 Fernando Perez <fperez@colorado.edu>
1569 2004-06-25 Fernando Perez <fperez@colorado.edu>
1563
1570
1564 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
1571 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
1565 -NUM', which was recently broken.
1572 -NUM', which was recently broken.
1566
1573
1567 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
1574 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
1568 in multi-line input (but not !!, which doesn't make sense there).
1575 in multi-line input (but not !!, which doesn't make sense there).
1569
1576
1570 * IPython/UserConfig/ipythonrc: made autoindent on by default.
1577 * IPython/UserConfig/ipythonrc: made autoindent on by default.
1571 It's just too useful, and people can turn it off in the less
1578 It's just too useful, and people can turn it off in the less
1572 common cases where it's a problem.
1579 common cases where it's a problem.
1573
1580
1574 2004-06-24 Fernando Perez <fperez@colorado.edu>
1581 2004-06-24 Fernando Perez <fperez@colorado.edu>
1575
1582
1576 * IPython/iplib.py (InteractiveShell._prefilter): big change -
1583 * IPython/iplib.py (InteractiveShell._prefilter): big change -
1577 special syntaxes (like alias calling) is now allied in multi-line
1584 special syntaxes (like alias calling) is now allied in multi-line
1578 input. This is still _very_ experimental, but it's necessary for
1585 input. This is still _very_ experimental, but it's necessary for
1579 efficient shell usage combining python looping syntax with system
1586 efficient shell usage combining python looping syntax with system
1580 calls. For now it's restricted to aliases, I don't think it
1587 calls. For now it's restricted to aliases, I don't think it
1581 really even makes sense to have this for magics.
1588 really even makes sense to have this for magics.
1582
1589
1583 2004-06-23 Fernando Perez <fperez@colorado.edu>
1590 2004-06-23 Fernando Perez <fperez@colorado.edu>
1584
1591
1585 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
1592 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
1586 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
1593 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
1587
1594
1588 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
1595 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
1589 extensions under Windows (after code sent by Gary Bishop). The
1596 extensions under Windows (after code sent by Gary Bishop). The
1590 extensions considered 'executable' are stored in IPython's rc
1597 extensions considered 'executable' are stored in IPython's rc
1591 structure as win_exec_ext.
1598 structure as win_exec_ext.
1592
1599
1593 * IPython/genutils.py (shell): new function, like system() but
1600 * IPython/genutils.py (shell): new function, like system() but
1594 without return value. Very useful for interactive shell work.
1601 without return value. Very useful for interactive shell work.
1595
1602
1596 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
1603 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
1597 delete aliases.
1604 delete aliases.
1598
1605
1599 * IPython/iplib.py (InteractiveShell.alias_table_update): make
1606 * IPython/iplib.py (InteractiveShell.alias_table_update): make
1600 sure that the alias table doesn't contain python keywords.
1607 sure that the alias table doesn't contain python keywords.
1601
1608
1602 2004-06-21 Fernando Perez <fperez@colorado.edu>
1609 2004-06-21 Fernando Perez <fperez@colorado.edu>
1603
1610
1604 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
1611 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
1605 non-existent items are found in $PATH. Reported by Thorsten.
1612 non-existent items are found in $PATH. Reported by Thorsten.
1606
1613
1607 2004-06-20 Fernando Perez <fperez@colorado.edu>
1614 2004-06-20 Fernando Perez <fperez@colorado.edu>
1608
1615
1609 * IPython/iplib.py (complete): modified the completer so that the
1616 * IPython/iplib.py (complete): modified the completer so that the
1610 order of priorities can be easily changed at runtime.
1617 order of priorities can be easily changed at runtime.
1611
1618
1612 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
1619 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
1613 Modified to auto-execute all lines beginning with '~', '/' or '.'.
1620 Modified to auto-execute all lines beginning with '~', '/' or '.'.
1614
1621
1615 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
1622 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
1616 expand Python variables prepended with $ in all system calls. The
1623 expand Python variables prepended with $ in all system calls. The
1617 same was done to InteractiveShell.handle_shell_escape. Now all
1624 same was done to InteractiveShell.handle_shell_escape. Now all
1618 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
1625 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
1619 expansion of python variables and expressions according to the
1626 expansion of python variables and expressions according to the
1620 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
1627 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
1621
1628
1622 Though PEP-215 has been rejected, a similar (but simpler) one
1629 Though PEP-215 has been rejected, a similar (but simpler) one
1623 seems like it will go into Python 2.4, PEP-292 -
1630 seems like it will go into Python 2.4, PEP-292 -
1624 http://www.python.org/peps/pep-0292.html.
1631 http://www.python.org/peps/pep-0292.html.
1625
1632
1626 I'll keep the full syntax of PEP-215, since IPython has since the
1633 I'll keep the full syntax of PEP-215, since IPython has since the
1627 start used Ka-Ping Yee's reference implementation discussed there
1634 start used Ka-Ping Yee's reference implementation discussed there
1628 (Itpl), and I actually like the powerful semantics it offers.
1635 (Itpl), and I actually like the powerful semantics it offers.
1629
1636
1630 In order to access normal shell variables, the $ has to be escaped
1637 In order to access normal shell variables, the $ has to be escaped
1631 via an extra $. For example:
1638 via an extra $. For example:
1632
1639
1633 In [7]: PATH='a python variable'
1640 In [7]: PATH='a python variable'
1634
1641
1635 In [8]: !echo $PATH
1642 In [8]: !echo $PATH
1636 a python variable
1643 a python variable
1637
1644
1638 In [9]: !echo $$PATH
1645 In [9]: !echo $$PATH
1639 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1646 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1640
1647
1641 (Magic.parse_options): escape $ so the shell doesn't evaluate
1648 (Magic.parse_options): escape $ so the shell doesn't evaluate
1642 things prematurely.
1649 things prematurely.
1643
1650
1644 * IPython/iplib.py (InteractiveShell.call_alias): added the
1651 * IPython/iplib.py (InteractiveShell.call_alias): added the
1645 ability for aliases to expand python variables via $.
1652 ability for aliases to expand python variables via $.
1646
1653
1647 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
1654 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
1648 system, now there's a @rehash/@rehashx pair of magics. These work
1655 system, now there's a @rehash/@rehashx pair of magics. These work
1649 like the csh rehash command, and can be invoked at any time. They
1656 like the csh rehash command, and can be invoked at any time. They
1650 build a table of aliases to everything in the user's $PATH
1657 build a table of aliases to everything in the user's $PATH
1651 (@rehash uses everything, @rehashx is slower but only adds
1658 (@rehash uses everything, @rehashx is slower but only adds
1652 executable files). With this, the pysh.py-based shell profile can
1659 executable files). With this, the pysh.py-based shell profile can
1653 now simply call rehash upon startup, and full access to all
1660 now simply call rehash upon startup, and full access to all
1654 programs in the user's path is obtained.
1661 programs in the user's path is obtained.
1655
1662
1656 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
1663 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
1657 functionality is now fully in place. I removed the old dynamic
1664 functionality is now fully in place. I removed the old dynamic
1658 code generation based approach, in favor of a much lighter one
1665 code generation based approach, in favor of a much lighter one
1659 based on a simple dict. The advantage is that this allows me to
1666 based on a simple dict. The advantage is that this allows me to
1660 now have thousands of aliases with negligible cost (unthinkable
1667 now have thousands of aliases with negligible cost (unthinkable
1661 with the old system).
1668 with the old system).
1662
1669
1663 2004-06-19 Fernando Perez <fperez@colorado.edu>
1670 2004-06-19 Fernando Perez <fperez@colorado.edu>
1664
1671
1665 * IPython/iplib.py (__init__): extended MagicCompleter class to
1672 * IPython/iplib.py (__init__): extended MagicCompleter class to
1666 also complete (last in priority) on user aliases.
1673 also complete (last in priority) on user aliases.
1667
1674
1668 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
1675 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
1669 call to eval.
1676 call to eval.
1670 (ItplNS.__init__): Added a new class which functions like Itpl,
1677 (ItplNS.__init__): Added a new class which functions like Itpl,
1671 but allows configuring the namespace for the evaluation to occur
1678 but allows configuring the namespace for the evaluation to occur
1672 in.
1679 in.
1673
1680
1674 2004-06-18 Fernando Perez <fperez@colorado.edu>
1681 2004-06-18 Fernando Perez <fperez@colorado.edu>
1675
1682
1676 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
1683 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
1677 better message when 'exit' or 'quit' are typed (a common newbie
1684 better message when 'exit' or 'quit' are typed (a common newbie
1678 confusion).
1685 confusion).
1679
1686
1680 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
1687 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
1681 check for Windows users.
1688 check for Windows users.
1682
1689
1683 * IPython/iplib.py (InteractiveShell.user_setup): removed
1690 * IPython/iplib.py (InteractiveShell.user_setup): removed
1684 disabling of colors for Windows. I'll test at runtime and issue a
1691 disabling of colors for Windows. I'll test at runtime and issue a
1685 warning if Gary's readline isn't found, as to nudge users to
1692 warning if Gary's readline isn't found, as to nudge users to
1686 download it.
1693 download it.
1687
1694
1688 2004-06-16 Fernando Perez <fperez@colorado.edu>
1695 2004-06-16 Fernando Perez <fperez@colorado.edu>
1689
1696
1690 * IPython/genutils.py (Stream.__init__): changed to print errors
1697 * IPython/genutils.py (Stream.__init__): changed to print errors
1691 to sys.stderr. I had a circular dependency here. Now it's
1698 to sys.stderr. I had a circular dependency here. Now it's
1692 possible to run ipython as IDLE's shell (consider this pre-alpha,
1699 possible to run ipython as IDLE's shell (consider this pre-alpha,
1693 since true stdout things end up in the starting terminal instead
1700 since true stdout things end up in the starting terminal instead
1694 of IDLE's out).
1701 of IDLE's out).
1695
1702
1696 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
1703 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
1697 users who haven't # updated their prompt_in2 definitions. Remove
1704 users who haven't # updated their prompt_in2 definitions. Remove
1698 eventually.
1705 eventually.
1699 (multiple_replace): added credit to original ASPN recipe.
1706 (multiple_replace): added credit to original ASPN recipe.
1700
1707
1701 2004-06-15 Fernando Perez <fperez@colorado.edu>
1708 2004-06-15 Fernando Perez <fperez@colorado.edu>
1702
1709
1703 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
1710 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
1704 list of auto-defined aliases.
1711 list of auto-defined aliases.
1705
1712
1706 2004-06-13 Fernando Perez <fperez@colorado.edu>
1713 2004-06-13 Fernando Perez <fperez@colorado.edu>
1707
1714
1708 * setup.py (scriptfiles): Don't trigger win_post_install unless an
1715 * setup.py (scriptfiles): Don't trigger win_post_install unless an
1709 install was really requested (so setup.py can be used for other
1716 install was really requested (so setup.py can be used for other
1710 things under Windows).
1717 things under Windows).
1711
1718
1712 2004-06-10 Fernando Perez <fperez@colorado.edu>
1719 2004-06-10 Fernando Perez <fperez@colorado.edu>
1713
1720
1714 * IPython/Logger.py (Logger.create_log): Manually remove any old
1721 * IPython/Logger.py (Logger.create_log): Manually remove any old
1715 backup, since os.remove may fail under Windows. Fixes bug
1722 backup, since os.remove may fail under Windows. Fixes bug
1716 reported by Thorsten.
1723 reported by Thorsten.
1717
1724
1718 2004-06-09 Fernando Perez <fperez@colorado.edu>
1725 2004-06-09 Fernando Perez <fperez@colorado.edu>
1719
1726
1720 * examples/example-embed.py: fixed all references to %n (replaced
1727 * examples/example-embed.py: fixed all references to %n (replaced
1721 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
1728 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
1722 for all examples and the manual as well.
1729 for all examples and the manual as well.
1723
1730
1724 2004-06-08 Fernando Perez <fperez@colorado.edu>
1731 2004-06-08 Fernando Perez <fperez@colorado.edu>
1725
1732
1726 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
1733 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
1727 alignment and color management. All 3 prompt subsystems now
1734 alignment and color management. All 3 prompt subsystems now
1728 inherit from BasePrompt.
1735 inherit from BasePrompt.
1729
1736
1730 * tools/release: updates for windows installer build and tag rpms
1737 * tools/release: updates for windows installer build and tag rpms
1731 with python version (since paths are fixed).
1738 with python version (since paths are fixed).
1732
1739
1733 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
1740 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
1734 which will become eventually obsolete. Also fixed the default
1741 which will become eventually obsolete. Also fixed the default
1735 prompt_in2 to use \D, so at least new users start with the correct
1742 prompt_in2 to use \D, so at least new users start with the correct
1736 defaults.
1743 defaults.
1737 WARNING: Users with existing ipythonrc files will need to apply
1744 WARNING: Users with existing ipythonrc files will need to apply
1738 this fix manually!
1745 this fix manually!
1739
1746
1740 * setup.py: make windows installer (.exe). This is finally the
1747 * setup.py: make windows installer (.exe). This is finally the
1741 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
1748 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
1742 which I hadn't included because it required Python 2.3 (or recent
1749 which I hadn't included because it required Python 2.3 (or recent
1743 distutils).
1750 distutils).
1744
1751
1745 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
1752 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
1746 usage of new '\D' escape.
1753 usage of new '\D' escape.
1747
1754
1748 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
1755 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
1749 lacks os.getuid())
1756 lacks os.getuid())
1750 (CachedOutput.set_colors): Added the ability to turn coloring
1757 (CachedOutput.set_colors): Added the ability to turn coloring
1751 on/off with @colors even for manually defined prompt colors. It
1758 on/off with @colors even for manually defined prompt colors. It
1752 uses a nasty global, but it works safely and via the generic color
1759 uses a nasty global, but it works safely and via the generic color
1753 handling mechanism.
1760 handling mechanism.
1754 (Prompt2.__init__): Introduced new escape '\D' for continuation
1761 (Prompt2.__init__): Introduced new escape '\D' for continuation
1755 prompts. It represents the counter ('\#') as dots.
1762 prompts. It represents the counter ('\#') as dots.
1756 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
1763 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
1757 need to update their ipythonrc files and replace '%n' with '\D' in
1764 need to update their ipythonrc files and replace '%n' with '\D' in
1758 their prompt_in2 settings everywhere. Sorry, but there's
1765 their prompt_in2 settings everywhere. Sorry, but there's
1759 otherwise no clean way to get all prompts to properly align. The
1766 otherwise no clean way to get all prompts to properly align. The
1760 ipythonrc shipped with IPython has been updated.
1767 ipythonrc shipped with IPython has been updated.
1761
1768
1762 2004-06-07 Fernando Perez <fperez@colorado.edu>
1769 2004-06-07 Fernando Perez <fperez@colorado.edu>
1763
1770
1764 * setup.py (isfile): Pass local_icons option to latex2html, so the
1771 * setup.py (isfile): Pass local_icons option to latex2html, so the
1765 resulting HTML file is self-contained. Thanks to
1772 resulting HTML file is self-contained. Thanks to
1766 dryice-AT-liu.com.cn for the tip.
1773 dryice-AT-liu.com.cn for the tip.
1767
1774
1768 * pysh.py: I created a new profile 'shell', which implements a
1775 * pysh.py: I created a new profile 'shell', which implements a
1769 _rudimentary_ IPython-based shell. This is in NO WAY a realy
1776 _rudimentary_ IPython-based shell. This is in NO WAY a realy
1770 system shell, nor will it become one anytime soon. It's mainly
1777 system shell, nor will it become one anytime soon. It's mainly
1771 meant to illustrate the use of the new flexible bash-like prompts.
1778 meant to illustrate the use of the new flexible bash-like prompts.
1772 I guess it could be used by hardy souls for true shell management,
1779 I guess it could be used by hardy souls for true shell management,
1773 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
1780 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
1774 profile. This uses the InterpreterExec extension provided by
1781 profile. This uses the InterpreterExec extension provided by
1775 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
1782 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
1776
1783
1777 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
1784 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
1778 auto-align itself with the length of the previous input prompt
1785 auto-align itself with the length of the previous input prompt
1779 (taking into account the invisible color escapes).
1786 (taking into account the invisible color escapes).
1780 (CachedOutput.__init__): Large restructuring of this class. Now
1787 (CachedOutput.__init__): Large restructuring of this class. Now
1781 all three prompts (primary1, primary2, output) are proper objects,
1788 all three prompts (primary1, primary2, output) are proper objects,
1782 managed by the 'parent' CachedOutput class. The code is still a
1789 managed by the 'parent' CachedOutput class. The code is still a
1783 bit hackish (all prompts share state via a pointer to the cache),
1790 bit hackish (all prompts share state via a pointer to the cache),
1784 but it's overall far cleaner than before.
1791 but it's overall far cleaner than before.
1785
1792
1786 * IPython/genutils.py (getoutputerror): modified to add verbose,
1793 * IPython/genutils.py (getoutputerror): modified to add verbose,
1787 debug and header options. This makes the interface of all getout*
1794 debug and header options. This makes the interface of all getout*
1788 functions uniform.
1795 functions uniform.
1789 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
1796 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
1790
1797
1791 * IPython/Magic.py (Magic.default_option): added a function to
1798 * IPython/Magic.py (Magic.default_option): added a function to
1792 allow registering default options for any magic command. This
1799 allow registering default options for any magic command. This
1793 makes it easy to have profiles which customize the magics globally
1800 makes it easy to have profiles which customize the magics globally
1794 for a certain use. The values set through this function are
1801 for a certain use. The values set through this function are
1795 picked up by the parse_options() method, which all magics should
1802 picked up by the parse_options() method, which all magics should
1796 use to parse their options.
1803 use to parse their options.
1797
1804
1798 * IPython/genutils.py (warn): modified the warnings framework to
1805 * IPython/genutils.py (warn): modified the warnings framework to
1799 use the Term I/O class. I'm trying to slowly unify all of
1806 use the Term I/O class. I'm trying to slowly unify all of
1800 IPython's I/O operations to pass through Term.
1807 IPython's I/O operations to pass through Term.
1801
1808
1802 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
1809 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
1803 the secondary prompt to correctly match the length of the primary
1810 the secondary prompt to correctly match the length of the primary
1804 one for any prompt. Now multi-line code will properly line up
1811 one for any prompt. Now multi-line code will properly line up
1805 even for path dependent prompts, such as the new ones available
1812 even for path dependent prompts, such as the new ones available
1806 via the prompt_specials.
1813 via the prompt_specials.
1807
1814
1808 2004-06-06 Fernando Perez <fperez@colorado.edu>
1815 2004-06-06 Fernando Perez <fperez@colorado.edu>
1809
1816
1810 * IPython/Prompts.py (prompt_specials): Added the ability to have
1817 * IPython/Prompts.py (prompt_specials): Added the ability to have
1811 bash-like special sequences in the prompts, which get
1818 bash-like special sequences in the prompts, which get
1812 automatically expanded. Things like hostname, current working
1819 automatically expanded. Things like hostname, current working
1813 directory and username are implemented already, but it's easy to
1820 directory and username are implemented already, but it's easy to
1814 add more in the future. Thanks to a patch by W.J. van der Laan
1821 add more in the future. Thanks to a patch by W.J. van der Laan
1815 <gnufnork-AT-hetdigitalegat.nl>
1822 <gnufnork-AT-hetdigitalegat.nl>
1816 (prompt_specials): Added color support for prompt strings, so
1823 (prompt_specials): Added color support for prompt strings, so
1817 users can define arbitrary color setups for their prompts.
1824 users can define arbitrary color setups for their prompts.
1818
1825
1819 2004-06-05 Fernando Perez <fperez@colorado.edu>
1826 2004-06-05 Fernando Perez <fperez@colorado.edu>
1820
1827
1821 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
1828 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
1822 code to load Gary Bishop's readline and configure it
1829 code to load Gary Bishop's readline and configure it
1823 automatically. Thanks to Gary for help on this.
1830 automatically. Thanks to Gary for help on this.
1824
1831
1825 2004-06-01 Fernando Perez <fperez@colorado.edu>
1832 2004-06-01 Fernando Perez <fperez@colorado.edu>
1826
1833
1827 * IPython/Logger.py (Logger.create_log): fix bug for logging
1834 * IPython/Logger.py (Logger.create_log): fix bug for logging
1828 with no filename (previous fix was incomplete).
1835 with no filename (previous fix was incomplete).
1829
1836
1830 2004-05-25 Fernando Perez <fperez@colorado.edu>
1837 2004-05-25 Fernando Perez <fperez@colorado.edu>
1831
1838
1832 * IPython/Magic.py (Magic.parse_options): fix bug where naked
1839 * IPython/Magic.py (Magic.parse_options): fix bug where naked
1833 parens would get passed to the shell.
1840 parens would get passed to the shell.
1834
1841
1835 2004-05-20 Fernando Perez <fperez@colorado.edu>
1842 2004-05-20 Fernando Perez <fperez@colorado.edu>
1836
1843
1837 * IPython/Magic.py (Magic.magic_prun): changed default profile
1844 * IPython/Magic.py (Magic.magic_prun): changed default profile
1838 sort order to 'time' (the more common profiling need).
1845 sort order to 'time' (the more common profiling need).
1839
1846
1840 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
1847 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
1841 so that source code shown is guaranteed in sync with the file on
1848 so that source code shown is guaranteed in sync with the file on
1842 disk (also changed in psource). Similar fix to the one for
1849 disk (also changed in psource). Similar fix to the one for
1843 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
1850 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
1844 <yann.ledu-AT-noos.fr>.
1851 <yann.ledu-AT-noos.fr>.
1845
1852
1846 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
1853 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
1847 with a single option would not be correctly parsed. Closes
1854 with a single option would not be correctly parsed. Closes
1848 http://www.scipy.net/roundup/ipython/issue14. This bug had been
1855 http://www.scipy.net/roundup/ipython/issue14. This bug had been
1849 introduced in 0.6.0 (on 2004-05-06).
1856 introduced in 0.6.0 (on 2004-05-06).
1850
1857
1851 2004-05-13 *** Released version 0.6.0
1858 2004-05-13 *** Released version 0.6.0
1852
1859
1853 2004-05-13 Fernando Perez <fperez@colorado.edu>
1860 2004-05-13 Fernando Perez <fperez@colorado.edu>
1854
1861
1855 * debian/: Added debian/ directory to CVS, so that debian support
1862 * debian/: Added debian/ directory to CVS, so that debian support
1856 is publicly accessible. The debian package is maintained by Jack
1863 is publicly accessible. The debian package is maintained by Jack
1857 Moffit <jack-AT-xiph.org>.
1864 Moffit <jack-AT-xiph.org>.
1858
1865
1859 * Documentation: included the notes about an ipython-based system
1866 * Documentation: included the notes about an ipython-based system
1860 shell (the hypothetical 'pysh') into the new_design.pdf document,
1867 shell (the hypothetical 'pysh') into the new_design.pdf document,
1861 so that these ideas get distributed to users along with the
1868 so that these ideas get distributed to users along with the
1862 official documentation.
1869 official documentation.
1863
1870
1864 2004-05-10 Fernando Perez <fperez@colorado.edu>
1871 2004-05-10 Fernando Perez <fperez@colorado.edu>
1865
1872
1866 * IPython/Logger.py (Logger.create_log): fix recently introduced
1873 * IPython/Logger.py (Logger.create_log): fix recently introduced
1867 bug (misindented line) where logstart would fail when not given an
1874 bug (misindented line) where logstart would fail when not given an
1868 explicit filename.
1875 explicit filename.
1869
1876
1870 2004-05-09 Fernando Perez <fperez@colorado.edu>
1877 2004-05-09 Fernando Perez <fperez@colorado.edu>
1871
1878
1872 * IPython/Magic.py (Magic.parse_options): skip system call when
1879 * IPython/Magic.py (Magic.parse_options): skip system call when
1873 there are no options to look for. Faster, cleaner for the common
1880 there are no options to look for. Faster, cleaner for the common
1874 case.
1881 case.
1875
1882
1876 * Documentation: many updates to the manual: describing Windows
1883 * Documentation: many updates to the manual: describing Windows
1877 support better, Gnuplot updates, credits, misc small stuff. Also
1884 support better, Gnuplot updates, credits, misc small stuff. Also
1878 updated the new_design doc a bit.
1885 updated the new_design doc a bit.
1879
1886
1880 2004-05-06 *** Released version 0.6.0.rc1
1887 2004-05-06 *** Released version 0.6.0.rc1
1881
1888
1882 2004-05-06 Fernando Perez <fperez@colorado.edu>
1889 2004-05-06 Fernando Perez <fperez@colorado.edu>
1883
1890
1884 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
1891 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
1885 operations to use the vastly more efficient list/''.join() method.
1892 operations to use the vastly more efficient list/''.join() method.
1886 (FormattedTB.text): Fix
1893 (FormattedTB.text): Fix
1887 http://www.scipy.net/roundup/ipython/issue12 - exception source
1894 http://www.scipy.net/roundup/ipython/issue12 - exception source
1888 extract not updated after reload. Thanks to Mike Salib
1895 extract not updated after reload. Thanks to Mike Salib
1889 <msalib-AT-mit.edu> for pinning the source of the problem.
1896 <msalib-AT-mit.edu> for pinning the source of the problem.
1890 Fortunately, the solution works inside ipython and doesn't require
1897 Fortunately, the solution works inside ipython and doesn't require
1891 any changes to python proper.
1898 any changes to python proper.
1892
1899
1893 * IPython/Magic.py (Magic.parse_options): Improved to process the
1900 * IPython/Magic.py (Magic.parse_options): Improved to process the
1894 argument list as a true shell would (by actually using the
1901 argument list as a true shell would (by actually using the
1895 underlying system shell). This way, all @magics automatically get
1902 underlying system shell). This way, all @magics automatically get
1896 shell expansion for variables. Thanks to a comment by Alex
1903 shell expansion for variables. Thanks to a comment by Alex
1897 Schmolck.
1904 Schmolck.
1898
1905
1899 2004-04-04 Fernando Perez <fperez@colorado.edu>
1906 2004-04-04 Fernando Perez <fperez@colorado.edu>
1900
1907
1901 * IPython/iplib.py (InteractiveShell.interact): Added a special
1908 * IPython/iplib.py (InteractiveShell.interact): Added a special
1902 trap for a debugger quit exception, which is basically impossible
1909 trap for a debugger quit exception, which is basically impossible
1903 to handle by normal mechanisms, given what pdb does to the stack.
1910 to handle by normal mechanisms, given what pdb does to the stack.
1904 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
1911 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
1905
1912
1906 2004-04-03 Fernando Perez <fperez@colorado.edu>
1913 2004-04-03 Fernando Perez <fperez@colorado.edu>
1907
1914
1908 * IPython/genutils.py (Term): Standardized the names of the Term
1915 * IPython/genutils.py (Term): Standardized the names of the Term
1909 class streams to cin/cout/cerr, following C++ naming conventions
1916 class streams to cin/cout/cerr, following C++ naming conventions
1910 (I can't use in/out/err because 'in' is not a valid attribute
1917 (I can't use in/out/err because 'in' is not a valid attribute
1911 name).
1918 name).
1912
1919
1913 * IPython/iplib.py (InteractiveShell.interact): don't increment
1920 * IPython/iplib.py (InteractiveShell.interact): don't increment
1914 the prompt if there's no user input. By Daniel 'Dang' Griffith
1921 the prompt if there's no user input. By Daniel 'Dang' Griffith
1915 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
1922 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
1916 Francois Pinard.
1923 Francois Pinard.
1917
1924
1918 2004-04-02 Fernando Perez <fperez@colorado.edu>
1925 2004-04-02 Fernando Perez <fperez@colorado.edu>
1919
1926
1920 * IPython/genutils.py (Stream.__init__): Modified to survive at
1927 * IPython/genutils.py (Stream.__init__): Modified to survive at
1921 least importing in contexts where stdin/out/err aren't true file
1928 least importing in contexts where stdin/out/err aren't true file
1922 objects, such as PyCrust (they lack fileno() and mode). However,
1929 objects, such as PyCrust (they lack fileno() and mode). However,
1923 the recovery facilities which rely on these things existing will
1930 the recovery facilities which rely on these things existing will
1924 not work.
1931 not work.
1925
1932
1926 2004-04-01 Fernando Perez <fperez@colorado.edu>
1933 2004-04-01 Fernando Perez <fperez@colorado.edu>
1927
1934
1928 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
1935 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
1929 use the new getoutputerror() function, so it properly
1936 use the new getoutputerror() function, so it properly
1930 distinguishes stdout/err.
1937 distinguishes stdout/err.
1931
1938
1932 * IPython/genutils.py (getoutputerror): added a function to
1939 * IPython/genutils.py (getoutputerror): added a function to
1933 capture separately the standard output and error of a command.
1940 capture separately the standard output and error of a command.
1934 After a comment from dang on the mailing lists. This code is
1941 After a comment from dang on the mailing lists. This code is
1935 basically a modified version of commands.getstatusoutput(), from
1942 basically a modified version of commands.getstatusoutput(), from
1936 the standard library.
1943 the standard library.
1937
1944
1938 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
1945 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
1939 '!!' as a special syntax (shorthand) to access @sx.
1946 '!!' as a special syntax (shorthand) to access @sx.
1940
1947
1941 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
1948 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
1942 command and return its output as a list split on '\n'.
1949 command and return its output as a list split on '\n'.
1943
1950
1944 2004-03-31 Fernando Perez <fperez@colorado.edu>
1951 2004-03-31 Fernando Perez <fperez@colorado.edu>
1945
1952
1946 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
1953 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
1947 method to dictionaries used as FakeModule instances if they lack
1954 method to dictionaries used as FakeModule instances if they lack
1948 it. At least pydoc in python2.3 breaks for runtime-defined
1955 it. At least pydoc in python2.3 breaks for runtime-defined
1949 functions without this hack. At some point I need to _really_
1956 functions without this hack. At some point I need to _really_
1950 understand what FakeModule is doing, because it's a gross hack.
1957 understand what FakeModule is doing, because it's a gross hack.
1951 But it solves Arnd's problem for now...
1958 But it solves Arnd's problem for now...
1952
1959
1953 2004-02-27 Fernando Perez <fperez@colorado.edu>
1960 2004-02-27 Fernando Perez <fperez@colorado.edu>
1954
1961
1955 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
1962 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
1956 mode would behave erratically. Also increased the number of
1963 mode would behave erratically. Also increased the number of
1957 possible logs in rotate mod to 999. Thanks to Rod Holland
1964 possible logs in rotate mod to 999. Thanks to Rod Holland
1958 <rhh@StructureLABS.com> for the report and fixes.
1965 <rhh@StructureLABS.com> for the report and fixes.
1959
1966
1960 2004-02-26 Fernando Perez <fperez@colorado.edu>
1967 2004-02-26 Fernando Perez <fperez@colorado.edu>
1961
1968
1962 * IPython/genutils.py (page): Check that the curses module really
1969 * IPython/genutils.py (page): Check that the curses module really
1963 has the initscr attribute before trying to use it. For some
1970 has the initscr attribute before trying to use it. For some
1964 reason, the Solaris curses module is missing this. I think this
1971 reason, the Solaris curses module is missing this. I think this
1965 should be considered a Solaris python bug, but I'm not sure.
1972 should be considered a Solaris python bug, but I'm not sure.
1966
1973
1967 2004-01-17 Fernando Perez <fperez@colorado.edu>
1974 2004-01-17 Fernando Perez <fperez@colorado.edu>
1968
1975
1969 * IPython/genutils.py (Stream.__init__): Changes to try to make
1976 * IPython/genutils.py (Stream.__init__): Changes to try to make
1970 ipython robust against stdin/out/err being closed by the user.
1977 ipython robust against stdin/out/err being closed by the user.
1971 This is 'user error' (and blocks a normal python session, at least
1978 This is 'user error' (and blocks a normal python session, at least
1972 the stdout case). However, Ipython should be able to survive such
1979 the stdout case). However, Ipython should be able to survive such
1973 instances of abuse as gracefully as possible. To simplify the
1980 instances of abuse as gracefully as possible. To simplify the
1974 coding and maintain compatibility with Gary Bishop's Term
1981 coding and maintain compatibility with Gary Bishop's Term
1975 contributions, I've made use of classmethods for this. I think
1982 contributions, I've made use of classmethods for this. I think
1976 this introduces a dependency on python 2.2.
1983 this introduces a dependency on python 2.2.
1977
1984
1978 2004-01-13 Fernando Perez <fperez@colorado.edu>
1985 2004-01-13 Fernando Perez <fperez@colorado.edu>
1979
1986
1980 * IPython/numutils.py (exp_safe): simplified the code a bit and
1987 * IPython/numutils.py (exp_safe): simplified the code a bit and
1981 removed the need for importing the kinds module altogether.
1988 removed the need for importing the kinds module altogether.
1982
1989
1983 2004-01-06 Fernando Perez <fperez@colorado.edu>
1990 2004-01-06 Fernando Perez <fperez@colorado.edu>
1984
1991
1985 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
1992 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
1986 a magic function instead, after some community feedback. No
1993 a magic function instead, after some community feedback. No
1987 special syntax will exist for it, but its name is deliberately
1994 special syntax will exist for it, but its name is deliberately
1988 very short.
1995 very short.
1989
1996
1990 2003-12-20 Fernando Perez <fperez@colorado.edu>
1997 2003-12-20 Fernando Perez <fperez@colorado.edu>
1991
1998
1992 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
1999 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
1993 new functionality, to automagically assign the result of a shell
2000 new functionality, to automagically assign the result of a shell
1994 command to a variable. I'll solicit some community feedback on
2001 command to a variable. I'll solicit some community feedback on
1995 this before making it permanent.
2002 this before making it permanent.
1996
2003
1997 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
2004 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
1998 requested about callables for which inspect couldn't obtain a
2005 requested about callables for which inspect couldn't obtain a
1999 proper argspec. Thanks to a crash report sent by Etienne
2006 proper argspec. Thanks to a crash report sent by Etienne
2000 Posthumus <etienne-AT-apple01.cs.vu.nl>.
2007 Posthumus <etienne-AT-apple01.cs.vu.nl>.
2001
2008
2002 2003-12-09 Fernando Perez <fperez@colorado.edu>
2009 2003-12-09 Fernando Perez <fperez@colorado.edu>
2003
2010
2004 * IPython/genutils.py (page): patch for the pager to work across
2011 * IPython/genutils.py (page): patch for the pager to work across
2005 various versions of Windows. By Gary Bishop.
2012 various versions of Windows. By Gary Bishop.
2006
2013
2007 2003-12-04 Fernando Perez <fperez@colorado.edu>
2014 2003-12-04 Fernando Perez <fperez@colorado.edu>
2008
2015
2009 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
2016 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
2010 Gnuplot.py version 1.7, whose internal names changed quite a bit.
2017 Gnuplot.py version 1.7, whose internal names changed quite a bit.
2011 While I tested this and it looks ok, there may still be corner
2018 While I tested this and it looks ok, there may still be corner
2012 cases I've missed.
2019 cases I've missed.
2013
2020
2014 2003-12-01 Fernando Perez <fperez@colorado.edu>
2021 2003-12-01 Fernando Perez <fperez@colorado.edu>
2015
2022
2016 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
2023 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
2017 where a line like 'p,q=1,2' would fail because the automagic
2024 where a line like 'p,q=1,2' would fail because the automagic
2018 system would be triggered for @p.
2025 system would be triggered for @p.
2019
2026
2020 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
2027 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
2021 cleanups, code unmodified.
2028 cleanups, code unmodified.
2022
2029
2023 * IPython/genutils.py (Term): added a class for IPython to handle
2030 * IPython/genutils.py (Term): added a class for IPython to handle
2024 output. In most cases it will just be a proxy for stdout/err, but
2031 output. In most cases it will just be a proxy for stdout/err, but
2025 having this allows modifications to be made for some platforms,
2032 having this allows modifications to be made for some platforms,
2026 such as handling color escapes under Windows. All of this code
2033 such as handling color escapes under Windows. All of this code
2027 was contributed by Gary Bishop, with minor modifications by me.
2034 was contributed by Gary Bishop, with minor modifications by me.
2028 The actual changes affect many files.
2035 The actual changes affect many files.
2029
2036
2030 2003-11-30 Fernando Perez <fperez@colorado.edu>
2037 2003-11-30 Fernando Perez <fperez@colorado.edu>
2031
2038
2032 * IPython/iplib.py (file_matches): new completion code, courtesy
2039 * IPython/iplib.py (file_matches): new completion code, courtesy
2033 of Jeff Collins. This enables filename completion again under
2040 of Jeff Collins. This enables filename completion again under
2034 python 2.3, which disabled it at the C level.
2041 python 2.3, which disabled it at the C level.
2035
2042
2036 2003-11-11 Fernando Perez <fperez@colorado.edu>
2043 2003-11-11 Fernando Perez <fperez@colorado.edu>
2037
2044
2038 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
2045 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
2039 for Numeric.array(map(...)), but often convenient.
2046 for Numeric.array(map(...)), but often convenient.
2040
2047
2041 2003-11-05 Fernando Perez <fperez@colorado.edu>
2048 2003-11-05 Fernando Perez <fperez@colorado.edu>
2042
2049
2043 * IPython/numutils.py (frange): Changed a call from int() to
2050 * IPython/numutils.py (frange): Changed a call from int() to
2044 int(round()) to prevent a problem reported with arange() in the
2051 int(round()) to prevent a problem reported with arange() in the
2045 numpy list.
2052 numpy list.
2046
2053
2047 2003-10-06 Fernando Perez <fperez@colorado.edu>
2054 2003-10-06 Fernando Perez <fperez@colorado.edu>
2048
2055
2049 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
2056 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
2050 prevent crashes if sys lacks an argv attribute (it happens with
2057 prevent crashes if sys lacks an argv attribute (it happens with
2051 embedded interpreters which build a bare-bones sys module).
2058 embedded interpreters which build a bare-bones sys module).
2052 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
2059 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
2053
2060
2054 2003-09-24 Fernando Perez <fperez@colorado.edu>
2061 2003-09-24 Fernando Perez <fperez@colorado.edu>
2055
2062
2056 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
2063 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
2057 to protect against poorly written user objects where __getattr__
2064 to protect against poorly written user objects where __getattr__
2058 raises exceptions other than AttributeError. Thanks to a bug
2065 raises exceptions other than AttributeError. Thanks to a bug
2059 report by Oliver Sander <osander-AT-gmx.de>.
2066 report by Oliver Sander <osander-AT-gmx.de>.
2060
2067
2061 * IPython/FakeModule.py (FakeModule.__repr__): this method was
2068 * IPython/FakeModule.py (FakeModule.__repr__): this method was
2062 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
2069 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
2063
2070
2064 2003-09-09 Fernando Perez <fperez@colorado.edu>
2071 2003-09-09 Fernando Perez <fperez@colorado.edu>
2065
2072
2066 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2073 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2067 unpacking a list whith a callable as first element would
2074 unpacking a list whith a callable as first element would
2068 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
2075 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
2069 Collins.
2076 Collins.
2070
2077
2071 2003-08-25 *** Released version 0.5.0
2078 2003-08-25 *** Released version 0.5.0
2072
2079
2073 2003-08-22 Fernando Perez <fperez@colorado.edu>
2080 2003-08-22 Fernando Perez <fperez@colorado.edu>
2074
2081
2075 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
2082 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
2076 improperly defined user exceptions. Thanks to feedback from Mark
2083 improperly defined user exceptions. Thanks to feedback from Mark
2077 Russell <mrussell-AT-verio.net>.
2084 Russell <mrussell-AT-verio.net>.
2078
2085
2079 2003-08-20 Fernando Perez <fperez@colorado.edu>
2086 2003-08-20 Fernando Perez <fperez@colorado.edu>
2080
2087
2081 * IPython/OInspect.py (Inspector.pinfo): changed String Form
2088 * IPython/OInspect.py (Inspector.pinfo): changed String Form
2082 printing so that it would print multi-line string forms starting
2089 printing so that it would print multi-line string forms starting
2083 with a new line. This way the formatting is better respected for
2090 with a new line. This way the formatting is better respected for
2084 objects which work hard to make nice string forms.
2091 objects which work hard to make nice string forms.
2085
2092
2086 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
2093 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
2087 autocall would overtake data access for objects with both
2094 autocall would overtake data access for objects with both
2088 __getitem__ and __call__.
2095 __getitem__ and __call__.
2089
2096
2090 2003-08-19 *** Released version 0.5.0-rc1
2097 2003-08-19 *** Released version 0.5.0-rc1
2091
2098
2092 2003-08-19 Fernando Perez <fperez@colorado.edu>
2099 2003-08-19 Fernando Perez <fperez@colorado.edu>
2093
2100
2094 * IPython/deep_reload.py (load_tail): single tiny change here
2101 * IPython/deep_reload.py (load_tail): single tiny change here
2095 seems to fix the long-standing bug of dreload() failing to work
2102 seems to fix the long-standing bug of dreload() failing to work
2096 for dotted names. But this module is pretty tricky, so I may have
2103 for dotted names. But this module is pretty tricky, so I may have
2097 missed some subtlety. Needs more testing!.
2104 missed some subtlety. Needs more testing!.
2098
2105
2099 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
2106 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
2100 exceptions which have badly implemented __str__ methods.
2107 exceptions which have badly implemented __str__ methods.
2101 (VerboseTB.text): harden against inspect.getinnerframes crashing,
2108 (VerboseTB.text): harden against inspect.getinnerframes crashing,
2102 which I've been getting reports about from Python 2.3 users. I
2109 which I've been getting reports about from Python 2.3 users. I
2103 wish I had a simple test case to reproduce the problem, so I could
2110 wish I had a simple test case to reproduce the problem, so I could
2104 either write a cleaner workaround or file a bug report if
2111 either write a cleaner workaround or file a bug report if
2105 necessary.
2112 necessary.
2106
2113
2107 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
2114 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
2108 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
2115 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
2109 a bug report by Tjabo Kloppenburg.
2116 a bug report by Tjabo Kloppenburg.
2110
2117
2111 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
2118 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
2112 crashes. Wrapped the pdb call in a blanket try/except, since pdb
2119 crashes. Wrapped the pdb call in a blanket try/except, since pdb
2113 seems rather unstable. Thanks to a bug report by Tjabo
2120 seems rather unstable. Thanks to a bug report by Tjabo
2114 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
2121 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
2115
2122
2116 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
2123 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
2117 this out soon because of the critical fixes in the inner loop for
2124 this out soon because of the critical fixes in the inner loop for
2118 generators.
2125 generators.
2119
2126
2120 * IPython/Magic.py (Magic.getargspec): removed. This (and
2127 * IPython/Magic.py (Magic.getargspec): removed. This (and
2121 _get_def) have been obsoleted by OInspect for a long time, I
2128 _get_def) have been obsoleted by OInspect for a long time, I
2122 hadn't noticed that they were dead code.
2129 hadn't noticed that they were dead code.
2123 (Magic._ofind): restored _ofind functionality for a few literals
2130 (Magic._ofind): restored _ofind functionality for a few literals
2124 (those in ["''",'""','[]','{}','()']). But it won't work anymore
2131 (those in ["''",'""','[]','{}','()']). But it won't work anymore
2125 for things like "hello".capitalize?, since that would require a
2132 for things like "hello".capitalize?, since that would require a
2126 potentially dangerous eval() again.
2133 potentially dangerous eval() again.
2127
2134
2128 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
2135 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
2129 logic a bit more to clean up the escapes handling and minimize the
2136 logic a bit more to clean up the escapes handling and minimize the
2130 use of _ofind to only necessary cases. The interactive 'feel' of
2137 use of _ofind to only necessary cases. The interactive 'feel' of
2131 IPython should have improved quite a bit with the changes in
2138 IPython should have improved quite a bit with the changes in
2132 _prefilter and _ofind (besides being far safer than before).
2139 _prefilter and _ofind (besides being far safer than before).
2133
2140
2134 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
2141 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
2135 obscure, never reported). Edit would fail to find the object to
2142 obscure, never reported). Edit would fail to find the object to
2136 edit under some circumstances.
2143 edit under some circumstances.
2137 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
2144 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
2138 which were causing double-calling of generators. Those eval calls
2145 which were causing double-calling of generators. Those eval calls
2139 were _very_ dangerous, since code with side effects could be
2146 were _very_ dangerous, since code with side effects could be
2140 triggered. As they say, 'eval is evil'... These were the
2147 triggered. As they say, 'eval is evil'... These were the
2141 nastiest evals in IPython. Besides, _ofind is now far simpler,
2148 nastiest evals in IPython. Besides, _ofind is now far simpler,
2142 and it should also be quite a bit faster. Its use of inspect is
2149 and it should also be quite a bit faster. Its use of inspect is
2143 also safer, so perhaps some of the inspect-related crashes I've
2150 also safer, so perhaps some of the inspect-related crashes I've
2144 seen lately with Python 2.3 might be taken care of. That will
2151 seen lately with Python 2.3 might be taken care of. That will
2145 need more testing.
2152 need more testing.
2146
2153
2147 2003-08-17 Fernando Perez <fperez@colorado.edu>
2154 2003-08-17 Fernando Perez <fperez@colorado.edu>
2148
2155
2149 * IPython/iplib.py (InteractiveShell._prefilter): significant
2156 * IPython/iplib.py (InteractiveShell._prefilter): significant
2150 simplifications to the logic for handling user escapes. Faster
2157 simplifications to the logic for handling user escapes. Faster
2151 and simpler code.
2158 and simpler code.
2152
2159
2153 2003-08-14 Fernando Perez <fperez@colorado.edu>
2160 2003-08-14 Fernando Perez <fperez@colorado.edu>
2154
2161
2155 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
2162 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
2156 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
2163 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
2157 but it should be quite a bit faster. And the recursive version
2164 but it should be quite a bit faster. And the recursive version
2158 generated O(log N) intermediate storage for all rank>1 arrays,
2165 generated O(log N) intermediate storage for all rank>1 arrays,
2159 even if they were contiguous.
2166 even if they were contiguous.
2160 (l1norm): Added this function.
2167 (l1norm): Added this function.
2161 (norm): Added this function for arbitrary norms (including
2168 (norm): Added this function for arbitrary norms (including
2162 l-infinity). l1 and l2 are still special cases for convenience
2169 l-infinity). l1 and l2 are still special cases for convenience
2163 and speed.
2170 and speed.
2164
2171
2165 2003-08-03 Fernando Perez <fperez@colorado.edu>
2172 2003-08-03 Fernando Perez <fperez@colorado.edu>
2166
2173
2167 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
2174 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
2168 exceptions, which now raise PendingDeprecationWarnings in Python
2175 exceptions, which now raise PendingDeprecationWarnings in Python
2169 2.3. There were some in Magic and some in Gnuplot2.
2176 2.3. There were some in Magic and some in Gnuplot2.
2170
2177
2171 2003-06-30 Fernando Perez <fperez@colorado.edu>
2178 2003-06-30 Fernando Perez <fperez@colorado.edu>
2172
2179
2173 * IPython/genutils.py (page): modified to call curses only for
2180 * IPython/genutils.py (page): modified to call curses only for
2174 terminals where TERM=='xterm'. After problems under many other
2181 terminals where TERM=='xterm'. After problems under many other
2175 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2182 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2176
2183
2177 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2184 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2178 would be triggered when readline was absent. This was just an old
2185 would be triggered when readline was absent. This was just an old
2179 debugging statement I'd forgotten to take out.
2186 debugging statement I'd forgotten to take out.
2180
2187
2181 2003-06-20 Fernando Perez <fperez@colorado.edu>
2188 2003-06-20 Fernando Perez <fperez@colorado.edu>
2182
2189
2183 * IPython/genutils.py (clock): modified to return only user time
2190 * IPython/genutils.py (clock): modified to return only user time
2184 (not counting system time), after a discussion on scipy. While
2191 (not counting system time), after a discussion on scipy. While
2185 system time may be a useful quantity occasionally, it may much
2192 system time may be a useful quantity occasionally, it may much
2186 more easily be skewed by occasional swapping or other similar
2193 more easily be skewed by occasional swapping or other similar
2187 activity.
2194 activity.
2188
2195
2189 2003-06-05 Fernando Perez <fperez@colorado.edu>
2196 2003-06-05 Fernando Perez <fperez@colorado.edu>
2190
2197
2191 * IPython/numutils.py (identity): new function, for building
2198 * IPython/numutils.py (identity): new function, for building
2192 arbitrary rank Kronecker deltas (mostly backwards compatible with
2199 arbitrary rank Kronecker deltas (mostly backwards compatible with
2193 Numeric.identity)
2200 Numeric.identity)
2194
2201
2195 2003-06-03 Fernando Perez <fperez@colorado.edu>
2202 2003-06-03 Fernando Perez <fperez@colorado.edu>
2196
2203
2197 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2204 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2198 arguments passed to magics with spaces, to allow trailing '\' to
2205 arguments passed to magics with spaces, to allow trailing '\' to
2199 work normally (mainly for Windows users).
2206 work normally (mainly for Windows users).
2200
2207
2201 2003-05-29 Fernando Perez <fperez@colorado.edu>
2208 2003-05-29 Fernando Perez <fperez@colorado.edu>
2202
2209
2203 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2210 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2204 instead of pydoc.help. This fixes a bizarre behavior where
2211 instead of pydoc.help. This fixes a bizarre behavior where
2205 printing '%s' % locals() would trigger the help system. Now
2212 printing '%s' % locals() would trigger the help system. Now
2206 ipython behaves like normal python does.
2213 ipython behaves like normal python does.
2207
2214
2208 Note that if one does 'from pydoc import help', the bizarre
2215 Note that if one does 'from pydoc import help', the bizarre
2209 behavior returns, but this will also happen in normal python, so
2216 behavior returns, but this will also happen in normal python, so
2210 it's not an ipython bug anymore (it has to do with how pydoc.help
2217 it's not an ipython bug anymore (it has to do with how pydoc.help
2211 is implemented).
2218 is implemented).
2212
2219
2213 2003-05-22 Fernando Perez <fperez@colorado.edu>
2220 2003-05-22 Fernando Perez <fperez@colorado.edu>
2214
2221
2215 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2222 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2216 return [] instead of None when nothing matches, also match to end
2223 return [] instead of None when nothing matches, also match to end
2217 of line. Patch by Gary Bishop.
2224 of line. Patch by Gary Bishop.
2218
2225
2219 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2226 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2220 protection as before, for files passed on the command line. This
2227 protection as before, for files passed on the command line. This
2221 prevents the CrashHandler from kicking in if user files call into
2228 prevents the CrashHandler from kicking in if user files call into
2222 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2229 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2223 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2230 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2224
2231
2225 2003-05-20 *** Released version 0.4.0
2232 2003-05-20 *** Released version 0.4.0
2226
2233
2227 2003-05-20 Fernando Perez <fperez@colorado.edu>
2234 2003-05-20 Fernando Perez <fperez@colorado.edu>
2228
2235
2229 * setup.py: added support for manpages. It's a bit hackish b/c of
2236 * setup.py: added support for manpages. It's a bit hackish b/c of
2230 a bug in the way the bdist_rpm distutils target handles gzipped
2237 a bug in the way the bdist_rpm distutils target handles gzipped
2231 manpages, but it works. After a patch by Jack.
2238 manpages, but it works. After a patch by Jack.
2232
2239
2233 2003-05-19 Fernando Perez <fperez@colorado.edu>
2240 2003-05-19 Fernando Perez <fperez@colorado.edu>
2234
2241
2235 * IPython/numutils.py: added a mockup of the kinds module, since
2242 * IPython/numutils.py: added a mockup of the kinds module, since
2236 it was recently removed from Numeric. This way, numutils will
2243 it was recently removed from Numeric. This way, numutils will
2237 work for all users even if they are missing kinds.
2244 work for all users even if they are missing kinds.
2238
2245
2239 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2246 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2240 failure, which can occur with SWIG-wrapped extensions. After a
2247 failure, which can occur with SWIG-wrapped extensions. After a
2241 crash report from Prabhu.
2248 crash report from Prabhu.
2242
2249
2243 2003-05-16 Fernando Perez <fperez@colorado.edu>
2250 2003-05-16 Fernando Perez <fperez@colorado.edu>
2244
2251
2245 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2252 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2246 protect ipython from user code which may call directly
2253 protect ipython from user code which may call directly
2247 sys.excepthook (this looks like an ipython crash to the user, even
2254 sys.excepthook (this looks like an ipython crash to the user, even
2248 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2255 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2249 This is especially important to help users of WxWindows, but may
2256 This is especially important to help users of WxWindows, but may
2250 also be useful in other cases.
2257 also be useful in other cases.
2251
2258
2252 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2259 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2253 an optional tb_offset to be specified, and to preserve exception
2260 an optional tb_offset to be specified, and to preserve exception
2254 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2261 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2255
2262
2256 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2263 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2257
2264
2258 2003-05-15 Fernando Perez <fperez@colorado.edu>
2265 2003-05-15 Fernando Perez <fperez@colorado.edu>
2259
2266
2260 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2267 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2261 installing for a new user under Windows.
2268 installing for a new user under Windows.
2262
2269
2263 2003-05-12 Fernando Perez <fperez@colorado.edu>
2270 2003-05-12 Fernando Perez <fperez@colorado.edu>
2264
2271
2265 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2272 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2266 handler for Emacs comint-based lines. Currently it doesn't do
2273 handler for Emacs comint-based lines. Currently it doesn't do
2267 much (but importantly, it doesn't update the history cache). In
2274 much (but importantly, it doesn't update the history cache). In
2268 the future it may be expanded if Alex needs more functionality
2275 the future it may be expanded if Alex needs more functionality
2269 there.
2276 there.
2270
2277
2271 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2278 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2272 info to crash reports.
2279 info to crash reports.
2273
2280
2274 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2281 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2275 just like Python's -c. Also fixed crash with invalid -color
2282 just like Python's -c. Also fixed crash with invalid -color
2276 option value at startup. Thanks to Will French
2283 option value at startup. Thanks to Will French
2277 <wfrench-AT-bestweb.net> for the bug report.
2284 <wfrench-AT-bestweb.net> for the bug report.
2278
2285
2279 2003-05-09 Fernando Perez <fperez@colorado.edu>
2286 2003-05-09 Fernando Perez <fperez@colorado.edu>
2280
2287
2281 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2288 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2282 to EvalDict (it's a mapping, after all) and simplified its code
2289 to EvalDict (it's a mapping, after all) and simplified its code
2283 quite a bit, after a nice discussion on c.l.py where Gustavo
2290 quite a bit, after a nice discussion on c.l.py where Gustavo
2284 Córdova <gcordova-AT-sismex.com> suggested the new version.
2291 Córdova <gcordova-AT-sismex.com> suggested the new version.
2285
2292
2286 2003-04-30 Fernando Perez <fperez@colorado.edu>
2293 2003-04-30 Fernando Perez <fperez@colorado.edu>
2287
2294
2288 * IPython/genutils.py (timings_out): modified it to reduce its
2295 * IPython/genutils.py (timings_out): modified it to reduce its
2289 overhead in the common reps==1 case.
2296 overhead in the common reps==1 case.
2290
2297
2291 2003-04-29 Fernando Perez <fperez@colorado.edu>
2298 2003-04-29 Fernando Perez <fperez@colorado.edu>
2292
2299
2293 * IPython/genutils.py (timings_out): Modified to use the resource
2300 * IPython/genutils.py (timings_out): Modified to use the resource
2294 module, which avoids the wraparound problems of time.clock().
2301 module, which avoids the wraparound problems of time.clock().
2295
2302
2296 2003-04-17 *** Released version 0.2.15pre4
2303 2003-04-17 *** Released version 0.2.15pre4
2297
2304
2298 2003-04-17 Fernando Perez <fperez@colorado.edu>
2305 2003-04-17 Fernando Perez <fperez@colorado.edu>
2299
2306
2300 * setup.py (scriptfiles): Split windows-specific stuff over to a
2307 * setup.py (scriptfiles): Split windows-specific stuff over to a
2301 separate file, in an attempt to have a Windows GUI installer.
2308 separate file, in an attempt to have a Windows GUI installer.
2302 That didn't work, but part of the groundwork is done.
2309 That didn't work, but part of the groundwork is done.
2303
2310
2304 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2311 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2305 indent/unindent with 4 spaces. Particularly useful in combination
2312 indent/unindent with 4 spaces. Particularly useful in combination
2306 with the new auto-indent option.
2313 with the new auto-indent option.
2307
2314
2308 2003-04-16 Fernando Perez <fperez@colorado.edu>
2315 2003-04-16 Fernando Perez <fperez@colorado.edu>
2309
2316
2310 * IPython/Magic.py: various replacements of self.rc for
2317 * IPython/Magic.py: various replacements of self.rc for
2311 self.shell.rc. A lot more remains to be done to fully disentangle
2318 self.shell.rc. A lot more remains to be done to fully disentangle
2312 this class from the main Shell class.
2319 this class from the main Shell class.
2313
2320
2314 * IPython/GnuplotRuntime.py: added checks for mouse support so
2321 * IPython/GnuplotRuntime.py: added checks for mouse support so
2315 that we don't try to enable it if the current gnuplot doesn't
2322 that we don't try to enable it if the current gnuplot doesn't
2316 really support it. Also added checks so that we don't try to
2323 really support it. Also added checks so that we don't try to
2317 enable persist under Windows (where Gnuplot doesn't recognize the
2324 enable persist under Windows (where Gnuplot doesn't recognize the
2318 option).
2325 option).
2319
2326
2320 * IPython/iplib.py (InteractiveShell.interact): Added optional
2327 * IPython/iplib.py (InteractiveShell.interact): Added optional
2321 auto-indenting code, after a patch by King C. Shu
2328 auto-indenting code, after a patch by King C. Shu
2322 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2329 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2323 get along well with pasting indented code. If I ever figure out
2330 get along well with pasting indented code. If I ever figure out
2324 how to make that part go well, it will become on by default.
2331 how to make that part go well, it will become on by default.
2325
2332
2326 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2333 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2327 crash ipython if there was an unmatched '%' in the user's prompt
2334 crash ipython if there was an unmatched '%' in the user's prompt
2328 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2335 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2329
2336
2330 * IPython/iplib.py (InteractiveShell.interact): removed the
2337 * IPython/iplib.py (InteractiveShell.interact): removed the
2331 ability to ask the user whether he wants to crash or not at the
2338 ability to ask the user whether he wants to crash or not at the
2332 'last line' exception handler. Calling functions at that point
2339 'last line' exception handler. Calling functions at that point
2333 changes the stack, and the error reports would have incorrect
2340 changes the stack, and the error reports would have incorrect
2334 tracebacks.
2341 tracebacks.
2335
2342
2336 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2343 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2337 pass through a peger a pretty-printed form of any object. After a
2344 pass through a peger a pretty-printed form of any object. After a
2338 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2345 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2339
2346
2340 2003-04-14 Fernando Perez <fperez@colorado.edu>
2347 2003-04-14 Fernando Perez <fperez@colorado.edu>
2341
2348
2342 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2349 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2343 all files in ~ would be modified at first install (instead of
2350 all files in ~ would be modified at first install (instead of
2344 ~/.ipython). This could be potentially disastrous, as the
2351 ~/.ipython). This could be potentially disastrous, as the
2345 modification (make line-endings native) could damage binary files.
2352 modification (make line-endings native) could damage binary files.
2346
2353
2347 2003-04-10 Fernando Perez <fperez@colorado.edu>
2354 2003-04-10 Fernando Perez <fperez@colorado.edu>
2348
2355
2349 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2356 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2350 handle only lines which are invalid python. This now means that
2357 handle only lines which are invalid python. This now means that
2351 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2358 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2352 for the bug report.
2359 for the bug report.
2353
2360
2354 2003-04-01 Fernando Perez <fperez@colorado.edu>
2361 2003-04-01 Fernando Perez <fperez@colorado.edu>
2355
2362
2356 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2363 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2357 where failing to set sys.last_traceback would crash pdb.pm().
2364 where failing to set sys.last_traceback would crash pdb.pm().
2358 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2365 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2359 report.
2366 report.
2360
2367
2361 2003-03-25 Fernando Perez <fperez@colorado.edu>
2368 2003-03-25 Fernando Perez <fperez@colorado.edu>
2362
2369
2363 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2370 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2364 before printing it (it had a lot of spurious blank lines at the
2371 before printing it (it had a lot of spurious blank lines at the
2365 end).
2372 end).
2366
2373
2367 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2374 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2368 output would be sent 21 times! Obviously people don't use this
2375 output would be sent 21 times! Obviously people don't use this
2369 too often, or I would have heard about it.
2376 too often, or I would have heard about it.
2370
2377
2371 2003-03-24 Fernando Perez <fperez@colorado.edu>
2378 2003-03-24 Fernando Perez <fperez@colorado.edu>
2372
2379
2373 * setup.py (scriptfiles): renamed the data_files parameter from
2380 * setup.py (scriptfiles): renamed the data_files parameter from
2374 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2381 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2375 for the patch.
2382 for the patch.
2376
2383
2377 2003-03-20 Fernando Perez <fperez@colorado.edu>
2384 2003-03-20 Fernando Perez <fperez@colorado.edu>
2378
2385
2379 * IPython/genutils.py (error): added error() and fatal()
2386 * IPython/genutils.py (error): added error() and fatal()
2380 functions.
2387 functions.
2381
2388
2382 2003-03-18 *** Released version 0.2.15pre3
2389 2003-03-18 *** Released version 0.2.15pre3
2383
2390
2384 2003-03-18 Fernando Perez <fperez@colorado.edu>
2391 2003-03-18 Fernando Perez <fperez@colorado.edu>
2385
2392
2386 * setupext/install_data_ext.py
2393 * setupext/install_data_ext.py
2387 (install_data_ext.initialize_options): Class contributed by Jack
2394 (install_data_ext.initialize_options): Class contributed by Jack
2388 Moffit for fixing the old distutils hack. He is sending this to
2395 Moffit for fixing the old distutils hack. He is sending this to
2389 the distutils folks so in the future we may not need it as a
2396 the distutils folks so in the future we may not need it as a
2390 private fix.
2397 private fix.
2391
2398
2392 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2399 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2393 changes for Debian packaging. See his patch for full details.
2400 changes for Debian packaging. See his patch for full details.
2394 The old distutils hack of making the ipythonrc* files carry a
2401 The old distutils hack of making the ipythonrc* files carry a
2395 bogus .py extension is gone, at last. Examples were moved to a
2402 bogus .py extension is gone, at last. Examples were moved to a
2396 separate subdir under doc/, and the separate executable scripts
2403 separate subdir under doc/, and the separate executable scripts
2397 now live in their own directory. Overall a great cleanup. The
2404 now live in their own directory. Overall a great cleanup. The
2398 manual was updated to use the new files, and setup.py has been
2405 manual was updated to use the new files, and setup.py has been
2399 fixed for this setup.
2406 fixed for this setup.
2400
2407
2401 * IPython/PyColorize.py (Parser.usage): made non-executable and
2408 * IPython/PyColorize.py (Parser.usage): made non-executable and
2402 created a pycolor wrapper around it to be included as a script.
2409 created a pycolor wrapper around it to be included as a script.
2403
2410
2404 2003-03-12 *** Released version 0.2.15pre2
2411 2003-03-12 *** Released version 0.2.15pre2
2405
2412
2406 2003-03-12 Fernando Perez <fperez@colorado.edu>
2413 2003-03-12 Fernando Perez <fperez@colorado.edu>
2407
2414
2408 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2415 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2409 long-standing problem with garbage characters in some terminals.
2416 long-standing problem with garbage characters in some terminals.
2410 The issue was really that the \001 and \002 escapes must _only_ be
2417 The issue was really that the \001 and \002 escapes must _only_ be
2411 passed to input prompts (which call readline), but _never_ to
2418 passed to input prompts (which call readline), but _never_ to
2412 normal text to be printed on screen. I changed ColorANSI to have
2419 normal text to be printed on screen. I changed ColorANSI to have
2413 two classes: TermColors and InputTermColors, each with the
2420 two classes: TermColors and InputTermColors, each with the
2414 appropriate escapes for input prompts or normal text. The code in
2421 appropriate escapes for input prompts or normal text. The code in
2415 Prompts.py got slightly more complicated, but this very old and
2422 Prompts.py got slightly more complicated, but this very old and
2416 annoying bug is finally fixed.
2423 annoying bug is finally fixed.
2417
2424
2418 All the credit for nailing down the real origin of this problem
2425 All the credit for nailing down the real origin of this problem
2419 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2426 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2420 *Many* thanks to him for spending quite a bit of effort on this.
2427 *Many* thanks to him for spending quite a bit of effort on this.
2421
2428
2422 2003-03-05 *** Released version 0.2.15pre1
2429 2003-03-05 *** Released version 0.2.15pre1
2423
2430
2424 2003-03-03 Fernando Perez <fperez@colorado.edu>
2431 2003-03-03 Fernando Perez <fperez@colorado.edu>
2425
2432
2426 * IPython/FakeModule.py: Moved the former _FakeModule to a
2433 * IPython/FakeModule.py: Moved the former _FakeModule to a
2427 separate file, because it's also needed by Magic (to fix a similar
2434 separate file, because it's also needed by Magic (to fix a similar
2428 pickle-related issue in @run).
2435 pickle-related issue in @run).
2429
2436
2430 2003-03-02 Fernando Perez <fperez@colorado.edu>
2437 2003-03-02 Fernando Perez <fperez@colorado.edu>
2431
2438
2432 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2439 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2433 the autocall option at runtime.
2440 the autocall option at runtime.
2434 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2441 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2435 across Magic.py to start separating Magic from InteractiveShell.
2442 across Magic.py to start separating Magic from InteractiveShell.
2436 (Magic._ofind): Fixed to return proper namespace for dotted
2443 (Magic._ofind): Fixed to return proper namespace for dotted
2437 names. Before, a dotted name would always return 'not currently
2444 names. Before, a dotted name would always return 'not currently
2438 defined', because it would find the 'parent'. s.x would be found,
2445 defined', because it would find the 'parent'. s.x would be found,
2439 but since 'x' isn't defined by itself, it would get confused.
2446 but since 'x' isn't defined by itself, it would get confused.
2440 (Magic.magic_run): Fixed pickling problems reported by Ralf
2447 (Magic.magic_run): Fixed pickling problems reported by Ralf
2441 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2448 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2442 that I'd used when Mike Heeter reported similar issues at the
2449 that I'd used when Mike Heeter reported similar issues at the
2443 top-level, but now for @run. It boils down to injecting the
2450 top-level, but now for @run. It boils down to injecting the
2444 namespace where code is being executed with something that looks
2451 namespace where code is being executed with something that looks
2445 enough like a module to fool pickle.dump(). Since a pickle stores
2452 enough like a module to fool pickle.dump(). Since a pickle stores
2446 a named reference to the importing module, we need this for
2453 a named reference to the importing module, we need this for
2447 pickles to save something sensible.
2454 pickles to save something sensible.
2448
2455
2449 * IPython/ipmaker.py (make_IPython): added an autocall option.
2456 * IPython/ipmaker.py (make_IPython): added an autocall option.
2450
2457
2451 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2458 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2452 the auto-eval code. Now autocalling is an option, and the code is
2459 the auto-eval code. Now autocalling is an option, and the code is
2453 also vastly safer. There is no more eval() involved at all.
2460 also vastly safer. There is no more eval() involved at all.
2454
2461
2455 2003-03-01 Fernando Perez <fperez@colorado.edu>
2462 2003-03-01 Fernando Perez <fperez@colorado.edu>
2456
2463
2457 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2464 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2458 dict with named keys instead of a tuple.
2465 dict with named keys instead of a tuple.
2459
2466
2460 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2467 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2461
2468
2462 * setup.py (make_shortcut): Fixed message about directories
2469 * setup.py (make_shortcut): Fixed message about directories
2463 created during Windows installation (the directories were ok, just
2470 created during Windows installation (the directories were ok, just
2464 the printed message was misleading). Thanks to Chris Liechti
2471 the printed message was misleading). Thanks to Chris Liechti
2465 <cliechti-AT-gmx.net> for the heads up.
2472 <cliechti-AT-gmx.net> for the heads up.
2466
2473
2467 2003-02-21 Fernando Perez <fperez@colorado.edu>
2474 2003-02-21 Fernando Perez <fperez@colorado.edu>
2468
2475
2469 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2476 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2470 of ValueError exception when checking for auto-execution. This
2477 of ValueError exception when checking for auto-execution. This
2471 one is raised by things like Numeric arrays arr.flat when the
2478 one is raised by things like Numeric arrays arr.flat when the
2472 array is non-contiguous.
2479 array is non-contiguous.
2473
2480
2474 2003-01-31 Fernando Perez <fperez@colorado.edu>
2481 2003-01-31 Fernando Perez <fperez@colorado.edu>
2475
2482
2476 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2483 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2477 not return any value at all (even though the command would get
2484 not return any value at all (even though the command would get
2478 executed).
2485 executed).
2479 (xsys): Flush stdout right after printing the command to ensure
2486 (xsys): Flush stdout right after printing the command to ensure
2480 proper ordering of commands and command output in the total
2487 proper ordering of commands and command output in the total
2481 output.
2488 output.
2482 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2489 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2483 system/getoutput as defaults. The old ones are kept for
2490 system/getoutput as defaults. The old ones are kept for
2484 compatibility reasons, so no code which uses this library needs
2491 compatibility reasons, so no code which uses this library needs
2485 changing.
2492 changing.
2486
2493
2487 2003-01-27 *** Released version 0.2.14
2494 2003-01-27 *** Released version 0.2.14
2488
2495
2489 2003-01-25 Fernando Perez <fperez@colorado.edu>
2496 2003-01-25 Fernando Perez <fperez@colorado.edu>
2490
2497
2491 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2498 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2492 functions defined in previous edit sessions could not be re-edited
2499 functions defined in previous edit sessions could not be re-edited
2493 (because the temp files were immediately removed). Now temp files
2500 (because the temp files were immediately removed). Now temp files
2494 are removed only at IPython's exit.
2501 are removed only at IPython's exit.
2495 (Magic.magic_run): Improved @run to perform shell-like expansions
2502 (Magic.magic_run): Improved @run to perform shell-like expansions
2496 on its arguments (~users and $VARS). With this, @run becomes more
2503 on its arguments (~users and $VARS). With this, @run becomes more
2497 like a normal command-line.
2504 like a normal command-line.
2498
2505
2499 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2506 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2500 bugs related to embedding and cleaned up that code. A fairly
2507 bugs related to embedding and cleaned up that code. A fairly
2501 important one was the impossibility to access the global namespace
2508 important one was the impossibility to access the global namespace
2502 through the embedded IPython (only local variables were visible).
2509 through the embedded IPython (only local variables were visible).
2503
2510
2504 2003-01-14 Fernando Perez <fperez@colorado.edu>
2511 2003-01-14 Fernando Perez <fperez@colorado.edu>
2505
2512
2506 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
2513 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
2507 auto-calling to be a bit more conservative. Now it doesn't get
2514 auto-calling to be a bit more conservative. Now it doesn't get
2508 triggered if any of '!=()<>' are in the rest of the input line, to
2515 triggered if any of '!=()<>' are in the rest of the input line, to
2509 allow comparing callables. Thanks to Alex for the heads up.
2516 allow comparing callables. Thanks to Alex for the heads up.
2510
2517
2511 2003-01-07 Fernando Perez <fperez@colorado.edu>
2518 2003-01-07 Fernando Perez <fperez@colorado.edu>
2512
2519
2513 * IPython/genutils.py (page): fixed estimation of the number of
2520 * IPython/genutils.py (page): fixed estimation of the number of
2514 lines in a string to be paged to simply count newlines. This
2521 lines in a string to be paged to simply count newlines. This
2515 prevents over-guessing due to embedded escape sequences. A better
2522 prevents over-guessing due to embedded escape sequences. A better
2516 long-term solution would involve stripping out the control chars
2523 long-term solution would involve stripping out the control chars
2517 for the count, but it's potentially so expensive I just don't
2524 for the count, but it's potentially so expensive I just don't
2518 think it's worth doing.
2525 think it's worth doing.
2519
2526
2520 2002-12-19 *** Released version 0.2.14pre50
2527 2002-12-19 *** Released version 0.2.14pre50
2521
2528
2522 2002-12-19 Fernando Perez <fperez@colorado.edu>
2529 2002-12-19 Fernando Perez <fperez@colorado.edu>
2523
2530
2524 * tools/release (version): Changed release scripts to inform
2531 * tools/release (version): Changed release scripts to inform
2525 Andrea and build a NEWS file with a list of recent changes.
2532 Andrea and build a NEWS file with a list of recent changes.
2526
2533
2527 * IPython/ColorANSI.py (__all__): changed terminal detection
2534 * IPython/ColorANSI.py (__all__): changed terminal detection
2528 code. Seems to work better for xterms without breaking
2535 code. Seems to work better for xterms without breaking
2529 konsole. Will need more testing to determine if WinXP and Mac OSX
2536 konsole. Will need more testing to determine if WinXP and Mac OSX
2530 also work ok.
2537 also work ok.
2531
2538
2532 2002-12-18 *** Released version 0.2.14pre49
2539 2002-12-18 *** Released version 0.2.14pre49
2533
2540
2534 2002-12-18 Fernando Perez <fperez@colorado.edu>
2541 2002-12-18 Fernando Perez <fperez@colorado.edu>
2535
2542
2536 * Docs: added new info about Mac OSX, from Andrea.
2543 * Docs: added new info about Mac OSX, from Andrea.
2537
2544
2538 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
2545 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
2539 allow direct plotting of python strings whose format is the same
2546 allow direct plotting of python strings whose format is the same
2540 of gnuplot data files.
2547 of gnuplot data files.
2541
2548
2542 2002-12-16 Fernando Perez <fperez@colorado.edu>
2549 2002-12-16 Fernando Perez <fperez@colorado.edu>
2543
2550
2544 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
2551 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
2545 value of exit question to be acknowledged.
2552 value of exit question to be acknowledged.
2546
2553
2547 2002-12-03 Fernando Perez <fperez@colorado.edu>
2554 2002-12-03 Fernando Perez <fperez@colorado.edu>
2548
2555
2549 * IPython/ipmaker.py: removed generators, which had been added
2556 * IPython/ipmaker.py: removed generators, which had been added
2550 by mistake in an earlier debugging run. This was causing trouble
2557 by mistake in an earlier debugging run. This was causing trouble
2551 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
2558 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
2552 for pointing this out.
2559 for pointing this out.
2553
2560
2554 2002-11-17 Fernando Perez <fperez@colorado.edu>
2561 2002-11-17 Fernando Perez <fperez@colorado.edu>
2555
2562
2556 * Manual: updated the Gnuplot section.
2563 * Manual: updated the Gnuplot section.
2557
2564
2558 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
2565 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
2559 a much better split of what goes in Runtime and what goes in
2566 a much better split of what goes in Runtime and what goes in
2560 Interactive.
2567 Interactive.
2561
2568
2562 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
2569 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
2563 being imported from iplib.
2570 being imported from iplib.
2564
2571
2565 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
2572 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
2566 for command-passing. Now the global Gnuplot instance is called
2573 for command-passing. Now the global Gnuplot instance is called
2567 'gp' instead of 'g', which was really a far too fragile and
2574 'gp' instead of 'g', which was really a far too fragile and
2568 common name.
2575 common name.
2569
2576
2570 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
2577 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
2571 bounding boxes generated by Gnuplot for square plots.
2578 bounding boxes generated by Gnuplot for square plots.
2572
2579
2573 * IPython/genutils.py (popkey): new function added. I should
2580 * IPython/genutils.py (popkey): new function added. I should
2574 suggest this on c.l.py as a dict method, it seems useful.
2581 suggest this on c.l.py as a dict method, it seems useful.
2575
2582
2576 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
2583 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
2577 to transparently handle PostScript generation. MUCH better than
2584 to transparently handle PostScript generation. MUCH better than
2578 the previous plot_eps/replot_eps (which I removed now). The code
2585 the previous plot_eps/replot_eps (which I removed now). The code
2579 is also fairly clean and well documented now (including
2586 is also fairly clean and well documented now (including
2580 docstrings).
2587 docstrings).
2581
2588
2582 2002-11-13 Fernando Perez <fperez@colorado.edu>
2589 2002-11-13 Fernando Perez <fperez@colorado.edu>
2583
2590
2584 * IPython/Magic.py (Magic.magic_edit): fixed docstring
2591 * IPython/Magic.py (Magic.magic_edit): fixed docstring
2585 (inconsistent with options).
2592 (inconsistent with options).
2586
2593
2587 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
2594 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
2588 manually disabled, I don't know why. Fixed it.
2595 manually disabled, I don't know why. Fixed it.
2589 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
2596 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
2590 eps output.
2597 eps output.
2591
2598
2592 2002-11-12 Fernando Perez <fperez@colorado.edu>
2599 2002-11-12 Fernando Perez <fperez@colorado.edu>
2593
2600
2594 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
2601 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
2595 don't propagate up to caller. Fixes crash reported by François
2602 don't propagate up to caller. Fixes crash reported by François
2596 Pinard.
2603 Pinard.
2597
2604
2598 2002-11-09 Fernando Perez <fperez@colorado.edu>
2605 2002-11-09 Fernando Perez <fperez@colorado.edu>
2599
2606
2600 * IPython/ipmaker.py (make_IPython): fixed problem with writing
2607 * IPython/ipmaker.py (make_IPython): fixed problem with writing
2601 history file for new users.
2608 history file for new users.
2602 (make_IPython): fixed bug where initial install would leave the
2609 (make_IPython): fixed bug where initial install would leave the
2603 user running in the .ipython dir.
2610 user running in the .ipython dir.
2604 (make_IPython): fixed bug where config dir .ipython would be
2611 (make_IPython): fixed bug where config dir .ipython would be
2605 created regardless of the given -ipythondir option. Thanks to Cory
2612 created regardless of the given -ipythondir option. Thanks to Cory
2606 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
2613 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
2607
2614
2608 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
2615 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
2609 type confirmations. Will need to use it in all of IPython's code
2616 type confirmations. Will need to use it in all of IPython's code
2610 consistently.
2617 consistently.
2611
2618
2612 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
2619 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
2613 context to print 31 lines instead of the default 5. This will make
2620 context to print 31 lines instead of the default 5. This will make
2614 the crash reports extremely detailed in case the problem is in
2621 the crash reports extremely detailed in case the problem is in
2615 libraries I don't have access to.
2622 libraries I don't have access to.
2616
2623
2617 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
2624 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
2618 line of defense' code to still crash, but giving users fair
2625 line of defense' code to still crash, but giving users fair
2619 warning. I don't want internal errors to go unreported: if there's
2626 warning. I don't want internal errors to go unreported: if there's
2620 an internal problem, IPython should crash and generate a full
2627 an internal problem, IPython should crash and generate a full
2621 report.
2628 report.
2622
2629
2623 2002-11-08 Fernando Perez <fperez@colorado.edu>
2630 2002-11-08 Fernando Perez <fperez@colorado.edu>
2624
2631
2625 * IPython/iplib.py (InteractiveShell.interact): added code to trap
2632 * IPython/iplib.py (InteractiveShell.interact): added code to trap
2626 otherwise uncaught exceptions which can appear if people set
2633 otherwise uncaught exceptions which can appear if people set
2627 sys.stdout to something badly broken. Thanks to a crash report
2634 sys.stdout to something badly broken. Thanks to a crash report
2628 from henni-AT-mail.brainbot.com.
2635 from henni-AT-mail.brainbot.com.
2629
2636
2630 2002-11-04 Fernando Perez <fperez@colorado.edu>
2637 2002-11-04 Fernando Perez <fperez@colorado.edu>
2631
2638
2632 * IPython/iplib.py (InteractiveShell.interact): added
2639 * IPython/iplib.py (InteractiveShell.interact): added
2633 __IPYTHON__active to the builtins. It's a flag which goes on when
2640 __IPYTHON__active to the builtins. It's a flag which goes on when
2634 the interaction starts and goes off again when it stops. This
2641 the interaction starts and goes off again when it stops. This
2635 allows embedding code to detect being inside IPython. Before this
2642 allows embedding code to detect being inside IPython. Before this
2636 was done via __IPYTHON__, but that only shows that an IPython
2643 was done via __IPYTHON__, but that only shows that an IPython
2637 instance has been created.
2644 instance has been created.
2638
2645
2639 * IPython/Magic.py (Magic.magic_env): I realized that in a
2646 * IPython/Magic.py (Magic.magic_env): I realized that in a
2640 UserDict, instance.data holds the data as a normal dict. So I
2647 UserDict, instance.data holds the data as a normal dict. So I
2641 modified @env to return os.environ.data instead of rebuilding a
2648 modified @env to return os.environ.data instead of rebuilding a
2642 dict by hand.
2649 dict by hand.
2643
2650
2644 2002-11-02 Fernando Perez <fperez@colorado.edu>
2651 2002-11-02 Fernando Perez <fperez@colorado.edu>
2645
2652
2646 * IPython/genutils.py (warn): changed so that level 1 prints no
2653 * IPython/genutils.py (warn): changed so that level 1 prints no
2647 header. Level 2 is now the default (with 'WARNING' header, as
2654 header. Level 2 is now the default (with 'WARNING' header, as
2648 before). I think I tracked all places where changes were needed in
2655 before). I think I tracked all places where changes were needed in
2649 IPython, but outside code using the old level numbering may have
2656 IPython, but outside code using the old level numbering may have
2650 broken.
2657 broken.
2651
2658
2652 * IPython/iplib.py (InteractiveShell.runcode): added this to
2659 * IPython/iplib.py (InteractiveShell.runcode): added this to
2653 handle the tracebacks in SystemExit traps correctly. The previous
2660 handle the tracebacks in SystemExit traps correctly. The previous
2654 code (through interact) was printing more of the stack than
2661 code (through interact) was printing more of the stack than
2655 necessary, showing IPython internal code to the user.
2662 necessary, showing IPython internal code to the user.
2656
2663
2657 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
2664 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
2658 default. Now that the default at the confirmation prompt is yes,
2665 default. Now that the default at the confirmation prompt is yes,
2659 it's not so intrusive. François' argument that ipython sessions
2666 it's not so intrusive. François' argument that ipython sessions
2660 tend to be complex enough not to lose them from an accidental C-d,
2667 tend to be complex enough not to lose them from an accidental C-d,
2661 is a valid one.
2668 is a valid one.
2662
2669
2663 * IPython/iplib.py (InteractiveShell.interact): added a
2670 * IPython/iplib.py (InteractiveShell.interact): added a
2664 showtraceback() call to the SystemExit trap, and modified the exit
2671 showtraceback() call to the SystemExit trap, and modified the exit
2665 confirmation to have yes as the default.
2672 confirmation to have yes as the default.
2666
2673
2667 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
2674 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
2668 this file. It's been gone from the code for a long time, this was
2675 this file. It's been gone from the code for a long time, this was
2669 simply leftover junk.
2676 simply leftover junk.
2670
2677
2671 2002-11-01 Fernando Perez <fperez@colorado.edu>
2678 2002-11-01 Fernando Perez <fperez@colorado.edu>
2672
2679
2673 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
2680 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
2674 added. If set, IPython now traps EOF and asks for
2681 added. If set, IPython now traps EOF and asks for
2675 confirmation. After a request by François Pinard.
2682 confirmation. After a request by François Pinard.
2676
2683
2677 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
2684 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
2678 of @abort, and with a new (better) mechanism for handling the
2685 of @abort, and with a new (better) mechanism for handling the
2679 exceptions.
2686 exceptions.
2680
2687
2681 2002-10-27 Fernando Perez <fperez@colorado.edu>
2688 2002-10-27 Fernando Perez <fperez@colorado.edu>
2682
2689
2683 * IPython/usage.py (__doc__): updated the --help information and
2690 * IPython/usage.py (__doc__): updated the --help information and
2684 the ipythonrc file to indicate that -log generates
2691 the ipythonrc file to indicate that -log generates
2685 ./ipython.log. Also fixed the corresponding info in @logstart.
2692 ./ipython.log. Also fixed the corresponding info in @logstart.
2686 This and several other fixes in the manuals thanks to reports by
2693 This and several other fixes in the manuals thanks to reports by
2687 François Pinard <pinard-AT-iro.umontreal.ca>.
2694 François Pinard <pinard-AT-iro.umontreal.ca>.
2688
2695
2689 * IPython/Logger.py (Logger.switch_log): Fixed error message to
2696 * IPython/Logger.py (Logger.switch_log): Fixed error message to
2690 refer to @logstart (instead of @log, which doesn't exist).
2697 refer to @logstart (instead of @log, which doesn't exist).
2691
2698
2692 * IPython/iplib.py (InteractiveShell._prefilter): fixed
2699 * IPython/iplib.py (InteractiveShell._prefilter): fixed
2693 AttributeError crash. Thanks to Christopher Armstrong
2700 AttributeError crash. Thanks to Christopher Armstrong
2694 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
2701 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
2695 introduced recently (in 0.2.14pre37) with the fix to the eval
2702 introduced recently (in 0.2.14pre37) with the fix to the eval
2696 problem mentioned below.
2703 problem mentioned below.
2697
2704
2698 2002-10-17 Fernando Perez <fperez@colorado.edu>
2705 2002-10-17 Fernando Perez <fperez@colorado.edu>
2699
2706
2700 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
2707 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
2701 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
2708 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
2702
2709
2703 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
2710 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
2704 this function to fix a problem reported by Alex Schmolck. He saw
2711 this function to fix a problem reported by Alex Schmolck. He saw
2705 it with list comprehensions and generators, which were getting
2712 it with list comprehensions and generators, which were getting
2706 called twice. The real problem was an 'eval' call in testing for
2713 called twice. The real problem was an 'eval' call in testing for
2707 automagic which was evaluating the input line silently.
2714 automagic which was evaluating the input line silently.
2708
2715
2709 This is a potentially very nasty bug, if the input has side
2716 This is a potentially very nasty bug, if the input has side
2710 effects which must not be repeated. The code is much cleaner now,
2717 effects which must not be repeated. The code is much cleaner now,
2711 without any blanket 'except' left and with a regexp test for
2718 without any blanket 'except' left and with a regexp test for
2712 actual function names.
2719 actual function names.
2713
2720
2714 But an eval remains, which I'm not fully comfortable with. I just
2721 But an eval remains, which I'm not fully comfortable with. I just
2715 don't know how to find out if an expression could be a callable in
2722 don't know how to find out if an expression could be a callable in
2716 the user's namespace without doing an eval on the string. However
2723 the user's namespace without doing an eval on the string. However
2717 that string is now much more strictly checked so that no code
2724 that string is now much more strictly checked so that no code
2718 slips by, so the eval should only happen for things that can
2725 slips by, so the eval should only happen for things that can
2719 really be only function/method names.
2726 really be only function/method names.
2720
2727
2721 2002-10-15 Fernando Perez <fperez@colorado.edu>
2728 2002-10-15 Fernando Perez <fperez@colorado.edu>
2722
2729
2723 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
2730 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
2724 OSX information to main manual, removed README_Mac_OSX file from
2731 OSX information to main manual, removed README_Mac_OSX file from
2725 distribution. Also updated credits for recent additions.
2732 distribution. Also updated credits for recent additions.
2726
2733
2727 2002-10-10 Fernando Perez <fperez@colorado.edu>
2734 2002-10-10 Fernando Perez <fperez@colorado.edu>
2728
2735
2729 * README_Mac_OSX: Added a README for Mac OSX users for fixing
2736 * README_Mac_OSX: Added a README for Mac OSX users for fixing
2730 terminal-related issues. Many thanks to Andrea Riciputi
2737 terminal-related issues. Many thanks to Andrea Riciputi
2731 <andrea.riciputi-AT-libero.it> for writing it.
2738 <andrea.riciputi-AT-libero.it> for writing it.
2732
2739
2733 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
2740 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
2734 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2741 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2735
2742
2736 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
2743 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
2737 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
2744 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
2738 <syver-en-AT-online.no> who both submitted patches for this problem.
2745 <syver-en-AT-online.no> who both submitted patches for this problem.
2739
2746
2740 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
2747 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
2741 global embedding to make sure that things don't overwrite user
2748 global embedding to make sure that things don't overwrite user
2742 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
2749 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
2743
2750
2744 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
2751 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
2745 compatibility. Thanks to Hayden Callow
2752 compatibility. Thanks to Hayden Callow
2746 <h.callow-AT-elec.canterbury.ac.nz>
2753 <h.callow-AT-elec.canterbury.ac.nz>
2747
2754
2748 2002-10-04 Fernando Perez <fperez@colorado.edu>
2755 2002-10-04 Fernando Perez <fperez@colorado.edu>
2749
2756
2750 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
2757 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
2751 Gnuplot.File objects.
2758 Gnuplot.File objects.
2752
2759
2753 2002-07-23 Fernando Perez <fperez@colorado.edu>
2760 2002-07-23 Fernando Perez <fperez@colorado.edu>
2754
2761
2755 * IPython/genutils.py (timing): Added timings() and timing() for
2762 * IPython/genutils.py (timing): Added timings() and timing() for
2756 quick access to the most commonly needed data, the execution
2763 quick access to the most commonly needed data, the execution
2757 times. Old timing() renamed to timings_out().
2764 times. Old timing() renamed to timings_out().
2758
2765
2759 2002-07-18 Fernando Perez <fperez@colorado.edu>
2766 2002-07-18 Fernando Perez <fperez@colorado.edu>
2760
2767
2761 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
2768 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
2762 bug with nested instances disrupting the parent's tab completion.
2769 bug with nested instances disrupting the parent's tab completion.
2763
2770
2764 * IPython/iplib.py (all_completions): Added Alex Schmolck's
2771 * IPython/iplib.py (all_completions): Added Alex Schmolck's
2765 all_completions code to begin the emacs integration.
2772 all_completions code to begin the emacs integration.
2766
2773
2767 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
2774 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
2768 argument to allow titling individual arrays when plotting.
2775 argument to allow titling individual arrays when plotting.
2769
2776
2770 2002-07-15 Fernando Perez <fperez@colorado.edu>
2777 2002-07-15 Fernando Perez <fperez@colorado.edu>
2771
2778
2772 * setup.py (make_shortcut): changed to retrieve the value of
2779 * setup.py (make_shortcut): changed to retrieve the value of
2773 'Program Files' directory from the registry (this value changes in
2780 'Program Files' directory from the registry (this value changes in
2774 non-english versions of Windows). Thanks to Thomas Fanslau
2781 non-english versions of Windows). Thanks to Thomas Fanslau
2775 <tfanslau-AT-gmx.de> for the report.
2782 <tfanslau-AT-gmx.de> for the report.
2776
2783
2777 2002-07-10 Fernando Perez <fperez@colorado.edu>
2784 2002-07-10 Fernando Perez <fperez@colorado.edu>
2778
2785
2779 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
2786 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
2780 a bug in pdb, which crashes if a line with only whitespace is
2787 a bug in pdb, which crashes if a line with only whitespace is
2781 entered. Bug report submitted to sourceforge.
2788 entered. Bug report submitted to sourceforge.
2782
2789
2783 2002-07-09 Fernando Perez <fperez@colorado.edu>
2790 2002-07-09 Fernando Perez <fperez@colorado.edu>
2784
2791
2785 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
2792 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
2786 reporting exceptions (it's a bug in inspect.py, I just set a
2793 reporting exceptions (it's a bug in inspect.py, I just set a
2787 workaround).
2794 workaround).
2788
2795
2789 2002-07-08 Fernando Perez <fperez@colorado.edu>
2796 2002-07-08 Fernando Perez <fperez@colorado.edu>
2790
2797
2791 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
2798 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
2792 __IPYTHON__ in __builtins__ to show up in user_ns.
2799 __IPYTHON__ in __builtins__ to show up in user_ns.
2793
2800
2794 2002-07-03 Fernando Perez <fperez@colorado.edu>
2801 2002-07-03 Fernando Perez <fperez@colorado.edu>
2795
2802
2796 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
2803 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
2797 name from @gp_set_instance to @gp_set_default.
2804 name from @gp_set_instance to @gp_set_default.
2798
2805
2799 * IPython/ipmaker.py (make_IPython): default editor value set to
2806 * IPython/ipmaker.py (make_IPython): default editor value set to
2800 '0' (a string), to match the rc file. Otherwise will crash when
2807 '0' (a string), to match the rc file. Otherwise will crash when
2801 .strip() is called on it.
2808 .strip() is called on it.
2802
2809
2803
2810
2804 2002-06-28 Fernando Perez <fperez@colorado.edu>
2811 2002-06-28 Fernando Perez <fperez@colorado.edu>
2805
2812
2806 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
2813 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
2807 of files in current directory when a file is executed via
2814 of files in current directory when a file is executed via
2808 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
2815 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
2809
2816
2810 * setup.py (manfiles): fix for rpm builds, submitted by RA
2817 * setup.py (manfiles): fix for rpm builds, submitted by RA
2811 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
2818 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
2812
2819
2813 * IPython/ipmaker.py (make_IPython): fixed lookup of default
2820 * IPython/ipmaker.py (make_IPython): fixed lookup of default
2814 editor when set to '0'. Problem was, '0' evaluates to True (it's a
2821 editor when set to '0'. Problem was, '0' evaluates to True (it's a
2815 string!). A. Schmolck caught this one.
2822 string!). A. Schmolck caught this one.
2816
2823
2817 2002-06-27 Fernando Perez <fperez@colorado.edu>
2824 2002-06-27 Fernando Perez <fperez@colorado.edu>
2818
2825
2819 * IPython/ipmaker.py (make_IPython): fixed bug when running user
2826 * IPython/ipmaker.py (make_IPython): fixed bug when running user
2820 defined files at the cmd line. __name__ wasn't being set to
2827 defined files at the cmd line. __name__ wasn't being set to
2821 __main__.
2828 __main__.
2822
2829
2823 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
2830 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
2824 regular lists and tuples besides Numeric arrays.
2831 regular lists and tuples besides Numeric arrays.
2825
2832
2826 * IPython/Prompts.py (CachedOutput.__call__): Added output
2833 * IPython/Prompts.py (CachedOutput.__call__): Added output
2827 supression for input ending with ';'. Similar to Mathematica and
2834 supression for input ending with ';'. Similar to Mathematica and
2828 Matlab. The _* vars and Out[] list are still updated, just like
2835 Matlab. The _* vars and Out[] list are still updated, just like
2829 Mathematica behaves.
2836 Mathematica behaves.
2830
2837
2831 2002-06-25 Fernando Perez <fperez@colorado.edu>
2838 2002-06-25 Fernando Perez <fperez@colorado.edu>
2832
2839
2833 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
2840 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
2834 .ini extensions for profiels under Windows.
2841 .ini extensions for profiels under Windows.
2835
2842
2836 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
2843 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
2837 string form. Fix contributed by Alexander Schmolck
2844 string form. Fix contributed by Alexander Schmolck
2838 <a.schmolck-AT-gmx.net>
2845 <a.schmolck-AT-gmx.net>
2839
2846
2840 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
2847 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
2841 pre-configured Gnuplot instance.
2848 pre-configured Gnuplot instance.
2842
2849
2843 2002-06-21 Fernando Perez <fperez@colorado.edu>
2850 2002-06-21 Fernando Perez <fperez@colorado.edu>
2844
2851
2845 * IPython/numutils.py (exp_safe): new function, works around the
2852 * IPython/numutils.py (exp_safe): new function, works around the
2846 underflow problems in Numeric.
2853 underflow problems in Numeric.
2847 (log2): New fn. Safe log in base 2: returns exact integer answer
2854 (log2): New fn. Safe log in base 2: returns exact integer answer
2848 for exact integer powers of 2.
2855 for exact integer powers of 2.
2849
2856
2850 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
2857 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
2851 properly.
2858 properly.
2852
2859
2853 2002-06-20 Fernando Perez <fperez@colorado.edu>
2860 2002-06-20 Fernando Perez <fperez@colorado.edu>
2854
2861
2855 * IPython/genutils.py (timing): new function like
2862 * IPython/genutils.py (timing): new function like
2856 Mathematica's. Similar to time_test, but returns more info.
2863 Mathematica's. Similar to time_test, but returns more info.
2857
2864
2858 2002-06-18 Fernando Perez <fperez@colorado.edu>
2865 2002-06-18 Fernando Perez <fperez@colorado.edu>
2859
2866
2860 * IPython/Magic.py (Magic.magic_save): modified @save and @r
2867 * IPython/Magic.py (Magic.magic_save): modified @save and @r
2861 according to Mike Heeter's suggestions.
2868 according to Mike Heeter's suggestions.
2862
2869
2863 2002-06-16 Fernando Perez <fperez@colorado.edu>
2870 2002-06-16 Fernando Perez <fperez@colorado.edu>
2864
2871
2865 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
2872 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
2866 system. GnuplotMagic is gone as a user-directory option. New files
2873 system. GnuplotMagic is gone as a user-directory option. New files
2867 make it easier to use all the gnuplot stuff both from external
2874 make it easier to use all the gnuplot stuff both from external
2868 programs as well as from IPython. Had to rewrite part of
2875 programs as well as from IPython. Had to rewrite part of
2869 hardcopy() b/c of a strange bug: often the ps files simply don't
2876 hardcopy() b/c of a strange bug: often the ps files simply don't
2870 get created, and require a repeat of the command (often several
2877 get created, and require a repeat of the command (often several
2871 times).
2878 times).
2872
2879
2873 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
2880 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
2874 resolve output channel at call time, so that if sys.stderr has
2881 resolve output channel at call time, so that if sys.stderr has
2875 been redirected by user this gets honored.
2882 been redirected by user this gets honored.
2876
2883
2877 2002-06-13 Fernando Perez <fperez@colorado.edu>
2884 2002-06-13 Fernando Perez <fperez@colorado.edu>
2878
2885
2879 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
2886 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
2880 IPShell. Kept a copy with the old names to avoid breaking people's
2887 IPShell. Kept a copy with the old names to avoid breaking people's
2881 embedded code.
2888 embedded code.
2882
2889
2883 * IPython/ipython: simplified it to the bare minimum after
2890 * IPython/ipython: simplified it to the bare minimum after
2884 Holger's suggestions. Added info about how to use it in
2891 Holger's suggestions. Added info about how to use it in
2885 PYTHONSTARTUP.
2892 PYTHONSTARTUP.
2886
2893
2887 * IPython/Shell.py (IPythonShell): changed the options passing
2894 * IPython/Shell.py (IPythonShell): changed the options passing
2888 from a string with funky %s replacements to a straight list. Maybe
2895 from a string with funky %s replacements to a straight list. Maybe
2889 a bit more typing, but it follows sys.argv conventions, so there's
2896 a bit more typing, but it follows sys.argv conventions, so there's
2890 less special-casing to remember.
2897 less special-casing to remember.
2891
2898
2892 2002-06-12 Fernando Perez <fperez@colorado.edu>
2899 2002-06-12 Fernando Perez <fperez@colorado.edu>
2893
2900
2894 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
2901 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
2895 command. Thanks to a suggestion by Mike Heeter.
2902 command. Thanks to a suggestion by Mike Heeter.
2896 (Magic.magic_pfile): added behavior to look at filenames if given
2903 (Magic.magic_pfile): added behavior to look at filenames if given
2897 arg is not a defined object.
2904 arg is not a defined object.
2898 (Magic.magic_save): New @save function to save code snippets. Also
2905 (Magic.magic_save): New @save function to save code snippets. Also
2899 a Mike Heeter idea.
2906 a Mike Heeter idea.
2900
2907
2901 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
2908 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
2902 plot() and replot(). Much more convenient now, especially for
2909 plot() and replot(). Much more convenient now, especially for
2903 interactive use.
2910 interactive use.
2904
2911
2905 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
2912 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
2906 filenames.
2913 filenames.
2907
2914
2908 2002-06-02 Fernando Perez <fperez@colorado.edu>
2915 2002-06-02 Fernando Perez <fperez@colorado.edu>
2909
2916
2910 * IPython/Struct.py (Struct.__init__): modified to admit
2917 * IPython/Struct.py (Struct.__init__): modified to admit
2911 initialization via another struct.
2918 initialization via another struct.
2912
2919
2913 * IPython/genutils.py (SystemExec.__init__): New stateful
2920 * IPython/genutils.py (SystemExec.__init__): New stateful
2914 interface to xsys and bq. Useful for writing system scripts.
2921 interface to xsys and bq. Useful for writing system scripts.
2915
2922
2916 2002-05-30 Fernando Perez <fperez@colorado.edu>
2923 2002-05-30 Fernando Perez <fperez@colorado.edu>
2917
2924
2918 * MANIFEST.in: Changed docfile selection to exclude all the lyx
2925 * MANIFEST.in: Changed docfile selection to exclude all the lyx
2919 documents. This will make the user download smaller (it's getting
2926 documents. This will make the user download smaller (it's getting
2920 too big).
2927 too big).
2921
2928
2922 2002-05-29 Fernando Perez <fperez@colorado.edu>
2929 2002-05-29 Fernando Perez <fperez@colorado.edu>
2923
2930
2924 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
2931 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
2925 fix problems with shelve and pickle. Seems to work, but I don't
2932 fix problems with shelve and pickle. Seems to work, but I don't
2926 know if corner cases break it. Thanks to Mike Heeter
2933 know if corner cases break it. Thanks to Mike Heeter
2927 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
2934 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
2928
2935
2929 2002-05-24 Fernando Perez <fperez@colorado.edu>
2936 2002-05-24 Fernando Perez <fperez@colorado.edu>
2930
2937
2931 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
2938 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
2932 macros having broken.
2939 macros having broken.
2933
2940
2934 2002-05-21 Fernando Perez <fperez@colorado.edu>
2941 2002-05-21 Fernando Perez <fperez@colorado.edu>
2935
2942
2936 * IPython/Magic.py (Magic.magic_logstart): fixed recently
2943 * IPython/Magic.py (Magic.magic_logstart): fixed recently
2937 introduced logging bug: all history before logging started was
2944 introduced logging bug: all history before logging started was
2938 being written one character per line! This came from the redesign
2945 being written one character per line! This came from the redesign
2939 of the input history as a special list which slices to strings,
2946 of the input history as a special list which slices to strings,
2940 not to lists.
2947 not to lists.
2941
2948
2942 2002-05-20 Fernando Perez <fperez@colorado.edu>
2949 2002-05-20 Fernando Perez <fperez@colorado.edu>
2943
2950
2944 * IPython/Prompts.py (CachedOutput.__init__): made the color table
2951 * IPython/Prompts.py (CachedOutput.__init__): made the color table
2945 be an attribute of all classes in this module. The design of these
2952 be an attribute of all classes in this module. The design of these
2946 classes needs some serious overhauling.
2953 classes needs some serious overhauling.
2947
2954
2948 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
2955 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
2949 which was ignoring '_' in option names.
2956 which was ignoring '_' in option names.
2950
2957
2951 * IPython/ultraTB.py (FormattedTB.__init__): Changed
2958 * IPython/ultraTB.py (FormattedTB.__init__): Changed
2952 'Verbose_novars' to 'Context' and made it the new default. It's a
2959 'Verbose_novars' to 'Context' and made it the new default. It's a
2953 bit more readable and also safer than verbose.
2960 bit more readable and also safer than verbose.
2954
2961
2955 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
2962 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
2956 triple-quoted strings.
2963 triple-quoted strings.
2957
2964
2958 * IPython/OInspect.py (__all__): new module exposing the object
2965 * IPython/OInspect.py (__all__): new module exposing the object
2959 introspection facilities. Now the corresponding magics are dummy
2966 introspection facilities. Now the corresponding magics are dummy
2960 wrappers around this. Having this module will make it much easier
2967 wrappers around this. Having this module will make it much easier
2961 to put these functions into our modified pdb.
2968 to put these functions into our modified pdb.
2962 This new object inspector system uses the new colorizing module,
2969 This new object inspector system uses the new colorizing module,
2963 so source code and other things are nicely syntax highlighted.
2970 so source code and other things are nicely syntax highlighted.
2964
2971
2965 2002-05-18 Fernando Perez <fperez@colorado.edu>
2972 2002-05-18 Fernando Perez <fperez@colorado.edu>
2966
2973
2967 * IPython/ColorANSI.py: Split the coloring tools into a separate
2974 * IPython/ColorANSI.py: Split the coloring tools into a separate
2968 module so I can use them in other code easier (they were part of
2975 module so I can use them in other code easier (they were part of
2969 ultraTB).
2976 ultraTB).
2970
2977
2971 2002-05-17 Fernando Perez <fperez@colorado.edu>
2978 2002-05-17 Fernando Perez <fperez@colorado.edu>
2972
2979
2973 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
2980 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
2974 fixed it to set the global 'g' also to the called instance, as
2981 fixed it to set the global 'g' also to the called instance, as
2975 long as 'g' was still a gnuplot instance (so it doesn't overwrite
2982 long as 'g' was still a gnuplot instance (so it doesn't overwrite
2976 user's 'g' variables).
2983 user's 'g' variables).
2977
2984
2978 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
2985 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
2979 global variables (aliases to _ih,_oh) so that users which expect
2986 global variables (aliases to _ih,_oh) so that users which expect
2980 In[5] or Out[7] to work aren't unpleasantly surprised.
2987 In[5] or Out[7] to work aren't unpleasantly surprised.
2981 (InputList.__getslice__): new class to allow executing slices of
2988 (InputList.__getslice__): new class to allow executing slices of
2982 input history directly. Very simple class, complements the use of
2989 input history directly. Very simple class, complements the use of
2983 macros.
2990 macros.
2984
2991
2985 2002-05-16 Fernando Perez <fperez@colorado.edu>
2992 2002-05-16 Fernando Perez <fperez@colorado.edu>
2986
2993
2987 * setup.py (docdirbase): make doc directory be just doc/IPython
2994 * setup.py (docdirbase): make doc directory be just doc/IPython
2988 without version numbers, it will reduce clutter for users.
2995 without version numbers, it will reduce clutter for users.
2989
2996
2990 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
2997 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
2991 execfile call to prevent possible memory leak. See for details:
2998 execfile call to prevent possible memory leak. See for details:
2992 http://mail.python.org/pipermail/python-list/2002-February/088476.html
2999 http://mail.python.org/pipermail/python-list/2002-February/088476.html
2993
3000
2994 2002-05-15 Fernando Perez <fperez@colorado.edu>
3001 2002-05-15 Fernando Perez <fperez@colorado.edu>
2995
3002
2996 * IPython/Magic.py (Magic.magic_psource): made the object
3003 * IPython/Magic.py (Magic.magic_psource): made the object
2997 introspection names be more standard: pdoc, pdef, pfile and
3004 introspection names be more standard: pdoc, pdef, pfile and
2998 psource. They all print/page their output, and it makes
3005 psource. They all print/page their output, and it makes
2999 remembering them easier. Kept old names for compatibility as
3006 remembering them easier. Kept old names for compatibility as
3000 aliases.
3007 aliases.
3001
3008
3002 2002-05-14 Fernando Perez <fperez@colorado.edu>
3009 2002-05-14 Fernando Perez <fperez@colorado.edu>
3003
3010
3004 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
3011 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
3005 what the mouse problem was. The trick is to use gnuplot with temp
3012 what the mouse problem was. The trick is to use gnuplot with temp
3006 files and NOT with pipes (for data communication), because having
3013 files and NOT with pipes (for data communication), because having
3007 both pipes and the mouse on is bad news.
3014 both pipes and the mouse on is bad news.
3008
3015
3009 2002-05-13 Fernando Perez <fperez@colorado.edu>
3016 2002-05-13 Fernando Perez <fperez@colorado.edu>
3010
3017
3011 * IPython/Magic.py (Magic._ofind): fixed namespace order search
3018 * IPython/Magic.py (Magic._ofind): fixed namespace order search
3012 bug. Information would be reported about builtins even when
3019 bug. Information would be reported about builtins even when
3013 user-defined functions overrode them.
3020 user-defined functions overrode them.
3014
3021
3015 2002-05-11 Fernando Perez <fperez@colorado.edu>
3022 2002-05-11 Fernando Perez <fperez@colorado.edu>
3016
3023
3017 * IPython/__init__.py (__all__): removed FlexCompleter from
3024 * IPython/__init__.py (__all__): removed FlexCompleter from
3018 __all__ so that things don't fail in platforms without readline.
3025 __all__ so that things don't fail in platforms without readline.
3019
3026
3020 2002-05-10 Fernando Perez <fperez@colorado.edu>
3027 2002-05-10 Fernando Perez <fperez@colorado.edu>
3021
3028
3022 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
3029 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
3023 it requires Numeric, effectively making Numeric a dependency for
3030 it requires Numeric, effectively making Numeric a dependency for
3024 IPython.
3031 IPython.
3025
3032
3026 * Released 0.2.13
3033 * Released 0.2.13
3027
3034
3028 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
3035 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
3029 profiler interface. Now all the major options from the profiler
3036 profiler interface. Now all the major options from the profiler
3030 module are directly supported in IPython, both for single
3037 module are directly supported in IPython, both for single
3031 expressions (@prun) and for full programs (@run -p).
3038 expressions (@prun) and for full programs (@run -p).
3032
3039
3033 2002-05-09 Fernando Perez <fperez@colorado.edu>
3040 2002-05-09 Fernando Perez <fperez@colorado.edu>
3034
3041
3035 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
3042 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
3036 magic properly formatted for screen.
3043 magic properly formatted for screen.
3037
3044
3038 * setup.py (make_shortcut): Changed things to put pdf version in
3045 * setup.py (make_shortcut): Changed things to put pdf version in
3039 doc/ instead of doc/manual (had to change lyxport a bit).
3046 doc/ instead of doc/manual (had to change lyxport a bit).
3040
3047
3041 * IPython/Magic.py (Profile.string_stats): made profile runs go
3048 * IPython/Magic.py (Profile.string_stats): made profile runs go
3042 through pager (they are long and a pager allows searching, saving,
3049 through pager (they are long and a pager allows searching, saving,
3043 etc.)
3050 etc.)
3044
3051
3045 2002-05-08 Fernando Perez <fperez@colorado.edu>
3052 2002-05-08 Fernando Perez <fperez@colorado.edu>
3046
3053
3047 * Released 0.2.12
3054 * Released 0.2.12
3048
3055
3049 2002-05-06 Fernando Perez <fperez@colorado.edu>
3056 2002-05-06 Fernando Perez <fperez@colorado.edu>
3050
3057
3051 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
3058 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
3052 introduced); 'hist n1 n2' was broken.
3059 introduced); 'hist n1 n2' was broken.
3053 (Magic.magic_pdb): added optional on/off arguments to @pdb
3060 (Magic.magic_pdb): added optional on/off arguments to @pdb
3054 (Magic.magic_run): added option -i to @run, which executes code in
3061 (Magic.magic_run): added option -i to @run, which executes code in
3055 the IPython namespace instead of a clean one. Also added @irun as
3062 the IPython namespace instead of a clean one. Also added @irun as
3056 an alias to @run -i.
3063 an alias to @run -i.
3057
3064
3058 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3065 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3059 fixed (it didn't really do anything, the namespaces were wrong).
3066 fixed (it didn't really do anything, the namespaces were wrong).
3060
3067
3061 * IPython/Debugger.py (__init__): Added workaround for python 2.1
3068 * IPython/Debugger.py (__init__): Added workaround for python 2.1
3062
3069
3063 * IPython/__init__.py (__all__): Fixed package namespace, now
3070 * IPython/__init__.py (__all__): Fixed package namespace, now
3064 'import IPython' does give access to IPython.<all> as
3071 'import IPython' does give access to IPython.<all> as
3065 expected. Also renamed __release__ to Release.
3072 expected. Also renamed __release__ to Release.
3066
3073
3067 * IPython/Debugger.py (__license__): created new Pdb class which
3074 * IPython/Debugger.py (__license__): created new Pdb class which
3068 functions like a drop-in for the normal pdb.Pdb but does NOT
3075 functions like a drop-in for the normal pdb.Pdb but does NOT
3069 import readline by default. This way it doesn't muck up IPython's
3076 import readline by default. This way it doesn't muck up IPython's
3070 readline handling, and now tab-completion finally works in the
3077 readline handling, and now tab-completion finally works in the
3071 debugger -- sort of. It completes things globally visible, but the
3078 debugger -- sort of. It completes things globally visible, but the
3072 completer doesn't track the stack as pdb walks it. That's a bit
3079 completer doesn't track the stack as pdb walks it. That's a bit
3073 tricky, and I'll have to implement it later.
3080 tricky, and I'll have to implement it later.
3074
3081
3075 2002-05-05 Fernando Perez <fperez@colorado.edu>
3082 2002-05-05 Fernando Perez <fperez@colorado.edu>
3076
3083
3077 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
3084 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
3078 magic docstrings when printed via ? (explicit \'s were being
3085 magic docstrings when printed via ? (explicit \'s were being
3079 printed).
3086 printed).
3080
3087
3081 * IPython/ipmaker.py (make_IPython): fixed namespace
3088 * IPython/ipmaker.py (make_IPython): fixed namespace
3082 identification bug. Now variables loaded via logs or command-line
3089 identification bug. Now variables loaded via logs or command-line
3083 files are recognized in the interactive namespace by @who.
3090 files are recognized in the interactive namespace by @who.
3084
3091
3085 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
3092 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
3086 log replay system stemming from the string form of Structs.
3093 log replay system stemming from the string form of Structs.
3087
3094
3088 * IPython/Magic.py (Macro.__init__): improved macros to properly
3095 * IPython/Magic.py (Macro.__init__): improved macros to properly
3089 handle magic commands in them.
3096 handle magic commands in them.
3090 (Magic.magic_logstart): usernames are now expanded so 'logstart
3097 (Magic.magic_logstart): usernames are now expanded so 'logstart
3091 ~/mylog' now works.
3098 ~/mylog' now works.
3092
3099
3093 * IPython/iplib.py (complete): fixed bug where paths starting with
3100 * IPython/iplib.py (complete): fixed bug where paths starting with
3094 '/' would be completed as magic names.
3101 '/' would be completed as magic names.
3095
3102
3096 2002-05-04 Fernando Perez <fperez@colorado.edu>
3103 2002-05-04 Fernando Perez <fperez@colorado.edu>
3097
3104
3098 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
3105 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
3099 allow running full programs under the profiler's control.
3106 allow running full programs under the profiler's control.
3100
3107
3101 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
3108 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
3102 mode to report exceptions verbosely but without formatting
3109 mode to report exceptions verbosely but without formatting
3103 variables. This addresses the issue of ipython 'freezing' (it's
3110 variables. This addresses the issue of ipython 'freezing' (it's
3104 not frozen, but caught in an expensive formatting loop) when huge
3111 not frozen, but caught in an expensive formatting loop) when huge
3105 variables are in the context of an exception.
3112 variables are in the context of an exception.
3106 (VerboseTB.text): Added '--->' markers at line where exception was
3113 (VerboseTB.text): Added '--->' markers at line where exception was
3107 triggered. Much clearer to read, especially in NoColor modes.
3114 triggered. Much clearer to read, especially in NoColor modes.
3108
3115
3109 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
3116 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
3110 implemented in reverse when changing to the new parse_options().
3117 implemented in reverse when changing to the new parse_options().
3111
3118
3112 2002-05-03 Fernando Perez <fperez@colorado.edu>
3119 2002-05-03 Fernando Perez <fperez@colorado.edu>
3113
3120
3114 * IPython/Magic.py (Magic.parse_options): new function so that
3121 * IPython/Magic.py (Magic.parse_options): new function so that
3115 magics can parse options easier.
3122 magics can parse options easier.
3116 (Magic.magic_prun): new function similar to profile.run(),
3123 (Magic.magic_prun): new function similar to profile.run(),
3117 suggested by Chris Hart.
3124 suggested by Chris Hart.
3118 (Magic.magic_cd): fixed behavior so that it only changes if
3125 (Magic.magic_cd): fixed behavior so that it only changes if
3119 directory actually is in history.
3126 directory actually is in history.
3120
3127
3121 * IPython/usage.py (__doc__): added information about potential
3128 * IPython/usage.py (__doc__): added information about potential
3122 slowness of Verbose exception mode when there are huge data
3129 slowness of Verbose exception mode when there are huge data
3123 structures to be formatted (thanks to Archie Paulson).
3130 structures to be formatted (thanks to Archie Paulson).
3124
3131
3125 * IPython/ipmaker.py (make_IPython): Changed default logging
3132 * IPython/ipmaker.py (make_IPython): Changed default logging
3126 (when simply called with -log) to use curr_dir/ipython.log in
3133 (when simply called with -log) to use curr_dir/ipython.log in
3127 rotate mode. Fixed crash which was occuring with -log before
3134 rotate mode. Fixed crash which was occuring with -log before
3128 (thanks to Jim Boyle).
3135 (thanks to Jim Boyle).
3129
3136
3130 2002-05-01 Fernando Perez <fperez@colorado.edu>
3137 2002-05-01 Fernando Perez <fperez@colorado.edu>
3131
3138
3132 * Released 0.2.11 for these fixes (mainly the ultraTB one which
3139 * Released 0.2.11 for these fixes (mainly the ultraTB one which
3133 was nasty -- though somewhat of a corner case).
3140 was nasty -- though somewhat of a corner case).
3134
3141
3135 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
3142 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
3136 text (was a bug).
3143 text (was a bug).
3137
3144
3138 2002-04-30 Fernando Perez <fperez@colorado.edu>
3145 2002-04-30 Fernando Perez <fperez@colorado.edu>
3139
3146
3140 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
3147 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
3141 a print after ^D or ^C from the user so that the In[] prompt
3148 a print after ^D or ^C from the user so that the In[] prompt
3142 doesn't over-run the gnuplot one.
3149 doesn't over-run the gnuplot one.
3143
3150
3144 2002-04-29 Fernando Perez <fperez@colorado.edu>
3151 2002-04-29 Fernando Perez <fperez@colorado.edu>
3145
3152
3146 * Released 0.2.10
3153 * Released 0.2.10
3147
3154
3148 * IPython/__release__.py (version): get date dynamically.
3155 * IPython/__release__.py (version): get date dynamically.
3149
3156
3150 * Misc. documentation updates thanks to Arnd's comments. Also ran
3157 * Misc. documentation updates thanks to Arnd's comments. Also ran
3151 a full spellcheck on the manual (hadn't been done in a while).
3158 a full spellcheck on the manual (hadn't been done in a while).
3152
3159
3153 2002-04-27 Fernando Perez <fperez@colorado.edu>
3160 2002-04-27 Fernando Perez <fperez@colorado.edu>
3154
3161
3155 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
3162 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
3156 starting a log in mid-session would reset the input history list.
3163 starting a log in mid-session would reset the input history list.
3157
3164
3158 2002-04-26 Fernando Perez <fperez@colorado.edu>
3165 2002-04-26 Fernando Perez <fperez@colorado.edu>
3159
3166
3160 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
3167 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
3161 all files were being included in an update. Now anything in
3168 all files were being included in an update. Now anything in
3162 UserConfig that matches [A-Za-z]*.py will go (this excludes
3169 UserConfig that matches [A-Za-z]*.py will go (this excludes
3163 __init__.py)
3170 __init__.py)
3164
3171
3165 2002-04-25 Fernando Perez <fperez@colorado.edu>
3172 2002-04-25 Fernando Perez <fperez@colorado.edu>
3166
3173
3167 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
3174 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
3168 to __builtins__ so that any form of embedded or imported code can
3175 to __builtins__ so that any form of embedded or imported code can
3169 test for being inside IPython.
3176 test for being inside IPython.
3170
3177
3171 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3178 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3172 changed to GnuplotMagic because it's now an importable module,
3179 changed to GnuplotMagic because it's now an importable module,
3173 this makes the name follow that of the standard Gnuplot module.
3180 this makes the name follow that of the standard Gnuplot module.
3174 GnuplotMagic can now be loaded at any time in mid-session.
3181 GnuplotMagic can now be loaded at any time in mid-session.
3175
3182
3176 2002-04-24 Fernando Perez <fperez@colorado.edu>
3183 2002-04-24 Fernando Perez <fperez@colorado.edu>
3177
3184
3178 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3185 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3179 the globals (IPython has its own namespace) and the
3186 the globals (IPython has its own namespace) and the
3180 PhysicalQuantity stuff is much better anyway.
3187 PhysicalQuantity stuff is much better anyway.
3181
3188
3182 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3189 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3183 embedding example to standard user directory for
3190 embedding example to standard user directory for
3184 distribution. Also put it in the manual.
3191 distribution. Also put it in the manual.
3185
3192
3186 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3193 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3187 instance as first argument (so it doesn't rely on some obscure
3194 instance as first argument (so it doesn't rely on some obscure
3188 hidden global).
3195 hidden global).
3189
3196
3190 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3197 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3191 delimiters. While it prevents ().TAB from working, it allows
3198 delimiters. While it prevents ().TAB from working, it allows
3192 completions in open (... expressions. This is by far a more common
3199 completions in open (... expressions. This is by far a more common
3193 case.
3200 case.
3194
3201
3195 2002-04-23 Fernando Perez <fperez@colorado.edu>
3202 2002-04-23 Fernando Perez <fperez@colorado.edu>
3196
3203
3197 * IPython/Extensions/InterpreterPasteInput.py: new
3204 * IPython/Extensions/InterpreterPasteInput.py: new
3198 syntax-processing module for pasting lines with >>> or ... at the
3205 syntax-processing module for pasting lines with >>> or ... at the
3199 start.
3206 start.
3200
3207
3201 * IPython/Extensions/PhysicalQ_Interactive.py
3208 * IPython/Extensions/PhysicalQ_Interactive.py
3202 (PhysicalQuantityInteractive.__int__): fixed to work with either
3209 (PhysicalQuantityInteractive.__int__): fixed to work with either
3203 Numeric or math.
3210 Numeric or math.
3204
3211
3205 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3212 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3206 provided profiles. Now we have:
3213 provided profiles. Now we have:
3207 -math -> math module as * and cmath with its own namespace.
3214 -math -> math module as * and cmath with its own namespace.
3208 -numeric -> Numeric as *, plus gnuplot & grace
3215 -numeric -> Numeric as *, plus gnuplot & grace
3209 -physics -> same as before
3216 -physics -> same as before
3210
3217
3211 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3218 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3212 user-defined magics wouldn't be found by @magic if they were
3219 user-defined magics wouldn't be found by @magic if they were
3213 defined as class methods. Also cleaned up the namespace search
3220 defined as class methods. Also cleaned up the namespace search
3214 logic and the string building (to use %s instead of many repeated
3221 logic and the string building (to use %s instead of many repeated
3215 string adds).
3222 string adds).
3216
3223
3217 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3224 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3218 of user-defined magics to operate with class methods (cleaner, in
3225 of user-defined magics to operate with class methods (cleaner, in
3219 line with the gnuplot code).
3226 line with the gnuplot code).
3220
3227
3221 2002-04-22 Fernando Perez <fperez@colorado.edu>
3228 2002-04-22 Fernando Perez <fperez@colorado.edu>
3222
3229
3223 * setup.py: updated dependency list so that manual is updated when
3230 * setup.py: updated dependency list so that manual is updated when
3224 all included files change.
3231 all included files change.
3225
3232
3226 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3233 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3227 the delimiter removal option (the fix is ugly right now).
3234 the delimiter removal option (the fix is ugly right now).
3228
3235
3229 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3236 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3230 all of the math profile (quicker loading, no conflict between
3237 all of the math profile (quicker loading, no conflict between
3231 g-9.8 and g-gnuplot).
3238 g-9.8 and g-gnuplot).
3232
3239
3233 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3240 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3234 name of post-mortem files to IPython_crash_report.txt.
3241 name of post-mortem files to IPython_crash_report.txt.
3235
3242
3236 * Cleanup/update of the docs. Added all the new readline info and
3243 * Cleanup/update of the docs. Added all the new readline info and
3237 formatted all lists as 'real lists'.
3244 formatted all lists as 'real lists'.
3238
3245
3239 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3246 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3240 tab-completion options, since the full readline parse_and_bind is
3247 tab-completion options, since the full readline parse_and_bind is
3241 now accessible.
3248 now accessible.
3242
3249
3243 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3250 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3244 handling of readline options. Now users can specify any string to
3251 handling of readline options. Now users can specify any string to
3245 be passed to parse_and_bind(), as well as the delimiters to be
3252 be passed to parse_and_bind(), as well as the delimiters to be
3246 removed.
3253 removed.
3247 (InteractiveShell.__init__): Added __name__ to the global
3254 (InteractiveShell.__init__): Added __name__ to the global
3248 namespace so that things like Itpl which rely on its existence
3255 namespace so that things like Itpl which rely on its existence
3249 don't crash.
3256 don't crash.
3250 (InteractiveShell._prefilter): Defined the default with a _ so
3257 (InteractiveShell._prefilter): Defined the default with a _ so
3251 that prefilter() is easier to override, while the default one
3258 that prefilter() is easier to override, while the default one
3252 remains available.
3259 remains available.
3253
3260
3254 2002-04-18 Fernando Perez <fperez@colorado.edu>
3261 2002-04-18 Fernando Perez <fperez@colorado.edu>
3255
3262
3256 * Added information about pdb in the docs.
3263 * Added information about pdb in the docs.
3257
3264
3258 2002-04-17 Fernando Perez <fperez@colorado.edu>
3265 2002-04-17 Fernando Perez <fperez@colorado.edu>
3259
3266
3260 * IPython/ipmaker.py (make_IPython): added rc_override option to
3267 * IPython/ipmaker.py (make_IPython): added rc_override option to
3261 allow passing config options at creation time which may override
3268 allow passing config options at creation time which may override
3262 anything set in the config files or command line. This is
3269 anything set in the config files or command line. This is
3263 particularly useful for configuring embedded instances.
3270 particularly useful for configuring embedded instances.
3264
3271
3265 2002-04-15 Fernando Perez <fperez@colorado.edu>
3272 2002-04-15 Fernando Perez <fperez@colorado.edu>
3266
3273
3267 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3274 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3268 crash embedded instances because of the input cache falling out of
3275 crash embedded instances because of the input cache falling out of
3269 sync with the output counter.
3276 sync with the output counter.
3270
3277
3271 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3278 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3272 mode which calls pdb after an uncaught exception in IPython itself.
3279 mode which calls pdb after an uncaught exception in IPython itself.
3273
3280
3274 2002-04-14 Fernando Perez <fperez@colorado.edu>
3281 2002-04-14 Fernando Perez <fperez@colorado.edu>
3275
3282
3276 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3283 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3277 readline, fix it back after each call.
3284 readline, fix it back after each call.
3278
3285
3279 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3286 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3280 method to force all access via __call__(), which guarantees that
3287 method to force all access via __call__(), which guarantees that
3281 traceback references are properly deleted.
3288 traceback references are properly deleted.
3282
3289
3283 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3290 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3284 improve printing when pprint is in use.
3291 improve printing when pprint is in use.
3285
3292
3286 2002-04-13 Fernando Perez <fperez@colorado.edu>
3293 2002-04-13 Fernando Perez <fperez@colorado.edu>
3287
3294
3288 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3295 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3289 exceptions aren't caught anymore. If the user triggers one, he
3296 exceptions aren't caught anymore. If the user triggers one, he
3290 should know why he's doing it and it should go all the way up,
3297 should know why he's doing it and it should go all the way up,
3291 just like any other exception. So now @abort will fully kill the
3298 just like any other exception. So now @abort will fully kill the
3292 embedded interpreter and the embedding code (unless that happens
3299 embedded interpreter and the embedding code (unless that happens
3293 to catch SystemExit).
3300 to catch SystemExit).
3294
3301
3295 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3302 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3296 and a debugger() method to invoke the interactive pdb debugger
3303 and a debugger() method to invoke the interactive pdb debugger
3297 after printing exception information. Also added the corresponding
3304 after printing exception information. Also added the corresponding
3298 -pdb option and @pdb magic to control this feature, and updated
3305 -pdb option and @pdb magic to control this feature, and updated
3299 the docs. After a suggestion from Christopher Hart
3306 the docs. After a suggestion from Christopher Hart
3300 (hart-AT-caltech.edu).
3307 (hart-AT-caltech.edu).
3301
3308
3302 2002-04-12 Fernando Perez <fperez@colorado.edu>
3309 2002-04-12 Fernando Perez <fperez@colorado.edu>
3303
3310
3304 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3311 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3305 the exception handlers defined by the user (not the CrashHandler)
3312 the exception handlers defined by the user (not the CrashHandler)
3306 so that user exceptions don't trigger an ipython bug report.
3313 so that user exceptions don't trigger an ipython bug report.
3307
3314
3308 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3315 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3309 configurable (it should have always been so).
3316 configurable (it should have always been so).
3310
3317
3311 2002-03-26 Fernando Perez <fperez@colorado.edu>
3318 2002-03-26 Fernando Perez <fperez@colorado.edu>
3312
3319
3313 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3320 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3314 and there to fix embedding namespace issues. This should all be
3321 and there to fix embedding namespace issues. This should all be
3315 done in a more elegant way.
3322 done in a more elegant way.
3316
3323
3317 2002-03-25 Fernando Perez <fperez@colorado.edu>
3324 2002-03-25 Fernando Perez <fperez@colorado.edu>
3318
3325
3319 * IPython/genutils.py (get_home_dir): Try to make it work under
3326 * IPython/genutils.py (get_home_dir): Try to make it work under
3320 win9x also.
3327 win9x also.
3321
3328
3322 2002-03-20 Fernando Perez <fperez@colorado.edu>
3329 2002-03-20 Fernando Perez <fperez@colorado.edu>
3323
3330
3324 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3331 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3325 sys.displayhook untouched upon __init__.
3332 sys.displayhook untouched upon __init__.
3326
3333
3327 2002-03-19 Fernando Perez <fperez@colorado.edu>
3334 2002-03-19 Fernando Perez <fperez@colorado.edu>
3328
3335
3329 * Released 0.2.9 (for embedding bug, basically).
3336 * Released 0.2.9 (for embedding bug, basically).
3330
3337
3331 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3338 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3332 exceptions so that enclosing shell's state can be restored.
3339 exceptions so that enclosing shell's state can be restored.
3333
3340
3334 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3341 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3335 naming conventions in the .ipython/ dir.
3342 naming conventions in the .ipython/ dir.
3336
3343
3337 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3344 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3338 from delimiters list so filenames with - in them get expanded.
3345 from delimiters list so filenames with - in them get expanded.
3339
3346
3340 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3347 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3341 sys.displayhook not being properly restored after an embedded call.
3348 sys.displayhook not being properly restored after an embedded call.
3342
3349
3343 2002-03-18 Fernando Perez <fperez@colorado.edu>
3350 2002-03-18 Fernando Perez <fperez@colorado.edu>
3344
3351
3345 * Released 0.2.8
3352 * Released 0.2.8
3346
3353
3347 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3354 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3348 some files weren't being included in a -upgrade.
3355 some files weren't being included in a -upgrade.
3349 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3356 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3350 on' so that the first tab completes.
3357 on' so that the first tab completes.
3351 (InteractiveShell.handle_magic): fixed bug with spaces around
3358 (InteractiveShell.handle_magic): fixed bug with spaces around
3352 quotes breaking many magic commands.
3359 quotes breaking many magic commands.
3353
3360
3354 * setup.py: added note about ignoring the syntax error messages at
3361 * setup.py: added note about ignoring the syntax error messages at
3355 installation.
3362 installation.
3356
3363
3357 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3364 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3358 streamlining the gnuplot interface, now there's only one magic @gp.
3365 streamlining the gnuplot interface, now there's only one magic @gp.
3359
3366
3360 2002-03-17 Fernando Perez <fperez@colorado.edu>
3367 2002-03-17 Fernando Perez <fperez@colorado.edu>
3361
3368
3362 * IPython/UserConfig/magic_gnuplot.py: new name for the
3369 * IPython/UserConfig/magic_gnuplot.py: new name for the
3363 example-magic_pm.py file. Much enhanced system, now with a shell
3370 example-magic_pm.py file. Much enhanced system, now with a shell
3364 for communicating directly with gnuplot, one command at a time.
3371 for communicating directly with gnuplot, one command at a time.
3365
3372
3366 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3373 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3367 setting __name__=='__main__'.
3374 setting __name__=='__main__'.
3368
3375
3369 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3376 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3370 mini-shell for accessing gnuplot from inside ipython. Should
3377 mini-shell for accessing gnuplot from inside ipython. Should
3371 extend it later for grace access too. Inspired by Arnd's
3378 extend it later for grace access too. Inspired by Arnd's
3372 suggestion.
3379 suggestion.
3373
3380
3374 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3381 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3375 calling magic functions with () in their arguments. Thanks to Arnd
3382 calling magic functions with () in their arguments. Thanks to Arnd
3376 Baecker for pointing this to me.
3383 Baecker for pointing this to me.
3377
3384
3378 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3385 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3379 infinitely for integer or complex arrays (only worked with floats).
3386 infinitely for integer or complex arrays (only worked with floats).
3380
3387
3381 2002-03-16 Fernando Perez <fperez@colorado.edu>
3388 2002-03-16 Fernando Perez <fperez@colorado.edu>
3382
3389
3383 * setup.py: Merged setup and setup_windows into a single script
3390 * setup.py: Merged setup and setup_windows into a single script
3384 which properly handles things for windows users.
3391 which properly handles things for windows users.
3385
3392
3386 2002-03-15 Fernando Perez <fperez@colorado.edu>
3393 2002-03-15 Fernando Perez <fperez@colorado.edu>
3387
3394
3388 * Big change to the manual: now the magics are all automatically
3395 * Big change to the manual: now the magics are all automatically
3389 documented. This information is generated from their docstrings
3396 documented. This information is generated from their docstrings
3390 and put in a latex file included by the manual lyx file. This way
3397 and put in a latex file included by the manual lyx file. This way
3391 we get always up to date information for the magics. The manual
3398 we get always up to date information for the magics. The manual
3392 now also has proper version information, also auto-synced.
3399 now also has proper version information, also auto-synced.
3393
3400
3394 For this to work, an undocumented --magic_docstrings option was added.
3401 For this to work, an undocumented --magic_docstrings option was added.
3395
3402
3396 2002-03-13 Fernando Perez <fperez@colorado.edu>
3403 2002-03-13 Fernando Perez <fperez@colorado.edu>
3397
3404
3398 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3405 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3399 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3406 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3400
3407
3401 2002-03-12 Fernando Perez <fperez@colorado.edu>
3408 2002-03-12 Fernando Perez <fperez@colorado.edu>
3402
3409
3403 * IPython/ultraTB.py (TermColors): changed color escapes again to
3410 * IPython/ultraTB.py (TermColors): changed color escapes again to
3404 fix the (old, reintroduced) line-wrapping bug. Basically, if
3411 fix the (old, reintroduced) line-wrapping bug. Basically, if
3405 \001..\002 aren't given in the color escapes, lines get wrapped
3412 \001..\002 aren't given in the color escapes, lines get wrapped
3406 weirdly. But giving those screws up old xterms and emacs terms. So
3413 weirdly. But giving those screws up old xterms and emacs terms. So
3407 I added some logic for emacs terms to be ok, but I can't identify old
3414 I added some logic for emacs terms to be ok, but I can't identify old
3408 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3415 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3409
3416
3410 2002-03-10 Fernando Perez <fperez@colorado.edu>
3417 2002-03-10 Fernando Perez <fperez@colorado.edu>
3411
3418
3412 * IPython/usage.py (__doc__): Various documentation cleanups and
3419 * IPython/usage.py (__doc__): Various documentation cleanups and
3413 updates, both in usage docstrings and in the manual.
3420 updates, both in usage docstrings and in the manual.
3414
3421
3415 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3422 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3416 handling of caching. Set minimum acceptabe value for having a
3423 handling of caching. Set minimum acceptabe value for having a
3417 cache at 20 values.
3424 cache at 20 values.
3418
3425
3419 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3426 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3420 install_first_time function to a method, renamed it and added an
3427 install_first_time function to a method, renamed it and added an
3421 'upgrade' mode. Now people can update their config directory with
3428 'upgrade' mode. Now people can update their config directory with
3422 a simple command line switch (-upgrade, also new).
3429 a simple command line switch (-upgrade, also new).
3423
3430
3424 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3431 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3425 @file (convenient for automagic users under Python >= 2.2).
3432 @file (convenient for automagic users under Python >= 2.2).
3426 Removed @files (it seemed more like a plural than an abbrev. of
3433 Removed @files (it seemed more like a plural than an abbrev. of
3427 'file show').
3434 'file show').
3428
3435
3429 * IPython/iplib.py (install_first_time): Fixed crash if there were
3436 * IPython/iplib.py (install_first_time): Fixed crash if there were
3430 backup files ('~') in .ipython/ install directory.
3437 backup files ('~') in .ipython/ install directory.
3431
3438
3432 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3439 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3433 system. Things look fine, but these changes are fairly
3440 system. Things look fine, but these changes are fairly
3434 intrusive. Test them for a few days.
3441 intrusive. Test them for a few days.
3435
3442
3436 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3443 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3437 the prompts system. Now all in/out prompt strings are user
3444 the prompts system. Now all in/out prompt strings are user
3438 controllable. This is particularly useful for embedding, as one
3445 controllable. This is particularly useful for embedding, as one
3439 can tag embedded instances with particular prompts.
3446 can tag embedded instances with particular prompts.
3440
3447
3441 Also removed global use of sys.ps1/2, which now allows nested
3448 Also removed global use of sys.ps1/2, which now allows nested
3442 embeddings without any problems. Added command-line options for
3449 embeddings without any problems. Added command-line options for
3443 the prompt strings.
3450 the prompt strings.
3444
3451
3445 2002-03-08 Fernando Perez <fperez@colorado.edu>
3452 2002-03-08 Fernando Perez <fperez@colorado.edu>
3446
3453
3447 * IPython/UserConfig/example-embed-short.py (ipshell): added
3454 * IPython/UserConfig/example-embed-short.py (ipshell): added
3448 example file with the bare minimum code for embedding.
3455 example file with the bare minimum code for embedding.
3449
3456
3450 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3457 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3451 functionality for the embeddable shell to be activated/deactivated
3458 functionality for the embeddable shell to be activated/deactivated
3452 either globally or at each call.
3459 either globally or at each call.
3453
3460
3454 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3461 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3455 rewriting the prompt with '--->' for auto-inputs with proper
3462 rewriting the prompt with '--->' for auto-inputs with proper
3456 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3463 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3457 this is handled by the prompts class itself, as it should.
3464 this is handled by the prompts class itself, as it should.
3458
3465
3459 2002-03-05 Fernando Perez <fperez@colorado.edu>
3466 2002-03-05 Fernando Perez <fperez@colorado.edu>
3460
3467
3461 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3468 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3462 @logstart to avoid name clashes with the math log function.
3469 @logstart to avoid name clashes with the math log function.
3463
3470
3464 * Big updates to X/Emacs section of the manual.
3471 * Big updates to X/Emacs section of the manual.
3465
3472
3466 * Removed ipython_emacs. Milan explained to me how to pass
3473 * Removed ipython_emacs. Milan explained to me how to pass
3467 arguments to ipython through Emacs. Some day I'm going to end up
3474 arguments to ipython through Emacs. Some day I'm going to end up
3468 learning some lisp...
3475 learning some lisp...
3469
3476
3470 2002-03-04 Fernando Perez <fperez@colorado.edu>
3477 2002-03-04 Fernando Perez <fperez@colorado.edu>
3471
3478
3472 * IPython/ipython_emacs: Created script to be used as the
3479 * IPython/ipython_emacs: Created script to be used as the
3473 py-python-command Emacs variable so we can pass IPython
3480 py-python-command Emacs variable so we can pass IPython
3474 parameters. I can't figure out how to tell Emacs directly to pass
3481 parameters. I can't figure out how to tell Emacs directly to pass
3475 parameters to IPython, so a dummy shell script will do it.
3482 parameters to IPython, so a dummy shell script will do it.
3476
3483
3477 Other enhancements made for things to work better under Emacs'
3484 Other enhancements made for things to work better under Emacs'
3478 various types of terminals. Many thanks to Milan Zamazal
3485 various types of terminals. Many thanks to Milan Zamazal
3479 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3486 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3480
3487
3481 2002-03-01 Fernando Perez <fperez@colorado.edu>
3488 2002-03-01 Fernando Perez <fperez@colorado.edu>
3482
3489
3483 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3490 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3484 that loading of readline is now optional. This gives better
3491 that loading of readline is now optional. This gives better
3485 control to emacs users.
3492 control to emacs users.
3486
3493
3487 * IPython/ultraTB.py (__date__): Modified color escape sequences
3494 * IPython/ultraTB.py (__date__): Modified color escape sequences
3488 and now things work fine under xterm and in Emacs' term buffers
3495 and now things work fine under xterm and in Emacs' term buffers
3489 (though not shell ones). Well, in emacs you get colors, but all
3496 (though not shell ones). Well, in emacs you get colors, but all
3490 seem to be 'light' colors (no difference between dark and light
3497 seem to be 'light' colors (no difference between dark and light
3491 ones). But the garbage chars are gone, and also in xterms. It
3498 ones). But the garbage chars are gone, and also in xterms. It
3492 seems that now I'm using 'cleaner' ansi sequences.
3499 seems that now I'm using 'cleaner' ansi sequences.
3493
3500
3494 2002-02-21 Fernando Perez <fperez@colorado.edu>
3501 2002-02-21 Fernando Perez <fperez@colorado.edu>
3495
3502
3496 * Released 0.2.7 (mainly to publish the scoping fix).
3503 * Released 0.2.7 (mainly to publish the scoping fix).
3497
3504
3498 * IPython/Logger.py (Logger.logstate): added. A corresponding
3505 * IPython/Logger.py (Logger.logstate): added. A corresponding
3499 @logstate magic was created.
3506 @logstate magic was created.
3500
3507
3501 * IPython/Magic.py: fixed nested scoping problem under Python
3508 * IPython/Magic.py: fixed nested scoping problem under Python
3502 2.1.x (automagic wasn't working).
3509 2.1.x (automagic wasn't working).
3503
3510
3504 2002-02-20 Fernando Perez <fperez@colorado.edu>
3511 2002-02-20 Fernando Perez <fperez@colorado.edu>
3505
3512
3506 * Released 0.2.6.
3513 * Released 0.2.6.
3507
3514
3508 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
3515 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
3509 option so that logs can come out without any headers at all.
3516 option so that logs can come out without any headers at all.
3510
3517
3511 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
3518 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
3512 SciPy.
3519 SciPy.
3513
3520
3514 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
3521 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
3515 that embedded IPython calls don't require vars() to be explicitly
3522 that embedded IPython calls don't require vars() to be explicitly
3516 passed. Now they are extracted from the caller's frame (code
3523 passed. Now they are extracted from the caller's frame (code
3517 snatched from Eric Jones' weave). Added better documentation to
3524 snatched from Eric Jones' weave). Added better documentation to
3518 the section on embedding and the example file.
3525 the section on embedding and the example file.
3519
3526
3520 * IPython/genutils.py (page): Changed so that under emacs, it just
3527 * IPython/genutils.py (page): Changed so that under emacs, it just
3521 prints the string. You can then page up and down in the emacs
3528 prints the string. You can then page up and down in the emacs
3522 buffer itself. This is how the builtin help() works.
3529 buffer itself. This is how the builtin help() works.
3523
3530
3524 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
3531 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
3525 macro scoping: macros need to be executed in the user's namespace
3532 macro scoping: macros need to be executed in the user's namespace
3526 to work as if they had been typed by the user.
3533 to work as if they had been typed by the user.
3527
3534
3528 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
3535 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
3529 execute automatically (no need to type 'exec...'). They then
3536 execute automatically (no need to type 'exec...'). They then
3530 behave like 'true macros'. The printing system was also modified
3537 behave like 'true macros'. The printing system was also modified
3531 for this to work.
3538 for this to work.
3532
3539
3533 2002-02-19 Fernando Perez <fperez@colorado.edu>
3540 2002-02-19 Fernando Perez <fperez@colorado.edu>
3534
3541
3535 * IPython/genutils.py (page_file): new function for paging files
3542 * IPython/genutils.py (page_file): new function for paging files
3536 in an OS-independent way. Also necessary for file viewing to work
3543 in an OS-independent way. Also necessary for file viewing to work
3537 well inside Emacs buffers.
3544 well inside Emacs buffers.
3538 (page): Added checks for being in an emacs buffer.
3545 (page): Added checks for being in an emacs buffer.
3539 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
3546 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
3540 same bug in iplib.
3547 same bug in iplib.
3541
3548
3542 2002-02-18 Fernando Perez <fperez@colorado.edu>
3549 2002-02-18 Fernando Perez <fperez@colorado.edu>
3543
3550
3544 * IPython/iplib.py (InteractiveShell.init_readline): modified use
3551 * IPython/iplib.py (InteractiveShell.init_readline): modified use
3545 of readline so that IPython can work inside an Emacs buffer.
3552 of readline so that IPython can work inside an Emacs buffer.
3546
3553
3547 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
3554 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
3548 method signatures (they weren't really bugs, but it looks cleaner
3555 method signatures (they weren't really bugs, but it looks cleaner
3549 and keeps PyChecker happy).
3556 and keeps PyChecker happy).
3550
3557
3551 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
3558 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
3552 for implementing various user-defined hooks. Currently only
3559 for implementing various user-defined hooks. Currently only
3553 display is done.
3560 display is done.
3554
3561
3555 * IPython/Prompts.py (CachedOutput._display): changed display
3562 * IPython/Prompts.py (CachedOutput._display): changed display
3556 functions so that they can be dynamically changed by users easily.
3563 functions so that they can be dynamically changed by users easily.
3557
3564
3558 * IPython/Extensions/numeric_formats.py (num_display): added an
3565 * IPython/Extensions/numeric_formats.py (num_display): added an
3559 extension for printing NumPy arrays in flexible manners. It
3566 extension for printing NumPy arrays in flexible manners. It
3560 doesn't do anything yet, but all the structure is in
3567 doesn't do anything yet, but all the structure is in
3561 place. Ultimately the plan is to implement output format control
3568 place. Ultimately the plan is to implement output format control
3562 like in Octave.
3569 like in Octave.
3563
3570
3564 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
3571 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
3565 methods are found at run-time by all the automatic machinery.
3572 methods are found at run-time by all the automatic machinery.
3566
3573
3567 2002-02-17 Fernando Perez <fperez@colorado.edu>
3574 2002-02-17 Fernando Perez <fperez@colorado.edu>
3568
3575
3569 * setup_Windows.py (make_shortcut): documented. Cleaned up the
3576 * setup_Windows.py (make_shortcut): documented. Cleaned up the
3570 whole file a little.
3577 whole file a little.
3571
3578
3572 * ToDo: closed this document. Now there's a new_design.lyx
3579 * ToDo: closed this document. Now there's a new_design.lyx
3573 document for all new ideas. Added making a pdf of it for the
3580 document for all new ideas. Added making a pdf of it for the
3574 end-user distro.
3581 end-user distro.
3575
3582
3576 * IPython/Logger.py (Logger.switch_log): Created this to replace
3583 * IPython/Logger.py (Logger.switch_log): Created this to replace
3577 logon() and logoff(). It also fixes a nasty crash reported by
3584 logon() and logoff(). It also fixes a nasty crash reported by
3578 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
3585 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
3579
3586
3580 * IPython/iplib.py (complete): got auto-completion to work with
3587 * IPython/iplib.py (complete): got auto-completion to work with
3581 automagic (I had wanted this for a long time).
3588 automagic (I had wanted this for a long time).
3582
3589
3583 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
3590 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
3584 to @file, since file() is now a builtin and clashes with automagic
3591 to @file, since file() is now a builtin and clashes with automagic
3585 for @file.
3592 for @file.
3586
3593
3587 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
3594 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
3588 of this was previously in iplib, which had grown to more than 2000
3595 of this was previously in iplib, which had grown to more than 2000
3589 lines, way too long. No new functionality, but it makes managing
3596 lines, way too long. No new functionality, but it makes managing
3590 the code a bit easier.
3597 the code a bit easier.
3591
3598
3592 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
3599 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
3593 information to crash reports.
3600 information to crash reports.
3594
3601
3595 2002-02-12 Fernando Perez <fperez@colorado.edu>
3602 2002-02-12 Fernando Perez <fperez@colorado.edu>
3596
3603
3597 * Released 0.2.5.
3604 * Released 0.2.5.
3598
3605
3599 2002-02-11 Fernando Perez <fperez@colorado.edu>
3606 2002-02-11 Fernando Perez <fperez@colorado.edu>
3600
3607
3601 * Wrote a relatively complete Windows installer. It puts
3608 * Wrote a relatively complete Windows installer. It puts
3602 everything in place, creates Start Menu entries and fixes the
3609 everything in place, creates Start Menu entries and fixes the
3603 color issues. Nothing fancy, but it works.
3610 color issues. Nothing fancy, but it works.
3604
3611
3605 2002-02-10 Fernando Perez <fperez@colorado.edu>
3612 2002-02-10 Fernando Perez <fperez@colorado.edu>
3606
3613
3607 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
3614 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
3608 os.path.expanduser() call so that we can type @run ~/myfile.py and
3615 os.path.expanduser() call so that we can type @run ~/myfile.py and
3609 have thigs work as expected.
3616 have thigs work as expected.
3610
3617
3611 * IPython/genutils.py (page): fixed exception handling so things
3618 * IPython/genutils.py (page): fixed exception handling so things
3612 work both in Unix and Windows correctly. Quitting a pager triggers
3619 work both in Unix and Windows correctly. Quitting a pager triggers
3613 an IOError/broken pipe in Unix, and in windows not finding a pager
3620 an IOError/broken pipe in Unix, and in windows not finding a pager
3614 is also an IOError, so I had to actually look at the return value
3621 is also an IOError, so I had to actually look at the return value
3615 of the exception, not just the exception itself. Should be ok now.
3622 of the exception, not just the exception itself. Should be ok now.
3616
3623
3617 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
3624 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
3618 modified to allow case-insensitive color scheme changes.
3625 modified to allow case-insensitive color scheme changes.
3619
3626
3620 2002-02-09 Fernando Perez <fperez@colorado.edu>
3627 2002-02-09 Fernando Perez <fperez@colorado.edu>
3621
3628
3622 * IPython/genutils.py (native_line_ends): new function to leave
3629 * IPython/genutils.py (native_line_ends): new function to leave
3623 user config files with os-native line-endings.
3630 user config files with os-native line-endings.
3624
3631
3625 * README and manual updates.
3632 * README and manual updates.
3626
3633
3627 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
3634 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
3628 instead of StringType to catch Unicode strings.
3635 instead of StringType to catch Unicode strings.
3629
3636
3630 * IPython/genutils.py (filefind): fixed bug for paths with
3637 * IPython/genutils.py (filefind): fixed bug for paths with
3631 embedded spaces (very common in Windows).
3638 embedded spaces (very common in Windows).
3632
3639
3633 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
3640 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
3634 files under Windows, so that they get automatically associated
3641 files under Windows, so that they get automatically associated
3635 with a text editor. Windows makes it a pain to handle
3642 with a text editor. Windows makes it a pain to handle
3636 extension-less files.
3643 extension-less files.
3637
3644
3638 * IPython/iplib.py (InteractiveShell.init_readline): Made the
3645 * IPython/iplib.py (InteractiveShell.init_readline): Made the
3639 warning about readline only occur for Posix. In Windows there's no
3646 warning about readline only occur for Posix. In Windows there's no
3640 way to get readline, so why bother with the warning.
3647 way to get readline, so why bother with the warning.
3641
3648
3642 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
3649 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
3643 for __str__ instead of dir(self), since dir() changed in 2.2.
3650 for __str__ instead of dir(self), since dir() changed in 2.2.
3644
3651
3645 * Ported to Windows! Tested on XP, I suspect it should work fine
3652 * Ported to Windows! Tested on XP, I suspect it should work fine
3646 on NT/2000, but I don't think it will work on 98 et al. That
3653 on NT/2000, but I don't think it will work on 98 et al. That
3647 series of Windows is such a piece of junk anyway that I won't try
3654 series of Windows is such a piece of junk anyway that I won't try
3648 porting it there. The XP port was straightforward, showed a few
3655 porting it there. The XP port was straightforward, showed a few
3649 bugs here and there (fixed all), in particular some string
3656 bugs here and there (fixed all), in particular some string
3650 handling stuff which required considering Unicode strings (which
3657 handling stuff which required considering Unicode strings (which
3651 Windows uses). This is good, but hasn't been too tested :) No
3658 Windows uses). This is good, but hasn't been too tested :) No
3652 fancy installer yet, I'll put a note in the manual so people at
3659 fancy installer yet, I'll put a note in the manual so people at
3653 least make manually a shortcut.
3660 least make manually a shortcut.
3654
3661
3655 * IPython/iplib.py (Magic.magic_colors): Unified the color options
3662 * IPython/iplib.py (Magic.magic_colors): Unified the color options
3656 into a single one, "colors". This now controls both prompt and
3663 into a single one, "colors". This now controls both prompt and
3657 exception color schemes, and can be changed both at startup
3664 exception color schemes, and can be changed both at startup
3658 (either via command-line switches or via ipythonrc files) and at
3665 (either via command-line switches or via ipythonrc files) and at
3659 runtime, with @colors.
3666 runtime, with @colors.
3660 (Magic.magic_run): renamed @prun to @run and removed the old
3667 (Magic.magic_run): renamed @prun to @run and removed the old
3661 @run. The two were too similar to warrant keeping both.
3668 @run. The two were too similar to warrant keeping both.
3662
3669
3663 2002-02-03 Fernando Perez <fperez@colorado.edu>
3670 2002-02-03 Fernando Perez <fperez@colorado.edu>
3664
3671
3665 * IPython/iplib.py (install_first_time): Added comment on how to
3672 * IPython/iplib.py (install_first_time): Added comment on how to
3666 configure the color options for first-time users. Put a <return>
3673 configure the color options for first-time users. Put a <return>
3667 request at the end so that small-terminal users get a chance to
3674 request at the end so that small-terminal users get a chance to
3668 read the startup info.
3675 read the startup info.
3669
3676
3670 2002-01-23 Fernando Perez <fperez@colorado.edu>
3677 2002-01-23 Fernando Perez <fperez@colorado.edu>
3671
3678
3672 * IPython/iplib.py (CachedOutput.update): Changed output memory
3679 * IPython/iplib.py (CachedOutput.update): Changed output memory
3673 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
3680 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
3674 input history we still use _i. Did this b/c these variable are
3681 input history we still use _i. Did this b/c these variable are
3675 very commonly used in interactive work, so the less we need to
3682 very commonly used in interactive work, so the less we need to
3676 type the better off we are.
3683 type the better off we are.
3677 (Magic.magic_prun): updated @prun to better handle the namespaces
3684 (Magic.magic_prun): updated @prun to better handle the namespaces
3678 the file will run in, including a fix for __name__ not being set
3685 the file will run in, including a fix for __name__ not being set
3679 before.
3686 before.
3680
3687
3681 2002-01-20 Fernando Perez <fperez@colorado.edu>
3688 2002-01-20 Fernando Perez <fperez@colorado.edu>
3682
3689
3683 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
3690 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
3684 extra garbage for Python 2.2. Need to look more carefully into
3691 extra garbage for Python 2.2. Need to look more carefully into
3685 this later.
3692 this later.
3686
3693
3687 2002-01-19 Fernando Perez <fperez@colorado.edu>
3694 2002-01-19 Fernando Perez <fperez@colorado.edu>
3688
3695
3689 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
3696 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
3690 display SyntaxError exceptions properly formatted when they occur
3697 display SyntaxError exceptions properly formatted when they occur
3691 (they can be triggered by imported code).
3698 (they can be triggered by imported code).
3692
3699
3693 2002-01-18 Fernando Perez <fperez@colorado.edu>
3700 2002-01-18 Fernando Perez <fperez@colorado.edu>
3694
3701
3695 * IPython/iplib.py (InteractiveShell.safe_execfile): now
3702 * IPython/iplib.py (InteractiveShell.safe_execfile): now
3696 SyntaxError exceptions are reported nicely formatted, instead of
3703 SyntaxError exceptions are reported nicely formatted, instead of
3697 spitting out only offset information as before.
3704 spitting out only offset information as before.
3698 (Magic.magic_prun): Added the @prun function for executing
3705 (Magic.magic_prun): Added the @prun function for executing
3699 programs with command line args inside IPython.
3706 programs with command line args inside IPython.
3700
3707
3701 2002-01-16 Fernando Perez <fperez@colorado.edu>
3708 2002-01-16 Fernando Perez <fperez@colorado.edu>
3702
3709
3703 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
3710 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
3704 to *not* include the last item given in a range. This brings their
3711 to *not* include the last item given in a range. This brings their
3705 behavior in line with Python's slicing:
3712 behavior in line with Python's slicing:
3706 a[n1:n2] -> a[n1]...a[n2-1]
3713 a[n1:n2] -> a[n1]...a[n2-1]
3707 It may be a bit less convenient, but I prefer to stick to Python's
3714 It may be a bit less convenient, but I prefer to stick to Python's
3708 conventions *everywhere*, so users never have to wonder.
3715 conventions *everywhere*, so users never have to wonder.
3709 (Magic.magic_macro): Added @macro function to ease the creation of
3716 (Magic.magic_macro): Added @macro function to ease the creation of
3710 macros.
3717 macros.
3711
3718
3712 2002-01-05 Fernando Perez <fperez@colorado.edu>
3719 2002-01-05 Fernando Perez <fperez@colorado.edu>
3713
3720
3714 * Released 0.2.4.
3721 * Released 0.2.4.
3715
3722
3716 * IPython/iplib.py (Magic.magic_pdef):
3723 * IPython/iplib.py (Magic.magic_pdef):
3717 (InteractiveShell.safe_execfile): report magic lines and error
3724 (InteractiveShell.safe_execfile): report magic lines and error
3718 lines without line numbers so one can easily copy/paste them for
3725 lines without line numbers so one can easily copy/paste them for
3719 re-execution.
3726 re-execution.
3720
3727
3721 * Updated manual with recent changes.
3728 * Updated manual with recent changes.
3722
3729
3723 * IPython/iplib.py (Magic.magic_oinfo): added constructor
3730 * IPython/iplib.py (Magic.magic_oinfo): added constructor
3724 docstring printing when class? is called. Very handy for knowing
3731 docstring printing when class? is called. Very handy for knowing
3725 how to create class instances (as long as __init__ is well
3732 how to create class instances (as long as __init__ is well
3726 documented, of course :)
3733 documented, of course :)
3727 (Magic.magic_doc): print both class and constructor docstrings.
3734 (Magic.magic_doc): print both class and constructor docstrings.
3728 (Magic.magic_pdef): give constructor info if passed a class and
3735 (Magic.magic_pdef): give constructor info if passed a class and
3729 __call__ info for callable object instances.
3736 __call__ info for callable object instances.
3730
3737
3731 2002-01-04 Fernando Perez <fperez@colorado.edu>
3738 2002-01-04 Fernando Perez <fperez@colorado.edu>
3732
3739
3733 * Made deep_reload() off by default. It doesn't always work
3740 * Made deep_reload() off by default. It doesn't always work
3734 exactly as intended, so it's probably safer to have it off. It's
3741 exactly as intended, so it's probably safer to have it off. It's
3735 still available as dreload() anyway, so nothing is lost.
3742 still available as dreload() anyway, so nothing is lost.
3736
3743
3737 2002-01-02 Fernando Perez <fperez@colorado.edu>
3744 2002-01-02 Fernando Perez <fperez@colorado.edu>
3738
3745
3739 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
3746 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
3740 so I wanted an updated release).
3747 so I wanted an updated release).
3741
3748
3742 2001-12-27 Fernando Perez <fperez@colorado.edu>
3749 2001-12-27 Fernando Perez <fperez@colorado.edu>
3743
3750
3744 * IPython/iplib.py (InteractiveShell.interact): Added the original
3751 * IPython/iplib.py (InteractiveShell.interact): Added the original
3745 code from 'code.py' for this module in order to change the
3752 code from 'code.py' for this module in order to change the
3746 handling of a KeyboardInterrupt. This was necessary b/c otherwise
3753 handling of a KeyboardInterrupt. This was necessary b/c otherwise
3747 the history cache would break when the user hit Ctrl-C, and
3754 the history cache would break when the user hit Ctrl-C, and
3748 interact() offers no way to add any hooks to it.
3755 interact() offers no way to add any hooks to it.
3749
3756
3750 2001-12-23 Fernando Perez <fperez@colorado.edu>
3757 2001-12-23 Fernando Perez <fperez@colorado.edu>
3751
3758
3752 * setup.py: added check for 'MANIFEST' before trying to remove
3759 * setup.py: added check for 'MANIFEST' before trying to remove
3753 it. Thanks to Sean Reifschneider.
3760 it. Thanks to Sean Reifschneider.
3754
3761
3755 2001-12-22 Fernando Perez <fperez@colorado.edu>
3762 2001-12-22 Fernando Perez <fperez@colorado.edu>
3756
3763
3757 * Released 0.2.2.
3764 * Released 0.2.2.
3758
3765
3759 * Finished (reasonably) writing the manual. Later will add the
3766 * Finished (reasonably) writing the manual. Later will add the
3760 python-standard navigation stylesheets, but for the time being
3767 python-standard navigation stylesheets, but for the time being
3761 it's fairly complete. Distribution will include html and pdf
3768 it's fairly complete. Distribution will include html and pdf
3762 versions.
3769 versions.
3763
3770
3764 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
3771 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
3765 (MayaVi author).
3772 (MayaVi author).
3766
3773
3767 2001-12-21 Fernando Perez <fperez@colorado.edu>
3774 2001-12-21 Fernando Perez <fperez@colorado.edu>
3768
3775
3769 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
3776 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
3770 good public release, I think (with the manual and the distutils
3777 good public release, I think (with the manual and the distutils
3771 installer). The manual can use some work, but that can go
3778 installer). The manual can use some work, but that can go
3772 slowly. Otherwise I think it's quite nice for end users. Next
3779 slowly. Otherwise I think it's quite nice for end users. Next
3773 summer, rewrite the guts of it...
3780 summer, rewrite the guts of it...
3774
3781
3775 * Changed format of ipythonrc files to use whitespace as the
3782 * Changed format of ipythonrc files to use whitespace as the
3776 separator instead of an explicit '='. Cleaner.
3783 separator instead of an explicit '='. Cleaner.
3777
3784
3778 2001-12-20 Fernando Perez <fperez@colorado.edu>
3785 2001-12-20 Fernando Perez <fperez@colorado.edu>
3779
3786
3780 * Started a manual in LyX. For now it's just a quick merge of the
3787 * Started a manual in LyX. For now it's just a quick merge of the
3781 various internal docstrings and READMEs. Later it may grow into a
3788 various internal docstrings and READMEs. Later it may grow into a
3782 nice, full-blown manual.
3789 nice, full-blown manual.
3783
3790
3784 * Set up a distutils based installer. Installation should now be
3791 * Set up a distutils based installer. Installation should now be
3785 trivially simple for end-users.
3792 trivially simple for end-users.
3786
3793
3787 2001-12-11 Fernando Perez <fperez@colorado.edu>
3794 2001-12-11 Fernando Perez <fperez@colorado.edu>
3788
3795
3789 * Released 0.2.0. First public release, announced it at
3796 * Released 0.2.0. First public release, announced it at
3790 comp.lang.python. From now on, just bugfixes...
3797 comp.lang.python. From now on, just bugfixes...
3791
3798
3792 * Went through all the files, set copyright/license notices and
3799 * Went through all the files, set copyright/license notices and
3793 cleaned up things. Ready for release.
3800 cleaned up things. Ready for release.
3794
3801
3795 2001-12-10 Fernando Perez <fperez@colorado.edu>
3802 2001-12-10 Fernando Perez <fperez@colorado.edu>
3796
3803
3797 * Changed the first-time installer not to use tarfiles. It's more
3804 * Changed the first-time installer not to use tarfiles. It's more
3798 robust now and less unix-dependent. Also makes it easier for
3805 robust now and less unix-dependent. Also makes it easier for
3799 people to later upgrade versions.
3806 people to later upgrade versions.
3800
3807
3801 * Changed @exit to @abort to reflect the fact that it's pretty
3808 * Changed @exit to @abort to reflect the fact that it's pretty
3802 brutal (a sys.exit()). The difference between @abort and Ctrl-D
3809 brutal (a sys.exit()). The difference between @abort and Ctrl-D
3803 becomes significant only when IPyhton is embedded: in that case,
3810 becomes significant only when IPyhton is embedded: in that case,
3804 C-D closes IPython only, but @abort kills the enclosing program
3811 C-D closes IPython only, but @abort kills the enclosing program
3805 too (unless it had called IPython inside a try catching
3812 too (unless it had called IPython inside a try catching
3806 SystemExit).
3813 SystemExit).
3807
3814
3808 * Created Shell module which exposes the actuall IPython Shell
3815 * Created Shell module which exposes the actuall IPython Shell
3809 classes, currently the normal and the embeddable one. This at
3816 classes, currently the normal and the embeddable one. This at
3810 least offers a stable interface we won't need to change when
3817 least offers a stable interface we won't need to change when
3811 (later) the internals are rewritten. That rewrite will be confined
3818 (later) the internals are rewritten. That rewrite will be confined
3812 to iplib and ipmaker, but the Shell interface should remain as is.
3819 to iplib and ipmaker, but the Shell interface should remain as is.
3813
3820
3814 * Added embed module which offers an embeddable IPShell object,
3821 * Added embed module which offers an embeddable IPShell object,
3815 useful to fire up IPython *inside* a running program. Great for
3822 useful to fire up IPython *inside* a running program. Great for
3816 debugging or dynamical data analysis.
3823 debugging or dynamical data analysis.
3817
3824
3818 2001-12-08 Fernando Perez <fperez@colorado.edu>
3825 2001-12-08 Fernando Perez <fperez@colorado.edu>
3819
3826
3820 * Fixed small bug preventing seeing info from methods of defined
3827 * Fixed small bug preventing seeing info from methods of defined
3821 objects (incorrect namespace in _ofind()).
3828 objects (incorrect namespace in _ofind()).
3822
3829
3823 * Documentation cleanup. Moved the main usage docstrings to a
3830 * Documentation cleanup. Moved the main usage docstrings to a
3824 separate file, usage.py (cleaner to maintain, and hopefully in the
3831 separate file, usage.py (cleaner to maintain, and hopefully in the
3825 future some perlpod-like way of producing interactive, man and
3832 future some perlpod-like way of producing interactive, man and
3826 html docs out of it will be found).
3833 html docs out of it will be found).
3827
3834
3828 * Added @profile to see your profile at any time.
3835 * Added @profile to see your profile at any time.
3829
3836
3830 * Added @p as an alias for 'print'. It's especially convenient if
3837 * Added @p as an alias for 'print'. It's especially convenient if
3831 using automagic ('p x' prints x).
3838 using automagic ('p x' prints x).
3832
3839
3833 * Small cleanups and fixes after a pychecker run.
3840 * Small cleanups and fixes after a pychecker run.
3834
3841
3835 * Changed the @cd command to handle @cd - and @cd -<n> for
3842 * Changed the @cd command to handle @cd - and @cd -<n> for
3836 visiting any directory in _dh.
3843 visiting any directory in _dh.
3837
3844
3838 * Introduced _dh, a history of visited directories. @dhist prints
3845 * Introduced _dh, a history of visited directories. @dhist prints
3839 it out with numbers.
3846 it out with numbers.
3840
3847
3841 2001-12-07 Fernando Perez <fperez@colorado.edu>
3848 2001-12-07 Fernando Perez <fperez@colorado.edu>
3842
3849
3843 * Released 0.1.22
3850 * Released 0.1.22
3844
3851
3845 * Made initialization a bit more robust against invalid color
3852 * Made initialization a bit more robust against invalid color
3846 options in user input (exit, not traceback-crash).
3853 options in user input (exit, not traceback-crash).
3847
3854
3848 * Changed the bug crash reporter to write the report only in the
3855 * Changed the bug crash reporter to write the report only in the
3849 user's .ipython directory. That way IPython won't litter people's
3856 user's .ipython directory. That way IPython won't litter people's
3850 hard disks with crash files all over the place. Also print on
3857 hard disks with crash files all over the place. Also print on
3851 screen the necessary mail command.
3858 screen the necessary mail command.
3852
3859
3853 * With the new ultraTB, implemented LightBG color scheme for light
3860 * With the new ultraTB, implemented LightBG color scheme for light
3854 background terminals. A lot of people like white backgrounds, so I
3861 background terminals. A lot of people like white backgrounds, so I
3855 guess we should at least give them something readable.
3862 guess we should at least give them something readable.
3856
3863
3857 2001-12-06 Fernando Perez <fperez@colorado.edu>
3864 2001-12-06 Fernando Perez <fperez@colorado.edu>
3858
3865
3859 * Modified the structure of ultraTB. Now there's a proper class
3866 * Modified the structure of ultraTB. Now there's a proper class
3860 for tables of color schemes which allow adding schemes easily and
3867 for tables of color schemes which allow adding schemes easily and
3861 switching the active scheme without creating a new instance every
3868 switching the active scheme without creating a new instance every
3862 time (which was ridiculous). The syntax for creating new schemes
3869 time (which was ridiculous). The syntax for creating new schemes
3863 is also cleaner. I think ultraTB is finally done, with a clean
3870 is also cleaner. I think ultraTB is finally done, with a clean
3864 class structure. Names are also much cleaner (now there's proper
3871 class structure. Names are also much cleaner (now there's proper
3865 color tables, no need for every variable to also have 'color' in
3872 color tables, no need for every variable to also have 'color' in
3866 its name).
3873 its name).
3867
3874
3868 * Broke down genutils into separate files. Now genutils only
3875 * Broke down genutils into separate files. Now genutils only
3869 contains utility functions, and classes have been moved to their
3876 contains utility functions, and classes have been moved to their
3870 own files (they had enough independent functionality to warrant
3877 own files (they had enough independent functionality to warrant
3871 it): ConfigLoader, OutputTrap, Struct.
3878 it): ConfigLoader, OutputTrap, Struct.
3872
3879
3873 2001-12-05 Fernando Perez <fperez@colorado.edu>
3880 2001-12-05 Fernando Perez <fperez@colorado.edu>
3874
3881
3875 * IPython turns 21! Released version 0.1.21, as a candidate for
3882 * IPython turns 21! Released version 0.1.21, as a candidate for
3876 public consumption. If all goes well, release in a few days.
3883 public consumption. If all goes well, release in a few days.
3877
3884
3878 * Fixed path bug (files in Extensions/ directory wouldn't be found
3885 * Fixed path bug (files in Extensions/ directory wouldn't be found
3879 unless IPython/ was explicitly in sys.path).
3886 unless IPython/ was explicitly in sys.path).
3880
3887
3881 * Extended the FlexCompleter class as MagicCompleter to allow
3888 * Extended the FlexCompleter class as MagicCompleter to allow
3882 completion of @-starting lines.
3889 completion of @-starting lines.
3883
3890
3884 * Created __release__.py file as a central repository for release
3891 * Created __release__.py file as a central repository for release
3885 info that other files can read from.
3892 info that other files can read from.
3886
3893
3887 * Fixed small bug in logging: when logging was turned on in
3894 * Fixed small bug in logging: when logging was turned on in
3888 mid-session, old lines with special meanings (!@?) were being
3895 mid-session, old lines with special meanings (!@?) were being
3889 logged without the prepended comment, which is necessary since
3896 logged without the prepended comment, which is necessary since
3890 they are not truly valid python syntax. This should make session
3897 they are not truly valid python syntax. This should make session
3891 restores produce less errors.
3898 restores produce less errors.
3892
3899
3893 * The namespace cleanup forced me to make a FlexCompleter class
3900 * The namespace cleanup forced me to make a FlexCompleter class
3894 which is nothing but a ripoff of rlcompleter, but with selectable
3901 which is nothing but a ripoff of rlcompleter, but with selectable
3895 namespace (rlcompleter only works in __main__.__dict__). I'll try
3902 namespace (rlcompleter only works in __main__.__dict__). I'll try
3896 to submit a note to the authors to see if this change can be
3903 to submit a note to the authors to see if this change can be
3897 incorporated in future rlcompleter releases (Dec.6: done)
3904 incorporated in future rlcompleter releases (Dec.6: done)
3898
3905
3899 * More fixes to namespace handling. It was a mess! Now all
3906 * More fixes to namespace handling. It was a mess! Now all
3900 explicit references to __main__.__dict__ are gone (except when
3907 explicit references to __main__.__dict__ are gone (except when
3901 really needed) and everything is handled through the namespace
3908 really needed) and everything is handled through the namespace
3902 dicts in the IPython instance. We seem to be getting somewhere
3909 dicts in the IPython instance. We seem to be getting somewhere
3903 with this, finally...
3910 with this, finally...
3904
3911
3905 * Small documentation updates.
3912 * Small documentation updates.
3906
3913
3907 * Created the Extensions directory under IPython (with an
3914 * Created the Extensions directory under IPython (with an
3908 __init__.py). Put the PhysicalQ stuff there. This directory should
3915 __init__.py). Put the PhysicalQ stuff there. This directory should
3909 be used for all special-purpose extensions.
3916 be used for all special-purpose extensions.
3910
3917
3911 * File renaming:
3918 * File renaming:
3912 ipythonlib --> ipmaker
3919 ipythonlib --> ipmaker
3913 ipplib --> iplib
3920 ipplib --> iplib
3914 This makes a bit more sense in terms of what these files actually do.
3921 This makes a bit more sense in terms of what these files actually do.
3915
3922
3916 * Moved all the classes and functions in ipythonlib to ipplib, so
3923 * Moved all the classes and functions in ipythonlib to ipplib, so
3917 now ipythonlib only has make_IPython(). This will ease up its
3924 now ipythonlib only has make_IPython(). This will ease up its
3918 splitting in smaller functional chunks later.
3925 splitting in smaller functional chunks later.
3919
3926
3920 * Cleaned up (done, I think) output of @whos. Better column
3927 * Cleaned up (done, I think) output of @whos. Better column
3921 formatting, and now shows str(var) for as much as it can, which is
3928 formatting, and now shows str(var) for as much as it can, which is
3922 typically what one gets with a 'print var'.
3929 typically what one gets with a 'print var'.
3923
3930
3924 2001-12-04 Fernando Perez <fperez@colorado.edu>
3931 2001-12-04 Fernando Perez <fperez@colorado.edu>
3925
3932
3926 * Fixed namespace problems. Now builtin/IPyhton/user names get
3933 * Fixed namespace problems. Now builtin/IPyhton/user names get
3927 properly reported in their namespace. Internal namespace handling
3934 properly reported in their namespace. Internal namespace handling
3928 is finally getting decent (not perfect yet, but much better than
3935 is finally getting decent (not perfect yet, but much better than
3929 the ad-hoc mess we had).
3936 the ad-hoc mess we had).
3930
3937
3931 * Removed -exit option. If people just want to run a python
3938 * Removed -exit option. If people just want to run a python
3932 script, that's what the normal interpreter is for. Less
3939 script, that's what the normal interpreter is for. Less
3933 unnecessary options, less chances for bugs.
3940 unnecessary options, less chances for bugs.
3934
3941
3935 * Added a crash handler which generates a complete post-mortem if
3942 * Added a crash handler which generates a complete post-mortem if
3936 IPython crashes. This will help a lot in tracking bugs down the
3943 IPython crashes. This will help a lot in tracking bugs down the
3937 road.
3944 road.
3938
3945
3939 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
3946 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
3940 which were boud to functions being reassigned would bypass the
3947 which were boud to functions being reassigned would bypass the
3941 logger, breaking the sync of _il with the prompt counter. This
3948 logger, breaking the sync of _il with the prompt counter. This
3942 would then crash IPython later when a new line was logged.
3949 would then crash IPython later when a new line was logged.
3943
3950
3944 2001-12-02 Fernando Perez <fperez@colorado.edu>
3951 2001-12-02 Fernando Perez <fperez@colorado.edu>
3945
3952
3946 * Made IPython a package. This means people don't have to clutter
3953 * Made IPython a package. This means people don't have to clutter
3947 their sys.path with yet another directory. Changed the INSTALL
3954 their sys.path with yet another directory. Changed the INSTALL
3948 file accordingly.
3955 file accordingly.
3949
3956
3950 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
3957 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
3951 sorts its output (so @who shows it sorted) and @whos formats the
3958 sorts its output (so @who shows it sorted) and @whos formats the
3952 table according to the width of the first column. Nicer, easier to
3959 table according to the width of the first column. Nicer, easier to
3953 read. Todo: write a generic table_format() which takes a list of
3960 read. Todo: write a generic table_format() which takes a list of
3954 lists and prints it nicely formatted, with optional row/column
3961 lists and prints it nicely formatted, with optional row/column
3955 separators and proper padding and justification.
3962 separators and proper padding and justification.
3956
3963
3957 * Released 0.1.20
3964 * Released 0.1.20
3958
3965
3959 * Fixed bug in @log which would reverse the inputcache list (a
3966 * Fixed bug in @log which would reverse the inputcache list (a
3960 copy operation was missing).
3967 copy operation was missing).
3961
3968
3962 * Code cleanup. @config was changed to use page(). Better, since
3969 * Code cleanup. @config was changed to use page(). Better, since
3963 its output is always quite long.
3970 its output is always quite long.
3964
3971
3965 * Itpl is back as a dependency. I was having too many problems
3972 * Itpl is back as a dependency. I was having too many problems
3966 getting the parametric aliases to work reliably, and it's just
3973 getting the parametric aliases to work reliably, and it's just
3967 easier to code weird string operations with it than playing %()s
3974 easier to code weird string operations with it than playing %()s
3968 games. It's only ~6k, so I don't think it's too big a deal.
3975 games. It's only ~6k, so I don't think it's too big a deal.
3969
3976
3970 * Found (and fixed) a very nasty bug with history. !lines weren't
3977 * Found (and fixed) a very nasty bug with history. !lines weren't
3971 getting cached, and the out of sync caches would crash
3978 getting cached, and the out of sync caches would crash
3972 IPython. Fixed it by reorganizing the prefilter/handlers/logger
3979 IPython. Fixed it by reorganizing the prefilter/handlers/logger
3973 division of labor a bit better. Bug fixed, cleaner structure.
3980 division of labor a bit better. Bug fixed, cleaner structure.
3974
3981
3975 2001-12-01 Fernando Perez <fperez@colorado.edu>
3982 2001-12-01 Fernando Perez <fperez@colorado.edu>
3976
3983
3977 * Released 0.1.19
3984 * Released 0.1.19
3978
3985
3979 * Added option -n to @hist to prevent line number printing. Much
3986 * Added option -n to @hist to prevent line number printing. Much
3980 easier to copy/paste code this way.
3987 easier to copy/paste code this way.
3981
3988
3982 * Created global _il to hold the input list. Allows easy
3989 * Created global _il to hold the input list. Allows easy
3983 re-execution of blocks of code by slicing it (inspired by Janko's
3990 re-execution of blocks of code by slicing it (inspired by Janko's
3984 comment on 'macros').
3991 comment on 'macros').
3985
3992
3986 * Small fixes and doc updates.
3993 * Small fixes and doc updates.
3987
3994
3988 * Rewrote @history function (was @h). Renamed it to @hist, @h is
3995 * Rewrote @history function (was @h). Renamed it to @hist, @h is
3989 much too fragile with automagic. Handles properly multi-line
3996 much too fragile with automagic. Handles properly multi-line
3990 statements and takes parameters.
3997 statements and takes parameters.
3991
3998
3992 2001-11-30 Fernando Perez <fperez@colorado.edu>
3999 2001-11-30 Fernando Perez <fperez@colorado.edu>
3993
4000
3994 * Version 0.1.18 released.
4001 * Version 0.1.18 released.
3995
4002
3996 * Fixed nasty namespace bug in initial module imports.
4003 * Fixed nasty namespace bug in initial module imports.
3997
4004
3998 * Added copyright/license notes to all code files (except
4005 * Added copyright/license notes to all code files (except
3999 DPyGetOpt). For the time being, LGPL. That could change.
4006 DPyGetOpt). For the time being, LGPL. That could change.
4000
4007
4001 * Rewrote a much nicer README, updated INSTALL, cleaned up
4008 * Rewrote a much nicer README, updated INSTALL, cleaned up
4002 ipythonrc-* samples.
4009 ipythonrc-* samples.
4003
4010
4004 * Overall code/documentation cleanup. Basically ready for
4011 * Overall code/documentation cleanup. Basically ready for
4005 release. Only remaining thing: licence decision (LGPL?).
4012 release. Only remaining thing: licence decision (LGPL?).
4006
4013
4007 * Converted load_config to a class, ConfigLoader. Now recursion
4014 * Converted load_config to a class, ConfigLoader. Now recursion
4008 control is better organized. Doesn't include the same file twice.
4015 control is better organized. Doesn't include the same file twice.
4009
4016
4010 2001-11-29 Fernando Perez <fperez@colorado.edu>
4017 2001-11-29 Fernando Perez <fperez@colorado.edu>
4011
4018
4012 * Got input history working. Changed output history variables from
4019 * Got input history working. Changed output history variables from
4013 _p to _o so that _i is for input and _o for output. Just cleaner
4020 _p to _o so that _i is for input and _o for output. Just cleaner
4014 convention.
4021 convention.
4015
4022
4016 * Implemented parametric aliases. This pretty much allows the
4023 * Implemented parametric aliases. This pretty much allows the
4017 alias system to offer full-blown shell convenience, I think.
4024 alias system to offer full-blown shell convenience, I think.
4018
4025
4019 * Version 0.1.17 released, 0.1.18 opened.
4026 * Version 0.1.17 released, 0.1.18 opened.
4020
4027
4021 * dot_ipython/ipythonrc (alias): added documentation.
4028 * dot_ipython/ipythonrc (alias): added documentation.
4022 (xcolor): Fixed small bug (xcolors -> xcolor)
4029 (xcolor): Fixed small bug (xcolors -> xcolor)
4023
4030
4024 * Changed the alias system. Now alias is a magic command to define
4031 * Changed the alias system. Now alias is a magic command to define
4025 aliases just like the shell. Rationale: the builtin magics should
4032 aliases just like the shell. Rationale: the builtin magics should
4026 be there for things deeply connected to IPython's
4033 be there for things deeply connected to IPython's
4027 architecture. And this is a much lighter system for what I think
4034 architecture. And this is a much lighter system for what I think
4028 is the really important feature: allowing users to define quickly
4035 is the really important feature: allowing users to define quickly
4029 magics that will do shell things for them, so they can customize
4036 magics that will do shell things for them, so they can customize
4030 IPython easily to match their work habits. If someone is really
4037 IPython easily to match their work habits. If someone is really
4031 desperate to have another name for a builtin alias, they can
4038 desperate to have another name for a builtin alias, they can
4032 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
4039 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
4033 works.
4040 works.
4034
4041
4035 2001-11-28 Fernando Perez <fperez@colorado.edu>
4042 2001-11-28 Fernando Perez <fperez@colorado.edu>
4036
4043
4037 * Changed @file so that it opens the source file at the proper
4044 * Changed @file so that it opens the source file at the proper
4038 line. Since it uses less, if your EDITOR environment is
4045 line. Since it uses less, if your EDITOR environment is
4039 configured, typing v will immediately open your editor of choice
4046 configured, typing v will immediately open your editor of choice
4040 right at the line where the object is defined. Not as quick as
4047 right at the line where the object is defined. Not as quick as
4041 having a direct @edit command, but for all intents and purposes it
4048 having a direct @edit command, but for all intents and purposes it
4042 works. And I don't have to worry about writing @edit to deal with
4049 works. And I don't have to worry about writing @edit to deal with
4043 all the editors, less does that.
4050 all the editors, less does that.
4044
4051
4045 * Version 0.1.16 released, 0.1.17 opened.
4052 * Version 0.1.16 released, 0.1.17 opened.
4046
4053
4047 * Fixed some nasty bugs in the page/page_dumb combo that could
4054 * Fixed some nasty bugs in the page/page_dumb combo that could
4048 crash IPython.
4055 crash IPython.
4049
4056
4050 2001-11-27 Fernando Perez <fperez@colorado.edu>
4057 2001-11-27 Fernando Perez <fperez@colorado.edu>
4051
4058
4052 * Version 0.1.15 released, 0.1.16 opened.
4059 * Version 0.1.15 released, 0.1.16 opened.
4053
4060
4054 * Finally got ? and ?? to work for undefined things: now it's
4061 * Finally got ? and ?? to work for undefined things: now it's
4055 possible to type {}.get? and get information about the get method
4062 possible to type {}.get? and get information about the get method
4056 of dicts, or os.path? even if only os is defined (so technically
4063 of dicts, or os.path? even if only os is defined (so technically
4057 os.path isn't). Works at any level. For example, after import os,
4064 os.path isn't). Works at any level. For example, after import os,
4058 os?, os.path?, os.path.abspath? all work. This is great, took some
4065 os?, os.path?, os.path.abspath? all work. This is great, took some
4059 work in _ofind.
4066 work in _ofind.
4060
4067
4061 * Fixed more bugs with logging. The sanest way to do it was to add
4068 * Fixed more bugs with logging. The sanest way to do it was to add
4062 to @log a 'mode' parameter. Killed two in one shot (this mode
4069 to @log a 'mode' parameter. Killed two in one shot (this mode
4063 option was a request of Janko's). I think it's finally clean
4070 option was a request of Janko's). I think it's finally clean
4064 (famous last words).
4071 (famous last words).
4065
4072
4066 * Added a page_dumb() pager which does a decent job of paging on
4073 * Added a page_dumb() pager which does a decent job of paging on
4067 screen, if better things (like less) aren't available. One less
4074 screen, if better things (like less) aren't available. One less
4068 unix dependency (someday maybe somebody will port this to
4075 unix dependency (someday maybe somebody will port this to
4069 windows).
4076 windows).
4070
4077
4071 * Fixed problem in magic_log: would lock of logging out if log
4078 * Fixed problem in magic_log: would lock of logging out if log
4072 creation failed (because it would still think it had succeeded).
4079 creation failed (because it would still think it had succeeded).
4073
4080
4074 * Improved the page() function using curses to auto-detect screen
4081 * Improved the page() function using curses to auto-detect screen
4075 size. Now it can make a much better decision on whether to print
4082 size. Now it can make a much better decision on whether to print
4076 or page a string. Option screen_length was modified: a value 0
4083 or page a string. Option screen_length was modified: a value 0
4077 means auto-detect, and that's the default now.
4084 means auto-detect, and that's the default now.
4078
4085
4079 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
4086 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
4080 go out. I'll test it for a few days, then talk to Janko about
4087 go out. I'll test it for a few days, then talk to Janko about
4081 licences and announce it.
4088 licences and announce it.
4082
4089
4083 * Fixed the length of the auto-generated ---> prompt which appears
4090 * Fixed the length of the auto-generated ---> prompt which appears
4084 for auto-parens and auto-quotes. Getting this right isn't trivial,
4091 for auto-parens and auto-quotes. Getting this right isn't trivial,
4085 with all the color escapes, different prompt types and optional
4092 with all the color escapes, different prompt types and optional
4086 separators. But it seems to be working in all the combinations.
4093 separators. But it seems to be working in all the combinations.
4087
4094
4088 2001-11-26 Fernando Perez <fperez@colorado.edu>
4095 2001-11-26 Fernando Perez <fperez@colorado.edu>
4089
4096
4090 * Wrote a regexp filter to get option types from the option names
4097 * Wrote a regexp filter to get option types from the option names
4091 string. This eliminates the need to manually keep two duplicate
4098 string. This eliminates the need to manually keep two duplicate
4092 lists.
4099 lists.
4093
4100
4094 * Removed the unneeded check_option_names. Now options are handled
4101 * Removed the unneeded check_option_names. Now options are handled
4095 in a much saner manner and it's easy to visually check that things
4102 in a much saner manner and it's easy to visually check that things
4096 are ok.
4103 are ok.
4097
4104
4098 * Updated version numbers on all files I modified to carry a
4105 * Updated version numbers on all files I modified to carry a
4099 notice so Janko and Nathan have clear version markers.
4106 notice so Janko and Nathan have clear version markers.
4100
4107
4101 * Updated docstring for ultraTB with my changes. I should send
4108 * Updated docstring for ultraTB with my changes. I should send
4102 this to Nathan.
4109 this to Nathan.
4103
4110
4104 * Lots of small fixes. Ran everything through pychecker again.
4111 * Lots of small fixes. Ran everything through pychecker again.
4105
4112
4106 * Made loading of deep_reload an cmd line option. If it's not too
4113 * Made loading of deep_reload an cmd line option. If it's not too
4107 kosher, now people can just disable it. With -nodeep_reload it's
4114 kosher, now people can just disable it. With -nodeep_reload it's
4108 still available as dreload(), it just won't overwrite reload().
4115 still available as dreload(), it just won't overwrite reload().
4109
4116
4110 * Moved many options to the no| form (-opt and -noopt
4117 * Moved many options to the no| form (-opt and -noopt
4111 accepted). Cleaner.
4118 accepted). Cleaner.
4112
4119
4113 * Changed magic_log so that if called with no parameters, it uses
4120 * Changed magic_log so that if called with no parameters, it uses
4114 'rotate' mode. That way auto-generated logs aren't automatically
4121 'rotate' mode. That way auto-generated logs aren't automatically
4115 over-written. For normal logs, now a backup is made if it exists
4122 over-written. For normal logs, now a backup is made if it exists
4116 (only 1 level of backups). A new 'backup' mode was added to the
4123 (only 1 level of backups). A new 'backup' mode was added to the
4117 Logger class to support this. This was a request by Janko.
4124 Logger class to support this. This was a request by Janko.
4118
4125
4119 * Added @logoff/@logon to stop/restart an active log.
4126 * Added @logoff/@logon to stop/restart an active log.
4120
4127
4121 * Fixed a lot of bugs in log saving/replay. It was pretty
4128 * Fixed a lot of bugs in log saving/replay. It was pretty
4122 broken. Now special lines (!@,/) appear properly in the command
4129 broken. Now special lines (!@,/) appear properly in the command
4123 history after a log replay.
4130 history after a log replay.
4124
4131
4125 * Tried and failed to implement full session saving via pickle. My
4132 * Tried and failed to implement full session saving via pickle. My
4126 idea was to pickle __main__.__dict__, but modules can't be
4133 idea was to pickle __main__.__dict__, but modules can't be
4127 pickled. This would be a better alternative to replaying logs, but
4134 pickled. This would be a better alternative to replaying logs, but
4128 seems quite tricky to get to work. Changed -session to be called
4135 seems quite tricky to get to work. Changed -session to be called
4129 -logplay, which more accurately reflects what it does. And if we
4136 -logplay, which more accurately reflects what it does. And if we
4130 ever get real session saving working, -session is now available.
4137 ever get real session saving working, -session is now available.
4131
4138
4132 * Implemented color schemes for prompts also. As for tracebacks,
4139 * Implemented color schemes for prompts also. As for tracebacks,
4133 currently only NoColor and Linux are supported. But now the
4140 currently only NoColor and Linux are supported. But now the
4134 infrastructure is in place, based on a generic ColorScheme
4141 infrastructure is in place, based on a generic ColorScheme
4135 class. So writing and activating new schemes both for the prompts
4142 class. So writing and activating new schemes both for the prompts
4136 and the tracebacks should be straightforward.
4143 and the tracebacks should be straightforward.
4137
4144
4138 * Version 0.1.13 released, 0.1.14 opened.
4145 * Version 0.1.13 released, 0.1.14 opened.
4139
4146
4140 * Changed handling of options for output cache. Now counter is
4147 * Changed handling of options for output cache. Now counter is
4141 hardwired starting at 1 and one specifies the maximum number of
4148 hardwired starting at 1 and one specifies the maximum number of
4142 entries *in the outcache* (not the max prompt counter). This is
4149 entries *in the outcache* (not the max prompt counter). This is
4143 much better, since many statements won't increase the cache
4150 much better, since many statements won't increase the cache
4144 count. It also eliminated some confusing options, now there's only
4151 count. It also eliminated some confusing options, now there's only
4145 one: cache_size.
4152 one: cache_size.
4146
4153
4147 * Added 'alias' magic function and magic_alias option in the
4154 * Added 'alias' magic function and magic_alias option in the
4148 ipythonrc file. Now the user can easily define whatever names he
4155 ipythonrc file. Now the user can easily define whatever names he
4149 wants for the magic functions without having to play weird
4156 wants for the magic functions without having to play weird
4150 namespace games. This gives IPython a real shell-like feel.
4157 namespace games. This gives IPython a real shell-like feel.
4151
4158
4152 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
4159 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
4153 @ or not).
4160 @ or not).
4154
4161
4155 This was one of the last remaining 'visible' bugs (that I know
4162 This was one of the last remaining 'visible' bugs (that I know
4156 of). I think if I can clean up the session loading so it works
4163 of). I think if I can clean up the session loading so it works
4157 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
4164 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
4158 about licensing).
4165 about licensing).
4159
4166
4160 2001-11-25 Fernando Perez <fperez@colorado.edu>
4167 2001-11-25 Fernando Perez <fperez@colorado.edu>
4161
4168
4162 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
4169 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
4163 there's a cleaner distinction between what ? and ?? show.
4170 there's a cleaner distinction between what ? and ?? show.
4164
4171
4165 * Added screen_length option. Now the user can define his own
4172 * Added screen_length option. Now the user can define his own
4166 screen size for page() operations.
4173 screen size for page() operations.
4167
4174
4168 * Implemented magic shell-like functions with automatic code
4175 * Implemented magic shell-like functions with automatic code
4169 generation. Now adding another function is just a matter of adding
4176 generation. Now adding another function is just a matter of adding
4170 an entry to a dict, and the function is dynamically generated at
4177 an entry to a dict, and the function is dynamically generated at
4171 run-time. Python has some really cool features!
4178 run-time. Python has some really cool features!
4172
4179
4173 * Renamed many options to cleanup conventions a little. Now all
4180 * Renamed many options to cleanup conventions a little. Now all
4174 are lowercase, and only underscores where needed. Also in the code
4181 are lowercase, and only underscores where needed. Also in the code
4175 option name tables are clearer.
4182 option name tables are clearer.
4176
4183
4177 * Changed prompts a little. Now input is 'In [n]:' instead of
4184 * Changed prompts a little. Now input is 'In [n]:' instead of
4178 'In[n]:='. This allows it the numbers to be aligned with the
4185 'In[n]:='. This allows it the numbers to be aligned with the
4179 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4186 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4180 Python (it was a Mathematica thing). The '...' continuation prompt
4187 Python (it was a Mathematica thing). The '...' continuation prompt
4181 was also changed a little to align better.
4188 was also changed a little to align better.
4182
4189
4183 * Fixed bug when flushing output cache. Not all _p<n> variables
4190 * Fixed bug when flushing output cache. Not all _p<n> variables
4184 exist, so their deletion needs to be wrapped in a try:
4191 exist, so their deletion needs to be wrapped in a try:
4185
4192
4186 * Figured out how to properly use inspect.formatargspec() (it
4193 * Figured out how to properly use inspect.formatargspec() (it
4187 requires the args preceded by *). So I removed all the code from
4194 requires the args preceded by *). So I removed all the code from
4188 _get_pdef in Magic, which was just replicating that.
4195 _get_pdef in Magic, which was just replicating that.
4189
4196
4190 * Added test to prefilter to allow redefining magic function names
4197 * Added test to prefilter to allow redefining magic function names
4191 as variables. This is ok, since the @ form is always available,
4198 as variables. This is ok, since the @ form is always available,
4192 but whe should allow the user to define a variable called 'ls' if
4199 but whe should allow the user to define a variable called 'ls' if
4193 he needs it.
4200 he needs it.
4194
4201
4195 * Moved the ToDo information from README into a separate ToDo.
4202 * Moved the ToDo information from README into a separate ToDo.
4196
4203
4197 * General code cleanup and small bugfixes. I think it's close to a
4204 * General code cleanup and small bugfixes. I think it's close to a
4198 state where it can be released, obviously with a big 'beta'
4205 state where it can be released, obviously with a big 'beta'
4199 warning on it.
4206 warning on it.
4200
4207
4201 * Got the magic function split to work. Now all magics are defined
4208 * Got the magic function split to work. Now all magics are defined
4202 in a separate class. It just organizes things a bit, and now
4209 in a separate class. It just organizes things a bit, and now
4203 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4210 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4204 was too long).
4211 was too long).
4205
4212
4206 * Changed @clear to @reset to avoid potential confusions with
4213 * Changed @clear to @reset to avoid potential confusions with
4207 the shell command clear. Also renamed @cl to @clear, which does
4214 the shell command clear. Also renamed @cl to @clear, which does
4208 exactly what people expect it to from their shell experience.
4215 exactly what people expect it to from their shell experience.
4209
4216
4210 Added a check to the @reset command (since it's so
4217 Added a check to the @reset command (since it's so
4211 destructive, it's probably a good idea to ask for confirmation).
4218 destructive, it's probably a good idea to ask for confirmation).
4212 But now reset only works for full namespace resetting. Since the
4219 But now reset only works for full namespace resetting. Since the
4213 del keyword is already there for deleting a few specific
4220 del keyword is already there for deleting a few specific
4214 variables, I don't see the point of having a redundant magic
4221 variables, I don't see the point of having a redundant magic
4215 function for the same task.
4222 function for the same task.
4216
4223
4217 2001-11-24 Fernando Perez <fperez@colorado.edu>
4224 2001-11-24 Fernando Perez <fperez@colorado.edu>
4218
4225
4219 * Updated the builtin docs (esp. the ? ones).
4226 * Updated the builtin docs (esp. the ? ones).
4220
4227
4221 * Ran all the code through pychecker. Not terribly impressed with
4228 * Ran all the code through pychecker. Not terribly impressed with
4222 it: lots of spurious warnings and didn't really find anything of
4229 it: lots of spurious warnings and didn't really find anything of
4223 substance (just a few modules being imported and not used).
4230 substance (just a few modules being imported and not used).
4224
4231
4225 * Implemented the new ultraTB functionality into IPython. New
4232 * Implemented the new ultraTB functionality into IPython. New
4226 option: xcolors. This chooses color scheme. xmode now only selects
4233 option: xcolors. This chooses color scheme. xmode now only selects
4227 between Plain and Verbose. Better orthogonality.
4234 between Plain and Verbose. Better orthogonality.
4228
4235
4229 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4236 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4230 mode and color scheme for the exception handlers. Now it's
4237 mode and color scheme for the exception handlers. Now it's
4231 possible to have the verbose traceback with no coloring.
4238 possible to have the verbose traceback with no coloring.
4232
4239
4233 2001-11-23 Fernando Perez <fperez@colorado.edu>
4240 2001-11-23 Fernando Perez <fperez@colorado.edu>
4234
4241
4235 * Version 0.1.12 released, 0.1.13 opened.
4242 * Version 0.1.12 released, 0.1.13 opened.
4236
4243
4237 * Removed option to set auto-quote and auto-paren escapes by
4244 * Removed option to set auto-quote and auto-paren escapes by
4238 user. The chances of breaking valid syntax are just too high. If
4245 user. The chances of breaking valid syntax are just too high. If
4239 someone *really* wants, they can always dig into the code.
4246 someone *really* wants, they can always dig into the code.
4240
4247
4241 * Made prompt separators configurable.
4248 * Made prompt separators configurable.
4242
4249
4243 2001-11-22 Fernando Perez <fperez@colorado.edu>
4250 2001-11-22 Fernando Perez <fperez@colorado.edu>
4244
4251
4245 * Small bugfixes in many places.
4252 * Small bugfixes in many places.
4246
4253
4247 * Removed the MyCompleter class from ipplib. It seemed redundant
4254 * Removed the MyCompleter class from ipplib. It seemed redundant
4248 with the C-p,C-n history search functionality. Less code to
4255 with the C-p,C-n history search functionality. Less code to
4249 maintain.
4256 maintain.
4250
4257
4251 * Moved all the original ipython.py code into ipythonlib.py. Right
4258 * Moved all the original ipython.py code into ipythonlib.py. Right
4252 now it's just one big dump into a function called make_IPython, so
4259 now it's just one big dump into a function called make_IPython, so
4253 no real modularity has been gained. But at least it makes the
4260 no real modularity has been gained. But at least it makes the
4254 wrapper script tiny, and since ipythonlib is a module, it gets
4261 wrapper script tiny, and since ipythonlib is a module, it gets
4255 compiled and startup is much faster.
4262 compiled and startup is much faster.
4256
4263
4257 This is a reasobably 'deep' change, so we should test it for a
4264 This is a reasobably 'deep' change, so we should test it for a
4258 while without messing too much more with the code.
4265 while without messing too much more with the code.
4259
4266
4260 2001-11-21 Fernando Perez <fperez@colorado.edu>
4267 2001-11-21 Fernando Perez <fperez@colorado.edu>
4261
4268
4262 * Version 0.1.11 released, 0.1.12 opened for further work.
4269 * Version 0.1.11 released, 0.1.12 opened for further work.
4263
4270
4264 * Removed dependency on Itpl. It was only needed in one place. It
4271 * Removed dependency on Itpl. It was only needed in one place. It
4265 would be nice if this became part of python, though. It makes life
4272 would be nice if this became part of python, though. It makes life
4266 *a lot* easier in some cases.
4273 *a lot* easier in some cases.
4267
4274
4268 * Simplified the prefilter code a bit. Now all handlers are
4275 * Simplified the prefilter code a bit. Now all handlers are
4269 expected to explicitly return a value (at least a blank string).
4276 expected to explicitly return a value (at least a blank string).
4270
4277
4271 * Heavy edits in ipplib. Removed the help system altogether. Now
4278 * Heavy edits in ipplib. Removed the help system altogether. Now
4272 obj?/?? is used for inspecting objects, a magic @doc prints
4279 obj?/?? is used for inspecting objects, a magic @doc prints
4273 docstrings, and full-blown Python help is accessed via the 'help'
4280 docstrings, and full-blown Python help is accessed via the 'help'
4274 keyword. This cleans up a lot of code (less to maintain) and does
4281 keyword. This cleans up a lot of code (less to maintain) and does
4275 the job. Since 'help' is now a standard Python component, might as
4282 the job. Since 'help' is now a standard Python component, might as
4276 well use it and remove duplicate functionality.
4283 well use it and remove duplicate functionality.
4277
4284
4278 Also removed the option to use ipplib as a standalone program. By
4285 Also removed the option to use ipplib as a standalone program. By
4279 now it's too dependent on other parts of IPython to function alone.
4286 now it's too dependent on other parts of IPython to function alone.
4280
4287
4281 * Fixed bug in genutils.pager. It would crash if the pager was
4288 * Fixed bug in genutils.pager. It would crash if the pager was
4282 exited immediately after opening (broken pipe).
4289 exited immediately after opening (broken pipe).
4283
4290
4284 * Trimmed down the VerboseTB reporting a little. The header is
4291 * Trimmed down the VerboseTB reporting a little. The header is
4285 much shorter now and the repeated exception arguments at the end
4292 much shorter now and the repeated exception arguments at the end
4286 have been removed. For interactive use the old header seemed a bit
4293 have been removed. For interactive use the old header seemed a bit
4287 excessive.
4294 excessive.
4288
4295
4289 * Fixed small bug in output of @whos for variables with multi-word
4296 * Fixed small bug in output of @whos for variables with multi-word
4290 types (only first word was displayed).
4297 types (only first word was displayed).
4291
4298
4292 2001-11-17 Fernando Perez <fperez@colorado.edu>
4299 2001-11-17 Fernando Perez <fperez@colorado.edu>
4293
4300
4294 * Version 0.1.10 released, 0.1.11 opened for further work.
4301 * Version 0.1.10 released, 0.1.11 opened for further work.
4295
4302
4296 * Modified dirs and friends. dirs now *returns* the stack (not
4303 * Modified dirs and friends. dirs now *returns* the stack (not
4297 prints), so one can manipulate it as a variable. Convenient to
4304 prints), so one can manipulate it as a variable. Convenient to
4298 travel along many directories.
4305 travel along many directories.
4299
4306
4300 * Fixed bug in magic_pdef: would only work with functions with
4307 * Fixed bug in magic_pdef: would only work with functions with
4301 arguments with default values.
4308 arguments with default values.
4302
4309
4303 2001-11-14 Fernando Perez <fperez@colorado.edu>
4310 2001-11-14 Fernando Perez <fperez@colorado.edu>
4304
4311
4305 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4312 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4306 example with IPython. Various other minor fixes and cleanups.
4313 example with IPython. Various other minor fixes and cleanups.
4307
4314
4308 * Version 0.1.9 released, 0.1.10 opened for further work.
4315 * Version 0.1.9 released, 0.1.10 opened for further work.
4309
4316
4310 * Added sys.path to the list of directories searched in the
4317 * Added sys.path to the list of directories searched in the
4311 execfile= option. It used to be the current directory and the
4318 execfile= option. It used to be the current directory and the
4312 user's IPYTHONDIR only.
4319 user's IPYTHONDIR only.
4313
4320
4314 2001-11-13 Fernando Perez <fperez@colorado.edu>
4321 2001-11-13 Fernando Perez <fperez@colorado.edu>
4315
4322
4316 * Reinstated the raw_input/prefilter separation that Janko had
4323 * Reinstated the raw_input/prefilter separation that Janko had
4317 initially. This gives a more convenient setup for extending the
4324 initially. This gives a more convenient setup for extending the
4318 pre-processor from the outside: raw_input always gets a string,
4325 pre-processor from the outside: raw_input always gets a string,
4319 and prefilter has to process it. We can then redefine prefilter
4326 and prefilter has to process it. We can then redefine prefilter
4320 from the outside and implement extensions for special
4327 from the outside and implement extensions for special
4321 purposes.
4328 purposes.
4322
4329
4323 Today I got one for inputting PhysicalQuantity objects
4330 Today I got one for inputting PhysicalQuantity objects
4324 (from Scientific) without needing any function calls at
4331 (from Scientific) without needing any function calls at
4325 all. Extremely convenient, and it's all done as a user-level
4332 all. Extremely convenient, and it's all done as a user-level
4326 extension (no IPython code was touched). Now instead of:
4333 extension (no IPython code was touched). Now instead of:
4327 a = PhysicalQuantity(4.2,'m/s**2')
4334 a = PhysicalQuantity(4.2,'m/s**2')
4328 one can simply say
4335 one can simply say
4329 a = 4.2 m/s**2
4336 a = 4.2 m/s**2
4330 or even
4337 or even
4331 a = 4.2 m/s^2
4338 a = 4.2 m/s^2
4332
4339
4333 I use this, but it's also a proof of concept: IPython really is
4340 I use this, but it's also a proof of concept: IPython really is
4334 fully user-extensible, even at the level of the parsing of the
4341 fully user-extensible, even at the level of the parsing of the
4335 command line. It's not trivial, but it's perfectly doable.
4342 command line. It's not trivial, but it's perfectly doable.
4336
4343
4337 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4344 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4338 the problem of modules being loaded in the inverse order in which
4345 the problem of modules being loaded in the inverse order in which
4339 they were defined in
4346 they were defined in
4340
4347
4341 * Version 0.1.8 released, 0.1.9 opened for further work.
4348 * Version 0.1.8 released, 0.1.9 opened for further work.
4342
4349
4343 * Added magics pdef, source and file. They respectively show the
4350 * Added magics pdef, source and file. They respectively show the
4344 definition line ('prototype' in C), source code and full python
4351 definition line ('prototype' in C), source code and full python
4345 file for any callable object. The object inspector oinfo uses
4352 file for any callable object. The object inspector oinfo uses
4346 these to show the same information.
4353 these to show the same information.
4347
4354
4348 * Version 0.1.7 released, 0.1.8 opened for further work.
4355 * Version 0.1.7 released, 0.1.8 opened for further work.
4349
4356
4350 * Separated all the magic functions into a class called Magic. The
4357 * Separated all the magic functions into a class called Magic. The
4351 InteractiveShell class was becoming too big for Xemacs to handle
4358 InteractiveShell class was becoming too big for Xemacs to handle
4352 (de-indenting a line would lock it up for 10 seconds while it
4359 (de-indenting a line would lock it up for 10 seconds while it
4353 backtracked on the whole class!)
4360 backtracked on the whole class!)
4354
4361
4355 FIXME: didn't work. It can be done, but right now namespaces are
4362 FIXME: didn't work. It can be done, but right now namespaces are
4356 all messed up. Do it later (reverted it for now, so at least
4363 all messed up. Do it later (reverted it for now, so at least
4357 everything works as before).
4364 everything works as before).
4358
4365
4359 * Got the object introspection system (magic_oinfo) working! I
4366 * Got the object introspection system (magic_oinfo) working! I
4360 think this is pretty much ready for release to Janko, so he can
4367 think this is pretty much ready for release to Janko, so he can
4361 test it for a while and then announce it. Pretty much 100% of what
4368 test it for a while and then announce it. Pretty much 100% of what
4362 I wanted for the 'phase 1' release is ready. Happy, tired.
4369 I wanted for the 'phase 1' release is ready. Happy, tired.
4363
4370
4364 2001-11-12 Fernando Perez <fperez@colorado.edu>
4371 2001-11-12 Fernando Perez <fperez@colorado.edu>
4365
4372
4366 * Version 0.1.6 released, 0.1.7 opened for further work.
4373 * Version 0.1.6 released, 0.1.7 opened for further work.
4367
4374
4368 * Fixed bug in printing: it used to test for truth before
4375 * Fixed bug in printing: it used to test for truth before
4369 printing, so 0 wouldn't print. Now checks for None.
4376 printing, so 0 wouldn't print. Now checks for None.
4370
4377
4371 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4378 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4372 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4379 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4373 reaches by hand into the outputcache. Think of a better way to do
4380 reaches by hand into the outputcache. Think of a better way to do
4374 this later.
4381 this later.
4375
4382
4376 * Various small fixes thanks to Nathan's comments.
4383 * Various small fixes thanks to Nathan's comments.
4377
4384
4378 * Changed magic_pprint to magic_Pprint. This way it doesn't
4385 * Changed magic_pprint to magic_Pprint. This way it doesn't
4379 collide with pprint() and the name is consistent with the command
4386 collide with pprint() and the name is consistent with the command
4380 line option.
4387 line option.
4381
4388
4382 * Changed prompt counter behavior to be fully like
4389 * Changed prompt counter behavior to be fully like
4383 Mathematica's. That is, even input that doesn't return a result
4390 Mathematica's. That is, even input that doesn't return a result
4384 raises the prompt counter. The old behavior was kind of confusing
4391 raises the prompt counter. The old behavior was kind of confusing
4385 (getting the same prompt number several times if the operation
4392 (getting the same prompt number several times if the operation
4386 didn't return a result).
4393 didn't return a result).
4387
4394
4388 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4395 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4389
4396
4390 * Fixed -Classic mode (wasn't working anymore).
4397 * Fixed -Classic mode (wasn't working anymore).
4391
4398
4392 * Added colored prompts using Nathan's new code. Colors are
4399 * Added colored prompts using Nathan's new code. Colors are
4393 currently hardwired, they can be user-configurable. For
4400 currently hardwired, they can be user-configurable. For
4394 developers, they can be chosen in file ipythonlib.py, at the
4401 developers, they can be chosen in file ipythonlib.py, at the
4395 beginning of the CachedOutput class def.
4402 beginning of the CachedOutput class def.
4396
4403
4397 2001-11-11 Fernando Perez <fperez@colorado.edu>
4404 2001-11-11 Fernando Perez <fperez@colorado.edu>
4398
4405
4399 * Version 0.1.5 released, 0.1.6 opened for further work.
4406 * Version 0.1.5 released, 0.1.6 opened for further work.
4400
4407
4401 * Changed magic_env to *return* the environment as a dict (not to
4408 * Changed magic_env to *return* the environment as a dict (not to
4402 print it). This way it prints, but it can also be processed.
4409 print it). This way it prints, but it can also be processed.
4403
4410
4404 * Added Verbose exception reporting to interactive
4411 * Added Verbose exception reporting to interactive
4405 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4412 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4406 traceback. Had to make some changes to the ultraTB file. This is
4413 traceback. Had to make some changes to the ultraTB file. This is
4407 probably the last 'big' thing in my mental todo list. This ties
4414 probably the last 'big' thing in my mental todo list. This ties
4408 in with the next entry:
4415 in with the next entry:
4409
4416
4410 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4417 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4411 has to specify is Plain, Color or Verbose for all exception
4418 has to specify is Plain, Color or Verbose for all exception
4412 handling.
4419 handling.
4413
4420
4414 * Removed ShellServices option. All this can really be done via
4421 * Removed ShellServices option. All this can really be done via
4415 the magic system. It's easier to extend, cleaner and has automatic
4422 the magic system. It's easier to extend, cleaner and has automatic
4416 namespace protection and documentation.
4423 namespace protection and documentation.
4417
4424
4418 2001-11-09 Fernando Perez <fperez@colorado.edu>
4425 2001-11-09 Fernando Perez <fperez@colorado.edu>
4419
4426
4420 * Fixed bug in output cache flushing (missing parameter to
4427 * Fixed bug in output cache flushing (missing parameter to
4421 __init__). Other small bugs fixed (found using pychecker).
4428 __init__). Other small bugs fixed (found using pychecker).
4422
4429
4423 * Version 0.1.4 opened for bugfixing.
4430 * Version 0.1.4 opened for bugfixing.
4424
4431
4425 2001-11-07 Fernando Perez <fperez@colorado.edu>
4432 2001-11-07 Fernando Perez <fperez@colorado.edu>
4426
4433
4427 * Version 0.1.3 released, mainly because of the raw_input bug.
4434 * Version 0.1.3 released, mainly because of the raw_input bug.
4428
4435
4429 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4436 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4430 and when testing for whether things were callable, a call could
4437 and when testing for whether things were callable, a call could
4431 actually be made to certain functions. They would get called again
4438 actually be made to certain functions. They would get called again
4432 once 'really' executed, with a resulting double call. A disaster
4439 once 'really' executed, with a resulting double call. A disaster
4433 in many cases (list.reverse() would never work!).
4440 in many cases (list.reverse() would never work!).
4434
4441
4435 * Removed prefilter() function, moved its code to raw_input (which
4442 * Removed prefilter() function, moved its code to raw_input (which
4436 after all was just a near-empty caller for prefilter). This saves
4443 after all was just a near-empty caller for prefilter). This saves
4437 a function call on every prompt, and simplifies the class a tiny bit.
4444 a function call on every prompt, and simplifies the class a tiny bit.
4438
4445
4439 * Fix _ip to __ip name in magic example file.
4446 * Fix _ip to __ip name in magic example file.
4440
4447
4441 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4448 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4442 work with non-gnu versions of tar.
4449 work with non-gnu versions of tar.
4443
4450
4444 2001-11-06 Fernando Perez <fperez@colorado.edu>
4451 2001-11-06 Fernando Perez <fperez@colorado.edu>
4445
4452
4446 * Version 0.1.2. Just to keep track of the recent changes.
4453 * Version 0.1.2. Just to keep track of the recent changes.
4447
4454
4448 * Fixed nasty bug in output prompt routine. It used to check 'if
4455 * Fixed nasty bug in output prompt routine. It used to check 'if
4449 arg != None...'. Problem is, this fails if arg implements a
4456 arg != None...'. Problem is, this fails if arg implements a
4450 special comparison (__cmp__) which disallows comparing to
4457 special comparison (__cmp__) which disallows comparing to
4451 None. Found it when trying to use the PhysicalQuantity module from
4458 None. Found it when trying to use the PhysicalQuantity module from
4452 ScientificPython.
4459 ScientificPython.
4453
4460
4454 2001-11-05 Fernando Perez <fperez@colorado.edu>
4461 2001-11-05 Fernando Perez <fperez@colorado.edu>
4455
4462
4456 * Also added dirs. Now the pushd/popd/dirs family functions
4463 * Also added dirs. Now the pushd/popd/dirs family functions
4457 basically like the shell, with the added convenience of going home
4464 basically like the shell, with the added convenience of going home
4458 when called with no args.
4465 when called with no args.
4459
4466
4460 * pushd/popd slightly modified to mimic shell behavior more
4467 * pushd/popd slightly modified to mimic shell behavior more
4461 closely.
4468 closely.
4462
4469
4463 * Added env,pushd,popd from ShellServices as magic functions. I
4470 * Added env,pushd,popd from ShellServices as magic functions. I
4464 think the cleanest will be to port all desired functions from
4471 think the cleanest will be to port all desired functions from
4465 ShellServices as magics and remove ShellServices altogether. This
4472 ShellServices as magics and remove ShellServices altogether. This
4466 will provide a single, clean way of adding functionality
4473 will provide a single, clean way of adding functionality
4467 (shell-type or otherwise) to IP.
4474 (shell-type or otherwise) to IP.
4468
4475
4469 2001-11-04 Fernando Perez <fperez@colorado.edu>
4476 2001-11-04 Fernando Perez <fperez@colorado.edu>
4470
4477
4471 * Added .ipython/ directory to sys.path. This way users can keep
4478 * Added .ipython/ directory to sys.path. This way users can keep
4472 customizations there and access them via import.
4479 customizations there and access them via import.
4473
4480
4474 2001-11-03 Fernando Perez <fperez@colorado.edu>
4481 2001-11-03 Fernando Perez <fperez@colorado.edu>
4475
4482
4476 * Opened version 0.1.1 for new changes.
4483 * Opened version 0.1.1 for new changes.
4477
4484
4478 * Changed version number to 0.1.0: first 'public' release, sent to
4485 * Changed version number to 0.1.0: first 'public' release, sent to
4479 Nathan and Janko.
4486 Nathan and Janko.
4480
4487
4481 * Lots of small fixes and tweaks.
4488 * Lots of small fixes and tweaks.
4482
4489
4483 * Minor changes to whos format. Now strings are shown, snipped if
4490 * Minor changes to whos format. Now strings are shown, snipped if
4484 too long.
4491 too long.
4485
4492
4486 * Changed ShellServices to work on __main__ so they show up in @who
4493 * Changed ShellServices to work on __main__ so they show up in @who
4487
4494
4488 * Help also works with ? at the end of a line:
4495 * Help also works with ? at the end of a line:
4489 ?sin and sin?
4496 ?sin and sin?
4490 both produce the same effect. This is nice, as often I use the
4497 both produce the same effect. This is nice, as often I use the
4491 tab-complete to find the name of a method, but I used to then have
4498 tab-complete to find the name of a method, but I used to then have
4492 to go to the beginning of the line to put a ? if I wanted more
4499 to go to the beginning of the line to put a ? if I wanted more
4493 info. Now I can just add the ? and hit return. Convenient.
4500 info. Now I can just add the ? and hit return. Convenient.
4494
4501
4495 2001-11-02 Fernando Perez <fperez@colorado.edu>
4502 2001-11-02 Fernando Perez <fperez@colorado.edu>
4496
4503
4497 * Python version check (>=2.1) added.
4504 * Python version check (>=2.1) added.
4498
4505
4499 * Added LazyPython documentation. At this point the docs are quite
4506 * Added LazyPython documentation. At this point the docs are quite
4500 a mess. A cleanup is in order.
4507 a mess. A cleanup is in order.
4501
4508
4502 * Auto-installer created. For some bizarre reason, the zipfiles
4509 * Auto-installer created. For some bizarre reason, the zipfiles
4503 module isn't working on my system. So I made a tar version
4510 module isn't working on my system. So I made a tar version
4504 (hopefully the command line options in various systems won't kill
4511 (hopefully the command line options in various systems won't kill
4505 me).
4512 me).
4506
4513
4507 * Fixes to Struct in genutils. Now all dictionary-like methods are
4514 * Fixes to Struct in genutils. Now all dictionary-like methods are
4508 protected (reasonably).
4515 protected (reasonably).
4509
4516
4510 * Added pager function to genutils and changed ? to print usage
4517 * Added pager function to genutils and changed ? to print usage
4511 note through it (it was too long).
4518 note through it (it was too long).
4512
4519
4513 * Added the LazyPython functionality. Works great! I changed the
4520 * Added the LazyPython functionality. Works great! I changed the
4514 auto-quote escape to ';', it's on home row and next to '. But
4521 auto-quote escape to ';', it's on home row and next to '. But
4515 both auto-quote and auto-paren (still /) escapes are command-line
4522 both auto-quote and auto-paren (still /) escapes are command-line
4516 parameters.
4523 parameters.
4517
4524
4518
4525
4519 2001-11-01 Fernando Perez <fperez@colorado.edu>
4526 2001-11-01 Fernando Perez <fperez@colorado.edu>
4520
4527
4521 * Version changed to 0.0.7. Fairly large change: configuration now
4528 * Version changed to 0.0.7. Fairly large change: configuration now
4522 is all stored in a directory, by default .ipython. There, all
4529 is all stored in a directory, by default .ipython. There, all
4523 config files have normal looking names (not .names)
4530 config files have normal looking names (not .names)
4524
4531
4525 * Version 0.0.6 Released first to Lucas and Archie as a test
4532 * Version 0.0.6 Released first to Lucas and Archie as a test
4526 run. Since it's the first 'semi-public' release, change version to
4533 run. Since it's the first 'semi-public' release, change version to
4527 > 0.0.6 for any changes now.
4534 > 0.0.6 for any changes now.
4528
4535
4529 * Stuff I had put in the ipplib.py changelog:
4536 * Stuff I had put in the ipplib.py changelog:
4530
4537
4531 Changes to InteractiveShell:
4538 Changes to InteractiveShell:
4532
4539
4533 - Made the usage message a parameter.
4540 - Made the usage message a parameter.
4534
4541
4535 - Require the name of the shell variable to be given. It's a bit
4542 - Require the name of the shell variable to be given. It's a bit
4536 of a hack, but allows the name 'shell' not to be hardwire in the
4543 of a hack, but allows the name 'shell' not to be hardwire in the
4537 magic (@) handler, which is problematic b/c it requires
4544 magic (@) handler, which is problematic b/c it requires
4538 polluting the global namespace with 'shell'. This in turn is
4545 polluting the global namespace with 'shell'. This in turn is
4539 fragile: if a user redefines a variable called shell, things
4546 fragile: if a user redefines a variable called shell, things
4540 break.
4547 break.
4541
4548
4542 - magic @: all functions available through @ need to be defined
4549 - magic @: all functions available through @ need to be defined
4543 as magic_<name>, even though they can be called simply as
4550 as magic_<name>, even though they can be called simply as
4544 @<name>. This allows the special command @magic to gather
4551 @<name>. This allows the special command @magic to gather
4545 information automatically about all existing magic functions,
4552 information automatically about all existing magic functions,
4546 even if they are run-time user extensions, by parsing the shell
4553 even if they are run-time user extensions, by parsing the shell
4547 instance __dict__ looking for special magic_ names.
4554 instance __dict__ looking for special magic_ names.
4548
4555
4549 - mainloop: added *two* local namespace parameters. This allows
4556 - mainloop: added *two* local namespace parameters. This allows
4550 the class to differentiate between parameters which were there
4557 the class to differentiate between parameters which were there
4551 before and after command line initialization was processed. This
4558 before and after command line initialization was processed. This
4552 way, later @who can show things loaded at startup by the
4559 way, later @who can show things loaded at startup by the
4553 user. This trick was necessary to make session saving/reloading
4560 user. This trick was necessary to make session saving/reloading
4554 really work: ideally after saving/exiting/reloading a session,
4561 really work: ideally after saving/exiting/reloading a session,
4555 *everythin* should look the same, including the output of @who. I
4562 *everythin* should look the same, including the output of @who. I
4556 was only able to make this work with this double namespace
4563 was only able to make this work with this double namespace
4557 trick.
4564 trick.
4558
4565
4559 - added a header to the logfile which allows (almost) full
4566 - added a header to the logfile which allows (almost) full
4560 session restoring.
4567 session restoring.
4561
4568
4562 - prepend lines beginning with @ or !, with a and log
4569 - prepend lines beginning with @ or !, with a and log
4563 them. Why? !lines: may be useful to know what you did @lines:
4570 them. Why? !lines: may be useful to know what you did @lines:
4564 they may affect session state. So when restoring a session, at
4571 they may affect session state. So when restoring a session, at
4565 least inform the user of their presence. I couldn't quite get
4572 least inform the user of their presence. I couldn't quite get
4566 them to properly re-execute, but at least the user is warned.
4573 them to properly re-execute, but at least the user is warned.
4567
4574
4568 * Started ChangeLog.
4575 * Started ChangeLog.
@@ -1,9168 +1,9151 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 10
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 1.1in
62 \topmargin 1in
62 \topmargin 1in
63 \rightmargin 1.1in
63 \rightmargin 1.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 Subsection
167 \layout Subsection
168
168
169 Main features
169 Main features
170 \layout Itemize
170 \layout Itemize
171
171
172 Dynamic object introspection.
172 Dynamic object introspection.
173 One can access docstrings, function definition prototypes, source code,
173 One can access docstrings, function definition prototypes, source code,
174 source files and other details of any object accessible to the interpreter
174 source files and other details of any object accessible to the interpreter
175 with a single keystroke (`
175 with a single keystroke (`
176 \family typewriter
176 \family typewriter
177 ?
177 ?
178 \family default
178 \family default
179 ').
179 ').
180 \layout Itemize
180 \layout Itemize
181
181
182 Completion in the local namespace, by typing TAB at the prompt.
182 Completion in the local namespace, by typing TAB at the prompt.
183 This works for keywords, methods, variables and files in the current directory.
183 This works for keywords, methods, variables and files in the current directory.
184 This is supported via the readline library, and full access to configuring
184 This is supported via the readline library, and full access to configuring
185 readline's behavior is provided.
185 readline's behavior is provided.
186 \layout Itemize
186 \layout Itemize
187
187
188 Numbered input/output prompts with command history (persistent across sessions
188 Numbered input/output prompts with command history (persistent across sessions
189 and tied to each profile), full searching in this history and caching of
189 and tied to each profile), full searching in this history and caching of
190 all input and output.
190 all input and output.
191 \layout Itemize
191 \layout Itemize
192
192
193 User-extensible `magic' commands.
193 User-extensible `magic' commands.
194 A set of commands prefixed with
194 A set of commands prefixed with
195 \family typewriter
195 \family typewriter
196 %
196 %
197 \family default
197 \family default
198 is available for controlling IPython itself and provides directory control,
198 is available for controlling IPython itself and provides directory control,
199 namespace information and many aliases to common system shell commands.
199 namespace information and many aliases to common system shell commands.
200 \layout Itemize
200 \layout Itemize
201
201
202 Alias facility for defining your own system aliases.
202 Alias facility for defining your own system aliases.
203 \layout Itemize
203 \layout Itemize
204
204
205 Complete system shell access.
205 Complete system shell access.
206 Lines starting with ! are passed directly to the system shell, and using
206 Lines starting with ! are passed directly to the system shell, and using
207 !! captures shell output into python variables for further use.
207 !! captures shell output into python variables for further use.
208 \layout Itemize
208 \layout Itemize
209
209
210 All calls to the system (via aliases or via !) have their standard output/error
210 All calls to the system (via aliases or via !) have their standard output/error
211 automatically stored as strings, and also available as lists.
211 automatically stored as strings, and also available as lists.
212 \layout Itemize
212 \layout Itemize
213
213
214 Background execution of Python commands in a separate thread.
214 Background execution of Python commands in a separate thread.
215 IPython has an internal job manager called
215 IPython has an internal job manager called
216 \family typewriter
216 \family typewriter
217 jobs
217 jobs
218 \family default
218 \family default
219 , and a conveninence backgrounding magic function called
219 , and a conveninence backgrounding magic function called
220 \family typewriter
220 \family typewriter
221 %bg
221 %bg
222 \family default
222 \family default
223 .
223 .
224 \layout Itemize
224 \layout Itemize
225
225
226 The ability to expand python variables when calling the system shell.
226 The ability to expand python variables when calling the system shell.
227 In a shell command, any python variable prefixed with
227 In a shell command, any python variable prefixed with
228 \family typewriter
228 \family typewriter
229 $
229 $
230 \family default
230 \family default
231 is expanded.
231 is expanded.
232 A double
232 A double
233 \family typewriter
233 \family typewriter
234 $$
234 $$
235 \family default
235 \family default
236 allows passing a literal
236 allows passing a literal
237 \family typewriter
237 \family typewriter
238 $
238 $
239 \family default
239 \family default
240 to the shell (for access to shell and environment variables like
240 to the shell (for access to shell and environment variables like
241 \family typewriter
241 \family typewriter
242 $PATH
242 $PATH
243 \family default
243 \family default
244 ).
244 ).
245 \layout Itemize
245 \layout Itemize
246
246
247 Filesystem navigation, via a magic
247 Filesystem navigation, via a magic
248 \family typewriter
248 \family typewriter
249 %cd
249 %cd
250 \family default
250 \family default
251 command, along with a persistent bookmark system (using
251 command, along with a persistent bookmark system (using
252 \family typewriter
252 \family typewriter
253 %bookmark
253 %bookmark
254 \family default
254 \family default
255 ) for fast access to frequently visited directories.
255 ) for fast access to frequently visited directories.
256 \layout Itemize
256 \layout Itemize
257
257
258 Automatic indentation (optional) of code as you type (through the readline
258 Automatic indentation (optional) of code as you type (through the readline
259 library).
259 library).
260 \layout Itemize
260 \layout Itemize
261
261
262 Macro system for quickly re-executing multiple lines of previous input with
262 Macro system for quickly re-executing multiple lines of previous input with
263 a single name.
263 a single name.
264 \layout Itemize
264 \layout Itemize
265
265
266 Session logging (you can then later use these logs as code in your programs).
266 Session logging (you can then later use these logs as code in your programs).
267 \layout Itemize
267 \layout Itemize
268
268
269 Session restoring: logs can be replayed to restore a previous session to
269 Session restoring: logs can be replayed to restore a previous session to
270 the state where you left it.
270 the state where you left it.
271 \layout Itemize
271 \layout Itemize
272
272
273 Verbose and colored exception traceback printouts.
273 Verbose and colored exception traceback printouts.
274 Easier to parse visually, and in verbose mode they produce a lot of useful
274 Easier to parse visually, and in verbose mode they produce a lot of useful
275 debugging information (basically a terminal version of the cgitb module).
275 debugging information (basically a terminal version of the cgitb module).
276 \layout Itemize
276 \layout Itemize
277
277
278 Auto-parentheses: callable objects can be executed without parentheses:
278 Auto-parentheses: callable objects can be executed without parentheses:
279
279
280 \family typewriter
280 \family typewriter
281 `sin 3'
281 `sin 3'
282 \family default
282 \family default
283 is automatically converted to
283 is automatically converted to
284 \family typewriter
284 \family typewriter
285 `sin(3)
285 `sin(3)
286 \family default
286 \family default
287 '.
287 '.
288 \layout Itemize
288 \layout Itemize
289
289
290 Auto-quoting: using `
290 Auto-quoting: using `
291 \family typewriter
291 \family typewriter
292 ,
292 ,
293 \family default
293 \family default
294 ' or `
294 ' or `
295 \family typewriter
295 \family typewriter
296 ;
296 ;
297 \family default
297 \family default
298 ' as the first character forces auto-quoting of the rest of the line:
298 ' as the first character forces auto-quoting of the rest of the line:
299 \family typewriter
299 \family typewriter
300 `,my_function a\SpecialChar ~
300 `,my_function a\SpecialChar ~
301 b'
301 b'
302 \family default
302 \family default
303 becomes automatically
303 becomes automatically
304 \family typewriter
304 \family typewriter
305 `my_function("a","b")'
305 `my_function("a","b")'
306 \family default
306 \family default
307 , while
307 , while
308 \family typewriter
308 \family typewriter
309 `;my_function a\SpecialChar ~
309 `;my_function a\SpecialChar ~
310 b'
310 b'
311 \family default
311 \family default
312 becomes
312 becomes
313 \family typewriter
313 \family typewriter
314 `my_function("a b")'
314 `my_function("a b")'
315 \family default
315 \family default
316 .
316 .
317 \layout Itemize
317 \layout Itemize
318
318
319 Extensible input syntax.
319 Extensible input syntax.
320 You can define filters that pre-process user input to simplify input in
320 You can define filters that pre-process user input to simplify input in
321 special situations.
321 special situations.
322 This allows for example pasting multi-line code fragments which start with
322 This allows for example pasting multi-line code fragments which start with
323
323
324 \family typewriter
324 \family typewriter
325 `>>>'
325 `>>>'
326 \family default
326 \family default
327 or
327 or
328 \family typewriter
328 \family typewriter
329 `...'
329 `...'
330 \family default
330 \family default
331 such as those from other python sessions or the standard Python documentation.
331 such as those from other python sessions or the standard Python documentation.
332 \layout Itemize
332 \layout Itemize
333
333
334 Flexible configuration system.
334 Flexible configuration system.
335 It uses a configuration file which allows permanent setting of all command-line
335 It uses a configuration file which allows permanent setting of all command-line
336 options, module loading, code and file execution.
336 options, module loading, code and file execution.
337 The system allows recursive file inclusion, so you can have a base file
337 The system allows recursive file inclusion, so you can have a base file
338 with defaults and layers which load other customizations for particular
338 with defaults and layers which load other customizations for particular
339 projects.
339 projects.
340 \layout Itemize
340 \layout Itemize
341
341
342 Embeddable.
342 Embeddable.
343 You can call IPython as a python shell inside your own python programs.
343 You can call IPython as a python shell inside your own python programs.
344 This can be used both for debugging code or for providing interactive abilities
344 This can be used both for debugging code or for providing interactive abilities
345 to your programs with knowledge about the local namespaces (very useful
345 to your programs with knowledge about the local namespaces (very useful
346 in debugging and data analysis situations).
346 in debugging and data analysis situations).
347 \layout Itemize
347 \layout Itemize
348
348
349 Easy debugger access.
349 Easy debugger access.
350 You can set IPython to call up an enhanced version of the Python debugger
350 You can set IPython to call up an enhanced version of the Python debugger
351 (
351 (
352 \family typewriter
352 \family typewriter
353 pdb
353 pdb
354 \family default
354 \family default
355 ) every time there is an uncaught exception.
355 ) every time there is an uncaught exception.
356 This drops you inside the code which triggered the exception with all the
356 This drops you inside the code which triggered the exception with all the
357 data live and it is possible to navigate the stack to rapidly isolate the
357 data live and it is possible to navigate the stack to rapidly isolate the
358 source of a bug.
358 source of a bug.
359 The
359 The
360 \family typewriter
360 \family typewriter
361 %run
361 %run
362 \family default
362 \family default
363 magic command --with the
363 magic command --with the
364 \family typewriter
364 \family typewriter
365 -d
365 -d
366 \family default
366 \family default
367 option-- can run any script under
367 option-- can run any script under
368 \family typewriter
368 \family typewriter
369 pdb
369 pdb
370 \family default
370 \family default
371 's control, automatically setting initial breakpoints for you.
371 's control, automatically setting initial breakpoints for you.
372 This version of
372 This version of
373 \family typewriter
373 \family typewriter
374 pdb
374 pdb
375 \family default
375 \family default
376 has IPython-specific improvements, including tab-completion and traceback
376 has IPython-specific improvements, including tab-completion and traceback
377 coloring support.
377 coloring support.
378 \layout Itemize
378 \layout Itemize
379
379
380 Profiler support.
380 Profiler support.
381 You can run single statements (similar to
381 You can run single statements (similar to
382 \family typewriter
382 \family typewriter
383 profile.run()
383 profile.run()
384 \family default
384 \family default
385 ) or complete programs under the profiler's control.
385 ) or complete programs under the profiler's control.
386 While this is possible with the standard
386 While this is possible with the standard
387 \family typewriter
387 \family typewriter
388 profile
388 profile
389 \family default
389 \family default
390 module, IPython wraps this functionality with magic commands (see
390 module, IPython wraps this functionality with magic commands (see
391 \family typewriter
391 \family typewriter
392 `%prun'
392 `%prun'
393 \family default
393 \family default
394 and
394 and
395 \family typewriter
395 \family typewriter
396 `%run -p
396 `%run -p
397 \family default
397 \family default
398 ') convenient for rapid interactive work.
398 ') convenient for rapid interactive work.
399 \layout Subsection
399 \layout Subsection
400
400
401 Portability and Python requirements
401 Portability and Python requirements
402 \layout Standard
402 \layout Standard
403
403
404
404
405 \series bold
405 \series bold
406 Python requirements:
406 Python requirements:
407 \series default
407 \series default
408 IPython works with Python version 2.2 or newer.
408 IPython works with Python version 2.2 or newer.
409 It has been tested with Python 2.4 and no problems have been reported.
409 It has been tested with Python 2.4 and no problems have been reported.
410 Support for Python 2.1 hasn't been recently tested, since I don't have access
410 Support for Python 2.1 hasn't been recently tested, since I don't have access
411 to it on any of my systems.
411 to it on any of my systems.
412 But I suspect there may be some problems with Python 2.1, because some of
412 But I suspect there may be some problems with Python 2.1, because some of
413 the newer code may use 2.2 features.
413 the newer code may use 2.2 features.
414 \layout Standard
414 \layout Standard
415
415
416 IPython is developed under
416 IPython is developed under
417 \series bold
417 \series bold
418 Linux
418 Linux
419 \series default
419 \series default
420 , but it should work in any reasonable Unix-type system (tested OK under
420 , but it should work in any reasonable Unix-type system (tested OK under
421 Solaris and the *BSD family, for which a port exists thanks to Dryice Liu).
421 Solaris and the *BSD family, for which a port exists thanks to Dryice Liu).
422 \layout Standard
422 \layout Standard
423
423
424
424
425 \series bold
425 \series bold
426 Mac OS X
426 Mac OS X
427 \series default
427 \series default
428 : it works, apparently without any problems (thanks to Jim Boyle at Lawrence
428 : it works, apparently without any problems (thanks to Jim Boyle at Lawrence
429 Livermore for the information).
429 Livermore for the information).
430 Thanks to Andrea Riciputi, Fink support is available.
430 Thanks to Andrea Riciputi, Fink support is available.
431 \layout Standard
431 \layout Standard
432
432
433
433
434 \series bold
434 \series bold
435 CygWin
435 CygWin
436 \series default
436 \series default
437 : it works mostly OK, though some users have reported problems with prompt
437 : it works mostly OK, though some users have reported problems with prompt
438 coloring.
438 coloring.
439 No satisfactory solution to this has been found so far, you may want to
439 No satisfactory solution to this has been found so far, you may want to
440 disable colors permanently in the
440 disable colors permanently in the
441 \family typewriter
441 \family typewriter
442 ipythonrc
442 ipythonrc
443 \family default
443 \family default
444 configuration file if you experience problems.
444 configuration file if you experience problems.
445 If you have proper color support under cygwin, please post to the IPython
445 If you have proper color support under cygwin, please post to the IPython
446 mailing list so this issue can be resolved for all users.
446 mailing list so this issue can be resolved for all users.
447 \layout Standard
447 \layout Standard
448
448
449
449
450 \series bold
450 \series bold
451 Windows
451 Windows
452 \series default
452 \series default
453 : it works well under Windows XP/2k, and I suspect NT should behave similarly.
453 : it works well under Windows XP/2k, and I suspect NT should behave similarly.
454 Section\SpecialChar ~
454 Section\SpecialChar ~
455
455
456 \begin_inset LatexCommand \ref{sub:Under-Windows}
456 \begin_inset LatexCommand \ref{sub:Under-Windows}
457
457
458 \end_inset
458 \end_inset
459
459
460 describes installation details for Windows, including some additional tools
460 describes installation details for Windows, including some additional tools
461 needed on this platform.
461 needed on this platform.
462 \layout Standard
462 \layout Standard
463
463
464 Windows 9x support is present, and has been reported to work fine (at least
464 Windows 9x support is present, and has been reported to work fine (at least
465 on WinME).
465 on WinME).
466 \layout Standard
466 \layout Standard
467
467
468 Please note, however, that I have very little access to and experience with
468 Please note, however, that I have very little access to and experience with
469 Windows development.
469 Windows development.
470 For this reason, Windows-specific bugs tend to linger far longer than I
470 For this reason, Windows-specific bugs tend to linger far longer than I
471 would like, and often I just can't find a satisfactory solution.
471 would like, and often I just can't find a satisfactory solution.
472 If any Windows user wants to join in with development help, all hands are
472 If any Windows user wants to join in with development help, all hands are
473 always welcome.
473 always welcome.
474 \layout Subsection
474 \layout Subsection
475
475
476 Location
476 Location
477 \layout Standard
477 \layout Standard
478
478
479 IPython is generously hosted at
479 IPython is generously hosted at
480 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
480 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
481
481
482 \end_inset
482 \end_inset
483
483
484 by the SciPy project.
484 by the SciPy project.
485 This site offers downloads, subversion access, mailing lists and a bug
485 This site offers downloads, subversion access, mailing lists and a bug
486 tracking system.
486 tracking system.
487 I am very grateful to Enthought (
487 I am very grateful to Enthought (
488 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
488 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
489
489
490 \end_inset
490 \end_inset
491
491
492 ) and all of the SciPy team for their contribution.
492 ) and all of the SciPy team for their contribution.
493 \layout Section
493 \layout Section
494
494
495
495
496 \begin_inset LatexCommand \label{sec:install}
496 \begin_inset LatexCommand \label{sec:install}
497
497
498 \end_inset
498 \end_inset
499
499
500 Installation
500 Installation
501 \layout Subsection
501 \layout Subsection
502
502
503 Instant instructions
503 Instant instructions
504 \layout Standard
504 \layout Standard
505
505
506 If you are of the impatient kind, under Linux/Unix simply untar/unzip the
506 If you are of the impatient kind, under Linux/Unix simply untar/unzip the
507 download, then install with
507 download, then install with
508 \family typewriter
508 \family typewriter
509 `python setup.py install'
509 `python setup.py install'
510 \family default
510 \family default
511 .
511 .
512 Under Windows, double-click on the provided
512 Under Windows, double-click on the provided
513 \family typewriter
513 \family typewriter
514 .exe
514 .exe
515 \family default
515 \family default
516 binary installer.
516 binary installer.
517 \layout Standard
517 \layout Standard
518
518
519 Then, take a look at Sections
519 Then, take a look at Sections
520 \begin_inset LatexCommand \ref{sec:good_config}
520 \begin_inset LatexCommand \ref{sec:good_config}
521
521
522 \end_inset
522 \end_inset
523
523
524 for configuring things optimally and
524 for configuring things optimally and
525 \begin_inset LatexCommand \ref{sec:quick_tips}
525 \begin_inset LatexCommand \ref{sec:quick_tips}
526
526
527 \end_inset
527 \end_inset
528
528
529 for quick tips on efficient use of IPython.
529 for quick tips on efficient use of IPython.
530 You can later refer to the rest of the manual for all the gory details.
530 You can later refer to the rest of the manual for all the gory details.
531 \layout Standard
531 \layout Standard
532
532
533 See the notes in sec.
533 See the notes in sec.
534
534
535 \begin_inset LatexCommand \ref{sec:upgrade}
535 \begin_inset LatexCommand \ref{sec:upgrade}
536
536
537 \end_inset
537 \end_inset
538
538
539 for upgrading IPython versions.
539 for upgrading IPython versions.
540 \layout Subsection
540 \layout Subsection
541
541
542 Detailed Unix instructions (Linux, Mac OS X, etc.)
542 Detailed Unix instructions (Linux, Mac OS X, etc.)
543 \layout Standard
543 \layout Standard
544
544
545 For RPM based systems, simply install the supplied package in the usual
545 For RPM based systems, simply install the supplied package in the usual
546 manner.
546 manner.
547 If you download the tar archive, the process is:
547 If you download the tar archive, the process is:
548 \layout Enumerate
548 \layout Enumerate
549
549
550 Unzip/untar the
550 Unzip/untar the
551 \family typewriter
551 \family typewriter
552 ipython-XXX.tar.gz
552 ipython-XXX.tar.gz
553 \family default
553 \family default
554 file wherever you want (
554 file wherever you want (
555 \family typewriter
555 \family typewriter
556 XXX
556 XXX
557 \family default
557 \family default
558 is the version number).
558 is the version number).
559 It will make a directory called
559 It will make a directory called
560 \family typewriter
560 \family typewriter
561 ipython-XXX.
561 ipython-XXX.
562
562
563 \family default
563 \family default
564 Change into that directory where you will find the files
564 Change into that directory where you will find the files
565 \family typewriter
565 \family typewriter
566 README
566 README
567 \family default
567 \family default
568 and
568 and
569 \family typewriter
569 \family typewriter
570 setup.py
570 setup.py
571 \family default
571 \family default
572 .
572 .
573
573
574 \family typewriter
574 \family typewriter
575 O
575 O
576 \family default
576 \family default
577 nce you've completed the installation, you can safely remove this directory.
577 nce you've completed the installation, you can safely remove this directory.
578
578
579 \layout Enumerate
579 \layout Enumerate
580
580
581 If you are installing over a previous installation of version 0.2.0 or earlier,
581 If you are installing over a previous installation of version 0.2.0 or earlier,
582 first remove your
582 first remove your
583 \family typewriter
583 \family typewriter
584 $HOME/.ipython
584 $HOME/.ipython
585 \family default
585 \family default
586 directory, since the configuration file format has changed somewhat (the
586 directory, since the configuration file format has changed somewhat (the
587 '=' were removed from all option specifications).
587 '=' were removed from all option specifications).
588 Or you can call ipython with the
588 Or you can call ipython with the
589 \family typewriter
589 \family typewriter
590 -upgrade
590 -upgrade
591 \family default
591 \family default
592 option and it will do this automatically for you.
592 option and it will do this automatically for you.
593 \layout Enumerate
593 \layout Enumerate
594
594
595 IPython uses distutils, so you can install it by simply typing at the system
595 IPython uses distutils, so you can install it by simply typing at the system
596 prompt (don't type the
596 prompt (don't type the
597 \family typewriter
597 \family typewriter
598 $
598 $
599 \family default
599 \family default
600 )
600 )
601 \newline
601 \newline
602
602
603 \family typewriter
603 \family typewriter
604 $ python setup.py install
604 $ python setup.py install
605 \family default
605 \family default
606
606
607 \newline
607 \newline
608 Note that this assumes you have root access to your machine.
608 Note that this assumes you have root access to your machine.
609 If you don't have root access or don't want IPython to go in the default
609 If you don't have root access or don't want IPython to go in the default
610 python directories, you'll need to use the
610 python directories, you'll need to use the
611 \begin_inset ERT
611 \begin_inset ERT
612 status Collapsed
612 status Collapsed
613
613
614 \layout Standard
614 \layout Standard
615
615
616 \backslash
616 \backslash
617 verb|--home|
617 verb|--home|
618 \end_inset
618 \end_inset
619
619
620 option (or
620 option (or
621 \begin_inset ERT
621 \begin_inset ERT
622 status Collapsed
622 status Collapsed
623
623
624 \layout Standard
624 \layout Standard
625
625
626 \backslash
626 \backslash
627 verb|--prefix|
627 verb|--prefix|
628 \end_inset
628 \end_inset
629
629
630 ).
630 ).
631 For example:
631 For example:
632 \newline
632 \newline
633
633
634 \begin_inset ERT
634 \begin_inset ERT
635 status Collapsed
635 status Collapsed
636
636
637 \layout Standard
637 \layout Standard
638
638
639 \backslash
639 \backslash
640 verb|$ python setup.py install --home $HOME/local|
640 verb|$ python setup.py install --home $HOME/local|
641 \end_inset
641 \end_inset
642
642
643
643
644 \newline
644 \newline
645 will install IPython into
645 will install IPython into
646 \family typewriter
646 \family typewriter
647 $HOME/local
647 $HOME/local
648 \family default
648 \family default
649 and its subdirectories (creating them if necessary).
649 and its subdirectories (creating them if necessary).
650 \newline
650 \newline
651 You can type
651 You can type
652 \newline
652 \newline
653
653
654 \begin_inset ERT
654 \begin_inset ERT
655 status Collapsed
655 status Collapsed
656
656
657 \layout Standard
657 \layout Standard
658
658
659 \backslash
659 \backslash
660 verb|$ python setup.py --help|
660 verb|$ python setup.py --help|
661 \end_inset
661 \end_inset
662
662
663
663
664 \newline
664 \newline
665 for more details.
665 for more details.
666 \newline
666 \newline
667 Note that if you change the default location for
667 Note that if you change the default location for
668 \begin_inset ERT
668 \begin_inset ERT
669 status Collapsed
669 status Collapsed
670
670
671 \layout Standard
671 \layout Standard
672
672
673 \backslash
673 \backslash
674 verb|--home|
674 verb|--home|
675 \end_inset
675 \end_inset
676
676
677 at installation, IPython may end up installed at a location which is not
677 at installation, IPython may end up installed at a location which is not
678 part of your
678 part of your
679 \family typewriter
679 \family typewriter
680 $PYTHONPATH
680 $PYTHONPATH
681 \family default
681 \family default
682 environment variable.
682 environment variable.
683 In this case, you'll need to configure this variable to include the actual
683 In this case, you'll need to configure this variable to include the actual
684 directory where the
684 directory where the
685 \family typewriter
685 \family typewriter
686 IPython/
686 IPython/
687 \family default
687 \family default
688 directory ended (typically the value you give to
688 directory ended (typically the value you give to
689 \begin_inset ERT
689 \begin_inset ERT
690 status Collapsed
690 status Collapsed
691
691
692 \layout Standard
692 \layout Standard
693
693
694 \backslash
694 \backslash
695 verb|--home|
695 verb|--home|
696 \end_inset
696 \end_inset
697
697
698 plus
698 plus
699 \family typewriter
699 \family typewriter
700 /lib/python
700 /lib/python
701 \family default
701 \family default
702 ).
702 ).
703 \layout Subsubsection
703 \layout Subsubsection
704
704
705 Mac OSX information
705 Mac OSX information
706 \layout Standard
706 \layout Standard
707
707
708 Under OSX, there is a choice you need to make.
708 Under OSX, there is a choice you need to make.
709 Apple ships its own build of Python, which lives in the core OSX filesystem
709 Apple ships its own build of Python, which lives in the core OSX filesystem
710 hierarchy.
710 hierarchy.
711 You can also manually install a separate Python, either purely by hand
711 You can also manually install a separate Python, either purely by hand
712 (typically in
712 (typically in
713 \family typewriter
713 \family typewriter
714 /usr/local
714 /usr/local
715 \family default
715 \family default
716 ) or by using Fink, which puts everything under
716 ) or by using Fink, which puts everything under
717 \family typewriter
717 \family typewriter
718 /sw
718 /sw
719 \family default
719 \family default
720 .
720 .
721 Which route to follow is a matter of personal preference, as I've seen
721 Which route to follow is a matter of personal preference, as I've seen
722 users who favor each of the approaches.
722 users who favor each of the approaches.
723 Here I will simply list the known installation issues under OSX, along
723 Here I will simply list the known installation issues under OSX, along
724 with their solutions.
724 with their solutions.
725 \layout Standard
725 \layout Standard
726
726
727 This page:
727 This page:
728 \begin_inset LatexCommand \htmlurl{http://geosci.uchicago.edu/~tobis/pylab.html}
728 \begin_inset LatexCommand \htmlurl{http://geosci.uchicago.edu/~tobis/pylab.html}
729
729
730 \end_inset
730 \end_inset
731
731
732 contains information on this topic, with additional details on how to make
732 contains information on this topic, with additional details on how to make
733 IPython and matplotlib play nicely under OSX.
733 IPython and matplotlib play nicely under OSX.
734 \layout Subsubsection*
734 \layout Subsubsection*
735
735
736 GUI problems
736 GUI problems
737 \layout Standard
737 \layout Standard
738
738
739 The following instructions apply to an install of IPython under OSX from
739 The following instructions apply to an install of IPython under OSX from
740 unpacking the
740 unpacking the
741 \family typewriter
741 \family typewriter
742 .tar.gz
742 .tar.gz
743 \family default
743 \family default
744 distribution and installing it for the default Python interpreter shipped
744 distribution and installing it for the default Python interpreter shipped
745 by Apple.
745 by Apple.
746 If you are using a fink install, fink will take care of these details for
746 If you are using a fink install, fink will take care of these details for
747 you, by installing IPython against fink's Python.
747 you, by installing IPython against fink's Python.
748 \layout Standard
748 \layout Standard
749
749
750 IPython offers various forms of support for interacting with graphical applicati
750 IPython offers various forms of support for interacting with graphical applicati
751 ons from the command line, from simple Tk apps (which are in principle always
751 ons from the command line, from simple Tk apps (which are in principle always
752 supported by Python) to interactive control of WX, Qt and GTK apps.
752 supported by Python) to interactive control of WX, Qt and GTK apps.
753 Under OSX, however, this requires that ipython is installed by calling
753 Under OSX, however, this requires that ipython is installed by calling
754 the special
754 the special
755 \family typewriter
755 \family typewriter
756 pythonw
756 pythonw
757 \family default
757 \family default
758 script at installation time, which takes care of coordinating things with
758 script at installation time, which takes care of coordinating things with
759 Apple's graphical environment.
759 Apple's graphical environment.
760 \layout Standard
760 \layout Standard
761
761
762 So when installing under OSX, it is best to use the following command:
762 So when installing under OSX, it is best to use the following command:
763 \family typewriter
763 \family typewriter
764
764
765 \newline
765 \newline
766
766
767 \family default
767 \family default
768
768
769 \begin_inset ERT
769 \begin_inset ERT
770 status Collapsed
770 status Collapsed
771
771
772 \layout Standard
772 \layout Standard
773
773
774 \backslash
774 \backslash
775 verb| $ sudo pythonw setup.py install --install-scripts=/usr/local/bin|
775 verb| $ sudo pythonw setup.py install --install-scripts=/usr/local/bin|
776 \end_inset
776 \end_inset
777
777
778
778
779 \newline
779 \newline
780 or
780 or
781 \newline
781 \newline
782
782
783 \begin_inset ERT
783 \begin_inset ERT
784 status Open
784 status Open
785
785
786 \layout Standard
786 \layout Standard
787
787
788 \backslash
788 \backslash
789 verb| $ sudo pythonw setup.py install --install-scripts=/usr/bin|
789 verb| $ sudo pythonw setup.py install --install-scripts=/usr/bin|
790 \end_inset
790 \end_inset
791
791
792
792
793 \newline
793 \newline
794 depending on where you like to keep hand-installed executables.
794 depending on where you like to keep hand-installed executables.
795 \layout Standard
795 \layout Standard
796
796
797 The resulting script will have an appropriate shebang line (the first line
797 The resulting script will have an appropriate shebang line (the first line
798 in the script whic begins with
798 in the script whic begins with
799 \family typewriter
799 \family typewriter
800 #!...
800 #!...
801 \family default
801 \family default
802 ) such that the ipython interpreter can interact with the OS X GUI.
802 ) such that the ipython interpreter can interact with the OS X GUI.
803 If the installed version does not work and has a shebang line that points
803 If the installed version does not work and has a shebang line that points
804 to, for example, just
804 to, for example, just
805 \family typewriter
805 \family typewriter
806 /usr/bin/python
806 /usr/bin/python
807 \family default
807 \family default
808 , then you might have a stale, cached version in your
808 , then you might have a stale, cached version in your
809 \family typewriter
809 \family typewriter
810 build/scripts-<python-version>
810 build/scripts-<python-version>
811 \family default
811 \family default
812 directory.
812 directory.
813 Delete that directory and rerun the
813 Delete that directory and rerun the
814 \family typewriter
814 \family typewriter
815 setup.py
815 setup.py
816 \family default
816 \family default
817 .
817 .
818
818
819 \layout Standard
819 \layout Standard
820
820
821 It is also a good idea to use the special flag
821 It is also a good idea to use the special flag
822 \begin_inset ERT
822 \begin_inset ERT
823 status Collapsed
823 status Collapsed
824
824
825 \layout Standard
825 \layout Standard
826
826
827 \backslash
827 \backslash
828 verb|--install-scripts|
828 verb|--install-scripts|
829 \end_inset
829 \end_inset
830
830
831 as indicated above, to ensure that the ipython scripts end up in a location
831 as indicated above, to ensure that the ipython scripts end up in a location
832 which is part of your
832 which is part of your
833 \family typewriter
833 \family typewriter
834 $PATH
834 $PATH
835 \family default
835 \family default
836 .
836 .
837 Otherwise Apple's Python will put the scripts in an internal directory
837 Otherwise Apple's Python will put the scripts in an internal directory
838 not available by default at the command line (if you use
838 not available by default at the command line (if you use
839 \family typewriter
839 \family typewriter
840 /usr/local/bin
840 /usr/local/bin
841 \family default
841 \family default
842 , you need to make sure this is in your
842 , you need to make sure this is in your
843 \family typewriter
843 \family typewriter
844 $PATH
844 $PATH
845 \family default
845 \family default
846 , which may not be true by default).
846 , which may not be true by default).
847 \layout Subsubsection*
847 \layout Subsubsection*
848
848
849 Readline problems
849 Readline problems
850 \layout Standard
850 \layout Standard
851
851
852 By default, the Python version shipped by Apple does
852 By default, the Python version shipped by Apple does
853 \emph on
853 \emph on
854 not
854 not
855 \emph default
855 \emph default
856 include the readline library, so central to IPython's behavior.
856 include the readline library, so central to IPython's behavior.
857 If you install IPython against Apple's Python, you will not have arrow
857 If you install IPython against Apple's Python, you will not have arrow
858 keys, tab completion, etc.
858 keys, tab completion, etc.
859 For Mac OSX 10.3 (Panther), you can find a prebuilt readline library here:
859 For Mac OSX 10.3 (Panther), you can find a prebuilt readline library here:
860 \newline
860 \newline
861
861
862 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/readline-5.0-py2.3-macosx10.3.zip}
862 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/readline-5.0-py2.3-macosx10.3.zip}
863
863
864 \end_inset
864 \end_inset
865
865
866
866
867 \layout Standard
867 \layout Standard
868
868
869 If you are using OSX 10.4 (Tiger), after installing this package you need
869 If you are using OSX 10.4 (Tiger), after installing this package you need
870 to either:
870 to either:
871 \layout Enumerate
871 \layout Enumerate
872
872
873 move
873 move
874 \family typewriter
874 \family typewriter
875 readline.so
875 readline.so
876 \family default
876 \family default
877 from
877 from
878 \family typewriter
878 \family typewriter
879 /Library/Python/2.3
879 /Library/Python/2.3
880 \family default
880 \family default
881 to
881 to
882 \family typewriter
882 \family typewriter
883 /Library/Python/2.3/site-packages
883 /Library/Python/2.3/site-packages
884 \family default
884 \family default
885 , or
885 , or
886 \layout Enumerate
886 \layout Enumerate
887
887
888 install
888 install
889 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/TigerPython23Compat.pkg.zip}
889 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/TigerPython23Compat.pkg.zip}
890
890
891 \end_inset
891 \end_inset
892
892
893
893
894 \layout Standard
894 \layout Standard
895
895
896 Users installing against Fink's Python or a properly hand-built one should
896 Users installing against Fink's Python or a properly hand-built one should
897 not have this problem.
897 not have this problem.
898 \layout Subsubsection*
898 \layout Subsubsection*
899
899
900 DarwinPorts
900 DarwinPorts
901 \layout Standard
901 \layout Standard
902
902
903 I report here a message from an OSX user, who suggests an alternative means
903 I report here a message from an OSX user, who suggests an alternative means
904 of using IPython under this operating system with good results.
904 of using IPython under this operating system with good results.
905 Please let me know of any updates that may be useful for this section.
905 Please let me know of any updates that may be useful for this section.
906 His message is reproduced verbatim below:
906 His message is reproduced verbatim below:
907 \layout Quote
907 \layout Quote
908
908
909 From: Markus Banfi
909 From: Markus Banfi
910 \family typewriter
910 \family typewriter
911 <markus.banfi-AT-mospheira.net>
911 <markus.banfi-AT-mospheira.net>
912 \layout Quote
912 \layout Quote
913
913
914 As a MacOS X (10.4.2) user I prefer to install software using DawinPorts instead
914 As a MacOS X (10.4.2) user I prefer to install software using DawinPorts instead
915 of Fink.
915 of Fink.
916 I had no problems installing ipython with DarwinPorts.
916 I had no problems installing ipython with DarwinPorts.
917 It's just:
917 It's just:
918 \layout Quote
918 \layout Quote
919
919
920
920
921 \family typewriter
921 \family typewriter
922 sudo port install py-ipython
922 sudo port install py-ipython
923 \layout Quote
923 \layout Quote
924
924
925 It automatically resolved all dependencies (python24, readline, py-readline).
925 It automatically resolved all dependencies (python24, readline, py-readline).
926 So far I did not encounter any problems with the DarwinPorts port of ipython.
926 So far I did not encounter any problems with the DarwinPorts port of ipython.
927
927
928 \layout Subsection
928 \layout Subsection
929
929
930
930
931 \begin_inset LatexCommand \label{sub:Under-Windows}
931 \begin_inset LatexCommand \label{sub:Under-Windows}
932
932
933 \end_inset
933 \end_inset
934
934
935 Windows instructions
935 Windows instructions
936 \layout Standard
936 \layout Standard
937
937
938 While you can use IPython under Windows with only a stock Python installation,
938 Some of IPython's very useful features are:
939 there is one extension,
939 \layout Itemize
940 \family typewriter
941 readline
942 \family default
943 , which will make the whole experience a lot more pleasant.
944 It is almost a requirement, since IPython will complain in its absence
945 (though it will function).
946
940
941 Integrated readline support (Tab-based file, object and attribute completion,
942 input history across sessions, editable command line, etc.)
943 \layout Itemize
944
945 Coloring of prompts, code and tracebacks.
946 \layout Standard
947
948 These, by default, are only available under Unix-like operating systems.
949 However, thanks to Gary Bishop's work, Windows XP/2k users can also benefit
950 from them.
951 His readline library implements both GNU readline functionality and color
952 support, so that IPython under Windows XP/2k can be as friendly and powerful
953 as under Unix-like environments.
947 \layout Standard
954 \layout Standard
948
955
949 The
956 The
950 \family typewriter
957 \family typewriter
951 readline
958 readline
952 \family default
959 \family default
953 extension needs two other libraries to work, so in all you need:
960 extension needs two other libraries to work, so in all you need:
954 \layout Enumerate
961 \layout Enumerate
955
962
956
963
957 \family typewriter
964 \family typewriter
958 PyWin32
965 PyWin32
959 \family default
966 \family default
960 from
967 from
961 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/mhammond}
968 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/mhammond}
962
969
963 \end_inset
970 \end_inset
964
971
965 .
972 .
966 \layout Enumerate
973 \layout Enumerate
967
974
968
975
969 \family typewriter
976 \family typewriter
970 CTypes
977 CTypes
971 \family default
978 \family default
972 from
979 from
973 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/theller/ctypes}
980 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/theller/ctypes}
974
981
975 \end_inset
982 \end_inset
976
983
977 (you
984 (you
978 \emph on
985 \emph on
979 must
986 must
980 \emph default
987 \emph default
981 use version 0.9.1 or newer).
988 use version 0.9.1 or newer).
982 \layout Enumerate
989 \layout Enumerate
983
990
984
991
985 \family typewriter
992 \family typewriter
986 Readline
993 Readline
987 \family default
994 \family default
988 for Windows from
995 for Windows from
989 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/uncpythontools}
996 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/uncpythontools}
990
997
991 \end_inset
998 \end_inset
992
999
993 .
1000 .
994 \layout Standard
1001 \layout Standard
995
1002
996
1003
997 \series bold
1004 \series bold
998 Warning about a broken readline-like library:
1005 Warning about a broken readline-like library:
999 \series default
1006 \series default
1000 several users have reported problems stemming from using the pseudo-readline
1007 several users have reported problems stemming from using the pseudo-readline
1001 library at
1008 library at
1002 \begin_inset LatexCommand \htmlurl{http://newcenturycomputers.net/projects/readline.html}
1009 \begin_inset LatexCommand \htmlurl{http://newcenturycomputers.net/projects/readline.html}
1003
1010
1004 \end_inset
1011 \end_inset
1005
1012
1006 .
1013 .
1007 This is a broken library which, while called readline, only implements
1014 This is a broken library which, while called readline, only implements
1008 an incomplete subset of the readline API.
1015 an incomplete subset of the readline API.
1009 Since it is still called readline, it fools IPython's detection mechanisms
1016 Since it is still called readline, it fools IPython's detection mechanisms
1010 and causes unpredictable crashes later.
1017 and causes unpredictable crashes later.
1011 If you wish to use IPython under Windows, you must NOT use this library,
1018 If you wish to use IPython under Windows, you must NOT use this library,
1012 which for all purposes is (at least as of version 1.6) terminally broken.
1019 which for all purposes is (at least as of version 1.6) terminally broken.
1013 \layout Subsubsection
1020 \layout Subsubsection
1014
1021
1015 Gary Bishop's readline and color support for Windows
1016 \layout Standard
1017
1018 Some of IPython's very useful features are:
1019 \layout Itemize
1020
1021 Integrated readline support (Tab-based file, object and attribute completion,
1022 input history across sessions, editable command line, etc.)
1023 \layout Itemize
1024
1025 Coloring of prompts, code and tracebacks.
1026 \layout Standard
1027
1028 These, by default, are only available under Unix-like operating systems.
1029 However, thanks to Gary Bishop's work, Windows XP/2k users can also benefit
1030 from them.
1031 His readline library implements both GNU readline functionality and color
1032 support, so that IPython under Windows XP/2k can be as friendly and powerful
1033 as under Unix-like environments.
1034 \layout Standard
1035
1036 You can find Gary's tools at
1037 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/uncpythontools}
1038
1039 \end_inset
1040
1041 ; Gary's
1042 \family typewriter
1043 readline
1044 \family default
1045 requires in turn the
1046 \family typewriter
1047 ctypes
1048 \family default
1049 library by Thomas Heller, available at
1050 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/theller/ctypes}
1051
1052 \end_inset
1053
1054 , and Mark Hammond's
1055 \family typewriter
1056 PyWin32
1057 \family default
1058 from
1059 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/mhammond}
1060
1061 \end_inset
1062
1063 (
1064 \family typewriter
1065 PyWin32
1066 \family default
1067 is great for anything Windows-related anyway, so you might as well get
1068 it).
1069 \layout Standard
1070
1071 Under MS\SpecialChar ~
1072 Windows, IPython will complain if it can not find this
1073 \family typewriter
1074 readline
1075 \family default
1076 library at startup and any time the
1077 \family typewriter
1078 %colors
1079 \family default
1080 command is issued, so you can consider it to be a quasi-requirement.
1081 \layout Subsubsection
1082
1083 Installation procedure
1022 Installation procedure
1084 \layout Standard
1023 \layout Standard
1085
1024
1086 Once you have the above installed, from the IPython download directory grab
1025 Once you have the above installed, from the IPython download directory grab
1087 the
1026 the
1088 \family typewriter
1027 \family typewriter
1089 ipython-XXX.win32.exe
1028 ipython-XXX.win32.exe
1090 \family default
1029 \family default
1091 file, where
1030 file, where
1092 \family typewriter
1031 \family typewriter
1093 XXX
1032 XXX
1094 \family default
1033 \family default
1095 represents the version number.
1034 represents the version number.
1096 This is a regular windows executable installer, which you can simply double-cli
1035 This is a regular windows executable installer, which you can simply double-cli
1097 ck to install.
1036 ck to install.
1098 It will add an entry for IPython to your Start Menu, as well as registering
1037 It will add an entry for IPython to your Start Menu, as well as registering
1099 IPython in the Windows list of applications, so you can later uninstall
1038 IPython in the Windows list of applications, so you can later uninstall
1100 it from the Control Panel.
1039 it from the Control Panel.
1101
1040
1102 \layout Standard
1041 \layout Standard
1103
1042
1104 IPython tries to install the configuration information in a directory named
1043 IPython tries to install the configuration information in a directory named
1105
1044
1106 \family typewriter
1045 \family typewriter
1107 .ipython
1046 .ipython
1108 \family default
1047 \family default
1109 (
1048 (
1110 \family typewriter
1049 \family typewriter
1111 _ipython
1050 _ipython
1112 \family default
1051 \family default
1113 under Windows) located in your `home' directory.
1052 under Windows) located in your `home' directory.
1114 IPython sets this directory by looking for a
1053 IPython sets this directory by looking for a
1115 \family typewriter
1054 \family typewriter
1116 HOME
1055 HOME
1117 \family default
1056 \family default
1118 environment variable; if such a variable does not exist, it uses
1057 environment variable; if such a variable does not exist, it uses
1119 \family typewriter
1058 \family typewriter
1120 HOMEDRIVE
1059 HOMEDRIVE
1121 \backslash
1060 \backslash
1122 HOMEPATH
1061 HOMEPATH
1123 \family default
1062 \family default
1124 (these are always defined by Windows).
1063 (these are always defined by Windows).
1125 This typically gives something like
1064 This typically gives something like
1126 \family typewriter
1065 \family typewriter
1127 C:
1066 C:
1128 \backslash
1067 \backslash
1129 Documents and Settings
1068 Documents and Settings
1130 \backslash
1069 \backslash
1131 YourUserName
1070 YourUserName
1132 \family default
1071 \family default
1133 , but your local details may vary.
1072 , but your local details may vary.
1134 In this directory you will find all the files that configure IPython's
1073 In this directory you will find all the files that configure IPython's
1135 defaults, and you can put there your profiles and extensions.
1074 defaults, and you can put there your profiles and extensions.
1136 This directory is automatically added by IPython to
1075 This directory is automatically added by IPython to
1137 \family typewriter
1076 \family typewriter
1138 sys.path
1077 sys.path
1139 \family default
1078 \family default
1140 , so anything you place there can be found by
1079 , so anything you place there can be found by
1141 \family typewriter
1080 \family typewriter
1142 import
1081 import
1143 \family default
1082 \family default
1144 statements.
1083 statements.
1145 \layout Paragraph
1084 \layout Paragraph
1146
1085
1147 Upgrading
1086 Upgrading
1148 \layout Standard
1087 \layout Standard
1149
1088
1150 For an IPython upgrade, you should first uninstall the previous version.
1089 For an IPython upgrade, you should first uninstall the previous version.
1151 This will ensure that all files and directories (such as the documentation)
1090 This will ensure that all files and directories (such as the documentation)
1152 which carry embedded version strings in their names are properly removed.
1091 which carry embedded version strings in their names are properly removed.
1153 \layout Paragraph
1092 \layout Paragraph
1154
1093
1155 Manual installation under Win32
1094 Manual installation under Win32
1156 \layout Standard
1095 \layout Standard
1157
1096
1158 In case the automatic installer does not work for some reason, you can download
1097 In case the automatic installer does not work for some reason, you can download
1159 the
1098 the
1160 \family typewriter
1099 \family typewriter
1161 ipython-XXX.tar.gz
1100 ipython-XXX.tar.gz
1162 \family default
1101 \family default
1163 file, which contains the full IPython source distribution (the popular
1102 file, which contains the full IPython source distribution (the popular
1164 WinZip can read
1103 WinZip can read
1165 \family typewriter
1104 \family typewriter
1166 .tar.gz
1105 .tar.gz
1167 \family default
1106 \family default
1168 files).
1107 files).
1169 After uncompressing the archive, you can install it at a command terminal
1108 After uncompressing the archive, you can install it at a command terminal
1170 just like any other Python module, by using
1109 just like any other Python module, by using
1171 \family typewriter
1110 \family typewriter
1172 `python setup.py install'
1111 `python setup.py install'
1173 \family default
1112 \family default
1174 .
1113 .
1175
1114
1176 \layout Standard
1115 \layout Standard
1177
1116
1178 After the installation, run the supplied
1117 After the installation, run the supplied
1179 \family typewriter
1118 \family typewriter
1180 win32_manual_post_install.py
1119 win32_manual_post_install.py
1181 \family default
1120 \family default
1182 script, which creates the necessary Start Menu shortcuts for you.
1121 script, which creates the necessary Start Menu shortcuts for you.
1183 \layout Subsection
1122 \layout Subsection
1184
1123
1185
1124
1186 \begin_inset LatexCommand \label{sec:upgrade}
1125 \begin_inset LatexCommand \label{sec:upgrade}
1187
1126
1188 \end_inset
1127 \end_inset
1189
1128
1190 Upgrading from a previous version
1129 Upgrading from a previous version
1191 \layout Standard
1130 \layout Standard
1192
1131
1193 If you are upgrading from a previous version of IPython, after doing the
1132 If you are upgrading from a previous version of IPython, after doing the
1194 routine installation described above, you should call IPython with the
1133 routine installation described above, you should call IPython with the
1195
1134
1196 \family typewriter
1135 \family typewriter
1197 -upgrade
1136 -upgrade
1198 \family default
1137 \family default
1199 option the first time you run your new copy.
1138 option the first time you run your new copy.
1200 This will automatically update your configuration directory while preserving
1139 This will automatically update your configuration directory while preserving
1201 copies of your old files.
1140 copies of your old files.
1202 You can then later merge back any personal customizations you may have
1141 You can then later merge back any personal customizations you may have
1203 made into the new files.
1142 made into the new files.
1204 It is a good idea to do this as there may be new options available in the
1143 It is a good idea to do this as there may be new options available in the
1205 new configuration files which you will not have.
1144 new configuration files which you will not have.
1206 \layout Standard
1145 \layout Standard
1207
1146
1208 Under Windows, if you don't know how to call python scripts with arguments
1147 Under Windows, if you don't know how to call python scripts with arguments
1209 from a command line, simply delete the old config directory and IPython
1148 from a command line, simply delete the old config directory and IPython
1210 will make a new one.
1149 will make a new one.
1211 Win2k and WinXP users will find it in
1150 Win2k and WinXP users will find it in
1212 \family typewriter
1151 \family typewriter
1213 C:
1152 C:
1214 \backslash
1153 \backslash
1215 Documents and Settings
1154 Documents and Settings
1216 \backslash
1155 \backslash
1217 YourUserName
1156 YourUserName
1218 \backslash
1157 \backslash
1219 _ipython
1158 _ipython
1220 \family default
1159 \family default
1221 , and Win 9x users under
1160 , and Win 9x users under
1222 \family typewriter
1161 \family typewriter
1223 C:
1162 C:
1224 \backslash
1163 \backslash
1225 Program Files
1164 Program Files
1226 \backslash
1165 \backslash
1227 IPython
1166 IPython
1228 \backslash
1167 \backslash
1229 _ipython.
1168 _ipython.
1230 \layout Section
1169 \layout Section
1231
1170
1232
1171
1233 \begin_inset LatexCommand \label{sec:good_config}
1172 \begin_inset LatexCommand \label{sec:good_config}
1234
1173
1235 \end_inset
1174 \end_inset
1236
1175
1237
1176
1238 \begin_inset OptArg
1177 \begin_inset OptArg
1239 collapsed true
1178 collapsed true
1240
1179
1241 \layout Standard
1180 \layout Standard
1242
1181
1243 Initial configuration
1182 Initial configuration
1244 \begin_inset ERT
1183 \begin_inset ERT
1245 status Collapsed
1184 status Collapsed
1246
1185
1247 \layout Standard
1186 \layout Standard
1248
1187
1249 \backslash
1188 \backslash
1250 ldots
1189 ldots
1251 \end_inset
1190 \end_inset
1252
1191
1253
1192
1254 \end_inset
1193 \end_inset
1255
1194
1256 Initial configuration of your environment
1195 Initial configuration of your environment
1257 \layout Standard
1196 \layout Standard
1258
1197
1259 This section will help you set various things in your environment for your
1198 This section will help you set various things in your environment for your
1260 IPython sessions to be as efficient as possible.
1199 IPython sessions to be as efficient as possible.
1261 All of IPython's configuration information, along with several example
1200 All of IPython's configuration information, along with several example
1262 files, is stored in a directory named by default
1201 files, is stored in a directory named by default
1263 \family typewriter
1202 \family typewriter
1264 $HOME/.ipython
1203 $HOME/.ipython
1265 \family default
1204 \family default
1266 .
1205 .
1267 You can change this by defining the environment variable
1206 You can change this by defining the environment variable
1268 \family typewriter
1207 \family typewriter
1269 IPYTHONDIR
1208 IPYTHONDIR
1270 \family default
1209 \family default
1271 , or at runtime with the command line option
1210 , or at runtime with the command line option
1272 \family typewriter
1211 \family typewriter
1273 -ipythondir
1212 -ipythondir
1274 \family default
1213 \family default
1275 .
1214 .
1276 \layout Standard
1215 \layout Standard
1277
1216
1278 If all goes well, the first time you run IPython it should automatically
1217 If all goes well, the first time you run IPython it should automatically
1279 create a user copy of the config directory for you, based on its builtin
1218 create a user copy of the config directory for you, based on its builtin
1280 defaults.
1219 defaults.
1281 You can look at the files it creates to learn more about configuring the
1220 You can look at the files it creates to learn more about configuring the
1282 system.
1221 system.
1283 The main file you will modify to configure IPython's behavior is called
1222 The main file you will modify to configure IPython's behavior is called
1284
1223
1285 \family typewriter
1224 \family typewriter
1286 ipythonrc
1225 ipythonrc
1287 \family default
1226 \family default
1288 (with a
1227 (with a
1289 \family typewriter
1228 \family typewriter
1290 .ini
1229 .ini
1291 \family default
1230 \family default
1292 extension under Windows), included for reference in Sec.
1231 extension under Windows), included for reference in Sec.
1293
1232
1294 \begin_inset LatexCommand \ref{sec:ipytonrc-sample}
1233 \begin_inset LatexCommand \ref{sec:ipytonrc-sample}
1295
1234
1296 \end_inset
1235 \end_inset
1297
1236
1298 .
1237 .
1299 This file is very commented and has many variables you can change to suit
1238 This file is very commented and has many variables you can change to suit
1300 your taste, you can find more details in Sec.
1239 your taste, you can find more details in Sec.
1301
1240
1302 \begin_inset LatexCommand \ref{sec:customization}
1241 \begin_inset LatexCommand \ref{sec:customization}
1303
1242
1304 \end_inset
1243 \end_inset
1305
1244
1306 .
1245 .
1307 Here we discuss the basic things you will want to make sure things are
1246 Here we discuss the basic things you will want to make sure things are
1308 working properly from the beginning.
1247 working properly from the beginning.
1309 \layout Subsection
1248 \layout Subsection
1310
1249
1311
1250
1312 \begin_inset LatexCommand \label{sec:help-access}
1251 \begin_inset LatexCommand \label{sec:help-access}
1313
1252
1314 \end_inset
1253 \end_inset
1315
1254
1316 Access to the Python help system
1255 Access to the Python help system
1317 \layout Standard
1256 \layout Standard
1318
1257
1319 This is true for Python in general (not just for IPython): you should have
1258 This is true for Python in general (not just for IPython): you should have
1320 an environment variable called
1259 an environment variable called
1321 \family typewriter
1260 \family typewriter
1322 PYTHONDOCS
1261 PYTHONDOCS
1323 \family default
1262 \family default
1324 pointing to the directory where your HTML Python documentation lives.
1263 pointing to the directory where your HTML Python documentation lives.
1325 In my system it's
1264 In my system it's
1326 \family typewriter
1265 \family typewriter
1327 /usr/share/doc/python-docs-2.3.4/html
1266 /usr/share/doc/python-docs-2.3.4/html
1328 \family default
1267 \family default
1329 , check your local details or ask your systems administrator.
1268 , check your local details or ask your systems administrator.
1330
1269
1331 \layout Standard
1270 \layout Standard
1332
1271
1333 This is the directory which holds the HTML version of the Python manuals.
1272 This is the directory which holds the HTML version of the Python manuals.
1334 Unfortunately it seems that different Linux distributions package these
1273 Unfortunately it seems that different Linux distributions package these
1335 files differently, so you may have to look around a bit.
1274 files differently, so you may have to look around a bit.
1336 Below I show the contents of this directory on my system for reference:
1275 Below I show the contents of this directory on my system for reference:
1337 \layout Standard
1276 \layout Standard
1338
1277
1339
1278
1340 \family typewriter
1279 \family typewriter
1341 [html]> ls
1280 [html]> ls
1342 \newline
1281 \newline
1343 about.dat acks.html dist/ ext/ index.html lib/ modindex.html stdabout.dat tut/
1282 about.dat acks.html dist/ ext/ index.html lib/ modindex.html stdabout.dat tut/
1344 about.html api/ doc/ icons/ inst/ mac/ ref/ style.css
1283 about.html api/ doc/ icons/ inst/ mac/ ref/ style.css
1345 \layout Standard
1284 \layout Standard
1346
1285
1347 You should really make sure this variable is correctly set so that Python's
1286 You should really make sure this variable is correctly set so that Python's
1348 pydoc-based help system works.
1287 pydoc-based help system works.
1349 It is a powerful and convenient system with full access to the Python manuals
1288 It is a powerful and convenient system with full access to the Python manuals
1350 and all modules accessible to you.
1289 and all modules accessible to you.
1351 \layout Standard
1290 \layout Standard
1352
1291
1353 Under Windows it seems that pydoc finds the documentation automatically,
1292 Under Windows it seems that pydoc finds the documentation automatically,
1354 so no extra setup appears necessary.
1293 so no extra setup appears necessary.
1355 \layout Subsection
1294 \layout Subsection
1356
1295
1357 Editor
1296 Editor
1358 \layout Standard
1297 \layout Standard
1359
1298
1360 The
1299 The
1361 \family typewriter
1300 \family typewriter
1362 %edit
1301 %edit
1363 \family default
1302 \family default
1364 command (and its alias
1303 command (and its alias
1365 \family typewriter
1304 \family typewriter
1366 %ed
1305 %ed
1367 \family default
1306 \family default
1368 ) will invoke the editor set in your environment as
1307 ) will invoke the editor set in your environment as
1369 \family typewriter
1308 \family typewriter
1370 EDITOR
1309 EDITOR
1371 \family default
1310 \family default
1372 .
1311 .
1373 If this variable is not set, it will default to
1312 If this variable is not set, it will default to
1374 \family typewriter
1313 \family typewriter
1375 vi
1314 vi
1376 \family default
1315 \family default
1377 under Linux/Unix and to
1316 under Linux/Unix and to
1378 \family typewriter
1317 \family typewriter
1379 notepad
1318 notepad
1380 \family default
1319 \family default
1381 under Windows.
1320 under Windows.
1382 You may want to set this variable properly and to a lightweight editor
1321 You may want to set this variable properly and to a lightweight editor
1383 which doesn't take too long to start (that is, something other than a new
1322 which doesn't take too long to start (that is, something other than a new
1384 instance of
1323 instance of
1385 \family typewriter
1324 \family typewriter
1386 Emacs
1325 Emacs
1387 \family default
1326 \family default
1388 ).
1327 ).
1389 This way you can edit multi-line code quickly and with the power of a real
1328 This way you can edit multi-line code quickly and with the power of a real
1390 editor right inside IPython.
1329 editor right inside IPython.
1391
1330
1392 \layout Standard
1331 \layout Standard
1393
1332
1394 If you are a dedicated
1333 If you are a dedicated
1395 \family typewriter
1334 \family typewriter
1396 Emacs
1335 Emacs
1397 \family default
1336 \family default
1398 user, you should set up the
1337 user, you should set up the
1399 \family typewriter
1338 \family typewriter
1400 Emacs
1339 Emacs
1401 \family default
1340 \family default
1402 server so that new requests are handled by the original process.
1341 server so that new requests are handled by the original process.
1403 This means that almost no time is spent in handling the request (assuming
1342 This means that almost no time is spent in handling the request (assuming
1404 an
1343 an
1405 \family typewriter
1344 \family typewriter
1406 Emacs
1345 Emacs
1407 \family default
1346 \family default
1408 process is already running).
1347 process is already running).
1409 For this to work, you need to set your
1348 For this to work, you need to set your
1410 \family typewriter
1349 \family typewriter
1411 EDITOR
1350 EDITOR
1412 \family default
1351 \family default
1413 environment variable to
1352 environment variable to
1414 \family typewriter
1353 \family typewriter
1415 'emacsclient'
1354 'emacsclient'
1416 \family default
1355 \family default
1417 .
1356 .
1418
1357
1419 \family typewriter
1358 \family typewriter
1420
1359
1421 \family default
1360 \family default
1422 The code below, supplied by Francois Pinard, can then be used in your
1361 The code below, supplied by Francois Pinard, can then be used in your
1423 \family typewriter
1362 \family typewriter
1424 .emacs
1363 .emacs
1425 \family default
1364 \family default
1426 file to enable the server:
1365 file to enable the server:
1427 \layout Standard
1366 \layout Standard
1428
1367
1429
1368
1430 \family typewriter
1369 \family typewriter
1431 (defvar server-buffer-clients)
1370 (defvar server-buffer-clients)
1432 \newline
1371 \newline
1433 (when (and (fboundp 'server-start) (string-equal (getenv "TERM") 'xterm))
1372 (when (and (fboundp 'server-start) (string-equal (getenv "TERM") 'xterm))
1434 \newline
1373 \newline
1435
1374
1436 \begin_inset ERT
1375 \begin_inset ERT
1437 status Collapsed
1376 status Collapsed
1438
1377
1439 \layout Standard
1378 \layout Standard
1440
1379
1441 \backslash
1380 \backslash
1442 hspace*{0mm}
1381 hspace*{0mm}
1443 \end_inset
1382 \end_inset
1444
1383
1445 \SpecialChar ~
1384 \SpecialChar ~
1446 \SpecialChar ~
1385 \SpecialChar ~
1447 (server-start)
1386 (server-start)
1448 \newline
1387 \newline
1449
1388
1450 \begin_inset ERT
1389 \begin_inset ERT
1451 status Collapsed
1390 status Collapsed
1452
1391
1453 \layout Standard
1392 \layout Standard
1454
1393
1455 \backslash
1394 \backslash
1456 hspace*{0mm}
1395 hspace*{0mm}
1457 \end_inset
1396 \end_inset
1458
1397
1459 \SpecialChar ~
1398 \SpecialChar ~
1460 \SpecialChar ~
1399 \SpecialChar ~
1461 (defun fp-kill-server-with-buffer-routine ()
1400 (defun fp-kill-server-with-buffer-routine ()
1462 \newline
1401 \newline
1463
1402
1464 \begin_inset ERT
1403 \begin_inset ERT
1465 status Collapsed
1404 status Collapsed
1466
1405
1467 \layout Standard
1406 \layout Standard
1468
1407
1469 \backslash
1408 \backslash
1470 hspace*{0mm}
1409 hspace*{0mm}
1471 \end_inset
1410 \end_inset
1472
1411
1473 \SpecialChar ~
1412 \SpecialChar ~
1474 \SpecialChar ~
1413 \SpecialChar ~
1475 \SpecialChar ~
1414 \SpecialChar ~
1476 \SpecialChar ~
1415 \SpecialChar ~
1477 (and server-buffer-clients (server-done)))
1416 (and server-buffer-clients (server-done)))
1478 \newline
1417 \newline
1479
1418
1480 \begin_inset ERT
1419 \begin_inset ERT
1481 status Collapsed
1420 status Collapsed
1482
1421
1483 \layout Standard
1422 \layout Standard
1484
1423
1485 \backslash
1424 \backslash
1486 hspace*{0mm}
1425 hspace*{0mm}
1487 \end_inset
1426 \end_inset
1488
1427
1489 \SpecialChar ~
1428 \SpecialChar ~
1490 \SpecialChar ~
1429 \SpecialChar ~
1491 (add-hook 'kill-buffer-hook 'fp-kill-server-with-buffer-routine))
1430 (add-hook 'kill-buffer-hook 'fp-kill-server-with-buffer-routine))
1492 \layout Standard
1431 \layout Standard
1493
1432
1494 You can also set the value of this editor via the commmand-line option '-
1433 You can also set the value of this editor via the commmand-line option '-
1495 \family typewriter
1434 \family typewriter
1496 editor'
1435 editor'
1497 \family default
1436 \family default
1498 or in your
1437 or in your
1499 \family typewriter
1438 \family typewriter
1500 ipythonrc
1439 ipythonrc
1501 \family default
1440 \family default
1502 file.
1441 file.
1503 This is useful if you wish to use specifically for IPython an editor different
1442 This is useful if you wish to use specifically for IPython an editor different
1504 from your typical default (and for Windows users who tend to use fewer
1443 from your typical default (and for Windows users who tend to use fewer
1505 environment variables).
1444 environment variables).
1506 \layout Subsection
1445 \layout Subsection
1507
1446
1508 Color
1447 Color
1509 \layout Standard
1448 \layout Standard
1510
1449
1511 The default IPython configuration has most bells and whistles turned on
1450 The default IPython configuration has most bells and whistles turned on
1512 (they're pretty safe).
1451 (they're pretty safe).
1513 But there's one that
1452 But there's one that
1514 \emph on
1453 \emph on
1515 may
1454 may
1516 \emph default
1455 \emph default
1517 cause problems on some systems: the use of color on screen for displaying
1456 cause problems on some systems: the use of color on screen for displaying
1518 information.
1457 information.
1519 This is very useful, since IPython can show prompts and exception tracebacks
1458 This is very useful, since IPython can show prompts and exception tracebacks
1520 with various colors, display syntax-highlighted source code, and in general
1459 with various colors, display syntax-highlighted source code, and in general
1521 make it easier to visually parse information.
1460 make it easier to visually parse information.
1522 \layout Standard
1461 \layout Standard
1523
1462
1524 The following terminals seem to handle the color sequences fine:
1463 The following terminals seem to handle the color sequences fine:
1525 \layout Itemize
1464 \layout Itemize
1526
1465
1527 Linux main text console, KDE Konsole, Gnome Terminal, E-term, rxvt, xterm.
1466 Linux main text console, KDE Konsole, Gnome Terminal, E-term, rxvt, xterm.
1528 \layout Itemize
1467 \layout Itemize
1529
1468
1530 CDE terminal (tested under Solaris).
1469 CDE terminal (tested under Solaris).
1531 This one boldfaces light colors.
1470 This one boldfaces light colors.
1532 \layout Itemize
1471 \layout Itemize
1533
1472
1534 (X)Emacs buffers.
1473 (X)Emacs buffers.
1535 See sec.
1474 See sec.
1536 \begin_inset LatexCommand \ref{sec:emacs}
1475 \begin_inset LatexCommand \ref{sec:emacs}
1537
1476
1538 \end_inset
1477 \end_inset
1539
1478
1540 for more details on using IPython with (X)Emacs.
1479 for more details on using IPython with (X)Emacs.
1541 \layout Itemize
1480 \layout Itemize
1542
1481
1543 A Windows (XP/2k) command prompt
1482 A Windows (XP/2k) command prompt
1544 \emph on
1483 \emph on
1545 with Gary Bishop's support extensions
1484 with Gary Bishop's support extensions
1546 \emph default
1485 \emph default
1547 .
1486 .
1548 Gary's extensions are discussed in Sec.\SpecialChar ~
1487 Gary's extensions are discussed in Sec.\SpecialChar ~
1549
1488
1550 \begin_inset LatexCommand \ref{sub:Under-Windows}
1489 \begin_inset LatexCommand \ref{sub:Under-Windows}
1551
1490
1552 \end_inset
1491 \end_inset
1553
1492
1554 .
1493 .
1555 \layout Itemize
1494 \layout Itemize
1556
1495
1557 A Windows (XP/2k) CygWin shell.
1496 A Windows (XP/2k) CygWin shell.
1558 Although some users have reported problems; it is not clear whether there
1497 Although some users have reported problems; it is not clear whether there
1559 is an issue for everyone or only under specific configurations.
1498 is an issue for everyone or only under specific configurations.
1560 If you have full color support under cygwin, please post to the IPython
1499 If you have full color support under cygwin, please post to the IPython
1561 mailing list so this issue can be resolved for all users.
1500 mailing list so this issue can be resolved for all users.
1562 \layout Standard
1501 \layout Standard
1563
1502
1564 These have shown problems:
1503 These have shown problems:
1565 \layout Itemize
1504 \layout Itemize
1566
1505
1567 Windows command prompt in WinXP/2k logged into a Linux machine via telnet
1506 Windows command prompt in WinXP/2k logged into a Linux machine via telnet
1568 or ssh.
1507 or ssh.
1569 \layout Itemize
1508 \layout Itemize
1570
1509
1571 Windows native command prompt in WinXP/2k,
1510 Windows native command prompt in WinXP/2k,
1572 \emph on
1511 \emph on
1573 without
1512 without
1574 \emph default
1513 \emph default
1575 Gary Bishop's extensions.
1514 Gary Bishop's extensions.
1576 Once Gary's readline library is installed, the normal WinXP/2k command
1515 Once Gary's readline library is installed, the normal WinXP/2k command
1577 prompt works perfectly.
1516 prompt works perfectly.
1578 \layout Standard
1517 \layout Standard
1579
1518
1580 Currently the following color schemes are available:
1519 Currently the following color schemes are available:
1581 \layout Itemize
1520 \layout Itemize
1582
1521
1583
1522
1584 \family typewriter
1523 \family typewriter
1585 NoColor
1524 NoColor
1586 \family default
1525 \family default
1587 : uses no color escapes at all (all escapes are empty
1526 : uses no color escapes at all (all escapes are empty
1588 \begin_inset Quotes eld
1527 \begin_inset Quotes eld
1589 \end_inset
1528 \end_inset
1590
1529
1591
1530
1592 \begin_inset Quotes eld
1531 \begin_inset Quotes eld
1593 \end_inset
1532 \end_inset
1594
1533
1595 strings).
1534 strings).
1596 This 'scheme' is thus fully safe to use in any terminal.
1535 This 'scheme' is thus fully safe to use in any terminal.
1597 \layout Itemize
1536 \layout Itemize
1598
1537
1599
1538
1600 \family typewriter
1539 \family typewriter
1601 Linux
1540 Linux
1602 \family default
1541 \family default
1603 : works well in Linux console type environments: dark background with light
1542 : works well in Linux console type environments: dark background with light
1604 fonts.
1543 fonts.
1605 It uses bright colors for information, so it is difficult to read if you
1544 It uses bright colors for information, so it is difficult to read if you
1606 have a light colored background.
1545 have a light colored background.
1607 \layout Itemize
1546 \layout Itemize
1608
1547
1609
1548
1610 \family typewriter
1549 \family typewriter
1611 LightBG
1550 LightBG
1612 \family default
1551 \family default
1613 : the basic colors are similar to those in the
1552 : the basic colors are similar to those in the
1614 \family typewriter
1553 \family typewriter
1615 Linux
1554 Linux
1616 \family default
1555 \family default
1617 scheme but darker.
1556 scheme but darker.
1618 It is easy to read in terminals with light backgrounds.
1557 It is easy to read in terminals with light backgrounds.
1619 \layout Standard
1558 \layout Standard
1620
1559
1621 IPython uses colors for two main groups of things: prompts and tracebacks
1560 IPython uses colors for two main groups of things: prompts and tracebacks
1622 which are directly printed to the terminal, and the object introspection
1561 which are directly printed to the terminal, and the object introspection
1623 system which passes large sets of data through a pager.
1562 system which passes large sets of data through a pager.
1624 \layout Subsubsection
1563 \layout Subsubsection
1625
1564
1626 Input/Output prompts and exception tracebacks
1565 Input/Output prompts and exception tracebacks
1627 \layout Standard
1566 \layout Standard
1628
1567
1629 You can test whether the colored prompts and tracebacks work on your system
1568 You can test whether the colored prompts and tracebacks work on your system
1630 interactively by typing
1569 interactively by typing
1631 \family typewriter
1570 \family typewriter
1632 '%colors Linux'
1571 '%colors Linux'
1633 \family default
1572 \family default
1634 at the prompt (use '
1573 at the prompt (use '
1635 \family typewriter
1574 \family typewriter
1636 %colors LightBG'
1575 %colors LightBG'
1637 \family default
1576 \family default
1638 if your terminal has a light background).
1577 if your terminal has a light background).
1639 If the input prompt shows garbage like:
1578 If the input prompt shows garbage like:
1640 \newline
1579 \newline
1641
1580
1642 \family typewriter
1581 \family typewriter
1643 [0;32mIn [[1;32m1[0;32m]: [0;00m
1582 [0;32mIn [[1;32m1[0;32m]: [0;00m
1644 \family default
1583 \family default
1645
1584
1646 \newline
1585 \newline
1647 instead of (in color) something like:
1586 instead of (in color) something like:
1648 \newline
1587 \newline
1649
1588
1650 \family typewriter
1589 \family typewriter
1651 In [1]:
1590 In [1]:
1652 \family default
1591 \family default
1653
1592
1654 \newline
1593 \newline
1655 this means that your terminal doesn't properly handle color escape sequences.
1594 this means that your terminal doesn't properly handle color escape sequences.
1656 You can go to a 'no color' mode by typing '
1595 You can go to a 'no color' mode by typing '
1657 \family typewriter
1596 \family typewriter
1658 %colors NoColor
1597 %colors NoColor
1659 \family default
1598 \family default
1660 '.
1599 '.
1661
1600
1662 \layout Standard
1601 \layout Standard
1663
1602
1664 You can try using a different terminal emulator program.
1603 You can try using a different terminal emulator program.
1665 To permanently set your color preferences, edit the file
1604 To permanently set your color preferences, edit the file
1666 \family typewriter
1605 \family typewriter
1667 $HOME/.ipython/ipythonrc
1606 $HOME/.ipython/ipythonrc
1668 \family default
1607 \family default
1669 and set the
1608 and set the
1670 \family typewriter
1609 \family typewriter
1671 colors
1610 colors
1672 \family default
1611 \family default
1673 option to the desired value.
1612 option to the desired value.
1674 \layout Subsubsection
1613 \layout Subsubsection
1675
1614
1676 Object details (types, docstrings, source code, etc.)
1615 Object details (types, docstrings, source code, etc.)
1677 \layout Standard
1616 \layout Standard
1678
1617
1679 IPython has a set of special functions for studying the objects you are
1618 IPython has a set of special functions for studying the objects you are
1680 working with, discussed in detail in Sec.
1619 working with, discussed in detail in Sec.
1681
1620
1682 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1621 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1683
1622
1684 \end_inset
1623 \end_inset
1685
1624
1686 .
1625 .
1687 But this system relies on passing information which is longer than your
1626 But this system relies on passing information which is longer than your
1688 screen through a data pager, such as the common Unix
1627 screen through a data pager, such as the common Unix
1689 \family typewriter
1628 \family typewriter
1690 less
1629 less
1691 \family default
1630 \family default
1692 and
1631 and
1693 \family typewriter
1632 \family typewriter
1694 more
1633 more
1695 \family default
1634 \family default
1696 programs.
1635 programs.
1697 In order to be able to see this information in color, your pager needs
1636 In order to be able to see this information in color, your pager needs
1698 to be properly configured.
1637 to be properly configured.
1699 I strongly recommend using
1638 I strongly recommend using
1700 \family typewriter
1639 \family typewriter
1701 less
1640 less
1702 \family default
1641 \family default
1703 instead of
1642 instead of
1704 \family typewriter
1643 \family typewriter
1705 more
1644 more
1706 \family default
1645 \family default
1707 , as it seems that
1646 , as it seems that
1708 \family typewriter
1647 \family typewriter
1709 more
1648 more
1710 \family default
1649 \family default
1711 simply can not understand colored text correctly.
1650 simply can not understand colored text correctly.
1712 \layout Standard
1651 \layout Standard
1713
1652
1714 In order to configure
1653 In order to configure
1715 \family typewriter
1654 \family typewriter
1716 less
1655 less
1717 \family default
1656 \family default
1718 as your default pager, do the following:
1657 as your default pager, do the following:
1719 \layout Enumerate
1658 \layout Enumerate
1720
1659
1721 Set the environment
1660 Set the environment
1722 \family typewriter
1661 \family typewriter
1723 PAGER
1662 PAGER
1724 \family default
1663 \family default
1725 variable to
1664 variable to
1726 \family typewriter
1665 \family typewriter
1727 less
1666 less
1728 \family default
1667 \family default
1729 .
1668 .
1730 \layout Enumerate
1669 \layout Enumerate
1731
1670
1732 Set the environment
1671 Set the environment
1733 \family typewriter
1672 \family typewriter
1734 LESS
1673 LESS
1735 \family default
1674 \family default
1736 variable to
1675 variable to
1737 \family typewriter
1676 \family typewriter
1738 -r
1677 -r
1739 \family default
1678 \family default
1740 (plus any other options you always want to pass to
1679 (plus any other options you always want to pass to
1741 \family typewriter
1680 \family typewriter
1742 less
1681 less
1743 \family default
1682 \family default
1744 by default).
1683 by default).
1745 This tells
1684 This tells
1746 \family typewriter
1685 \family typewriter
1747 less
1686 less
1748 \family default
1687 \family default
1749 to properly interpret control sequences, which is how color information
1688 to properly interpret control sequences, which is how color information
1750 is given to your terminal.
1689 is given to your terminal.
1751 \layout Standard
1690 \layout Standard
1752
1691
1753 For the
1692 For the
1754 \family typewriter
1693 \family typewriter
1755 csh
1694 csh
1756 \family default
1695 \family default
1757 or
1696 or
1758 \family typewriter
1697 \family typewriter
1759 tcsh
1698 tcsh
1760 \family default
1699 \family default
1761 shells, add to your
1700 shells, add to your
1762 \family typewriter
1701 \family typewriter
1763 ~/.cshrc
1702 ~/.cshrc
1764 \family default
1703 \family default
1765 file the lines:
1704 file the lines:
1766 \layout Standard
1705 \layout Standard
1767
1706
1768
1707
1769 \family typewriter
1708 \family typewriter
1770 setenv PAGER less
1709 setenv PAGER less
1771 \newline
1710 \newline
1772 setenv LESS -r
1711 setenv LESS -r
1773 \layout Standard
1712 \layout Standard
1774
1713
1775 There is similar syntax for other Unix shells, look at your system documentation
1714 There is similar syntax for other Unix shells, look at your system documentation
1776 for details.
1715 for details.
1777 \layout Standard
1716 \layout Standard
1778
1717
1779 If you are on a system which lacks proper data pagers (such as Windows),
1718 If you are on a system which lacks proper data pagers (such as Windows),
1780 IPython will use a very limited builtin pager.
1719 IPython will use a very limited builtin pager.
1781 \layout Subsection
1720 \layout Subsection
1782
1721
1783
1722
1784 \begin_inset LatexCommand \label{sec:emacs}
1723 \begin_inset LatexCommand \label{sec:emacs}
1785
1724
1786 \end_inset
1725 \end_inset
1787
1726
1788 (X)Emacs configuration
1727 (X)Emacs configuration
1789 \layout Standard
1728 \layout Standard
1790
1729
1791 Thanks to the work of Alexander Schmolck and Prabhu Ramachandran, currently
1730 Thanks to the work of Alexander Schmolck and Prabhu Ramachandran, currently
1792 (X)Emacs and IPython get along very well.
1731 (X)Emacs and IPython get along very well.
1793
1732
1794 \layout Standard
1733 \layout Standard
1795
1734
1796
1735
1797 \series bold
1736 \series bold
1798 Important note:
1737 Important note:
1799 \series default
1738 \series default
1800 You will need to use a recent enough version of
1739 You will need to use a recent enough version of
1801 \family typewriter
1740 \family typewriter
1802 python-mode.el
1741 python-mode.el
1803 \family default
1742 \family default
1804 , along with the file
1743 , along with the file
1805 \family typewriter
1744 \family typewriter
1806 ipython.el
1745 ipython.el
1807 \family default
1746 \family default
1808 .
1747 .
1809 You can check that the version you have of
1748 You can check that the version you have of
1810 \family typewriter
1749 \family typewriter
1811 python-mode.el
1750 python-mode.el
1812 \family default
1751 \family default
1813 is new enough by either looking at the revision number in the file itself,
1752 is new enough by either looking at the revision number in the file itself,
1814 or asking for it in (X)Emacs via
1753 or asking for it in (X)Emacs via
1815 \family typewriter
1754 \family typewriter
1816 M-x py-version
1755 M-x py-version
1817 \family default
1756 \family default
1818 .
1757 .
1819 Versions 4.68 and newer contain the necessary fixes for proper IPython support.
1758 Versions 4.68 and newer contain the necessary fixes for proper IPython support.
1820 \layout Standard
1759 \layout Standard
1821
1760
1822 The file
1761 The file
1823 \family typewriter
1762 \family typewriter
1824 ipython.el
1763 ipython.el
1825 \family default
1764 \family default
1826 is included with the IPython distribution, in the documentation directory
1765 is included with the IPython distribution, in the documentation directory
1827 (where this manual resides in PDF and HTML formats).
1766 (where this manual resides in PDF and HTML formats).
1828 \layout Standard
1767 \layout Standard
1829
1768
1830 Once you put these files in your Emacs path, all you need in your
1769 Once you put these files in your Emacs path, all you need in your
1831 \family typewriter
1770 \family typewriter
1832 .emacs
1771 .emacs
1833 \family default
1772 \family default
1834 file is:
1773 file is:
1835 \layout Standard
1774 \layout Standard
1836
1775
1837
1776
1838 \family typewriter
1777 \family typewriter
1839 (require 'ipython)
1778 (require 'ipython)
1840 \layout Standard
1779 \layout Standard
1841
1780
1842 This should give you full support for executing code snippets via IPython,
1781 This should give you full support for executing code snippets via IPython,
1843 opening IPython as your Python shell via
1782 opening IPython as your Python shell via
1844 \family typewriter
1783 \family typewriter
1845 C-c\SpecialChar ~
1784 C-c\SpecialChar ~
1846 !
1785 !
1847 \family default
1786 \family default
1848 , etc.
1787 , etc.
1849
1788
1850 \layout Subsubsection*
1789 \layout Subsubsection*
1851
1790
1852 Notes
1791 Notes
1853 \layout Itemize
1792 \layout Itemize
1854
1793
1855 There is one caveat you should be aware of: you must start the IPython shell
1794 There is one caveat you should be aware of: you must start the IPython shell
1856
1795
1857 \emph on
1796 \emph on
1858 before
1797 before
1859 \emph default
1798 \emph default
1860 attempting to execute any code regions via
1799 attempting to execute any code regions via
1861 \family typewriter
1800 \family typewriter
1862 C-c\SpecialChar ~
1801 C-c\SpecialChar ~
1863 |
1802 |
1864 \family default
1803 \family default
1865 .
1804 .
1866 Simply type
1805 Simply type
1867 \family typewriter
1806 \family typewriter
1868 C-c\SpecialChar ~
1807 C-c\SpecialChar ~
1869 !
1808 !
1870 \family default
1809 \family default
1871 to start IPython before passing any code regions to the interpreter, and
1810 to start IPython before passing any code regions to the interpreter, and
1872 you shouldn't experience any problems.
1811 you shouldn't experience any problems.
1873 \newline
1812 \newline
1874 This is due to a bug in Python itself, which has been fixed for Python 2.3,
1813 This is due to a bug in Python itself, which has been fixed for Python 2.3,
1875 but exists as of Python 2.2.2 (reported as SF bug [ 737947 ]).
1814 but exists as of Python 2.2.2 (reported as SF bug [ 737947 ]).
1876 \layout Itemize
1815 \layout Itemize
1877
1816
1878 The (X)Emacs support is maintained by Alexander Schmolck, so all comments/reques
1817 The (X)Emacs support is maintained by Alexander Schmolck, so all comments/reques
1879 ts should be directed to him through the IPython mailing lists.
1818 ts should be directed to him through the IPython mailing lists.
1880
1819
1881 \layout Itemize
1820 \layout Itemize
1882
1821
1883 This code is still somewhat experimental so it's a bit rough around the
1822 This code is still somewhat experimental so it's a bit rough around the
1884 edges (although in practice, it works quite well).
1823 edges (although in practice, it works quite well).
1885 \layout Itemize
1824 \layout Itemize
1886
1825
1887 Be aware that if you customize
1826 Be aware that if you customize
1888 \family typewriter
1827 \family typewriter
1889 py-python-command
1828 py-python-command
1890 \family default
1829 \family default
1891 previously, this value will override what
1830 previously, this value will override what
1892 \family typewriter
1831 \family typewriter
1893 ipython.el
1832 ipython.el
1894 \family default
1833 \family default
1895 does (because loading the customization variables comes later).
1834 does (because loading the customization variables comes later).
1896 \layout Section
1835 \layout Section
1897
1836
1898
1837
1899 \begin_inset LatexCommand \label{sec:quick_tips}
1838 \begin_inset LatexCommand \label{sec:quick_tips}
1900
1839
1901 \end_inset
1840 \end_inset
1902
1841
1903 Quick tips
1842 Quick tips
1904 \layout Standard
1843 \layout Standard
1905
1844
1906 IPython can be used as an improved replacement for the Python prompt, and
1845 IPython can be used as an improved replacement for the Python prompt, and
1907 for that you don't really need to read any more of this manual.
1846 for that you don't really need to read any more of this manual.
1908 But in this section we'll try to summarize a few tips on how to make the
1847 But in this section we'll try to summarize a few tips on how to make the
1909 most effective use of it for everyday Python development, highlighting
1848 most effective use of it for everyday Python development, highlighting
1910 things you might miss in the rest of the manual (which is getting long).
1849 things you might miss in the rest of the manual (which is getting long).
1911 We'll give references to parts in the manual which provide more detail
1850 We'll give references to parts in the manual which provide more detail
1912 when appropriate.
1851 when appropriate.
1913 \layout Standard
1852 \layout Standard
1914
1853
1915 The following article by Jeremy Jones provides an introductory tutorial
1854 The following article by Jeremy Jones provides an introductory tutorial
1916 about IPython:
1855 about IPython:
1917 \newline
1856 \newline
1918
1857
1919 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2005/01/27/ipython.html}
1858 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2005/01/27/ipython.html}
1920
1859
1921 \end_inset
1860 \end_inset
1922
1861
1923
1862
1924 \layout Itemize
1863 \layout Itemize
1925
1864
1926 The TAB key.
1865 The TAB key.
1927 TAB-completion, especially for attributes, is a convenient way to explore
1866 TAB-completion, especially for attributes, is a convenient way to explore
1928 the structure of any object you're dealing with.
1867 the structure of any object you're dealing with.
1929 Simply type
1868 Simply type
1930 \family typewriter
1869 \family typewriter
1931 object_name.<TAB>
1870 object_name.<TAB>
1932 \family default
1871 \family default
1933 and a list of the object's attributes will be printed (see sec.
1872 and a list of the object's attributes will be printed (see sec.
1934
1873
1935 \begin_inset LatexCommand \ref{sec:readline}
1874 \begin_inset LatexCommand \ref{sec:readline}
1936
1875
1937 \end_inset
1876 \end_inset
1938
1877
1939 for more).
1878 for more).
1940 Tab completion also works on file and directory names, which combined with
1879 Tab completion also works on file and directory names, which combined with
1941 IPython's alias system allows you to do from within IPython many of the
1880 IPython's alias system allows you to do from within IPython many of the
1942 things you normally would need the system shell for.
1881 things you normally would need the system shell for.
1943
1882
1944 \layout Itemize
1883 \layout Itemize
1945
1884
1946 Explore your objects.
1885 Explore your objects.
1947 Typing
1886 Typing
1948 \family typewriter
1887 \family typewriter
1949 object_name?
1888 object_name?
1950 \family default
1889 \family default
1951 will print all sorts of details about any object, including docstrings,
1890 will print all sorts of details about any object, including docstrings,
1952 function definition lines (for call arguments) and constructor details
1891 function definition lines (for call arguments) and constructor details
1953 for classes.
1892 for classes.
1954 The magic commands
1893 The magic commands
1955 \family typewriter
1894 \family typewriter
1956 %pdoc
1895 %pdoc
1957 \family default
1896 \family default
1958 ,
1897 ,
1959 \family typewriter
1898 \family typewriter
1960 %pdef
1899 %pdef
1961 \family default
1900 \family default
1962 ,
1901 ,
1963 \family typewriter
1902 \family typewriter
1964 %psource
1903 %psource
1965 \family default
1904 \family default
1966 and
1905 and
1967 \family typewriter
1906 \family typewriter
1968 %pfile
1907 %pfile
1969 \family default
1908 \family default
1970 will respectively print the docstring, function definition line, full source
1909 will respectively print the docstring, function definition line, full source
1971 code and the complete file for any object (when they can be found).
1910 code and the complete file for any object (when they can be found).
1972 If automagic is on (it is by default), you don't need to type the '
1911 If automagic is on (it is by default), you don't need to type the '
1973 \family typewriter
1912 \family typewriter
1974 %
1913 %
1975 \family default
1914 \family default
1976 ' explicitly.
1915 ' explicitly.
1977 See sec.
1916 See sec.
1978
1917
1979 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1918 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1980
1919
1981 \end_inset
1920 \end_inset
1982
1921
1983 for more.
1922 for more.
1984 \layout Itemize
1923 \layout Itemize
1985
1924
1986 The
1925 The
1987 \family typewriter
1926 \family typewriter
1988 %run
1927 %run
1989 \family default
1928 \family default
1990 magic command allows you to run any python script and load all of its data
1929 magic command allows you to run any python script and load all of its data
1991 directly into the interactive namespace.
1930 directly into the interactive namespace.
1992 Since the file is re-read from disk each time, changes you make to it are
1931 Since the file is re-read from disk each time, changes you make to it are
1993 reflected immediately (in contrast to the behavior of
1932 reflected immediately (in contrast to the behavior of
1994 \family typewriter
1933 \family typewriter
1995 import
1934 import
1996 \family default
1935 \family default
1997 ).
1936 ).
1998 I rarely use
1937 I rarely use
1999 \family typewriter
1938 \family typewriter
2000 import
1939 import
2001 \family default
1940 \family default
2002 for code I am testing, relying on
1941 for code I am testing, relying on
2003 \family typewriter
1942 \family typewriter
2004 %run
1943 %run
2005 \family default
1944 \family default
2006 instead.
1945 instead.
2007 See sec.
1946 See sec.
2008
1947
2009 \begin_inset LatexCommand \ref{sec:magic}
1948 \begin_inset LatexCommand \ref{sec:magic}
2010
1949
2011 \end_inset
1950 \end_inset
2012
1951
2013 for more on this and other magic commands, or type the name of any magic
1952 for more on this and other magic commands, or type the name of any magic
2014 command and ? to get details on it.
1953 command and ? to get details on it.
2015 See also sec.
1954 See also sec.
2016
1955
2017 \begin_inset LatexCommand \ref{sec:dreload}
1956 \begin_inset LatexCommand \ref{sec:dreload}
2018
1957
2019 \end_inset
1958 \end_inset
2020
1959
2021 for a recursive reload command.
1960 for a recursive reload command.
2022 \newline
1961 \newline
2023
1962
2024 \family typewriter
1963 \family typewriter
2025 %run
1964 %run
2026 \family default
1965 \family default
2027 also has special flags for timing the execution of your scripts (
1966 also has special flags for timing the execution of your scripts (
2028 \family typewriter
1967 \family typewriter
2029 -t
1968 -t
2030 \family default
1969 \family default
2031 ) and for executing them under the control of either Python's
1970 ) and for executing them under the control of either Python's
2032 \family typewriter
1971 \family typewriter
2033 pdb
1972 pdb
2034 \family default
1973 \family default
2035 debugger (
1974 debugger (
2036 \family typewriter
1975 \family typewriter
2037 -d
1976 -d
2038 \family default
1977 \family default
2039 ) or profiler (
1978 ) or profiler (
2040 \family typewriter
1979 \family typewriter
2041 -p
1980 -p
2042 \family default
1981 \family default
2043 ).
1982 ).
2044 With all of these,
1983 With all of these,
2045 \family typewriter
1984 \family typewriter
2046 %run
1985 %run
2047 \family default
1986 \family default
2048 can be used as the main tool for efficient interactive development of code
1987 can be used as the main tool for efficient interactive development of code
2049 which you write in your editor of choice.
1988 which you write in your editor of choice.
2050 \layout Itemize
1989 \layout Itemize
2051
1990
2052 Use the Python debugger,
1991 Use the Python debugger,
2053 \family typewriter
1992 \family typewriter
2054 pdb
1993 pdb
2055 \family default
1994 \family default
2056
1995
2057 \begin_inset Foot
1996 \begin_inset Foot
2058 collapsed true
1997 collapsed true
2059
1998
2060 \layout Standard
1999 \layout Standard
2061
2000
2062 Thanks to Christian Hart and Matthew Arnison for the suggestions leading
2001 Thanks to Christian Hart and Matthew Arnison for the suggestions leading
2063 to IPython's improved debugger and profiler support.
2002 to IPython's improved debugger and profiler support.
2064 \end_inset
2003 \end_inset
2065
2004
2066 .
2005 .
2067 The
2006 The
2068 \family typewriter
2007 \family typewriter
2069 %pdb
2008 %pdb
2070 \family default
2009 \family default
2071 command allows you to toggle on and off the automatic invocation of an
2010 command allows you to toggle on and off the automatic invocation of an
2072 IPython-enhanced
2011 IPython-enhanced
2073 \family typewriter
2012 \family typewriter
2074 pdb
2013 pdb
2075 \family default
2014 \family default
2076 debugger (with coloring, tab completion and more) at any uncaught exception.
2015 debugger (with coloring, tab completion and more) at any uncaught exception.
2077 The advantage of this is that
2016 The advantage of this is that
2078 \family typewriter
2017 \family typewriter
2079 pdb
2018 pdb
2080 \family default
2019 \family default
2081 starts
2020 starts
2082 \emph on
2021 \emph on
2083 inside
2022 inside
2084 \emph default
2023 \emph default
2085 the function where the exception occurred, with all data still available.
2024 the function where the exception occurred, with all data still available.
2086 You can print variables, see code, execute statements and even walk up
2025 You can print variables, see code, execute statements and even walk up
2087 and down the call stack to track down the true source of the problem (which
2026 and down the call stack to track down the true source of the problem (which
2088 often is many layers in the stack above where the exception gets triggered).
2027 often is many layers in the stack above where the exception gets triggered).
2089 \newline
2028 \newline
2090 Running programs with
2029 Running programs with
2091 \family typewriter
2030 \family typewriter
2092 %run
2031 %run
2093 \family default
2032 \family default
2094 and pdb active can be an efficient to develop and debug code, in many cases
2033 and pdb active can be an efficient to develop and debug code, in many cases
2095 eliminating the need for
2034 eliminating the need for
2096 \family typewriter
2035 \family typewriter
2097 print
2036 print
2098 \family default
2037 \family default
2099 statements or external debugging tools.
2038 statements or external debugging tools.
2100 I often simply put a
2039 I often simply put a
2101 \family typewriter
2040 \family typewriter
2102 1/0
2041 1/0
2103 \family default
2042 \family default
2104 in a place where I want to take a look so that pdb gets called, quickly
2043 in a place where I want to take a look so that pdb gets called, quickly
2105 view whatever variables I need to or test various pieces of code and then
2044 view whatever variables I need to or test various pieces of code and then
2106 remove the
2045 remove the
2107 \family typewriter
2046 \family typewriter
2108 1/0
2047 1/0
2109 \family default
2048 \family default
2110 .
2049 .
2111 \newline
2050 \newline
2112 Note also that `
2051 Note also that `
2113 \family typewriter
2052 \family typewriter
2114 %run -d
2053 %run -d
2115 \family default
2054 \family default
2116 ' activates
2055 ' activates
2117 \family typewriter
2056 \family typewriter
2118 pdb
2057 pdb
2119 \family default
2058 \family default
2120 and automatically sets initial breakpoints for you to step through your
2059 and automatically sets initial breakpoints for you to step through your
2121 code, watch variables, etc.
2060 code, watch variables, etc.
2122 See Sec.\SpecialChar ~
2061 See Sec.\SpecialChar ~
2123
2062
2124 \begin_inset LatexCommand \ref{sec:cache_output}
2063 \begin_inset LatexCommand \ref{sec:cache_output}
2125
2064
2126 \end_inset
2065 \end_inset
2127
2066
2128 for details.
2067 for details.
2129 \layout Itemize
2068 \layout Itemize
2130
2069
2131 Use the output cache.
2070 Use the output cache.
2132 All output results are automatically stored in a global dictionary named
2071 All output results are automatically stored in a global dictionary named
2133
2072
2134 \family typewriter
2073 \family typewriter
2135 Out
2074 Out
2136 \family default
2075 \family default
2137 and variables named
2076 and variables named
2138 \family typewriter
2077 \family typewriter
2139 _1
2078 _1
2140 \family default
2079 \family default
2141 ,
2080 ,
2142 \family typewriter
2081 \family typewriter
2143 _2
2082 _2
2144 \family default
2083 \family default
2145 , etc.
2084 , etc.
2146 alias them.
2085 alias them.
2147 For example, the result of input line 4 is available either as
2086 For example, the result of input line 4 is available either as
2148 \family typewriter
2087 \family typewriter
2149 Out[4]
2088 Out[4]
2150 \family default
2089 \family default
2151 or as
2090 or as
2152 \family typewriter
2091 \family typewriter
2153 _4
2092 _4
2154 \family default
2093 \family default
2155 .
2094 .
2156 Additionally, three variables named
2095 Additionally, three variables named
2157 \family typewriter
2096 \family typewriter
2158 _
2097 _
2159 \family default
2098 \family default
2160 ,
2099 ,
2161 \family typewriter
2100 \family typewriter
2162 __
2101 __
2163 \family default
2102 \family default
2164 and
2103 and
2165 \family typewriter
2104 \family typewriter
2166 ___
2105 ___
2167 \family default
2106 \family default
2168 are always kept updated with the for the last three results.
2107 are always kept updated with the for the last three results.
2169 This allows you to recall any previous result and further use it for new
2108 This allows you to recall any previous result and further use it for new
2170 calculations.
2109 calculations.
2171 See Sec.\SpecialChar ~
2110 See Sec.\SpecialChar ~
2172
2111
2173 \begin_inset LatexCommand \ref{sec:cache_output}
2112 \begin_inset LatexCommand \ref{sec:cache_output}
2174
2113
2175 \end_inset
2114 \end_inset
2176
2115
2177 for more.
2116 for more.
2178 \layout Itemize
2117 \layout Itemize
2179
2118
2180 Put a '
2119 Put a '
2181 \family typewriter
2120 \family typewriter
2182 ;
2121 ;
2183 \family default
2122 \family default
2184 ' at the end of a line to supress the printing of output.
2123 ' at the end of a line to supress the printing of output.
2185 This is useful when doing calculations which generate long output you are
2124 This is useful when doing calculations which generate long output you are
2186 not interested in seeing.
2125 not interested in seeing.
2187 The
2126 The
2188 \family typewriter
2127 \family typewriter
2189 _*
2128 _*
2190 \family default
2129 \family default
2191 variables and the
2130 variables and the
2192 \family typewriter
2131 \family typewriter
2193 Out[]
2132 Out[]
2194 \family default
2133 \family default
2195 list do get updated with the contents of the output, even if it is not
2134 list do get updated with the contents of the output, even if it is not
2196 printed.
2135 printed.
2197 You can thus still access the generated results this way for further processing.
2136 You can thus still access the generated results this way for further processing.
2198 \layout Itemize
2137 \layout Itemize
2199
2138
2200 A similar system exists for caching input.
2139 A similar system exists for caching input.
2201 All input is stored in a global list called
2140 All input is stored in a global list called
2202 \family typewriter
2141 \family typewriter
2203 In
2142 In
2204 \family default
2143 \family default
2205 , so you can re-execute lines 22 through 28 plus line 34 by typing
2144 , so you can re-execute lines 22 through 28 plus line 34 by typing
2206 \family typewriter
2145 \family typewriter
2207 'exec In[22:29]+In[34]'
2146 'exec In[22:29]+In[34]'
2208 \family default
2147 \family default
2209 (using Python slicing notation).
2148 (using Python slicing notation).
2210 If you need to execute the same set of lines often, you can assign them
2149 If you need to execute the same set of lines often, you can assign them
2211 to a macro with the
2150 to a macro with the
2212 \family typewriter
2151 \family typewriter
2213 %macro
2152 %macro
2214 \family default
2153 \family default
2215
2154
2216 \family typewriter
2155 \family typewriter
2217 function.
2156 function.
2218
2157
2219 \family default
2158 \family default
2220 See sec.
2159 See sec.
2221
2160
2222 \begin_inset LatexCommand \ref{sec:cache_input}
2161 \begin_inset LatexCommand \ref{sec:cache_input}
2223
2162
2224 \end_inset
2163 \end_inset
2225
2164
2226 for more.
2165 for more.
2227 \layout Itemize
2166 \layout Itemize
2228
2167
2229 Use your input history.
2168 Use your input history.
2230 The
2169 The
2231 \family typewriter
2170 \family typewriter
2232 %hist
2171 %hist
2233 \family default
2172 \family default
2234 command can show you all previous input, without line numbers if desired
2173 command can show you all previous input, without line numbers if desired
2235 (option
2174 (option
2236 \family typewriter
2175 \family typewriter
2237 -n
2176 -n
2238 \family default
2177 \family default
2239 ) so you can directly copy and paste code either back in IPython or in a
2178 ) so you can directly copy and paste code either back in IPython or in a
2240 text editor.
2179 text editor.
2241 You can also save all your history by turning on logging via
2180 You can also save all your history by turning on logging via
2242 \family typewriter
2181 \family typewriter
2243 %logstart
2182 %logstart
2244 \family default
2183 \family default
2245 ; these logs can later be either reloaded as IPython sessions or used as
2184 ; these logs can later be either reloaded as IPython sessions or used as
2246 code for your programs.
2185 code for your programs.
2247 \layout Itemize
2186 \layout Itemize
2248
2187
2249 Define your own macros with
2188 Define your own macros with
2250 \family typewriter
2189 \family typewriter
2251 %macro
2190 %macro
2252 \family default
2191 \family default
2253 .
2192 .
2254 This can be useful for automating sequences of expressions when working
2193 This can be useful for automating sequences of expressions when working
2255 interactively.
2194 interactively.
2256 \layout Itemize
2195 \layout Itemize
2257
2196
2258 Define your own system aliases.
2197 Define your own system aliases.
2259 Even though IPython gives you access to your system shell via the
2198 Even though IPython gives you access to your system shell via the
2260 \family typewriter
2199 \family typewriter
2261 !
2200 !
2262 \family default
2201 \family default
2263 prefix, it is convenient to have aliases to the system commands you use
2202 prefix, it is convenient to have aliases to the system commands you use
2264 most often.
2203 most often.
2265 This allows you to work seamlessly from inside IPython with the same commands
2204 This allows you to work seamlessly from inside IPython with the same commands
2266 you are used to in your system shell.
2205 you are used to in your system shell.
2267 \newline
2206 \newline
2268 IPython comes with some pre-defined aliases and a complete system for changing
2207 IPython comes with some pre-defined aliases and a complete system for changing
2269 directories, both via a stack (see
2208 directories, both via a stack (see
2270 \family typewriter
2209 \family typewriter
2271 %pushd
2210 %pushd
2272 \family default
2211 \family default
2273 ,
2212 ,
2274 \family typewriter
2213 \family typewriter
2275 %popd
2214 %popd
2276 \family default
2215 \family default
2277 and
2216 and
2278 \family typewriter
2217 \family typewriter
2279 %ds
2218 %ds
2280 \family default
2219 \family default
2281 ) and via direct
2220 ) and via direct
2282 \family typewriter
2221 \family typewriter
2283 %cd
2222 %cd
2284 \family default
2223 \family default
2285 .
2224 .
2286 The latter keeps a history of visited directories and allows you to go
2225 The latter keeps a history of visited directories and allows you to go
2287 to any previously visited one.
2226 to any previously visited one.
2288 \layout Itemize
2227 \layout Itemize
2289
2228
2290 Use Python to manipulate the results of system commands.
2229 Use Python to manipulate the results of system commands.
2291 The `
2230 The `
2292 \family typewriter
2231 \family typewriter
2293 !!
2232 !!
2294 \family default
2233 \family default
2295 ' special syntax, and the
2234 ' special syntax, and the
2296 \family typewriter
2235 \family typewriter
2297 %sc
2236 %sc
2298 \family default
2237 \family default
2299 and
2238 and
2300 \family typewriter
2239 \family typewriter
2301 %sx
2240 %sx
2302 \family default
2241 \family default
2303 magic commands allow you to capture system output into Python variables.
2242 magic commands allow you to capture system output into Python variables.
2304 \layout Itemize
2243 \layout Itemize
2305
2244
2306 Expand python variables when calling the shell (either via
2245 Expand python variables when calling the shell (either via
2307 \family typewriter
2246 \family typewriter
2308 `!'
2247 `!'
2309 \family default
2248 \family default
2310 and
2249 and
2311 \family typewriter
2250 \family typewriter
2312 `!!'
2251 `!!'
2313 \family default
2252 \family default
2314 or via aliases) by prepending a
2253 or via aliases) by prepending a
2315 \family typewriter
2254 \family typewriter
2316 $
2255 $
2317 \family default
2256 \family default
2318 in front of them.
2257 in front of them.
2319 You can also expand complete python expressions.
2258 You can also expand complete python expressions.
2320 See sec.\SpecialChar ~
2259 See sec.\SpecialChar ~
2321
2260
2322 \begin_inset LatexCommand \ref{sub:System-shell-access}
2261 \begin_inset LatexCommand \ref{sub:System-shell-access}
2323
2262
2324 \end_inset
2263 \end_inset
2325
2264
2326 for more.
2265 for more.
2327 \layout Itemize
2266 \layout Itemize
2328
2267
2329 Use profiles to maintain different configurations (modules to load, function
2268 Use profiles to maintain different configurations (modules to load, function
2330 definitions, option settings) for particular tasks.
2269 definitions, option settings) for particular tasks.
2331 You can then have customized versions of IPython for specific purposes.
2270 You can then have customized versions of IPython for specific purposes.
2332 See sec.\SpecialChar ~
2271 See sec.\SpecialChar ~
2333
2272
2334 \begin_inset LatexCommand \ref{sec:profiles}
2273 \begin_inset LatexCommand \ref{sec:profiles}
2335
2274
2336 \end_inset
2275 \end_inset
2337
2276
2338 for more.
2277 for more.
2339 \layout Itemize
2278 \layout Itemize
2340
2279
2341 Embed IPython in your programs.
2280 Embed IPython in your programs.
2342 A few lines of code are enough to load a complete IPython inside your own
2281 A few lines of code are enough to load a complete IPython inside your own
2343 programs, giving you the ability to work with your data interactively after
2282 programs, giving you the ability to work with your data interactively after
2344 automatic processing has been completed.
2283 automatic processing has been completed.
2345 See sec.\SpecialChar ~
2284 See sec.\SpecialChar ~
2346
2285
2347 \begin_inset LatexCommand \ref{sec:embed}
2286 \begin_inset LatexCommand \ref{sec:embed}
2348
2287
2349 \end_inset
2288 \end_inset
2350
2289
2351 for more.
2290 for more.
2352 \layout Itemize
2291 \layout Itemize
2353
2292
2354 Use the Python profiler.
2293 Use the Python profiler.
2355 When dealing with performance issues, the
2294 When dealing with performance issues, the
2356 \family typewriter
2295 \family typewriter
2357 %run
2296 %run
2358 \family default
2297 \family default
2359 command with a
2298 command with a
2360 \family typewriter
2299 \family typewriter
2361 -p
2300 -p
2362 \family default
2301 \family default
2363 option allows you to run complete programs under the control of the Python
2302 option allows you to run complete programs under the control of the Python
2364 profiler.
2303 profiler.
2365 The
2304 The
2366 \family typewriter
2305 \family typewriter
2367 %prun
2306 %prun
2368 \family default
2307 \family default
2369 command does a similar job for single Python expressions (like function
2308 command does a similar job for single Python expressions (like function
2370 calls).
2309 calls).
2371 \layout Itemize
2310 \layout Itemize
2372
2311
2373 Use
2312 Use
2374 \family typewriter
2313 \family typewriter
2375 %edit
2314 %edit
2376 \family default
2315 \family default
2377 to have almost multiline editing.
2316 to have almost multiline editing.
2378 While IPython doesn't support true multiline editing, this command allows
2317 While IPython doesn't support true multiline editing, this command allows
2379 you to call an editor on the spot, and IPython will execute the code you
2318 you to call an editor on the spot, and IPython will execute the code you
2380 type in there as if it were typed interactively.
2319 type in there as if it were typed interactively.
2381 \layout Itemize
2320 \layout Itemize
2382
2321
2383 Use the IPython.demo.Demo class to load any Python script as an interactive
2322 Use the IPython.demo.Demo class to load any Python script as an interactive
2384 demo.
2323 demo.
2385 With a minimal amount of simple markup, you can control the execution of
2324 With a minimal amount of simple markup, you can control the execution of
2386 the script, stopping as needed.
2325 the script, stopping as needed.
2387 See sec.\SpecialChar ~
2326 See sec.\SpecialChar ~
2388
2327
2389 \begin_inset LatexCommand \ref{sec:interactive-demos}
2328 \begin_inset LatexCommand \ref{sec:interactive-demos}
2390
2329
2391 \end_inset
2330 \end_inset
2392
2331
2393 for more.
2332 for more.
2394 \layout Standard
2333 \layout Standard
2395
2334
2335
2336 \series bold
2337 Effective logging:
2338 \series default
2339 a very useful suggestion sent in by Robert Kern follows
2340 \layout Standard
2341
2342 I recently happened on a nifty way to keep tidy per-project log files.
2343 I made a profile for my project (which is called "parkfield").
2344 \layout LyX-Code
2345
2346 include ipythonrc
2347 \layout LyX-Code
2348
2349 logfile '' # cancel earlier logfile invocation
2350 \layout LyX-Code
2351
2352 execute import time
2353 \layout LyX-Code
2354
2355 execute __cmd = '/Users/kern/research/logfiles/parkfield-%s.log rotate'
2356 \layout LyX-Code
2357
2358 execute __IP.magic_logstart(__cmd % time.strftime('%Y-%m-%d'))
2359 \layout Standard
2360
2361 I also added a shell alias for convenience:
2362 \layout LyX-Code
2363
2364 alias parkfield="ipython -pylab -profile parkfield"
2365 \layout Standard
2366
2367 Now I have a nice little directory with everything I ever type in, organized
2368 by project and date.
2369 \layout Standard
2370
2371
2372 \series bold
2373 Contribute your own:
2374 \series default
2396 If you have your own favorite tip on using IPython efficiently for a certain
2375 If you have your own favorite tip on using IPython efficiently for a certain
2397 task (especially things which can't be done in the normal Python interpreter),
2376 task (especially things which can't be done in the normal Python interpreter),
2398 don't hesitate to send it!
2377 don't hesitate to send it!
2399 \layout Section
2378 \layout Section
2400
2379
2401 Command-line use
2380 Command-line use
2402 \layout Standard
2381 \layout Standard
2403
2382
2404 You start IPython with the command:
2383 You start IPython with the command:
2405 \layout Standard
2384 \layout Standard
2406
2385
2407
2386
2408 \family typewriter
2387 \family typewriter
2409 $ ipython [options] files
2388 $ ipython [options] files
2410 \layout Standard
2389 \layout Standard
2411
2390
2412 If invoked with no options, it executes all the files listed in sequence
2391 If invoked with no options, it executes all the files listed in sequence
2413 and drops you into the interpreter while still acknowledging any options
2392 and drops you into the interpreter while still acknowledging any options
2414 you may have set in your ipythonrc file.
2393 you may have set in your ipythonrc file.
2415 This behavior is different from standard Python, which when called as
2394 This behavior is different from standard Python, which when called as
2416 \family typewriter
2395 \family typewriter
2417 python -i
2396 python -i
2418 \family default
2397 \family default
2419 will only execute one file and ignore your configuration setup.
2398 will only execute one file and ignore your configuration setup.
2420 \layout Standard
2399 \layout Standard
2421
2400
2422 Please note that some of the configuration options are not available at
2401 Please note that some of the configuration options are not available at
2423 the command line, simply because they are not practical here.
2402 the command line, simply because they are not practical here.
2424 Look into your ipythonrc configuration file for details on those.
2403 Look into your ipythonrc configuration file for details on those.
2425 This file typically installed in the
2404 This file typically installed in the
2426 \family typewriter
2405 \family typewriter
2427 $HOME/.ipython
2406 $HOME/.ipython
2428 \family default
2407 \family default
2429 directory.
2408 directory.
2430 For Windows users,
2409 For Windows users,
2431 \family typewriter
2410 \family typewriter
2432 $HOME
2411 $HOME
2433 \family default
2412 \family default
2434 resolves to
2413 resolves to
2435 \family typewriter
2414 \family typewriter
2436 C:
2415 C:
2437 \backslash
2416 \backslash
2438
2417
2439 \backslash
2418 \backslash
2440 Documents and Settings
2419 Documents and Settings
2441 \backslash
2420 \backslash
2442
2421
2443 \backslash
2422 \backslash
2444 YourUserName
2423 YourUserName
2445 \family default
2424 \family default
2446 in most instances.
2425 in most instances.
2447 In the rest of this text, we will refer to this directory as
2426 In the rest of this text, we will refer to this directory as
2448 \family typewriter
2427 \family typewriter
2449 IPYTHONDIR
2428 IPYTHONDIR
2450 \family default
2429 \family default
2451 .
2430 .
2452 \layout Subsection
2431 \layout Subsection
2453
2432
2454
2433
2455 \begin_inset LatexCommand \label{sec:threading-opts}
2434 \begin_inset LatexCommand \label{sec:threading-opts}
2456
2435
2457 \end_inset
2436 \end_inset
2458
2437
2459 Special Threading Options
2438 Special Threading Options
2460 \layout Standard
2439 \layout Standard
2461
2440
2462 The following special options are ONLY valid at the beginning of the command
2441 The following special options are ONLY valid at the beginning of the command
2463 line, and not later.
2442 line, and not later.
2464 This is because they control the initial- ization of ipython itself, before
2443 This is because they control the initial- ization of ipython itself, before
2465 the normal option-handling mechanism is active.
2444 the normal option-handling mechanism is active.
2466 \layout List
2445 \layout List
2467 \labelwidthstring 00.00.0000
2446 \labelwidthstring 00.00.0000
2468
2447
2469
2448
2470 \family typewriter
2449 \family typewriter
2471 \series bold
2450 \series bold
2472 -gthread,\SpecialChar ~
2451 -gthread,\SpecialChar ~
2473 -qthread,\SpecialChar ~
2452 -qthread,\SpecialChar ~
2474 -wthread,\SpecialChar ~
2453 -wthread,\SpecialChar ~
2475 -pylab:
2454 -pylab:
2476 \family default
2455 \family default
2477 \series default
2456 \series default
2478 Only
2457 Only
2479 \emph on
2458 \emph on
2480 one
2459 one
2481 \emph default
2460 \emph default
2482 of these can be given, and it can only be given as the first option passed
2461 of these can be given, and it can only be given as the first option passed
2483 to IPython (it will have no effect in any other position).
2462 to IPython (it will have no effect in any other position).
2484 They provide threading support for the GTK Qt and WXPython toolkits, and
2463 They provide threading support for the GTK Qt and WXPython toolkits, and
2485 for the matplotlib library.
2464 for the matplotlib library.
2486 \layout List
2465 \layout List
2487 \labelwidthstring 00.00.0000
2466 \labelwidthstring 00.00.0000
2488
2467
2489 \SpecialChar ~
2468 \SpecialChar ~
2490 With any of the first three options, IPython starts running a separate
2469 With any of the first three options, IPython starts running a separate
2491 thread for the graphical toolkit's operation, so that you can open and
2470 thread for the graphical toolkit's operation, so that you can open and
2492 control graphical elements from within an IPython command line, without
2471 control graphical elements from within an IPython command line, without
2493 blocking.
2472 blocking.
2494 All three provide essentially the same functionality, respectively for
2473 All three provide essentially the same functionality, respectively for
2495 GTK, QT and WXWidgets (via their Python interfaces).
2474 GTK, QT and WXWidgets (via their Python interfaces).
2496 \layout List
2475 \layout List
2497 \labelwidthstring 00.00.0000
2476 \labelwidthstring 00.00.0000
2498
2477
2499 \SpecialChar ~
2478 \SpecialChar ~
2500 If
2479 If
2501 \family typewriter
2480 \family typewriter
2502 -pylab
2481 -pylab
2503 \family default
2482 \family default
2504 is given, IPython loads special support for the mat plotlib library (
2483 is given, IPython loads special support for the mat plotlib library (
2505 \begin_inset LatexCommand \htmlurl{http://matplotlib.sourceforge.net}
2484 \begin_inset LatexCommand \htmlurl{http://matplotlib.sourceforge.net}
2506
2485
2507 \end_inset
2486 \end_inset
2508
2487
2509 ), allowing interactive usage of any of its backends as defined in the user's
2488 ), allowing interactive usage of any of its backends as defined in the user's
2510
2489
2511 \family typewriter
2490 \family typewriter
2512 ~/.matplotlib/matplotlibrc
2491 ~/.matplotlib/matplotlibrc
2513 \family default
2492 \family default
2514 file.
2493 file.
2515 It automatically activates GTK, Qt or WX threading for IPyhton if the choice
2494 It automatically activates GTK, Qt or WX threading for IPyhton if the choice
2516 of matplotlib backend requires it.
2495 of matplotlib backend requires it.
2517 It also modifies the
2496 It also modifies the
2518 \family typewriter
2497 \family typewriter
2519 %run
2498 %run
2520 \family default
2499 \family default
2521 command to correctly execute (without blocking) any matplotlib-based script
2500 command to correctly execute (without blocking) any matplotlib-based script
2522 which calls
2501 which calls
2523 \family typewriter
2502 \family typewriter
2524 show()
2503 show()
2525 \family default
2504 \family default
2526 at the end.
2505 at the end.
2527
2506
2528 \layout List
2507 \layout List
2529 \labelwidthstring 00.00.0000
2508 \labelwidthstring 00.00.0000
2530
2509
2531
2510
2532 \family typewriter
2511 \family typewriter
2533 \series bold
2512 \series bold
2534 -tk
2513 -tk
2535 \family default
2514 \family default
2536 \series default
2515 \series default
2537 The
2516 The
2538 \family typewriter
2517 \family typewriter
2539 -g/q/wthread
2518 -g/q/wthread
2540 \family default
2519 \family default
2541 options, and
2520 options, and
2542 \family typewriter
2521 \family typewriter
2543 -pylab
2522 -pylab
2544 \family default
2523 \family default
2545 (if matplotlib is configured to use GTK, Qt or WX), will normally block
2524 (if matplotlib is configured to use GTK, Qt or WX), will normally block
2546 Tk graphical interfaces.
2525 Tk graphical interfaces.
2547 This means that when either GTK, Qt or WX threading is active, any attempt
2526 This means that when either GTK, Qt or WX threading is active, any attempt
2548 to open a Tk GUI will result in a dead window, and possibly cause the Python
2527 to open a Tk GUI will result in a dead window, and possibly cause the Python
2549 interpreter to crash.
2528 interpreter to crash.
2550 An extra option,
2529 An extra option,
2551 \family typewriter
2530 \family typewriter
2552 -tk
2531 -tk
2553 \family default
2532 \family default
2554 , is available to address this issue.
2533 , is available to address this issue.
2555 It can
2534 It can
2556 \emph on
2535 \emph on
2557 only
2536 only
2558 \emph default
2537 \emph default
2559 be given as a
2538 be given as a
2560 \emph on
2539 \emph on
2561 second
2540 second
2562 \emph default
2541 \emph default
2563 option after any of the above (
2542 option after any of the above (
2564 \family typewriter
2543 \family typewriter
2565 -gthread
2544 -gthread
2566 \family default
2545 \family default
2567 ,
2546 ,
2568 \family typewriter
2547 \family typewriter
2569 -wthread
2548 -wthread
2570 \family default
2549 \family default
2571 or
2550 or
2572 \family typewriter
2551 \family typewriter
2573 -pylab
2552 -pylab
2574 \family default
2553 \family default
2575 ).
2554 ).
2576 \layout List
2555 \layout List
2577 \labelwidthstring 00.00.0000
2556 \labelwidthstring 00.00.0000
2578
2557
2579 \SpecialChar ~
2558 \SpecialChar ~
2580 If
2559 If
2581 \family typewriter
2560 \family typewriter
2582 -tk
2561 -tk
2583 \family default
2562 \family default
2584 is given, IPython will try to coordinate Tk threading with GTK, Qt or WX.
2563 is given, IPython will try to coordinate Tk threading with GTK, Qt or WX.
2585 This is however potentially unreliable, and you will have to test on your
2564 This is however potentially unreliable, and you will have to test on your
2586 platform and Python configuration to determine whether it works for you.
2565 platform and Python configuration to determine whether it works for you.
2587 Debian users have reported success, apparently due to the fact that Debian
2566 Debian users have reported success, apparently due to the fact that Debian
2588 builds all of Tcl, Tk, Tkinter and Python with pthreads support.
2567 builds all of Tcl, Tk, Tkinter and Python with pthreads support.
2589 Under other Linux environments (such as Fedora Core 2/3), this option has
2568 Under other Linux environments (such as Fedora Core 2/3), this option has
2590 caused random crashes and lockups of the Python interpreter.
2569 caused random crashes and lockups of the Python interpreter.
2591 Under other operating systems (Mac OSX and Windows), you'll need to try
2570 Under other operating systems (Mac OSX and Windows), you'll need to try
2592 it to find out, since currently no user reports are available.
2571 it to find out, since currently no user reports are available.
2593 \layout List
2572 \layout List
2594 \labelwidthstring 00.00.0000
2573 \labelwidthstring 00.00.0000
2595
2574
2596 \SpecialChar ~
2575 \SpecialChar ~
2597 There is unfortunately no way for IPython to determine at run time whether
2576 There is unfortunately no way for IPython to determine at run time whether
2598
2577
2599 \family typewriter
2578 \family typewriter
2600 -tk
2579 -tk
2601 \family default
2580 \family default
2602 will work reliably or not, so you will need to do some experiments before
2581 will work reliably or not, so you will need to do some experiments before
2603 relying on it for regular work.
2582 relying on it for regular work.
2604
2583
2605 \layout Subsection
2584 \layout Subsection
2606
2585
2607
2586
2608 \begin_inset LatexCommand \label{sec:cmd-line-opts}
2587 \begin_inset LatexCommand \label{sec:cmd-line-opts}
2609
2588
2610 \end_inset
2589 \end_inset
2611
2590
2612 Regular Options
2591 Regular Options
2613 \layout Standard
2592 \layout Standard
2614
2593
2615 After the above threading options have been given, regular options can follow
2594 After the above threading options have been given, regular options can follow
2616 in any order.
2595 in any order.
2617 All options can be abbreviated to their shortest non-ambiguous form and
2596 All options can be abbreviated to their shortest non-ambiguous form and
2618 are case-sensitive.
2597 are case-sensitive.
2619 One or two dashes can be used.
2598 One or two dashes can be used.
2620 Some options have an alternate short form, indicated after a
2599 Some options have an alternate short form, indicated after a
2621 \family typewriter
2600 \family typewriter
2622 |
2601 |
2623 \family default
2602 \family default
2624 .
2603 .
2625 \layout Standard
2604 \layout Standard
2626
2605
2627 Most options can also be set from your ipythonrc configuration file.
2606 Most options can also be set from your ipythonrc configuration file.
2628 See the provided example for more details on what the options do.
2607 See the provided example for more details on what the options do.
2629 Options given at the command line override the values set in the ipythonrc
2608 Options given at the command line override the values set in the ipythonrc
2630 file.
2609 file.
2631 \layout Standard
2610 \layout Standard
2632
2611
2633 All options with a
2612 All options with a
2634 \family typewriter
2613 \family typewriter
2635 [no]
2614 [no]
2636 \family default
2615 \family default
2637 prepended can be specified in negated form (
2616 prepended can be specified in negated form (
2638 \family typewriter
2617 \family typewriter
2639 -nooption
2618 -nooption
2640 \family default
2619 \family default
2641 instead of
2620 instead of
2642 \family typewriter
2621 \family typewriter
2643 -option
2622 -option
2644 \family default
2623 \family default
2645 ) to turn the feature off.
2624 ) to turn the feature off.
2646 \layout List
2625 \layout List
2647 \labelwidthstring 00.00.0000
2626 \labelwidthstring 00.00.0000
2648
2627
2649
2628
2650 \family typewriter
2629 \family typewriter
2651 \series bold
2630 \series bold
2652 -help
2631 -help
2653 \family default
2632 \family default
2654 \series default
2633 \series default
2655 : print a help message and exit.
2634 : print a help message and exit.
2656 \layout List
2635 \layout List
2657 \labelwidthstring 00.00.0000
2636 \labelwidthstring 00.00.0000
2658
2637
2659
2638
2660 \family typewriter
2639 \family typewriter
2661 \series bold
2640 \series bold
2662 -pylab:
2641 -pylab:
2663 \family default
2642 \family default
2664 \series default
2643 \series default
2665 this can
2644 this can
2666 \emph on
2645 \emph on
2667 only
2646 only
2668 \emph default
2647 \emph default
2669 be given as the
2648 be given as the
2670 \emph on
2649 \emph on
2671 first
2650 first
2672 \emph default
2651 \emph default
2673 option passed to IPython (it will have no effect in any other position).
2652 option passed to IPython (it will have no effect in any other position).
2674 It adds special support for the matplotlib library (
2653 It adds special support for the matplotlib library (
2675 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
2654 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
2676
2655
2677 \end_inset
2656 \end_inset
2678
2657
2679 ), allowing interactive usage of any of its backends as defined in the user's
2658 ), allowing interactive usage of any of its backends as defined in the user's
2680
2659
2681 \family typewriter
2660 \family typewriter
2682 .matplotlibrc
2661 .matplotlibrc
2683 \family default
2662 \family default
2684 file.
2663 file.
2685 It automatically activates GTK or WX threading for IPyhton if the choice
2664 It automatically activates GTK or WX threading for IPyhton if the choice
2686 of matplotlib backend requires it.
2665 of matplotlib backend requires it.
2687 It also modifies the
2666 It also modifies the
2688 \family typewriter
2667 \family typewriter
2689 %run
2668 %run
2690 \family default
2669 \family default
2691 command to correctly execute (without blocking) any matplotlib-based script
2670 command to correctly execute (without blocking) any matplotlib-based script
2692 which calls
2671 which calls
2693 \family typewriter
2672 \family typewriter
2694 show()
2673 show()
2695 \family default
2674 \family default
2696 at the end.
2675 at the end.
2697 See Sec.\SpecialChar ~
2676 See Sec.\SpecialChar ~
2698
2677
2699 \begin_inset LatexCommand \ref{sec:matplotlib-support}
2678 \begin_inset LatexCommand \ref{sec:matplotlib-support}
2700
2679
2701 \end_inset
2680 \end_inset
2702
2681
2703 for more details.
2682 for more details.
2704 \layout List
2683 \layout List
2705 \labelwidthstring 00.00.0000
2684 \labelwidthstring 00.00.0000
2706
2685
2707
2686
2708 \family typewriter
2687 \family typewriter
2709 \series bold
2688 \series bold
2710 -[no]autocall:
2689 -[no]autocall:
2711 \family default
2690 \family default
2712 \series default
2691 \series default
2713 Make IPython automatically call any callable object even if you didn't
2692 Make IPython automatically call any callable object even if you didn't
2714 type explicit parentheses.
2693 type explicit parentheses.
2715 For example, `str 43' becomes `str(43)' automatically.
2694 For example, `str 43' becomes `str(43)' automatically.
2716 \layout List
2695 \layout List
2717 \labelwidthstring 00.00.0000
2696 \labelwidthstring 00.00.0000
2718
2697
2719
2698
2720 \family typewriter
2699 \family typewriter
2721 \series bold
2700 \series bold
2722 -[no]autoindent:
2701 -[no]autoindent:
2723 \family default
2702 \family default
2724 \series default
2703 \series default
2725 Turn automatic indentation on/off.
2704 Turn automatic indentation on/off.
2726 \layout List
2705 \layout List
2727 \labelwidthstring 00.00.0000
2706 \labelwidthstring 00.00.0000
2728
2707
2729
2708
2730 \family typewriter
2709 \family typewriter
2731 \series bold
2710 \series bold
2732 -[no]automagic
2711 -[no]automagic
2733 \series default
2712 \series default
2734 :
2713 :
2735 \family default
2714 \family default
2736 make magic commands automatic (without needing their first character to
2715 make magic commands automatic (without needing their first character to
2737 be
2716 be
2738 \family typewriter
2717 \family typewriter
2739 %
2718 %
2740 \family default
2719 \family default
2741 ).
2720 ).
2742 Type
2721 Type
2743 \family typewriter
2722 \family typewriter
2744 %magic
2723 %magic
2745 \family default
2724 \family default
2746 at the IPython prompt for more information.
2725 at the IPython prompt for more information.
2747 \layout List
2726 \layout List
2748 \labelwidthstring 00.00.0000
2727 \labelwidthstring 00.00.0000
2749
2728
2750
2729
2751 \family typewriter
2730 \family typewriter
2752 \series bold
2731 \series bold
2753 -[no]autoedit_syntax:
2732 -[no]autoedit_syntax:
2754 \family default
2733 \family default
2755 \series default
2734 \series default
2756 When a syntax error occurs after editing a file, automatically open the
2735 When a syntax error occurs after editing a file, automatically open the
2757 file to the trouble causing line for convenient fixing.
2736 file to the trouble causing line for convenient fixing.
2758
2737
2759 \layout List
2738 \layout List
2760 \labelwidthstring 00.00.0000
2739 \labelwidthstring 00.00.0000
2761
2740
2762
2741
2763 \family typewriter
2742 \family typewriter
2764 \series bold
2743 \series bold
2765 -[no]banner
2744 -[no]banner
2766 \series default
2745 \series default
2767 :
2746 :
2768 \family default
2747 \family default
2769 Print the initial information banner (default on).
2748 Print the initial information banner (default on).
2770 \layout List
2749 \layout List
2771 \labelwidthstring 00.00.0000
2750 \labelwidthstring 00.00.0000
2772
2751
2773
2752
2774 \family typewriter
2753 \family typewriter
2775 \series bold
2754 \series bold
2776 -c\SpecialChar ~
2755 -c\SpecialChar ~
2777 <command>:
2756 <command>:
2778 \family default
2757 \family default
2779 \series default
2758 \series default
2780 execute the given command string, and set sys.argv to
2759 execute the given command string, and set sys.argv to
2781 \family typewriter
2760 \family typewriter
2782 ['c']
2761 ['c']
2783 \family default
2762 \family default
2784 .
2763 .
2785 This is similar to the
2764 This is similar to the
2786 \family typewriter
2765 \family typewriter
2787 -c
2766 -c
2788 \family default
2767 \family default
2789 option in the normal Python interpreter.
2768 option in the normal Python interpreter.
2790
2769
2791 \layout List
2770 \layout List
2792 \labelwidthstring 00.00.0000
2771 \labelwidthstring 00.00.0000
2793
2772
2794
2773
2795 \family typewriter
2774 \family typewriter
2796 \series bold
2775 \series bold
2797 -cache_size|cs\SpecialChar ~
2776 -cache_size|cs\SpecialChar ~
2798 <n>
2777 <n>
2799 \series default
2778 \series default
2800 :
2779 :
2801 \family default
2780 \family default
2802 size of the output cache (maximum number of entries to hold in memory).
2781 size of the output cache (maximum number of entries to hold in memory).
2803 The default is 1000, you can change it permanently in your config file.
2782 The default is 1000, you can change it permanently in your config file.
2804 Setting it to 0 completely disables the caching system, and the minimum
2783 Setting it to 0 completely disables the caching system, and the minimum
2805 value accepted is 20 (if you provide a value less than 20, it is reset
2784 value accepted is 20 (if you provide a value less than 20, it is reset
2806 to 0 and a warning is issued) This limit is defined because otherwise you'll
2785 to 0 and a warning is issued) This limit is defined because otherwise you'll
2807 spend more time re-flushing a too small cache than working.
2786 spend more time re-flushing a too small cache than working.
2808 \layout List
2787 \layout List
2809 \labelwidthstring 00.00.0000
2788 \labelwidthstring 00.00.0000
2810
2789
2811
2790
2812 \family typewriter
2791 \family typewriter
2813 \series bold
2792 \series bold
2814 -classic|cl
2793 -classic|cl
2815 \series default
2794 \series default
2816 :
2795 :
2817 \family default
2796 \family default
2818 Gives IPython a similar feel to the classic Python prompt.
2797 Gives IPython a similar feel to the classic Python prompt.
2819 \layout List
2798 \layout List
2820 \labelwidthstring 00.00.0000
2799 \labelwidthstring 00.00.0000
2821
2800
2822
2801
2823 \family typewriter
2802 \family typewriter
2824 \series bold
2803 \series bold
2825 -colors\SpecialChar ~
2804 -colors\SpecialChar ~
2826 <scheme>:
2805 <scheme>:
2827 \family default
2806 \family default
2828 \series default
2807 \series default
2829 Color scheme for prompts and exception reporting.
2808 Color scheme for prompts and exception reporting.
2830 Currently implemented: NoColor, Linux and LightBG.
2809 Currently implemented: NoColor, Linux and LightBG.
2831 \layout List
2810 \layout List
2832 \labelwidthstring 00.00.0000
2811 \labelwidthstring 00.00.0000
2833
2812
2834
2813
2835 \family typewriter
2814 \family typewriter
2836 \series bold
2815 \series bold
2837 -[no]color_info:
2816 -[no]color_info:
2838 \family default
2817 \family default
2839 \series default
2818 \series default
2840 IPython can display information about objects via a set of functions, and
2819 IPython can display information about objects via a set of functions, and
2841 optionally can use colors for this, syntax highlighting source code and
2820 optionally can use colors for this, syntax highlighting source code and
2842 various other elements.
2821 various other elements.
2843 However, because this information is passed through a pager (like 'less')
2822 However, because this information is passed through a pager (like 'less')
2844 and many pagers get confused with color codes, this option is off by default.
2823 and many pagers get confused with color codes, this option is off by default.
2845 You can test it and turn it on permanently in your ipythonrc file if it
2824 You can test it and turn it on permanently in your ipythonrc file if it
2846 works for you.
2825 works for you.
2847 As a reference, the 'less' pager supplied with Mandrake 8.2 works ok, but
2826 As a reference, the 'less' pager supplied with Mandrake 8.2 works ok, but
2848 that in RedHat 7.2 doesn't.
2827 that in RedHat 7.2 doesn't.
2849 \layout List
2828 \layout List
2850 \labelwidthstring 00.00.0000
2829 \labelwidthstring 00.00.0000
2851
2830
2852 \SpecialChar ~
2831 \SpecialChar ~
2853 Test it and turn it on permanently if it works with your system.
2832 Test it and turn it on permanently if it works with your system.
2854 The magic function
2833 The magic function
2855 \family typewriter
2834 \family typewriter
2856 %color_info
2835 %color_info
2857 \family default
2836 \family default
2858 allows you to toggle this interactively for testing.
2837 allows you to toggle this interactively for testing.
2859 \layout List
2838 \layout List
2860 \labelwidthstring 00.00.0000
2839 \labelwidthstring 00.00.0000
2861
2840
2862
2841
2863 \family typewriter
2842 \family typewriter
2864 \series bold
2843 \series bold
2865 -[no]debug
2844 -[no]debug
2866 \family default
2845 \family default
2867 \series default
2846 \series default
2868 : Show information about the loading process.
2847 : Show information about the loading process.
2869 Very useful to pin down problems with your configuration files or to get
2848 Very useful to pin down problems with your configuration files or to get
2870 details about session restores.
2849 details about session restores.
2871 \layout List
2850 \layout List
2872 \labelwidthstring 00.00.0000
2851 \labelwidthstring 00.00.0000
2873
2852
2874
2853
2875 \family typewriter
2854 \family typewriter
2876 \series bold
2855 \series bold
2877 -[no]deep_reload
2856 -[no]deep_reload
2878 \series default
2857 \series default
2879 :
2858 :
2880 \family default
2859 \family default
2881 IPython can use the
2860 IPython can use the
2882 \family typewriter
2861 \family typewriter
2883 deep_reload
2862 deep_reload
2884 \family default
2863 \family default
2885 module which reloads changes in modules recursively (it replaces the
2864 module which reloads changes in modules recursively (it replaces the
2886 \family typewriter
2865 \family typewriter
2887 reload()
2866 reload()
2888 \family default
2867 \family default
2889 function, so you don't need to change anything to use it).
2868 function, so you don't need to change anything to use it).
2890
2869
2891 \family typewriter
2870 \family typewriter
2892 deep_reload()
2871 deep_reload()
2893 \family default
2872 \family default
2894 forces a full reload of modules whose code may have changed, which the
2873 forces a full reload of modules whose code may have changed, which the
2895 default
2874 default
2896 \family typewriter
2875 \family typewriter
2897 reload()
2876 reload()
2898 \family default
2877 \family default
2899 function does not.
2878 function does not.
2900 \layout List
2879 \layout List
2901 \labelwidthstring 00.00.0000
2880 \labelwidthstring 00.00.0000
2902
2881
2903 \SpecialChar ~
2882 \SpecialChar ~
2904 When deep_reload is off, IPython will use the normal
2883 When deep_reload is off, IPython will use the normal
2905 \family typewriter
2884 \family typewriter
2906 reload()
2885 reload()
2907 \family default
2886 \family default
2908 , but deep_reload will still be available as
2887 , but deep_reload will still be available as
2909 \family typewriter
2888 \family typewriter
2910 dreload()
2889 dreload()
2911 \family default
2890 \family default
2912 .
2891 .
2913 This feature is off by default [which means that you have both normal
2892 This feature is off by default [which means that you have both normal
2914 \family typewriter
2893 \family typewriter
2915 reload()
2894 reload()
2916 \family default
2895 \family default
2917 and
2896 and
2918 \family typewriter
2897 \family typewriter
2919 dreload()
2898 dreload()
2920 \family default
2899 \family default
2921 ].
2900 ].
2922 \layout List
2901 \layout List
2923 \labelwidthstring 00.00.0000
2902 \labelwidthstring 00.00.0000
2924
2903
2925
2904
2926 \family typewriter
2905 \family typewriter
2927 \series bold
2906 \series bold
2928 -editor\SpecialChar ~
2907 -editor\SpecialChar ~
2929 <name>
2908 <name>
2930 \family default
2909 \family default
2931 \series default
2910 \series default
2932 : Which editor to use with the
2911 : Which editor to use with the
2933 \family typewriter
2912 \family typewriter
2934 %edit
2913 %edit
2935 \family default
2914 \family default
2936 command.
2915 command.
2937 By default, IPython will honor your
2916 By default, IPython will honor your
2938 \family typewriter
2917 \family typewriter
2939 EDITOR
2918 EDITOR
2940 \family default
2919 \family default
2941 environment variable (if not set, vi is the Unix default and notepad the
2920 environment variable (if not set, vi is the Unix default and notepad the
2942 Windows one).
2921 Windows one).
2943 Since this editor is invoked on the fly by IPython and is meant for editing
2922 Since this editor is invoked on the fly by IPython and is meant for editing
2944 small code snippets, you may want to use a small, lightweight editor here
2923 small code snippets, you may want to use a small, lightweight editor here
2945 (in case your default
2924 (in case your default
2946 \family typewriter
2925 \family typewriter
2947 EDITOR
2926 EDITOR
2948 \family default
2927 \family default
2949 is something like Emacs).
2928 is something like Emacs).
2950 \layout List
2929 \layout List
2951 \labelwidthstring 00.00.0000
2930 \labelwidthstring 00.00.0000
2952
2931
2953
2932
2954 \family typewriter
2933 \family typewriter
2955 \series bold
2934 \series bold
2956 -ipythondir\SpecialChar ~
2935 -ipythondir\SpecialChar ~
2957 <name>
2936 <name>
2958 \series default
2937 \series default
2959 :
2938 :
2960 \family default
2939 \family default
2961 name of your IPython configuration directory
2940 name of your IPython configuration directory
2962 \family typewriter
2941 \family typewriter
2963 IPYTHONDIR
2942 IPYTHONDIR
2964 \family default
2943 \family default
2965 .
2944 .
2966 This can also be specified through the environment variable
2945 This can also be specified through the environment variable
2967 \family typewriter
2946 \family typewriter
2968 IPYTHONDIR
2947 IPYTHONDIR
2969 \family default
2948 \family default
2970 .
2949 .
2971 \layout List
2950 \layout List
2972 \labelwidthstring 00.00.0000
2951 \labelwidthstring 00.00.0000
2973
2952
2974
2953
2975 \family typewriter
2954 \family typewriter
2976 \series bold
2955 \series bold
2977 -log|l
2956 -log|l
2978 \family default
2957 \family default
2979 \series default
2958 \series default
2980 : generate a log file of all input.
2959 : generate a log file of all input.
2981 Defaults to
2960 Defaults to
2982 \family typewriter
2961 \family typewriter
2983 $IPYTHONDIR/log
2962 $IPYTHONDIR/log
2984 \family default
2963 \family default
2985 .
2964 .
2986 You can use this to later restore a session by loading your logfile as
2965 You can use this to later restore a session by loading your logfile as
2987 a file to be executed with option
2966 a file to be executed with option
2988 \family typewriter
2967 \family typewriter
2989 -logplay
2968 -logplay
2990 \family default
2969 \family default
2991 (see below).
2970 (see below).
2992 \layout List
2971 \layout List
2993 \labelwidthstring 00.00.0000
2972 \labelwidthstring 00.00.0000
2994
2973
2995
2974
2996 \family typewriter
2975 \family typewriter
2997 \series bold
2976 \series bold
2998 -logfile|lf\SpecialChar ~
2977 -logfile|lf\SpecialChar ~
2999 <name>
2978 <name>
3000 \series default
2979 \series default
3001 :
2980 :
3002 \family default
2981 \family default
3003 specify the name of your logfile.
2982 specify the name of your logfile.
3004 \layout List
2983 \layout List
3005 \labelwidthstring 00.00.0000
2984 \labelwidthstring 00.00.0000
3006
2985
3007
2986
3008 \family typewriter
2987 \family typewriter
3009 \series bold
2988 \series bold
3010 -logplay|lp\SpecialChar ~
2989 -logplay|lp\SpecialChar ~
3011 <name>
2990 <name>
3012 \series default
2991 \series default
3013 :
2992 :
3014 \family default
2993 \family default
3015 you can replay a previous log.
2994 you can replay a previous log.
3016 For restoring a session as close as possible to the state you left it in,
2995 For restoring a session as close as possible to the state you left it in,
3017 use this option (don't just run the logfile).
2996 use this option (don't just run the logfile).
3018 With
2997 With
3019 \family typewriter
2998 \family typewriter
3020 -logplay
2999 -logplay
3021 \family default
3000 \family default
3022 , IPython will try to reconstruct the previous working environment in full,
3001 , IPython will try to reconstruct the previous working environment in full,
3023 not just execute the commands in the logfile.
3002 not just execute the commands in the logfile.
3024 \layout List
3003 \layout List
3025 \labelwidthstring 00.00.0000
3004 \labelwidthstring 00.00.0000
3026
3005
3027 \SpecialChar ~
3006 \SpecialChar ~
3028 When a session is restored, logging is automatically turned on again with
3007 When a session is restored, logging is automatically turned on again with
3029 the name of the logfile it was invoked with (it is read from the log header).
3008 the name of the logfile it was invoked with (it is read from the log header).
3030 So once you've turned logging on for a session, you can quit IPython and
3009 So once you've turned logging on for a session, you can quit IPython and
3031 reload it as many times as you want and it will continue to log its history
3010 reload it as many times as you want and it will continue to log its history
3032 and restore from the beginning every time.
3011 and restore from the beginning every time.
3033 \layout List
3012 \layout List
3034 \labelwidthstring 00.00.0000
3013 \labelwidthstring 00.00.0000
3035
3014
3036 \SpecialChar ~
3015 \SpecialChar ~
3037 Caveats: there are limitations in this option.
3016 Caveats: there are limitations in this option.
3038 The history variables
3017 The history variables
3039 \family typewriter
3018 \family typewriter
3040 _i*
3019 _i*
3041 \family default
3020 \family default
3042 ,
3021 ,
3043 \family typewriter
3022 \family typewriter
3044 _*
3023 _*
3045 \family default
3024 \family default
3046 and
3025 and
3047 \family typewriter
3026 \family typewriter
3048 _dh
3027 _dh
3049 \family default
3028 \family default
3050 don't get restored properly.
3029 don't get restored properly.
3051 In the future we will try to implement full session saving by writing and
3030 In the future we will try to implement full session saving by writing and
3052 retrieving a 'snapshot' of the memory state of IPython.
3031 retrieving a 'snapshot' of the memory state of IPython.
3053 But our first attempts failed because of inherent limitations of Python's
3032 But our first attempts failed because of inherent limitations of Python's
3054 Pickle module, so this may have to wait.
3033 Pickle module, so this may have to wait.
3055 \layout List
3034 \layout List
3056 \labelwidthstring 00.00.0000
3035 \labelwidthstring 00.00.0000
3057
3036
3058
3037
3059 \family typewriter
3038 \family typewriter
3060 \series bold
3039 \series bold
3061 -[no]messages
3040 -[no]messages
3062 \series default
3041 \series default
3063 :
3042 :
3064 \family default
3043 \family default
3065 Print messages which IPython collects about its startup process (default
3044 Print messages which IPython collects about its startup process (default
3066 on).
3045 on).
3067 \layout List
3046 \layout List
3068 \labelwidthstring 00.00.0000
3047 \labelwidthstring 00.00.0000
3069
3048
3070
3049
3071 \family typewriter
3050 \family typewriter
3072 \series bold
3051 \series bold
3073 -[no]pdb
3052 -[no]pdb
3074 \family default
3053 \family default
3075 \series default
3054 \series default
3076 : Automatically call the pdb debugger after every uncaught exception.
3055 : Automatically call the pdb debugger after every uncaught exception.
3077 If you are used to debugging using pdb, this puts you automatically inside
3056 If you are used to debugging using pdb, this puts you automatically inside
3078 of it after any call (either in IPython or in code called by it) which
3057 of it after any call (either in IPython or in code called by it) which
3079 triggers an exception which goes uncaught.
3058 triggers an exception which goes uncaught.
3080 \layout List
3059 \layout List
3081 \labelwidthstring 00.00.0000
3060 \labelwidthstring 00.00.0000
3082
3061
3083
3062
3084 \family typewriter
3063 \family typewriter
3085 \series bold
3064 \series bold
3086 -[no]pprint
3065 -[no]pprint
3087 \series default
3066 \series default
3088 :
3067 :
3089 \family default
3068 \family default
3090 ipython can optionally use the pprint (pretty printer) module for displaying
3069 ipython can optionally use the pprint (pretty printer) module for displaying
3091 results.
3070 results.
3092 pprint tends to give a nicer display of nested data structures.
3071 pprint tends to give a nicer display of nested data structures.
3093 If you like it, you can turn it on permanently in your config file (default
3072 If you like it, you can turn it on permanently in your config file (default
3094 off).
3073 off).
3095 \layout List
3074 \layout List
3096 \labelwidthstring 00.00.0000
3075 \labelwidthstring 00.00.0000
3097
3076
3098
3077
3099 \family typewriter
3078 \family typewriter
3100 \series bold
3079 \series bold
3101 -profile|p <name>
3080 -profile|p <name>
3102 \series default
3081 \series default
3103 :
3082 :
3104 \family default
3083 \family default
3105 assume that your config file is
3084 assume that your config file is
3106 \family typewriter
3085 \family typewriter
3107 ipythonrc-<name>
3086 ipythonrc-<name>
3108 \family default
3087 \family default
3109 (looks in current dir first, then in
3088 (looks in current dir first, then in
3110 \family typewriter
3089 \family typewriter
3111 IPYTHONDIR
3090 IPYTHONDIR
3112 \family default
3091 \family default
3113 ).
3092 ).
3114 This is a quick way to keep and load multiple config files for different
3093 This is a quick way to keep and load multiple config files for different
3115 tasks, especially if you use the include option of config files.
3094 tasks, especially if you use the include option of config files.
3116 You can keep a basic
3095 You can keep a basic
3117 \family typewriter
3096 \family typewriter
3118 IPYTHONDIR/ipythonrc
3097 IPYTHONDIR/ipythonrc
3119 \family default
3098 \family default
3120 file and then have other 'profiles' which include this one and load extra
3099 file and then have other 'profiles' which include this one and load extra
3121 things for particular tasks.
3100 things for particular tasks.
3122 For example:
3101 For example:
3123 \layout List
3102 \layout List
3124 \labelwidthstring 00.00.0000
3103 \labelwidthstring 00.00.0000
3125
3104
3126
3105
3127 \family typewriter
3106 \family typewriter
3128 \SpecialChar ~
3107 \SpecialChar ~
3129
3108
3130 \family default
3109 \family default
3131 1.
3110 1.
3132
3111
3133 \family typewriter
3112 \family typewriter
3134 $HOME/.ipython/ipythonrc
3113 $HOME/.ipython/ipythonrc
3135 \family default
3114 \family default
3136 : load basic things you always want.
3115 : load basic things you always want.
3137 \layout List
3116 \layout List
3138 \labelwidthstring 00.00.0000
3117 \labelwidthstring 00.00.0000
3139
3118
3140
3119
3141 \family typewriter
3120 \family typewriter
3142 \SpecialChar ~
3121 \SpecialChar ~
3143
3122
3144 \family default
3123 \family default
3145 2.
3124 2.
3146
3125
3147 \family typewriter
3126 \family typewriter
3148 $HOME/.ipython/ipythonrc-math
3127 $HOME/.ipython/ipythonrc-math
3149 \family default
3128 \family default
3150 : load (1) and basic math-related modules.
3129 : load (1) and basic math-related modules.
3151
3130
3152 \layout List
3131 \layout List
3153 \labelwidthstring 00.00.0000
3132 \labelwidthstring 00.00.0000
3154
3133
3155
3134
3156 \family typewriter
3135 \family typewriter
3157 \SpecialChar ~
3136 \SpecialChar ~
3158
3137
3159 \family default
3138 \family default
3160 3.
3139 3.
3161
3140
3162 \family typewriter
3141 \family typewriter
3163 $HOME/.ipython/ipythonrc-numeric
3142 $HOME/.ipython/ipythonrc-numeric
3164 \family default
3143 \family default
3165 : load (1) and Numeric and plotting modules.
3144 : load (1) and Numeric and plotting modules.
3166 \layout List
3145 \layout List
3167 \labelwidthstring 00.00.0000
3146 \labelwidthstring 00.00.0000
3168
3147
3169 \SpecialChar ~
3148 \SpecialChar ~
3170 Since it is possible to create an endless loop by having circular file
3149 Since it is possible to create an endless loop by having circular file
3171 inclusions, IPython will stop if it reaches 15 recursive inclusions.
3150 inclusions, IPython will stop if it reaches 15 recursive inclusions.
3172 \layout List
3151 \layout List
3173 \labelwidthstring 00.00.0000
3152 \labelwidthstring 00.00.0000
3174
3153
3175
3154
3176 \family typewriter
3155 \family typewriter
3177 \series bold
3156 \series bold
3178 -prompt_in1|pi1\SpecialChar ~
3157 -prompt_in1|pi1\SpecialChar ~
3179 <string>:
3158 <string>:
3180 \family default
3159 \family default
3181 \series default
3160 \series default
3182 Specify the string used for input prompts.
3161 Specify the string used for input prompts.
3183 Note that if you are using numbered prompts, the number is represented
3162 Note that if you are using numbered prompts, the number is represented
3184 with a '
3163 with a '
3185 \backslash
3164 \backslash
3186 #' in the string.
3165 #' in the string.
3187 Don't forget to quote strings with spaces embedded in them.
3166 Don't forget to quote strings with spaces embedded in them.
3188 Default: '
3167 Default: '
3189 \family typewriter
3168 \family typewriter
3190 In\SpecialChar ~
3169 In\SpecialChar ~
3191 [
3170 [
3192 \backslash
3171 \backslash
3193 #]:
3172 #]:
3194 \family default
3173 \family default
3195 '.
3174 '.
3196 Sec.\SpecialChar ~
3175 Sec.\SpecialChar ~
3197
3176
3198 \begin_inset LatexCommand \ref{sec:prompts}
3177 \begin_inset LatexCommand \ref{sec:prompts}
3199
3178
3200 \end_inset
3179 \end_inset
3201
3180
3202 discusses in detail all the available escapes to customize your prompts.
3181 discusses in detail all the available escapes to customize your prompts.
3203 \layout List
3182 \layout List
3204 \labelwidthstring 00.00.0000
3183 \labelwidthstring 00.00.0000
3205
3184
3206
3185
3207 \family typewriter
3186 \family typewriter
3208 \series bold
3187 \series bold
3209 -prompt_in2|pi2\SpecialChar ~
3188 -prompt_in2|pi2\SpecialChar ~
3210 <string>:
3189 <string>:
3211 \family default
3190 \family default
3212 \series default
3191 \series default
3213 Similar to the previous option, but used for the continuation prompts.
3192 Similar to the previous option, but used for the continuation prompts.
3214 The special sequence '
3193 The special sequence '
3215 \family typewriter
3194 \family typewriter
3216
3195
3217 \backslash
3196 \backslash
3218 D
3197 D
3219 \family default
3198 \family default
3220 ' is similar to '
3199 ' is similar to '
3221 \family typewriter
3200 \family typewriter
3222
3201
3223 \backslash
3202 \backslash
3224 #
3203 #
3225 \family default
3204 \family default
3226 ', but with all digits replaced dots (so you can have your continuation
3205 ', but with all digits replaced dots (so you can have your continuation
3227 prompt aligned with your input prompt).
3206 prompt aligned with your input prompt).
3228 Default: '
3207 Default: '
3229 \family typewriter
3208 \family typewriter
3230 \SpecialChar ~
3209 \SpecialChar ~
3231 \SpecialChar ~
3210 \SpecialChar ~
3232 \SpecialChar ~
3211 \SpecialChar ~
3233 .
3212 .
3234 \backslash
3213 \backslash
3235 D.:
3214 D.:
3236 \family default
3215 \family default
3237 ' (note three spaces at the start for alignment with '
3216 ' (note three spaces at the start for alignment with '
3238 \family typewriter
3217 \family typewriter
3239 In\SpecialChar ~
3218 In\SpecialChar ~
3240 [
3219 [
3241 \backslash
3220 \backslash
3242 #]
3221 #]
3243 \family default
3222 \family default
3244 ').
3223 ').
3245 \layout List
3224 \layout List
3246 \labelwidthstring 00.00.0000
3225 \labelwidthstring 00.00.0000
3247
3226
3248
3227
3249 \family typewriter
3228 \family typewriter
3250 \series bold
3229 \series bold
3251 -prompt_out|po\SpecialChar ~
3230 -prompt_out|po\SpecialChar ~
3252 <string>:
3231 <string>:
3253 \family default
3232 \family default
3254 \series default
3233 \series default
3255 String used for output prompts, also uses numbers like
3234 String used for output prompts, also uses numbers like
3256 \family typewriter
3235 \family typewriter
3257 prompt_in1
3236 prompt_in1
3258 \family default
3237 \family default
3259 .
3238 .
3260 Default: '
3239 Default: '
3261 \family typewriter
3240 \family typewriter
3262 Out[
3241 Out[
3263 \backslash
3242 \backslash
3264 #]:
3243 #]:
3265 \family default
3244 \family default
3266 '
3245 '
3267 \layout List
3246 \layout List
3268 \labelwidthstring 00.00.0000
3247 \labelwidthstring 00.00.0000
3269
3248
3270
3249
3271 \family typewriter
3250 \family typewriter
3272 \series bold
3251 \series bold
3273 -quick
3252 -quick
3274 \family default
3253 \family default
3275 \series default
3254 \series default
3276 : start in bare bones mode (no config file loaded).
3255 : start in bare bones mode (no config file loaded).
3277 \layout List
3256 \layout List
3278 \labelwidthstring 00.00.0000
3257 \labelwidthstring 00.00.0000
3279
3258
3280
3259
3281 \family typewriter
3260 \family typewriter
3282 \series bold
3261 \series bold
3283 -rcfile\SpecialChar ~
3262 -rcfile\SpecialChar ~
3284 <name>
3263 <name>
3285 \series default
3264 \series default
3286 :
3265 :
3287 \family default
3266 \family default
3288 name of your IPython resource configuration file.
3267 name of your IPython resource configuration file.
3289 Normally IPython loads ipythonrc (from current directory) or
3268 Normally IPython loads ipythonrc (from current directory) or
3290 \family typewriter
3269 \family typewriter
3291 IPYTHONDIR/ipythonrc
3270 IPYTHONDIR/ipythonrc
3292 \family default
3271 \family default
3293 .
3272 .
3294 \layout List
3273 \layout List
3295 \labelwidthstring 00.00.0000
3274 \labelwidthstring 00.00.0000
3296
3275
3297 \SpecialChar ~
3276 \SpecialChar ~
3298 If the loading of your config file fails, IPython starts with a bare bones
3277 If the loading of your config file fails, IPython starts with a bare bones
3299 configuration (no modules loaded at all).
3278 configuration (no modules loaded at all).
3300 \layout List
3279 \layout List
3301 \labelwidthstring 00.00.0000
3280 \labelwidthstring 00.00.0000
3302
3281
3303
3282
3304 \family typewriter
3283 \family typewriter
3305 \series bold
3284 \series bold
3306 -[no]readline
3285 -[no]readline
3307 \family default
3286 \family default
3308 \series default
3287 \series default
3309 : use the readline library, which is needed to support name completion and
3288 : use the readline library, which is needed to support name completion and
3310 command history, among other things.
3289 command history, among other things.
3311 It is enabled by default, but may cause problems for users of X/Emacs in
3290 It is enabled by default, but may cause problems for users of X/Emacs in
3312 Python comint or shell buffers.
3291 Python comint or shell buffers.
3313 \layout List
3292 \layout List
3314 \labelwidthstring 00.00.0000
3293 \labelwidthstring 00.00.0000
3315
3294
3316 \SpecialChar ~
3295 \SpecialChar ~
3317 Note that X/Emacs 'eterm' buffers (opened with
3296 Note that X/Emacs 'eterm' buffers (opened with
3318 \family typewriter
3297 \family typewriter
3319 M-x\SpecialChar ~
3298 M-x\SpecialChar ~
3320 term
3299 term
3321 \family default
3300 \family default
3322 ) support IPython's readline and syntax coloring fine, only 'emacs' (
3301 ) support IPython's readline and syntax coloring fine, only 'emacs' (
3323 \family typewriter
3302 \family typewriter
3324 M-x\SpecialChar ~
3303 M-x\SpecialChar ~
3325 shell
3304 shell
3326 \family default
3305 \family default
3327 and
3306 and
3328 \family typewriter
3307 \family typewriter
3329 C-c\SpecialChar ~
3308 C-c\SpecialChar ~
3330 !
3309 !
3331 \family default
3310 \family default
3332 ) buffers do not.
3311 ) buffers do not.
3333 \layout List
3312 \layout List
3334 \labelwidthstring 00.00.0000
3313 \labelwidthstring 00.00.0000
3335
3314
3336
3315
3337 \family typewriter
3316 \family typewriter
3338 \series bold
3317 \series bold
3339 -screen_length|sl\SpecialChar ~
3318 -screen_length|sl\SpecialChar ~
3340 <n>
3319 <n>
3341 \series default
3320 \series default
3342 :
3321 :
3343 \family default
3322 \family default
3344 number of lines of your screen.
3323 number of lines of your screen.
3345 This is used to control printing of very long strings.
3324 This is used to control printing of very long strings.
3346 Strings longer than this number of lines will be sent through a pager instead
3325 Strings longer than this number of lines will be sent through a pager instead
3347 of directly printed.
3326 of directly printed.
3348 \layout List
3327 \layout List
3349 \labelwidthstring 00.00.0000
3328 \labelwidthstring 00.00.0000
3350
3329
3351 \SpecialChar ~
3330 \SpecialChar ~
3352 The default value for this is 0, which means IPython will auto-detect your
3331 The default value for this is 0, which means IPython will auto-detect your
3353 screen size every time it needs to print certain potentially long strings
3332 screen size every time it needs to print certain potentially long strings
3354 (this doesn't change the behavior of the 'print' keyword, it's only triggered
3333 (this doesn't change the behavior of the 'print' keyword, it's only triggered
3355 internally).
3334 internally).
3356 If for some reason this isn't working well (it needs curses support), specify
3335 If for some reason this isn't working well (it needs curses support), specify
3357 it yourself.
3336 it yourself.
3358 Otherwise don't change the default.
3337 Otherwise don't change the default.
3359 \layout List
3338 \layout List
3360 \labelwidthstring 00.00.0000
3339 \labelwidthstring 00.00.0000
3361
3340
3362
3341
3363 \family typewriter
3342 \family typewriter
3364 \series bold
3343 \series bold
3365 -separate_in|si\SpecialChar ~
3344 -separate_in|si\SpecialChar ~
3366 <string>
3345 <string>
3367 \series default
3346 \series default
3368 :
3347 :
3369 \family default
3348 \family default
3370 separator before input prompts.
3349 separator before input prompts.
3371 Default: '
3350 Default: '
3372 \family typewriter
3351 \family typewriter
3373
3352
3374 \backslash
3353 \backslash
3375 n
3354 n
3376 \family default
3355 \family default
3377 '
3356 '
3378 \layout List
3357 \layout List
3379 \labelwidthstring 00.00.0000
3358 \labelwidthstring 00.00.0000
3380
3359
3381
3360
3382 \family typewriter
3361 \family typewriter
3383 \series bold
3362 \series bold
3384 -separate_out|so\SpecialChar ~
3363 -separate_out|so\SpecialChar ~
3385 <string>
3364 <string>
3386 \family default
3365 \family default
3387 \series default
3366 \series default
3388 : separator before output prompts.
3367 : separator before output prompts.
3389 Default: nothing.
3368 Default: nothing.
3390 \layout List
3369 \layout List
3391 \labelwidthstring 00.00.0000
3370 \labelwidthstring 00.00.0000
3392
3371
3393
3372
3394 \family typewriter
3373 \family typewriter
3395 \series bold
3374 \series bold
3396 -separate_out2|so2\SpecialChar ~
3375 -separate_out2|so2\SpecialChar ~
3397 <string>
3376 <string>
3398 \series default
3377 \series default
3399 :
3378 :
3400 \family default
3379 \family default
3401 separator after output prompts.
3380 separator after output prompts.
3402 Default: nothing.
3381 Default: nothing.
3403 \layout List
3382 \layout List
3404 \labelwidthstring 00.00.0000
3383 \labelwidthstring 00.00.0000
3405
3384
3406 \SpecialChar ~
3385 \SpecialChar ~
3407 For these three options, use the value 0 to specify no separator.
3386 For these three options, use the value 0 to specify no separator.
3408 \layout List
3387 \layout List
3409 \labelwidthstring 00.00.0000
3388 \labelwidthstring 00.00.0000
3410
3389
3411
3390
3412 \family typewriter
3391 \family typewriter
3413 \series bold
3392 \series bold
3414 -nosep
3393 -nosep
3415 \series default
3394 \series default
3416 :
3395 :
3417 \family default
3396 \family default
3418 shorthand for
3397 shorthand for
3419 \family typewriter
3398 \family typewriter
3420 '-SeparateIn 0 -SeparateOut 0 -SeparateOut2 0'
3399 '-SeparateIn 0 -SeparateOut 0 -SeparateOut2 0'
3421 \family default
3400 \family default
3422 .
3401 .
3423 Simply removes all input/output separators.
3402 Simply removes all input/output separators.
3424 \layout List
3403 \layout List
3425 \labelwidthstring 00.00.0000
3404 \labelwidthstring 00.00.0000
3426
3405
3427
3406
3428 \family typewriter
3407 \family typewriter
3429 \series bold
3408 \series bold
3430 -upgrade
3409 -upgrade
3431 \family default
3410 \family default
3432 \series default
3411 \series default
3433 : allows you to upgrade your
3412 : allows you to upgrade your
3434 \family typewriter
3413 \family typewriter
3435 IPYTHONDIR
3414 IPYTHONDIR
3436 \family default
3415 \family default
3437 configuration when you install a new version of IPython.
3416 configuration when you install a new version of IPython.
3438 Since new versions may include new command line options or example files,
3417 Since new versions may include new command line options or example files,
3439 this copies updated ipythonrc-type files.
3418 this copies updated ipythonrc-type files.
3440 However, it backs up (with a
3419 However, it backs up (with a
3441 \family typewriter
3420 \family typewriter
3442 .old
3421 .old
3443 \family default
3422 \family default
3444 extension) all files which it overwrites so that you can merge back any
3423 extension) all files which it overwrites so that you can merge back any
3445 customizations you might have in your personal files.
3424 customizations you might have in your personal files.
3446 \layout List
3425 \layout List
3447 \labelwidthstring 00.00.0000
3426 \labelwidthstring 00.00.0000
3448
3427
3449
3428
3450 \family typewriter
3429 \family typewriter
3451 \series bold
3430 \series bold
3452 -Version
3431 -Version
3453 \series default
3432 \series default
3454 :
3433 :
3455 \family default
3434 \family default
3456 print version information and exit.
3435 print version information and exit.
3457 \layout List
3436 \layout List
3458 \labelwidthstring 00.00.0000
3437 \labelwidthstring 00.00.0000
3459
3438
3460
3439
3461 \family typewriter
3440 \family typewriter
3462 \series bold
3441 \series bold
3463 -xmode <modename>
3442 -xmode <modename>
3464 \series default
3443 \series default
3465 :
3444 :
3466 \family default
3445 \family default
3467 Mode for exception reporting.
3446 Mode for exception reporting.
3468 \layout List
3447 \layout List
3469 \labelwidthstring 00.00.0000
3448 \labelwidthstring 00.00.0000
3470
3449
3471 \SpecialChar ~
3450 \SpecialChar ~
3472 Valid modes: Plain, Context and Verbose.
3451 Valid modes: Plain, Context and Verbose.
3473 \layout List
3452 \layout List
3474 \labelwidthstring 00.00.0000
3453 \labelwidthstring 00.00.0000
3475
3454
3476 \SpecialChar ~
3455 \SpecialChar ~
3477 Plain: similar to python's normal traceback printing.
3456 Plain: similar to python's normal traceback printing.
3478 \layout List
3457 \layout List
3479 \labelwidthstring 00.00.0000
3458 \labelwidthstring 00.00.0000
3480
3459
3481 \SpecialChar ~
3460 \SpecialChar ~
3482 Context: prints 5 lines of context source code around each line in the
3461 Context: prints 5 lines of context source code around each line in the
3483 traceback.
3462 traceback.
3484 \layout List
3463 \layout List
3485 \labelwidthstring 00.00.0000
3464 \labelwidthstring 00.00.0000
3486
3465
3487 \SpecialChar ~
3466 \SpecialChar ~
3488 Verbose: similar to Context, but additionally prints the variables currently
3467 Verbose: similar to Context, but additionally prints the variables currently
3489 visible where the exception happened (shortening their strings if too long).
3468 visible where the exception happened (shortening their strings if too long).
3490 This can potentially be very slow, if you happen to have a huge data structure
3469 This can potentially be very slow, if you happen to have a huge data structure
3491 whose string representation is complex to compute.
3470 whose string representation is complex to compute.
3492 Your computer may appear to freeze for a while with cpu usage at 100%.
3471 Your computer may appear to freeze for a while with cpu usage at 100%.
3493 If this occurs, you can cancel the traceback with Ctrl-C (maybe hitting
3472 If this occurs, you can cancel the traceback with Ctrl-C (maybe hitting
3494 it more than once).
3473 it more than once).
3495 \layout Section
3474 \layout Section
3496
3475
3497 Interactive use
3476 Interactive use
3498 \layout Standard
3477 \layout Standard
3499
3478
3500
3479
3501 \series bold
3480 \series bold
3502 Warning
3481 Warning
3503 \series default
3482 \series default
3504 : IPython relies on the existence of a global variable called
3483 : IPython relies on the existence of a global variable called
3505 \family typewriter
3484 \family typewriter
3506 __IP
3485 __IP
3507 \family default
3486 \family default
3508 which controls the shell itself.
3487 which controls the shell itself.
3509 If you redefine
3488 If you redefine
3510 \family typewriter
3489 \family typewriter
3511 __IP
3490 __IP
3512 \family default
3491 \family default
3513 to anything, bizarre behavior will quickly occur.
3492 to anything, bizarre behavior will quickly occur.
3514 \layout Standard
3493 \layout Standard
3515
3494
3516 Other than the above warning, IPython is meant to work as a drop-in replacement
3495 Other than the above warning, IPython is meant to work as a drop-in replacement
3517 for the standard interactive interpreter.
3496 for the standard interactive interpreter.
3518 As such, any code which is valid python should execute normally under IPython
3497 As such, any code which is valid python should execute normally under IPython
3519 (cases where this is not true should be reported as bugs).
3498 (cases where this is not true should be reported as bugs).
3520 It does, however, offer many features which are not available at a standard
3499 It does, however, offer many features which are not available at a standard
3521 python prompt.
3500 python prompt.
3522 What follows is a list of these.
3501 What follows is a list of these.
3523 \layout Subsection
3502 \layout Subsection
3524
3503
3525 Caution for Windows users
3504 Caution for Windows users
3526 \layout Standard
3505 \layout Standard
3527
3506
3528 Windows, unfortunately, uses the `
3507 Windows, unfortunately, uses the `
3529 \family typewriter
3508 \family typewriter
3530
3509
3531 \backslash
3510 \backslash
3532
3511
3533 \family default
3512 \family default
3534 ' character as a path separator.
3513 ' character as a path separator.
3535 This is a terrible choice, because `
3514 This is a terrible choice, because `
3536 \family typewriter
3515 \family typewriter
3537
3516
3538 \backslash
3517 \backslash
3539
3518
3540 \family default
3519 \family default
3541 ' also represents the escape character in most modern programming languages,
3520 ' also represents the escape character in most modern programming languages,
3542 including Python.
3521 including Python.
3543 For this reason, issuing many of the commands discussed below (especially
3522 For this reason, issuing many of the commands discussed below (especially
3544 magics which affect the filesystem) with `
3523 magics which affect the filesystem) with `
3545 \family typewriter
3524 \family typewriter
3546
3525
3547 \backslash
3526 \backslash
3548
3527
3549 \family default
3528 \family default
3550 ' in them will cause strange errors.
3529 ' in them will cause strange errors.
3551 \layout Standard
3530 \layout Standard
3552
3531
3553 A partial solution is to use instead the `
3532 A partial solution is to use instead the `
3554 \family typewriter
3533 \family typewriter
3555 /
3534 /
3556 \family default
3535 \family default
3557 ' character as a path separator, which Windows recognizes in
3536 ' character as a path separator, which Windows recognizes in
3558 \emph on
3537 \emph on
3559 most
3538 most
3560 \emph default
3539 \emph default
3561 situations.
3540 situations.
3562 However, in Windows commands `
3541 However, in Windows commands `
3563 \family typewriter
3542 \family typewriter
3564 /
3543 /
3565 \family default
3544 \family default
3566 ' flags options, so you can not use it for the root directory.
3545 ' flags options, so you can not use it for the root directory.
3567 This means that paths beginning at the root must be typed in a contrived
3546 This means that paths beginning at the root must be typed in a contrived
3568 manner like:
3547 manner like:
3569 \newline
3548 \newline
3570
3549
3571 \family typewriter
3550 \family typewriter
3572 %copy
3551 %copy
3573 \backslash
3552 \backslash
3574 opt/foo/bar.txt
3553 opt/foo/bar.txt
3575 \backslash
3554 \backslash
3576 tmp
3555 tmp
3577 \layout Standard
3556 \layout Standard
3578
3557
3579 There is no sensible thing IPython can do to truly work around this flaw
3558 There is no sensible thing IPython can do to truly work around this flaw
3580 in Windows
3559 in Windows
3581 \begin_inset Foot
3560 \begin_inset Foot
3582 collapsed true
3561 collapsed true
3583
3562
3584 \layout Standard
3563 \layout Standard
3585
3564
3586 If anyone comes up with a
3565 If anyone comes up with a
3587 \emph on
3566 \emph on
3588 clean
3567 clean
3589 \emph default
3568 \emph default
3590 solution which works consistently and does not negatively impact other
3569 solution which works consistently and does not negatively impact other
3591 platforms at all, I'll gladly accept a patch.
3570 platforms at all, I'll gladly accept a patch.
3592 \end_inset
3571 \end_inset
3593
3572
3594 .
3573 .
3595 \layout Subsection
3574 \layout Subsection
3596
3575
3597
3576
3598 \begin_inset LatexCommand \label{sec:magic}
3577 \begin_inset LatexCommand \label{sec:magic}
3599
3578
3600 \end_inset
3579 \end_inset
3601
3580
3602 Magic command system
3581 Magic command system
3603 \layout Standard
3582 \layout Standard
3604
3583
3605 IPython will treat any line whose first character is a
3584 IPython will treat any line whose first character is a
3606 \family typewriter
3585 \family typewriter
3607 %
3586 %
3608 \family default
3587 \family default
3609 as a special call to a 'magic' function.
3588 as a special call to a 'magic' function.
3610 These allow you to control the behavior of IPython itself, plus a lot of
3589 These allow you to control the behavior of IPython itself, plus a lot of
3611 system-type features.
3590 system-type features.
3612 They are all prefixed with a
3591 They are all prefixed with a
3613 \family typewriter
3592 \family typewriter
3614 %
3593 %
3615 \family default
3594 \family default
3616 character, but parameters are given without parentheses or quotes.
3595 character, but parameters are given without parentheses or quotes.
3617 \layout Standard
3596 \layout Standard
3618
3597
3619 Example: typing
3598 Example: typing
3620 \family typewriter
3599 \family typewriter
3621 '%cd mydir'
3600 '%cd mydir'
3622 \family default
3601 \family default
3623 (without the quotes) changes you working directory to
3602 (without the quotes) changes you working directory to
3624 \family typewriter
3603 \family typewriter
3625 'mydir'
3604 'mydir'
3626 \family default
3605 \family default
3627 , if it exists.
3606 , if it exists.
3628 \layout Standard
3607 \layout Standard
3629
3608
3630 If you have 'automagic' enabled (in your
3609 If you have 'automagic' enabled (in your
3631 \family typewriter
3610 \family typewriter
3632 ipythonrc
3611 ipythonrc
3633 \family default
3612 \family default
3634 file, via the command line option
3613 file, via the command line option
3635 \family typewriter
3614 \family typewriter
3636 -automagic
3615 -automagic
3637 \family default
3616 \family default
3638 or with the
3617 or with the
3639 \family typewriter
3618 \family typewriter
3640 %automagic
3619 %automagic
3641 \family default
3620 \family default
3642 function), you don't need to type in the
3621 function), you don't need to type in the
3643 \family typewriter
3622 \family typewriter
3644 %
3623 %
3645 \family default
3624 \family default
3646 explicitly.
3625 explicitly.
3647 IPython will scan its internal list of magic functions and call one if
3626 IPython will scan its internal list of magic functions and call one if
3648 it exists.
3627 it exists.
3649 With automagic on you can then just type '
3628 With automagic on you can then just type '
3650 \family typewriter
3629 \family typewriter
3651 cd mydir
3630 cd mydir
3652 \family default
3631 \family default
3653 ' to go to directory '
3632 ' to go to directory '
3654 \family typewriter
3633 \family typewriter
3655 mydir
3634 mydir
3656 \family default
3635 \family default
3657 '.
3636 '.
3658 The automagic system has the lowest possible precedence in name searches,
3637 The automagic system has the lowest possible precedence in name searches,
3659 so defining an identifier with the same name as an existing magic function
3638 so defining an identifier with the same name as an existing magic function
3660 will shadow it for automagic use.
3639 will shadow it for automagic use.
3661 You can still access the shadowed magic function by explicitly using the
3640 You can still access the shadowed magic function by explicitly using the
3662
3641
3663 \family typewriter
3642 \family typewriter
3664 %
3643 %
3665 \family default
3644 \family default
3666 character at the beginning of the line.
3645 character at the beginning of the line.
3667 \layout Standard
3646 \layout Standard
3668
3647
3669 An example (with automagic on) should clarify all this:
3648 An example (with automagic on) should clarify all this:
3670 \layout LyX-Code
3649 \layout LyX-Code
3671
3650
3672 In [1]: cd ipython # %cd is called by automagic
3651 In [1]: cd ipython # %cd is called by automagic
3673 \layout LyX-Code
3652 \layout LyX-Code
3674
3653
3675 /home/fperez/ipython
3654 /home/fperez/ipython
3676 \layout LyX-Code
3655 \layout LyX-Code
3677
3656
3678 In [2]: cd=1 # now cd is just a variable
3657 In [2]: cd=1 # now cd is just a variable
3679 \layout LyX-Code
3658 \layout LyX-Code
3680
3659
3681 In [3]: cd ..
3660 In [3]: cd ..
3682 # and doesn't work as a function anymore
3661 # and doesn't work as a function anymore
3683 \layout LyX-Code
3662 \layout LyX-Code
3684
3663
3685 ------------------------------------------------------------
3664 ------------------------------------------------------------
3686 \layout LyX-Code
3665 \layout LyX-Code
3687
3666
3688 File "<console>", line 1
3667 File "<console>", line 1
3689 \layout LyX-Code
3668 \layout LyX-Code
3690
3669
3691 cd ..
3670 cd ..
3692 \layout LyX-Code
3671 \layout LyX-Code
3693
3672
3694 ^
3673 ^
3695 \layout LyX-Code
3674 \layout LyX-Code
3696
3675
3697 SyntaxError: invalid syntax
3676 SyntaxError: invalid syntax
3698 \layout LyX-Code
3677 \layout LyX-Code
3699
3678
3700 \layout LyX-Code
3679 \layout LyX-Code
3701
3680
3702 In [4]: %cd ..
3681 In [4]: %cd ..
3703 # but %cd always works
3682 # but %cd always works
3704 \layout LyX-Code
3683 \layout LyX-Code
3705
3684
3706 /home/fperez
3685 /home/fperez
3707 \layout LyX-Code
3686 \layout LyX-Code
3708
3687
3709 In [5]: del cd # if you remove the cd variable
3688 In [5]: del cd # if you remove the cd variable
3710 \layout LyX-Code
3689 \layout LyX-Code
3711
3690
3712 In [6]: cd ipython # automagic can work again
3691 In [6]: cd ipython # automagic can work again
3713 \layout LyX-Code
3692 \layout LyX-Code
3714
3693
3715 /home/fperez/ipython
3694 /home/fperez/ipython
3716 \layout Standard
3695 \layout Standard
3717
3696
3718 You can define your own magic functions to extend the system.
3697 You can define your own magic functions to extend the system.
3719 The following is a snippet of code which shows how to do it.
3698 The following is a snippet of code which shows how to do it.
3720 It is provided as file
3699 It is provided as file
3721 \family typewriter
3700 \family typewriter
3722 example-magic.py
3701 example-magic.py
3723 \family default
3702 \family default
3724 in the examples directory:
3703 in the examples directory:
3725 \layout Standard
3704 \layout Standard
3726
3705
3727
3706
3728 \begin_inset ERT
3707 \begin_inset ERT
3729 status Open
3708 status Open
3730
3709
3731 \layout Standard
3710 \layout Standard
3732
3711
3733 \backslash
3712 \backslash
3734 codelist{examples/example-magic.py}
3713 codelist{examples/example-magic.py}
3735 \end_inset
3714 \end_inset
3736
3715
3737
3716
3738 \layout Standard
3717 \layout Standard
3739
3718
3740 You can also define your own aliased names for magic functions.
3719 You can also define your own aliased names for magic functions.
3741 In your
3720 In your
3742 \family typewriter
3721 \family typewriter
3743 ipythonrc
3722 ipythonrc
3744 \family default
3723 \family default
3745 file, placing a line like:
3724 file, placing a line like:
3746 \layout Standard
3725 \layout Standard
3747
3726
3748
3727
3749 \family typewriter
3728 \family typewriter
3750 execute __IP.magic_cl = __IP.magic_clear
3729 execute __IP.magic_cl = __IP.magic_clear
3751 \layout Standard
3730 \layout Standard
3752
3731
3753 will define
3732 will define
3754 \family typewriter
3733 \family typewriter
3755 %cl
3734 %cl
3756 \family default
3735 \family default
3757 as a new name for
3736 as a new name for
3758 \family typewriter
3737 \family typewriter
3759 %clear
3738 %clear
3760 \family default
3739 \family default
3761 .
3740 .
3762 \layout Standard
3741 \layout Standard
3763
3742
3764 Type
3743 Type
3765 \family typewriter
3744 \family typewriter
3766 %magic
3745 %magic
3767 \family default
3746 \family default
3768 for more information, including a list of all available magic functions
3747 for more information, including a list of all available magic functions
3769 at any time and their docstrings.
3748 at any time and their docstrings.
3770 You can also type
3749 You can also type
3771 \family typewriter
3750 \family typewriter
3772 %magic_function_name?
3751 %magic_function_name?
3773 \family default
3752 \family default
3774 (see sec.
3753 (see sec.
3775
3754
3776 \begin_inset LatexCommand \ref{sec:dyn-object-info}
3755 \begin_inset LatexCommand \ref{sec:dyn-object-info}
3777
3756
3778 \end_inset
3757 \end_inset
3779
3758
3780 for information on the
3759 for information on the
3781 \family typewriter
3760 \family typewriter
3782 '?'
3761 '?'
3783 \family default
3762 \family default
3784 system) to get information about any particular magic function you are
3763 system) to get information about any particular magic function you are
3785 interested in.
3764 interested in.
3786 \layout Subsubsection
3765 \layout Subsubsection
3787
3766
3788 Magic commands
3767 Magic commands
3789 \layout Standard
3768 \layout Standard
3790
3769
3791 The rest of this section is automatically generated for each release from
3770 The rest of this section is automatically generated for each release from
3792 the docstrings in the IPython code.
3771 the docstrings in the IPython code.
3793 Therefore the formatting is somewhat minimal, but this method has the advantage
3772 Therefore the formatting is somewhat minimal, but this method has the advantage
3794 of having information always in sync with the code.
3773 of having information always in sync with the code.
3795 \layout Standard
3774 \layout Standard
3796
3775
3797 A list of all the magic commands available in IPython's
3776 A list of all the magic commands available in IPython's
3798 \emph on
3777 \emph on
3799 default
3778 default
3800 \emph default
3779 \emph default
3801 installation follows.
3780 installation follows.
3802 This is similar to what you'll see by simply typing
3781 This is similar to what you'll see by simply typing
3803 \family typewriter
3782 \family typewriter
3804 %magic
3783 %magic
3805 \family default
3784 \family default
3806 at the prompt, but that will also give you information about magic commands
3785 at the prompt, but that will also give you information about magic commands
3807 you may have added as part of your personal customizations.
3786 you may have added as part of your personal customizations.
3808 \layout Standard
3787 \layout Standard
3809
3788
3810
3789
3811 \begin_inset Include \input{magic.tex}
3790 \begin_inset Include \input{magic.tex}
3812 preview false
3791 preview false
3813
3792
3814 \end_inset
3793 \end_inset
3815
3794
3816
3795
3817 \layout Subsection
3796 \layout Subsection
3818
3797
3819 Access to the standard Python help
3798 Access to the standard Python help
3820 \layout Standard
3799 \layout Standard
3821
3800
3822 As of Python 2.1, a help system is available with access to object docstrings
3801 As of Python 2.1, a help system is available with access to object docstrings
3823 and the Python manuals.
3802 and the Python manuals.
3824 Simply type
3803 Simply type
3825 \family typewriter
3804 \family typewriter
3826 'help'
3805 'help'
3827 \family default
3806 \family default
3828 (no quotes) to access it.
3807 (no quotes) to access it.
3829 You can also type
3808 You can also type
3830 \family typewriter
3809 \family typewriter
3831 help(object)
3810 help(object)
3832 \family default
3811 \family default
3833 to obtain information about a given object, and
3812 to obtain information about a given object, and
3834 \family typewriter
3813 \family typewriter
3835 help('keyword')
3814 help('keyword')
3836 \family default
3815 \family default
3837 for information on a keyword.
3816 for information on a keyword.
3838 As noted in sec.
3817 As noted in sec.
3839
3818
3840 \begin_inset LatexCommand \ref{sec:help-access}
3819 \begin_inset LatexCommand \ref{sec:help-access}
3841
3820
3842 \end_inset
3821 \end_inset
3843
3822
3844 , you need to properly configure your environment variable
3823 , you need to properly configure your environment variable
3845 \family typewriter
3824 \family typewriter
3846 PYTHONDOCS
3825 PYTHONDOCS
3847 \family default
3826 \family default
3848 for this feature to work correctly.
3827 for this feature to work correctly.
3849 \layout Subsection
3828 \layout Subsection
3850
3829
3851
3830
3852 \begin_inset LatexCommand \label{sec:dyn-object-info}
3831 \begin_inset LatexCommand \label{sec:dyn-object-info}
3853
3832
3854 \end_inset
3833 \end_inset
3855
3834
3856 Dynamic object information
3835 Dynamic object information
3857 \layout Standard
3836 \layout Standard
3858
3837
3859 Typing
3838 Typing
3860 \family typewriter
3839 \family typewriter
3861 ?word
3840 ?word
3862 \family default
3841 \family default
3863 or
3842 or
3864 \family typewriter
3843 \family typewriter
3865 word?
3844 word?
3866 \family default
3845 \family default
3867 prints detailed information about an object.
3846 prints detailed information about an object.
3868 If certain strings in the object are too long (docstrings, code, etc.) they
3847 If certain strings in the object are too long (docstrings, code, etc.) they
3869 get snipped in the center for brevity.
3848 get snipped in the center for brevity.
3870 This system gives access variable types and values, full source code for
3849 This system gives access variable types and values, full source code for
3871 any object (if available), function prototypes and other useful information.
3850 any object (if available), function prototypes and other useful information.
3872 \layout Standard
3851 \layout Standard
3873
3852
3874 Typing
3853 Typing
3875 \family typewriter
3854 \family typewriter
3876 ??word
3855 ??word
3877 \family default
3856 \family default
3878 or
3857 or
3879 \family typewriter
3858 \family typewriter
3880 word??
3859 word??
3881 \family default
3860 \family default
3882 gives access to the full information without snipping long strings.
3861 gives access to the full information without snipping long strings.
3883 Long strings are sent to the screen through the
3862 Long strings are sent to the screen through the
3884 \family typewriter
3863 \family typewriter
3885 less
3864 less
3886 \family default
3865 \family default
3887 pager if longer than the screen and printed otherwise.
3866 pager if longer than the screen and printed otherwise.
3888 On systems lacking the
3867 On systems lacking the
3889 \family typewriter
3868 \family typewriter
3890 less
3869 less
3891 \family default
3870 \family default
3892 command, IPython uses a very basic internal pager.
3871 command, IPython uses a very basic internal pager.
3893 \layout Standard
3872 \layout Standard
3894
3873
3895 The following magic functions are particularly useful for gathering information
3874 The following magic functions are particularly useful for gathering information
3896 about your working environment.
3875 about your working environment.
3897 You can get more details by typing
3876 You can get more details by typing
3898 \family typewriter
3877 \family typewriter
3899 %magic
3878 %magic
3900 \family default
3879 \family default
3901 or querying them individually (use
3880 or querying them individually (use
3902 \family typewriter
3881 \family typewriter
3903 %function_name?
3882 %function_name?
3904 \family default
3883 \family default
3905 with or without the
3884 with or without the
3906 \family typewriter
3885 \family typewriter
3907 %
3886 %
3908 \family default
3887 \family default
3909 ), this is just a summary:
3888 ), this is just a summary:
3910 \layout List
3889 \layout List
3911 \labelwidthstring 00.00.0000
3890 \labelwidthstring 00.00.0000
3912
3891
3913
3892
3914 \family typewriter
3893 \family typewriter
3915 \series bold
3894 \series bold
3916 %pdoc\SpecialChar ~
3895 %pdoc\SpecialChar ~
3917 <object>
3896 <object>
3918 \family default
3897 \family default
3919 \series default
3898 \series default
3920 : Print (or run through a pager if too long) the docstring for an object.
3899 : Print (or run through a pager if too long) the docstring for an object.
3921 If the given object is a class, it will print both the class and the constructo
3900 If the given object is a class, it will print both the class and the constructo
3922 r docstrings.
3901 r docstrings.
3923 \layout List
3902 \layout List
3924 \labelwidthstring 00.00.0000
3903 \labelwidthstring 00.00.0000
3925
3904
3926
3905
3927 \family typewriter
3906 \family typewriter
3928 \series bold
3907 \series bold
3929 %pdef\SpecialChar ~
3908 %pdef\SpecialChar ~
3930 <object>
3909 <object>
3931 \family default
3910 \family default
3932 \series default
3911 \series default
3933 : Print the definition header for any callable object.
3912 : Print the definition header for any callable object.
3934 If the object is a class, print the constructor information.
3913 If the object is a class, print the constructor information.
3935 \layout List
3914 \layout List
3936 \labelwidthstring 00.00.0000
3915 \labelwidthstring 00.00.0000
3937
3916
3938
3917
3939 \family typewriter
3918 \family typewriter
3940 \series bold
3919 \series bold
3941 %psource\SpecialChar ~
3920 %psource\SpecialChar ~
3942 <object>
3921 <object>
3943 \family default
3922 \family default
3944 \series default
3923 \series default
3945 : Print (or run through a pager if too long) the source code for an object.
3924 : Print (or run through a pager if too long) the source code for an object.
3946 \layout List
3925 \layout List
3947 \labelwidthstring 00.00.0000
3926 \labelwidthstring 00.00.0000
3948
3927
3949
3928
3950 \family typewriter
3929 \family typewriter
3951 \series bold
3930 \series bold
3952 %pfile\SpecialChar ~
3931 %pfile\SpecialChar ~
3953 <object>
3932 <object>
3954 \family default
3933 \family default
3955 \series default
3934 \series default
3956 : Show the entire source file where an object was defined via a pager, opening
3935 : Show the entire source file where an object was defined via a pager, opening
3957 it at the line where the object definition begins.
3936 it at the line where the object definition begins.
3958 \layout List
3937 \layout List
3959 \labelwidthstring 00.00.0000
3938 \labelwidthstring 00.00.0000
3960
3939
3961
3940
3962 \family typewriter
3941 \family typewriter
3963 \series bold
3942 \series bold
3964 %who/%whos
3943 %who/%whos
3965 \family default
3944 \family default
3966 \series default
3945 \series default
3967 : These functions give information about identifiers you have defined interactiv
3946 : These functions give information about identifiers you have defined interactiv
3968 ely (not things you loaded or defined in your configuration files).
3947 ely (not things you loaded or defined in your configuration files).
3969
3948
3970 \family typewriter
3949 \family typewriter
3971 %who
3950 %who
3972 \family default
3951 \family default
3973 just prints a list of identifiers and
3952 just prints a list of identifiers and
3974 \family typewriter
3953 \family typewriter
3975 %whos
3954 %whos
3976 \family default
3955 \family default
3977 prints a table with some basic details about each identifier.
3956 prints a table with some basic details about each identifier.
3978 \layout Standard
3957 \layout Standard
3979
3958
3980 Note that the dynamic object information functions (
3959 Note that the dynamic object information functions (
3981 \family typewriter
3960 \family typewriter
3982 ?/??, %pdoc, %pfile, %pdef, %psource
3961 ?/??, %pdoc, %pfile, %pdef, %psource
3983 \family default
3962 \family default
3984 ) give you access to documentation even on things which are not really defined
3963 ) give you access to documentation even on things which are not really defined
3985 as separate identifiers.
3964 as separate identifiers.
3986 Try for example typing
3965 Try for example typing
3987 \family typewriter
3966 \family typewriter
3988 {}.get?
3967 {}.get?
3989 \family default
3968 \family default
3990 or after doing
3969 or after doing
3991 \family typewriter
3970 \family typewriter
3992 import os
3971 import os
3993 \family default
3972 \family default
3994 , type
3973 , type
3995 \family typewriter
3974 \family typewriter
3996 os.path.abspath??
3975 os.path.abspath??
3997 \family default
3976 \family default
3998 .
3977 .
3999 \layout Subsection
3978 \layout Subsection
4000
3979
4001
3980
4002 \begin_inset LatexCommand \label{sec:readline}
3981 \begin_inset LatexCommand \label{sec:readline}
4003
3982
4004 \end_inset
3983 \end_inset
4005
3984
4006 Readline-based features
3985 Readline-based features
4007 \layout Standard
3986 \layout Standard
4008
3987
4009 These features require the GNU readline library, so they won't work if your
3988 These features require the GNU readline library, so they won't work if your
4010 Python installation lacks readline support.
3989 Python installation lacks readline support.
4011 We will first describe the default behavior IPython uses, and then how
3990 We will first describe the default behavior IPython uses, and then how
4012 to change it to suit your preferences.
3991 to change it to suit your preferences.
4013 \layout Subsubsection
3992 \layout Subsubsection
4014
3993
4015 Command line completion
3994 Command line completion
4016 \layout Standard
3995 \layout Standard
4017
3996
4018 At any time, hitting TAB will complete any available python commands or
3997 At any time, hitting TAB will complete any available python commands or
4019 variable names, and show you a list of the possible completions if there's
3998 variable names, and show you a list of the possible completions if there's
4020 no unambiguous one.
3999 no unambiguous one.
4021 It will also complete filenames in the current directory if no python names
4000 It will also complete filenames in the current directory if no python names
4022 match what you've typed so far.
4001 match what you've typed so far.
4023 \layout Subsubsection
4002 \layout Subsubsection
4024
4003
4025 Search command history
4004 Search command history
4026 \layout Standard
4005 \layout Standard
4027
4006
4028 IPython provides two ways for searching through previous input and thus
4007 IPython provides two ways for searching through previous input and thus
4029 reduce the need for repetitive typing:
4008 reduce the need for repetitive typing:
4030 \layout Enumerate
4009 \layout Enumerate
4031
4010
4032 Start typing, and then use
4011 Start typing, and then use
4033 \family typewriter
4012 \family typewriter
4034 Ctrl-p
4013 Ctrl-p
4035 \family default
4014 \family default
4036 (previous,up) and
4015 (previous,up) and
4037 \family typewriter
4016 \family typewriter
4038 Ctrl-n
4017 Ctrl-n
4039 \family default
4018 \family default
4040 (next,down) to search through only the history items that match what you've
4019 (next,down) to search through only the history items that match what you've
4041 typed so far.
4020 typed so far.
4042 If you use
4021 If you use
4043 \family typewriter
4022 \family typewriter
4044 Ctrl-p/Ctrl-n
4023 Ctrl-p/Ctrl-n
4045 \family default
4024 \family default
4046 at a blank prompt, they just behave like normal arrow keys.
4025 at a blank prompt, they just behave like normal arrow keys.
4047 \layout Enumerate
4026 \layout Enumerate
4048
4027
4049 Hit
4028 Hit
4050 \family typewriter
4029 \family typewriter
4051 Ctrl-r
4030 Ctrl-r
4052 \family default
4031 \family default
4053 : opens a search prompt.
4032 : opens a search prompt.
4054 Begin typing and the system searches your history for lines that contain
4033 Begin typing and the system searches your history for lines that contain
4055 what you've typed so far, completing as much as it can.
4034 what you've typed so far, completing as much as it can.
4056 \layout Subsubsection
4035 \layout Subsubsection
4057
4036
4058 Persistent command history across sessions
4037 Persistent command history across sessions
4059 \layout Standard
4038 \layout Standard
4060
4039
4061 IPython will save your input history when it leaves and reload it next time
4040 IPython will save your input history when it leaves and reload it next time
4062 you restart it.
4041 you restart it.
4063 By default, the history file is named
4042 By default, the history file is named
4064 \family typewriter
4043 \family typewriter
4065 $IPYTHONDIR/history
4044 $IPYTHONDIR/history
4066 \family default
4045 \family default
4067 , but if you've loaded a named profile, '
4046 , but if you've loaded a named profile, '
4068 \family typewriter
4047 \family typewriter
4069 -PROFILE_NAME
4048 -PROFILE_NAME
4070 \family default
4049 \family default
4071 ' is appended to the name.
4050 ' is appended to the name.
4072 This allows you to keep separate histories related to various tasks: commands
4051 This allows you to keep separate histories related to various tasks: commands
4073 related to numerical work will not be clobbered by a system shell history,
4052 related to numerical work will not be clobbered by a system shell history,
4074 for example.
4053 for example.
4075 \layout Subsubsection
4054 \layout Subsubsection
4076
4055
4077 Autoindent
4056 Autoindent
4078 \layout Standard
4057 \layout Standard
4079
4058
4080 IPython can recognize lines ending in ':' and indent the next line, while
4059 IPython can recognize lines ending in ':' and indent the next line, while
4081 also un-indenting automatically after 'raise' or 'return'.
4060 also un-indenting automatically after 'raise' or 'return'.
4082
4061
4083 \layout Standard
4062 \layout Standard
4084
4063
4085 This feature uses the readline library, so it will honor your
4064 This feature uses the readline library, so it will honor your
4086 \family typewriter
4065 \family typewriter
4087 ~/.inputrc
4066 ~/.inputrc
4088 \family default
4067 \family default
4089 configuration (or whatever file your
4068 configuration (or whatever file your
4090 \family typewriter
4069 \family typewriter
4091 INPUTRC
4070 INPUTRC
4092 \family default
4071 \family default
4093 variable points to).
4072 variable points to).
4094 Adding the following lines to your
4073 Adding the following lines to your
4095 \family typewriter
4074 \family typewriter
4096 .inputrc
4075 .inputrc
4097 \family default
4076 \family default
4098 file can make indenting/unindenting more convenient (
4077 file can make indenting/unindenting more convenient (
4099 \family typewriter
4078 \family typewriter
4100 M-i
4079 M-i
4101 \family default
4080 \family default
4102 indents,
4081 indents,
4103 \family typewriter
4082 \family typewriter
4104 M-u
4083 M-u
4105 \family default
4084 \family default
4106 unindents):
4085 unindents):
4107 \layout Standard
4086 \layout Standard
4108
4087
4109
4088
4110 \family typewriter
4089 \family typewriter
4111 $if Python
4090 $if Python
4112 \newline
4091 \newline
4113 "
4092 "
4114 \backslash
4093 \backslash
4115 M-i": "\SpecialChar ~
4094 M-i": "\SpecialChar ~
4116 \SpecialChar ~
4095 \SpecialChar ~
4117 \SpecialChar ~
4096 \SpecialChar ~
4118 \SpecialChar ~
4097 \SpecialChar ~
4119 "
4098 "
4120 \newline
4099 \newline
4121 "
4100 "
4122 \backslash
4101 \backslash
4123 M-u": "
4102 M-u": "
4124 \backslash
4103 \backslash
4125 d
4104 d
4126 \backslash
4105 \backslash
4127 d
4106 d
4128 \backslash
4107 \backslash
4129 d
4108 d
4130 \backslash
4109 \backslash
4131 d"
4110 d"
4132 \newline
4111 \newline
4133 $endif
4112 $endif
4134 \layout Standard
4113 \layout Standard
4135
4114
4136 Note that there are 4 spaces between the quote marks after
4115 Note that there are 4 spaces between the quote marks after
4137 \family typewriter
4116 \family typewriter
4138 "M-i"
4117 "M-i"
4139 \family default
4118 \family default
4140 above.
4119 above.
4141 \layout Standard
4120 \layout Standard
4142
4121
4143
4122
4144 \series bold
4123 \series bold
4145 Warning:
4124 Warning:
4146 \series default
4125 \series default
4147 this feature is ON by default, but it can cause problems with the pasting
4126 this feature is ON by default, but it can cause problems with the pasting
4148 of multi-line indented code (the pasted code gets re-indented on each line).
4127 of multi-line indented code (the pasted code gets re-indented on each line).
4149 A magic function
4128 A magic function
4150 \family typewriter
4129 \family typewriter
4151 %autoindent
4130 %autoindent
4152 \family default
4131 \family default
4153 allows you to toggle it on/off at runtime.
4132 allows you to toggle it on/off at runtime.
4154 You can also disable it permanently on in your
4133 You can also disable it permanently on in your
4155 \family typewriter
4134 \family typewriter
4156 ipythonrc
4135 ipythonrc
4157 \family default
4136 \family default
4158 file (set
4137 file (set
4159 \family typewriter
4138 \family typewriter
4160 autoindent 0
4139 autoindent 0
4161 \family default
4140 \family default
4162 ).
4141 ).
4163 \layout Subsubsection
4142 \layout Subsubsection
4164
4143
4165 Customizing readline behavior
4144 Customizing readline behavior
4166 \layout Standard
4145 \layout Standard
4167
4146
4168 All these features are based on the GNU readline library, which has an extremely
4147 All these features are based on the GNU readline library, which has an extremely
4169 customizable interface.
4148 customizable interface.
4170 Normally, readline is configured via a file which defines the behavior
4149 Normally, readline is configured via a file which defines the behavior
4171 of the library; the details of the syntax for this can be found in the
4150 of the library; the details of the syntax for this can be found in the
4172 readline documentation available with your system or on the Internet.
4151 readline documentation available with your system or on the Internet.
4173 IPython doesn't read this file (if it exists) directly, but it does support
4152 IPython doesn't read this file (if it exists) directly, but it does support
4174 passing to readline valid options via a simple interface.
4153 passing to readline valid options via a simple interface.
4175 In brief, you can customize readline by setting the following options in
4154 In brief, you can customize readline by setting the following options in
4176 your
4155 your
4177 \family typewriter
4156 \family typewriter
4178 ipythonrc
4157 ipythonrc
4179 \family default
4158 \family default
4180 configuration file (note that these options can
4159 configuration file (note that these options can
4181 \emph on
4160 \emph on
4182 not
4161 not
4183 \emph default
4162 \emph default
4184 be specified at the command line):
4163 be specified at the command line):
4185 \layout List
4164 \layout List
4186 \labelwidthstring 00.00.0000
4165 \labelwidthstring 00.00.0000
4187
4166
4188
4167
4189 \family typewriter
4168 \family typewriter
4190 \series bold
4169 \series bold
4191 readline_parse_and_bind:
4170 readline_parse_and_bind:
4192 \family default
4171 \family default
4193 \series default
4172 \series default
4194 this option can appear as many times as you want, each time defining a
4173 this option can appear as many times as you want, each time defining a
4195 string to be executed via a
4174 string to be executed via a
4196 \family typewriter
4175 \family typewriter
4197 readline.parse_and_bind()
4176 readline.parse_and_bind()
4198 \family default
4177 \family default
4199 command.
4178 command.
4200 The syntax for valid commands of this kind can be found by reading the
4179 The syntax for valid commands of this kind can be found by reading the
4201 documentation for the GNU readline library, as these commands are of the
4180 documentation for the GNU readline library, as these commands are of the
4202 kind which readline accepts in its configuration file.
4181 kind which readline accepts in its configuration file.
4203 \layout List
4182 \layout List
4204 \labelwidthstring 00.00.0000
4183 \labelwidthstring 00.00.0000
4205
4184
4206
4185
4207 \family typewriter
4186 \family typewriter
4208 \series bold
4187 \series bold
4209 readline_remove_delims:
4188 readline_remove_delims:
4210 \family default
4189 \family default
4211 \series default
4190 \series default
4212 a string of characters to be removed from the default word-delimiters list
4191 a string of characters to be removed from the default word-delimiters list
4213 used by readline, so that completions may be performed on strings which
4192 used by readline, so that completions may be performed on strings which
4214 contain them.
4193 contain them.
4215 Do not change the default value unless you know what you're doing.
4194 Do not change the default value unless you know what you're doing.
4216 \layout List
4195 \layout List
4217 \labelwidthstring 00.00.0000
4196 \labelwidthstring 00.00.0000
4218
4197
4219
4198
4220 \family typewriter
4199 \family typewriter
4221 \series bold
4200 \series bold
4222 readline_omit__names
4201 readline_omit__names
4223 \family default
4202 \family default
4224 \series default
4203 \series default
4225 : when tab-completion is enabled, hitting
4204 : when tab-completion is enabled, hitting
4226 \family typewriter
4205 \family typewriter
4227 <tab>
4206 <tab>
4228 \family default
4207 \family default
4229 after a '
4208 after a '
4230 \family typewriter
4209 \family typewriter
4231 .
4210 .
4232 \family default
4211 \family default
4233 ' in a name will complete all attributes of an object, including all the
4212 ' in a name will complete all attributes of an object, including all the
4234 special methods whose names include double underscores (like
4213 special methods whose names include double underscores (like
4235 \family typewriter
4214 \family typewriter
4236 __getitem__
4215 __getitem__
4237 \family default
4216 \family default
4238 or
4217 or
4239 \family typewriter
4218 \family typewriter
4240 __class__
4219 __class__
4241 \family default
4220 \family default
4242 ).
4221 ).
4243 If you'd rather not see these names by default, you can set this option
4222 If you'd rather not see these names by default, you can set this option
4244 to 1.
4223 to 1.
4245 Note that even when this option is set, you can still see those names by
4224 Note that even when this option is set, you can still see those names by
4246 explicitly typing a
4225 explicitly typing a
4247 \family typewriter
4226 \family typewriter
4248 _
4227 _
4249 \family default
4228 \family default
4250 after the period and hitting
4229 after the period and hitting
4251 \family typewriter
4230 \family typewriter
4252 <tab>
4231 <tab>
4253 \family default
4232 \family default
4254 : '
4233 : '
4255 \family typewriter
4234 \family typewriter
4256 name._<tab>
4235 name._<tab>
4257 \family default
4236 \family default
4258 ' will always complete attribute names starting with '
4237 ' will always complete attribute names starting with '
4259 \family typewriter
4238 \family typewriter
4260 _
4239 _
4261 \family default
4240 \family default
4262 '.
4241 '.
4263 \layout List
4242 \layout List
4264 \labelwidthstring 00.00.0000
4243 \labelwidthstring 00.00.0000
4265
4244
4266 \SpecialChar ~
4245 \SpecialChar ~
4267 This option is off by default so that new users see all attributes of any
4246 This option is off by default so that new users see all attributes of any
4268 objects they are dealing with.
4247 objects they are dealing with.
4269 \layout Standard
4248 \layout Standard
4270
4249
4271 You will find the default values along with a corresponding detailed explanation
4250 You will find the default values along with a corresponding detailed explanation
4272 in your
4251 in your
4273 \family typewriter
4252 \family typewriter
4274 ipythonrc
4253 ipythonrc
4275 \family default
4254 \family default
4276 file.
4255 file.
4277 \layout Subsection
4256 \layout Subsection
4278
4257
4279 Session logging and restoring
4258 Session logging and restoring
4280 \layout Standard
4259 \layout Standard
4281
4260
4282 You can log all input from a session either by starting IPython with the
4261 You can log all input from a session either by starting IPython with the
4283 command line switches
4262 command line switches
4284 \family typewriter
4263 \family typewriter
4285 -log
4264 -log
4286 \family default
4265 \family default
4287 or
4266 or
4288 \family typewriter
4267 \family typewriter
4289 -logfile
4268 -logfile
4290 \family default
4269 \family default
4291 (see sec.
4270 (see sec.
4292
4271
4293 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
4272 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
4294
4273
4295 \end_inset
4274 \end_inset
4296
4275
4297 )or by activating the logging at any moment with the magic function
4276 )or by activating the logging at any moment with the magic function
4298 \family typewriter
4277 \family typewriter
4299 %logstart
4278 %logstart
4300 \family default
4279 \family default
4301 .
4280 .
4302
4281
4303 \layout Standard
4282 \layout Standard
4304
4283
4305 Log files can later be reloaded with the
4284 Log files can later be reloaded with the
4306 \family typewriter
4285 \family typewriter
4307 -logplay
4286 -logplay
4308 \family default
4287 \family default
4309 option and IPython will attempt to 'replay' the log by executing all the
4288 option and IPython will attempt to 'replay' the log by executing all the
4310 lines in it, thus restoring the state of a previous session.
4289 lines in it, thus restoring the state of a previous session.
4311 This feature is not quite perfect, but can still be useful in many cases.
4290 This feature is not quite perfect, but can still be useful in many cases.
4312 \layout Standard
4291 \layout Standard
4313
4292
4314 The log files can also be used as a way to have a permanent record of any
4293 The log files can also be used as a way to have a permanent record of any
4315 code you wrote while experimenting.
4294 code you wrote while experimenting.
4316 Log files are regular text files which you can later open in your favorite
4295 Log files are regular text files which you can later open in your favorite
4317 text editor to extract code or to 'clean them up' before using them to
4296 text editor to extract code or to 'clean them up' before using them to
4318 replay a session.
4297 replay a session.
4319 \layout Standard
4298 \layout Standard
4320
4299
4321 The
4300 The
4322 \family typewriter
4301 \family typewriter
4323 %logstart
4302 %logstart
4324 \family default
4303 \family default
4325 function for activating logging in mid-session is used as follows:
4304 function for activating logging in mid-session is used as follows:
4326 \layout Standard
4305 \layout Standard
4327
4306
4328
4307
4329 \family typewriter
4308 \family typewriter
4330 %logstart [log_name [log_mode]]
4309 %logstart [log_name [log_mode]]
4331 \layout Standard
4310 \layout Standard
4332
4311
4333 If no name is given, it defaults to a file named
4312 If no name is given, it defaults to a file named
4334 \family typewriter
4313 \family typewriter
4335 'log'
4314 'log'
4336 \family default
4315 \family default
4337 in your IPYTHONDIR directory, in
4316 in your IPYTHONDIR directory, in
4338 \family typewriter
4317 \family typewriter
4339 'rotate'
4318 'rotate'
4340 \family default
4319 \family default
4341 mode (see below).
4320 mode (see below).
4342 \layout Standard
4321 \layout Standard
4343
4322
4344 '
4323 '
4345 \family typewriter
4324 \family typewriter
4346 %logstart name
4325 %logstart name
4347 \family default
4326 \family default
4348 ' saves to file
4327 ' saves to file
4349 \family typewriter
4328 \family typewriter
4350 'name'
4329 'name'
4351 \family default
4330 \family default
4352 in
4331 in
4353 \family typewriter
4332 \family typewriter
4354 'backup'
4333 'backup'
4355 \family default
4334 \family default
4356 mode.
4335 mode.
4357 It saves your history up to that point and then continues logging.
4336 It saves your history up to that point and then continues logging.
4358 \layout Standard
4337 \layout Standard
4359
4338
4360
4339
4361 \family typewriter
4340 \family typewriter
4362 %logstart
4341 %logstart
4363 \family default
4342 \family default
4364 takes a second optional parameter: logging mode.
4343 takes a second optional parameter: logging mode.
4365 This can be one of (note that the modes are given unquoted):
4344 This can be one of (note that the modes are given unquoted):
4366 \layout List
4345 \layout List
4367 \labelwidthstring 00.00.0000
4346 \labelwidthstring 00.00.0000
4368
4347
4369
4348
4370 \family typewriter
4349 \family typewriter
4371 over
4350 over
4372 \family default
4351 \family default
4373 : overwrite existing
4352 : overwrite existing
4374 \family typewriter
4353 \family typewriter
4375 log_name
4354 log_name
4376 \family default
4355 \family default
4377 .
4356 .
4378 \layout List
4357 \layout List
4379 \labelwidthstring 00.00.0000
4358 \labelwidthstring 00.00.0000
4380
4359
4381
4360
4382 \family typewriter
4361 \family typewriter
4383 backup
4362 backup
4384 \family default
4363 \family default
4385 : rename (if exists) to
4364 : rename (if exists) to
4386 \family typewriter
4365 \family typewriter
4387 log_name~
4366 log_name~
4388 \family default
4367 \family default
4389 and start
4368 and start
4390 \family typewriter
4369 \family typewriter
4391 log_name
4370 log_name
4392 \family default
4371 \family default
4393 .
4372 .
4394 \layout List
4373 \layout List
4395 \labelwidthstring 00.00.0000
4374 \labelwidthstring 00.00.0000
4396
4375
4397
4376
4398 \family typewriter
4377 \family typewriter
4399 append
4378 append
4400 \family default
4379 \family default
4401 : well, that says it.
4380 : well, that says it.
4402 \layout List
4381 \layout List
4403 \labelwidthstring 00.00.0000
4382 \labelwidthstring 00.00.0000
4404
4383
4405
4384
4406 \family typewriter
4385 \family typewriter
4407 rotate
4386 rotate
4408 \family default
4387 \family default
4409 : create rotating logs
4388 : create rotating logs
4410 \family typewriter
4389 \family typewriter
4411 log_name
4390 log_name
4412 \family default
4391 \family default
4413 .
4392 .
4414 \family typewriter
4393 \family typewriter
4415 1~
4394 1~
4416 \family default
4395 \family default
4417 ,
4396 ,
4418 \family typewriter
4397 \family typewriter
4419 log_name.2~
4398 log_name.2~
4420 \family default
4399 \family default
4421 , etc.
4400 , etc.
4422 \layout Standard
4401 \layout Standard
4423
4402
4424 The
4403 The
4425 \family typewriter
4404 \family typewriter
4426 %logoff
4405 %logoff
4427 \family default
4406 \family default
4428 and
4407 and
4429 \family typewriter
4408 \family typewriter
4430 %logon
4409 %logon
4431 \family default
4410 \family default
4432 functions allow you to temporarily stop and resume logging to a file which
4411 functions allow you to temporarily stop and resume logging to a file which
4433 had previously been started with
4412 had previously been started with
4434 \family typewriter
4413 \family typewriter
4435 %logstart
4414 %logstart
4436 \family default
4415 \family default
4437 .
4416 .
4438 They will fail (with an explanation) if you try to use them before logging
4417 They will fail (with an explanation) if you try to use them before logging
4439 has been started.
4418 has been started.
4440 \layout Subsection
4419 \layout Subsection
4441
4420
4442
4421
4443 \begin_inset LatexCommand \label{sub:System-shell-access}
4422 \begin_inset LatexCommand \label{sub:System-shell-access}
4444
4423
4445 \end_inset
4424 \end_inset
4446
4425
4447 System shell access
4426 System shell access
4448 \layout Standard
4427 \layout Standard
4449
4428
4450 Any input line beginning with a
4429 Any input line beginning with a
4451 \family typewriter
4430 \family typewriter
4452 !
4431 !
4453 \family default
4432 \family default
4454 character is passed verbatim (minus the
4433 character is passed verbatim (minus the
4455 \family typewriter
4434 \family typewriter
4456 !
4435 !
4457 \family default
4436 \family default
4458 , of course) to the underlying operating system.
4437 , of course) to the underlying operating system.
4459 For example, typing
4438 For example, typing
4460 \family typewriter
4439 \family typewriter
4461 !ls
4440 !ls
4462 \family default
4441 \family default
4463 will run
4442 will run
4464 \family typewriter
4443 \family typewriter
4465 'ls'
4444 'ls'
4466 \family default
4445 \family default
4467 in the current directory.
4446 in the current directory.
4468 \layout Subsubsection
4447 \layout Subsubsection
4469
4448
4470 Manual capture of command output
4449 Manual capture of command output
4471 \layout Standard
4450 \layout Standard
4472
4451
4473 If the input line begins with
4452 If the input line begins with
4474 \emph on
4453 \emph on
4475 two
4454 two
4476 \emph default
4455 \emph default
4477 exclamation marks,
4456 exclamation marks,
4478 \family typewriter
4457 \family typewriter
4479 !!
4458 !!
4480 \family default
4459 \family default
4481 , the command is executed but its output is captured and returned as a python
4460 , the command is executed but its output is captured and returned as a python
4482 list, split on newlines.
4461 list, split on newlines.
4483 Any output sent by the subprocess to standard error is printed separately,
4462 Any output sent by the subprocess to standard error is printed separately,
4484 so that the resulting list only captures standard output.
4463 so that the resulting list only captures standard output.
4485 The
4464 The
4486 \family typewriter
4465 \family typewriter
4487 !!
4466 !!
4488 \family default
4467 \family default
4489 syntax is a shorthand for the
4468 syntax is a shorthand for the
4490 \family typewriter
4469 \family typewriter
4491 %sx
4470 %sx
4492 \family default
4471 \family default
4493 magic command.
4472 magic command.
4494 \layout Standard
4473 \layout Standard
4495
4474
4496 Finally, the
4475 Finally, the
4497 \family typewriter
4476 \family typewriter
4498 %sc
4477 %sc
4499 \family default
4478 \family default
4500 magic (short for `shell capture') is similar to
4479 magic (short for `shell capture') is similar to
4501 \family typewriter
4480 \family typewriter
4502 %sx
4481 %sx
4503 \family default
4482 \family default
4504 , but allowing more fine-grained control of the capture details, and storing
4483 , but allowing more fine-grained control of the capture details, and storing
4505 the result directly into a named variable.
4484 the result directly into a named variable.
4506 \layout Standard
4485 \layout Standard
4507
4486
4508 See Sec.\SpecialChar ~
4487 See Sec.\SpecialChar ~
4509
4488
4510 \begin_inset LatexCommand \ref{sec:magic}
4489 \begin_inset LatexCommand \ref{sec:magic}
4511
4490
4512 \end_inset
4491 \end_inset
4513
4492
4514 for details on the magics
4493 for details on the magics
4515 \family typewriter
4494 \family typewriter
4516 %sc
4495 %sc
4517 \family default
4496 \family default
4518 and
4497 and
4519 \family typewriter
4498 \family typewriter
4520 %sx
4499 %sx
4521 \family default
4500 \family default
4522 , or use IPython's own help (
4501 , or use IPython's own help (
4523 \family typewriter
4502 \family typewriter
4524 sc?
4503 sc?
4525 \family default
4504 \family default
4526 and
4505 and
4527 \family typewriter
4506 \family typewriter
4528 sx?
4507 sx?
4529 \family default
4508 \family default
4530 ) for further details.
4509 ) for further details.
4531 \layout Standard
4510 \layout Standard
4532
4511
4533 IPython also allows you to expand the value of python variables when making
4512 IPython also allows you to expand the value of python variables when making
4534 system calls.
4513 system calls.
4535 Any python variable or expression which you prepend with
4514 Any python variable or expression which you prepend with
4536 \family typewriter
4515 \family typewriter
4537 $
4516 $
4538 \family default
4517 \family default
4539 will get expanded before the system call is made.
4518 will get expanded before the system call is made.
4540
4519
4541 \layout Standard
4520 \layout Standard
4542
4521
4543
4522
4544 \family typewriter
4523 \family typewriter
4545 In [1]: pyvar='Hello world'
4524 In [1]: pyvar='Hello world'
4546 \newline
4525 \newline
4547 In [2]: !echo "A python variable: $pyvar"
4526 In [2]: !echo "A python variable: $pyvar"
4548 \newline
4527 \newline
4549 A python variable: Hello world
4528 A python variable: Hello world
4550 \layout Standard
4529 \layout Standard
4551
4530
4552 If you want the shell to actually see a literal
4531 If you want the shell to actually see a literal
4553 \family typewriter
4532 \family typewriter
4554 $
4533 $
4555 \family default
4534 \family default
4556 , you need to type it twice:
4535 , you need to type it twice:
4557 \layout Standard
4536 \layout Standard
4558
4537
4559
4538
4560 \family typewriter
4539 \family typewriter
4561 In [3]: !echo "A system variable: $$HOME"
4540 In [3]: !echo "A system variable: $$HOME"
4562 \newline
4541 \newline
4563 A system variable: /home/fperez
4542 A system variable: /home/fperez
4564 \layout Standard
4543 \layout Standard
4565
4544
4566 You can pass arbitrary expressions, though you'll need to delimit them with
4545 You can pass arbitrary expressions, though you'll need to delimit them with
4567
4546
4568 \family typewriter
4547 \family typewriter
4569 {}
4548 {}
4570 \family default
4549 \family default
4571 if there is ambiguity as to the extent of the expression:
4550 if there is ambiguity as to the extent of the expression:
4572 \layout Standard
4551 \layout Standard
4573
4552
4574
4553
4575 \family typewriter
4554 \family typewriter
4576 In [5]: x=10
4555 In [5]: x=10
4577 \newline
4556 \newline
4578 In [6]: y=20
4557 In [6]: y=20
4579 \newline
4558 \newline
4580 In [13]: !echo $x+y
4559 In [13]: !echo $x+y
4581 \newline
4560 \newline
4582 10+y
4561 10+y
4583 \newline
4562 \newline
4584 In [7]: !echo ${x+y}
4563 In [7]: !echo ${x+y}
4585 \newline
4564 \newline
4586 30
4565 30
4587 \layout Standard
4566 \layout Standard
4588
4567
4589 Even object attributes can be expanded:
4568 Even object attributes can be expanded:
4590 \layout Standard
4569 \layout Standard
4591
4570
4592
4571
4593 \family typewriter
4572 \family typewriter
4594 In [12]: !echo $sys.argv
4573 In [12]: !echo $sys.argv
4595 \newline
4574 \newline
4596 [/home/fperez/usr/bin/ipython]
4575 [/home/fperez/usr/bin/ipython]
4597 \layout Subsection
4576 \layout Subsection
4598
4577
4599 System command aliases
4578 System command aliases
4600 \layout Standard
4579 \layout Standard
4601
4580
4602 The
4581 The
4603 \family typewriter
4582 \family typewriter
4604 %alias
4583 %alias
4605 \family default
4584 \family default
4606 magic function and the
4585 magic function and the
4607 \family typewriter
4586 \family typewriter
4608 alias
4587 alias
4609 \family default
4588 \family default
4610 option in the
4589 option in the
4611 \family typewriter
4590 \family typewriter
4612 ipythonrc
4591 ipythonrc
4613 \family default
4592 \family default
4614 configuration file allow you to define magic functions which are in fact
4593 configuration file allow you to define magic functions which are in fact
4615 system shell commands.
4594 system shell commands.
4616 These aliases can have parameters.
4595 These aliases can have parameters.
4617
4596
4618 \layout Standard
4597 \layout Standard
4619
4598
4620 '
4599 '
4621 \family typewriter
4600 \family typewriter
4622 %alias alias_name cmd
4601 %alias alias_name cmd
4623 \family default
4602 \family default
4624 ' defines '
4603 ' defines '
4625 \family typewriter
4604 \family typewriter
4626 alias_name
4605 alias_name
4627 \family default
4606 \family default
4628 ' as an alias for '
4607 ' as an alias for '
4629 \family typewriter
4608 \family typewriter
4630 cmd
4609 cmd
4631 \family default
4610 \family default
4632 '
4611 '
4633 \layout Standard
4612 \layout Standard
4634
4613
4635 Then, typing '
4614 Then, typing '
4636 \family typewriter
4615 \family typewriter
4637 %alias_name params
4616 %alias_name params
4638 \family default
4617 \family default
4639 ' will execute the system command '
4618 ' will execute the system command '
4640 \family typewriter
4619 \family typewriter
4641 cmd params
4620 cmd params
4642 \family default
4621 \family default
4643 ' (from your underlying operating system).
4622 ' (from your underlying operating system).
4644
4623
4645 \layout Standard
4624 \layout Standard
4646
4625
4647 You can also define aliases with parameters using
4626 You can also define aliases with parameters using
4648 \family typewriter
4627 \family typewriter
4649 %s
4628 %s
4650 \family default
4629 \family default
4651 specifiers (one per parameter).
4630 specifiers (one per parameter).
4652 The following example defines the
4631 The following example defines the
4653 \family typewriter
4632 \family typewriter
4654 %parts
4633 %parts
4655 \family default
4634 \family default
4656 function as an alias to the command '
4635 function as an alias to the command '
4657 \family typewriter
4636 \family typewriter
4658 echo first %s second %s
4637 echo first %s second %s
4659 \family default
4638 \family default
4660 ' where each
4639 ' where each
4661 \family typewriter
4640 \family typewriter
4662 %s
4641 %s
4663 \family default
4642 \family default
4664 will be replaced by a positional parameter to the call to
4643 will be replaced by a positional parameter to the call to
4665 \family typewriter
4644 \family typewriter
4666 %parts:
4645 %parts:
4667 \layout Standard
4646 \layout Standard
4668
4647
4669
4648
4670 \family typewriter
4649 \family typewriter
4671 In [1]: alias parts echo first %s second %s
4650 In [1]: alias parts echo first %s second %s
4672 \newline
4651 \newline
4673 In [2]: %parts A B
4652 In [2]: %parts A B
4674 \newline
4653 \newline
4675 first A second B
4654 first A second B
4676 \newline
4655 \newline
4677 In [3]: %parts A
4656 In [3]: %parts A
4678 \newline
4657 \newline
4679 Incorrect number of arguments: 2 expected.
4658 Incorrect number of arguments: 2 expected.
4680
4659
4681 \newline
4660 \newline
4682 parts is an alias to: 'echo first %s second %s'
4661 parts is an alias to: 'echo first %s second %s'
4683 \layout Standard
4662 \layout Standard
4684
4663
4685 If called with no parameters,
4664 If called with no parameters,
4686 \family typewriter
4665 \family typewriter
4687 %alias
4666 %alias
4688 \family default
4667 \family default
4689 prints the table of currently defined aliases.
4668 prints the table of currently defined aliases.
4690 \layout Standard
4669 \layout Standard
4691
4670
4692 The
4671 The
4693 \family typewriter
4672 \family typewriter
4694 %rehash/rehashx
4673 %rehash/rehashx
4695 \family default
4674 \family default
4696 magics allow you to load your entire
4675 magics allow you to load your entire
4697 \family typewriter
4676 \family typewriter
4698 $PATH
4677 $PATH
4699 \family default
4678 \family default
4700 as ipython aliases.
4679 as ipython aliases.
4701 See their respective docstrings (or sec.\SpecialChar ~
4680 See their respective docstrings (or sec.\SpecialChar ~
4702
4681
4703 \begin_inset LatexCommand \ref{sec:magic}
4682 \begin_inset LatexCommand \ref{sec:magic}
4704
4683
4705 \end_inset
4684 \end_inset
4706
4685
4707 for further details).
4686 for further details).
4708 \layout Subsection
4687 \layout Subsection
4709
4688
4710
4689
4711 \begin_inset LatexCommand \label{sec:dreload}
4690 \begin_inset LatexCommand \label{sec:dreload}
4712
4691
4713 \end_inset
4692 \end_inset
4714
4693
4715 Recursive reload
4694 Recursive reload
4716 \layout Standard
4695 \layout Standard
4717
4696
4718 The
4697 The
4719 \family typewriter
4698 \family typewriter
4720 %dreload
4699 %dreload
4721 \family default
4700 \family default
4722 command does a recursive reload of a module: changes made to the module
4701 command does a recursive reload of a module: changes made to the module
4723 since you imported will actually be available without having to exit.
4702 since you imported will actually be available without having to exit.
4724 \layout Subsection
4703 \layout Subsection
4725
4704
4726 Verbose and colored exception traceback printouts
4705 Verbose and colored exception traceback printouts
4727 \layout Standard
4706 \layout Standard
4728
4707
4729 IPython provides the option to see very detailed exception tracebacks, which
4708 IPython provides the option to see very detailed exception tracebacks, which
4730 can be especially useful when debugging large programs.
4709 can be especially useful when debugging large programs.
4731 You can run any Python file with the
4710 You can run any Python file with the
4732 \family typewriter
4711 \family typewriter
4733 %run
4712 %run
4734 \family default
4713 \family default
4735 function to benefit from these detailed tracebacks.
4714 function to benefit from these detailed tracebacks.
4736 Furthermore, both normal and verbose tracebacks can be colored (if your
4715 Furthermore, both normal and verbose tracebacks can be colored (if your
4737 terminal supports it) which makes them much easier to parse visually.
4716 terminal supports it) which makes them much easier to parse visually.
4738 \layout Standard
4717 \layout Standard
4739
4718
4740 See the magic
4719 See the magic
4741 \family typewriter
4720 \family typewriter
4742 xmode
4721 xmode
4743 \family default
4722 \family default
4744 and
4723 and
4745 \family typewriter
4724 \family typewriter
4746 colors
4725 colors
4747 \family default
4726 \family default
4748 functions for details (just type
4727 functions for details (just type
4749 \family typewriter
4728 \family typewriter
4750 %magic
4729 %magic
4751 \family default
4730 \family default
4752 ).
4731 ).
4753 \layout Standard
4732 \layout Standard
4754
4733
4755 These features are basically a terminal version of Ka-Ping Yee's
4734 These features are basically a terminal version of Ka-Ping Yee's
4756 \family typewriter
4735 \family typewriter
4757 cgitb
4736 cgitb
4758 \family default
4737 \family default
4759 module, now part of the standard Python library.
4738 module, now part of the standard Python library.
4760 \layout Subsection
4739 \layout Subsection
4761
4740
4762
4741
4763 \begin_inset LatexCommand \label{sec:cache_input}
4742 \begin_inset LatexCommand \label{sec:cache_input}
4764
4743
4765 \end_inset
4744 \end_inset
4766
4745
4767 Input caching system
4746 Input caching system
4768 \layout Standard
4747 \layout Standard
4769
4748
4770 IPython offers numbered prompts (In/Out) with input and output caching.
4749 IPython offers numbered prompts (In/Out) with input and output caching.
4771 All input is saved and can be retrieved as variables (besides the usual
4750 All input is saved and can be retrieved as variables (besides the usual
4772 arrow key recall).
4751 arrow key recall).
4773 \layout Standard
4752 \layout Standard
4774
4753
4775 The following GLOBAL variables always exist (so don't overwrite them!):
4754 The following GLOBAL variables always exist (so don't overwrite them!):
4776
4755
4777 \family typewriter
4756 \family typewriter
4778 _i
4757 _i
4779 \family default
4758 \family default
4780 : stores previous input.
4759 : stores previous input.
4781
4760
4782 \family typewriter
4761 \family typewriter
4783 _ii
4762 _ii
4784 \family default
4763 \family default
4785 : next previous.
4764 : next previous.
4786
4765
4787 \family typewriter
4766 \family typewriter
4788 _iii
4767 _iii
4789 \family default
4768 \family default
4790 : next-next previous.
4769 : next-next previous.
4791
4770
4792 \family typewriter
4771 \family typewriter
4793 _ih
4772 _ih
4794 \family default
4773 \family default
4795 : a list of all input
4774 : a list of all input
4796 \family typewriter
4775 \family typewriter
4797 _ih[n]
4776 _ih[n]
4798 \family default
4777 \family default
4799 is the input from line
4778 is the input from line
4800 \family typewriter
4779 \family typewriter
4801 n
4780 n
4802 \family default
4781 \family default
4803 and this list is aliased to the global variable
4782 and this list is aliased to the global variable
4804 \family typewriter
4783 \family typewriter
4805 In
4784 In
4806 \family default
4785 \family default
4807 .
4786 .
4808 If you overwrite
4787 If you overwrite
4809 \family typewriter
4788 \family typewriter
4810 In
4789 In
4811 \family default
4790 \family default
4812 with a variable of your own, you can remake the assignment to the internal
4791 with a variable of your own, you can remake the assignment to the internal
4813 list with a simple
4792 list with a simple
4814 \family typewriter
4793 \family typewriter
4815 'In=_ih'
4794 'In=_ih'
4816 \family default
4795 \family default
4817 .
4796 .
4818 \layout Standard
4797 \layout Standard
4819
4798
4820 Additionally, global variables named
4799 Additionally, global variables named
4821 \family typewriter
4800 \family typewriter
4822 _i<n>
4801 _i<n>
4823 \family default
4802 \family default
4824 are dynamically created (
4803 are dynamically created (
4825 \family typewriter
4804 \family typewriter
4826 <n>
4805 <n>
4827 \family default
4806 \family default
4828 being the prompt counter), such that
4807 being the prompt counter), such that
4829 \newline
4808 \newline
4830
4809
4831 \family typewriter
4810 \family typewriter
4832 _i<n> == _ih[<n>] == In[<n>].
4811 _i<n> == _ih[<n>] == In[<n>].
4833 \layout Standard
4812 \layout Standard
4834
4813
4835 For example, what you typed at prompt 14 is available as
4814 For example, what you typed at prompt 14 is available as
4836 \family typewriter
4815 \family typewriter
4837 _i14,
4816 _i14,
4838 \family default
4817 \family default
4839
4818
4840 \family typewriter
4819 \family typewriter
4841 _ih[14]
4820 _ih[14]
4842 \family default
4821 \family default
4843 and
4822 and
4844 \family typewriter
4823 \family typewriter
4845 In[14]
4824 In[14]
4846 \family default
4825 \family default
4847 .
4826 .
4848 \layout Standard
4827 \layout Standard
4849
4828
4850 This allows you to easily cut and paste multi line interactive prompts by
4829 This allows you to easily cut and paste multi line interactive prompts by
4851 printing them out: they print like a clean string, without prompt characters.
4830 printing them out: they print like a clean string, without prompt characters.
4852 You can also manipulate them like regular variables (they are strings),
4831 You can also manipulate them like regular variables (they are strings),
4853 modify or exec them (typing
4832 modify or exec them (typing
4854 \family typewriter
4833 \family typewriter
4855 'exec _i9'
4834 'exec _i9'
4856 \family default
4835 \family default
4857 will re-execute the contents of input prompt 9, '
4836 will re-execute the contents of input prompt 9, '
4858 \family typewriter
4837 \family typewriter
4859 exec In[9:14]+In[18]
4838 exec In[9:14]+In[18]
4860 \family default
4839 \family default
4861 ' will re-execute lines 9 through 13 and line 18).
4840 ' will re-execute lines 9 through 13 and line 18).
4862 \layout Standard
4841 \layout Standard
4863
4842
4864 You can also re-execute multiple lines of input easily by using the magic
4843 You can also re-execute multiple lines of input easily by using the magic
4865
4844
4866 \family typewriter
4845 \family typewriter
4867 %macro
4846 %macro
4868 \family default
4847 \family default
4869 function (which automates the process and allows re-execution without having
4848 function (which automates the process and allows re-execution without having
4870 to type '
4849 to type '
4871 \family typewriter
4850 \family typewriter
4872 exec
4851 exec
4873 \family default
4852 \family default
4874 ' every time).
4853 ' every time).
4875 The macro system also allows you to re-execute previous lines which include
4854 The macro system also allows you to re-execute previous lines which include
4876 magic function calls (which require special processing).
4855 magic function calls (which require special processing).
4877 Type
4856 Type
4878 \family typewriter
4857 \family typewriter
4879 %macro?
4858 %macro?
4880 \family default
4859 \family default
4881 or see sec.
4860 or see sec.
4882
4861
4883 \begin_inset LatexCommand \ref{sec:magic}
4862 \begin_inset LatexCommand \ref{sec:magic}
4884
4863
4885 \end_inset
4864 \end_inset
4886
4865
4887 for more details on the macro system.
4866 for more details on the macro system.
4888 \layout Standard
4867 \layout Standard
4889
4868
4890 A history function
4869 A history function
4891 \family typewriter
4870 \family typewriter
4892 %hist
4871 %hist
4893 \family default
4872 \family default
4894 allows you to see any part of your input history by printing a range of
4873 allows you to see any part of your input history by printing a range of
4895 the
4874 the
4896 \family typewriter
4875 \family typewriter
4897 _i
4876 _i
4898 \family default
4877 \family default
4899 variables.
4878 variables.
4900 \layout Subsection
4879 \layout Subsection
4901
4880
4902
4881
4903 \begin_inset LatexCommand \label{sec:cache_output}
4882 \begin_inset LatexCommand \label{sec:cache_output}
4904
4883
4905 \end_inset
4884 \end_inset
4906
4885
4907 Output caching system
4886 Output caching system
4908 \layout Standard
4887 \layout Standard
4909
4888
4910 For output that is returned from actions, a system similar to the input
4889 For output that is returned from actions, a system similar to the input
4911 cache exists but using
4890 cache exists but using
4912 \family typewriter
4891 \family typewriter
4913 _
4892 _
4914 \family default
4893 \family default
4915 instead of
4894 instead of
4916 \family typewriter
4895 \family typewriter
4917 _i
4896 _i
4918 \family default
4897 \family default
4919 .
4898 .
4920 Only actions that produce a result (NOT assignments, for example) are cached.
4899 Only actions that produce a result (NOT assignments, for example) are cached.
4921 If you are familiar with Mathematica, IPython's
4900 If you are familiar with Mathematica, IPython's
4922 \family typewriter
4901 \family typewriter
4923 _
4902 _
4924 \family default
4903 \family default
4925 variables behave exactly like Mathematica's
4904 variables behave exactly like Mathematica's
4926 \family typewriter
4905 \family typewriter
4927 %
4906 %
4928 \family default
4907 \family default
4929 variables.
4908 variables.
4930 \layout Standard
4909 \layout Standard
4931
4910
4932 The following GLOBAL variables always exist (so don't overwrite them!):
4911 The following GLOBAL variables always exist (so don't overwrite them!):
4933
4912
4934 \layout List
4913 \layout List
4935 \labelwidthstring 00.00.0000
4914 \labelwidthstring 00.00.0000
4936
4915
4937
4916
4938 \family typewriter
4917 \family typewriter
4939 \series bold
4918 \series bold
4940 _
4919 _
4941 \family default
4920 \family default
4942 \series default
4921 \series default
4943 (a
4922 (a
4944 \emph on
4923 \emph on
4945 single
4924 single
4946 \emph default
4925 \emph default
4947 underscore) : stores previous output, like Python's default interpreter.
4926 underscore) : stores previous output, like Python's default interpreter.
4948 \layout List
4927 \layout List
4949 \labelwidthstring 00.00.0000
4928 \labelwidthstring 00.00.0000
4950
4929
4951
4930
4952 \family typewriter
4931 \family typewriter
4953 \series bold
4932 \series bold
4954 __
4933 __
4955 \family default
4934 \family default
4956 \series default
4935 \series default
4957 (two underscores): next previous.
4936 (two underscores): next previous.
4958 \layout List
4937 \layout List
4959 \labelwidthstring 00.00.0000
4938 \labelwidthstring 00.00.0000
4960
4939
4961
4940
4962 \family typewriter
4941 \family typewriter
4963 \series bold
4942 \series bold
4964 ___
4943 ___
4965 \family default
4944 \family default
4966 \series default
4945 \series default
4967 (three underscores): next-next previous.
4946 (three underscores): next-next previous.
4968 \layout Standard
4947 \layout Standard
4969
4948
4970 Additionally, global variables named
4949 Additionally, global variables named
4971 \family typewriter
4950 \family typewriter
4972 _<n>
4951 _<n>
4973 \family default
4952 \family default
4974 are dynamically created (
4953 are dynamically created (
4975 \family typewriter
4954 \family typewriter
4976 <n>
4955 <n>
4977 \family default
4956 \family default
4978 being the prompt counter), such that the result of output
4957 being the prompt counter), such that the result of output
4979 \family typewriter
4958 \family typewriter
4980 <n>
4959 <n>
4981 \family default
4960 \family default
4982 is always available as
4961 is always available as
4983 \family typewriter
4962 \family typewriter
4984 _<n>
4963 _<n>
4985 \family default
4964 \family default
4986 (don't use the angle brackets, just the number, e.g.
4965 (don't use the angle brackets, just the number, e.g.
4987
4966
4988 \family typewriter
4967 \family typewriter
4989 _21
4968 _21
4990 \family default
4969 \family default
4991 ).
4970 ).
4992 \layout Standard
4971 \layout Standard
4993
4972
4994 These global variables are all stored in a global dictionary (not a list,
4973 These global variables are all stored in a global dictionary (not a list,
4995 since it only has entries for lines which returned a result) available
4974 since it only has entries for lines which returned a result) available
4996 under the names
4975 under the names
4997 \family typewriter
4976 \family typewriter
4998 _oh
4977 _oh
4999 \family default
4978 \family default
5000 and
4979 and
5001 \family typewriter
4980 \family typewriter
5002 Out
4981 Out
5003 \family default
4982 \family default
5004 (similar to
4983 (similar to
5005 \family typewriter
4984 \family typewriter
5006 _ih
4985 _ih
5007 \family default
4986 \family default
5008 and
4987 and
5009 \family typewriter
4988 \family typewriter
5010 In
4989 In
5011 \family default
4990 \family default
5012 ).
4991 ).
5013 So the output from line 12 can be obtained as
4992 So the output from line 12 can be obtained as
5014 \family typewriter
4993 \family typewriter
5015 _12
4994 _12
5016 \family default
4995 \family default
5017 ,
4996 ,
5018 \family typewriter
4997 \family typewriter
5019 Out[12]
4998 Out[12]
5020 \family default
4999 \family default
5021 or
5000 or
5022 \family typewriter
5001 \family typewriter
5023 _oh[12]
5002 _oh[12]
5024 \family default
5003 \family default
5025 .
5004 .
5026 If you accidentally overwrite the
5005 If you accidentally overwrite the
5027 \family typewriter
5006 \family typewriter
5028 Out
5007 Out
5029 \family default
5008 \family default
5030 variable you can recover it by typing
5009 variable you can recover it by typing
5031 \family typewriter
5010 \family typewriter
5032 'Out=_oh
5011 'Out=_oh
5033 \family default
5012 \family default
5034 ' at the prompt.
5013 ' at the prompt.
5035 \layout Standard
5014 \layout Standard
5036
5015
5037 This system obviously can potentially put heavy memory demands on your system,
5016 This system obviously can potentially put heavy memory demands on your system,
5038 since it prevents Python's garbage collector from removing any previously
5017 since it prevents Python's garbage collector from removing any previously
5039 computed results.
5018 computed results.
5040 You can control how many results are kept in memory with the option (at
5019 You can control how many results are kept in memory with the option (at
5041 the command line or in your
5020 the command line or in your
5042 \family typewriter
5021 \family typewriter
5043 ipythonrc
5022 ipythonrc
5044 \family default
5023 \family default
5045 file)
5024 file)
5046 \family typewriter
5025 \family typewriter
5047 cache_size
5026 cache_size
5048 \family default
5027 \family default
5049 .
5028 .
5050 If you set it to 0, the whole system is completely disabled and the prompts
5029 If you set it to 0, the whole system is completely disabled and the prompts
5051 revert to the classic
5030 revert to the classic
5052 \family typewriter
5031 \family typewriter
5053 '>>>'
5032 '>>>'
5054 \family default
5033 \family default
5055 of normal Python.
5034 of normal Python.
5056 \layout Subsection
5035 \layout Subsection
5057
5036
5058 Directory history
5037 Directory history
5059 \layout Standard
5038 \layout Standard
5060
5039
5061 Your history of visited directories is kept in the global list
5040 Your history of visited directories is kept in the global list
5062 \family typewriter
5041 \family typewriter
5063 _dh
5042 _dh
5064 \family default
5043 \family default
5065 , and the magic
5044 , and the magic
5066 \family typewriter
5045 \family typewriter
5067 %cd
5046 %cd
5068 \family default
5047 \family default
5069 command can be used to go to any entry in that list.
5048 command can be used to go to any entry in that list.
5070 The
5049 The
5071 \family typewriter
5050 \family typewriter
5072 %dhist
5051 %dhist
5073 \family default
5052 \family default
5074 command allows you to view this history.
5053 command allows you to view this history.
5075 \layout Subsection
5054 \layout Subsection
5076
5055
5077 Automatic parentheses and quotes
5056 Automatic parentheses and quotes
5078 \layout Standard
5057 \layout Standard
5079
5058
5080 These features were adapted from Nathan Gray's LazyPython.
5059 These features were adapted from Nathan Gray's LazyPython.
5081 They are meant to allow less typing for common situations.
5060 They are meant to allow less typing for common situations.
5082 \layout Subsubsection
5061 \layout Subsubsection
5083
5062
5084 Automatic parentheses
5063 Automatic parentheses
5085 \layout Standard
5064 \layout Standard
5086
5065
5087 Callable objects (i.e.
5066 Callable objects (i.e.
5088 functions, methods, etc) can be invoked like this (notice the commas between
5067 functions, methods, etc) can be invoked like this (notice the commas between
5089 the arguments):
5068 the arguments):
5090 \layout Standard
5069 \layout Standard
5091
5070
5092
5071
5093 \family typewriter
5072 \family typewriter
5094 >>> callable_ob arg1, arg2, arg3
5073 >>> callable_ob arg1, arg2, arg3
5095 \layout Standard
5074 \layout Standard
5096
5075
5097 and the input will be translated to this:
5076 and the input will be translated to this:
5098 \layout Standard
5077 \layout Standard
5099
5078
5100
5079
5101 \family typewriter
5080 \family typewriter
5102 --> callable_ob(arg1, arg2, arg3)
5081 --> callable_ob(arg1, arg2, arg3)
5103 \layout Standard
5082 \layout Standard
5104
5083
5105 You can force automatic parentheses by using '/' as the first character
5084 You can force automatic parentheses by using '/' as the first character
5106 of a line.
5085 of a line.
5107 For example:
5086 For example:
5108 \layout Standard
5087 \layout Standard
5109
5088
5110
5089
5111 \family typewriter
5090 \family typewriter
5112 >>> /globals # becomes 'globals()'
5091 >>> /globals # becomes 'globals()'
5113 \layout Standard
5092 \layout Standard
5114
5093
5115 Note that the '/' MUST be the first character on the line! This won't work:
5094 Note that the '/' MUST be the first character on the line! This won't work:
5116
5095
5117 \layout Standard
5096 \layout Standard
5118
5097
5119
5098
5120 \family typewriter
5099 \family typewriter
5121 >>> print /globals # syntax error
5100 >>> print /globals # syntax error
5122 \layout Standard
5101 \layout Standard
5123
5102
5124 In most cases the automatic algorithm should work, so you should rarely
5103 In most cases the automatic algorithm should work, so you should rarely
5125 need to explicitly invoke /.
5104 need to explicitly invoke /.
5126 One notable exception is if you are trying to call a function with a list
5105 One notable exception is if you are trying to call a function with a list
5127 of tuples as arguments (the parenthesis will confuse IPython):
5106 of tuples as arguments (the parenthesis will confuse IPython):
5128 \layout Standard
5107 \layout Standard
5129
5108
5130
5109
5131 \family typewriter
5110 \family typewriter
5132 In [1]: zip (1,2,3),(4,5,6) # won't work
5111 In [1]: zip (1,2,3),(4,5,6) # won't work
5133 \layout Standard
5112 \layout Standard
5134
5113
5135 but this will work:
5114 but this will work:
5136 \layout Standard
5115 \layout Standard
5137
5116
5138
5117
5139 \family typewriter
5118 \family typewriter
5140 In [2]: /zip (1,2,3),(4,5,6)
5119 In [2]: /zip (1,2,3),(4,5,6)
5141 \newline
5120 \newline
5142 ------> zip ((1,2,3),(4,5,6))
5121 ------> zip ((1,2,3),(4,5,6))
5143 \newline
5122 \newline
5144 Out[2]= [(1, 4), (2, 5), (3, 6)]
5123 Out[2]= [(1, 4), (2, 5), (3, 6)]
5145 \layout Standard
5124 \layout Standard
5146
5125
5147 IPython tells you that it has altered your command line by displaying the
5126 IPython tells you that it has altered your command line by displaying the
5148 new command line preceded by
5127 new command line preceded by
5149 \family typewriter
5128 \family typewriter
5150 -->
5129 -->
5151 \family default
5130 \family default
5152 .
5131 .
5153 e.g.:
5132 e.g.:
5154 \layout Standard
5133 \layout Standard
5155
5134
5156
5135
5157 \family typewriter
5136 \family typewriter
5158 In [18]: callable list
5137 In [18]: callable list
5159 \newline
5138 \newline
5160 -------> callable (list)
5139 -------> callable (list)
5161 \layout Subsubsection
5140 \layout Subsubsection
5162
5141
5163 Automatic quoting
5142 Automatic quoting
5164 \layout Standard
5143 \layout Standard
5165
5144
5166 You can force automatic quoting of a function's arguments by using
5145 You can force automatic quoting of a function's arguments by using
5167 \family typewriter
5146 \family typewriter
5168 `,'
5147 `,'
5169 \family default
5148 \family default
5170 or
5149 or
5171 \family typewriter
5150 \family typewriter
5172 `;'
5151 `;'
5173 \family default
5152 \family default
5174 as the first character of a line.
5153 as the first character of a line.
5175 For example:
5154 For example:
5176 \layout Standard
5155 \layout Standard
5177
5156
5178
5157
5179 \family typewriter
5158 \family typewriter
5180 >>> ,my_function /home/me # becomes my_function("/home/me")
5159 >>> ,my_function /home/me # becomes my_function("/home/me")
5181 \layout Standard
5160 \layout Standard
5182
5161
5183 If you use
5162 If you use
5184 \family typewriter
5163 \family typewriter
5185 `;'
5164 `;'
5186 \family default
5165 \family default
5187 instead, the whole argument is quoted as a single string (while
5166 instead, the whole argument is quoted as a single string (while
5188 \family typewriter
5167 \family typewriter
5189 `,'
5168 `,'
5190 \family default
5169 \family default
5191 splits on whitespace):
5170 splits on whitespace):
5192 \layout Standard
5171 \layout Standard
5193
5172
5194
5173
5195 \family typewriter
5174 \family typewriter
5196 >>> ,my_function a b c # becomes my_function("a","b","c")
5175 >>> ,my_function a b c # becomes my_function("a","b","c")
5197 \layout Standard
5176 \layout Standard
5198
5177
5199
5178
5200 \family typewriter
5179 \family typewriter
5201 >>> ;my_function a b c # becomes my_function("a b c")
5180 >>> ;my_function a b c # becomes my_function("a b c")
5202 \layout Standard
5181 \layout Standard
5203
5182
5204 Note that the `
5183 Note that the `
5205 \family typewriter
5184 \family typewriter
5206 ,
5185 ,
5207 \family default
5186 \family default
5208 ' or `
5187 ' or `
5209 \family typewriter
5188 \family typewriter
5210 ;
5189 ;
5211 \family default
5190 \family default
5212 ' MUST be the first character on the line! This won't work:
5191 ' MUST be the first character on the line! This won't work:
5213 \layout Standard
5192 \layout Standard
5214
5193
5215
5194
5216 \family typewriter
5195 \family typewriter
5217 >>> x = ,my_function /home/me # syntax error
5196 >>> x = ,my_function /home/me # syntax error
5218 \layout Section
5197 \layout Section
5219
5198
5220
5199
5221 \begin_inset LatexCommand \label{sec:customization}
5200 \begin_inset LatexCommand \label{sec:customization}
5222
5201
5223 \end_inset
5202 \end_inset
5224
5203
5225 Customization
5204 Customization
5226 \layout Standard
5205 \layout Standard
5227
5206
5228 As we've already mentioned, IPython reads a configuration file which can
5207 As we've already mentioned, IPython reads a configuration file which can
5229 be specified at the command line (
5208 be specified at the command line (
5230 \family typewriter
5209 \family typewriter
5231 -rcfile
5210 -rcfile
5232 \family default
5211 \family default
5233 ) or which by default is assumed to be called
5212 ) or which by default is assumed to be called
5234 \family typewriter
5213 \family typewriter
5235 ipythonrc
5214 ipythonrc
5236 \family default
5215 \family default
5237 .
5216 .
5238 Such a file is looked for in the current directory where IPython is started
5217 Such a file is looked for in the current directory where IPython is started
5239 and then in your
5218 and then in your
5240 \family typewriter
5219 \family typewriter
5241 IPYTHONDIR
5220 IPYTHONDIR
5242 \family default
5221 \family default
5243 , which allows you to have local configuration files for specific projects.
5222 , which allows you to have local configuration files for specific projects.
5244 In this section we will call these types of configuration files simply
5223 In this section we will call these types of configuration files simply
5245 rcfiles (short for resource configuration file).
5224 rcfiles (short for resource configuration file).
5246 \layout Standard
5225 \layout Standard
5247
5226
5248 The syntax of an rcfile is one of key-value pairs separated by whitespace,
5227 The syntax of an rcfile is one of key-value pairs separated by whitespace,
5249 one per line.
5228 one per line.
5250 Lines beginning with a
5229 Lines beginning with a
5251 \family typewriter
5230 \family typewriter
5252 #
5231 #
5253 \family default
5232 \family default
5254 are ignored as comments, but comments can
5233 are ignored as comments, but comments can
5255 \series bold
5234 \series bold
5256 not
5235 not
5257 \series default
5236 \series default
5258 be put on lines with data (the parser is fairly primitive).
5237 be put on lines with data (the parser is fairly primitive).
5259 Note that these are not python files, and this is deliberate, because it
5238 Note that these are not python files, and this is deliberate, because it
5260 allows us to do some things which would be quite tricky to implement if
5239 allows us to do some things which would be quite tricky to implement if
5261 they were normal python files.
5240 they were normal python files.
5262 \layout Standard
5241 \layout Standard
5263
5242
5264 First, an rcfile can contain permanent default values for almost all command
5243 First, an rcfile can contain permanent default values for almost all command
5265 line options (except things like
5244 line options (except things like
5266 \family typewriter
5245 \family typewriter
5267 -help
5246 -help
5268 \family default
5247 \family default
5269 or
5248 or
5270 \family typewriter
5249 \family typewriter
5271 -Version
5250 -Version
5272 \family default
5251 \family default
5273 ).
5252 ).
5274 Sec\SpecialChar ~
5253 Sec\SpecialChar ~
5275
5254
5276 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
5255 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
5277
5256
5278 \end_inset
5257 \end_inset
5279
5258
5280 contains a description of all command-line options.
5259 contains a description of all command-line options.
5281 However, values you explicitly specify at the command line override the
5260 However, values you explicitly specify at the command line override the
5282 values defined in the rcfile.
5261 values defined in the rcfile.
5283 \layout Standard
5262 \layout Standard
5284
5263
5285 Besides command line option values, the rcfile can specify values for certain
5264 Besides command line option values, the rcfile can specify values for certain
5286 extra special options which are not available at the command line.
5265 extra special options which are not available at the command line.
5287 These options are briefly described below.
5266 These options are briefly described below.
5288
5267
5289 \layout Standard
5268 \layout Standard
5290
5269
5291 Each of these options may appear as many times as you need it in the file.
5270 Each of these options may appear as many times as you need it in the file.
5292 \layout List
5271 \layout List
5293 \labelwidthstring 00.00.0000
5272 \labelwidthstring 00.00.0000
5294
5273
5295
5274
5296 \family typewriter
5275 \family typewriter
5297 \series bold
5276 \series bold
5298 include\SpecialChar ~
5277 include\SpecialChar ~
5299 <file1>\SpecialChar ~
5278 <file1>\SpecialChar ~
5300 <file2>\SpecialChar ~
5279 <file2>\SpecialChar ~
5301 ...
5280 ...
5302 \family default
5281 \family default
5303 \series default
5282 \series default
5304 : you can name
5283 : you can name
5305 \emph on
5284 \emph on
5306 other
5285 other
5307 \emph default
5286 \emph default
5308 rcfiles you want to recursively load up to 15 levels (don't use the
5287 rcfiles you want to recursively load up to 15 levels (don't use the
5309 \family typewriter
5288 \family typewriter
5310 <>
5289 <>
5311 \family default
5290 \family default
5312 brackets in your names!).
5291 brackets in your names!).
5313 This feature allows you to define a 'base' rcfile with general options
5292 This feature allows you to define a 'base' rcfile with general options
5314 and special-purpose files which can be loaded only when needed with particular
5293 and special-purpose files which can be loaded only when needed with particular
5315 configuration options.
5294 configuration options.
5316 To make this more convenient, IPython accepts the
5295 To make this more convenient, IPython accepts the
5317 \family typewriter
5296 \family typewriter
5318 -profile <name>
5297 -profile <name>
5319 \family default
5298 \family default
5320 option (abbreviates to
5299 option (abbreviates to
5321 \family typewriter
5300 \family typewriter
5322 -p <name
5301 -p <name
5323 \family default
5302 \family default
5324 >)
5303 >)
5325 \family typewriter
5304 \family typewriter
5326 which
5305 which
5327 \family default
5306 \family default
5328 tells it to look for an rcfile named
5307 tells it to look for an rcfile named
5329 \family typewriter
5308 \family typewriter
5330 ipythonrc-<name>
5309 ipythonrc-<name>
5331 \family default
5310 \family default
5332 .
5311 .
5333
5312
5334 \layout List
5313 \layout List
5335 \labelwidthstring 00.00.0000
5314 \labelwidthstring 00.00.0000
5336
5315
5337
5316
5338 \family typewriter
5317 \family typewriter
5339 \series bold
5318 \series bold
5340 import_mod\SpecialChar ~
5319 import_mod\SpecialChar ~
5341 <mod1>\SpecialChar ~
5320 <mod1>\SpecialChar ~
5342 <mod2>\SpecialChar ~
5321 <mod2>\SpecialChar ~
5343 ...
5322 ...
5344 \family default
5323 \family default
5345 \series default
5324 \series default
5346 : import modules with '
5325 : import modules with '
5347 \family typewriter
5326 \family typewriter
5348 import
5327 import
5349 \family default
5328 \family default
5350
5329
5351 \family typewriter
5330 \family typewriter
5352 <mod1>,<mod2>,...
5331 <mod1>,<mod2>,...
5353 \family default
5332 \family default
5354 '
5333 '
5355 \layout List
5334 \layout List
5356 \labelwidthstring 00.00.0000
5335 \labelwidthstring 00.00.0000
5357
5336
5358
5337
5359 \family typewriter
5338 \family typewriter
5360 \series bold
5339 \series bold
5361 import_some\SpecialChar ~
5340 import_some\SpecialChar ~
5362 <mod>\SpecialChar ~
5341 <mod>\SpecialChar ~
5363 <f1>\SpecialChar ~
5342 <f1>\SpecialChar ~
5364 <f2>\SpecialChar ~
5343 <f2>\SpecialChar ~
5365 ...
5344 ...
5366 \family default
5345 \family default
5367 \series default
5346 \series default
5368 : import functions with '
5347 : import functions with '
5369 \family typewriter
5348 \family typewriter
5370 from <mod> import
5349 from <mod> import
5371 \family default
5350 \family default
5372
5351
5373 \family typewriter
5352 \family typewriter
5374 <f1>,<f2>,...
5353 <f1>,<f2>,...
5375 \family default
5354 \family default
5376 '
5355 '
5377 \layout List
5356 \layout List
5378 \labelwidthstring 00.00.0000
5357 \labelwidthstring 00.00.0000
5379
5358
5380
5359
5381 \family typewriter
5360 \family typewriter
5382 \series bold
5361 \series bold
5383 import_all\SpecialChar ~
5362 import_all\SpecialChar ~
5384 <mod1>\SpecialChar ~
5363 <mod1>\SpecialChar ~
5385 <mod2>\SpecialChar ~
5364 <mod2>\SpecialChar ~
5386 ...
5365 ...
5387 \family default
5366 \family default
5388 \series default
5367 \series default
5389 : for each module listed import functions with '
5368 : for each module listed import functions with '
5390 \family typewriter
5369 \family typewriter
5391 from <mod> import *
5370 from <mod> import *
5392 \family default
5371 \family default
5393 '
5372 '
5394 \layout List
5373 \layout List
5395 \labelwidthstring 00.00.0000
5374 \labelwidthstring 00.00.0000
5396
5375
5397
5376
5398 \family typewriter
5377 \family typewriter
5399 \series bold
5378 \series bold
5400 execute\SpecialChar ~
5379 execute\SpecialChar ~
5401 <python\SpecialChar ~
5380 <python\SpecialChar ~
5402 code>
5381 code>
5403 \family default
5382 \family default
5404 \series default
5383 \series default
5405 : give any single-line python code to be executed.
5384 : give any single-line python code to be executed.
5406 \layout List
5385 \layout List
5407 \labelwidthstring 00.00.0000
5386 \labelwidthstring 00.00.0000
5408
5387
5409
5388
5410 \family typewriter
5389 \family typewriter
5411 \series bold
5390 \series bold
5412 execfile\SpecialChar ~
5391 execfile\SpecialChar ~
5413 <filename>
5392 <filename>
5414 \family default
5393 \family default
5415 \series default
5394 \series default
5416 : execute the python file given with an '
5395 : execute the python file given with an '
5417 \family typewriter
5396 \family typewriter
5418 execfile(filename)
5397 execfile(filename)
5419 \family default
5398 \family default
5420 ' command.
5399 ' command.
5421 Username expansion is performed on the given names.
5400 Username expansion is performed on the given names.
5422 So if you need any amount of extra fancy customization that won't fit in
5401 So if you need any amount of extra fancy customization that won't fit in
5423 any of the above 'canned' options, you can just put it in a separate python
5402 any of the above 'canned' options, you can just put it in a separate python
5424 file and execute it.
5403 file and execute it.
5425 \layout List
5404 \layout List
5426 \labelwidthstring 00.00.0000
5405 \labelwidthstring 00.00.0000
5427
5406
5428
5407
5429 \family typewriter
5408 \family typewriter
5430 \series bold
5409 \series bold
5431 alias\SpecialChar ~
5410 alias\SpecialChar ~
5432 <alias_def>
5411 <alias_def>
5433 \family default
5412 \family default
5434 \series default
5413 \series default
5435 : this is equivalent to calling '
5414 : this is equivalent to calling '
5436 \family typewriter
5415 \family typewriter
5437 %alias\SpecialChar ~
5416 %alias\SpecialChar ~
5438 <alias_def>
5417 <alias_def>
5439 \family default
5418 \family default
5440 ' at the IPython command line.
5419 ' at the IPython command line.
5441 This way, from within IPython you can do common system tasks without having
5420 This way, from within IPython you can do common system tasks without having
5442 to exit it or use the
5421 to exit it or use the
5443 \family typewriter
5422 \family typewriter
5444 !
5423 !
5445 \family default
5424 \family default
5446 escape.
5425 escape.
5447 IPython isn't meant to be a shell replacement, but it is often very useful
5426 IPython isn't meant to be a shell replacement, but it is often very useful
5448 to be able to do things with files while testing code.
5427 to be able to do things with files while testing code.
5449 This gives you the flexibility to have within IPython any aliases you may
5428 This gives you the flexibility to have within IPython any aliases you may
5450 be used to under your normal system shell.
5429 be used to under your normal system shell.
5451 \layout Subsection
5430 \layout Subsection
5452
5431
5453
5432
5454 \begin_inset LatexCommand \label{sec:ipytonrc-sample}
5433 \begin_inset LatexCommand \label{sec:ipytonrc-sample}
5455
5434
5456 \end_inset
5435 \end_inset
5457
5436
5458 Sample
5437 Sample
5459 \family typewriter
5438 \family typewriter
5460 ipythonrc
5439 ipythonrc
5461 \family default
5440 \family default
5462 file
5441 file
5463 \layout Standard
5442 \layout Standard
5464
5443
5465 The default rcfile, called
5444 The default rcfile, called
5466 \family typewriter
5445 \family typewriter
5467 ipythonrc
5446 ipythonrc
5468 \family default
5447 \family default
5469 and supplied in your
5448 and supplied in your
5470 \family typewriter
5449 \family typewriter
5471 IPYTHONDIR
5450 IPYTHONDIR
5472 \family default
5451 \family default
5473 directory contains lots of comments on all of these options.
5452 directory contains lots of comments on all of these options.
5474 We reproduce it here for reference:
5453 We reproduce it here for reference:
5475 \layout Standard
5454 \layout Standard
5476
5455
5477
5456
5478 \begin_inset ERT
5457 \begin_inset ERT
5479 status Open
5458 status Open
5480
5459
5481 \layout Standard
5460 \layout Standard
5482
5461
5483 \backslash
5462 \backslash
5484 codelist{../IPython/UserConfig/ipythonrc}
5463 codelist{../IPython/UserConfig/ipythonrc}
5485 \end_inset
5464 \end_inset
5486
5465
5487
5466
5488 \layout Subsection
5467 \layout Subsection
5489
5468
5490
5469
5491 \begin_inset LatexCommand \label{sec:prompts}
5470 \begin_inset LatexCommand \label{sec:prompts}
5492
5471
5493 \end_inset
5472 \end_inset
5494
5473
5495 Fine-tuning your prompt
5474 Fine-tuning your prompt
5496 \layout Standard
5475 \layout Standard
5497
5476
5498 IPython's prompts can be customized using a syntax similar to that of the
5477 IPython's prompts can be customized using a syntax similar to that of the
5499
5478
5500 \family typewriter
5479 \family typewriter
5501 bash
5480 bash
5502 \family default
5481 \family default
5503 shell.
5482 shell.
5504 Many of
5483 Many of
5505 \family typewriter
5484 \family typewriter
5506 bash
5485 bash
5507 \family default
5486 \family default
5508 's escapes are supported, as well as a few additional ones.
5487 's escapes are supported, as well as a few additional ones.
5509 We list them below:
5488 We list them below:
5510 \layout Description
5489 \layout Description
5511
5490
5512
5491
5513 \backslash
5492 \backslash
5514 # the prompt/history count number
5493 # the prompt/history count number
5515 \layout Description
5494 \layout Description
5516
5495
5517
5496
5518 \backslash
5497 \backslash
5519 D the prompt/history count, with the actual digits replaced by dots.
5498 D the prompt/history count, with the actual digits replaced by dots.
5520 Used mainly in continuation prompts (prompt_in2)
5499 Used mainly in continuation prompts (prompt_in2)
5521 \layout Description
5500 \layout Description
5522
5501
5523
5502
5524 \backslash
5503 \backslash
5525 w the current working directory
5504 w the current working directory
5526 \layout Description
5505 \layout Description
5527
5506
5528
5507
5529 \backslash
5508 \backslash
5530 W the basename of current working directory
5509 W the basename of current working directory
5531 \layout Description
5510 \layout Description
5532
5511
5533
5512
5534 \backslash
5513 \backslash
5535 X
5514 X
5536 \emph on
5515 \emph on
5537 n
5516 n
5538 \emph default
5517 \emph default
5539 where
5518 where
5540 \begin_inset Formula $n=0\ldots5.$
5519 \begin_inset Formula $n=0\ldots5.$
5541 \end_inset
5520 \end_inset
5542
5521
5543 The current working directory, with
5522 The current working directory, with
5544 \family typewriter
5523 \family typewriter
5545 $HOME
5524 $HOME
5546 \family default
5525 \family default
5547 replaced by
5526 replaced by
5548 \family typewriter
5527 \family typewriter
5549 ~
5528 ~
5550 \family default
5529 \family default
5551 , and filtered out to contain only
5530 , and filtered out to contain only
5552 \begin_inset Formula $n$
5531 \begin_inset Formula $n$
5553 \end_inset
5532 \end_inset
5554
5533
5555 path elements
5534 path elements
5556 \layout Description
5535 \layout Description
5557
5536
5558
5537
5559 \backslash
5538 \backslash
5560 Y
5539 Y
5561 \emph on
5540 \emph on
5562 n
5541 n
5563 \emph default
5542 \emph default
5564 Similar to
5543 Similar to
5565 \backslash
5544 \backslash
5566 X
5545 X
5567 \emph on
5546 \emph on
5568 n
5547 n
5569 \emph default
5548 \emph default
5570 , but with the
5549 , but with the
5571 \begin_inset Formula $n+1$
5550 \begin_inset Formula $n+1$
5572 \end_inset
5551 \end_inset
5573
5552
5574 element included if it is
5553 element included if it is
5575 \family typewriter
5554 \family typewriter
5576 ~
5555 ~
5577 \family default
5556 \family default
5578 (this is similar to the behavior of the %c
5557 (this is similar to the behavior of the %c
5579 \emph on
5558 \emph on
5580 n
5559 n
5581 \emph default
5560 \emph default
5582 escapes in
5561 escapes in
5583 \family typewriter
5562 \family typewriter
5584 tcsh
5563 tcsh
5585 \family default
5564 \family default
5586 )
5565 )
5587 \layout Description
5566 \layout Description
5588
5567
5589
5568
5590 \backslash
5569 \backslash
5591 u the username of the current user
5570 u the username of the current user
5592 \layout Description
5571 \layout Description
5593
5572
5594
5573
5595 \backslash
5574 \backslash
5596 $ if the effective UID is 0, a #, otherwise a $
5575 $ if the effective UID is 0, a #, otherwise a $
5597 \layout Description
5576 \layout Description
5598
5577
5599
5578
5600 \backslash
5579 \backslash
5601 h the hostname up to the first `.'
5580 h the hostname up to the first `.'
5602 \layout Description
5581 \layout Description
5603
5582
5604
5583
5605 \backslash
5584 \backslash
5606 H the hostname
5585 H the hostname
5607 \layout Description
5586 \layout Description
5608
5587
5609
5588
5610 \backslash
5589 \backslash
5611 n a newline
5590 n a newline
5612 \layout Description
5591 \layout Description
5613
5592
5614
5593
5615 \backslash
5594 \backslash
5616 r a carriage return
5595 r a carriage return
5617 \layout Description
5596 \layout Description
5618
5597
5619
5598
5620 \backslash
5599 \backslash
5621 v IPython version string
5600 v IPython version string
5622 \layout Standard
5601 \layout Standard
5623
5602
5624 In addition to these, ANSI color escapes can be insterted into the prompts,
5603 In addition to these, ANSI color escapes can be insterted into the prompts,
5625 as
5604 as
5626 \family typewriter
5605 \family typewriter
5627
5606
5628 \backslash
5607 \backslash
5629 C_
5608 C_
5630 \emph on
5609 \emph on
5631 ColorName
5610 ColorName
5632 \family default
5611 \family default
5633 \emph default
5612 \emph default
5634 .
5613 .
5635 The list of valid color names is: Black, Blue, Brown, Cyan, DarkGray, Green,
5614 The list of valid color names is: Black, Blue, Brown, Cyan, DarkGray, Green,
5636 LightBlue, LightCyan, LightGray, LightGreen, LightPurple, LightRed, NoColor,
5615 LightBlue, LightCyan, LightGray, LightGreen, LightPurple, LightRed, NoColor,
5637 Normal, Purple, Red, White, Yellow.
5616 Normal, Purple, Red, White, Yellow.
5638 \layout Standard
5617 \layout Standard
5639
5618
5640 Finally, IPython supports the evaluation of arbitrary expressions in your
5619 Finally, IPython supports the evaluation of arbitrary expressions in your
5641 prompt string.
5620 prompt string.
5642 The prompt strings are evaluated through the syntax of PEP 215, but basically
5621 The prompt strings are evaluated through the syntax of PEP 215, but basically
5643 you can use
5622 you can use
5644 \family typewriter
5623 \family typewriter
5645 $x.y
5624 $x.y
5646 \family default
5625 \family default
5647 to expand the value of
5626 to expand the value of
5648 \family typewriter
5627 \family typewriter
5649 x.y
5628 x.y
5650 \family default
5629 \family default
5651 , and for more complicated expressions you can use braces:
5630 , and for more complicated expressions you can use braces:
5652 \family typewriter
5631 \family typewriter
5653 ${foo()+x}
5632 ${foo()+x}
5654 \family default
5633 \family default
5655 will call function
5634 will call function
5656 \family typewriter
5635 \family typewriter
5657 foo
5636 foo
5658 \family default
5637 \family default
5659 and add to it the value of
5638 and add to it the value of
5660 \family typewriter
5639 \family typewriter
5661 x
5640 x
5662 \family default
5641 \family default
5663 , before putting the result into your prompt.
5642 , before putting the result into your prompt.
5664 For example, using
5643 For example, using
5665 \newline
5644 \newline
5666
5645
5667 \family typewriter
5646 \family typewriter
5668 prompt_in1 '${commands.getoutput("uptime")}
5647 prompt_in1 '${commands.getoutput("uptime")}
5669 \backslash
5648 \backslash
5670 nIn [
5649 nIn [
5671 \backslash
5650 \backslash
5672 #]: '
5651 #]: '
5673 \newline
5652 \newline
5674
5653
5675 \family default
5654 \family default
5676 will print the result of the uptime command on each prompt (assuming the
5655 will print the result of the uptime command on each prompt (assuming the
5677
5656
5678 \family typewriter
5657 \family typewriter
5679 commands
5658 commands
5680 \family default
5659 \family default
5681 module has been imported in your
5660 module has been imported in your
5682 \family typewriter
5661 \family typewriter
5683 ipythonrc
5662 ipythonrc
5684 \family default
5663 \family default
5685 file).
5664 file).
5686 \layout Subsubsection
5665 \layout Subsubsection
5687
5666
5688 Prompt examples
5667 Prompt examples
5689 \layout Standard
5668 \layout Standard
5690
5669
5691 The following options in an ipythonrc file will give you IPython's default
5670 The following options in an ipythonrc file will give you IPython's default
5692 prompts:
5671 prompts:
5693 \layout Standard
5672 \layout Standard
5694
5673
5695
5674
5696 \family typewriter
5675 \family typewriter
5697 prompt_in1 'In [
5676 prompt_in1 'In [
5698 \backslash
5677 \backslash
5699 #]:'
5678 #]:'
5700 \newline
5679 \newline
5701 prompt_in2 '\SpecialChar ~
5680 prompt_in2 '\SpecialChar ~
5702 \SpecialChar ~
5681 \SpecialChar ~
5703 \SpecialChar ~
5682 \SpecialChar ~
5704 .
5683 .
5705 \backslash
5684 \backslash
5706 D.:'
5685 D.:'
5707 \newline
5686 \newline
5708 prompt_out 'Out[
5687 prompt_out 'Out[
5709 \backslash
5688 \backslash
5710 #]:'
5689 #]:'
5711 \layout Standard
5690 \layout Standard
5712
5691
5713 which look like this:
5692 which look like this:
5714 \layout Standard
5693 \layout Standard
5715
5694
5716
5695
5717 \family typewriter
5696 \family typewriter
5718 In [1]: 1+2
5697 In [1]: 1+2
5719 \newline
5698 \newline
5720 Out[1]: 3
5699 Out[1]: 3
5721 \layout Standard
5700 \layout Standard
5722
5701
5723
5702
5724 \family typewriter
5703 \family typewriter
5725 In [2]: for i in (1,2,3):
5704 In [2]: for i in (1,2,3):
5726 \newline
5705 \newline
5727
5706
5728 \begin_inset ERT
5707 \begin_inset ERT
5729 status Collapsed
5708 status Collapsed
5730
5709
5731 \layout Standard
5710 \layout Standard
5732
5711
5733 \backslash
5712 \backslash
5734 hspace*{0mm}
5713 hspace*{0mm}
5735 \end_inset
5714 \end_inset
5736
5715
5737 \SpecialChar ~
5716 \SpecialChar ~
5738 \SpecialChar ~
5717 \SpecialChar ~
5739 \SpecialChar ~
5718 \SpecialChar ~
5740 ...: \SpecialChar ~
5719 ...: \SpecialChar ~
5741 \SpecialChar ~
5720 \SpecialChar ~
5742 \SpecialChar ~
5721 \SpecialChar ~
5743 \SpecialChar ~
5722 \SpecialChar ~
5744 print i,
5723 print i,
5745 \newline
5724 \newline
5746
5725
5747 \begin_inset ERT
5726 \begin_inset ERT
5748 status Collapsed
5727 status Collapsed
5749
5728
5750 \layout Standard
5729 \layout Standard
5751
5730
5752 \backslash
5731 \backslash
5753 hspace*{0mm}
5732 hspace*{0mm}
5754 \end_inset
5733 \end_inset
5755
5734
5756 \SpecialChar ~
5735 \SpecialChar ~
5757 \SpecialChar ~
5736 \SpecialChar ~
5758 \SpecialChar ~
5737 \SpecialChar ~
5759 ...:
5738 ...:
5760 \newline
5739 \newline
5761 1 2 3
5740 1 2 3
5762 \layout Standard
5741 \layout Standard
5763
5742
5764 These will give you a very colorful prompt with path information:
5743 These will give you a very colorful prompt with path information:
5765 \layout Standard
5744 \layout Standard
5766
5745
5767
5746
5768 \family typewriter
5747 \family typewriter
5769 #prompt_in1 '
5748 #prompt_in1 '
5770 \backslash
5749 \backslash
5771 C_Red
5750 C_Red
5772 \backslash
5751 \backslash
5773 u
5752 u
5774 \backslash
5753 \backslash
5775 C_Blue[
5754 C_Blue[
5776 \backslash
5755 \backslash
5777 C_Cyan
5756 C_Cyan
5778 \backslash
5757 \backslash
5779 Y1
5758 Y1
5780 \backslash
5759 \backslash
5781 C_Blue]
5760 C_Blue]
5782 \backslash
5761 \backslash
5783 C_LightGreen
5762 C_LightGreen
5784 \backslash
5763 \backslash
5785 #>'
5764 #>'
5786 \newline
5765 \newline
5787 prompt_in2 ' ..
5766 prompt_in2 ' ..
5788 \backslash
5767 \backslash
5789 D>'
5768 D>'
5790 \newline
5769 \newline
5791 prompt_out '<
5770 prompt_out '<
5792 \backslash
5771 \backslash
5793 #>'
5772 #>'
5794 \layout Standard
5773 \layout Standard
5795
5774
5796 which look like this:
5775 which look like this:
5797 \layout Standard
5776 \layout Standard
5798
5777
5799
5778
5800 \family typewriter
5779 \family typewriter
5801 \color red
5780 \color red
5802 fperez
5781 fperez
5803 \color blue
5782 \color blue
5804 [
5783 [
5805 \color cyan
5784 \color cyan
5806 ~/ipython
5785 ~/ipython
5807 \color blue
5786 \color blue
5808 ]
5787 ]
5809 \color green
5788 \color green
5810 1>
5789 1>
5811 \color default
5790 \color default
5812 1+2
5791 1+2
5813 \newline
5792 \newline
5814
5793
5815 \begin_inset ERT
5794 \begin_inset ERT
5816 status Collapsed
5795 status Collapsed
5817
5796
5818 \layout Standard
5797 \layout Standard
5819
5798
5820 \backslash
5799 \backslash
5821 hspace*{0mm}
5800 hspace*{0mm}
5822 \end_inset
5801 \end_inset
5823
5802
5824 \SpecialChar ~
5803 \SpecialChar ~
5825 \SpecialChar ~
5804 \SpecialChar ~
5826 \SpecialChar ~
5805 \SpecialChar ~
5827 \SpecialChar ~
5806 \SpecialChar ~
5828 \SpecialChar ~
5807 \SpecialChar ~
5829 \SpecialChar ~
5808 \SpecialChar ~
5830 \SpecialChar ~
5809 \SpecialChar ~
5831 \SpecialChar ~
5810 \SpecialChar ~
5832 \SpecialChar ~
5811 \SpecialChar ~
5833 \SpecialChar ~
5812 \SpecialChar ~
5834 \SpecialChar ~
5813 \SpecialChar ~
5835 \SpecialChar ~
5814 \SpecialChar ~
5836 \SpecialChar ~
5815 \SpecialChar ~
5837 \SpecialChar ~
5816 \SpecialChar ~
5838 \SpecialChar ~
5817 \SpecialChar ~
5839 \SpecialChar ~
5818 \SpecialChar ~
5840
5819
5841 \color red
5820 \color red
5842 <1>
5821 <1>
5843 \color default
5822 \color default
5844 3
5823 3
5845 \newline
5824 \newline
5846
5825
5847 \color red
5826 \color red
5848 fperez
5827 fperez
5849 \color blue
5828 \color blue
5850 [
5829 [
5851 \color cyan
5830 \color cyan
5852 ~/ipython
5831 ~/ipython
5853 \color blue
5832 \color blue
5854 ]
5833 ]
5855 \color green
5834 \color green
5856 2>
5835 2>
5857 \color default
5836 \color default
5858 for i in (1,2,3):
5837 for i in (1,2,3):
5859 \newline
5838 \newline
5860
5839
5861 \begin_inset ERT
5840 \begin_inset ERT
5862 status Collapsed
5841 status Collapsed
5863
5842
5864 \layout Standard
5843 \layout Standard
5865
5844
5866 \backslash
5845 \backslash
5867 hspace*{0mm}
5846 hspace*{0mm}
5868 \end_inset
5847 \end_inset
5869
5848
5870 \SpecialChar ~
5849 \SpecialChar ~
5871 \SpecialChar ~
5850 \SpecialChar ~
5872 \SpecialChar ~
5851 \SpecialChar ~
5873 \SpecialChar ~
5852 \SpecialChar ~
5874 \SpecialChar ~
5853 \SpecialChar ~
5875 \SpecialChar ~
5854 \SpecialChar ~
5876 \SpecialChar ~
5855 \SpecialChar ~
5877 \SpecialChar ~
5856 \SpecialChar ~
5878 \SpecialChar ~
5857 \SpecialChar ~
5879 \SpecialChar ~
5858 \SpecialChar ~
5880 \SpecialChar ~
5859 \SpecialChar ~
5881 \SpecialChar ~
5860 \SpecialChar ~
5882 \SpecialChar ~
5861 \SpecialChar ~
5883 \SpecialChar ~
5862 \SpecialChar ~
5884 \SpecialChar ~
5863 \SpecialChar ~
5885
5864
5886 \color green
5865 \color green
5887 ...>
5866 ...>
5888 \color default
5867 \color default
5889 \SpecialChar ~
5868 \SpecialChar ~
5890 \SpecialChar ~
5869 \SpecialChar ~
5891 \SpecialChar ~
5870 \SpecialChar ~
5892 \SpecialChar ~
5871 \SpecialChar ~
5893 print i,
5872 print i,
5894 \newline
5873 \newline
5895
5874
5896 \begin_inset ERT
5875 \begin_inset ERT
5897 status Collapsed
5876 status Collapsed
5898
5877
5899 \layout Standard
5878 \layout Standard
5900
5879
5901 \backslash
5880 \backslash
5902 hspace*{0mm}
5881 hspace*{0mm}
5903 \end_inset
5882 \end_inset
5904
5883
5905 \SpecialChar ~
5884 \SpecialChar ~
5906 \SpecialChar ~
5885 \SpecialChar ~
5907 \SpecialChar ~
5886 \SpecialChar ~
5908 \SpecialChar ~
5887 \SpecialChar ~
5909 \SpecialChar ~
5888 \SpecialChar ~
5910 \SpecialChar ~
5889 \SpecialChar ~
5911 \SpecialChar ~
5890 \SpecialChar ~
5912 \SpecialChar ~
5891 \SpecialChar ~
5913 \SpecialChar ~
5892 \SpecialChar ~
5914 \SpecialChar ~
5893 \SpecialChar ~
5915 \SpecialChar ~
5894 \SpecialChar ~
5916 \SpecialChar ~
5895 \SpecialChar ~
5917 \SpecialChar ~
5896 \SpecialChar ~
5918 \SpecialChar ~
5897 \SpecialChar ~
5919 \SpecialChar ~
5898 \SpecialChar ~
5920
5899
5921 \color green
5900 \color green
5922 ...>
5901 ...>
5923 \color default
5902 \color default
5924
5903
5925 \newline
5904 \newline
5926 1 2 3
5905 1 2 3
5927 \layout Standard
5906 \layout Standard
5928
5907
5929 The following shows the usage of dynamic expression evaluation:
5908 The following shows the usage of dynamic expression evaluation:
5930 \layout Subsection
5909 \layout Subsection
5931
5910
5932
5911
5933 \begin_inset LatexCommand \label{sec:profiles}
5912 \begin_inset LatexCommand \label{sec:profiles}
5934
5913
5935 \end_inset
5914 \end_inset
5936
5915
5937 IPython profiles
5916 IPython profiles
5938 \layout Standard
5917 \layout Standard
5939
5918
5940 As we already mentioned, IPython supports the
5919 As we already mentioned, IPython supports the
5941 \family typewriter
5920 \family typewriter
5942 -profile
5921 -profile
5943 \family default
5922 \family default
5944 command-line option (see sec.
5923 command-line option (see sec.
5945
5924
5946 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
5925 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
5947
5926
5948 \end_inset
5927 \end_inset
5949
5928
5950 ).
5929 ).
5951 A profile is nothing more than a particular configuration file like your
5930 A profile is nothing more than a particular configuration file like your
5952 basic
5931 basic
5953 \family typewriter
5932 \family typewriter
5954 ipythonrc
5933 ipythonrc
5955 \family default
5934 \family default
5956 one, but with particular customizations for a specific purpose.
5935 one, but with particular customizations for a specific purpose.
5957 When you start IPython with '
5936 When you start IPython with '
5958 \family typewriter
5937 \family typewriter
5959 ipython -profile <name>
5938 ipython -profile <name>
5960 \family default
5939 \family default
5961 ', it assumes that in your
5940 ', it assumes that in your
5962 \family typewriter
5941 \family typewriter
5963 IPYTHONDIR
5942 IPYTHONDIR
5964 \family default
5943 \family default
5965 there is a file called
5944 there is a file called
5966 \family typewriter
5945 \family typewriter
5967 ipythonrc-<name>
5946 ipythonrc-<name>
5968 \family default
5947 \family default
5969 , and loads it instead of the normal
5948 , and loads it instead of the normal
5970 \family typewriter
5949 \family typewriter
5971 ipythonrc
5950 ipythonrc
5972 \family default
5951 \family default
5973 .
5952 .
5974 \layout Standard
5953 \layout Standard
5975
5954
5976 This system allows you to maintain multiple configurations which load modules,
5955 This system allows you to maintain multiple configurations which load modules,
5977 set options, define functions, etc.
5956 set options, define functions, etc.
5978 suitable for different tasks and activate them in a very simple manner.
5957 suitable for different tasks and activate them in a very simple manner.
5979 In order to avoid having to repeat all of your basic options (common things
5958 In order to avoid having to repeat all of your basic options (common things
5980 that don't change such as your color preferences, for example), any profile
5959 that don't change such as your color preferences, for example), any profile
5981 can include another configuration file.
5960 can include another configuration file.
5982 The most common way to use profiles is then to have each one include your
5961 The most common way to use profiles is then to have each one include your
5983 basic
5962 basic
5984 \family typewriter
5963 \family typewriter
5985 ipythonrc
5964 ipythonrc
5986 \family default
5965 \family default
5987 file as a starting point, and then add further customizations.
5966 file as a starting point, and then add further customizations.
5988 \layout Standard
5967 \layout Standard
5989
5968
5990 In sections
5969 In sections
5991 \begin_inset LatexCommand \ref{sec:syntax-extensions}
5970 \begin_inset LatexCommand \ref{sec:syntax-extensions}
5992
5971
5993 \end_inset
5972 \end_inset
5994
5973
5995 and
5974 and
5996 \begin_inset LatexCommand \ref{sec:Gnuplot}
5975 \begin_inset LatexCommand \ref{sec:Gnuplot}
5997
5976
5998 \end_inset
5977 \end_inset
5999
5978
6000 we discuss some particular profiles which come as part of the standard
5979 we discuss some particular profiles which come as part of the standard
6001 IPython distribution.
5980 IPython distribution.
6002 You may also look in your
5981 You may also look in your
6003 \family typewriter
5982 \family typewriter
6004 IPYTHONDIR
5983 IPYTHONDIR
6005 \family default
5984 \family default
6006 directory, any file whose name begins with
5985 directory, any file whose name begins with
6007 \family typewriter
5986 \family typewriter
6008 ipythonrc-
5987 ipythonrc-
6009 \family default
5988 \family default
6010 is a profile.
5989 is a profile.
6011 You can use those as examples for further customizations to suit your own
5990 You can use those as examples for further customizations to suit your own
6012 needs.
5991 needs.
6013 \layout Section
5992 \layout Section
6014
5993
6015
5994
6016 \begin_inset OptArg
5995 \begin_inset OptArg
6017 collapsed false
5996 collapsed false
6018
5997
6019 \layout Standard
5998 \layout Standard
6020
5999
6021 IPython as default...
6000 IPython as default...
6022 \end_inset
6001 \end_inset
6023
6002
6024 IPython as your default Python environment
6003 IPython as your default Python environment
6025 \layout Standard
6004 \layout Standard
6026
6005
6027 Python honors the environment variable
6006 Python honors the environment variable
6028 \family typewriter
6007 \family typewriter
6029 PYTHONSTARTUP
6008 PYTHONSTARTUP
6030 \family default
6009 \family default
6031 and will execute at startup the file referenced by this variable.
6010 and will execute at startup the file referenced by this variable.
6032 If you put at the end of this file the following two lines of code:
6011 If you put at the end of this file the following two lines of code:
6033 \layout Standard
6012 \layout Standard
6034
6013
6035
6014
6036 \family typewriter
6015 \family typewriter
6037 import IPython
6016 import IPython
6038 \newline
6017 \newline
6039 IPython.Shell.IPShell().mainloop(sys_exit=1)
6018 IPython.Shell.IPShell().mainloop(sys_exit=1)
6040 \layout Standard
6019 \layout Standard
6041
6020
6042 then IPython will be your working environment anytime you start Python.
6021 then IPython will be your working environment anytime you start Python.
6043 The
6022 The
6044 \family typewriter
6023 \family typewriter
6045 sys_exit=1
6024 sys_exit=1
6046 \family default
6025 \family default
6047 is needed to have IPython issue a call to
6026 is needed to have IPython issue a call to
6048 \family typewriter
6027 \family typewriter
6049 sys.exit()
6028 sys.exit()
6050 \family default
6029 \family default
6051 when it finishes, otherwise you'll be back at the normal Python '
6030 when it finishes, otherwise you'll be back at the normal Python '
6052 \family typewriter
6031 \family typewriter
6053 >>>
6032 >>>
6054 \family default
6033 \family default
6055 ' prompt
6034 ' prompt
6056 \begin_inset Foot
6035 \begin_inset Foot
6057 collapsed true
6036 collapsed true
6058
6037
6059 \layout Standard
6038 \layout Standard
6060
6039
6061 Based on an idea by Holger Krekel.
6040 Based on an idea by Holger Krekel.
6062 \end_inset
6041 \end_inset
6063
6042
6064 .
6043 .
6065 \layout Standard
6044 \layout Standard
6066
6045
6067 This is probably useful to developers who manage multiple Python versions
6046 This is probably useful to developers who manage multiple Python versions
6068 and don't want to have correspondingly multiple IPython versions.
6047 and don't want to have correspondingly multiple IPython versions.
6069 Note that in this mode, there is no way to pass IPython any command-line
6048 Note that in this mode, there is no way to pass IPython any command-line
6070 options, as those are trapped first by Python itself.
6049 options, as those are trapped first by Python itself.
6071 \layout Section
6050 \layout Section
6072
6051
6073
6052
6074 \begin_inset LatexCommand \label{sec:embed}
6053 \begin_inset LatexCommand \label{sec:embed}
6075
6054
6076 \end_inset
6055 \end_inset
6077
6056
6078 Embedding IPython
6057 Embedding IPython
6079 \layout Standard
6058 \layout Standard
6080
6059
6081 It is possible to start an IPython instance
6060 It is possible to start an IPython instance
6082 \emph on
6061 \emph on
6083 inside
6062 inside
6084 \emph default
6063 \emph default
6085 your own Python programs.
6064 your own Python programs.
6086 This allows you to evaluate dynamically the state of your code, operate
6065 This allows you to evaluate dynamically the state of your code, operate
6087 with your variables, analyze them, etc.
6066 with your variables, analyze them, etc.
6088 Note however that any changes you make to values while in the shell do
6067 Note however that any changes you make to values while in the shell do
6089
6068
6090 \emph on
6069 \emph on
6091 not
6070 not
6092 \emph default
6071 \emph default
6093 propagate back to the running code, so it is safe to modify your values
6072 propagate back to the running code, so it is safe to modify your values
6094 because you won't break your code in bizarre ways by doing so.
6073 because you won't break your code in bizarre ways by doing so.
6095 \layout Standard
6074 \layout Standard
6096
6075
6097 This feature allows you to easily have a fully functional python environment
6076 This feature allows you to easily have a fully functional python environment
6098 for doing object introspection anywhere in your code with a simple function
6077 for doing object introspection anywhere in your code with a simple function
6099 call.
6078 call.
6100 In some cases a simple print statement is enough, but if you need to do
6079 In some cases a simple print statement is enough, but if you need to do
6101 more detailed analysis of a code fragment this feature can be very valuable.
6080 more detailed analysis of a code fragment this feature can be very valuable.
6102 \layout Standard
6081 \layout Standard
6103
6082
6104 It can also be useful in scientific computing situations where it is common
6083 It can also be useful in scientific computing situations where it is common
6105 to need to do some automatic, computationally intensive part and then stop
6084 to need to do some automatic, computationally intensive part and then stop
6106 to look at data, plots, etc
6085 to look at data, plots, etc
6107 \begin_inset Foot
6086 \begin_inset Foot
6108 collapsed true
6087 collapsed true
6109
6088
6110 \layout Standard
6089 \layout Standard
6111
6090
6112 This functionality was inspired by IDL's combination of the
6091 This functionality was inspired by IDL's combination of the
6113 \family typewriter
6092 \family typewriter
6114 stop
6093 stop
6115 \family default
6094 \family default
6116 keyword and the
6095 keyword and the
6117 \family typewriter
6096 \family typewriter
6118 .continue
6097 .continue
6119 \family default
6098 \family default
6120 executive command, which I have found very useful in the past, and by a
6099 executive command, which I have found very useful in the past, and by a
6121 posting on comp.lang.python by cmkl <cmkleffner-AT-gmx.de> on Dec.
6100 posting on comp.lang.python by cmkl <cmkleffner-AT-gmx.de> on Dec.
6122 06/01 concerning similar uses of pyrepl.
6101 06/01 concerning similar uses of pyrepl.
6123 \end_inset
6102 \end_inset
6124
6103
6125 .
6104 .
6126 Opening an IPython instance will give you full access to your data and
6105 Opening an IPython instance will give you full access to your data and
6127 functions, and you can resume program execution once you are done with
6106 functions, and you can resume program execution once you are done with
6128 the interactive part (perhaps to stop again later, as many times as needed).
6107 the interactive part (perhaps to stop again later, as many times as needed).
6129 \layout Standard
6108 \layout Standard
6130
6109
6131 The following code snippet is the bare minimum you need to include in your
6110 The following code snippet is the bare minimum you need to include in your
6132 Python programs for this to work (detailed examples follow later):
6111 Python programs for this to work (detailed examples follow later):
6133 \layout LyX-Code
6112 \layout LyX-Code
6134
6113
6135 from IPython.Shell import IPShellEmbed
6114 from IPython.Shell import IPShellEmbed
6136 \layout LyX-Code
6115 \layout LyX-Code
6137
6116
6138 ipshell = IPShellEmbed()
6117 ipshell = IPShellEmbed()
6139 \layout LyX-Code
6118 \layout LyX-Code
6140
6119
6141 ipshell() # this call anywhere in your program will start IPython
6120 ipshell() # this call anywhere in your program will start IPython
6142 \layout Standard
6121 \layout Standard
6143
6122
6144 You can run embedded instances even in code which is itself being run at
6123 You can run embedded instances even in code which is itself being run at
6145 the IPython interactive prompt with '
6124 the IPython interactive prompt with '
6146 \family typewriter
6125 \family typewriter
6147 %run\SpecialChar ~
6126 %run\SpecialChar ~
6148 <filename>
6127 <filename>
6149 \family default
6128 \family default
6150 '.
6129 '.
6151 Since it's easy to get lost as to where you are (in your top-level IPython
6130 Since it's easy to get lost as to where you are (in your top-level IPython
6152 or in your embedded one), it's a good idea in such cases to set the in/out
6131 or in your embedded one), it's a good idea in such cases to set the in/out
6153 prompts to something different for the embedded instances.
6132 prompts to something different for the embedded instances.
6154 The code examples below illustrate this.
6133 The code examples below illustrate this.
6155 \layout Standard
6134 \layout Standard
6156
6135
6157 You can also have multiple IPython instances in your program and open them
6136 You can also have multiple IPython instances in your program and open them
6158 separately, for example with different options for data presentation.
6137 separately, for example with different options for data presentation.
6159 If you close and open the same instance multiple times, its prompt counters
6138 If you close and open the same instance multiple times, its prompt counters
6160 simply continue from each execution to the next.
6139 simply continue from each execution to the next.
6161 \layout Standard
6140 \layout Standard
6162
6141
6163 Please look at the docstrings in the
6142 Please look at the docstrings in the
6164 \family typewriter
6143 \family typewriter
6165 Shell.py
6144 Shell.py
6166 \family default
6145 \family default
6167 module for more details on the use of this system.
6146 module for more details on the use of this system.
6168 \layout Standard
6147 \layout Standard
6169
6148
6170 The following sample file illustrating how to use the embedding functionality
6149 The following sample file illustrating how to use the embedding functionality
6171 is provided in the examples directory as
6150 is provided in the examples directory as
6172 \family typewriter
6151 \family typewriter
6173 example-embed.py
6152 example-embed.py
6174 \family default
6153 \family default
6175 .
6154 .
6176 It should be fairly self-explanatory:
6155 It should be fairly self-explanatory:
6177 \layout Standard
6156 \layout Standard
6178
6157
6179
6158
6180 \begin_inset ERT
6159 \begin_inset ERT
6181 status Open
6160 status Open
6182
6161
6183 \layout Standard
6162 \layout Standard
6184
6163
6185 \backslash
6164 \backslash
6186 codelist{examples/example-embed.py}
6165 codelist{examples/example-embed.py}
6187 \end_inset
6166 \end_inset
6188
6167
6189
6168
6190 \layout Standard
6169 \layout Standard
6191
6170
6192 Once you understand how the system functions, you can use the following
6171 Once you understand how the system functions, you can use the following
6193 code fragments in your programs which are ready for cut and paste:
6172 code fragments in your programs which are ready for cut and paste:
6194 \layout Standard
6173 \layout Standard
6195
6174
6196
6175
6197 \begin_inset ERT
6176 \begin_inset ERT
6198 status Open
6177 status Open
6199
6178
6200 \layout Standard
6179 \layout Standard
6201
6180
6202 \backslash
6181 \backslash
6203 codelist{examples/example-embed-short.py}
6182 codelist{examples/example-embed-short.py}
6204 \end_inset
6183 \end_inset
6205
6184
6206
6185
6207 \layout Section
6186 \layout Section
6208
6187
6209
6188
6210 \begin_inset LatexCommand \label{sec:using-pdb}
6189 \begin_inset LatexCommand \label{sec:using-pdb}
6211
6190
6212 \end_inset
6191 \end_inset
6213
6192
6214 Using the Python debugger (
6193 Using the Python debugger (
6215 \family typewriter
6194 \family typewriter
6216 pdb
6195 pdb
6217 \family default
6196 \family default
6218 )
6197 )
6219 \layout Subsection
6198 \layout Subsection
6220
6199
6221 Running entire programs via
6200 Running entire programs via
6222 \family typewriter
6201 \family typewriter
6223 pdb
6202 pdb
6224 \layout Standard
6203 \layout Standard
6225
6204
6226
6205
6227 \family typewriter
6206 \family typewriter
6228 pdb
6207 pdb
6229 \family default
6208 \family default
6230 , the Python debugger, is a powerful interactive debugger which allows you
6209 , the Python debugger, is a powerful interactive debugger which allows you
6231 to step through code, set breakpoints, watch variables, etc.
6210 to step through code, set breakpoints, watch variables, etc.
6232 IPython makes it very easy to start any script under the control of
6211 IPython makes it very easy to start any script under the control of
6233 \family typewriter
6212 \family typewriter
6234 pdb
6213 pdb
6235 \family default
6214 \family default
6236 , regardless of whether you have wrapped it into a
6215 , regardless of whether you have wrapped it into a
6237 \family typewriter
6216 \family typewriter
6238 `main()'
6217 `main()'
6239 \family default
6218 \family default
6240 function or not.
6219 function or not.
6241 For this, simply type
6220 For this, simply type
6242 \family typewriter
6221 \family typewriter
6243 `%run -d myscript'
6222 `%run -d myscript'
6244 \family default
6223 \family default
6245 at an IPython prompt.
6224 at an IPython prompt.
6246 See the
6225 See the
6247 \family typewriter
6226 \family typewriter
6248 %run
6227 %run
6249 \family default
6228 \family default
6250 command's documentation (via
6229 command's documentation (via
6251 \family typewriter
6230 \family typewriter
6252 `%run?'
6231 `%run?'
6253 \family default
6232 \family default
6254 or in Sec.\SpecialChar ~
6233 or in Sec.\SpecialChar ~
6255
6234
6256 \begin_inset LatexCommand \ref{sec:magic}
6235 \begin_inset LatexCommand \ref{sec:magic}
6257
6236
6258 \end_inset
6237 \end_inset
6259
6238
6260 ) for more details, including how to control where
6239 ) for more details, including how to control where
6261 \family typewriter
6240 \family typewriter
6262 pdb
6241 pdb
6263 \family default
6242 \family default
6264 will stop execution first.
6243 will stop execution first.
6265 \layout Standard
6244 \layout Standard
6266
6245
6267 For more information on the use of the
6246 For more information on the use of the
6268 \family typewriter
6247 \family typewriter
6269 pdb
6248 pdb
6270 \family default
6249 \family default
6271 debugger, read the included
6250 debugger, read the included
6272 \family typewriter
6251 \family typewriter
6273 pdb.doc
6252 pdb.doc
6274 \family default
6253 \family default
6275 file (part of the standard Python distribution).
6254 file (part of the standard Python distribution).
6276 On a stock Linux system it is located at
6255 On a stock Linux system it is located at
6277 \family typewriter
6256 \family typewriter
6278 /usr/lib/python2.3/pdb.doc
6257 /usr/lib/python2.3/pdb.doc
6279 \family default
6258 \family default
6280 , but the easiest way to read it is by using the
6259 , but the easiest way to read it is by using the
6281 \family typewriter
6260 \family typewriter
6282 help()
6261 help()
6283 \family default
6262 \family default
6284 function of the
6263 function of the
6285 \family typewriter
6264 \family typewriter
6286 pdb
6265 pdb
6287 \family default
6266 \family default
6288 module as follows (in an IPython prompt):
6267 module as follows (in an IPython prompt):
6289 \layout Standard
6268 \layout Standard
6290
6269
6291
6270
6292 \family typewriter
6271 \family typewriter
6293 In [1]: import pdb
6272 In [1]: import pdb
6294 \newline
6273 \newline
6295 In [2]: pdb.help()
6274 In [2]: pdb.help()
6296 \layout Standard
6275 \layout Standard
6297
6276
6298 This will load the
6277 This will load the
6299 \family typewriter
6278 \family typewriter
6300 pdb.doc
6279 pdb.doc
6301 \family default
6280 \family default
6302 document in a file viewer for you automatically.
6281 document in a file viewer for you automatically.
6303 \layout Subsection
6282 \layout Subsection
6304
6283
6305 Automatic invocation of
6284 Automatic invocation of
6306 \family typewriter
6285 \family typewriter
6307 pdb
6286 pdb
6308 \family default
6287 \family default
6309 on exceptions
6288 on exceptions
6310 \layout Standard
6289 \layout Standard
6311
6290
6312 IPython, if started with the
6291 IPython, if started with the
6313 \family typewriter
6292 \family typewriter
6314 -pdb
6293 -pdb
6315 \family default
6294 \family default
6316 option (or if the option is set in your rc file) can call the Python
6295 option (or if the option is set in your rc file) can call the Python
6317 \family typewriter
6296 \family typewriter
6318 pdb
6297 pdb
6319 \family default
6298 \family default
6320 debugger every time your code triggers an uncaught exception
6299 debugger every time your code triggers an uncaught exception
6321 \begin_inset Foot
6300 \begin_inset Foot
6322 collapsed true
6301 collapsed true
6323
6302
6324 \layout Standard
6303 \layout Standard
6325
6304
6326 Many thanks to Christopher Hart for the request which prompted adding this
6305 Many thanks to Christopher Hart for the request which prompted adding this
6327 feature to IPython.
6306 feature to IPython.
6328 \end_inset
6307 \end_inset
6329
6308
6330 .
6309 .
6331 This feature can also be toggled at any time with the
6310 This feature can also be toggled at any time with the
6332 \family typewriter
6311 \family typewriter
6333 %pdb
6312 %pdb
6334 \family default
6313 \family default
6335 magic command.
6314 magic command.
6336 This can be extremely useful in order to find the origin of subtle bugs,
6315 This can be extremely useful in order to find the origin of subtle bugs,
6337 because
6316 because
6338 \family typewriter
6317 \family typewriter
6339 pdb
6318 pdb
6340 \family default
6319 \family default
6341 opens up at the point in your code which triggered the exception, and while
6320 opens up at the point in your code which triggered the exception, and while
6342 your program is at this point `dead', all the data is still available and
6321 your program is at this point `dead', all the data is still available and
6343 you can walk up and down the stack frame and understand the origin of the
6322 you can walk up and down the stack frame and understand the origin of the
6344 problem.
6323 problem.
6345 \layout Standard
6324 \layout Standard
6346
6325
6347 Furthermore, you can use these debugging facilities both with the embedded
6326 Furthermore, you can use these debugging facilities both with the embedded
6348 IPython mode and without IPython at all.
6327 IPython mode and without IPython at all.
6349 For an embedded shell (see sec.
6328 For an embedded shell (see sec.
6350
6329
6351 \begin_inset LatexCommand \ref{sec:embed}
6330 \begin_inset LatexCommand \ref{sec:embed}
6352
6331
6353 \end_inset
6332 \end_inset
6354
6333
6355 ), simply call the constructor with
6334 ), simply call the constructor with
6356 \family typewriter
6335 \family typewriter
6357 `-pdb'
6336 `-pdb'
6358 \family default
6337 \family default
6359 in the argument string and automatically
6338 in the argument string and automatically
6360 \family typewriter
6339 \family typewriter
6361 pdb
6340 pdb
6362 \family default
6341 \family default
6363 will be called if an uncaught exception is triggered by your code.
6342 will be called if an uncaught exception is triggered by your code.
6364
6343
6365 \layout Standard
6344 \layout Standard
6366
6345
6367 For stand-alone use of the feature in your programs which do not use IPython
6346 For stand-alone use of the feature in your programs which do not use IPython
6368 at all, put the following lines toward the top of your `main' routine:
6347 at all, put the following lines toward the top of your `main' routine:
6369 \layout Standard
6348 \layout Standard
6370 \align left
6349 \align left
6371
6350
6372 \family typewriter
6351 \family typewriter
6373 import sys,IPython.ultraTB
6352 import sys,IPython.ultraTB
6374 \newline
6353 \newline
6375 sys.excepthook = IPython.ultraTB.FormattedTB(mode=`Verbose', color_scheme=`Linux',
6354 sys.excepthook = IPython.ultraTB.FormattedTB(mode=`Verbose', color_scheme=`Linux',
6376 call_pdb=1)
6355 call_pdb=1)
6377 \layout Standard
6356 \layout Standard
6378
6357
6379 The
6358 The
6380 \family typewriter
6359 \family typewriter
6381 mode
6360 mode
6382 \family default
6361 \family default
6383 keyword can be either
6362 keyword can be either
6384 \family typewriter
6363 \family typewriter
6385 `Verbose'
6364 `Verbose'
6386 \family default
6365 \family default
6387 or
6366 or
6388 \family typewriter
6367 \family typewriter
6389 `Plain'
6368 `Plain'
6390 \family default
6369 \family default
6391 , giving either very detailed or normal tracebacks respectively.
6370 , giving either very detailed or normal tracebacks respectively.
6392 The
6371 The
6393 \family typewriter
6372 \family typewriter
6394 color_scheme
6373 color_scheme
6395 \family default
6374 \family default
6396 keyword can be one of
6375 keyword can be one of
6397 \family typewriter
6376 \family typewriter
6398 `NoColor'
6377 `NoColor'
6399 \family default
6378 \family default
6400 ,
6379 ,
6401 \family typewriter
6380 \family typewriter
6402 `Linux'
6381 `Linux'
6403 \family default
6382 \family default
6404 (default) or
6383 (default) or
6405 \family typewriter
6384 \family typewriter
6406 `LightBG'
6385 `LightBG'
6407 \family default
6386 \family default
6408 .
6387 .
6409 These are the same options which can be set in IPython with
6388 These are the same options which can be set in IPython with
6410 \family typewriter
6389 \family typewriter
6411 -colors
6390 -colors
6412 \family default
6391 \family default
6413 and
6392 and
6414 \family typewriter
6393 \family typewriter
6415 -xmode
6394 -xmode
6416 \family default
6395 \family default
6417 .
6396 .
6418 \layout Standard
6397 \layout Standard
6419
6398
6420 This will give any of your programs detailed, colored tracebacks with automatic
6399 This will give any of your programs detailed, colored tracebacks with automatic
6421 invocation of
6400 invocation of
6422 \family typewriter
6401 \family typewriter
6423 pdb
6402 pdb
6424 \family default
6403 \family default
6425 .
6404 .
6426 \layout Section
6405 \layout Section
6427
6406
6428
6407
6429 \begin_inset LatexCommand \label{sec:syntax-extensions}
6408 \begin_inset LatexCommand \label{sec:syntax-extensions}
6430
6409
6431 \end_inset
6410 \end_inset
6432
6411
6433 Extensions for syntax processing
6412 Extensions for syntax processing
6434 \layout Standard
6413 \layout Standard
6435
6414
6436 This isn't for the faint of heart, because the potential for breaking things
6415 This isn't for the faint of heart, because the potential for breaking things
6437 is quite high.
6416 is quite high.
6438 But it can be a very powerful and useful feature.
6417 But it can be a very powerful and useful feature.
6439 In a nutshell, you can redefine the way IPython processes the user input
6418 In a nutshell, you can redefine the way IPython processes the user input
6440 line to accept new, special extensions to the syntax without needing to
6419 line to accept new, special extensions to the syntax without needing to
6441 change any of IPython's own code.
6420 change any of IPython's own code.
6442 \layout Standard
6421 \layout Standard
6443
6422
6444 In the
6423 In the
6445 \family typewriter
6424 \family typewriter
6446 IPython/Extensions
6425 IPython/Extensions
6447 \family default
6426 \family default
6448 directory you will find some examples supplied, which we will briefly describe
6427 directory you will find some examples supplied, which we will briefly describe
6449 now.
6428 now.
6450 These can be used `as is' (and both provide very useful functionality),
6429 These can be used `as is' (and both provide very useful functionality),
6451 or you can use them as a starting point for writing your own extensions.
6430 or you can use them as a starting point for writing your own extensions.
6452 \layout Subsection
6431 \layout Subsection
6453
6432
6454 Pasting of code starting with
6433 Pasting of code starting with
6455 \family typewriter
6434 \family typewriter
6456 `>>>
6435 `>>>
6457 \family default
6436 \family default
6458 ' or
6437 ' or
6459 \family typewriter
6438 \family typewriter
6460 `...
6439 `...
6461
6440
6462 \family default
6441 \family default
6463 '
6442 '
6464 \layout Standard
6443 \layout Standard
6465
6444
6466 In the python tutorial it is common to find code examples which have been
6445 In the python tutorial it is common to find code examples which have been
6467 taken from real python sessions.
6446 taken from real python sessions.
6468 The problem with those is that all the lines begin with either
6447 The problem with those is that all the lines begin with either
6469 \family typewriter
6448 \family typewriter
6470 `>>>
6449 `>>>
6471 \family default
6450 \family default
6472 ' or
6451 ' or
6473 \family typewriter
6452 \family typewriter
6474 `...
6453 `...
6475
6454
6476 \family default
6455 \family default
6477 ', which makes it impossible to paste them all at once.
6456 ', which makes it impossible to paste them all at once.
6478 One must instead do a line by line manual copying, carefully removing the
6457 One must instead do a line by line manual copying, carefully removing the
6479 leading extraneous characters.
6458 leading extraneous characters.
6480 \layout Standard
6459 \layout Standard
6481
6460
6482 This extension identifies those starting characters and removes them from
6461 This extension identifies those starting characters and removes them from
6483 the input automatically, so that one can paste multi-line examples directly
6462 the input automatically, so that one can paste multi-line examples directly
6484 into IPython, saving a lot of time.
6463 into IPython, saving a lot of time.
6485 Please look at the file
6464 Please look at the file
6486 \family typewriter
6465 \family typewriter
6487 InterpreterPasteInput.py
6466 InterpreterPasteInput.py
6488 \family default
6467 \family default
6489 in the
6468 in the
6490 \family typewriter
6469 \family typewriter
6491 IPython/Extensions
6470 IPython/Extensions
6492 \family default
6471 \family default
6493 directory for details on how this is done.
6472 directory for details on how this is done.
6494 \layout Standard
6473 \layout Standard
6495
6474
6496 IPython comes with a special profile enabling this feature, called
6475 IPython comes with a special profile enabling this feature, called
6497 \family typewriter
6476 \family typewriter
6498 tutorial
6477 tutorial
6499 \family default
6478 \family default
6500 \emph on
6479 \emph on
6501 .
6480 .
6502
6481
6503 \emph default
6482 \emph default
6504 Simply start IPython via
6483 Simply start IPython via
6505 \family typewriter
6484 \family typewriter
6506 `ipython\SpecialChar ~
6485 `ipython\SpecialChar ~
6507 -p\SpecialChar ~
6486 -p\SpecialChar ~
6508 tutorial'
6487 tutorial'
6509 \family default
6488 \family default
6510 and the feature will be available.
6489 and the feature will be available.
6511 In a normal IPython session you can activate the feature by importing the
6490 In a normal IPython session you can activate the feature by importing the
6512 corresponding module with:
6491 corresponding module with:
6513 \newline
6492 \newline
6514
6493
6515 \family typewriter
6494 \family typewriter
6516 In [1]: import IPython.Extensions.InterpreterPasteInput
6495 In [1]: import IPython.Extensions.InterpreterPasteInput
6517 \layout Standard
6496 \layout Standard
6518
6497
6519 The following is a 'screenshot' of how things work when this extension is
6498 The following is a 'screenshot' of how things work when this extension is
6520 on, copying an example from the standard tutorial:
6499 on, copying an example from the standard tutorial:
6521 \layout Standard
6500 \layout Standard
6522
6501
6523
6502
6524 \family typewriter
6503 \family typewriter
6525 IPython profile: tutorial
6504 IPython profile: tutorial
6526 \newline
6505 \newline
6527 \SpecialChar ~
6506 \SpecialChar ~
6528
6507
6529 \newline
6508 \newline
6530 *** Pasting of code with ">>>" or "..." has been enabled.
6509 *** Pasting of code with ">>>" or "..." has been enabled.
6531 \newline
6510 \newline
6532 \SpecialChar ~
6511 \SpecialChar ~
6533
6512
6534 \newline
6513 \newline
6535 In [1]: >>> def fib2(n): # return Fibonacci series up to n
6514 In [1]: >>> def fib2(n): # return Fibonacci series up to n
6536 \newline
6515 \newline
6537
6516
6538 \begin_inset ERT
6517 \begin_inset ERT
6539 status Collapsed
6518 status Collapsed
6540
6519
6541 \layout Standard
6520 \layout Standard
6542
6521
6543 \backslash
6522 \backslash
6544 hspace*{0mm}
6523 hspace*{0mm}
6545 \end_inset
6524 \end_inset
6546
6525
6547 \SpecialChar ~
6526 \SpecialChar ~
6548 \SpecialChar ~
6527 \SpecialChar ~
6549 ...: ...\SpecialChar ~
6528 ...: ...\SpecialChar ~
6550 \SpecialChar ~
6529 \SpecialChar ~
6551 \SpecialChar ~
6530 \SpecialChar ~
6552 \SpecialChar ~
6531 \SpecialChar ~
6553 """Return a list containing the Fibonacci series up to n."""
6532 """Return a list containing the Fibonacci series up to n."""
6554 \newline
6533 \newline
6555
6534
6556 \begin_inset ERT
6535 \begin_inset ERT
6557 status Collapsed
6536 status Collapsed
6558
6537
6559 \layout Standard
6538 \layout Standard
6560
6539
6561 \backslash
6540 \backslash
6562 hspace*{0mm}
6541 hspace*{0mm}
6563 \end_inset
6542 \end_inset
6564
6543
6565 \SpecialChar ~
6544 \SpecialChar ~
6566 \SpecialChar ~
6545 \SpecialChar ~
6567 ...: ...\SpecialChar ~
6546 ...: ...\SpecialChar ~
6568 \SpecialChar ~
6547 \SpecialChar ~
6569 \SpecialChar ~
6548 \SpecialChar ~
6570 \SpecialChar ~
6549 \SpecialChar ~
6571 result = []
6550 result = []
6572 \newline
6551 \newline
6573
6552
6574 \begin_inset ERT
6553 \begin_inset ERT
6575 status Collapsed
6554 status Collapsed
6576
6555
6577 \layout Standard
6556 \layout Standard
6578
6557
6579 \backslash
6558 \backslash
6580 hspace*{0mm}
6559 hspace*{0mm}
6581 \end_inset
6560 \end_inset
6582
6561
6583 \SpecialChar ~
6562 \SpecialChar ~
6584 \SpecialChar ~
6563 \SpecialChar ~
6585 ...: ...\SpecialChar ~
6564 ...: ...\SpecialChar ~
6586 \SpecialChar ~
6565 \SpecialChar ~
6587 \SpecialChar ~
6566 \SpecialChar ~
6588 \SpecialChar ~
6567 \SpecialChar ~
6589 a, b = 0, 1
6568 a, b = 0, 1
6590 \newline
6569 \newline
6591
6570
6592 \begin_inset ERT
6571 \begin_inset ERT
6593 status Collapsed
6572 status Collapsed
6594
6573
6595 \layout Standard
6574 \layout Standard
6596
6575
6597 \backslash
6576 \backslash
6598 hspace*{0mm}
6577 hspace*{0mm}
6599 \end_inset
6578 \end_inset
6600
6579
6601 \SpecialChar ~
6580 \SpecialChar ~
6602 \SpecialChar ~
6581 \SpecialChar ~
6603 ...: ...\SpecialChar ~
6582 ...: ...\SpecialChar ~
6604 \SpecialChar ~
6583 \SpecialChar ~
6605 \SpecialChar ~
6584 \SpecialChar ~
6606 \SpecialChar ~
6585 \SpecialChar ~
6607 while b < n:
6586 while b < n:
6608 \newline
6587 \newline
6609
6588
6610 \begin_inset ERT
6589 \begin_inset ERT
6611 status Collapsed
6590 status Collapsed
6612
6591
6613 \layout Standard
6592 \layout Standard
6614
6593
6615 \backslash
6594 \backslash
6616 hspace*{0mm}
6595 hspace*{0mm}
6617 \end_inset
6596 \end_inset
6618
6597
6619 \SpecialChar ~
6598 \SpecialChar ~
6620 \SpecialChar ~
6599 \SpecialChar ~
6621 ...: ...\SpecialChar ~
6600 ...: ...\SpecialChar ~
6622 \SpecialChar ~
6601 \SpecialChar ~
6623 \SpecialChar ~
6602 \SpecialChar ~
6624 \SpecialChar ~
6603 \SpecialChar ~
6625 \SpecialChar ~
6604 \SpecialChar ~
6626 \SpecialChar ~
6605 \SpecialChar ~
6627 \SpecialChar ~
6606 \SpecialChar ~
6628 \SpecialChar ~
6607 \SpecialChar ~
6629 result.append(b)\SpecialChar ~
6608 result.append(b)\SpecialChar ~
6630 \SpecialChar ~
6609 \SpecialChar ~
6631 \SpecialChar ~
6610 \SpecialChar ~
6632 # see below
6611 # see below
6633 \newline
6612 \newline
6634
6613
6635 \begin_inset ERT
6614 \begin_inset ERT
6636 status Collapsed
6615 status Collapsed
6637
6616
6638 \layout Standard
6617 \layout Standard
6639
6618
6640 \backslash
6619 \backslash
6641 hspace*{0mm}
6620 hspace*{0mm}
6642 \end_inset
6621 \end_inset
6643
6622
6644 \SpecialChar ~
6623 \SpecialChar ~
6645 \SpecialChar ~
6624 \SpecialChar ~
6646 ...: ...\SpecialChar ~
6625 ...: ...\SpecialChar ~
6647 \SpecialChar ~
6626 \SpecialChar ~
6648 \SpecialChar ~
6627 \SpecialChar ~
6649 \SpecialChar ~
6628 \SpecialChar ~
6650 \SpecialChar ~
6629 \SpecialChar ~
6651 \SpecialChar ~
6630 \SpecialChar ~
6652 \SpecialChar ~
6631 \SpecialChar ~
6653 \SpecialChar ~
6632 \SpecialChar ~
6654 a, b = b, a+b
6633 a, b = b, a+b
6655 \newline
6634 \newline
6656
6635
6657 \begin_inset ERT
6636 \begin_inset ERT
6658 status Collapsed
6637 status Collapsed
6659
6638
6660 \layout Standard
6639 \layout Standard
6661
6640
6662 \backslash
6641 \backslash
6663 hspace*{0mm}
6642 hspace*{0mm}
6664 \end_inset
6643 \end_inset
6665
6644
6666 \SpecialChar ~
6645 \SpecialChar ~
6667 \SpecialChar ~
6646 \SpecialChar ~
6668 ...: ...\SpecialChar ~
6647 ...: ...\SpecialChar ~
6669 \SpecialChar ~
6648 \SpecialChar ~
6670 \SpecialChar ~
6649 \SpecialChar ~
6671 \SpecialChar ~
6650 \SpecialChar ~
6672 return result
6651 return result
6673 \newline
6652 \newline
6674
6653
6675 \begin_inset ERT
6654 \begin_inset ERT
6676 status Collapsed
6655 status Collapsed
6677
6656
6678 \layout Standard
6657 \layout Standard
6679
6658
6680 \backslash
6659 \backslash
6681 hspace*{0mm}
6660 hspace*{0mm}
6682 \end_inset
6661 \end_inset
6683
6662
6684 \SpecialChar ~
6663 \SpecialChar ~
6685 \SpecialChar ~
6664 \SpecialChar ~
6686 ...:
6665 ...:
6687 \newline
6666 \newline
6688 \SpecialChar ~
6667 \SpecialChar ~
6689
6668
6690 \newline
6669 \newline
6691 In [2]: fib2(10)
6670 In [2]: fib2(10)
6692 \newline
6671 \newline
6693 Out[2]: [1, 1, 2, 3, 5, 8]
6672 Out[2]: [1, 1, 2, 3, 5, 8]
6694 \layout Standard
6673 \layout Standard
6695
6674
6696 Note that as currently written, this extension does
6675 Note that as currently written, this extension does
6697 \emph on
6676 \emph on
6698 not
6677 not
6699 \emph default
6678 \emph default
6700 recognize IPython's prompts for pasting.
6679 recognize IPython's prompts for pasting.
6701 Those are more complicated, since the user can change them very easily,
6680 Those are more complicated, since the user can change them very easily,
6702 they involve numbers and can vary in length.
6681 they involve numbers and can vary in length.
6703 One could however extract all the relevant information from the IPython
6682 One could however extract all the relevant information from the IPython
6704 instance and build an appropriate regular expression.
6683 instance and build an appropriate regular expression.
6705 This is left as an exercise for the reader.
6684 This is left as an exercise for the reader.
6706 \layout Subsection
6685 \layout Subsection
6707
6686
6708 Input of physical quantities with units
6687 Input of physical quantities with units
6709 \layout Standard
6688 \layout Standard
6710
6689
6711 The module
6690 The module
6712 \family typewriter
6691 \family typewriter
6713 PhysicalQInput
6692 PhysicalQInput
6714 \family default
6693 \family default
6715 allows a simplified form of input for physical quantities with units.
6694 allows a simplified form of input for physical quantities with units.
6716 This file is meant to be used in conjunction with the
6695 This file is meant to be used in conjunction with the
6717 \family typewriter
6696 \family typewriter
6718 PhysicalQInteractive
6697 PhysicalQInteractive
6719 \family default
6698 \family default
6720 module (in the same directory) and
6699 module (in the same directory) and
6721 \family typewriter
6700 \family typewriter
6722 Physics.PhysicalQuantities
6701 Physics.PhysicalQuantities
6723 \family default
6702 \family default
6724 from Konrad Hinsen's ScientificPython (
6703 from Konrad Hinsen's ScientificPython (
6725 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/hinsen/scientific.html}
6704 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/hinsen/scientific.html}
6726
6705
6727 \end_inset
6706 \end_inset
6728
6707
6729 ).
6708 ).
6730 \layout Standard
6709 \layout Standard
6731
6710
6732 The
6711 The
6733 \family typewriter
6712 \family typewriter
6734 Physics.PhysicalQuantities
6713 Physics.PhysicalQuantities
6735 \family default
6714 \family default
6736 module defines
6715 module defines
6737 \family typewriter
6716 \family typewriter
6738 PhysicalQuantity
6717 PhysicalQuantity
6739 \family default
6718 \family default
6740 objects, but these must be declared as instances of a class.
6719 objects, but these must be declared as instances of a class.
6741 For example, to define
6720 For example, to define
6742 \family typewriter
6721 \family typewriter
6743 v
6722 v
6744 \family default
6723 \family default
6745 as a velocity of 3\SpecialChar ~
6724 as a velocity of 3\SpecialChar ~
6746 m/s, normally you would write:
6725 m/s, normally you would write:
6747 \family typewriter
6726 \family typewriter
6748
6727
6749 \newline
6728 \newline
6750 In [1]: v = PhysicalQuantity(3,'m/s')
6729 In [1]: v = PhysicalQuantity(3,'m/s')
6751 \layout Standard
6730 \layout Standard
6752
6731
6753 Using the
6732 Using the
6754 \family typewriter
6733 \family typewriter
6755 PhysicalQ_Input
6734 PhysicalQ_Input
6756 \family default
6735 \family default
6757 extension this can be input instead as:
6736 extension this can be input instead as:
6758 \family typewriter
6737 \family typewriter
6759
6738
6760 \newline
6739 \newline
6761 In [1]: v = 3 m/s
6740 In [1]: v = 3 m/s
6762 \family default
6741 \family default
6763
6742
6764 \newline
6743 \newline
6765 which is much more convenient for interactive use (even though it is blatantly
6744 which is much more convenient for interactive use (even though it is blatantly
6766 invalid Python syntax).
6745 invalid Python syntax).
6767 \layout Standard
6746 \layout Standard
6768
6747
6769 The
6748 The
6770 \family typewriter
6749 \family typewriter
6771 physics
6750 physics
6772 \family default
6751 \family default
6773 profile supplied with IPython (enabled via
6752 profile supplied with IPython (enabled via
6774 \family typewriter
6753 \family typewriter
6775 'ipython -p physics'
6754 'ipython -p physics'
6776 \family default
6755 \family default
6777 ) uses these extensions, which you can also activate with:
6756 ) uses these extensions, which you can also activate with:
6778 \layout Standard
6757 \layout Standard
6779
6758
6780
6759
6781 \family typewriter
6760 \family typewriter
6782 from math import * # math MUST be imported BEFORE PhysicalQInteractive
6761 from math import * # math MUST be imported BEFORE PhysicalQInteractive
6783 \newline
6762 \newline
6784 from IPython.Extensions.PhysicalQInteractive import *
6763 from IPython.Extensions.PhysicalQInteractive import *
6785 \newline
6764 \newline
6786 import IPython.Extensions.PhysicalQInput
6765 import IPython.Extensions.PhysicalQInput
6787 \layout Section
6766 \layout Section
6788
6767
6789 IPython as a system shell
6768 IPython as a system shell
6790 \layout Standard
6769 \layout Standard
6791
6770
6792 IPython ships with a special profile called
6771 IPython ships with a special profile called
6793 \family typewriter
6772 \family typewriter
6794 pysh
6773 pysh
6795 \family default
6774 \family default
6796 , which you can activate at the command line as
6775 , which you can activate at the command line as
6797 \family typewriter
6776 \family typewriter
6798 `ipython -p pysh'
6777 `ipython -p pysh'
6799 \family default
6778 \family default
6800 .
6779 .
6801 This loads
6780 This loads
6802 \family typewriter
6781 \family typewriter
6803 InterpreterExec
6782 InterpreterExec
6804 \family default
6783 \family default
6805 , along with some additional facilities and a prompt customized for filesystem
6784 , along with some additional facilities and a prompt customized for filesystem
6806 navigation.
6785 navigation.
6807 \layout Standard
6786 \layout Standard
6808
6787
6809 Note that this does
6788 Note that this does
6810 \emph on
6789 \emph on
6811 not
6790 not
6812 \emph default
6791 \emph default
6813 make IPython a full-fledged system shell.
6792 make IPython a full-fledged system shell.
6814 In particular, it has no job control, so if you type Ctrl-Z (under Unix),
6793 In particular, it has no job control, so if you type Ctrl-Z (under Unix),
6815 you'll suspend pysh itself, not the process you just started.
6794 you'll suspend pysh itself, not the process you just started.
6816
6795
6817 \layout Standard
6796 \layout Standard
6818
6797
6819 What the shell profile allows you to do is to use the convenient and powerful
6798 What the shell profile allows you to do is to use the convenient and powerful
6820 syntax of Python to do quick scripting at the command line.
6799 syntax of Python to do quick scripting at the command line.
6821 Below we describe some of its features.
6800 Below we describe some of its features.
6822 \layout Subsection
6801 \layout Subsection
6823
6802
6824 Aliases
6803 Aliases
6825 \layout Standard
6804 \layout Standard
6826
6805
6827 All of your
6806 All of your
6828 \family typewriter
6807 \family typewriter
6829 $PATH
6808 $PATH
6830 \family default
6809 \family default
6831 has been loaded as IPython aliases, so you should be able to type any normal
6810 has been loaded as IPython aliases, so you should be able to type any normal
6832 system command and have it executed.
6811 system command and have it executed.
6833 See
6812 See
6834 \family typewriter
6813 \family typewriter
6835 %alias?
6814 %alias?
6836 \family default
6815 \family default
6837 and
6816 and
6838 \family typewriter
6817 \family typewriter
6839 %unalias?
6818 %unalias?
6840 \family default
6819 \family default
6841 for details on the alias facilities.
6820 for details on the alias facilities.
6842 See also
6821 See also
6843 \family typewriter
6822 \family typewriter
6844 %rehash?
6823 %rehash?
6845 \family default
6824 \family default
6846 and
6825 and
6847 \family typewriter
6826 \family typewriter
6848 %rehashx?
6827 %rehashx?
6849 \family default
6828 \family default
6850 for details on the mechanism used to load
6829 for details on the mechanism used to load
6851 \family typewriter
6830 \family typewriter
6852 $PATH
6831 $PATH
6853 \family default
6832 \family default
6854 .
6833 .
6855 \layout Subsection
6834 \layout Subsection
6856
6835
6857 Special syntax
6836 Special syntax
6858 \layout Standard
6837 \layout Standard
6859
6838
6860 Any lines which begin with
6839 Any lines which begin with
6861 \family typewriter
6840 \family typewriter
6862 `~'
6841 `~'
6863 \family default
6842 \family default
6864 ,
6843 ,
6865 \family typewriter
6844 \family typewriter
6866 `/'
6845 `/'
6867 \family default
6846 \family default
6868 and
6847 and
6869 \family typewriter
6848 \family typewriter
6870 `.'
6849 `.'
6871 \family default
6850 \family default
6872 will be executed as shell commands instead of as Python code.
6851 will be executed as shell commands instead of as Python code.
6873 The special escapes below are also recognized.
6852 The special escapes below are also recognized.
6874
6853
6875 \family typewriter
6854 \family typewriter
6876 !cmd
6855 !cmd
6877 \family default
6856 \family default
6878 is valid in single or multi-line input, all others are only valid in single-lin
6857 is valid in single or multi-line input, all others are only valid in single-lin
6879 e input:
6858 e input:
6880 \layout Description
6859 \layout Description
6881
6860
6882
6861
6883 \family typewriter
6862 \family typewriter
6884 !cmd
6863 !cmd
6885 \family default
6864 \family default
6886 pass `cmd' directly to the shell
6865 pass `cmd' directly to the shell
6887 \layout Description
6866 \layout Description
6888
6867
6889
6868
6890 \family typewriter
6869 \family typewriter
6891 !!cmd
6870 !!cmd
6892 \family default
6871 \family default
6893 execute `cmd' and return output as a list (split on `
6872 execute `cmd' and return output as a list (split on `
6894 \backslash
6873 \backslash
6895 n')
6874 n')
6896 \layout Description
6875 \layout Description
6897
6876
6898
6877
6899 \family typewriter
6878 \family typewriter
6900 $var=cmd
6879 $var=cmd
6901 \family default
6880 \family default
6902 capture output of cmd into var, as a string
6881 capture output of cmd into var, as a string
6903 \layout Description
6882 \layout Description
6904
6883
6905
6884
6906 \family typewriter
6885 \family typewriter
6907 $$var=cmd
6886 $$var=cmd
6908 \family default
6887 \family default
6909 capture output of cmd into var, as a list (split on `
6888 capture output of cmd into var, as a list (split on `
6910 \backslash
6889 \backslash
6911 n')
6890 n')
6912 \layout Standard
6891 \layout Standard
6913
6892
6914 The
6893 The
6915 \family typewriter
6894 \family typewriter
6916 $
6895 $
6917 \family default
6896 \family default
6918 /
6897 /
6919 \family typewriter
6898 \family typewriter
6920 $$
6899 $$
6921 \family default
6900 \family default
6922 syntaxes make Python variables from system output, which you can later
6901 syntaxes make Python variables from system output, which you can later
6923 use for further scripting.
6902 use for further scripting.
6924 The converse is also possible: when executing an alias or calling to the
6903 The converse is also possible: when executing an alias or calling to the
6925 system via
6904 system via
6926 \family typewriter
6905 \family typewriter
6927 !
6906 !
6928 \family default
6907 \family default
6929 /
6908 /
6930 \family typewriter
6909 \family typewriter
6931 !!
6910 !!
6932 \family default
6911 \family default
6933 , you can expand any python variable or expression by prepending it with
6912 , you can expand any python variable or expression by prepending it with
6934
6913
6935 \family typewriter
6914 \family typewriter
6936 $
6915 $
6937 \family default
6916 \family default
6938 .
6917 .
6939 Full details of the allowed syntax can be found in Python's PEP 215.
6918 Full details of the allowed syntax can be found in Python's PEP 215.
6940 \layout Standard
6919 \layout Standard
6941
6920
6942 A few brief examples will illustrate these (note that the indentation below
6921 A few brief examples will illustrate these (note that the indentation below
6943 may be incorrectly displayed):
6922 may be incorrectly displayed):
6944 \layout Standard
6923 \layout Standard
6945
6924
6946
6925
6947 \family typewriter
6926 \family typewriter
6948 fperez[~/test]|3> !ls *s.py
6927 fperez[~/test]|3> !ls *s.py
6949 \newline
6928 \newline
6950 scopes.py strings.py
6929 scopes.py strings.py
6951 \layout Standard
6930 \layout Standard
6952
6931
6953 ls is an internal alias, so there's no need to use
6932 ls is an internal alias, so there's no need to use
6954 \family typewriter
6933 \family typewriter
6955 !
6934 !
6956 \family default
6935 \family default
6957 :
6936 :
6958 \layout Standard
6937 \layout Standard
6959
6938
6960
6939
6961 \family typewriter
6940 \family typewriter
6962 fperez[~/test]|4> ls *s.py
6941 fperez[~/test]|4> ls *s.py
6963 \newline
6942 \newline
6964 scopes.py* strings.py
6943 scopes.py* strings.py
6965 \layout Standard
6944 \layout Standard
6966
6945
6967 !!ls will return the output into a Python variable:
6946 !!ls will return the output into a Python variable:
6968 \layout Standard
6947 \layout Standard
6969
6948
6970
6949
6971 \family typewriter
6950 \family typewriter
6972 fperez[~/test]|5> !!ls *s.py
6951 fperez[~/test]|5> !!ls *s.py
6973 \newline
6952 \newline
6974
6953
6975 \begin_inset ERT
6954 \begin_inset ERT
6976 status Collapsed
6955 status Collapsed
6977
6956
6978 \layout Standard
6957 \layout Standard
6979
6958
6980 \backslash
6959 \backslash
6981 hspace*{0mm}
6960 hspace*{0mm}
6982 \end_inset
6961 \end_inset
6983
6962
6984 \SpecialChar ~
6963 \SpecialChar ~
6985 \SpecialChar ~
6964 \SpecialChar ~
6986 \SpecialChar ~
6965 \SpecialChar ~
6987 \SpecialChar ~
6966 \SpecialChar ~
6988 \SpecialChar ~
6967 \SpecialChar ~
6989 \SpecialChar ~
6968 \SpecialChar ~
6990 \SpecialChar ~
6969 \SpecialChar ~
6991 \SpecialChar ~
6970 \SpecialChar ~
6992 \SpecialChar ~
6971 \SpecialChar ~
6993 \SpecialChar ~
6972 \SpecialChar ~
6994 \SpecialChar ~
6973 \SpecialChar ~
6995 \SpecialChar ~
6974 \SpecialChar ~
6996 \SpecialChar ~
6975 \SpecialChar ~
6997 \SpecialChar ~
6976 \SpecialChar ~
6998 <5> ['scopes.py', 'strings.py']
6977 <5> ['scopes.py', 'strings.py']
6999 \newline
6978 \newline
7000 fperez[~/test]|6> print _5
6979 fperez[~/test]|6> print _5
7001 \newline
6980 \newline
7002 ['scopes.py', 'strings.py']
6981 ['scopes.py', 'strings.py']
7003 \layout Standard
6982 \layout Standard
7004
6983
7005
6984
7006 \family typewriter
6985 \family typewriter
7007 $
6986 $
7008 \family default
6987 \family default
7009 and
6988 and
7010 \family typewriter
6989 \family typewriter
7011 $$
6990 $$
7012 \family default
6991 \family default
7013 allow direct capture to named variables:
6992 allow direct capture to named variables:
7014 \layout Standard
6993 \layout Standard
7015
6994
7016
6995
7017 \family typewriter
6996 \family typewriter
7018 fperez[~/test]|7> $astr = ls *s.py
6997 fperez[~/test]|7> $astr = ls *s.py
7019 \newline
6998 \newline
7020 fperez[~/test]|8> astr
6999 fperez[~/test]|8> astr
7021 \newline
7000 \newline
7022
7001
7023 \begin_inset ERT
7002 \begin_inset ERT
7024 status Collapsed
7003 status Collapsed
7025
7004
7026 \layout Standard
7005 \layout Standard
7027
7006
7028 \backslash
7007 \backslash
7029 hspace*{0mm}
7008 hspace*{0mm}
7030 \end_inset
7009 \end_inset
7031
7010
7032 \SpecialChar ~
7011 \SpecialChar ~
7033 \SpecialChar ~
7012 \SpecialChar ~
7034 \SpecialChar ~
7013 \SpecialChar ~
7035 \SpecialChar ~
7014 \SpecialChar ~
7036 \SpecialChar ~
7015 \SpecialChar ~
7037 \SpecialChar ~
7016 \SpecialChar ~
7038 \SpecialChar ~
7017 \SpecialChar ~
7039 \SpecialChar ~
7018 \SpecialChar ~
7040 \SpecialChar ~
7019 \SpecialChar ~
7041 \SpecialChar ~
7020 \SpecialChar ~
7042 \SpecialChar ~
7021 \SpecialChar ~
7043 \SpecialChar ~
7022 \SpecialChar ~
7044 \SpecialChar ~
7023 \SpecialChar ~
7045 \SpecialChar ~
7024 \SpecialChar ~
7046 <8> 'scopes.py
7025 <8> 'scopes.py
7047 \backslash
7026 \backslash
7048 nstrings.py'
7027 nstrings.py'
7049 \layout Standard
7028 \layout Standard
7050
7029
7051
7030
7052 \family typewriter
7031 \family typewriter
7053 fperez[~/test]|9> $$alist = ls *s.py
7032 fperez[~/test]|9> $$alist = ls *s.py
7054 \newline
7033 \newline
7055 fperez[~/test]|10> alist
7034 fperez[~/test]|10> alist
7056 \newline
7035 \newline
7057
7036
7058 \begin_inset ERT
7037 \begin_inset ERT
7059 status Collapsed
7038 status Collapsed
7060
7039
7061 \layout Standard
7040 \layout Standard
7062
7041
7063 \backslash
7042 \backslash
7064 hspace*{0mm}
7043 hspace*{0mm}
7065 \end_inset
7044 \end_inset
7066
7045
7067 \SpecialChar ~
7046 \SpecialChar ~
7068 \SpecialChar ~
7047 \SpecialChar ~
7069 \SpecialChar ~
7048 \SpecialChar ~
7070 \SpecialChar ~
7049 \SpecialChar ~
7071 \SpecialChar ~
7050 \SpecialChar ~
7072 \SpecialChar ~
7051 \SpecialChar ~
7073 \SpecialChar ~
7052 \SpecialChar ~
7074 \SpecialChar ~
7053 \SpecialChar ~
7075 \SpecialChar ~
7054 \SpecialChar ~
7076 \SpecialChar ~
7055 \SpecialChar ~
7077 \SpecialChar ~
7056 \SpecialChar ~
7078 \SpecialChar ~
7057 \SpecialChar ~
7079 \SpecialChar ~
7058 \SpecialChar ~
7080 \SpecialChar ~
7059 \SpecialChar ~
7081 <10> ['scopes.py', 'strings.py']
7060 <10> ['scopes.py', 'strings.py']
7082 \layout Standard
7061 \layout Standard
7083
7062
7084 alist is now a normal python list you can loop over.
7063 alist is now a normal python list you can loop over.
7085 Using
7064 Using
7086 \family typewriter
7065 \family typewriter
7087 $
7066 $
7088 \family default
7067 \family default
7089 will expand back the python values when alias calls are made:
7068 will expand back the python values when alias calls are made:
7090 \layout Standard
7069 \layout Standard
7091
7070
7092
7071
7093 \family typewriter
7072 \family typewriter
7094 fperez[~/test]|11> for f in alist:
7073 fperez[~/test]|11> for f in alist:
7095 \newline
7074 \newline
7096
7075
7097 \begin_inset ERT
7076 \begin_inset ERT
7098 status Collapsed
7077 status Collapsed
7099
7078
7100 \layout Standard
7079 \layout Standard
7101
7080
7102 \backslash
7081 \backslash
7103 hspace*{0mm}
7082 hspace*{0mm}
7104 \end_inset
7083 \end_inset
7105
7084
7106 \SpecialChar ~
7085 \SpecialChar ~
7107 \SpecialChar ~
7086 \SpecialChar ~
7108 \SpecialChar ~
7087 \SpecialChar ~
7109 \SpecialChar ~
7088 \SpecialChar ~
7110 \SpecialChar ~
7089 \SpecialChar ~
7111 \SpecialChar ~
7090 \SpecialChar ~
7112 \SpecialChar ~
7091 \SpecialChar ~
7113 \SpecialChar ~
7092 \SpecialChar ~
7114 \SpecialChar ~
7093 \SpecialChar ~
7115 \SpecialChar ~
7094 \SpecialChar ~
7116 \SpecialChar ~
7095 \SpecialChar ~
7117 \SpecialChar ~
7096 \SpecialChar ~
7118 \SpecialChar ~
7097 \SpecialChar ~
7119 \SpecialChar ~
7098 \SpecialChar ~
7120 |..> \SpecialChar ~
7099 |..> \SpecialChar ~
7121 \SpecialChar ~
7100 \SpecialChar ~
7122 \SpecialChar ~
7101 \SpecialChar ~
7123 \SpecialChar ~
7102 \SpecialChar ~
7124 print 'file',f,
7103 print 'file',f,
7125 \newline
7104 \newline
7126
7105
7127 \begin_inset ERT
7106 \begin_inset ERT
7128 status Collapsed
7107 status Collapsed
7129
7108
7130 \layout Standard
7109 \layout Standard
7131
7110
7132 \backslash
7111 \backslash
7133 hspace*{0mm}
7112 hspace*{0mm}
7134 \end_inset
7113 \end_inset
7135
7114
7136 \SpecialChar ~
7115 \SpecialChar ~
7137 \SpecialChar ~
7116 \SpecialChar ~
7138 \SpecialChar ~
7117 \SpecialChar ~
7139 \SpecialChar ~
7118 \SpecialChar ~
7140 \SpecialChar ~
7119 \SpecialChar ~
7141 \SpecialChar ~
7120 \SpecialChar ~
7142 \SpecialChar ~
7121 \SpecialChar ~
7143 \SpecialChar ~
7122 \SpecialChar ~
7144 \SpecialChar ~
7123 \SpecialChar ~
7145 \SpecialChar ~
7124 \SpecialChar ~
7146 \SpecialChar ~
7125 \SpecialChar ~
7147 \SpecialChar ~
7126 \SpecialChar ~
7148 \SpecialChar ~
7127 \SpecialChar ~
7149 \SpecialChar ~
7128 \SpecialChar ~
7150 |..> \SpecialChar ~
7129 |..> \SpecialChar ~
7151 \SpecialChar ~
7130 \SpecialChar ~
7152 \SpecialChar ~
7131 \SpecialChar ~
7153 \SpecialChar ~
7132 \SpecialChar ~
7154 wc -l $f
7133 wc -l $f
7155 \newline
7134 \newline
7156
7135
7157 \begin_inset ERT
7136 \begin_inset ERT
7158 status Collapsed
7137 status Collapsed
7159
7138
7160 \layout Standard
7139 \layout Standard
7161
7140
7162 \backslash
7141 \backslash
7163 hspace*{0mm}
7142 hspace*{0mm}
7164 \end_inset
7143 \end_inset
7165
7144
7166 \SpecialChar ~
7145 \SpecialChar ~
7167 \SpecialChar ~
7146 \SpecialChar ~
7168 \SpecialChar ~
7147 \SpecialChar ~
7169 \SpecialChar ~
7148 \SpecialChar ~
7170 \SpecialChar ~
7149 \SpecialChar ~
7171 \SpecialChar ~
7150 \SpecialChar ~
7172 \SpecialChar ~
7151 \SpecialChar ~
7173 \SpecialChar ~
7152 \SpecialChar ~
7174 \SpecialChar ~
7153 \SpecialChar ~
7175 \SpecialChar ~
7154 \SpecialChar ~
7176 \SpecialChar ~
7155 \SpecialChar ~
7177 \SpecialChar ~
7156 \SpecialChar ~
7178 \SpecialChar ~
7157 \SpecialChar ~
7179 \SpecialChar ~
7158 \SpecialChar ~
7180 |..>
7159 |..>
7181 \newline
7160 \newline
7182 file scopes.py 13 scopes.py
7161 file scopes.py 13 scopes.py
7183 \newline
7162 \newline
7184 file strings.py 4 strings.py
7163 file strings.py 4 strings.py
7185 \layout Standard
7164 \layout Standard
7186
7165
7187 Note that you may need to protect your variables with braces if you want
7166 Note that you may need to protect your variables with braces if you want
7188 to append strings to their names.
7167 to append strings to their names.
7189 To copy all files in alist to
7168 To copy all files in alist to
7190 \family typewriter
7169 \family typewriter
7191 .bak
7170 .bak
7192 \family default
7171 \family default
7193 extensions, you must use:
7172 extensions, you must use:
7194 \layout Standard
7173 \layout Standard
7195
7174
7196
7175
7197 \family typewriter
7176 \family typewriter
7198 fperez[~/test]|12> for f in alist:
7177 fperez[~/test]|12> for f in alist:
7199 \newline
7178 \newline
7200
7179
7201 \begin_inset ERT
7180 \begin_inset ERT
7202 status Collapsed
7181 status Collapsed
7203
7182
7204 \layout Standard
7183 \layout Standard
7205
7184
7206 \backslash
7185 \backslash
7207 hspace*{0mm}
7186 hspace*{0mm}
7208 \end_inset
7187 \end_inset
7209
7188
7210 \SpecialChar ~
7189 \SpecialChar ~
7211 \SpecialChar ~
7190 \SpecialChar ~
7212 \SpecialChar ~
7191 \SpecialChar ~
7213 \SpecialChar ~
7192 \SpecialChar ~
7214 \SpecialChar ~
7193 \SpecialChar ~
7215 \SpecialChar ~
7194 \SpecialChar ~
7216 \SpecialChar ~
7195 \SpecialChar ~
7217 \SpecialChar ~
7196 \SpecialChar ~
7218 \SpecialChar ~
7197 \SpecialChar ~
7219 \SpecialChar ~
7198 \SpecialChar ~
7220 \SpecialChar ~
7199 \SpecialChar ~
7221 \SpecialChar ~
7200 \SpecialChar ~
7222 \SpecialChar ~
7201 \SpecialChar ~
7223 \SpecialChar ~
7202 \SpecialChar ~
7224 |..> \SpecialChar ~
7203 |..> \SpecialChar ~
7225 \SpecialChar ~
7204 \SpecialChar ~
7226 \SpecialChar ~
7205 \SpecialChar ~
7227 \SpecialChar ~
7206 \SpecialChar ~
7228 cp $f ${f}.bak
7207 cp $f ${f}.bak
7229 \layout Standard
7208 \layout Standard
7230
7209
7231 If you try using
7210 If you try using
7232 \family typewriter
7211 \family typewriter
7233 $f.bak
7212 $f.bak
7234 \family default
7213 \family default
7235 , you'll get an AttributeError exception saying that your string object
7214 , you'll get an AttributeError exception saying that your string object
7236 doesn't have a
7215 doesn't have a
7237 \family typewriter
7216 \family typewriter
7238 .bak
7217 .bak
7239 \family default
7218 \family default
7240 attribute.
7219 attribute.
7241 This is because the
7220 This is because the
7242 \family typewriter
7221 \family typewriter
7243 $
7222 $
7244 \family default
7223 \family default
7245 expansion mechanism allows you to expand full Python expressions:
7224 expansion mechanism allows you to expand full Python expressions:
7246 \layout Standard
7225 \layout Standard
7247
7226
7248
7227
7249 \family typewriter
7228 \family typewriter
7250 fperez[~/test]|13> echo "sys.platform is: $sys.platform"
7229 fperez[~/test]|13> echo "sys.platform is: $sys.platform"
7251 \newline
7230 \newline
7252 sys.platform is: linux2
7231 sys.platform is: linux2
7253 \layout Standard
7232 \layout Standard
7254
7233
7255 IPython's input history handling is still active, which allows you to rerun
7234 IPython's input history handling is still active, which allows you to rerun
7256 a single block of multi-line input by simply using exec:
7235 a single block of multi-line input by simply using exec:
7257 \newline
7236 \newline
7258
7237
7259 \family typewriter
7238 \family typewriter
7260 fperez[~/test]|14> $$alist = ls *.eps
7239 fperez[~/test]|14> $$alist = ls *.eps
7261 \newline
7240 \newline
7262 fperez[~/test]|15> exec _i11
7241 fperez[~/test]|15> exec _i11
7263 \newline
7242 \newline
7264 file image2.eps 921 image2.eps
7243 file image2.eps 921 image2.eps
7265 \newline
7244 \newline
7266 file image.eps 921 image.eps
7245 file image.eps 921 image.eps
7267 \layout Standard
7246 \layout Standard
7268
7247
7269 While these are new special-case syntaxes, they are designed to allow very
7248 While these are new special-case syntaxes, they are designed to allow very
7270 efficient use of the shell with minimal typing.
7249 efficient use of the shell with minimal typing.
7271 At an interactive shell prompt, conciseness of expression wins over readability.
7250 At an interactive shell prompt, conciseness of expression wins over readability.
7272 \layout Subsection
7251 \layout Subsection
7273
7252
7274 Useful functions and modules
7253 Useful functions and modules
7275 \layout Standard
7254 \layout Standard
7276
7255
7277 The os, sys and shutil modules from the Python standard library are automaticall
7256 The os, sys and shutil modules from the Python standard library are automaticall
7278 y loaded.
7257 y loaded.
7279 Some additional functions, useful for shell usage, are listed below.
7258 Some additional functions, useful for shell usage, are listed below.
7280 You can request more help about them with `
7259 You can request more help about them with `
7281 \family typewriter
7260 \family typewriter
7282 ?
7261 ?
7283 \family default
7262 \family default
7284 '.
7263 '.
7285 \layout Description
7264 \layout Description
7286
7265
7287
7266
7288 \family typewriter
7267 \family typewriter
7289 shell
7268 shell
7290 \family default
7269 \family default
7291 - execute a command in the underlying system shell
7270 - execute a command in the underlying system shell
7292 \layout Description
7271 \layout Description
7293
7272
7294
7273
7295 \family typewriter
7274 \family typewriter
7296 system
7275 system
7297 \family default
7276 \family default
7298 - like
7277 - like
7299 \family typewriter
7278 \family typewriter
7300 shell()
7279 shell()
7301 \family default
7280 \family default
7302 , but return the exit status of the command
7281 , but return the exit status of the command
7303 \layout Description
7282 \layout Description
7304
7283
7305
7284
7306 \family typewriter
7285 \family typewriter
7307 sout
7286 sout
7308 \family default
7287 \family default
7309 - capture the output of a command as a string
7288 - capture the output of a command as a string
7310 \layout Description
7289 \layout Description
7311
7290
7312
7291
7313 \family typewriter
7292 \family typewriter
7314 lout
7293 lout
7315 \family default
7294 \family default
7316 - capture the output of a command as a list (split on `
7295 - capture the output of a command as a list (split on `
7317 \backslash
7296 \backslash
7318 n')
7297 n')
7319 \layout Description
7298 \layout Description
7320
7299
7321
7300
7322 \family typewriter
7301 \family typewriter
7323 getoutputerror
7302 getoutputerror
7324 \family default
7303 \family default
7325 - capture (output,error) of a shell commandss
7304 - capture (output,error) of a shell commandss
7326 \layout Standard
7305 \layout Standard
7327
7306
7328
7307
7329 \family typewriter
7308 \family typewriter
7330 sout
7309 sout
7331 \family default
7310 \family default
7332 /
7311 /
7333 \family typewriter
7312 \family typewriter
7334 lout
7313 lout
7335 \family default
7314 \family default
7336 are the functional equivalents of
7315 are the functional equivalents of
7337 \family typewriter
7316 \family typewriter
7338 $
7317 $
7339 \family default
7318 \family default
7340 /
7319 /
7341 \family typewriter
7320 \family typewriter
7342 $$
7321 $$
7343 \family default
7322 \family default
7344 .
7323 .
7345 They are provided to allow you to capture system output in the middle of
7324 They are provided to allow you to capture system output in the middle of
7346 true python code, function definitions, etc (where
7325 true python code, function definitions, etc (where
7347 \family typewriter
7326 \family typewriter
7348 $
7327 $
7349 \family default
7328 \family default
7350 and
7329 and
7351 \family typewriter
7330 \family typewriter
7352 $$
7331 $$
7353 \family default
7332 \family default
7354 are invalid).
7333 are invalid).
7355 \layout Subsection
7334 \layout Subsection
7356
7335
7357 Directory management
7336 Directory management
7358 \layout Standard
7337 \layout Standard
7359
7338
7360 Since each command passed by pysh to the underlying system is executed in
7339 Since each command passed by pysh to the underlying system is executed in
7361 a subshell which exits immediately, you can NOT use !cd to navigate the
7340 a subshell which exits immediately, you can NOT use !cd to navigate the
7362 filesystem.
7341 filesystem.
7363 \layout Standard
7342 \layout Standard
7364
7343
7365 Pysh provides its own builtin
7344 Pysh provides its own builtin
7366 \family typewriter
7345 \family typewriter
7367 `%cd
7346 `%cd
7368 \family default
7347 \family default
7369 ' magic command to move in the filesystem (the
7348 ' magic command to move in the filesystem (the
7370 \family typewriter
7349 \family typewriter
7371 %
7350 %
7372 \family default
7351 \family default
7373 is not required with automagic on).
7352 is not required with automagic on).
7374 It also maintains a list of visited directories (use
7353 It also maintains a list of visited directories (use
7375 \family typewriter
7354 \family typewriter
7376 %dhist
7355 %dhist
7377 \family default
7356 \family default
7378 to see it) and allows direct switching to any of them.
7357 to see it) and allows direct switching to any of them.
7379 Type
7358 Type
7380 \family typewriter
7359 \family typewriter
7381 `cd?
7360 `cd?
7382 \family default
7361 \family default
7383 ' for more details.
7362 ' for more details.
7384 \layout Standard
7363 \layout Standard
7385
7364
7386
7365
7387 \family typewriter
7366 \family typewriter
7388 %pushd
7367 %pushd
7389 \family default
7368 \family default
7390 ,
7369 ,
7391 \family typewriter
7370 \family typewriter
7392 %popd
7371 %popd
7393 \family default
7372 \family default
7394 and
7373 and
7395 \family typewriter
7374 \family typewriter
7396 %dirs
7375 %dirs
7397 \family default
7376 \family default
7398 are provided for directory stack handling.
7377 are provided for directory stack handling.
7399 \layout Subsection
7378 \layout Subsection
7400
7379
7401 Prompt customization
7380 Prompt customization
7402 \layout Standard
7381 \layout Standard
7403
7382
7404 The supplied
7383 The supplied
7405 \family typewriter
7384 \family typewriter
7406 ipythonrc-pysh
7385 ipythonrc-pysh
7407 \family default
7386 \family default
7408 profile comes with an example of a very colored and detailed prompt, mainly
7387 profile comes with an example of a very colored and detailed prompt, mainly
7409 to serve as an illustration.
7388 to serve as an illustration.
7410 The valid escape sequences, besides color names, are:
7389 The valid escape sequences, besides color names, are:
7411 \layout Description
7390 \layout Description
7412
7391
7413
7392
7414 \backslash
7393 \backslash
7415 # - Prompt number.
7394 # - Prompt number.
7416 \layout Description
7395 \layout Description
7417
7396
7418
7397
7419 \backslash
7398 \backslash
7420 D - Dots, as many as there are digits in
7399 D - Dots, as many as there are digits in
7421 \backslash
7400 \backslash
7422 # (so they align).
7401 # (so they align).
7423 \layout Description
7402 \layout Description
7424
7403
7425
7404
7426 \backslash
7405 \backslash
7427 w - Current working directory (cwd).
7406 w - Current working directory (cwd).
7428 \layout Description
7407 \layout Description
7429
7408
7430
7409
7431 \backslash
7410 \backslash
7432 W - Basename of current working directory.
7411 W - Basename of current working directory.
7433 \layout Description
7412 \layout Description
7434
7413
7435
7414
7436 \backslash
7415 \backslash
7437 X
7416 X
7438 \emph on
7417 \emph on
7439 N
7418 N
7440 \emph default
7419 \emph default
7441 - Where
7420 - Where
7442 \emph on
7421 \emph on
7443 N
7422 N
7444 \emph default
7423 \emph default
7445 =0..5.
7424 =0..5.
7446 N terms of the cwd, with $HOME written as ~.
7425 N terms of the cwd, with $HOME written as ~.
7447 \layout Description
7426 \layout Description
7448
7427
7449
7428
7450 \backslash
7429 \backslash
7451 Y
7430 Y
7452 \emph on
7431 \emph on
7453 N
7432 N
7454 \emph default
7433 \emph default
7455 - Where
7434 - Where
7456 \emph on
7435 \emph on
7457 N
7436 N
7458 \emph default
7437 \emph default
7459 =0..5.
7438 =0..5.
7460 Like X
7439 Like X
7461 \emph on
7440 \emph on
7462 N
7441 N
7463 \emph default
7442 \emph default
7464 , but if ~ is term
7443 , but if ~ is term
7465 \emph on
7444 \emph on
7466 N
7445 N
7467 \emph default
7446 \emph default
7468 +1 it's also shown.
7447 +1 it's also shown.
7469 \layout Description
7448 \layout Description
7470
7449
7471
7450
7472 \backslash
7451 \backslash
7473 u - Username.
7452 u - Username.
7474 \layout Description
7453 \layout Description
7475
7454
7476
7455
7477 \backslash
7456 \backslash
7478 H - Full hostname.
7457 H - Full hostname.
7479 \layout Description
7458 \layout Description
7480
7459
7481
7460
7482 \backslash
7461 \backslash
7483 h - Hostname up to first '.'
7462 h - Hostname up to first '.'
7484 \layout Description
7463 \layout Description
7485
7464
7486
7465
7487 \backslash
7466 \backslash
7488 $ - Root symbol ($ or #).
7467 $ - Root symbol ($ or #).
7489
7468
7490 \layout Description
7469 \layout Description
7491
7470
7492
7471
7493 \backslash
7472 \backslash
7494 t - Current time, in H:M:S format.
7473 t - Current time, in H:M:S format.
7495 \layout Description
7474 \layout Description
7496
7475
7497
7476
7498 \backslash
7477 \backslash
7499 v - IPython release version.
7478 v - IPython release version.
7500
7479
7501 \layout Description
7480 \layout Description
7502
7481
7503
7482
7504 \backslash
7483 \backslash
7505 n - Newline.
7484 n - Newline.
7506
7485
7507 \layout Description
7486 \layout Description
7508
7487
7509
7488
7510 \backslash
7489 \backslash
7511 r - Carriage return.
7490 r - Carriage return.
7512
7491
7513 \layout Description
7492 \layout Description
7514
7493
7515
7494
7516 \backslash
7495 \backslash
7517
7496
7518 \backslash
7497 \backslash
7519 - An explicitly escaped '
7498 - An explicitly escaped '
7520 \backslash
7499 \backslash
7521 '.
7500 '.
7522 \layout Standard
7501 \layout Standard
7523
7502
7524 You can configure your prompt colors using any ANSI color escape.
7503 You can configure your prompt colors using any ANSI color escape.
7525 Each color escape sets the color for any subsequent text, until another
7504 Each color escape sets the color for any subsequent text, until another
7526 escape comes in and changes things.
7505 escape comes in and changes things.
7527 The valid color escapes are:
7506 The valid color escapes are:
7528 \layout Description
7507 \layout Description
7529
7508
7530
7509
7531 \backslash
7510 \backslash
7532 C_Black
7511 C_Black
7533 \layout Description
7512 \layout Description
7534
7513
7535
7514
7536 \backslash
7515 \backslash
7537 C_Blue
7516 C_Blue
7538 \layout Description
7517 \layout Description
7539
7518
7540
7519
7541 \backslash
7520 \backslash
7542 C_Brown
7521 C_Brown
7543 \layout Description
7522 \layout Description
7544
7523
7545
7524
7546 \backslash
7525 \backslash
7547 C_Cyan
7526 C_Cyan
7548 \layout Description
7527 \layout Description
7549
7528
7550
7529
7551 \backslash
7530 \backslash
7552 C_DarkGray
7531 C_DarkGray
7553 \layout Description
7532 \layout Description
7554
7533
7555
7534
7556 \backslash
7535 \backslash
7557 C_Green
7536 C_Green
7558 \layout Description
7537 \layout Description
7559
7538
7560
7539
7561 \backslash
7540 \backslash
7562 C_LightBlue
7541 C_LightBlue
7563 \layout Description
7542 \layout Description
7564
7543
7565
7544
7566 \backslash
7545 \backslash
7567 C_LightCyan
7546 C_LightCyan
7568 \layout Description
7547 \layout Description
7569
7548
7570
7549
7571 \backslash
7550 \backslash
7572 C_LightGray
7551 C_LightGray
7573 \layout Description
7552 \layout Description
7574
7553
7575
7554
7576 \backslash
7555 \backslash
7577 C_LightGreen
7556 C_LightGreen
7578 \layout Description
7557 \layout Description
7579
7558
7580
7559
7581 \backslash
7560 \backslash
7582 C_LightPurple
7561 C_LightPurple
7583 \layout Description
7562 \layout Description
7584
7563
7585
7564
7586 \backslash
7565 \backslash
7587 C_LightRed
7566 C_LightRed
7588 \layout Description
7567 \layout Description
7589
7568
7590
7569
7591 \backslash
7570 \backslash
7592 C_Purple
7571 C_Purple
7593 \layout Description
7572 \layout Description
7594
7573
7595
7574
7596 \backslash
7575 \backslash
7597 C_Red
7576 C_Red
7598 \layout Description
7577 \layout Description
7599
7578
7600
7579
7601 \backslash
7580 \backslash
7602 C_White
7581 C_White
7603 \layout Description
7582 \layout Description
7604
7583
7605
7584
7606 \backslash
7585 \backslash
7607 C_Yellow
7586 C_Yellow
7608 \layout Description
7587 \layout Description
7609
7588
7610
7589
7611 \backslash
7590 \backslash
7612 C_Normal Stop coloring, defaults to your terminal settings.
7591 C_Normal Stop coloring, defaults to your terminal settings.
7613 \layout Section
7592 \layout Section
7614
7593
7615
7594
7616 \begin_inset LatexCommand \label{sec:Threading-support}
7595 \begin_inset LatexCommand \label{sec:Threading-support}
7617
7596
7618 \end_inset
7597 \end_inset
7619
7598
7620 Threading support
7599 Threading support
7621 \layout Standard
7600 \layout Standard
7622
7601
7623
7602
7624 \series bold
7603 \series bold
7625 WARNING:
7604 WARNING:
7626 \series default
7605 \series default
7627 The threading support is still somewhat experimental, and it has only seen
7606 The threading support is still somewhat experimental, and it has only seen
7628 reasonable testing under Linux.
7607 reasonable testing under Linux.
7629 Threaded code is particularly tricky to debug, and it tends to show extremely
7608 Threaded code is particularly tricky to debug, and it tends to show extremely
7630 platform-dependent behavior.
7609 platform-dependent behavior.
7631 Since I only have access to Linux machines, I will have to rely on user's
7610 Since I only have access to Linux machines, I will have to rely on user's
7632 experiences and assistance for this area of IPython to improve under other
7611 experiences and assistance for this area of IPython to improve under other
7633 platforms.
7612 platforms.
7634 \layout Standard
7613 \layout Standard
7635
7614
7636 IPython, via the
7615 IPython, via the
7637 \family typewriter
7616 \family typewriter
7638 -gthread
7617 -gthread
7639 \family default
7618 \family default
7640 ,
7619 ,
7641 \family typewriter
7620 \family typewriter
7642 -qthread
7621 -qthread
7643 \family default
7622 \family default
7644 and
7623 and
7645 \family typewriter
7624 \family typewriter
7646 -wthread
7625 -wthread
7647 \family default
7626 \family default
7648 options (described in Sec.\SpecialChar ~
7627 options (described in Sec.\SpecialChar ~
7649
7628
7650 \begin_inset LatexCommand \ref{sec:threading-opts}
7629 \begin_inset LatexCommand \ref{sec:threading-opts}
7651
7630
7652 \end_inset
7631 \end_inset
7653
7632
7654 ), can run in multithreaded mode to support pyGTK, Qt and WXPython applications
7633 ), can run in multithreaded mode to support pyGTK, Qt and WXPython applications
7655 respectively.
7634 respectively.
7656 These GUI toolkits need to control the python main loop of execution, so
7635 These GUI toolkits need to control the python main loop of execution, so
7657 under a normal Python interpreter, starting a pyGTK, Qt or WXPython application
7636 under a normal Python interpreter, starting a pyGTK, Qt or WXPython application
7658 will immediately freeze the shell.
7637 will immediately freeze the shell.
7659
7638
7660 \layout Standard
7639 \layout Standard
7661
7640
7662 IPython, with one of these options (you can only use one at a time), separates
7641 IPython, with one of these options (you can only use one at a time), separates
7663 the graphical loop and IPython's code execution run into different threads.
7642 the graphical loop and IPython's code execution run into different threads.
7664 This allows you to test interactively (with
7643 This allows you to test interactively (with
7665 \family typewriter
7644 \family typewriter
7666 %run
7645 %run
7667 \family default
7646 \family default
7668 , for example) your GUI code without blocking.
7647 , for example) your GUI code without blocking.
7669 \layout Standard
7648 \layout Standard
7670
7649
7671 A nice mini-tutorial on using IPython along with the Qt Designer application
7650 A nice mini-tutorial on using IPython along with the Qt Designer application
7672 is available at the SciPy wiki:
7651 is available at the SciPy wiki:
7673 \begin_inset LatexCommand \htmlurl{http://www.scipy.org/wikis/topical_software/QtWithIPythonAndDesigner}
7652 \begin_inset LatexCommand \htmlurl{http://www.scipy.org/wikis/topical_software/QtWithIPythonAndDesigner}
7674
7653
7675 \end_inset
7654 \end_inset
7676
7655
7677 .
7656 .
7678 \layout Subsection
7657 \layout Subsection
7679
7658
7680 Tk issues
7659 Tk issues
7681 \layout Standard
7660 \layout Standard
7682
7661
7683 As indicated in Sec.\SpecialChar ~
7662 As indicated in Sec.\SpecialChar ~
7684
7663
7685 \begin_inset LatexCommand \ref{sec:threading-opts}
7664 \begin_inset LatexCommand \ref{sec:threading-opts}
7686
7665
7687 \end_inset
7666 \end_inset
7688
7667
7689 , a special
7668 , a special
7690 \family typewriter
7669 \family typewriter
7691 -tk
7670 -tk
7692 \family default
7671 \family default
7693 option is provided to try and allow Tk graphical applications to coexist
7672 option is provided to try and allow Tk graphical applications to coexist
7694 interactively with WX, Qt or GTK ones.
7673 interactively with WX, Qt or GTK ones.
7695 Whether this works at all, however, is very platform and configuration
7674 Whether this works at all, however, is very platform and configuration
7696 dependent.
7675 dependent.
7697 Please experiment with simple test cases before committing to using this
7676 Please experiment with simple test cases before committing to using this
7698 combination of Tk and GTK/Qt/WX threading in a production environment.
7677 combination of Tk and GTK/Qt/WX threading in a production environment.
7699 \layout Subsection
7678 \layout Subsection
7700
7679
7701 Signals and Threads
7680 Signals and Threads
7702 \layout Standard
7681 \layout Standard
7703
7682
7704 When any of the thread systems (GTK, Qt or WX) are active, either directly
7683 When any of the thread systems (GTK, Qt or WX) are active, either directly
7705 or via
7684 or via
7706 \family typewriter
7685 \family typewriter
7707 -pylab
7686 -pylab
7708 \family default
7687 \family default
7709 with a threaded backend, it is impossible to interrupt long-running Python
7688 with a threaded backend, it is impossible to interrupt long-running Python
7710 code via
7689 code via
7711 \family typewriter
7690 \family typewriter
7712 Ctrl-C
7691 Ctrl-C
7713 \family default
7692 \family default
7714 .
7693 .
7715 IPython can not pass the KeyboardInterrupt exception (or the underlying
7694 IPython can not pass the KeyboardInterrupt exception (or the underlying
7716
7695
7717 \family typewriter
7696 \family typewriter
7718 SIGINT
7697 SIGINT
7719 \family default
7698 \family default
7720 ) across threads, so any long-running process started from IPython will
7699 ) across threads, so any long-running process started from IPython will
7721 run to completion, or will have to be killed via an external (OS-based)
7700 run to completion, or will have to be killed via an external (OS-based)
7722 mechanism.
7701 mechanism.
7723 \layout Standard
7702 \layout Standard
7724
7703
7725 To the best of my knowledge, this limitation is imposed by the Python interprete
7704 To the best of my knowledge, this limitation is imposed by the Python interprete
7726 r itself, and it comes from the difficulty of writing portable signal/threaded
7705 r itself, and it comes from the difficulty of writing portable signal/threaded
7727 code.
7706 code.
7728 If any user is an expert on this topic and can suggest a better solution,
7707 If any user is an expert on this topic and can suggest a better solution,
7729 I would love to hear about it.
7708 I would love to hear about it.
7730 In the IPython sources, look at the
7709 In the IPython sources, look at the
7731 \family typewriter
7710 \family typewriter
7732 Shell.py
7711 Shell.py
7733 \family default
7712 \family default
7734 module, and in particular at the
7713 module, and in particular at the
7735 \family typewriter
7714 \family typewriter
7736 runcode()
7715 runcode()
7737 \family default
7716 \family default
7738 method.
7717 method.
7739
7718
7740 \layout Subsection
7719 \layout Subsection
7741
7720
7742 I/O pitfalls
7721 I/O pitfalls
7743 \layout Standard
7722 \layout Standard
7744
7723
7745 Be mindful that the Python interpreter switches between threads every
7724 Be mindful that the Python interpreter switches between threads every
7746 \begin_inset Formula $N$
7725 \begin_inset Formula $N$
7747 \end_inset
7726 \end_inset
7748
7727
7749 bytecodes, where the default value as of Python\SpecialChar ~
7728 bytecodes, where the default value as of Python\SpecialChar ~
7750 2.3 is
7729 2.3 is
7751 \begin_inset Formula $N=100.$
7730 \begin_inset Formula $N=100.$
7752 \end_inset
7731 \end_inset
7753
7732
7754 This value can be read by using the
7733 This value can be read by using the
7755 \family typewriter
7734 \family typewriter
7756 sys.getcheckinterval()
7735 sys.getcheckinterval()
7757 \family default
7736 \family default
7758 function, and it can be reset via
7737 function, and it can be reset via
7759 \family typewriter
7738 \family typewriter
7760 sys.setcheckinterval(
7739 sys.setcheckinterval(
7761 \emph on
7740 \emph on
7762 N
7741 N
7763 \emph default
7742 \emph default
7764 )
7743 )
7765 \family default
7744 \family default
7766 .
7745 .
7767 This switching of threads can cause subtly confusing effects if one of
7746 This switching of threads can cause subtly confusing effects if one of
7768 your threads is doing file I/O.
7747 your threads is doing file I/O.
7769 In text mode, most systems only flush file buffers when they encounter
7748 In text mode, most systems only flush file buffers when they encounter
7770 a
7749 a
7771 \family typewriter
7750 \family typewriter
7772 `
7751 `
7773 \backslash
7752 \backslash
7774 n'
7753 n'
7775 \family default
7754 \family default
7776 .
7755 .
7777 An instruction as simple as
7756 An instruction as simple as
7778 \family typewriter
7757 \family typewriter
7779
7758
7780 \newline
7759 \newline
7781 \SpecialChar ~
7760 \SpecialChar ~
7782 \SpecialChar ~
7761 \SpecialChar ~
7783 print >> filehandle,
7762 print >> filehandle,
7784 \begin_inset Quotes eld
7763 \begin_inset Quotes eld
7785 \end_inset
7764 \end_inset
7786
7765
7787 hello world
7766 hello world
7788 \begin_inset Quotes erd
7767 \begin_inset Quotes erd
7789 \end_inset
7768 \end_inset
7790
7769
7791
7770
7792 \family default
7771 \family default
7793
7772
7794 \newline
7773 \newline
7795 actually consists of several bytecodes, so it is possible that the newline
7774 actually consists of several bytecodes, so it is possible that the newline
7796 does not reach your file before the next thread switch.
7775 does not reach your file before the next thread switch.
7797 Similarly, if you are writing to a file in binary mode, the file won't
7776 Similarly, if you are writing to a file in binary mode, the file won't
7798 be flushed until the buffer fills, and your other thread may see apparently
7777 be flushed until the buffer fills, and your other thread may see apparently
7799 truncated files.
7778 truncated files.
7800
7779
7801 \layout Standard
7780 \layout Standard
7802
7781
7803 For this reason, if you are using IPython's thread support and have (for
7782 For this reason, if you are using IPython's thread support and have (for
7804 example) a GUI application which will read data generated by files written
7783 example) a GUI application which will read data generated by files written
7805 to from the IPython thread, the safest approach is to open all of your
7784 to from the IPython thread, the safest approach is to open all of your
7806 files in unbuffered mode (the third argument to the
7785 files in unbuffered mode (the third argument to the
7807 \family typewriter
7786 \family typewriter
7808 file/open
7787 file/open
7809 \family default
7788 \family default
7810 function is the buffering value):
7789 function is the buffering value):
7811 \newline
7790 \newline
7812
7791
7813 \family typewriter
7792 \family typewriter
7814 \SpecialChar ~
7793 \SpecialChar ~
7815 \SpecialChar ~
7794 \SpecialChar ~
7816 filehandle = open(filename,mode,0)
7795 filehandle = open(filename,mode,0)
7817 \layout Standard
7796 \layout Standard
7818
7797
7819 This is obviously a brute force way of avoiding race conditions with the
7798 This is obviously a brute force way of avoiding race conditions with the
7820 file buffering.
7799 file buffering.
7821 If you want to do it cleanly, and you have a resource which is being shared
7800 If you want to do it cleanly, and you have a resource which is being shared
7822 by the interactive IPython loop and your GUI thread, you should really
7801 by the interactive IPython loop and your GUI thread, you should really
7823 handle it with thread locking and syncrhonization properties.
7802 handle it with thread locking and syncrhonization properties.
7824 The Python documentation discusses these.
7803 The Python documentation discusses these.
7825 \layout Section
7804 \layout Section
7826
7805
7827
7806
7828 \begin_inset LatexCommand \label{sec:interactive-demos}
7807 \begin_inset LatexCommand \label{sec:interactive-demos}
7829
7808
7830 \end_inset
7809 \end_inset
7831
7810
7832 Interactive demos with IPython
7811 Interactive demos with IPython
7833 \layout Standard
7812 \layout Standard
7834
7813
7835 IPython ships with a basic system for running scripts interactively in sections,
7814 IPython ships with a basic system for running scripts interactively in sections,
7836 useful when presenting code to audiences.
7815 useful when presenting code to audiences.
7837 A few tags embedded in comments (so that the script remains valid Python
7816 A few tags embedded in comments (so that the script remains valid Python
7838 code) divide a file into separate blocks, and the demo can be run one block
7817 code) divide a file into separate blocks, and the demo can be run one block
7839 at a time, with IPython printing (with syntax highlighting) the block before
7818 at a time, with IPython printing (with syntax highlighting) the block before
7840 executing it, and returning to the interactive prompt after each block.
7819 executing it, and returning to the interactive prompt after each block.
7841 The interactive namespace is updated after each block is run with the contents
7820 The interactive namespace is updated after each block is run with the contents
7842 of the demo's namespace.
7821 of the demo's namespace.
7843 \layout Standard
7822 \layout Standard
7844
7823
7845 This allows you to show a piece of code, run it and then execute interactively
7824 This allows you to show a piece of code, run it and then execute interactively
7846 commands based on the variables just created.
7825 commands based on the variables just created.
7847 Once you want to continue, you simply execute the next block of the demo.
7826 Once you want to continue, you simply execute the next block of the demo.
7848 The following listing shows the markup necessary for dividing a script
7827 The following listing shows the markup necessary for dividing a script
7849 into sections for execution as a demo.
7828 into sections for execution as a demo.
7850 \layout Standard
7829 \layout Standard
7851
7830
7852
7831
7853 \begin_inset ERT
7832 \begin_inset ERT
7854 status Open
7833 status Open
7855
7834
7856 \layout Standard
7835 \layout Standard
7857
7836
7858 \backslash
7837 \backslash
7859 codelist{examples/example-demo.py}
7838 codelist{examples/example-demo.py}
7860 \end_inset
7839 \end_inset
7861
7840
7862
7841
7863 \layout Standard
7842 \layout Standard
7864
7843
7865 In order to run a file as a demo, you must first make a
7844 In order to run a file as a demo, you must first make a
7866 \family typewriter
7845 \family typewriter
7867 Demo
7846 Demo
7868 \family default
7847 \family default
7869 object out of it.
7848 object out of it.
7870 If the file is named
7849 If the file is named
7871 \family typewriter
7850 \family typewriter
7872 myscript.py
7851 myscript.py
7873 \family default
7852 \family default
7874 , the following code will make a demo:
7853 , the following code will make a demo:
7875 \layout LyX-Code
7854 \layout LyX-Code
7876
7855
7877 from IPython.demo import Demo
7856 from IPython.demo import Demo
7878 \layout LyX-Code
7857 \layout LyX-Code
7879
7858
7880 mydemo = Demo('myscript.py')
7859 mydemo = Demo('myscript.py')
7881 \layout Standard
7860 \layout Standard
7882
7861
7883 This creates the
7862 This creates the
7884 \family typewriter
7863 \family typewriter
7885 mydemo
7864 mydemo
7886 \family default
7865 \family default
7887 object, whose blocks you run one at a time by simply calling the object
7866 object, whose blocks you run one at a time by simply calling the object
7888 with no arguments.
7867 with no arguments.
7889 If you have autocall active in IPython (the default), all you need to do
7868 If you have autocall active in IPython (the default), all you need to do
7890 is type
7869 is type
7891 \layout LyX-Code
7870 \layout LyX-Code
7892
7871
7893 mydemo
7872 mydemo
7894 \layout Standard
7873 \layout Standard
7895
7874
7896 and IPython will call it, executing each block.
7875 and IPython will call it, executing each block.
7897 Demo objects can be restarted, you can move forward or back skipping blocks,
7876 Demo objects can be restarted, you can move forward or back skipping blocks,
7898 re-execute the last block, etc.
7877 re-execute the last block, etc.
7899 Simply use the Tab key on a demo object to see its methods, and call
7878 Simply use the Tab key on a demo object to see its methods, and call
7900 \family typewriter
7879 \family typewriter
7901 `?'
7880 `?'
7902 \family default
7881 \family default
7903 on them to see their docstrings for more usage details.
7882 on them to see their docstrings for more usage details.
7904 In addition, the
7883 In addition, the
7905 \family typewriter
7884 \family typewriter
7906 demo
7885 demo
7907 \family default
7886 \family default
7908 module itself contains a comprehensive docstring, which you can access
7887 module itself contains a comprehensive docstring, which you can access
7909 via
7888 via
7910 \layout LyX-Code
7889 \layout LyX-Code
7911
7890
7912 from IPython import demo
7891 from IPython import demo
7913 \layout LyX-Code
7892 \layout LyX-Code
7914
7893
7915 demo?
7894 demo?
7916 \layout Standard
7895 \layout Standard
7917
7896
7918
7897
7919 \series bold
7898 \series bold
7920 Limitations:
7899 Limitations:
7921 \series default
7900 \series default
7922 It is important to note that these demos are limited to fairly simple uses.
7901 It is important to note that these demos are limited to fairly simple uses.
7923 In particular, you can
7902 In particular, you can
7924 \emph on
7903 \emph on
7925 not
7904 not
7926 \emph default
7905 \emph default
7927 put division marks in indented code (loops, if statements, function definitions
7906 put division marks in indented code (loops, if statements, function definitions
7928 , etc.) Supporting something like this would basically require tracking the
7907 , etc.) Supporting something like this would basically require tracking the
7929 internal execution state of the Python interpreter, so only top-level divisions
7908 internal execution state of the Python interpreter, so only top-level divisions
7930 are allowed.
7909 are allowed.
7931 If you want to be able to open an IPython instance at an arbitrary point
7910 If you want to be able to open an IPython instance at an arbitrary point
7932 in a program, you can use IPython's embedding facilities, described in
7911 in a program, you can use IPython's embedding facilities, described in
7933 detail in Sec\SpecialChar \@.
7912 detail in Sec\SpecialChar \@.
7934 \SpecialChar ~
7913 \SpecialChar ~
7935
7914
7936 \begin_inset LatexCommand \ref{sec:embed}
7915 \begin_inset LatexCommand \ref{sec:embed}
7937
7916
7938 \end_inset
7917 \end_inset
7939
7918
7940 .
7919 .
7941 \layout Section
7920 \layout Section
7942
7921
7943
7922
7944 \begin_inset LatexCommand \label{sec:matplotlib-support}
7923 \begin_inset LatexCommand \label{sec:matplotlib-support}
7945
7924
7946 \end_inset
7925 \end_inset
7947
7926
7948 Plotting with
7927 Plotting with
7949 \family typewriter
7928 \family typewriter
7950 matplotlib
7929 matplotlib
7951 \family default
7930 \family default
7952
7931
7953 \layout Standard
7932 \layout Standard
7954
7933
7955 The matplotlib library (
7934 The matplotlib library (
7956 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
7935 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
7957
7936
7958 \end_inset
7937 \end_inset
7959
7938
7960 ) provides high quality 2D plotting for Python.
7939 ) provides high quality 2D plotting for Python.
7961 Matplotlib can produce plots on screen using a variety of GUI toolkits,
7940 Matplotlib can produce plots on screen using a variety of GUI toolkits,
7962 including Tk, GTK and WXPython.
7941 including Tk, GTK and WXPython.
7963 It also provides a number of commands useful for scientific computing,
7942 It also provides a number of commands useful for scientific computing,
7964 all with a syntax compatible with that of the popular Matlab program.
7943 all with a syntax compatible with that of the popular Matlab program.
7965 \layout Standard
7944 \layout Standard
7966
7945
7967 IPython accepts the special option
7946 IPython accepts the special option
7968 \family typewriter
7947 \family typewriter
7969 -pylab
7948 -pylab
7970 \family default
7949 \family default
7971 (Sec.\SpecialChar ~
7950 (Sec.\SpecialChar ~
7972
7951
7973 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
7952 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
7974
7953
7975 \end_inset
7954 \end_inset
7976
7955
7977 ).
7956 ).
7978 This configures it to support matplotlib, honoring the settings in the
7957 This configures it to support matplotlib, honoring the settings in the
7979
7958
7980 \family typewriter
7959 \family typewriter
7981 .matplotlibrc
7960 .matplotlibrc
7982 \family default
7961 \family default
7983 file.
7962 file.
7984 IPython will detect the user's choice of matplotlib GUI backend, and automatica
7963 IPython will detect the user's choice of matplotlib GUI backend, and automatica
7985 lly select the proper threading model to prevent blocking.
7964 lly select the proper threading model to prevent blocking.
7986 It also sets matplotlib in interactive mode and modifies
7965 It also sets matplotlib in interactive mode and modifies
7987 \family typewriter
7966 \family typewriter
7988 %run
7967 %run
7989 \family default
7968 \family default
7990 slightly, so that any matplotlib-based script can be executed using
7969 slightly, so that any matplotlib-based script can be executed using
7991 \family typewriter
7970 \family typewriter
7992 %run
7971 %run
7993 \family default
7972 \family default
7994 and the final
7973 and the final
7995 \family typewriter
7974 \family typewriter
7996 show()
7975 show()
7997 \family default
7976 \family default
7998 command does not block the interactive shell.
7977 command does not block the interactive shell.
7999 \layout Standard
7978 \layout Standard
8000
7979
8001 The
7980 The
8002 \family typewriter
7981 \family typewriter
8003 -pylab
7982 -pylab
8004 \family default
7983 \family default
8005 option must be given first in order for IPython to configure its threading
7984 option must be given first in order for IPython to configure its threading
8006 mode.
7985 mode.
8007 However, you can still issue other options afterwards.
7986 However, you can still issue other options afterwards.
8008 This allows you to have a matplotlib-based environment customized with
7987 This allows you to have a matplotlib-based environment customized with
8009 additional modules using the standard IPython profile mechanism (Sec.\SpecialChar ~
7988 additional modules using the standard IPython profile mechanism (Sec.\SpecialChar ~
8010
7989
8011 \begin_inset LatexCommand \ref{sec:profiles}
7990 \begin_inset LatexCommand \ref{sec:profiles}
8012
7991
8013 \end_inset
7992 \end_inset
8014
7993
8015 ): ``
7994 ): ``
8016 \family typewriter
7995 \family typewriter
8017 ipython -pylab -p myprofile
7996 ipython -pylab -p myprofile
8018 \family default
7997 \family default
8019 '' will load the profile defined in
7998 '' will load the profile defined in
8020 \family typewriter
7999 \family typewriter
8021 ipythonrc-myprofile
8000 ipythonrc-myprofile
8022 \family default
8001 \family default
8023 after configuring matplotlib.
8002 after configuring matplotlib.
8024 \layout Section
8003 \layout Section
8025
8004
8026
8005
8027 \begin_inset LatexCommand \label{sec:Gnuplot}
8006 \begin_inset LatexCommand \label{sec:Gnuplot}
8028
8007
8029 \end_inset
8008 \end_inset
8030
8009
8031 Plotting with
8010 Plotting with
8032 \family typewriter
8011 \family typewriter
8033 Gnuplot
8012 Gnuplot
8034 \layout Standard
8013 \layout Standard
8035
8014
8036 Through the magic extension system described in sec.
8015 Through the magic extension system described in sec.
8037
8016
8038 \begin_inset LatexCommand \ref{sec:magic}
8017 \begin_inset LatexCommand \ref{sec:magic}
8039
8018
8040 \end_inset
8019 \end_inset
8041
8020
8042 , IPython incorporates a mechanism for conveniently interfacing with the
8021 , IPython incorporates a mechanism for conveniently interfacing with the
8043 Gnuplot system (
8022 Gnuplot system (
8044 \begin_inset LatexCommand \htmlurl{http://www.gnuplot.info}
8023 \begin_inset LatexCommand \htmlurl{http://www.gnuplot.info}
8045
8024
8046 \end_inset
8025 \end_inset
8047
8026
8048 ).
8027 ).
8049 Gnuplot is a very complete 2D and 3D plotting package available for many
8028 Gnuplot is a very complete 2D and 3D plotting package available for many
8050 operating systems and commonly included in modern Linux distributions.
8029 operating systems and commonly included in modern Linux distributions.
8051
8030
8052 \layout Standard
8031 \layout Standard
8053
8032
8054 Besides having Gnuplot installed, this functionality requires the
8033 Besides having Gnuplot installed, this functionality requires the
8055 \family typewriter
8034 \family typewriter
8056 Gnuplot.py
8035 Gnuplot.py
8057 \family default
8036 \family default
8058 module for interfacing python with Gnuplot.
8037 module for interfacing python with Gnuplot.
8059 It can be downloaded from:
8038 It can be downloaded from:
8060 \begin_inset LatexCommand \htmlurl{http://gnuplot-py.sourceforge.net}
8039 \begin_inset LatexCommand \htmlurl{http://gnuplot-py.sourceforge.net}
8061
8040
8062 \end_inset
8041 \end_inset
8063
8042
8064 .
8043 .
8065 \layout Subsection
8044 \layout Subsection
8066
8045
8067 Proper Gnuplot configuration
8046 Proper Gnuplot configuration
8068 \layout Standard
8047 \layout Standard
8069
8048
8070 As of version 4.0, Gnuplot has excellent mouse and interactive keyboard support.
8049 As of version 4.0, Gnuplot has excellent mouse and interactive keyboard support.
8071 However, as of
8050 However, as of
8072 \family typewriter
8051 \family typewriter
8073 Gnuplot.py
8052 Gnuplot.py
8074 \family default
8053 \family default
8075 version 1.7, a new option was added to communicate between Python and Gnuplot
8054 version 1.7, a new option was added to communicate between Python and Gnuplot
8076 via FIFOs (pipes).
8055 via FIFOs (pipes).
8077 This mechanism, while fast, also breaks the mouse system.
8056 This mechanism, while fast, also breaks the mouse system.
8078 You must therefore set the variable
8057 You must therefore set the variable
8079 \family typewriter
8058 \family typewriter
8080 prefer_fifo_data
8059 prefer_fifo_data
8081 \family default
8060 \family default
8082 to
8061 to
8083 \family typewriter
8062 \family typewriter
8084 0
8063 0
8085 \family default
8064 \family default
8086 in file
8065 in file
8087 \family typewriter
8066 \family typewriter
8088 gp_unix.py
8067 gp_unix.py
8089 \family default
8068 \family default
8090 if you wish to keep the interactive mouse and keyboard features working
8069 if you wish to keep the interactive mouse and keyboard features working
8091 properly (
8070 properly (
8092 \family typewriter
8071 \family typewriter
8093 prefer_inline_data
8072 prefer_inline_data
8094 \family default
8073 \family default
8095 also must be
8074 also must be
8096 \family typewriter
8075 \family typewriter
8097 0
8076 0
8098 \family default
8077 \family default
8099 , but this is the default so unless you've changed it manually you should
8078 , but this is the default so unless you've changed it manually you should
8100 be fine).
8079 be fine).
8101 \layout Standard
8080 \layout Standard
8102
8081
8103 'Out of the box', Gnuplot is configured with a rather poor set of size,
8082 'Out of the box', Gnuplot is configured with a rather poor set of size,
8104 color and linewidth choices which make the graphs fairly hard to read on
8083 color and linewidth choices which make the graphs fairly hard to read on
8105 modern high-resolution displays (although they work fine on old 640x480
8084 modern high-resolution displays (although they work fine on old 640x480
8106 ones).
8085 ones).
8107 Below is a section of my
8086 Below is a section of my
8108 \family typewriter
8087 \family typewriter
8109 .Xdefaults
8088 .Xdefaults
8110 \family default
8089 \family default
8111 file which I use for having a more convenient Gnuplot setup.
8090 file which I use for having a more convenient Gnuplot setup.
8112 Remember to load it by running
8091 Remember to load it by running
8113 \family typewriter
8092 \family typewriter
8114 `xrdb .Xdefaults`
8093 `xrdb .Xdefaults`
8115 \family default
8094 \family default
8116 :
8095 :
8117 \layout Standard
8096 \layout Standard
8118
8097
8119
8098
8120 \family typewriter
8099 \family typewriter
8121 !******************************************************************
8100 !******************************************************************
8122 \newline
8101 \newline
8123 ! gnuplot options
8102 ! gnuplot options
8124 \newline
8103 \newline
8125 ! modify this for a convenient window size
8104 ! modify this for a convenient window size
8126 \newline
8105 \newline
8127 gnuplot*geometry: 780x580
8106 gnuplot*geometry: 780x580
8128 \layout Standard
8107 \layout Standard
8129
8108
8130
8109
8131 \family typewriter
8110 \family typewriter
8132 ! on-screen font (not for PostScript)
8111 ! on-screen font (not for PostScript)
8133 \newline
8112 \newline
8134 gnuplot*font: -misc-fixed-bold-r-normal--15-120-100-100-c-90-iso8859-1
8113 gnuplot*font: -misc-fixed-bold-r-normal--15-120-100-100-c-90-iso8859-1
8135 \layout Standard
8114 \layout Standard
8136
8115
8137
8116
8138 \family typewriter
8117 \family typewriter
8139 ! color options
8118 ! color options
8140 \newline
8119 \newline
8141 gnuplot*background: black
8120 gnuplot*background: black
8142 \newline
8121 \newline
8143 gnuplot*textColor: white
8122 gnuplot*textColor: white
8144 \newline
8123 \newline
8145 gnuplot*borderColor: white
8124 gnuplot*borderColor: white
8146 \newline
8125 \newline
8147 gnuplot*axisColor: white
8126 gnuplot*axisColor: white
8148 \newline
8127 \newline
8149 gnuplot*line1Color: red
8128 gnuplot*line1Color: red
8150 \newline
8129 \newline
8151 gnuplot*line2Color: green
8130 gnuplot*line2Color: green
8152 \newline
8131 \newline
8153 gnuplot*line3Color: blue
8132 gnuplot*line3Color: blue
8154 \newline
8133 \newline
8155 gnuplot*line4Color: magenta
8134 gnuplot*line4Color: magenta
8156 \newline
8135 \newline
8157 gnuplot*line5Color: cyan
8136 gnuplot*line5Color: cyan
8158 \newline
8137 \newline
8159 gnuplot*line6Color: sienna
8138 gnuplot*line6Color: sienna
8160 \newline
8139 \newline
8161 gnuplot*line7Color: orange
8140 gnuplot*line7Color: orange
8162 \newline
8141 \newline
8163 gnuplot*line8Color: coral
8142 gnuplot*line8Color: coral
8164 \layout Standard
8143 \layout Standard
8165
8144
8166
8145
8167 \family typewriter
8146 \family typewriter
8168 ! multiplicative factor for point styles
8147 ! multiplicative factor for point styles
8169 \newline
8148 \newline
8170 gnuplot*pointsize: 2
8149 gnuplot*pointsize: 2
8171 \layout Standard
8150 \layout Standard
8172
8151
8173
8152
8174 \family typewriter
8153 \family typewriter
8175 ! line width options (in pixels)
8154 ! line width options (in pixels)
8176 \newline
8155 \newline
8177 gnuplot*borderWidth: 2
8156 gnuplot*borderWidth: 2
8178 \newline
8157 \newline
8179 gnuplot*axisWidth: 2
8158 gnuplot*axisWidth: 2
8180 \newline
8159 \newline
8181 gnuplot*line1Width: 2
8160 gnuplot*line1Width: 2
8182 \newline
8161 \newline
8183 gnuplot*line2Width: 2
8162 gnuplot*line2Width: 2
8184 \newline
8163 \newline
8185 gnuplot*line3Width: 2
8164 gnuplot*line3Width: 2
8186 \newline
8165 \newline
8187 gnuplot*line4Width: 2
8166 gnuplot*line4Width: 2
8188 \newline
8167 \newline
8189 gnuplot*line5Width: 2
8168 gnuplot*line5Width: 2
8190 \newline
8169 \newline
8191 gnuplot*line6Width: 2
8170 gnuplot*line6Width: 2
8192 \newline
8171 \newline
8193 gnuplot*line7Width: 2
8172 gnuplot*line7Width: 2
8194 \newline
8173 \newline
8195 gnuplot*line8Width: 2
8174 gnuplot*line8Width: 2
8196 \layout Subsection
8175 \layout Subsection
8197
8176
8198 The
8177 The
8199 \family typewriter
8178 \family typewriter
8200 IPython.GnuplotRuntime
8179 IPython.GnuplotRuntime
8201 \family default
8180 \family default
8202 module
8181 module
8203 \layout Standard
8182 \layout Standard
8204
8183
8205 IPython includes a module called
8184 IPython includes a module called
8206 \family typewriter
8185 \family typewriter
8207 Gnuplot2.py
8186 Gnuplot2.py
8208 \family default
8187 \family default
8209 which extends and improves the default
8188 which extends and improves the default
8210 \family typewriter
8189 \family typewriter
8211 Gnuplot
8190 Gnuplot
8212 \family default
8191 \family default
8213 .
8192 .
8214 \family typewriter
8193 \family typewriter
8215 py
8194 py
8216 \family default
8195 \family default
8217 (which it still relies upon).
8196 (which it still relies upon).
8218 For example, the new
8197 For example, the new
8219 \family typewriter
8198 \family typewriter
8220 plot
8199 plot
8221 \family default
8200 \family default
8222 function adds several improvements to the original making it more convenient
8201 function adds several improvements to the original making it more convenient
8223 for interactive use, and
8202 for interactive use, and
8224 \family typewriter
8203 \family typewriter
8225 hardcopy
8204 hardcopy
8226 \family default
8205 \family default
8227 fixes a bug in the original which under some circumstances blocks the creation
8206 fixes a bug in the original which under some circumstances blocks the creation
8228 of PostScript output.
8207 of PostScript output.
8229 \layout Standard
8208 \layout Standard
8230
8209
8231 For scripting use,
8210 For scripting use,
8232 \family typewriter
8211 \family typewriter
8233 GnuplotRuntime.py
8212 GnuplotRuntime.py
8234 \family default
8213 \family default
8235 is provided, which wraps
8214 is provided, which wraps
8236 \family typewriter
8215 \family typewriter
8237 Gnuplot2.py
8216 Gnuplot2.py
8238 \family default
8217 \family default
8239 and creates a series of global aliases.
8218 and creates a series of global aliases.
8240 These make it easy to control Gnuplot plotting jobs through the Python
8219 These make it easy to control Gnuplot plotting jobs through the Python
8241 language.
8220 language.
8242 \layout Standard
8221 \layout Standard
8243
8222
8244 Below is some example code which illustrates how to configure Gnuplot inside
8223 Below is some example code which illustrates how to configure Gnuplot inside
8245 your own programs but have it available for further interactive use through
8224 your own programs but have it available for further interactive use through
8246 an embedded IPython instance.
8225 an embedded IPython instance.
8247 Simply run this file at a system prompt.
8226 Simply run this file at a system prompt.
8248 This file is provided as
8227 This file is provided as
8249 \family typewriter
8228 \family typewriter
8250 example-gnuplot.py
8229 example-gnuplot.py
8251 \family default
8230 \family default
8252 in the examples directory:
8231 in the examples directory:
8253 \layout Standard
8232 \layout Standard
8254
8233
8255
8234
8256 \begin_inset ERT
8235 \begin_inset ERT
8257 status Open
8236 status Open
8258
8237
8259 \layout Standard
8238 \layout Standard
8260
8239
8261 \backslash
8240 \backslash
8262 codelist{examples/example-gnuplot.py}
8241 codelist{examples/example-gnuplot.py}
8263 \end_inset
8242 \end_inset
8264
8243
8265
8244
8266 \layout Subsection
8245 \layout Subsection
8267
8246
8268 The
8247 The
8269 \family typewriter
8248 \family typewriter
8270 numeric
8249 numeric
8271 \family default
8250 \family default
8272 profile: a scientific computing environment
8251 profile: a scientific computing environment
8273 \layout Standard
8252 \layout Standard
8274
8253
8275 The
8254 The
8276 \family typewriter
8255 \family typewriter
8277 numeric
8256 numeric
8278 \family default
8257 \family default
8279 IPython profile, which you can activate with
8258 IPython profile, which you can activate with
8280 \family typewriter
8259 \family typewriter
8281 `ipython -p numeric
8260 `ipython -p numeric
8282 \family default
8261 \family default
8283 ' will automatically load the IPython Gnuplot extensions (plus Numeric and
8262 ' will automatically load the IPython Gnuplot extensions (plus Numeric and
8284 other useful things for numerical computing), contained in the
8263 other useful things for numerical computing), contained in the
8285 \family typewriter
8264 \family typewriter
8286 IPython.GnuplotInteractive
8265 IPython.GnuplotInteractive
8287 \family default
8266 \family default
8288 module.
8267 module.
8289 This will create the globals
8268 This will create the globals
8290 \family typewriter
8269 \family typewriter
8291 Gnuplot
8270 Gnuplot
8292 \family default
8271 \family default
8293 (an alias to the improved Gnuplot2 module),
8272 (an alias to the improved Gnuplot2 module),
8294 \family typewriter
8273 \family typewriter
8295 gp
8274 gp
8296 \family default
8275 \family default
8297 (a Gnuplot active instance), the new magic commands
8276 (a Gnuplot active instance), the new magic commands
8298 \family typewriter
8277 \family typewriter
8299 %gpc
8278 %gpc
8300 \family default
8279 \family default
8301 and
8280 and
8302 \family typewriter
8281 \family typewriter
8303 %gp_set_instance
8282 %gp_set_instance
8304 \family default
8283 \family default
8305 and several other convenient globals.
8284 and several other convenient globals.
8306 Type
8285 Type
8307 \family typewriter
8286 \family typewriter
8308 gphelp()
8287 gphelp()
8309 \family default
8288 \family default
8310 for further details.
8289 for further details.
8311 \layout Standard
8290 \layout Standard
8312
8291
8313 This should turn IPython into a convenient environment for numerical computing,
8292 This should turn IPython into a convenient environment for numerical computing,
8314 with all the functions in the NumPy library and the Gnuplot facilities
8293 with all the functions in the NumPy library and the Gnuplot facilities
8315 for plotting.
8294 for plotting.
8316 Further improvements can be obtained by loading the SciPy libraries for
8295 Further improvements can be obtained by loading the SciPy libraries for
8317 scientific computing, available at
8296 scientific computing, available at
8318 \begin_inset LatexCommand \htmlurl{http://scipy.org}
8297 \begin_inset LatexCommand \htmlurl{http://scipy.org}
8319
8298
8320 \end_inset
8299 \end_inset
8321
8300
8322 .
8301 .
8323 \layout Standard
8302 \layout Standard
8324
8303
8325 If you are in the middle of a working session with numerical objects and
8304 If you are in the middle of a working session with numerical objects and
8326 need to plot them but you didn't start the
8305 need to plot them but you didn't start the
8327 \family typewriter
8306 \family typewriter
8328 numeric
8307 numeric
8329 \family default
8308 \family default
8330 profile, you can load these extensions at any time by typing
8309 profile, you can load these extensions at any time by typing
8331 \newline
8310 \newline
8332
8311
8333 \family typewriter
8312 \family typewriter
8334 from IPython.GnuplotInteractive import *
8313 from IPython.GnuplotInteractive import *
8335 \newline
8314 \newline
8336
8315
8337 \family default
8316 \family default
8338 at the IPython prompt.
8317 at the IPython prompt.
8339 This will allow you to keep your objects intact and start using Gnuplot
8318 This will allow you to keep your objects intact and start using Gnuplot
8340 to view them.
8319 to view them.
8341 \layout Section
8320 \layout Section
8342
8321
8343 Reporting bugs
8322 Reporting bugs
8344 \layout Subsection*
8323 \layout Subsection*
8345
8324
8346 Automatic crash reports
8325 Automatic crash reports
8347 \layout Standard
8326 \layout Standard
8348
8327
8349 Ideally, IPython itself shouldn't crash.
8328 Ideally, IPython itself shouldn't crash.
8350 It will catch exceptions produced by you, but bugs in its internals will
8329 It will catch exceptions produced by you, but bugs in its internals will
8351 still crash it.
8330 still crash it.
8352 \layout Standard
8331 \layout Standard
8353
8332
8354 In such a situation, IPython will leave a file named
8333 In such a situation, IPython will leave a file named
8355 \family typewriter
8334 \family typewriter
8356 IPython_crash_report.txt
8335 IPython_crash_report.txt
8357 \family default
8336 \family default
8358 in your IPYTHONDIR directory (that way if crashes happen several times
8337 in your IPYTHONDIR directory (that way if crashes happen several times
8359 it won't litter many directories, the post-mortem file is always located
8338 it won't litter many directories, the post-mortem file is always located
8360 in the same place and new occurrences just overwrite the previous one).
8339 in the same place and new occurrences just overwrite the previous one).
8361 If you can mail this file to the developers (see sec.
8340 If you can mail this file to the developers (see sec.
8362
8341
8363 \begin_inset LatexCommand \ref{sec:credits}
8342 \begin_inset LatexCommand \ref{sec:credits}
8364
8343
8365 \end_inset
8344 \end_inset
8366
8345
8367 for names and addresses), it will help us
8346 for names and addresses), it will help us
8368 \emph on
8347 \emph on
8369 a lot
8348 a lot
8370 \emph default
8349 \emph default
8371 in understanding the cause of the problem and fixing it sooner.
8350 in understanding the cause of the problem and fixing it sooner.
8372 \layout Subsection*
8351 \layout Subsection*
8373
8352
8374 The bug tracker
8353 The bug tracker
8375 \layout Standard
8354 \layout Standard
8376
8355
8377 IPython also has an online bug-tracker, located at
8356 IPython also has an online bug-tracker, located at
8378 \begin_inset LatexCommand \htmlurl{http://www.scipy.net/roundup/ipython}
8357 \begin_inset LatexCommand \htmlurl{http://www.scipy.net/roundup/ipython}
8379
8358
8380 \end_inset
8359 \end_inset
8381
8360
8382 .
8361 .
8383 In addition to mailing the developers, it would be a good idea to file
8362 In addition to mailing the developers, it would be a good idea to file
8384 a bug report here.
8363 a bug report here.
8385 This will ensure that the issue is properly followed to conclusion.
8364 This will ensure that the issue is properly followed to conclusion.
8386 \layout Standard
8365 \layout Standard
8387
8366
8388 You can also use this bug tracker to file feature requests.
8367 You can also use this bug tracker to file feature requests.
8389 \layout Section
8368 \layout Section
8390
8369
8391 Brief history
8370 Brief history
8392 \layout Subsection
8371 \layout Subsection
8393
8372
8394 Origins
8373 Origins
8395 \layout Standard
8374 \layout Standard
8396
8375
8397 The current IPython system grew out of the following three projects:
8376 The current IPython system grew out of the following three projects:
8398 \layout List
8377 \layout List
8399 \labelwidthstring 00.00.0000
8378 \labelwidthstring 00.00.0000
8400
8379
8401 ipython by Fernando Pérez.
8380 ipython by Fernando Pérez.
8402 I was working on adding Mathematica-type prompts and a flexible configuration
8381 I was working on adding Mathematica-type prompts and a flexible configuration
8403 system (something better than
8382 system (something better than
8404 \family typewriter
8383 \family typewriter
8405 $PYTHONSTARTUP
8384 $PYTHONSTARTUP
8406 \family default
8385 \family default
8407 ) to the standard Python interactive interpreter.
8386 ) to the standard Python interactive interpreter.
8408 \layout List
8387 \layout List
8409 \labelwidthstring 00.00.0000
8388 \labelwidthstring 00.00.0000
8410
8389
8411 IPP by Janko Hauser.
8390 IPP by Janko Hauser.
8412 Very well organized, great usability.
8391 Very well organized, great usability.
8413 Had an old help system.
8392 Had an old help system.
8414 IPP was used as the `container' code into which I added the functionality
8393 IPP was used as the `container' code into which I added the functionality
8415 from ipython and LazyPython.
8394 from ipython and LazyPython.
8416 \layout List
8395 \layout List
8417 \labelwidthstring 00.00.0000
8396 \labelwidthstring 00.00.0000
8418
8397
8419 LazyPython by Nathan Gray.
8398 LazyPython by Nathan Gray.
8420 Simple but
8399 Simple but
8421 \emph on
8400 \emph on
8422 very
8401 very
8423 \emph default
8402 \emph default
8424 powerful.
8403 powerful.
8425 The quick syntax (auto parens, auto quotes) and verbose/colored tracebacks
8404 The quick syntax (auto parens, auto quotes) and verbose/colored tracebacks
8426 were all taken from here.
8405 were all taken from here.
8427 \layout Standard
8406 \layout Standard
8428
8407
8429 When I found out (see sec.
8408 When I found out (see sec.
8430
8409
8431 \begin_inset LatexCommand \ref{figgins}
8410 \begin_inset LatexCommand \ref{figgins}
8432
8411
8433 \end_inset
8412 \end_inset
8434
8413
8435 ) about IPP and LazyPython I tried to join all three into a unified system.
8414 ) about IPP and LazyPython I tried to join all three into a unified system.
8436 I thought this could provide a very nice working environment, both for
8415 I thought this could provide a very nice working environment, both for
8437 regular programming and scientific computing: shell-like features, IDL/Matlab
8416 regular programming and scientific computing: shell-like features, IDL/Matlab
8438 numerics, Mathematica-type prompt history and great object introspection
8417 numerics, Mathematica-type prompt history and great object introspection
8439 and help facilities.
8418 and help facilities.
8440 I think it worked reasonably well, though it was a lot more work than I
8419 I think it worked reasonably well, though it was a lot more work than I
8441 had initially planned.
8420 had initially planned.
8442 \layout Subsection
8421 \layout Subsection
8443
8422
8444 Current status
8423 Current status
8445 \layout Standard
8424 \layout Standard
8446
8425
8447 The above listed features work, and quite well for the most part.
8426 The above listed features work, and quite well for the most part.
8448 But until a major internal restructuring is done (see below), only bug
8427 But until a major internal restructuring is done (see below), only bug
8449 fixing will be done, no other features will be added (unless very minor
8428 fixing will be done, no other features will be added (unless very minor
8450 and well localized in the cleaner parts of the code).
8429 and well localized in the cleaner parts of the code).
8451 \layout Standard
8430 \layout Standard
8452
8431
8453 IPython consists of some 12000 lines of pure python code, of which roughly
8432 IPython consists of some 12000 lines of pure python code, of which roughly
8454 50% are fairly clean.
8433 50% are fairly clean.
8455 The other 50% are fragile, messy code which needs a massive restructuring
8434 The other 50% are fragile, messy code which needs a massive restructuring
8456 before any further major work is done.
8435 before any further major work is done.
8457 Even the messy code is fairly well documented though, and most of the problems
8436 Even the messy code is fairly well documented though, and most of the problems
8458 in the (non-existent) class design are well pointed to by a PyChecker run.
8437 in the (non-existent) class design are well pointed to by a PyChecker run.
8459 So the rewriting work isn't that bad, it will just be time-consuming.
8438 So the rewriting work isn't that bad, it will just be time-consuming.
8460 \layout Subsection
8439 \layout Subsection
8461
8440
8462 Future
8441 Future
8463 \layout Standard
8442 \layout Standard
8464
8443
8465 See the separate
8444 See the separate
8466 \family typewriter
8445 \family typewriter
8467 new_design
8446 new_design
8468 \family default
8447 \family default
8469 document for details.
8448 document for details.
8470 Ultimately, I would like to see IPython become part of the standard Python
8449 Ultimately, I would like to see IPython become part of the standard Python
8471 distribution as a `big brother with batteries' to the standard Python interacti
8450 distribution as a `big brother with batteries' to the standard Python interacti
8472 ve interpreter.
8451 ve interpreter.
8473 But that will never happen with the current state of the code, so all contribut
8452 But that will never happen with the current state of the code, so all contribut
8474 ions are welcome.
8453 ions are welcome.
8475 \layout Section
8454 \layout Section
8476
8455
8477 License
8456 License
8478 \layout Standard
8457 \layout Standard
8479
8458
8480 IPython is released under the terms of the BSD license, whose general form
8459 IPython is released under the terms of the BSD license, whose general form
8481 can be found at:
8460 can be found at:
8482 \begin_inset LatexCommand \htmlurl{http://www.opensource.org/licenses/bsd-license.php}
8461 \begin_inset LatexCommand \htmlurl{http://www.opensource.org/licenses/bsd-license.php}
8483
8462
8484 \end_inset
8463 \end_inset
8485
8464
8486 .
8465 .
8487 The full text of the IPython license is reproduced below:
8466 The full text of the IPython license is reproduced below:
8488 \layout Quote
8467 \layout Quote
8489
8468
8490
8469
8491 \family typewriter
8470 \family typewriter
8492 \size small
8471 \size small
8493 IPython is released under a BSD-type license.
8472 IPython is released under a BSD-type license.
8494 \layout Quote
8473 \layout Quote
8495
8474
8496
8475
8497 \family typewriter
8476 \family typewriter
8498 \size small
8477 \size small
8499 Copyright (c) 2001, 2002, 2003, 2004 Fernando Perez <fperez@colorado.edu>.
8478 Copyright (c) 2001, 2002, 2003, 2004 Fernando Perez <fperez@colorado.edu>.
8500 \layout Quote
8479 \layout Quote
8501
8480
8502
8481
8503 \family typewriter
8482 \family typewriter
8504 \size small
8483 \size small
8505 Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and
8484 Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and
8506 \newline
8485 \newline
8507 Nathaniel Gray <n8gray@caltech.edu>.
8486 Nathaniel Gray <n8gray@caltech.edu>.
8508 \layout Quote
8487 \layout Quote
8509
8488
8510
8489
8511 \family typewriter
8490 \family typewriter
8512 \size small
8491 \size small
8513 All rights reserved.
8492 All rights reserved.
8514 \layout Quote
8493 \layout Quote
8515
8494
8516
8495
8517 \family typewriter
8496 \family typewriter
8518 \size small
8497 \size small
8519 Redistribution and use in source and binary forms, with or without modification,
8498 Redistribution and use in source and binary forms, with or without modification,
8520 are permitted provided that the following conditions are met:
8499 are permitted provided that the following conditions are met:
8521 \layout Quote
8500 \layout Quote
8522
8501
8523
8502
8524 \family typewriter
8503 \family typewriter
8525 \size small
8504 \size small
8526 a.
8505 a.
8527 Redistributions of source code must retain the above copyright notice,
8506 Redistributions of source code must retain the above copyright notice,
8528 this list of conditions and the following disclaimer.
8507 this list of conditions and the following disclaimer.
8529 \layout Quote
8508 \layout Quote
8530
8509
8531
8510
8532 \family typewriter
8511 \family typewriter
8533 \size small
8512 \size small
8534 b.
8513 b.
8535 Redistributions in binary form must reproduce the above copyright notice,
8514 Redistributions in binary form must reproduce the above copyright notice,
8536 this list of conditions and the following disclaimer in the documentation
8515 this list of conditions and the following disclaimer in the documentation
8537 and/or other materials provided with the distribution.
8516 and/or other materials provided with the distribution.
8538 \layout Quote
8517 \layout Quote
8539
8518
8540
8519
8541 \family typewriter
8520 \family typewriter
8542 \size small
8521 \size small
8543 c.
8522 c.
8544 Neither the name of the copyright holders nor the names of any contributors
8523 Neither the name of the copyright holders nor the names of any contributors
8545 to this software may be used to endorse or promote products derived from
8524 to this software may be used to endorse or promote products derived from
8546 this software without specific prior written permission.
8525 this software without specific prior written permission.
8547 \layout Quote
8526 \layout Quote
8548
8527
8549
8528
8550 \family typewriter
8529 \family typewriter
8551 \size small
8530 \size small
8552 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
8531 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
8553 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
8532 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
8554 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
8533 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
8555 PURPOSE ARE DISCLAIMED.
8534 PURPOSE ARE DISCLAIMED.
8556 IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
8535 IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
8557 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
8536 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
8558 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
8537 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
8559 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
8538 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
8560 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
8539 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
8561 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
8540 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
8562 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8541 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8563
8542
8564 \layout Standard
8543 \layout Standard
8565
8544
8566 Individual authors are the holders of the copyright for their code and are
8545 Individual authors are the holders of the copyright for their code and are
8567 listed in each file.
8546 listed in each file.
8568 \layout Standard
8547 \layout Standard
8569
8548
8570 Some files (
8549 Some files (
8571 \family typewriter
8550 \family typewriter
8572 DPyGetOpt.py
8551 DPyGetOpt.py
8573 \family default
8552 \family default
8574 , for example) may be licensed under different conditions.
8553 , for example) may be licensed under different conditions.
8575 Ultimately each file indicates clearly the conditions under which its author/au
8554 Ultimately each file indicates clearly the conditions under which its author/au
8576 thors have decided to publish the code.
8555 thors have decided to publish the code.
8577 \layout Standard
8556 \layout Standard
8578
8557
8579 Versions of IPython up to and including 0.6.3 were released under the GNU
8558 Versions of IPython up to and including 0.6.3 were released under the GNU
8580 Lesser General Public License (LGPL), available at
8559 Lesser General Public License (LGPL), available at
8581 \begin_inset LatexCommand \htmlurl{http://www.gnu.org/copyleft/lesser.html}
8560 \begin_inset LatexCommand \htmlurl{http://www.gnu.org/copyleft/lesser.html}
8582
8561
8583 \end_inset
8562 \end_inset
8584
8563
8585 .
8564 .
8586 \layout Section
8565 \layout Section
8587
8566
8588
8567
8589 \begin_inset LatexCommand \label{sec:credits}
8568 \begin_inset LatexCommand \label{sec:credits}
8590
8569
8591 \end_inset
8570 \end_inset
8592
8571
8593 Credits
8572 Credits
8594 \layout Standard
8573 \layout Standard
8595
8574
8596 IPython is mainly developed by Fernando Pérez
8575 IPython is mainly developed by Fernando Pérez
8597 \family typewriter
8576 \family typewriter
8598 <fperez@colorado.edu>
8577 <fperez@colorado.edu>
8599 \family default
8578 \family default
8600 , but the project was born from mixing in Fernando's code with the IPP project
8579 , but the project was born from mixing in Fernando's code with the IPP project
8601 by Janko Hauser
8580 by Janko Hauser
8602 \family typewriter
8581 \family typewriter
8603 <jhauser-AT-zscout.de>
8582 <jhauser-AT-zscout.de>
8604 \family default
8583 \family default
8605 and LazyPython by Nathan Gray
8584 and LazyPython by Nathan Gray
8606 \family typewriter
8585 \family typewriter
8607 <n8gray-AT-caltech.edu>
8586 <n8gray-AT-caltech.edu>
8608 \family default
8587 \family default
8609 .
8588 .
8610 For all IPython-related requests, please contact Fernando.
8589 For all IPython-related requests, please contact Fernando.
8611
8590
8612 \layout Standard
8591 \layout Standard
8613
8592
8614 As of late 2005, the following developers have joined the core team:
8593 As of late 2005, the following developers have joined the core team:
8615 \layout List
8594 \layout List
8616 \labelwidthstring 00.00.0000
8595 \labelwidthstring 00.00.0000
8617
8596
8618 Robert\SpecialChar ~
8597 Robert\SpecialChar ~
8619 Kern
8598 Kern
8620 \family typewriter
8599 \family typewriter
8621 <rkern-AT-enthought.com>
8600 <rkern-AT-enthought.com>
8622 \family default
8601 \family default
8623 : co-mentored the 2005 Google Summer of Code project to develop python interacti
8602 : co-mentored the 2005 Google Summer of Code project to develop python interacti
8624 ve notebooks (XML documents) and graphical interface.
8603 ve notebooks (XML documents) and graphical interface.
8625 This project was awarded to the students Tzanko Matev
8604 This project was awarded to the students Tzanko Matev
8626 \family typewriter
8605 \family typewriter
8627 <tsanko-AT-gmail.com>
8606 <tsanko-AT-gmail.com>
8628 \family default
8607 \family default
8629 and Toni Alatalo
8608 and Toni Alatalo
8630 \family typewriter
8609 \family typewriter
8631 <antont-AT-an.org>
8610 <antont-AT-an.org>
8632 \layout List
8611 \layout List
8633 \labelwidthstring 00.00.0000
8612 \labelwidthstring 00.00.0000
8634
8613
8635 Brian\SpecialChar ~
8614 Brian\SpecialChar ~
8636 Granger
8615 Granger
8637 \family typewriter
8616 \family typewriter
8638 <bgranger-AT-scu.edu>
8617 <bgranger-AT-scu.edu>
8639 \family default
8618 \family default
8640 : extending IPython to allow support for interactive parallel computing.
8619 : extending IPython to allow support for interactive parallel computing.
8641 \layout Standard
8620 \layout Standard
8642
8621
8643 User or development help should be requested via the IPython mailing lists:
8622 User or development help should be requested via the IPython mailing lists:
8644 \layout Description
8623 \layout Description
8645
8624
8646 User\SpecialChar ~
8625 User\SpecialChar ~
8647 list:
8626 list:
8648 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-user}
8627 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-user}
8649
8628
8650 \end_inset
8629 \end_inset
8651
8630
8652
8631
8653 \layout Description
8632 \layout Description
8654
8633
8655 Developer's\SpecialChar ~
8634 Developer's\SpecialChar ~
8656 list:
8635 list:
8657 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-dev}
8636 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-dev}
8658
8637
8659 \end_inset
8638 \end_inset
8660
8639
8661
8640
8662 \layout Standard
8641 \layout Standard
8663
8642
8664 The IPython project is also very grateful to
8643 The IPython project is also very grateful to
8665 \begin_inset Foot
8644 \begin_inset Foot
8666 collapsed true
8645 collapsed true
8667
8646
8668 \layout Standard
8647 \layout Standard
8669
8648
8670 I've mangled email addresses to reduce spam, since the IPython manuals can
8649 I've mangled email addresses to reduce spam, since the IPython manuals can
8671 be accessed online.
8650 be accessed online.
8672 \end_inset
8651 \end_inset
8673
8652
8674 :
8653 :
8675 \layout Standard
8654 \layout Standard
8676
8655
8677 Bill Bumgarner
8656 Bill Bumgarner
8678 \family typewriter
8657 \family typewriter
8679 <bbum-AT-friday.com>
8658 <bbum-AT-friday.com>
8680 \family default
8659 \family default
8681 : for providing the DPyGetOpt module which gives very powerful and convenient
8660 : for providing the DPyGetOpt module which gives very powerful and convenient
8682 handling of command-line options (light years ahead of what Python 2.1.1's
8661 handling of command-line options (light years ahead of what Python 2.1.1's
8683 getopt module does).
8662 getopt module does).
8684 \layout Standard
8663 \layout Standard
8685
8664
8686 Ka-Ping Yee
8665 Ka-Ping Yee
8687 \family typewriter
8666 \family typewriter
8688 <ping-AT-lfw.org>
8667 <ping-AT-lfw.org>
8689 \family default
8668 \family default
8690 : for providing the Itpl module for convenient and powerful string interpolation
8669 : for providing the Itpl module for convenient and powerful string interpolation
8691 with a much nicer syntax than formatting through the '%' operator.
8670 with a much nicer syntax than formatting through the '%' operator.
8692 \layout Standard
8671 \layout Standard
8693
8672
8694 Arnd Bäcker
8673 Arnd Bäcker
8695 \family typewriter
8674 \family typewriter
8696 <baecker-AT-physik.tu-dresden.de>
8675 <baecker-AT-physik.tu-dresden.de>
8697 \family default
8676 \family default
8698 : for his many very useful suggestions and comments, and lots of help with
8677 : for his many very useful suggestions and comments, and lots of help with
8699 testing and documentation checking.
8678 testing and documentation checking.
8700 Many of IPython's newer features are a result of discussions with him (bugs
8679 Many of IPython's newer features are a result of discussions with him (bugs
8701 are still my fault, not his).
8680 are still my fault, not his).
8702 \layout Standard
8681 \layout Standard
8703
8682
8704 Obviously Guido van\SpecialChar ~
8683 Obviously Guido van\SpecialChar ~
8705 Rossum and the whole Python development team, that goes
8684 Rossum and the whole Python development team, that goes
8706 without saying.
8685 without saying.
8707 \layout Standard
8686 \layout Standard
8708
8687
8709 IPython's website is generously hosted at
8688 IPython's website is generously hosted at
8710 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
8689 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
8711
8690
8712 \end_inset
8691 \end_inset
8713
8692
8714 by Enthought (
8693 by Enthought (
8715 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
8694 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
8716
8695
8717 \end_inset
8696 \end_inset
8718
8697
8719 ).
8698 ).
8720 I am very grateful to them and all of the SciPy team for their contribution.
8699 I am very grateful to them and all of the SciPy team for their contribution.
8721 \layout Standard
8700 \layout Standard
8722
8701
8723
8702
8724 \begin_inset LatexCommand \label{figgins}
8703 \begin_inset LatexCommand \label{figgins}
8725
8704
8726 \end_inset
8705 \end_inset
8727
8706
8728 Fernando would also like to thank Stephen Figgins
8707 Fernando would also like to thank Stephen Figgins
8729 \family typewriter
8708 \family typewriter
8730 <fig-AT-monitor.net>
8709 <fig-AT-monitor.net>
8731 \family default
8710 \family default
8732 , an O'Reilly Python editor.
8711 , an O'Reilly Python editor.
8733 His Oct/11/2001 article about IPP and LazyPython, was what got this project
8712 His Oct/11/2001 article about IPP and LazyPython, was what got this project
8734 started.
8713 started.
8735 You can read it at:
8714 You can read it at:
8736 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2001/10/11/pythonnews.html}
8715 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2001/10/11/pythonnews.html}
8737
8716
8738 \end_inset
8717 \end_inset
8739
8718
8740 .
8719 .
8741 \layout Standard
8720 \layout Standard
8742
8721
8743 And last but not least, all the kind IPython users who have emailed new
8722 And last but not least, all the kind IPython users who have emailed new
8744 code, bug reports, fixes, comments and ideas.
8723 code, bug reports, fixes, comments and ideas.
8745 A brief list follows, please let me know if I have ommitted your name by
8724 A brief list follows, please let me know if I have ommitted your name by
8746 accident:
8725 accident:
8747 \layout List
8726 \layout List
8748 \labelwidthstring 00.00.0000
8727 \labelwidthstring 00.00.0000
8749
8728
8750 Jack\SpecialChar ~
8729 Jack\SpecialChar ~
8751 Moffit
8730 Moffit
8752 \family typewriter
8731 \family typewriter
8753 <jack-AT-xiph.org>
8732 <jack-AT-xiph.org>
8754 \family default
8733 \family default
8755 Bug fixes, including the infamous color problem.
8734 Bug fixes, including the infamous color problem.
8756 This bug alone caused many lost hours and frustration, many thanks to him
8735 This bug alone caused many lost hours and frustration, many thanks to him
8757 for the fix.
8736 for the fix.
8758 I've always been a fan of Ogg & friends, now I have one more reason to
8737 I've always been a fan of Ogg & friends, now I have one more reason to
8759 like these folks.
8738 like these folks.
8760 \newline
8739 \newline
8761 Jack is also contributing with Debian packaging and many other things.
8740 Jack is also contributing with Debian packaging and many other things.
8762 \layout List
8741 \layout List
8763 \labelwidthstring 00.00.0000
8742 \labelwidthstring 00.00.0000
8764
8743
8765 Alexander\SpecialChar ~
8744 Alexander\SpecialChar ~
8766 Schmolck
8745 Schmolck
8767 \family typewriter
8746 \family typewriter
8768 <a.schmolck-AT-gmx.net>
8747 <a.schmolck-AT-gmx.net>
8769 \family default
8748 \family default
8770 Emacs work, bug reports, bug fixes, ideas, lots more.
8749 Emacs work, bug reports, bug fixes, ideas, lots more.
8771 The ipython.el mode for (X)Emacs is Alex's code, providing full support
8750 The ipython.el mode for (X)Emacs is Alex's code, providing full support
8772 for IPython under (X)Emacs.
8751 for IPython under (X)Emacs.
8773 \layout List
8752 \layout List
8774 \labelwidthstring 00.00.0000
8753 \labelwidthstring 00.00.0000
8775
8754
8776 Andrea\SpecialChar ~
8755 Andrea\SpecialChar ~
8777 Riciputi
8756 Riciputi
8778 \family typewriter
8757 \family typewriter
8779 <andrea.riciputi-AT-libero.it>
8758 <andrea.riciputi-AT-libero.it>
8780 \family default
8759 \family default
8781 Mac OSX information, Fink package management.
8760 Mac OSX information, Fink package management.
8782 \layout List
8761 \layout List
8783 \labelwidthstring 00.00.0000
8762 \labelwidthstring 00.00.0000
8784
8763
8785 Gary\SpecialChar ~
8764 Gary\SpecialChar ~
8786 Bishop
8765 Bishop
8787 \family typewriter
8766 \family typewriter
8788 <gb-AT-cs.unc.edu>
8767 <gb-AT-cs.unc.edu>
8789 \family default
8768 \family default
8790 Bug reports, and patches to work around the exception handling idiosyncracies
8769 Bug reports, and patches to work around the exception handling idiosyncracies
8791 of WxPython.
8770 of WxPython.
8792 Readline and color support for Windows.
8771 Readline and color support for Windows.
8793 \layout List
8772 \layout List
8794 \labelwidthstring 00.00.0000
8773 \labelwidthstring 00.00.0000
8795
8774
8796 Jeffrey\SpecialChar ~
8775 Jeffrey\SpecialChar ~
8797 Collins
8776 Collins
8798 \family typewriter
8777 \family typewriter
8799 <Jeff.Collins-AT-vexcel.com>
8778 <Jeff.Collins-AT-vexcel.com>
8800 \family default
8779 \family default
8801 Bug reports.
8780 Bug reports.
8802 Much improved readline support, including fixes for Python 2.3.
8781 Much improved readline support, including fixes for Python 2.3.
8803 \layout List
8782 \layout List
8804 \labelwidthstring 00.00.0000
8783 \labelwidthstring 00.00.0000
8805
8784
8806 Dryice\SpecialChar ~
8785 Dryice\SpecialChar ~
8807 Liu
8786 Liu
8808 \family typewriter
8787 \family typewriter
8809 <dryice-AT-liu.com.cn>
8788 <dryice-AT-liu.com.cn>
8810 \family default
8789 \family default
8811 FreeBSD port.
8790 FreeBSD port.
8812 \layout List
8791 \layout List
8813 \labelwidthstring 00.00.0000
8792 \labelwidthstring 00.00.0000
8814
8793
8815 Mike\SpecialChar ~
8794 Mike\SpecialChar ~
8816 Heeter
8795 Heeter
8817 \family typewriter
8796 \family typewriter
8818 <korora-AT-SDF.LONESTAR.ORG>
8797 <korora-AT-SDF.LONESTAR.ORG>
8819 \layout List
8798 \layout List
8820 \labelwidthstring 00.00.0000
8799 \labelwidthstring 00.00.0000
8821
8800
8822 Christopher\SpecialChar ~
8801 Christopher\SpecialChar ~
8823 Hart
8802 Hart
8824 \family typewriter
8803 \family typewriter
8825 <hart-AT-caltech.edu>
8804 <hart-AT-caltech.edu>
8826 \family default
8805 \family default
8827 PDB integration.
8806 PDB integration.
8828 \layout List
8807 \layout List
8829 \labelwidthstring 00.00.0000
8808 \labelwidthstring 00.00.0000
8830
8809
8831 Milan\SpecialChar ~
8810 Milan\SpecialChar ~
8832 Zamazal
8811 Zamazal
8833 \family typewriter
8812 \family typewriter
8834 <pdm-AT-zamazal.org>
8813 <pdm-AT-zamazal.org>
8835 \family default
8814 \family default
8836 Emacs info.
8815 Emacs info.
8837 \layout List
8816 \layout List
8838 \labelwidthstring 00.00.0000
8817 \labelwidthstring 00.00.0000
8839
8818
8840 Philip\SpecialChar ~
8819 Philip\SpecialChar ~
8841 Hisley
8820 Hisley
8842 \family typewriter
8821 \family typewriter
8843 <compsys-AT-starpower.net>
8822 <compsys-AT-starpower.net>
8844 \layout List
8823 \layout List
8845 \labelwidthstring 00.00.0000
8824 \labelwidthstring 00.00.0000
8846
8825
8847 Holger\SpecialChar ~
8826 Holger\SpecialChar ~
8848 Krekel
8827 Krekel
8849 \family typewriter
8828 \family typewriter
8850 <pyth-AT-devel.trillke.net>
8829 <pyth-AT-devel.trillke.net>
8851 \family default
8830 \family default
8852 Tab completion, lots more.
8831 Tab completion, lots more.
8853 \layout List
8832 \layout List
8854 \labelwidthstring 00.00.0000
8833 \labelwidthstring 00.00.0000
8855
8834
8856 Robin\SpecialChar ~
8835 Robin\SpecialChar ~
8857 Siebler
8836 Siebler
8858 \family typewriter
8837 \family typewriter
8859 <robinsiebler-AT-starband.net>
8838 <robinsiebler-AT-starband.net>
8860 \layout List
8839 \layout List
8861 \labelwidthstring 00.00.0000
8840 \labelwidthstring 00.00.0000
8862
8841
8863 Ralf\SpecialChar ~
8842 Ralf\SpecialChar ~
8864 Ahlbrink
8843 Ahlbrink
8865 \family typewriter
8844 \family typewriter
8866 <ralf_ahlbrink-AT-web.de>
8845 <ralf_ahlbrink-AT-web.de>
8867 \layout List
8846 \layout List
8868 \labelwidthstring 00.00.0000
8847 \labelwidthstring 00.00.0000
8869
8848
8870 Thorsten\SpecialChar ~
8849 Thorsten\SpecialChar ~
8871 Kampe
8850 Kampe
8872 \family typewriter
8851 \family typewriter
8873 <thorsten-AT-thorstenkampe.de>
8852 <thorsten-AT-thorstenkampe.de>
8874 \layout List
8853 \layout List
8875 \labelwidthstring 00.00.0000
8854 \labelwidthstring 00.00.0000
8876
8855
8877 Fredrik\SpecialChar ~
8856 Fredrik\SpecialChar ~
8878 Kant
8857 Kant
8879 \family typewriter
8858 \family typewriter
8880 <fredrik.kant-AT-front.com>
8859 <fredrik.kant-AT-front.com>
8881 \family default
8860 \family default
8882 Windows setup.
8861 Windows setup.
8883 \layout List
8862 \layout List
8884 \labelwidthstring 00.00.0000
8863 \labelwidthstring 00.00.0000
8885
8864
8886 Syver\SpecialChar ~
8865 Syver\SpecialChar ~
8887 Enstad
8866 Enstad
8888 \family typewriter
8867 \family typewriter
8889 <syver-en-AT-online.no>
8868 <syver-en-AT-online.no>
8890 \family default
8869 \family default
8891 Windows setup.
8870 Windows setup.
8892 \layout List
8871 \layout List
8893 \labelwidthstring 00.00.0000
8872 \labelwidthstring 00.00.0000
8894
8873
8895 Richard
8874 Richard
8896 \family typewriter
8875 \family typewriter
8897 <rxe-AT-renre-europe.com>
8876 <rxe-AT-renre-europe.com>
8898 \family default
8877 \family default
8899 Global embedding.
8878 Global embedding.
8900 \layout List
8879 \layout List
8901 \labelwidthstring 00.00.0000
8880 \labelwidthstring 00.00.0000
8902
8881
8903 Hayden\SpecialChar ~
8882 Hayden\SpecialChar ~
8904 Callow
8883 Callow
8905 \family typewriter
8884 \family typewriter
8906 <h.callow-AT-elec.canterbury.ac.nz>
8885 <h.callow-AT-elec.canterbury.ac.nz>
8907 \family default
8886 \family default
8908 Gnuplot.py 1.6 compatibility.
8887 Gnuplot.py 1.6 compatibility.
8909 \layout List
8888 \layout List
8910 \labelwidthstring 00.00.0000
8889 \labelwidthstring 00.00.0000
8911
8890
8912 Leonardo\SpecialChar ~
8891 Leonardo\SpecialChar ~
8913 Santagada
8892 Santagada
8914 \family typewriter
8893 \family typewriter
8915 <retype-AT-terra.com.br>
8894 <retype-AT-terra.com.br>
8916 \family default
8895 \family default
8917 Fixes for Windows installation.
8896 Fixes for Windows installation.
8918 \layout List
8897 \layout List
8919 \labelwidthstring 00.00.0000
8898 \labelwidthstring 00.00.0000
8920
8899
8921 Christopher\SpecialChar ~
8900 Christopher\SpecialChar ~
8922 Armstrong
8901 Armstrong
8923 \family typewriter
8902 \family typewriter
8924 <radix-AT-twistedmatrix.com>
8903 <radix-AT-twistedmatrix.com>
8925 \family default
8904 \family default
8926 Bugfixes.
8905 Bugfixes.
8927 \layout List
8906 \layout List
8928 \labelwidthstring 00.00.0000
8907 \labelwidthstring 00.00.0000
8929
8908
8930 Francois\SpecialChar ~
8909 Francois\SpecialChar ~
8931 Pinard
8910 Pinard
8932 \family typewriter
8911 \family typewriter
8933 <pinard-AT-iro.umontreal.ca>
8912 <pinard-AT-iro.umontreal.ca>
8934 \family default
8913 \family default
8935 Code and documentation fixes.
8914 Code and documentation fixes.
8936 \layout List
8915 \layout List
8937 \labelwidthstring 00.00.0000
8916 \labelwidthstring 00.00.0000
8938
8917
8939 Cory\SpecialChar ~
8918 Cory\SpecialChar ~
8940 Dodt
8919 Dodt
8941 \family typewriter
8920 \family typewriter
8942 <cdodt-AT-fcoe.k12.ca.us>
8921 <cdodt-AT-fcoe.k12.ca.us>
8943 \family default
8922 \family default
8944 Bug reports and Windows ideas.
8923 Bug reports and Windows ideas.
8945 Patches for Windows installer.
8924 Patches for Windows installer.
8946 \layout List
8925 \layout List
8947 \labelwidthstring 00.00.0000
8926 \labelwidthstring 00.00.0000
8948
8927
8949 Olivier\SpecialChar ~
8928 Olivier\SpecialChar ~
8950 Aubert
8929 Aubert
8951 \family typewriter
8930 \family typewriter
8952 <oaubert-AT-bat710.univ-lyon1.fr>
8931 <oaubert-AT-bat710.univ-lyon1.fr>
8953 \family default
8932 \family default
8954 New magics.
8933 New magics.
8955 \layout List
8934 \layout List
8956 \labelwidthstring 00.00.0000
8935 \labelwidthstring 00.00.0000
8957
8936
8958 King\SpecialChar ~
8937 King\SpecialChar ~
8959 C.\SpecialChar ~
8938 C.\SpecialChar ~
8960 Shu
8939 Shu
8961 \family typewriter
8940 \family typewriter
8962 <kingshu-AT-myrealbox.com>
8941 <kingshu-AT-myrealbox.com>
8963 \family default
8942 \family default
8964 Autoindent patch.
8943 Autoindent patch.
8965 \layout List
8944 \layout List
8966 \labelwidthstring 00.00.0000
8945 \labelwidthstring 00.00.0000
8967
8946
8968 Chris\SpecialChar ~
8947 Chris\SpecialChar ~
8969 Drexler
8948 Drexler
8970 \family typewriter
8949 \family typewriter
8971 <chris-AT-ac-drexler.de>
8950 <chris-AT-ac-drexler.de>
8972 \family default
8951 \family default
8973 Readline packages for Win32/CygWin.
8952 Readline packages for Win32/CygWin.
8974 \layout List
8953 \layout List
8975 \labelwidthstring 00.00.0000
8954 \labelwidthstring 00.00.0000
8976
8955
8977 Gustavo\SpecialChar ~
8956 Gustavo\SpecialChar ~
8978 Córdova\SpecialChar ~
8957 Córdova\SpecialChar ~
8979 Avila
8958 Avila
8980 \family typewriter
8959 \family typewriter
8981 <gcordova-AT-sismex.com>
8960 <gcordova-AT-sismex.com>
8982 \family default
8961 \family default
8983 EvalDict code for nice, lightweight string interpolation.
8962 EvalDict code for nice, lightweight string interpolation.
8984 \layout List
8963 \layout List
8985 \labelwidthstring 00.00.0000
8964 \labelwidthstring 00.00.0000
8986
8965
8987 Kasper\SpecialChar ~
8966 Kasper\SpecialChar ~
8988 Souren
8967 Souren
8989 \family typewriter
8968 \family typewriter
8990 <Kasper.Souren-AT-ircam.fr>
8969 <Kasper.Souren-AT-ircam.fr>
8991 \family default
8970 \family default
8992 Bug reports, ideas.
8971 Bug reports, ideas.
8993 \layout List
8972 \layout List
8994 \labelwidthstring 00.00.0000
8973 \labelwidthstring 00.00.0000
8995
8974
8996 Gever\SpecialChar ~
8975 Gever\SpecialChar ~
8997 Tulley
8976 Tulley
8998 \family typewriter
8977 \family typewriter
8999 <gever-AT-helium.com>
8978 <gever-AT-helium.com>
9000 \family default
8979 \family default
9001 Code contributions.
8980 Code contributions.
9002 \layout List
8981 \layout List
9003 \labelwidthstring 00.00.0000
8982 \labelwidthstring 00.00.0000
9004
8983
9005 Ralf\SpecialChar ~
8984 Ralf\SpecialChar ~
9006 Schmitt
8985 Schmitt
9007 \family typewriter
8986 \family typewriter
9008 <ralf-AT-brainbot.com>
8987 <ralf-AT-brainbot.com>
9009 \family default
8988 \family default
9010 Bug reports & fixes.
8989 Bug reports & fixes.
9011 \layout List
8990 \layout List
9012 \labelwidthstring 00.00.0000
8991 \labelwidthstring 00.00.0000
9013
8992
9014 Oliver\SpecialChar ~
8993 Oliver\SpecialChar ~
9015 Sander
8994 Sander
9016 \family typewriter
8995 \family typewriter
9017 <osander-AT-gmx.de>
8996 <osander-AT-gmx.de>
9018 \family default
8997 \family default
9019 Bug reports.
8998 Bug reports.
9020 \layout List
8999 \layout List
9021 \labelwidthstring 00.00.0000
9000 \labelwidthstring 00.00.0000
9022
9001
9023 Rod\SpecialChar ~
9002 Rod\SpecialChar ~
9024 Holland
9003 Holland
9025 \family typewriter
9004 \family typewriter
9026 <rhh-AT-structurelabs.com>
9005 <rhh-AT-structurelabs.com>
9027 \family default
9006 \family default
9028 Bug reports and fixes to logging module.
9007 Bug reports and fixes to logging module.
9029 \layout List
9008 \layout List
9030 \labelwidthstring 00.00.0000
9009 \labelwidthstring 00.00.0000
9031
9010
9032 Daniel\SpecialChar ~
9011 Daniel\SpecialChar ~
9033 'Dang'\SpecialChar ~
9012 'Dang'\SpecialChar ~
9034 Griffith
9013 Griffith
9035 \family typewriter
9014 \family typewriter
9036 <pythondev-dang-AT-lazytwinacres.net>
9015 <pythondev-dang-AT-lazytwinacres.net>
9037 \family default
9016 \family default
9038 Fixes, enhancement suggestions for system shell use.
9017 Fixes, enhancement suggestions for system shell use.
9039 \layout List
9018 \layout List
9040 \labelwidthstring 00.00.0000
9019 \labelwidthstring 00.00.0000
9041
9020
9042 Viktor\SpecialChar ~
9021 Viktor\SpecialChar ~
9043 Ransmayr
9022 Ransmayr
9044 \family typewriter
9023 \family typewriter
9045 <viktor.ransmayr-AT-t-online.de>
9024 <viktor.ransmayr-AT-t-online.de>
9046 \family default
9025 \family default
9047 Tests and reports on Windows installation issues.
9026 Tests and reports on Windows installation issues.
9048 Contributed a true Windows binary installer.
9027 Contributed a true Windows binary installer.
9049 \layout List
9028 \layout List
9050 \labelwidthstring 00.00.0000
9029 \labelwidthstring 00.00.0000
9051
9030
9052 Mike\SpecialChar ~
9031 Mike\SpecialChar ~
9053 Salib
9032 Salib
9054 \family typewriter
9033 \family typewriter
9055 <msalib-AT-mit.edu>
9034 <msalib-AT-mit.edu>
9056 \family default
9035 \family default
9057 Help fixing a subtle bug related to traceback printing.
9036 Help fixing a subtle bug related to traceback printing.
9058 \layout List
9037 \layout List
9059 \labelwidthstring 00.00.0000
9038 \labelwidthstring 00.00.0000
9060
9039
9061 W.J.\SpecialChar ~
9040 W.J.\SpecialChar ~
9062 van\SpecialChar ~
9041 van\SpecialChar ~
9063 der\SpecialChar ~
9042 der\SpecialChar ~
9064 Laan
9043 Laan
9065 \family typewriter
9044 \family typewriter
9066 <gnufnork-AT-hetdigitalegat.nl>
9045 <gnufnork-AT-hetdigitalegat.nl>
9067 \family default
9046 \family default
9068 Bash-like prompt specials.
9047 Bash-like prompt specials.
9069 \layout List
9048 \layout List
9070 \labelwidthstring 00.00.0000
9049 \labelwidthstring 00.00.0000
9071
9050
9072 Ville\SpecialChar ~
9051 Ville\SpecialChar ~
9073 Vainio
9052 Vainio
9074 \family typewriter
9053 \family typewriter
9075 <vivainio-AT-kolumbus.fi>
9054 <vivainio-AT-kolumbus.fi>
9076 \family default
9055 \family default
9077 Bugfixes and suggestions.
9056 Bugfixes and suggestions.
9078 Excellent patches for many new features.
9057 Excellent patches for many new features.
9079 \layout List
9058 \layout List
9080 \labelwidthstring 00.00.0000
9059 \labelwidthstring 00.00.0000
9081
9060
9082 Antoon\SpecialChar ~
9061 Antoon\SpecialChar ~
9083 Pardon
9062 Pardon
9084 \family typewriter
9063 \family typewriter
9085 <Antoon.Pardon-AT-rece.vub.ac.be>
9064 <Antoon.Pardon-AT-rece.vub.ac.be>
9086 \family default
9065 \family default
9087 Critical fix for the multithreaded IPython.
9066 Critical fix for the multithreaded IPython.
9088 \layout List
9067 \layout List
9089 \labelwidthstring 00.00.0000
9068 \labelwidthstring 00.00.0000
9090
9069
9091 John\SpecialChar ~
9070 John\SpecialChar ~
9092 Hunter
9071 Hunter
9093 \family typewriter
9072 \family typewriter
9094 <jdhunter-AT-nitace.bsd.uchicago.edu>
9073 <jdhunter-AT-nitace.bsd.uchicago.edu>
9095 \family default
9074 \family default
9096 Matplotlib author, helped with all the development of support for matplotlib
9075 Matplotlib author, helped with all the development of support for matplotlib
9097 in IPyhton, including making necessary changes to matplotlib itself.
9076 in IPyhton, including making necessary changes to matplotlib itself.
9098 \layout List
9077 \layout List
9099 \labelwidthstring 00.00.0000
9078 \labelwidthstring 00.00.0000
9100
9079
9101 Matthew\SpecialChar ~
9080 Matthew\SpecialChar ~
9102 Arnison
9081 Arnison
9103 \family typewriter
9082 \family typewriter
9104 <maffew-AT-cat.org.au>
9083 <maffew-AT-cat.org.au>
9105 \family default
9084 \family default
9106 Bug reports, `
9085 Bug reports, `
9107 \family typewriter
9086 \family typewriter
9108 %run -d
9087 %run -d
9109 \family default
9088 \family default
9110 ' idea.
9089 ' idea.
9111 \layout List
9090 \layout List
9112 \labelwidthstring 00.00.0000
9091 \labelwidthstring 00.00.0000
9113
9092
9114 Prabhu\SpecialChar ~
9093 Prabhu\SpecialChar ~
9115 Ramachandran
9094 Ramachandran
9116 \family typewriter
9095 \family typewriter
9117 <prabhu_r-AT-users.sourceforge.net>
9096 <prabhu_r-AT-users.sourceforge.net>
9118 \family default
9097 \family default
9119 Help with (X)Emacs support, threading patches, ideas...
9098 Help with (X)Emacs support, threading patches, ideas...
9120 \layout List
9099 \layout List
9121 \labelwidthstring 00.00.0000
9100 \labelwidthstring 00.00.0000
9122
9101
9123 Norbert\SpecialChar ~
9102 Norbert\SpecialChar ~
9124 Tretkowski
9103 Tretkowski
9125 \family typewriter
9104 \family typewriter
9126 <tretkowski-AT-inittab.de>
9105 <tretkowski-AT-inittab.de>
9127 \family default
9106 \family default
9128 help with Debian packaging and distribution.
9107 help with Debian packaging and distribution.
9129 \layout List
9108 \layout List
9130 \labelwidthstring 00.00.0000
9109 \labelwidthstring 00.00.0000
9131
9110
9132 George\SpecialChar ~
9111 George\SpecialChar ~
9133 Sakkis <
9112 Sakkis <
9134 \family typewriter
9113 \family typewriter
9135 gsakkis-AT-eden.rutgers.edu>
9114 gsakkis-AT-eden.rutgers.edu>
9136 \family default
9115 \family default
9137 New matcher for tab-completing named arguments of user-defined functions.
9116 New matcher for tab-completing named arguments of user-defined functions.
9138 \layout List
9117 \layout List
9139 \labelwidthstring 00.00.0000
9118 \labelwidthstring 00.00.0000
9140
9119
9141 J�rgen\SpecialChar ~
9120 J�rgen\SpecialChar ~
9142 Stenarson
9121 Stenarson
9143 \family typewriter
9122 \family typewriter
9144 <jorgen.stenarson-AT-bostream.nu>
9123 <jorgen.stenarson-AT-bostream.nu>
9145 \family default
9124 \family default
9146 Wildcard support implementation for searching namespaces.
9125 Wildcard support implementation for searching namespaces.
9147 \layout List
9126 \layout List
9148 \labelwidthstring 00.00.0000
9127 \labelwidthstring 00.00.0000
9149
9128
9150 Vivian\SpecialChar ~
9129 Vivian\SpecialChar ~
9151 De\SpecialChar ~
9130 De\SpecialChar ~
9152 Smedt
9131 Smedt
9153 \family typewriter
9132 \family typewriter
9154 <vivian-AT-vdesmedt.com>
9133 <vivian-AT-vdesmedt.com>
9155 \family default
9134 \family default
9156 Debugger enhancements, so that when pdb is activated from within IPython,
9135 Debugger enhancements, so that when pdb is activated from within IPython,
9157 coloring, tab completion and other features continue to work seamlessly.
9136 coloring, tab completion and other features continue to work seamlessly.
9158 \layout List
9137 \layout List
9159 \labelwidthstring 00.00.0000
9138 \labelwidthstring 00.00.0000
9160
9139
9161 Scott (email unknown) Support for automatic editor invocation on syntax
9140 Scott\SpecialChar ~
9162 errors (see
9141 Tsai
9142 \family typewriter
9143 <scottt958-AT-yahoo.com.tw>
9144 \family default
9145 Support for automatic editor invocation on syntax errors (see
9163 \begin_inset LatexCommand \htmlurl{http://www.scipy.net/roundup/ipython/issue36}
9146 \begin_inset LatexCommand \htmlurl{http://www.scipy.net/roundup/ipython/issue36}
9164
9147
9165 \end_inset
9148 \end_inset
9166
9149
9167 ).
9150 ).
9168 \the_end
9151 \the_end
General Comments 0
You need to be logged in to leave comments. Login now