##// END OF EJS Templates
- Final commits for 0.8.0 tag....
jdh2358 -
Show More
@@ -1,3122 +1,3121 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 2221 2007-04-06 02:58:37Z fperez $"""
4 $Id: Magic.py 2225 2007-04-08 02:48:16Z jdh2358 $"""
5
5
6 #*****************************************************************************
6 #*****************************************************************************
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
8 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
8 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
9 #
9 #
10 # Distributed under the terms of the BSD License. The full license is in
10 # Distributed under the terms of the BSD License. The full license is in
11 # the file COPYING, distributed as part of this software.
11 # the file COPYING, distributed as part of this software.
12 #*****************************************************************************
12 #*****************************************************************************
13
13
14 #****************************************************************************
14 #****************************************************************************
15 # Modules and globals
15 # Modules and globals
16
16
17 from IPython import Release
17 from IPython import Release
18 __author__ = '%s <%s>\n%s <%s>' % \
18 __author__ = '%s <%s>\n%s <%s>' % \
19 ( Release.authors['Janko'] + Release.authors['Fernando'] )
19 ( Release.authors['Janko'] + Release.authors['Fernando'] )
20 __license__ = Release.license
20 __license__ = Release.license
21
21
22 # Python standard modules
22 # Python standard modules
23 import __builtin__
23 import __builtin__
24 import bdb
24 import bdb
25 import inspect
25 import inspect
26 import os
26 import os
27 import pdb
27 import pdb
28 import pydoc
28 import pydoc
29 import sys
29 import sys
30 import re
30 import re
31 import tempfile
31 import tempfile
32 import time
32 import time
33 import cPickle as pickle
33 import cPickle as pickle
34 import textwrap
34 import textwrap
35 from cStringIO import StringIO
35 from cStringIO import StringIO
36 from getopt import getopt,GetoptError
36 from getopt import getopt,GetoptError
37 from pprint import pprint, pformat
37 from pprint import pprint, pformat
38
38
39 # cProfile was added in Python2.5
39 # cProfile was added in Python2.5
40 try:
40 try:
41 import cProfile as profile
41 import cProfile as profile
42 import pstats
42 import pstats
43 except ImportError:
43 except ImportError:
44 # profile isn't bundled by default in Debian for license reasons
44 # profile isn't bundled by default in Debian for license reasons
45 try:
45 try:
46 import profile,pstats
46 import profile,pstats
47 except ImportError:
47 except ImportError:
48 profile = pstats = None
48 profile = pstats = None
49
49
50 # Homebrewed
50 # Homebrewed
51 import IPython
51 import IPython
52 from IPython import Debugger, OInspect, wildcard
52 from IPython import Debugger, OInspect, wildcard
53 from IPython.FakeModule import FakeModule
53 from IPython.FakeModule import FakeModule
54 from IPython.Itpl import Itpl, itpl, printpl,itplns
54 from IPython.Itpl import Itpl, itpl, printpl,itplns
55 from IPython.PyColorize import Parser
55 from IPython.PyColorize import Parser
56 from IPython.ipstruct import Struct
56 from IPython.ipstruct import Struct
57 from IPython.macro import Macro
57 from IPython.macro import Macro
58 from IPython.genutils import *
58 from IPython.genutils import *
59 from IPython import platutils
59 from IPython import platutils
60
60
61 #***************************************************************************
61 #***************************************************************************
62 # Utility functions
62 # Utility functions
63 def on_off(tag):
63 def on_off(tag):
64 """Return an ON/OFF string for a 1/0 input. Simple utility function."""
64 """Return an ON/OFF string for a 1/0 input. Simple utility function."""
65 return ['OFF','ON'][tag]
65 return ['OFF','ON'][tag]
66
66
67 class Bunch: pass
67 class Bunch: pass
68
68
69 #***************************************************************************
69 #***************************************************************************
70 # Main class implementing Magic functionality
70 # Main class implementing Magic functionality
71 class Magic:
71 class Magic:
72 """Magic functions for InteractiveShell.
72 """Magic functions for InteractiveShell.
73
73
74 Shell functions which can be reached as %function_name. All magic
74 Shell functions which can be reached as %function_name. All magic
75 functions should accept a string, which they can parse for their own
75 functions should accept a string, which they can parse for their own
76 needs. This can make some functions easier to type, eg `%cd ../`
76 needs. This can make some functions easier to type, eg `%cd ../`
77 vs. `%cd("../")`
77 vs. `%cd("../")`
78
78
79 ALL definitions MUST begin with the prefix magic_. The user won't need it
79 ALL definitions MUST begin with the prefix magic_. The user won't need it
80 at the command line, but it is is needed in the definition. """
80 at the command line, but it is is needed in the definition. """
81
81
82 # class globals
82 # class globals
83 auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.',
83 auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.',
84 'Automagic is ON, % prefix NOT needed for magic functions.']
84 'Automagic is ON, % prefix NOT needed for magic functions.']
85
85
86 #......................................................................
86 #......................................................................
87 # some utility functions
87 # some utility functions
88
88
89 def __init__(self,shell):
89 def __init__(self,shell):
90
90
91 self.options_table = {}
91 self.options_table = {}
92 if profile is None:
92 if profile is None:
93 self.magic_prun = self.profile_missing_notice
93 self.magic_prun = self.profile_missing_notice
94 self.shell = shell
94 self.shell = shell
95
95
96 # namespace for holding state we may need
96 # namespace for holding state we may need
97 self._magic_state = Bunch()
97 self._magic_state = Bunch()
98
98
99 def profile_missing_notice(self, *args, **kwargs):
99 def profile_missing_notice(self, *args, **kwargs):
100 error("""\
100 error("""\
101 The profile module could not be found. If you are a Debian user,
101 The profile module could not be found. If you are a Debian user,
102 it has been removed from the standard Debian package because of its non-free
102 it has been removed from the standard Debian package because of its non-free
103 license. To use profiling, please install"python2.3-profiler" from non-free.""")
103 license. To use profiling, please install"python2.3-profiler" from non-free.""")
104
104
105 def default_option(self,fn,optstr):
105 def default_option(self,fn,optstr):
106 """Make an entry in the options_table for fn, with value optstr"""
106 """Make an entry in the options_table for fn, with value optstr"""
107
107
108 if fn not in self.lsmagic():
108 if fn not in self.lsmagic():
109 error("%s is not a magic function" % fn)
109 error("%s is not a magic function" % fn)
110 self.options_table[fn] = optstr
110 self.options_table[fn] = optstr
111
111
112 def lsmagic(self):
112 def lsmagic(self):
113 """Return a list of currently available magic functions.
113 """Return a list of currently available magic functions.
114
114
115 Gives a list of the bare names after mangling (['ls','cd', ...], not
115 Gives a list of the bare names after mangling (['ls','cd', ...], not
116 ['magic_ls','magic_cd',...]"""
116 ['magic_ls','magic_cd',...]"""
117
117
118 # FIXME. This needs a cleanup, in the way the magics list is built.
118 # FIXME. This needs a cleanup, in the way the magics list is built.
119
119
120 # magics in class definition
120 # magics in class definition
121 class_magic = lambda fn: fn.startswith('magic_') and \
121 class_magic = lambda fn: fn.startswith('magic_') and \
122 callable(Magic.__dict__[fn])
122 callable(Magic.__dict__[fn])
123 # in instance namespace (run-time user additions)
123 # in instance namespace (run-time user additions)
124 inst_magic = lambda fn: fn.startswith('magic_') and \
124 inst_magic = lambda fn: fn.startswith('magic_') and \
125 callable(self.__dict__[fn])
125 callable(self.__dict__[fn])
126 # and bound magics by user (so they can access self):
126 # and bound magics by user (so they can access self):
127 inst_bound_magic = lambda fn: fn.startswith('magic_') and \
127 inst_bound_magic = lambda fn: fn.startswith('magic_') and \
128 callable(self.__class__.__dict__[fn])
128 callable(self.__class__.__dict__[fn])
129 magics = filter(class_magic,Magic.__dict__.keys()) + \
129 magics = filter(class_magic,Magic.__dict__.keys()) + \
130 filter(inst_magic,self.__dict__.keys()) + \
130 filter(inst_magic,self.__dict__.keys()) + \
131 filter(inst_bound_magic,self.__class__.__dict__.keys())
131 filter(inst_bound_magic,self.__class__.__dict__.keys())
132 out = []
132 out = []
133 for fn in magics:
133 for fn in magics:
134 out.append(fn.replace('magic_','',1))
134 out.append(fn.replace('magic_','',1))
135 out.sort()
135 out.sort()
136 return out
136 return out
137
137
138 def extract_input_slices(self,slices,raw=False):
138 def extract_input_slices(self,slices,raw=False):
139 """Return as a string a set of input history slices.
139 """Return as a string a set of input history slices.
140
140
141 Inputs:
141 Inputs:
142
142
143 - slices: the set of slices is given as a list of strings (like
143 - slices: the set of slices is given as a list of strings (like
144 ['1','4:8','9'], since this function is for use by magic functions
144 ['1','4:8','9'], since this function is for use by magic functions
145 which get their arguments as strings.
145 which get their arguments as strings.
146
146
147 Optional inputs:
147 Optional inputs:
148
148
149 - raw(False): by default, the processed input is used. If this is
149 - raw(False): by default, the processed input is used. If this is
150 true, the raw input history is used instead.
150 true, the raw input history is used instead.
151
151
152 Note that slices can be called with two notations:
152 Note that slices can be called with two notations:
153
153
154 N:M -> standard python form, means including items N...(M-1).
154 N:M -> standard python form, means including items N...(M-1).
155
155
156 N-M -> include items N..M (closed endpoint)."""
156 N-M -> include items N..M (closed endpoint)."""
157
157
158 if raw:
158 if raw:
159 hist = self.shell.input_hist_raw
159 hist = self.shell.input_hist_raw
160 else:
160 else:
161 hist = self.shell.input_hist
161 hist = self.shell.input_hist
162
162
163 cmds = []
163 cmds = []
164 for chunk in slices:
164 for chunk in slices:
165 if ':' in chunk:
165 if ':' in chunk:
166 ini,fin = map(int,chunk.split(':'))
166 ini,fin = map(int,chunk.split(':'))
167 elif '-' in chunk:
167 elif '-' in chunk:
168 ini,fin = map(int,chunk.split('-'))
168 ini,fin = map(int,chunk.split('-'))
169 fin += 1
169 fin += 1
170 else:
170 else:
171 ini = int(chunk)
171 ini = int(chunk)
172 fin = ini+1
172 fin = ini+1
173 cmds.append(hist[ini:fin])
173 cmds.append(hist[ini:fin])
174 return cmds
174 return cmds
175
175
176 def _ofind(self, oname, namespaces=None):
176 def _ofind(self, oname, namespaces=None):
177 """Find an object in the available namespaces.
177 """Find an object in the available namespaces.
178
178
179 self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic
179 self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic
180
180
181 Has special code to detect magic functions.
181 Has special code to detect magic functions.
182 """
182 """
183
183
184 oname = oname.strip()
184 oname = oname.strip()
185
185
186 alias_ns = None
186 alias_ns = None
187 if namespaces is None:
187 if namespaces is None:
188 # Namespaces to search in:
188 # Namespaces to search in:
189 # Put them in a list. The order is important so that we
189 # Put them in a list. The order is important so that we
190 # find things in the same order that Python finds them.
190 # find things in the same order that Python finds them.
191 namespaces = [ ('Interactive', self.shell.user_ns),
191 namespaces = [ ('Interactive', self.shell.user_ns),
192 ('IPython internal', self.shell.internal_ns),
192 ('IPython internal', self.shell.internal_ns),
193 ('Python builtin', __builtin__.__dict__),
193 ('Python builtin', __builtin__.__dict__),
194 ('Alias', self.shell.alias_table),
194 ('Alias', self.shell.alias_table),
195 ]
195 ]
196 alias_ns = self.shell.alias_table
196 alias_ns = self.shell.alias_table
197
197
198 # initialize results to 'null'
198 # initialize results to 'null'
199 found = 0; obj = None; ospace = None; ds = None;
199 found = 0; obj = None; ospace = None; ds = None;
200 ismagic = 0; isalias = 0; parent = None
200 ismagic = 0; isalias = 0; parent = None
201
201
202 # Look for the given name by splitting it in parts. If the head is
202 # Look for the given name by splitting it in parts. If the head is
203 # found, then we look for all the remaining parts as members, and only
203 # found, then we look for all the remaining parts as members, and only
204 # declare success if we can find them all.
204 # declare success if we can find them all.
205 oname_parts = oname.split('.')
205 oname_parts = oname.split('.')
206 oname_head, oname_rest = oname_parts[0],oname_parts[1:]
206 oname_head, oname_rest = oname_parts[0],oname_parts[1:]
207 for nsname,ns in namespaces:
207 for nsname,ns in namespaces:
208 try:
208 try:
209 obj = ns[oname_head]
209 obj = ns[oname_head]
210 except KeyError:
210 except KeyError:
211 continue
211 continue
212 else:
212 else:
213 #print 'oname_rest:', oname_rest # dbg
213 #print 'oname_rest:', oname_rest # dbg
214 for part in oname_rest:
214 for part in oname_rest:
215 try:
215 try:
216 parent = obj
216 parent = obj
217 obj = getattr(obj,part)
217 obj = getattr(obj,part)
218 except:
218 except:
219 # Blanket except b/c some badly implemented objects
219 # Blanket except b/c some badly implemented objects
220 # allow __getattr__ to raise exceptions other than
220 # allow __getattr__ to raise exceptions other than
221 # AttributeError, which then crashes IPython.
221 # AttributeError, which then crashes IPython.
222 break
222 break
223 else:
223 else:
224 # If we finish the for loop (no break), we got all members
224 # If we finish the for loop (no break), we got all members
225 found = 1
225 found = 1
226 ospace = nsname
226 ospace = nsname
227 if ns == alias_ns:
227 if ns == alias_ns:
228 isalias = 1
228 isalias = 1
229 break # namespace loop
229 break # namespace loop
230
230
231 # Try to see if it's magic
231 # Try to see if it's magic
232 if not found:
232 if not found:
233 if oname.startswith(self.shell.ESC_MAGIC):
233 if oname.startswith(self.shell.ESC_MAGIC):
234 oname = oname[1:]
234 oname = oname[1:]
235 obj = getattr(self,'magic_'+oname,None)
235 obj = getattr(self,'magic_'+oname,None)
236 if obj is not None:
236 if obj is not None:
237 found = 1
237 found = 1
238 ospace = 'IPython internal'
238 ospace = 'IPython internal'
239 ismagic = 1
239 ismagic = 1
240
240
241 # Last try: special-case some literals like '', [], {}, etc:
241 # Last try: special-case some literals like '', [], {}, etc:
242 if not found and oname_head in ["''",'""','[]','{}','()']:
242 if not found and oname_head in ["''",'""','[]','{}','()']:
243 obj = eval(oname_head)
243 obj = eval(oname_head)
244 found = 1
244 found = 1
245 ospace = 'Interactive'
245 ospace = 'Interactive'
246
246
247 return {'found':found, 'obj':obj, 'namespace':ospace,
247 return {'found':found, 'obj':obj, 'namespace':ospace,
248 'ismagic':ismagic, 'isalias':isalias, 'parent':parent}
248 'ismagic':ismagic, 'isalias':isalias, 'parent':parent}
249
249
250 def arg_err(self,func):
250 def arg_err(self,func):
251 """Print docstring if incorrect arguments were passed"""
251 """Print docstring if incorrect arguments were passed"""
252 print 'Error in arguments:'
252 print 'Error in arguments:'
253 print OInspect.getdoc(func)
253 print OInspect.getdoc(func)
254
254
255 def format_latex(self,strng):
255 def format_latex(self,strng):
256 """Format a string for latex inclusion."""
256 """Format a string for latex inclusion."""
257
257
258 # Characters that need to be escaped for latex:
258 # Characters that need to be escaped for latex:
259 escape_re = re.compile(r'(%|_|\$|#|&)',re.MULTILINE)
259 escape_re = re.compile(r'(%|_|\$|#|&)',re.MULTILINE)
260 # Magic command names as headers:
260 # Magic command names as headers:
261 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
261 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
262 re.MULTILINE)
262 re.MULTILINE)
263 # Magic commands
263 # Magic commands
264 cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC,
264 cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC,
265 re.MULTILINE)
265 re.MULTILINE)
266 # Paragraph continue
266 # Paragraph continue
267 par_re = re.compile(r'\\$',re.MULTILINE)
267 par_re = re.compile(r'\\$',re.MULTILINE)
268
268
269 # The "\n" symbol
269 # The "\n" symbol
270 newline_re = re.compile(r'\\n')
270 newline_re = re.compile(r'\\n')
271
271
272 # Now build the string for output:
272 # Now build the string for output:
273 #strng = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',strng)
273 #strng = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',strng)
274 strng = cmd_name_re.sub(r'\n\\bigskip\n\\texttt{\\textbf{ \1}}:',
274 strng = cmd_name_re.sub(r'\n\\bigskip\n\\texttt{\\textbf{ \1}}:',
275 strng)
275 strng)
276 strng = cmd_re.sub(r'\\texttt{\g<cmd>}',strng)
276 strng = cmd_re.sub(r'\\texttt{\g<cmd>}',strng)
277 strng = par_re.sub(r'\\\\',strng)
277 strng = par_re.sub(r'\\\\',strng)
278 strng = escape_re.sub(r'\\\1',strng)
278 strng = escape_re.sub(r'\\\1',strng)
279 strng = newline_re.sub(r'\\textbackslash{}n',strng)
279 strng = newline_re.sub(r'\\textbackslash{}n',strng)
280 return strng
280 return strng
281
281
282 def format_screen(self,strng):
282 def format_screen(self,strng):
283 """Format a string for screen printing.
283 """Format a string for screen printing.
284
284
285 This removes some latex-type format codes."""
285 This removes some latex-type format codes."""
286 # Paragraph continue
286 # Paragraph continue
287 par_re = re.compile(r'\\$',re.MULTILINE)
287 par_re = re.compile(r'\\$',re.MULTILINE)
288 strng = par_re.sub('',strng)
288 strng = par_re.sub('',strng)
289 return strng
289 return strng
290
290
291 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
291 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
292 """Parse options passed to an argument string.
292 """Parse options passed to an argument string.
293
293
294 The interface is similar to that of getopt(), but it returns back a
294 The interface is similar to that of getopt(), but it returns back a
295 Struct with the options as keys and the stripped argument string still
295 Struct with the options as keys and the stripped argument string still
296 as a string.
296 as a string.
297
297
298 arg_str is quoted as a true sys.argv vector by using shlex.split.
298 arg_str is quoted as a true sys.argv vector by using shlex.split.
299 This allows us to easily expand variables, glob files, quote
299 This allows us to easily expand variables, glob files, quote
300 arguments, etc.
300 arguments, etc.
301
301
302 Options:
302 Options:
303 -mode: default 'string'. If given as 'list', the argument string is
303 -mode: default 'string'. If given as 'list', the argument string is
304 returned as a list (split on whitespace) instead of a string.
304 returned as a list (split on whitespace) instead of a string.
305
305
306 -list_all: put all option values in lists. Normally only options
306 -list_all: put all option values in lists. Normally only options
307 appearing more than once are put in a list.
307 appearing more than once are put in a list.
308
308
309 -posix (True): whether to split the input line in POSIX mode or not,
309 -posix (True): whether to split the input line in POSIX mode or not,
310 as per the conventions outlined in the shlex module from the
310 as per the conventions outlined in the shlex module from the
311 standard library."""
311 standard library."""
312
312
313 # inject default options at the beginning of the input line
313 # inject default options at the beginning of the input line
314 caller = sys._getframe(1).f_code.co_name.replace('magic_','')
314 caller = sys._getframe(1).f_code.co_name.replace('magic_','')
315 arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str)
315 arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str)
316
316
317 mode = kw.get('mode','string')
317 mode = kw.get('mode','string')
318 if mode not in ['string','list']:
318 if mode not in ['string','list']:
319 raise ValueError,'incorrect mode given: %s' % mode
319 raise ValueError,'incorrect mode given: %s' % mode
320 # Get options
320 # Get options
321 list_all = kw.get('list_all',0)
321 list_all = kw.get('list_all',0)
322 posix = kw.get('posix',True)
322 posix = kw.get('posix',True)
323
323
324 # Check if we have more than one argument to warrant extra processing:
324 # Check if we have more than one argument to warrant extra processing:
325 odict = {} # Dictionary with options
325 odict = {} # Dictionary with options
326 args = arg_str.split()
326 args = arg_str.split()
327 if len(args) >= 1:
327 if len(args) >= 1:
328 # If the list of inputs only has 0 or 1 thing in it, there's no
328 # If the list of inputs only has 0 or 1 thing in it, there's no
329 # need to look for options
329 # need to look for options
330 argv = arg_split(arg_str,posix)
330 argv = arg_split(arg_str,posix)
331 # Do regular option processing
331 # Do regular option processing
332 try:
332 try:
333 opts,args = getopt(argv,opt_str,*long_opts)
333 opts,args = getopt(argv,opt_str,*long_opts)
334 except GetoptError,e:
334 except GetoptError,e:
335 raise GetoptError('%s ( allowed: "%s" %s)' % (e.msg,opt_str,
335 raise GetoptError('%s ( allowed: "%s" %s)' % (e.msg,opt_str,
336 " ".join(long_opts)))
336 " ".join(long_opts)))
337 for o,a in opts:
337 for o,a in opts:
338 if o.startswith('--'):
338 if o.startswith('--'):
339 o = o[2:]
339 o = o[2:]
340 else:
340 else:
341 o = o[1:]
341 o = o[1:]
342 try:
342 try:
343 odict[o].append(a)
343 odict[o].append(a)
344 except AttributeError:
344 except AttributeError:
345 odict[o] = [odict[o],a]
345 odict[o] = [odict[o],a]
346 except KeyError:
346 except KeyError:
347 if list_all:
347 if list_all:
348 odict[o] = [a]
348 odict[o] = [a]
349 else:
349 else:
350 odict[o] = a
350 odict[o] = a
351
351
352 # Prepare opts,args for return
352 # Prepare opts,args for return
353 opts = Struct(odict)
353 opts = Struct(odict)
354 if mode == 'string':
354 if mode == 'string':
355 args = ' '.join(args)
355 args = ' '.join(args)
356
356
357 return opts,args
357 return opts,args
358
358
359 #......................................................................
359 #......................................................................
360 # And now the actual magic functions
360 # And now the actual magic functions
361
361
362 # Functions for IPython shell work (vars,funcs, config, etc)
362 # Functions for IPython shell work (vars,funcs, config, etc)
363 def magic_lsmagic(self, parameter_s = ''):
363 def magic_lsmagic(self, parameter_s = ''):
364 """List currently available magic functions."""
364 """List currently available magic functions."""
365 mesc = self.shell.ESC_MAGIC
365 mesc = self.shell.ESC_MAGIC
366 print 'Available magic functions:\n'+mesc+\
366 print 'Available magic functions:\n'+mesc+\
367 (' '+mesc).join(self.lsmagic())
367 (' '+mesc).join(self.lsmagic())
368 print '\n' + Magic.auto_status[self.shell.rc.automagic]
368 print '\n' + Magic.auto_status[self.shell.rc.automagic]
369 return None
369 return None
370
370
371 def magic_magic(self, parameter_s = ''):
371 def magic_magic(self, parameter_s = ''):
372 """Print information about the magic function system."""
372 """Print information about the magic function system."""
373
373
374 mode = ''
374 mode = ''
375 try:
375 try:
376 if parameter_s.split()[0] == '-latex':
376 if parameter_s.split()[0] == '-latex':
377 mode = 'latex'
377 mode = 'latex'
378 if parameter_s.split()[0] == '-brief':
378 if parameter_s.split()[0] == '-brief':
379 mode = 'brief'
379 mode = 'brief'
380 except:
380 except:
381 pass
381 pass
382
382
383 magic_docs = []
383 magic_docs = []
384 for fname in self.lsmagic():
384 for fname in self.lsmagic():
385 mname = 'magic_' + fname
385 mname = 'magic_' + fname
386 for space in (Magic,self,self.__class__):
386 for space in (Magic,self,self.__class__):
387 try:
387 try:
388 fn = space.__dict__[mname]
388 fn = space.__dict__[mname]
389 except KeyError:
389 except KeyError:
390 pass
390 pass
391 else:
391 else:
392 break
392 break
393 if mode == 'brief':
393 if mode == 'brief':
394 # only first line
394 # only first line
395 fndoc = fn.__doc__.split('\n',1)[0]
395 fndoc = fn.__doc__.split('\n',1)[0]
396 else:
396 else:
397 fndoc = fn.__doc__
397 fndoc = fn.__doc__
398
398
399 magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC,
399 magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC,
400 fname,fndoc))
400 fname,fndoc))
401 magic_docs = ''.join(magic_docs)
401 magic_docs = ''.join(magic_docs)
402
402
403 if mode == 'latex':
403 if mode == 'latex':
404 print self.format_latex(magic_docs)
404 print self.format_latex(magic_docs)
405 return
405 return
406 else:
406 else:
407 magic_docs = self.format_screen(magic_docs)
407 magic_docs = self.format_screen(magic_docs)
408 if mode == 'brief':
408 if mode == 'brief':
409 return magic_docs
409 return magic_docs
410
410
411 outmsg = """
411 outmsg = """
412 IPython's 'magic' functions
412 IPython's 'magic' functions
413 ===========================
413 ===========================
414
414
415 The magic function system provides a series of functions which allow you to
415 The magic function system provides a series of functions which allow you to
416 control the behavior of IPython itself, plus a lot of system-type
416 control the behavior of IPython itself, plus a lot of system-type
417 features. All these functions are prefixed with a % character, but parameters
417 features. All these functions are prefixed with a % character, but parameters
418 are given without parentheses or quotes.
418 are given without parentheses or quotes.
419
419
420 NOTE: If you have 'automagic' enabled (via the command line option or with the
420 NOTE: If you have 'automagic' enabled (via the command line option or with the
421 %automagic function), you don't need to type in the % explicitly. By default,
421 %automagic function), you don't need to type in the % explicitly. By default,
422 IPython ships with automagic on, so you should only rarely need the % escape.
422 IPython ships with automagic on, so you should only rarely need the % escape.
423
423
424 Example: typing '%cd mydir' (without the quotes) changes you working directory
424 Example: typing '%cd mydir' (without the quotes) changes you working directory
425 to 'mydir', if it exists.
425 to 'mydir', if it exists.
426
426
427 You can define your own magic functions to extend the system. See the supplied
427 You can define your own magic functions to extend the system. See the supplied
428 ipythonrc and example-magic.py files for details (in your ipython
428 ipythonrc and example-magic.py files for details (in your ipython
429 configuration directory, typically $HOME/.ipython/).
429 configuration directory, typically $HOME/.ipython/).
430
430
431 You can also define your own aliased names for magic functions. In your
431 You can also define your own aliased names for magic functions. In your
432 ipythonrc file, placing a line like:
432 ipythonrc file, placing a line like:
433
433
434 execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
434 execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
435
435
436 will define %pf as a new name for %profile.
436 will define %pf as a new name for %profile.
437
437
438 You can also call magics in code using the ipmagic() function, which IPython
438 You can also call magics in code using the ipmagic() function, which IPython
439 automatically adds to the builtin namespace. Type 'ipmagic?' for details.
439 automatically adds to the builtin namespace. Type 'ipmagic?' for details.
440
440
441 For a list of the available magic functions, use %lsmagic. For a description
441 For a list of the available magic functions, use %lsmagic. For a description
442 of any of them, type %magic_name?, e.g. '%cd?'.
442 of any of them, type %magic_name?, e.g. '%cd?'.
443
443
444 Currently the magic system has the following functions:\n"""
444 Currently the magic system has the following functions:\n"""
445
445
446 mesc = self.shell.ESC_MAGIC
446 mesc = self.shell.ESC_MAGIC
447 outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):"
447 outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):"
448 "\n\n%s%s\n\n%s" % (outmsg,
448 "\n\n%s%s\n\n%s" % (outmsg,
449 magic_docs,mesc,mesc,
449 magic_docs,mesc,mesc,
450 (' '+mesc).join(self.lsmagic()),
450 (' '+mesc).join(self.lsmagic()),
451 Magic.auto_status[self.shell.rc.automagic] ) )
451 Magic.auto_status[self.shell.rc.automagic] ) )
452
452
453 page(outmsg,screen_lines=self.shell.rc.screen_length)
453 page(outmsg,screen_lines=self.shell.rc.screen_length)
454
454
455 def magic_automagic(self, parameter_s = ''):
455 def magic_automagic(self, parameter_s = ''):
456 """Make magic functions callable without having to type the initial %.
456 """Make magic functions callable without having to type the initial %.
457
457
458 Without argumentsl toggles on/off (when off, you must call it as
458 Without argumentsl toggles on/off (when off, you must call it as
459 %automagic, of course). With arguments it sets the value, and you can
459 %automagic, of course). With arguments it sets the value, and you can
460 use any of (case insensitive):
460 use any of (case insensitive):
461
461
462 - on,1,True: to activate
462 - on,1,True: to activate
463
463
464 - off,0,False: to deactivate.
464 - off,0,False: to deactivate.
465
465
466 Note that magic functions have lowest priority, so if there's a
466 Note that magic functions have lowest priority, so if there's a
467 variable whose name collides with that of a magic fn, automagic won't
467 variable whose name collides with that of a magic fn, automagic won't
468 work for that function (you get the variable instead). However, if you
468 work for that function (you get the variable instead). However, if you
469 delete the variable (del var), the previously shadowed magic function
469 delete the variable (del var), the previously shadowed magic function
470 becomes visible to automagic again."""
470 becomes visible to automagic again."""
471
471
472 rc = self.shell.rc
472 rc = self.shell.rc
473 arg = parameter_s.lower()
473 arg = parameter_s.lower()
474 if parameter_s in ('on','1','true'):
474 if parameter_s in ('on','1','true'):
475 rc.automagic = True
475 rc.automagic = True
476 elif parameter_s in ('off','0','false'):
476 elif parameter_s in ('off','0','false'):
477 rc.automagic = False
477 rc.automagic = False
478 else:
478 else:
479 rc.automagic = not rc.automagic
479 rc.automagic = not rc.automagic
480 print '\n' + Magic.auto_status[rc.automagic]
480 print '\n' + Magic.auto_status[rc.automagic]
481
481
482 def magic_autocall(self, parameter_s = ''):
482 def magic_autocall(self, parameter_s = ''):
483 """Make functions callable without having to type parentheses.
483 """Make functions callable without having to type parentheses.
484
484
485 Usage:
485 Usage:
486
486
487 %autocall [mode]
487 %autocall [mode]
488
488
489 The mode can be one of: 0->Off, 1->Smart, 2->Full. If not given, the
489 The mode can be one of: 0->Off, 1->Smart, 2->Full. If not given, the
490 value is toggled on and off (remembering the previous state)."""
490 value is toggled on and off (remembering the previous state)."""
491
491
492 rc = self.shell.rc
492 rc = self.shell.rc
493
493
494 if parameter_s:
494 if parameter_s:
495 arg = int(parameter_s)
495 arg = int(parameter_s)
496 else:
496 else:
497 arg = 'toggle'
497 arg = 'toggle'
498
498
499 if not arg in (0,1,2,'toggle'):
499 if not arg in (0,1,2,'toggle'):
500 error('Valid modes: (0->Off, 1->Smart, 2->Full')
500 error('Valid modes: (0->Off, 1->Smart, 2->Full')
501 return
501 return
502
502
503 if arg in (0,1,2):
503 if arg in (0,1,2):
504 rc.autocall = arg
504 rc.autocall = arg
505 else: # toggle
505 else: # toggle
506 if rc.autocall:
506 if rc.autocall:
507 self._magic_state.autocall_save = rc.autocall
507 self._magic_state.autocall_save = rc.autocall
508 rc.autocall = 0
508 rc.autocall = 0
509 else:
509 else:
510 try:
510 try:
511 rc.autocall = self._magic_state.autocall_save
511 rc.autocall = self._magic_state.autocall_save
512 except AttributeError:
512 except AttributeError:
513 rc.autocall = self._magic_state.autocall_save = 1
513 rc.autocall = self._magic_state.autocall_save = 1
514
514
515 print "Automatic calling is:",['OFF','Smart','Full'][rc.autocall]
515 print "Automatic calling is:",['OFF','Smart','Full'][rc.autocall]
516
516
517 def magic_autoindent(self, parameter_s = ''):
517 def magic_autoindent(self, parameter_s = ''):
518 """Toggle autoindent on/off (if available)."""
518 """Toggle autoindent on/off (if available)."""
519
519
520 self.shell.set_autoindent()
520 self.shell.set_autoindent()
521 print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent]
521 print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent]
522
522
523 def magic_system_verbose(self, parameter_s = ''):
523 def magic_system_verbose(self, parameter_s = ''):
524 """Set verbose printing of system calls.
524 """Set verbose printing of system calls.
525
525
526 If called without an argument, act as a toggle"""
526 If called without an argument, act as a toggle"""
527
527
528 if parameter_s:
528 if parameter_s:
529 val = bool(eval(parameter_s))
529 val = bool(eval(parameter_s))
530 else:
530 else:
531 val = None
531 val = None
532
532
533 self.shell.rc_set_toggle('system_verbose',val)
533 self.shell.rc_set_toggle('system_verbose',val)
534 print "System verbose printing is:",\
534 print "System verbose printing is:",\
535 ['OFF','ON'][self.shell.rc.system_verbose]
535 ['OFF','ON'][self.shell.rc.system_verbose]
536
536
537 def magic_history(self, parameter_s = ''):
537 def magic_history(self, parameter_s = ''):
538 """Print input history (_i<n> variables), with most recent last.
538 """Print input history (_i<n> variables), with most recent last.
539
539
540 %history -> print at most 40 inputs (some may be multi-line)\\
540 %history -> print at most 40 inputs (some may be multi-line)\\
541 %history n -> print at most n inputs\\
541 %history n -> print at most n inputs\\
542 %history n1 n2 -> print inputs between n1 and n2 (n2 not included)\\
542 %history n1 n2 -> print inputs between n1 and n2 (n2 not included)\\
543
543
544 Each input's number <n> is shown, and is accessible as the
544 Each input's number <n> is shown, and is accessible as the
545 automatically generated variable _i<n>. Multi-line statements are
545 automatically generated variable _i<n>. Multi-line statements are
546 printed starting at a new line for easy copy/paste.
546 printed starting at a new line for easy copy/paste.
547
547
548
548
549 Options:
549 Options:
550
550
551 -n: do NOT print line numbers. This is useful if you want to get a
551 -n: do NOT print line numbers. This is useful if you want to get a
552 printout of many lines which can be directly pasted into a text
552 printout of many lines which can be directly pasted into a text
553 editor.
553 editor.
554
554
555 This feature is only available if numbered prompts are in use.
555 This feature is only available if numbered prompts are in use.
556
556
557 -r: print the 'raw' history. IPython filters your input and
557 -r: print the 'raw' history. IPython filters your input and
558 converts it all into valid Python source before executing it (things
558 converts it all into valid Python source before executing it (things
559 like magics or aliases are turned into function calls, for
559 like magics or aliases are turned into function calls, for
560 example). With this option, you'll see the unfiltered history
560 example). With this option, you'll see the unfiltered history
561 instead of the filtered version: '%cd /' will be seen as '%cd /'
561 instead of the filtered version: '%cd /' will be seen as '%cd /'
562 instead of '_ip.magic("%cd /")'.
562 instead of '_ip.magic("%cd /")'.
563 """
563 """
564
564
565 shell = self.shell
565 shell = self.shell
566 if not shell.outputcache.do_full_cache:
566 if not shell.outputcache.do_full_cache:
567 print 'This feature is only available if numbered prompts are in use.'
567 print 'This feature is only available if numbered prompts are in use.'
568 return
568 return
569 opts,args = self.parse_options(parameter_s,'nr',mode='list')
569 opts,args = self.parse_options(parameter_s,'nr',mode='list')
570
570
571 if opts.has_key('r'):
571 if opts.has_key('r'):
572 input_hist = shell.input_hist_raw
572 input_hist = shell.input_hist_raw
573 else:
573 else:
574 input_hist = shell.input_hist
574 input_hist = shell.input_hist
575
575
576 default_length = 40
576 default_length = 40
577 if len(args) == 0:
577 if len(args) == 0:
578 final = len(input_hist)
578 final = len(input_hist)
579 init = max(1,final-default_length)
579 init = max(1,final-default_length)
580 elif len(args) == 1:
580 elif len(args) == 1:
581 final = len(input_hist)
581 final = len(input_hist)
582 init = max(1,final-int(args[0]))
582 init = max(1,final-int(args[0]))
583 elif len(args) == 2:
583 elif len(args) == 2:
584 init,final = map(int,args)
584 init,final = map(int,args)
585 else:
585 else:
586 warn('%hist takes 0, 1 or 2 arguments separated by spaces.')
586 warn('%hist takes 0, 1 or 2 arguments separated by spaces.')
587 print self.magic_hist.__doc__
587 print self.magic_hist.__doc__
588 return
588 return
589 width = len(str(final))
589 width = len(str(final))
590 line_sep = ['','\n']
590 line_sep = ['','\n']
591 print_nums = not opts.has_key('n')
591 print_nums = not opts.has_key('n')
592 for in_num in range(init,final):
592 for in_num in range(init,final):
593 inline = input_hist[in_num]
593 inline = input_hist[in_num]
594 multiline = int(inline.count('\n') > 1)
594 multiline = int(inline.count('\n') > 1)
595 if print_nums:
595 if print_nums:
596 print '%s:%s' % (str(in_num).ljust(width),line_sep[multiline]),
596 print '%s:%s' % (str(in_num).ljust(width),line_sep[multiline]),
597 print inline,
597 print inline,
598
598
599 def magic_hist(self, parameter_s=''):
599 def magic_hist(self, parameter_s=''):
600 """Alternate name for %history."""
600 """Alternate name for %history."""
601 return self.magic_history(parameter_s)
601 return self.magic_history(parameter_s)
602
602
603 def magic_p(self, parameter_s=''):
603 def magic_p(self, parameter_s=''):
604 """Just a short alias for Python's 'print'."""
604 """Just a short alias for Python's 'print'."""
605 exec 'print ' + parameter_s in self.shell.user_ns
605 exec 'print ' + parameter_s in self.shell.user_ns
606
606
607 def magic_r(self, parameter_s=''):
607 def magic_r(self, parameter_s=''):
608 """Repeat previous input.
608 """Repeat previous input.
609
609
610 If given an argument, repeats the previous command which starts with
610 If given an argument, repeats the previous command which starts with
611 the same string, otherwise it just repeats the previous input.
611 the same string, otherwise it just repeats the previous input.
612
612
613 Shell escaped commands (with ! as first character) are not recognized
613 Shell escaped commands (with ! as first character) are not recognized
614 by this system, only pure python code and magic commands.
614 by this system, only pure python code and magic commands.
615 """
615 """
616
616
617 start = parameter_s.strip()
617 start = parameter_s.strip()
618 esc_magic = self.shell.ESC_MAGIC
618 esc_magic = self.shell.ESC_MAGIC
619 # Identify magic commands even if automagic is on (which means
619 # Identify magic commands even if automagic is on (which means
620 # the in-memory version is different from that typed by the user).
620 # the in-memory version is different from that typed by the user).
621 if self.shell.rc.automagic:
621 if self.shell.rc.automagic:
622 start_magic = esc_magic+start
622 start_magic = esc_magic+start
623 else:
623 else:
624 start_magic = start
624 start_magic = start
625 # Look through the input history in reverse
625 # Look through the input history in reverse
626 for n in range(len(self.shell.input_hist)-2,0,-1):
626 for n in range(len(self.shell.input_hist)-2,0,-1):
627 input = self.shell.input_hist[n]
627 input = self.shell.input_hist[n]
628 # skip plain 'r' lines so we don't recurse to infinity
628 # skip plain 'r' lines so we don't recurse to infinity
629 if input != '_ip.magic("r")\n' and \
629 if input != '_ip.magic("r")\n' and \
630 (input.startswith(start) or input.startswith(start_magic)):
630 (input.startswith(start) or input.startswith(start_magic)):
631 #print 'match',`input` # dbg
631 #print 'match',`input` # dbg
632 print 'Executing:',input,
632 print 'Executing:',input,
633 self.shell.runlines(input)
633 self.shell.runlines(input)
634 return
634 return
635 print 'No previous input matching `%s` found.' % start
635 print 'No previous input matching `%s` found.' % start
636
636
637 def magic_page(self, parameter_s=''):
637 def magic_page(self, parameter_s=''):
638 """Pretty print the object and display it through a pager.
638 """Pretty print the object and display it through a pager.
639
639
640 %page [options] OBJECT
640 %page [options] OBJECT
641
641
642 If no object is given, use _ (last output).
642 If no object is given, use _ (last output).
643
643
644 Options:
644 Options:
645
645
646 -r: page str(object), don't pretty-print it."""
646 -r: page str(object), don't pretty-print it."""
647
647
648 # After a function contributed by Olivier Aubert, slightly modified.
648 # After a function contributed by Olivier Aubert, slightly modified.
649
649
650 # Process options/args
650 # Process options/args
651 opts,args = self.parse_options(parameter_s,'r')
651 opts,args = self.parse_options(parameter_s,'r')
652 raw = 'r' in opts
652 raw = 'r' in opts
653
653
654 oname = args and args or '_'
654 oname = args and args or '_'
655 info = self._ofind(oname)
655 info = self._ofind(oname)
656 if info['found']:
656 if info['found']:
657 txt = (raw and str or pformat)( info['obj'] )
657 txt = (raw and str or pformat)( info['obj'] )
658 page(txt)
658 page(txt)
659 else:
659 else:
660 print 'Object `%s` not found' % oname
660 print 'Object `%s` not found' % oname
661
661
662 def magic_profile(self, parameter_s=''):
662 def magic_profile(self, parameter_s=''):
663 """Print your currently active IPyhton profile."""
663 """Print your currently active IPyhton profile."""
664 if self.shell.rc.profile:
664 if self.shell.rc.profile:
665 printpl('Current IPython profile: $self.shell.rc.profile.')
665 printpl('Current IPython profile: $self.shell.rc.profile.')
666 else:
666 else:
667 print 'No profile active.'
667 print 'No profile active.'
668
668
669 def _inspect(self,meth,oname,namespaces=None,**kw):
669 def _inspect(self,meth,oname,namespaces=None,**kw):
670 """Generic interface to the inspector system.
670 """Generic interface to the inspector system.
671
671
672 This function is meant to be called by pdef, pdoc & friends."""
672 This function is meant to be called by pdef, pdoc & friends."""
673
673
674 #oname = oname.strip()
674 #oname = oname.strip()
675 #print '1- oname: <%r>' % oname # dbg
675 #print '1- oname: <%r>' % oname # dbg
676 try:
676 try:
677 oname = oname.strip().encode('ascii')
677 oname = oname.strip().encode('ascii')
678 #print '2- oname: <%r>' % oname # dbg
678 #print '2- oname: <%r>' % oname # dbg
679 except UnicodeEncodeError:
679 except UnicodeEncodeError:
680 print 'Python identifiers can only contain ascii characters.'
680 print 'Python identifiers can only contain ascii characters.'
681 return 'not found'
681 return 'not found'
682
682
683 info = Struct(self._ofind(oname, namespaces))
683 info = Struct(self._ofind(oname, namespaces))
684
684
685 if info.found:
685 if info.found:
686 # Get the docstring of the class property if it exists.
686 # Get the docstring of the class property if it exists.
687 path = oname.split('.')
687 path = oname.split('.')
688 root = '.'.join(path[:-1])
688 root = '.'.join(path[:-1])
689 if info.parent is not None:
689 if info.parent is not None:
690 try:
690 try:
691 target = getattr(info.parent, '__class__')
691 target = getattr(info.parent, '__class__')
692 # The object belongs to a class instance.
692 # The object belongs to a class instance.
693 try:
693 try:
694 target = getattr(target, path[-1])
694 target = getattr(target, path[-1])
695 # The class defines the object.
695 # The class defines the object.
696 if isinstance(target, property):
696 if isinstance(target, property):
697 oname = root + '.__class__.' + path[-1]
697 oname = root + '.__class__.' + path[-1]
698 info = Struct(self._ofind(oname))
698 info = Struct(self._ofind(oname))
699 except AttributeError: pass
699 except AttributeError: pass
700 except AttributeError: pass
700 except AttributeError: pass
701
701
702 pmethod = getattr(self.shell.inspector,meth)
702 pmethod = getattr(self.shell.inspector,meth)
703 formatter = info.ismagic and self.format_screen or None
703 formatter = info.ismagic and self.format_screen or None
704 if meth == 'pdoc':
704 if meth == 'pdoc':
705 pmethod(info.obj,oname,formatter)
705 pmethod(info.obj,oname,formatter)
706 elif meth == 'pinfo':
706 elif meth == 'pinfo':
707 pmethod(info.obj,oname,formatter,info,**kw)
707 pmethod(info.obj,oname,formatter,info,**kw)
708 else:
708 else:
709 pmethod(info.obj,oname)
709 pmethod(info.obj,oname)
710 else:
710 else:
711 print 'Object `%s` not found.' % oname
711 print 'Object `%s` not found.' % oname
712 return 'not found' # so callers can take other action
712 return 'not found' # so callers can take other action
713
713
714 def magic_pdef(self, parameter_s='', namespaces=None):
714 def magic_pdef(self, parameter_s='', namespaces=None):
715 """Print the definition header for any callable object.
715 """Print the definition header for any callable object.
716
716
717 If the object is a class, print the constructor information."""
717 If the object is a class, print the constructor information."""
718 self._inspect('pdef',parameter_s, namespaces)
718 self._inspect('pdef',parameter_s, namespaces)
719
719
720 def magic_pdoc(self, parameter_s='', namespaces=None):
720 def magic_pdoc(self, parameter_s='', namespaces=None):
721 """Print the docstring for an object.
721 """Print the docstring for an object.
722
722
723 If the given object is a class, it will print both the class and the
723 If the given object is a class, it will print both the class and the
724 constructor docstrings."""
724 constructor docstrings."""
725 self._inspect('pdoc',parameter_s, namespaces)
725 self._inspect('pdoc',parameter_s, namespaces)
726
726
727 def magic_psource(self, parameter_s='', namespaces=None):
727 def magic_psource(self, parameter_s='', namespaces=None):
728 """Print (or run through pager) the source code for an object."""
728 """Print (or run through pager) the source code for an object."""
729 self._inspect('psource',parameter_s, namespaces)
729 self._inspect('psource',parameter_s, namespaces)
730
730
731 def magic_pfile(self, parameter_s=''):
731 def magic_pfile(self, parameter_s=''):
732 """Print (or run through pager) the file where an object is defined.
732 """Print (or run through pager) the file where an object is defined.
733
733
734 The file opens at the line where the object definition begins. IPython
734 The file opens at the line where the object definition begins. IPython
735 will honor the environment variable PAGER if set, and otherwise will
735 will honor the environment variable PAGER if set, and otherwise will
736 do its best to print the file in a convenient form.
736 do its best to print the file in a convenient form.
737
737
738 If the given argument is not an object currently defined, IPython will
738 If the given argument is not an object currently defined, IPython will
739 try to interpret it as a filename (automatically adding a .py extension
739 try to interpret it as a filename (automatically adding a .py extension
740 if needed). You can thus use %pfile as a syntax highlighting code
740 if needed). You can thus use %pfile as a syntax highlighting code
741 viewer."""
741 viewer."""
742
742
743 # first interpret argument as an object name
743 # first interpret argument as an object name
744 out = self._inspect('pfile',parameter_s)
744 out = self._inspect('pfile',parameter_s)
745 # if not, try the input as a filename
745 # if not, try the input as a filename
746 if out == 'not found':
746 if out == 'not found':
747 try:
747 try:
748 filename = get_py_filename(parameter_s)
748 filename = get_py_filename(parameter_s)
749 except IOError,msg:
749 except IOError,msg:
750 print msg
750 print msg
751 return
751 return
752 page(self.shell.inspector.format(file(filename).read()))
752 page(self.shell.inspector.format(file(filename).read()))
753
753
754 def magic_pinfo(self, parameter_s='', namespaces=None):
754 def magic_pinfo(self, parameter_s='', namespaces=None):
755 """Provide detailed information about an object.
755 """Provide detailed information about an object.
756
756
757 '%pinfo object' is just a synonym for object? or ?object."""
757 '%pinfo object' is just a synonym for object? or ?object."""
758
758
759 #print 'pinfo par: <%s>' % parameter_s # dbg
759 #print 'pinfo par: <%s>' % parameter_s # dbg
760
760
761 # detail_level: 0 -> obj? , 1 -> obj??
761 # detail_level: 0 -> obj? , 1 -> obj??
762 detail_level = 0
762 detail_level = 0
763 # We need to detect if we got called as 'pinfo pinfo foo', which can
763 # We need to detect if we got called as 'pinfo pinfo foo', which can
764 # happen if the user types 'pinfo foo?' at the cmd line.
764 # happen if the user types 'pinfo foo?' at the cmd line.
765 pinfo,qmark1,oname,qmark2 = \
765 pinfo,qmark1,oname,qmark2 = \
766 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
766 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
767 if pinfo or qmark1 or qmark2:
767 if pinfo or qmark1 or qmark2:
768 detail_level = 1
768 detail_level = 1
769 if "*" in oname:
769 if "*" in oname:
770 self.magic_psearch(oname)
770 self.magic_psearch(oname)
771 else:
771 else:
772 self._inspect('pinfo', oname, detail_level=detail_level,
772 self._inspect('pinfo', oname, detail_level=detail_level,
773 namespaces=namespaces)
773 namespaces=namespaces)
774
774
775 def magic_psearch(self, parameter_s=''):
775 def magic_psearch(self, parameter_s=''):
776 """Search for object in namespaces by wildcard.
776 """Search for object in namespaces by wildcard.
777
777
778 %psearch [options] PATTERN [OBJECT TYPE]
778 %psearch [options] PATTERN [OBJECT TYPE]
779
779
780 Note: ? can be used as a synonym for %psearch, at the beginning or at
780 Note: ? can be used as a synonym for %psearch, at the beginning or at
781 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
781 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
782 rest of the command line must be unchanged (options come first), so
782 rest of the command line must be unchanged (options come first), so
783 for example the following forms are equivalent
783 for example the following forms are equivalent
784
784
785 %psearch -i a* function
785 %psearch -i a* function
786 -i a* function?
786 -i a* function?
787 ?-i a* function
787 ?-i a* function
788
788
789 Arguments:
789 Arguments:
790
790
791 PATTERN
791 PATTERN
792
792
793 where PATTERN is a string containing * as a wildcard similar to its
793 where PATTERN is a string containing * as a wildcard similar to its
794 use in a shell. The pattern is matched in all namespaces on the
794 use in a shell. The pattern is matched in all namespaces on the
795 search path. By default objects starting with a single _ are not
795 search path. By default objects starting with a single _ are not
796 matched, many IPython generated objects have a single
796 matched, many IPython generated objects have a single
797 underscore. The default is case insensitive matching. Matching is
797 underscore. The default is case insensitive matching. Matching is
798 also done on the attributes of objects and not only on the objects
798 also done on the attributes of objects and not only on the objects
799 in a module.
799 in a module.
800
800
801 [OBJECT TYPE]
801 [OBJECT TYPE]
802
802
803 Is the name of a python type from the types module. The name is
803 Is the name of a python type from the types module. The name is
804 given in lowercase without the ending type, ex. StringType is
804 given in lowercase without the ending type, ex. StringType is
805 written string. By adding a type here only objects matching the
805 written string. By adding a type here only objects matching the
806 given type are matched. Using all here makes the pattern match all
806 given type are matched. Using all here makes the pattern match all
807 types (this is the default).
807 types (this is the default).
808
808
809 Options:
809 Options:
810
810
811 -a: makes the pattern match even objects whose names start with a
811 -a: makes the pattern match even objects whose names start with a
812 single underscore. These names are normally ommitted from the
812 single underscore. These names are normally ommitted from the
813 search.
813 search.
814
814
815 -i/-c: make the pattern case insensitive/sensitive. If neither of
815 -i/-c: make the pattern case insensitive/sensitive. If neither of
816 these options is given, the default is read from your ipythonrc
816 these options is given, the default is read from your ipythonrc
817 file. The option name which sets this value is
817 file. The option name which sets this value is
818 'wildcards_case_sensitive'. If this option is not specified in your
818 'wildcards_case_sensitive'. If this option is not specified in your
819 ipythonrc file, IPython's internal default is to do a case sensitive
819 ipythonrc file, IPython's internal default is to do a case sensitive
820 search.
820 search.
821
821
822 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
822 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
823 specifiy can be searched in any of the following namespaces:
823 specifiy can be searched in any of the following namespaces:
824 'builtin', 'user', 'user_global','internal', 'alias', where
824 'builtin', 'user', 'user_global','internal', 'alias', where
825 'builtin' and 'user' are the search defaults. Note that you should
825 'builtin' and 'user' are the search defaults. Note that you should
826 not use quotes when specifying namespaces.
826 not use quotes when specifying namespaces.
827
827
828 'Builtin' contains the python module builtin, 'user' contains all
828 'Builtin' contains the python module builtin, 'user' contains all
829 user data, 'alias' only contain the shell aliases and no python
829 user data, 'alias' only contain the shell aliases and no python
830 objects, 'internal' contains objects used by IPython. The
830 objects, 'internal' contains objects used by IPython. The
831 'user_global' namespace is only used by embedded IPython instances,
831 'user_global' namespace is only used by embedded IPython instances,
832 and it contains module-level globals. You can add namespaces to the
832 and it contains module-level globals. You can add namespaces to the
833 search with -s or exclude them with -e (these options can be given
833 search with -s or exclude them with -e (these options can be given
834 more than once).
834 more than once).
835
835
836 Examples:
836 Examples:
837
837
838 %psearch a* -> objects beginning with an a
838 %psearch a* -> objects beginning with an a
839 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
839 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
840 %psearch a* function -> all functions beginning with an a
840 %psearch a* function -> all functions beginning with an a
841 %psearch re.e* -> objects beginning with an e in module re
841 %psearch re.e* -> objects beginning with an e in module re
842 %psearch r*.e* -> objects that start with e in modules starting in r
842 %psearch r*.e* -> objects that start with e in modules starting in r
843 %psearch r*.* string -> all strings in modules beginning with r
843 %psearch r*.* string -> all strings in modules beginning with r
844
844
845 Case sensitve search:
845 Case sensitve search:
846
846
847 %psearch -c a* list all object beginning with lower case a
847 %psearch -c a* list all object beginning with lower case a
848
848
849 Show objects beginning with a single _:
849 Show objects beginning with a single _:
850
850
851 %psearch -a _* list objects beginning with a single underscore"""
851 %psearch -a _* list objects beginning with a single underscore"""
852 try:
852 try:
853 parameter_s = parameter_s.encode('ascii')
853 parameter_s = parameter_s.encode('ascii')
854 except UnicodeEncodeError:
854 except UnicodeEncodeError:
855 print 'Python identifiers can only contain ascii characters.'
855 print 'Python identifiers can only contain ascii characters.'
856 return
856 return
857
857
858 # default namespaces to be searched
858 # default namespaces to be searched
859 def_search = ['user','builtin']
859 def_search = ['user','builtin']
860
860
861 # Process options/args
861 # Process options/args
862 opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
862 opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
863 opt = opts.get
863 opt = opts.get
864 shell = self.shell
864 shell = self.shell
865 psearch = shell.inspector.psearch
865 psearch = shell.inspector.psearch
866
866
867 # select case options
867 # select case options
868 if opts.has_key('i'):
868 if opts.has_key('i'):
869 ignore_case = True
869 ignore_case = True
870 elif opts.has_key('c'):
870 elif opts.has_key('c'):
871 ignore_case = False
871 ignore_case = False
872 else:
872 else:
873 ignore_case = not shell.rc.wildcards_case_sensitive
873 ignore_case = not shell.rc.wildcards_case_sensitive
874
874
875 # Build list of namespaces to search from user options
875 # Build list of namespaces to search from user options
876 def_search.extend(opt('s',[]))
876 def_search.extend(opt('s',[]))
877 ns_exclude = ns_exclude=opt('e',[])
877 ns_exclude = ns_exclude=opt('e',[])
878 ns_search = [nm for nm in def_search if nm not in ns_exclude]
878 ns_search = [nm for nm in def_search if nm not in ns_exclude]
879
879
880 # Call the actual search
880 # Call the actual search
881 try:
881 try:
882 psearch(args,shell.ns_table,ns_search,
882 psearch(args,shell.ns_table,ns_search,
883 show_all=opt('a'),ignore_case=ignore_case)
883 show_all=opt('a'),ignore_case=ignore_case)
884 except:
884 except:
885 shell.showtraceback()
885 shell.showtraceback()
886
886
887 def magic_who_ls(self, parameter_s=''):
887 def magic_who_ls(self, parameter_s=''):
888 """Return a sorted list of all interactive variables.
888 """Return a sorted list of all interactive variables.
889
889
890 If arguments are given, only variables of types matching these
890 If arguments are given, only variables of types matching these
891 arguments are returned."""
891 arguments are returned."""
892
892
893 user_ns = self.shell.user_ns
893 user_ns = self.shell.user_ns
894 internal_ns = self.shell.internal_ns
894 internal_ns = self.shell.internal_ns
895 user_config_ns = self.shell.user_config_ns
895 user_config_ns = self.shell.user_config_ns
896 out = []
896 out = []
897 typelist = parameter_s.split()
897 typelist = parameter_s.split()
898
898
899 for i in user_ns:
899 for i in user_ns:
900 if not (i.startswith('_') or i.startswith('_i')) \
900 if not (i.startswith('_') or i.startswith('_i')) \
901 and not (i in internal_ns or i in user_config_ns):
901 and not (i in internal_ns or i in user_config_ns):
902 if typelist:
902 if typelist:
903 if type(user_ns[i]).__name__ in typelist:
903 if type(user_ns[i]).__name__ in typelist:
904 out.append(i)
904 out.append(i)
905 else:
905 else:
906 out.append(i)
906 out.append(i)
907 out.sort()
907 out.sort()
908 return out
908 return out
909
909
910 def magic_who(self, parameter_s=''):
910 def magic_who(self, parameter_s=''):
911 """Print all interactive variables, with some minimal formatting.
911 """Print all interactive variables, with some minimal formatting.
912
912
913 If any arguments are given, only variables whose type matches one of
913 If any arguments are given, only variables whose type matches one of
914 these are printed. For example:
914 these are printed. For example:
915
915
916 %who function str
916 %who function str
917
917
918 will only list functions and strings, excluding all other types of
918 will only list functions and strings, excluding all other types of
919 variables. To find the proper type names, simply use type(var) at a
919 variables. To find the proper type names, simply use type(var) at a
920 command line to see how python prints type names. For example:
920 command line to see how python prints type names. For example:
921
921
922 In [1]: type('hello')\\
922 In [1]: type('hello')\\
923 Out[1]: <type 'str'>
923 Out[1]: <type 'str'>
924
924
925 indicates that the type name for strings is 'str'.
925 indicates that the type name for strings is 'str'.
926
926
927 %who always excludes executed names loaded through your configuration
927 %who always excludes executed names loaded through your configuration
928 file and things which are internal to IPython.
928 file and things which are internal to IPython.
929
929
930 This is deliberate, as typically you may load many modules and the
930 This is deliberate, as typically you may load many modules and the
931 purpose of %who is to show you only what you've manually defined."""
931 purpose of %who is to show you only what you've manually defined."""
932
932
933 varlist = self.magic_who_ls(parameter_s)
933 varlist = self.magic_who_ls(parameter_s)
934 if not varlist:
934 if not varlist:
935 if parameter_s:
935 if parameter_s:
936 print 'No variables match your requested type.'
936 print 'No variables match your requested type.'
937 else:
937 else:
938 print 'Interactive namespace is empty.'
938 print 'Interactive namespace is empty.'
939 return
939 return
940
940
941 # if we have variables, move on...
941 # if we have variables, move on...
942 count = 0
942 count = 0
943 for i in varlist:
943 for i in varlist:
944 print i+'\t',
944 print i+'\t',
945 count += 1
945 count += 1
946 if count > 8:
946 if count > 8:
947 count = 0
947 count = 0
948 print
948 print
949 print
949 print
950
950
951 def magic_whos(self, parameter_s=''):
951 def magic_whos(self, parameter_s=''):
952 """Like %who, but gives some extra information about each variable.
952 """Like %who, but gives some extra information about each variable.
953
953
954 The same type filtering of %who can be applied here.
954 The same type filtering of %who can be applied here.
955
955
956 For all variables, the type is printed. Additionally it prints:
956 For all variables, the type is printed. Additionally it prints:
957
957
958 - For {},[],(): their length.
958 - For {},[],(): their length.
959
959
960 - For numpy and Numeric arrays, a summary with shape, number of
960 - For numpy and Numeric arrays, a summary with shape, number of
961 elements, typecode and size in memory.
961 elements, typecode and size in memory.
962
962
963 - Everything else: a string representation, snipping their middle if
963 - Everything else: a string representation, snipping their middle if
964 too long."""
964 too long."""
965
965
966 varnames = self.magic_who_ls(parameter_s)
966 varnames = self.magic_who_ls(parameter_s)
967 if not varnames:
967 if not varnames:
968 if parameter_s:
968 if parameter_s:
969 print 'No variables match your requested type.'
969 print 'No variables match your requested type.'
970 else:
970 else:
971 print 'Interactive namespace is empty.'
971 print 'Interactive namespace is empty.'
972 return
972 return
973
973
974 # if we have variables, move on...
974 # if we have variables, move on...
975
975
976 # for these types, show len() instead of data:
976 # for these types, show len() instead of data:
977 seq_types = [types.DictType,types.ListType,types.TupleType]
977 seq_types = [types.DictType,types.ListType,types.TupleType]
978
978
979 # for numpy/Numeric arrays, display summary info
979 # for numpy/Numeric arrays, display summary info
980 try:
980 try:
981 import numpy
981 import numpy
982 except ImportError:
982 except ImportError:
983 ndarray_type = None
983 ndarray_type = None
984 else:
984 else:
985 ndarray_type = numpy.ndarray.__name__
985 ndarray_type = numpy.ndarray.__name__
986 try:
986 try:
987 import Numeric
987 import Numeric
988 except ImportError:
988 except ImportError:
989 array_type = None
989 array_type = None
990 else:
990 else:
991 array_type = Numeric.ArrayType.__name__
991 array_type = Numeric.ArrayType.__name__
992
992
993 # Find all variable names and types so we can figure out column sizes
993 # Find all variable names and types so we can figure out column sizes
994 def get_vars(i):
994 def get_vars(i):
995 return self.shell.user_ns[i]
995 return self.shell.user_ns[i]
996
996
997 # some types are well known and can be shorter
997 # some types are well known and can be shorter
998 abbrevs = {'IPython.macro.Macro' : 'Macro'}
998 abbrevs = {'IPython.macro.Macro' : 'Macro'}
999 def type_name(v):
999 def type_name(v):
1000 tn = type(v).__name__
1000 tn = type(v).__name__
1001 return abbrevs.get(tn,tn)
1001 return abbrevs.get(tn,tn)
1002
1002
1003 varlist = map(get_vars,varnames)
1003 varlist = map(get_vars,varnames)
1004
1004
1005 typelist = []
1005 typelist = []
1006 for vv in varlist:
1006 for vv in varlist:
1007 tt = type_name(vv)
1007 tt = type_name(vv)
1008
1008
1009 if tt=='instance':
1009 if tt=='instance':
1010 typelist.append( abbrevs.get(str(vv.__class__),
1010 typelist.append( abbrevs.get(str(vv.__class__),
1011 str(vv.__class__)))
1011 str(vv.__class__)))
1012 else:
1012 else:
1013 typelist.append(tt)
1013 typelist.append(tt)
1014
1014
1015 # column labels and # of spaces as separator
1015 # column labels and # of spaces as separator
1016 varlabel = 'Variable'
1016 varlabel = 'Variable'
1017 typelabel = 'Type'
1017 typelabel = 'Type'
1018 datalabel = 'Data/Info'
1018 datalabel = 'Data/Info'
1019 colsep = 3
1019 colsep = 3
1020 # variable format strings
1020 # variable format strings
1021 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
1021 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
1022 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
1022 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
1023 aformat = "%s: %s elems, type `%s`, %s bytes"
1023 aformat = "%s: %s elems, type `%s`, %s bytes"
1024 # find the size of the columns to format the output nicely
1024 # find the size of the columns to format the output nicely
1025 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
1025 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
1026 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
1026 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
1027 # table header
1027 # table header
1028 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
1028 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
1029 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
1029 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
1030 # and the table itself
1030 # and the table itself
1031 kb = 1024
1031 kb = 1024
1032 Mb = 1048576 # kb**2
1032 Mb = 1048576 # kb**2
1033 for vname,var,vtype in zip(varnames,varlist,typelist):
1033 for vname,var,vtype in zip(varnames,varlist,typelist):
1034 print itpl(vformat),
1034 print itpl(vformat),
1035 if vtype in seq_types:
1035 if vtype in seq_types:
1036 print len(var)
1036 print len(var)
1037 elif vtype in [array_type,ndarray_type]:
1037 elif vtype in [array_type,ndarray_type]:
1038 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
1038 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
1039 if vtype==ndarray_type:
1039 if vtype==ndarray_type:
1040 # numpy
1040 # numpy
1041 vsize = var.size
1041 vsize = var.size
1042 vbytes = vsize*var.itemsize
1042 vbytes = vsize*var.itemsize
1043 vdtype = var.dtype
1043 vdtype = var.dtype
1044 else:
1044 else:
1045 # Numeric
1045 # Numeric
1046 vsize = Numeric.size(var)
1046 vsize = Numeric.size(var)
1047 vbytes = vsize*var.itemsize()
1047 vbytes = vsize*var.itemsize()
1048 vdtype = var.typecode()
1048 vdtype = var.typecode()
1049
1049
1050 if vbytes < 100000:
1050 if vbytes < 100000:
1051 print aformat % (vshape,vsize,vdtype,vbytes)
1051 print aformat % (vshape,vsize,vdtype,vbytes)
1052 else:
1052 else:
1053 print aformat % (vshape,vsize,vdtype,vbytes),
1053 print aformat % (vshape,vsize,vdtype,vbytes),
1054 if vbytes < Mb:
1054 if vbytes < Mb:
1055 print '(%s kb)' % (vbytes/kb,)
1055 print '(%s kb)' % (vbytes/kb,)
1056 else:
1056 else:
1057 print '(%s Mb)' % (vbytes/Mb,)
1057 print '(%s Mb)' % (vbytes/Mb,)
1058 else:
1058 else:
1059 vstr = str(var).replace('\n','\\n')
1059 vstr = str(var).replace('\n','\\n')
1060 if len(vstr) < 50:
1060 if len(vstr) < 50:
1061 print vstr
1061 print vstr
1062 else:
1062 else:
1063 printpl(vfmt_short)
1063 printpl(vfmt_short)
1064
1064
1065 def magic_reset(self, parameter_s=''):
1065 def magic_reset(self, parameter_s=''):
1066 """Resets the namespace by removing all names defined by the user.
1066 """Resets the namespace by removing all names defined by the user.
1067
1067
1068 Input/Output history are left around in case you need them."""
1068 Input/Output history are left around in case you need them."""
1069
1069
1070 ans = self.shell.ask_yes_no(
1070 ans = self.shell.ask_yes_no(
1071 "Once deleted, variables cannot be recovered. Proceed (y/[n])? ")
1071 "Once deleted, variables cannot be recovered. Proceed (y/[n])? ")
1072 if not ans:
1072 if not ans:
1073 print 'Nothing done.'
1073 print 'Nothing done.'
1074 return
1074 return
1075 user_ns = self.shell.user_ns
1075 user_ns = self.shell.user_ns
1076 for i in self.magic_who_ls():
1076 for i in self.magic_who_ls():
1077 del(user_ns[i])
1077 del(user_ns[i])
1078
1078
1079 def magic_logstart(self,parameter_s=''):
1079 def magic_logstart(self,parameter_s=''):
1080 """Start logging anywhere in a session.
1080 """Start logging anywhere in a session.
1081
1081
1082 %logstart [-o|-r|-t] [log_name [log_mode]]
1082 %logstart [-o|-r|-t] [log_name [log_mode]]
1083
1083
1084 If no name is given, it defaults to a file named 'ipython_log.py' in your
1084 If no name is given, it defaults to a file named 'ipython_log.py' in your
1085 current directory, in 'rotate' mode (see below).
1085 current directory, in 'rotate' mode (see below).
1086
1086
1087 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
1087 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
1088 history up to that point and then continues logging.
1088 history up to that point and then continues logging.
1089
1089
1090 %logstart takes a second optional parameter: logging mode. This can be one
1090 %logstart takes a second optional parameter: logging mode. This can be one
1091 of (note that the modes are given unquoted):\\
1091 of (note that the modes are given unquoted):\\
1092 append: well, that says it.\\
1092 append: well, that says it.\\
1093 backup: rename (if exists) to name~ and start name.\\
1093 backup: rename (if exists) to name~ and start name.\\
1094 global: single logfile in your home dir, appended to.\\
1094 global: single logfile in your home dir, appended to.\\
1095 over : overwrite existing log.\\
1095 over : overwrite existing log.\\
1096 rotate: create rotating logs name.1~, name.2~, etc.
1096 rotate: create rotating logs name.1~, name.2~, etc.
1097
1097
1098 Options:
1098 Options:
1099
1099
1100 -o: log also IPython's output. In this mode, all commands which
1100 -o: log also IPython's output. In this mode, all commands which
1101 generate an Out[NN] prompt are recorded to the logfile, right after
1101 generate an Out[NN] prompt are recorded to the logfile, right after
1102 their corresponding input line. The output lines are always
1102 their corresponding input line. The output lines are always
1103 prepended with a '#[Out]# ' marker, so that the log remains valid
1103 prepended with a '#[Out]# ' marker, so that the log remains valid
1104 Python code.
1104 Python code.
1105
1105
1106 Since this marker is always the same, filtering only the output from
1106 Since this marker is always the same, filtering only the output from
1107 a log is very easy, using for example a simple awk call:
1107 a log is very easy, using for example a simple awk call:
1108
1108
1109 awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py
1109 awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py
1110
1110
1111 -r: log 'raw' input. Normally, IPython's logs contain the processed
1111 -r: log 'raw' input. Normally, IPython's logs contain the processed
1112 input, so that user lines are logged in their final form, converted
1112 input, so that user lines are logged in their final form, converted
1113 into valid Python. For example, %Exit is logged as
1113 into valid Python. For example, %Exit is logged as
1114 '_ip.magic("Exit"). If the -r flag is given, all input is logged
1114 '_ip.magic("Exit"). If the -r flag is given, all input is logged
1115 exactly as typed, with no transformations applied.
1115 exactly as typed, with no transformations applied.
1116
1116
1117 -t: put timestamps before each input line logged (these are put in
1117 -t: put timestamps before each input line logged (these are put in
1118 comments)."""
1118 comments)."""
1119
1119
1120 opts,par = self.parse_options(parameter_s,'ort')
1120 opts,par = self.parse_options(parameter_s,'ort')
1121 log_output = 'o' in opts
1121 log_output = 'o' in opts
1122 log_raw_input = 'r' in opts
1122 log_raw_input = 'r' in opts
1123 timestamp = 't' in opts
1123 timestamp = 't' in opts
1124
1124
1125 rc = self.shell.rc
1125 rc = self.shell.rc
1126 logger = self.shell.logger
1126 logger = self.shell.logger
1127
1127
1128 # if no args are given, the defaults set in the logger constructor by
1128 # if no args are given, the defaults set in the logger constructor by
1129 # ipytohn remain valid
1129 # ipytohn remain valid
1130 if par:
1130 if par:
1131 try:
1131 try:
1132 logfname,logmode = par.split()
1132 logfname,logmode = par.split()
1133 except:
1133 except:
1134 logfname = par
1134 logfname = par
1135 logmode = 'backup'
1135 logmode = 'backup'
1136 else:
1136 else:
1137 logfname = logger.logfname
1137 logfname = logger.logfname
1138 logmode = logger.logmode
1138 logmode = logger.logmode
1139 # put logfname into rc struct as if it had been called on the command
1139 # put logfname into rc struct as if it had been called on the command
1140 # line, so it ends up saved in the log header Save it in case we need
1140 # line, so it ends up saved in the log header Save it in case we need
1141 # to restore it...
1141 # to restore it...
1142 old_logfile = rc.opts.get('logfile','')
1142 old_logfile = rc.opts.get('logfile','')
1143 if logfname:
1143 if logfname:
1144 logfname = os.path.expanduser(logfname)
1144 logfname = os.path.expanduser(logfname)
1145 rc.opts.logfile = logfname
1145 rc.opts.logfile = logfname
1146 loghead = self.shell.loghead_tpl % (rc.opts,rc.args)
1146 loghead = self.shell.loghead_tpl % (rc.opts,rc.args)
1147 try:
1147 try:
1148 started = logger.logstart(logfname,loghead,logmode,
1148 started = logger.logstart(logfname,loghead,logmode,
1149 log_output,timestamp,log_raw_input)
1149 log_output,timestamp,log_raw_input)
1150 except:
1150 except:
1151 rc.opts.logfile = old_logfile
1151 rc.opts.logfile = old_logfile
1152 warn("Couldn't start log: %s" % sys.exc_info()[1])
1152 warn("Couldn't start log: %s" % sys.exc_info()[1])
1153 else:
1153 else:
1154 # log input history up to this point, optionally interleaving
1154 # log input history up to this point, optionally interleaving
1155 # output if requested
1155 # output if requested
1156
1156
1157 if timestamp:
1157 if timestamp:
1158 # disable timestamping for the previous history, since we've
1158 # disable timestamping for the previous history, since we've
1159 # lost those already (no time machine here).
1159 # lost those already (no time machine here).
1160 logger.timestamp = False
1160 logger.timestamp = False
1161
1161
1162 if log_raw_input:
1162 if log_raw_input:
1163 input_hist = self.shell.input_hist_raw
1163 input_hist = self.shell.input_hist_raw
1164 else:
1164 else:
1165 input_hist = self.shell.input_hist
1165 input_hist = self.shell.input_hist
1166
1166
1167 if log_output:
1167 if log_output:
1168 log_write = logger.log_write
1168 log_write = logger.log_write
1169 output_hist = self.shell.output_hist
1169 output_hist = self.shell.output_hist
1170 for n in range(1,len(input_hist)-1):
1170 for n in range(1,len(input_hist)-1):
1171 log_write(input_hist[n].rstrip())
1171 log_write(input_hist[n].rstrip())
1172 if n in output_hist:
1172 if n in output_hist:
1173 log_write(repr(output_hist[n]),'output')
1173 log_write(repr(output_hist[n]),'output')
1174 else:
1174 else:
1175 logger.log_write(input_hist[1:])
1175 logger.log_write(input_hist[1:])
1176 if timestamp:
1176 if timestamp:
1177 # re-enable timestamping
1177 # re-enable timestamping
1178 logger.timestamp = True
1178 logger.timestamp = True
1179
1179
1180 print ('Activating auto-logging. '
1180 print ('Activating auto-logging. '
1181 'Current session state plus future input saved.')
1181 'Current session state plus future input saved.')
1182 logger.logstate()
1182 logger.logstate()
1183
1183
1184 def magic_logoff(self,parameter_s=''):
1184 def magic_logoff(self,parameter_s=''):
1185 """Temporarily stop logging.
1185 """Temporarily stop logging.
1186
1186
1187 You must have previously started logging."""
1187 You must have previously started logging."""
1188 self.shell.logger.switch_log(0)
1188 self.shell.logger.switch_log(0)
1189
1189
1190 def magic_logon(self,parameter_s=''):
1190 def magic_logon(self,parameter_s=''):
1191 """Restart logging.
1191 """Restart logging.
1192
1192
1193 This function is for restarting logging which you've temporarily
1193 This function is for restarting logging which you've temporarily
1194 stopped with %logoff. For starting logging for the first time, you
1194 stopped with %logoff. For starting logging for the first time, you
1195 must use the %logstart function, which allows you to specify an
1195 must use the %logstart function, which allows you to specify an
1196 optional log filename."""
1196 optional log filename."""
1197
1197
1198 self.shell.logger.switch_log(1)
1198 self.shell.logger.switch_log(1)
1199
1199
1200 def magic_logstate(self,parameter_s=''):
1200 def magic_logstate(self,parameter_s=''):
1201 """Print the status of the logging system."""
1201 """Print the status of the logging system."""
1202
1202
1203 self.shell.logger.logstate()
1203 self.shell.logger.logstate()
1204
1204
1205 def magic_pdb(self, parameter_s=''):
1205 def magic_pdb(self, parameter_s=''):
1206 """Control the automatic calling of the pdb interactive debugger.
1206 """Control the automatic calling of the pdb interactive debugger.
1207
1207
1208 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1208 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1209 argument it works as a toggle.
1209 argument it works as a toggle.
1210
1210
1211 When an exception is triggered, IPython can optionally call the
1211 When an exception is triggered, IPython can optionally call the
1212 interactive pdb debugger after the traceback printout. %pdb toggles
1212 interactive pdb debugger after the traceback printout. %pdb toggles
1213 this feature on and off.
1213 this feature on and off.
1214
1214
1215 The initial state of this feature is set in your ipythonrc
1215 The initial state of this feature is set in your ipythonrc
1216 configuration file (the variable is called 'pdb').
1216 configuration file (the variable is called 'pdb').
1217
1217
1218 If you want to just activate the debugger AFTER an exception has fired,
1218 If you want to just activate the debugger AFTER an exception has fired,
1219 without having to type '%pdb on' and rerunning your code, you can use
1219 without having to type '%pdb on' and rerunning your code, you can use
1220 the %debug magic."""
1220 the %debug magic."""
1221
1221
1222 par = parameter_s.strip().lower()
1222 par = parameter_s.strip().lower()
1223
1223
1224 if par:
1224 if par:
1225 try:
1225 try:
1226 new_pdb = {'off':0,'0':0,'on':1,'1':1}[par]
1226 new_pdb = {'off':0,'0':0,'on':1,'1':1}[par]
1227 except KeyError:
1227 except KeyError:
1228 print ('Incorrect argument. Use on/1, off/0, '
1228 print ('Incorrect argument. Use on/1, off/0, '
1229 'or nothing for a toggle.')
1229 'or nothing for a toggle.')
1230 return
1230 return
1231 else:
1231 else:
1232 # toggle
1232 # toggle
1233 new_pdb = not self.shell.call_pdb
1233 new_pdb = not self.shell.call_pdb
1234
1234
1235 # set on the shell
1235 # set on the shell
1236 self.shell.call_pdb = new_pdb
1236 self.shell.call_pdb = new_pdb
1237 print 'Automatic pdb calling has been turned',on_off(new_pdb)
1237 print 'Automatic pdb calling has been turned',on_off(new_pdb)
1238
1238
1239 def magic_debug(self, parameter_s=''):
1239 def magic_debug(self, parameter_s=''):
1240 """Activate the interactive debugger in post-mortem mode.
1240 """Activate the interactive debugger in post-mortem mode.
1241
1241
1242 If an exception has just occurred, this lets you inspect its stack
1242 If an exception has just occurred, this lets you inspect its stack
1243 frames interactively. Note that this will always work only on the last
1243 frames interactively. Note that this will always work only on the last
1244 traceback that occurred, so you must call this quickly after an
1244 traceback that occurred, so you must call this quickly after an
1245 exception that you wish to inspect has fired, because if another one
1245 exception that you wish to inspect has fired, because if another one
1246 occurs, it clobbers the previous one.
1246 occurs, it clobbers the previous one.
1247
1247
1248 If you want IPython to automatically do this on every exception, see
1248 If you want IPython to automatically do this on every exception, see
1249 the %pdb magic for more details.
1249 the %pdb magic for more details.
1250 """
1250 """
1251
1251
1252 self.shell.debugger(force=True)
1252 self.shell.debugger(force=True)
1253
1253
1254 def magic_prun(self, parameter_s ='',user_mode=1,
1254 def magic_prun(self, parameter_s ='',user_mode=1,
1255 opts=None,arg_lst=None,prog_ns=None):
1255 opts=None,arg_lst=None,prog_ns=None):
1256
1256
1257 """Run a statement through the python code profiler.
1257 """Run a statement through the python code profiler.
1258
1258
1259 Usage:\\
1259 Usage:\\
1260 %prun [options] statement
1260 %prun [options] statement
1261
1261
1262 The given statement (which doesn't require quote marks) is run via the
1262 The given statement (which doesn't require quote marks) is run via the
1263 python profiler in a manner similar to the profile.run() function.
1263 python profiler in a manner similar to the profile.run() function.
1264 Namespaces are internally managed to work correctly; profile.run
1264 Namespaces are internally managed to work correctly; profile.run
1265 cannot be used in IPython because it makes certain assumptions about
1265 cannot be used in IPython because it makes certain assumptions about
1266 namespaces which do not hold under IPython.
1266 namespaces which do not hold under IPython.
1267
1267
1268 Options:
1268 Options:
1269
1269
1270 -l <limit>: you can place restrictions on what or how much of the
1270 -l <limit>: you can place restrictions on what or how much of the
1271 profile gets printed. The limit value can be:
1271 profile gets printed. The limit value can be:
1272
1272
1273 * A string: only information for function names containing this string
1273 * A string: only information for function names containing this string
1274 is printed.
1274 is printed.
1275
1275
1276 * An integer: only these many lines are printed.
1276 * An integer: only these many lines are printed.
1277
1277
1278 * A float (between 0 and 1): this fraction of the report is printed
1278 * A float (between 0 and 1): this fraction of the report is printed
1279 (for example, use a limit of 0.4 to see the topmost 40% only).
1279 (for example, use a limit of 0.4 to see the topmost 40% only).
1280
1280
1281 You can combine several limits with repeated use of the option. For
1281 You can combine several limits with repeated use of the option. For
1282 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1282 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1283 information about class constructors.
1283 information about class constructors.
1284
1284
1285 -r: return the pstats.Stats object generated by the profiling. This
1285 -r: return the pstats.Stats object generated by the profiling. This
1286 object has all the information about the profile in it, and you can
1286 object has all the information about the profile in it, and you can
1287 later use it for further analysis or in other functions.
1287 later use it for further analysis or in other functions.
1288
1288
1289 -s <key>: sort profile by given key. You can provide more than one key
1289 -s <key>: sort profile by given key. You can provide more than one key
1290 by using the option several times: '-s key1 -s key2 -s key3...'. The
1290 by using the option several times: '-s key1 -s key2 -s key3...'. The
1291 default sorting key is 'time'.
1291 default sorting key is 'time'.
1292
1292
1293 The following is copied verbatim from the profile documentation
1293 The following is copied verbatim from the profile documentation
1294 referenced below:
1294 referenced below:
1295
1295
1296 When more than one key is provided, additional keys are used as
1296 When more than one key is provided, additional keys are used as
1297 secondary criteria when the there is equality in all keys selected
1297 secondary criteria when the there is equality in all keys selected
1298 before them.
1298 before them.
1299
1299
1300 Abbreviations can be used for any key names, as long as the
1300 Abbreviations can be used for any key names, as long as the
1301 abbreviation is unambiguous. The following are the keys currently
1301 abbreviation is unambiguous. The following are the keys currently
1302 defined:
1302 defined:
1303
1303
1304 Valid Arg Meaning\\
1304 Valid Arg Meaning\\
1305 "calls" call count\\
1305 "calls" call count\\
1306 "cumulative" cumulative time\\
1306 "cumulative" cumulative time\\
1307 "file" file name\\
1307 "file" file name\\
1308 "module" file name\\
1308 "module" file name\\
1309 "pcalls" primitive call count\\
1309 "pcalls" primitive call count\\
1310 "line" line number\\
1310 "line" line number\\
1311 "name" function name\\
1311 "name" function name\\
1312 "nfl" name/file/line\\
1312 "nfl" name/file/line\\
1313 "stdname" standard name\\
1313 "stdname" standard name\\
1314 "time" internal time
1314 "time" internal time
1315
1315
1316 Note that all sorts on statistics are in descending order (placing
1316 Note that all sorts on statistics are in descending order (placing
1317 most time consuming items first), where as name, file, and line number
1317 most time consuming items first), where as name, file, and line number
1318 searches are in ascending order (i.e., alphabetical). The subtle
1318 searches are in ascending order (i.e., alphabetical). The subtle
1319 distinction between "nfl" and "stdname" is that the standard name is a
1319 distinction between "nfl" and "stdname" is that the standard name is a
1320 sort of the name as printed, which means that the embedded line
1320 sort of the name as printed, which means that the embedded line
1321 numbers get compared in an odd way. For example, lines 3, 20, and 40
1321 numbers get compared in an odd way. For example, lines 3, 20, and 40
1322 would (if the file names were the same) appear in the string order
1322 would (if the file names were the same) appear in the string order
1323 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1323 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1324 line numbers. In fact, sort_stats("nfl") is the same as
1324 line numbers. In fact, sort_stats("nfl") is the same as
1325 sort_stats("name", "file", "line").
1325 sort_stats("name", "file", "line").
1326
1326
1327 -T <filename>: save profile results as shown on screen to a text
1327 -T <filename>: save profile results as shown on screen to a text
1328 file. The profile is still shown on screen.
1328 file. The profile is still shown on screen.
1329
1329
1330 -D <filename>: save (via dump_stats) profile statistics to given
1330 -D <filename>: save (via dump_stats) profile statistics to given
1331 filename. This data is in a format understod by the pstats module, and
1331 filename. This data is in a format understod by the pstats module, and
1332 is generated by a call to the dump_stats() method of profile
1332 is generated by a call to the dump_stats() method of profile
1333 objects. The profile is still shown on screen.
1333 objects. The profile is still shown on screen.
1334
1334
1335 If you want to run complete programs under the profiler's control, use
1335 If you want to run complete programs under the profiler's control, use
1336 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1336 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1337 contains profiler specific options as described here.
1337 contains profiler specific options as described here.
1338
1338
1339 You can read the complete documentation for the profile module with:\\
1339 You can read the complete documentation for the profile module with:\\
1340 In [1]: import profile; profile.help() """
1340 In [1]: import profile; profile.help() """
1341
1341
1342 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1342 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1343 # protect user quote marks
1343 # protect user quote marks
1344 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1344 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1345
1345
1346 if user_mode: # regular user call
1346 if user_mode: # regular user call
1347 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1347 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1348 list_all=1)
1348 list_all=1)
1349 namespace = self.shell.user_ns
1349 namespace = self.shell.user_ns
1350 else: # called to run a program by %run -p
1350 else: # called to run a program by %run -p
1351 try:
1351 try:
1352 filename = get_py_filename(arg_lst[0])
1352 filename = get_py_filename(arg_lst[0])
1353 except IOError,msg:
1353 except IOError,msg:
1354 error(msg)
1354 error(msg)
1355 return
1355 return
1356
1356
1357 arg_str = 'execfile(filename,prog_ns)'
1357 arg_str = 'execfile(filename,prog_ns)'
1358 namespace = locals()
1358 namespace = locals()
1359
1359
1360 opts.merge(opts_def)
1360 opts.merge(opts_def)
1361
1361
1362 prof = profile.Profile()
1362 prof = profile.Profile()
1363 try:
1363 try:
1364 prof = prof.runctx(arg_str,namespace,namespace)
1364 prof = prof.runctx(arg_str,namespace,namespace)
1365 sys_exit = ''
1365 sys_exit = ''
1366 except SystemExit:
1366 except SystemExit:
1367 sys_exit = """*** SystemExit exception caught in code being profiled."""
1367 sys_exit = """*** SystemExit exception caught in code being profiled."""
1368
1368
1369 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1369 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1370
1370
1371 lims = opts.l
1371 lims = opts.l
1372 if lims:
1372 if lims:
1373 lims = [] # rebuild lims with ints/floats/strings
1373 lims = [] # rebuild lims with ints/floats/strings
1374 for lim in opts.l:
1374 for lim in opts.l:
1375 try:
1375 try:
1376 lims.append(int(lim))
1376 lims.append(int(lim))
1377 except ValueError:
1377 except ValueError:
1378 try:
1378 try:
1379 lims.append(float(lim))
1379 lims.append(float(lim))
1380 except ValueError:
1380 except ValueError:
1381 lims.append(lim)
1381 lims.append(lim)
1382
1382
1383 # Trap output.
1383 # Trap output.
1384 stdout_trap = StringIO()
1384 stdout_trap = StringIO()
1385
1385
1386 if hasattr(stats,'stream'):
1386 if hasattr(stats,'stream'):
1387 # In newer versions of python, the stats object has a 'stream'
1387 # In newer versions of python, the stats object has a 'stream'
1388 # attribute to write into.
1388 # attribute to write into.
1389 stats.stream = stdout_trap
1389 stats.stream = stdout_trap
1390 stats.print_stats(*lims)
1390 stats.print_stats(*lims)
1391 else:
1391 else:
1392 # For older versions, we manually redirect stdout during printing
1392 # For older versions, we manually redirect stdout during printing
1393 sys_stdout = sys.stdout
1393 sys_stdout = sys.stdout
1394 try:
1394 try:
1395 sys.stdout = stdout_trap
1395 sys.stdout = stdout_trap
1396 stats.print_stats(*lims)
1396 stats.print_stats(*lims)
1397 finally:
1397 finally:
1398 sys.stdout = sys_stdout
1398 sys.stdout = sys_stdout
1399
1399
1400 output = stdout_trap.getvalue()
1400 output = stdout_trap.getvalue()
1401 output = output.rstrip()
1401 output = output.rstrip()
1402
1402
1403 page(output,screen_lines=self.shell.rc.screen_length)
1403 page(output,screen_lines=self.shell.rc.screen_length)
1404 print sys_exit,
1404 print sys_exit,
1405
1405
1406 dump_file = opts.D[0]
1406 dump_file = opts.D[0]
1407 text_file = opts.T[0]
1407 text_file = opts.T[0]
1408 if dump_file:
1408 if dump_file:
1409 prof.dump_stats(dump_file)
1409 prof.dump_stats(dump_file)
1410 print '\n*** Profile stats marshalled to file',\
1410 print '\n*** Profile stats marshalled to file',\
1411 `dump_file`+'.',sys_exit
1411 `dump_file`+'.',sys_exit
1412 if text_file:
1412 if text_file:
1413 pfile = file(text_file,'w')
1413 pfile = file(text_file,'w')
1414 pfile.write(output)
1414 pfile.write(output)
1415 pfile.close()
1415 pfile.close()
1416 print '\n*** Profile printout saved to text file',\
1416 print '\n*** Profile printout saved to text file',\
1417 `text_file`+'.',sys_exit
1417 `text_file`+'.',sys_exit
1418
1418
1419 if opts.has_key('r'):
1419 if opts.has_key('r'):
1420 return stats
1420 return stats
1421 else:
1421 else:
1422 return None
1422 return None
1423
1423
1424 def magic_run(self, parameter_s ='',runner=None):
1424 def magic_run(self, parameter_s ='',runner=None):
1425 """Run the named file inside IPython as a program.
1425 """Run the named file inside IPython as a program.
1426
1426
1427 Usage:\\
1427 Usage:\\
1428 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1428 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1429
1429
1430 Parameters after the filename are passed as command-line arguments to
1430 Parameters after the filename are passed as command-line arguments to
1431 the program (put in sys.argv). Then, control returns to IPython's
1431 the program (put in sys.argv). Then, control returns to IPython's
1432 prompt.
1432 prompt.
1433
1433
1434 This is similar to running at a system prompt:\\
1434 This is similar to running at a system prompt:\\
1435 $ python file args\\
1435 $ python file args\\
1436 but with the advantage of giving you IPython's tracebacks, and of
1436 but with the advantage of giving you IPython's tracebacks, and of
1437 loading all variables into your interactive namespace for further use
1437 loading all variables into your interactive namespace for further use
1438 (unless -p is used, see below).
1438 (unless -p is used, see below).
1439
1439
1440 The file is executed in a namespace initially consisting only of
1440 The file is executed in a namespace initially consisting only of
1441 __name__=='__main__' and sys.argv constructed as indicated. It thus
1441 __name__=='__main__' and sys.argv constructed as indicated. It thus
1442 sees its environment as if it were being run as a stand-alone
1442 sees its environment as if it were being run as a stand-alone
1443 program. But after execution, the IPython interactive namespace gets
1443 program. But after execution, the IPython interactive namespace gets
1444 updated with all variables defined in the program (except for __name__
1444 updated with all variables defined in the program (except for __name__
1445 and sys.argv). This allows for very convenient loading of code for
1445 and sys.argv). This allows for very convenient loading of code for
1446 interactive work, while giving each program a 'clean sheet' to run in.
1446 interactive work, while giving each program a 'clean sheet' to run in.
1447
1447
1448 Options:
1448 Options:
1449
1449
1450 -n: __name__ is NOT set to '__main__', but to the running file's name
1450 -n: __name__ is NOT set to '__main__', but to the running file's name
1451 without extension (as python does under import). This allows running
1451 without extension (as python does under import). This allows running
1452 scripts and reloading the definitions in them without calling code
1452 scripts and reloading the definitions in them without calling code
1453 protected by an ' if __name__ == "__main__" ' clause.
1453 protected by an ' if __name__ == "__main__" ' clause.
1454
1454
1455 -i: run the file in IPython's namespace instead of an empty one. This
1455 -i: run the file in IPython's namespace instead of an empty one. This
1456 is useful if you are experimenting with code written in a text editor
1456 is useful if you are experimenting with code written in a text editor
1457 which depends on variables defined interactively.
1457 which depends on variables defined interactively.
1458
1458
1459 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1459 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1460 being run. This is particularly useful if IPython is being used to
1460 being run. This is particularly useful if IPython is being used to
1461 run unittests, which always exit with a sys.exit() call. In such
1461 run unittests, which always exit with a sys.exit() call. In such
1462 cases you are interested in the output of the test results, not in
1462 cases you are interested in the output of the test results, not in
1463 seeing a traceback of the unittest module.
1463 seeing a traceback of the unittest module.
1464
1464
1465 -t: print timing information at the end of the run. IPython will give
1465 -t: print timing information at the end of the run. IPython will give
1466 you an estimated CPU time consumption for your script, which under
1466 you an estimated CPU time consumption for your script, which under
1467 Unix uses the resource module to avoid the wraparound problems of
1467 Unix uses the resource module to avoid the wraparound problems of
1468 time.clock(). Under Unix, an estimate of time spent on system tasks
1468 time.clock(). Under Unix, an estimate of time spent on system tasks
1469 is also given (for Windows platforms this is reported as 0.0).
1469 is also given (for Windows platforms this is reported as 0.0).
1470
1470
1471 If -t is given, an additional -N<N> option can be given, where <N>
1471 If -t is given, an additional -N<N> option can be given, where <N>
1472 must be an integer indicating how many times you want the script to
1472 must be an integer indicating how many times you want the script to
1473 run. The final timing report will include total and per run results.
1473 run. The final timing report will include total and per run results.
1474
1474
1475 For example (testing the script uniq_stable.py):
1475 For example (testing the script uniq_stable.py):
1476
1476
1477 In [1]: run -t uniq_stable
1477 In [1]: run -t uniq_stable
1478
1478
1479 IPython CPU timings (estimated):\\
1479 IPython CPU timings (estimated):\\
1480 User : 0.19597 s.\\
1480 User : 0.19597 s.\\
1481 System: 0.0 s.\\
1481 System: 0.0 s.\\
1482
1482
1483 In [2]: run -t -N5 uniq_stable
1483 In [2]: run -t -N5 uniq_stable
1484
1484
1485 IPython CPU timings (estimated):\\
1485 IPython CPU timings (estimated):\\
1486 Total runs performed: 5\\
1486 Total runs performed: 5\\
1487 Times : Total Per run\\
1487 Times : Total Per run\\
1488 User : 0.910862 s, 0.1821724 s.\\
1488 User : 0.910862 s, 0.1821724 s.\\
1489 System: 0.0 s, 0.0 s.
1489 System: 0.0 s, 0.0 s.
1490
1490
1491 -d: run your program under the control of pdb, the Python debugger.
1491 -d: run your program under the control of pdb, the Python debugger.
1492 This allows you to execute your program step by step, watch variables,
1492 This allows you to execute your program step by step, watch variables,
1493 etc. Internally, what IPython does is similar to calling:
1493 etc. Internally, what IPython does is similar to calling:
1494
1494
1495 pdb.run('execfile("YOURFILENAME")')
1495 pdb.run('execfile("YOURFILENAME")')
1496
1496
1497 with a breakpoint set on line 1 of your file. You can change the line
1497 with a breakpoint set on line 1 of your file. You can change the line
1498 number for this automatic breakpoint to be <N> by using the -bN option
1498 number for this automatic breakpoint to be <N> by using the -bN option
1499 (where N must be an integer). For example:
1499 (where N must be an integer). For example:
1500
1500
1501 %run -d -b40 myscript
1501 %run -d -b40 myscript
1502
1502
1503 will set the first breakpoint at line 40 in myscript.py. Note that
1503 will set the first breakpoint at line 40 in myscript.py. Note that
1504 the first breakpoint must be set on a line which actually does
1504 the first breakpoint must be set on a line which actually does
1505 something (not a comment or docstring) for it to stop execution.
1505 something (not a comment or docstring) for it to stop execution.
1506
1506
1507 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1507 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1508 first enter 'c' (without qoutes) to start execution up to the first
1508 first enter 'c' (without qoutes) to start execution up to the first
1509 breakpoint.
1509 breakpoint.
1510
1510
1511 Entering 'help' gives information about the use of the debugger. You
1511 Entering 'help' gives information about the use of the debugger. You
1512 can easily see pdb's full documentation with "import pdb;pdb.help()"
1512 can easily see pdb's full documentation with "import pdb;pdb.help()"
1513 at a prompt.
1513 at a prompt.
1514
1514
1515 -p: run program under the control of the Python profiler module (which
1515 -p: run program under the control of the Python profiler module (which
1516 prints a detailed report of execution times, function calls, etc).
1516 prints a detailed report of execution times, function calls, etc).
1517
1517
1518 You can pass other options after -p which affect the behavior of the
1518 You can pass other options after -p which affect the behavior of the
1519 profiler itself. See the docs for %prun for details.
1519 profiler itself. See the docs for %prun for details.
1520
1520
1521 In this mode, the program's variables do NOT propagate back to the
1521 In this mode, the program's variables do NOT propagate back to the
1522 IPython interactive namespace (because they remain in the namespace
1522 IPython interactive namespace (because they remain in the namespace
1523 where the profiler executes them).
1523 where the profiler executes them).
1524
1524
1525 Internally this triggers a call to %prun, see its documentation for
1525 Internally this triggers a call to %prun, see its documentation for
1526 details on the options available specifically for profiling.
1526 details on the options available specifically for profiling.
1527
1527
1528 There is one special usage for which the text above doesn't apply:
1528 There is one special usage for which the text above doesn't apply:
1529 if the filename ends with .ipy, the file is run as ipython script,
1529 if the filename ends with .ipy, the file is run as ipython script,
1530 just as if the commands were written on IPython prompt.
1530 just as if the commands were written on IPython prompt.
1531 """
1531 """
1532
1532
1533 # get arguments and set sys.argv for program to be run.
1533 # get arguments and set sys.argv for program to be run.
1534 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1534 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1535 mode='list',list_all=1)
1535 mode='list',list_all=1)
1536
1536
1537 try:
1537 try:
1538 filename = get_py_filename(arg_lst[0])
1538 filename = get_py_filename(arg_lst[0])
1539 except IndexError:
1539 except IndexError:
1540 warn('you must provide at least a filename.')
1540 warn('you must provide at least a filename.')
1541 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1541 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1542 return
1542 return
1543 except IOError,msg:
1543 except IOError,msg:
1544 error(msg)
1544 error(msg)
1545 return
1545 return
1546
1546
1547 if filename.lower().endswith('.ipy'):
1547 if filename.lower().endswith('.ipy'):
1548 self.api.runlines(open(filename).read())
1548 self.api.runlines(open(filename).read())
1549 return
1549 return
1550
1550
1551 # Control the response to exit() calls made by the script being run
1551 # Control the response to exit() calls made by the script being run
1552 exit_ignore = opts.has_key('e')
1552 exit_ignore = opts.has_key('e')
1553
1553
1554 # Make sure that the running script gets a proper sys.argv as if it
1554 # Make sure that the running script gets a proper sys.argv as if it
1555 # were run from a system shell.
1555 # were run from a system shell.
1556 save_argv = sys.argv # save it for later restoring
1556 save_argv = sys.argv # save it for later restoring
1557 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1557 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1558
1558
1559 if opts.has_key('i'):
1559 if opts.has_key('i'):
1560 prog_ns = self.shell.user_ns
1560 prog_ns = self.shell.user_ns
1561 __name__save = self.shell.user_ns['__name__']
1561 __name__save = self.shell.user_ns['__name__']
1562 prog_ns['__name__'] = '__main__'
1562 prog_ns['__name__'] = '__main__'
1563 else:
1563 else:
1564 if opts.has_key('n'):
1564 if opts.has_key('n'):
1565 name = os.path.splitext(os.path.basename(filename))[0]
1565 name = os.path.splitext(os.path.basename(filename))[0]
1566 else:
1566 else:
1567 name = '__main__'
1567 name = '__main__'
1568 prog_ns = {'__name__':name}
1568 prog_ns = {'__name__':name}
1569
1569
1570 # Since '%run foo' emulates 'python foo.py' at the cmd line, we must
1570 # Since '%run foo' emulates 'python foo.py' at the cmd line, we must
1571 # set the __file__ global in the script's namespace
1571 # set the __file__ global in the script's namespace
1572 prog_ns['__file__'] = filename
1572 prog_ns['__file__'] = filename
1573
1573
1574 # pickle fix. See iplib for an explanation. But we need to make sure
1574 # pickle fix. See iplib for an explanation. But we need to make sure
1575 # that, if we overwrite __main__, we replace it at the end
1575 # that, if we overwrite __main__, we replace it at the end
1576 if prog_ns['__name__'] == '__main__':
1576 if prog_ns['__name__'] == '__main__':
1577 restore_main = sys.modules['__main__']
1577 restore_main = sys.modules['__main__']
1578 else:
1578 else:
1579 restore_main = False
1579 restore_main = False
1580
1580
1581 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1581 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1582
1582
1583 stats = None
1583 stats = None
1584 try:
1584 try:
1585 if self.shell.has_readline:
1585 if self.shell.has_readline:
1586 self.shell.savehist()
1586 self.shell.savehist()
1587
1587
1588 if opts.has_key('p'):
1588 if opts.has_key('p'):
1589 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1589 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1590 else:
1590 else:
1591 if opts.has_key('d'):
1591 if opts.has_key('d'):
1592 deb = Debugger.Pdb(self.shell.rc.colors)
1592 deb = Debugger.Pdb(self.shell.rc.colors)
1593 # reset Breakpoint state, which is moronically kept
1593 # reset Breakpoint state, which is moronically kept
1594 # in a class
1594 # in a class
1595 bdb.Breakpoint.next = 1
1595 bdb.Breakpoint.next = 1
1596 bdb.Breakpoint.bplist = {}
1596 bdb.Breakpoint.bplist = {}
1597 bdb.Breakpoint.bpbynumber = [None]
1597 bdb.Breakpoint.bpbynumber = [None]
1598 # Set an initial breakpoint to stop execution
1598 # Set an initial breakpoint to stop execution
1599 maxtries = 10
1599 maxtries = 10
1600 bp = int(opts.get('b',[1])[0])
1600 bp = int(opts.get('b',[1])[0])
1601 checkline = deb.checkline(filename,bp)
1601 checkline = deb.checkline(filename,bp)
1602 if not checkline:
1602 if not checkline:
1603 for bp in range(bp+1,bp+maxtries+1):
1603 for bp in range(bp+1,bp+maxtries+1):
1604 if deb.checkline(filename,bp):
1604 if deb.checkline(filename,bp):
1605 break
1605 break
1606 else:
1606 else:
1607 msg = ("\nI failed to find a valid line to set "
1607 msg = ("\nI failed to find a valid line to set "
1608 "a breakpoint\n"
1608 "a breakpoint\n"
1609 "after trying up to line: %s.\n"
1609 "after trying up to line: %s.\n"
1610 "Please set a valid breakpoint manually "
1610 "Please set a valid breakpoint manually "
1611 "with the -b option." % bp)
1611 "with the -b option." % bp)
1612 error(msg)
1612 error(msg)
1613 return
1613 return
1614 # if we find a good linenumber, set the breakpoint
1614 # if we find a good linenumber, set the breakpoint
1615 deb.do_break('%s:%s' % (filename,bp))
1615 deb.do_break('%s:%s' % (filename,bp))
1616 # Start file run
1616 # Start file run
1617 print "NOTE: Enter 'c' at the",
1617 print "NOTE: Enter 'c' at the",
1618 print "%s prompt to start your script." % deb.prompt
1618 print "%s prompt to start your script." % deb.prompt
1619 try:
1619 try:
1620 deb.run('execfile("%s")' % filename,prog_ns)
1620 deb.run('execfile("%s")' % filename,prog_ns)
1621
1621
1622 except:
1622 except:
1623 etype, value, tb = sys.exc_info()
1623 etype, value, tb = sys.exc_info()
1624 # Skip three frames in the traceback: the %run one,
1624 # Skip three frames in the traceback: the %run one,
1625 # one inside bdb.py, and the command-line typed by the
1625 # one inside bdb.py, and the command-line typed by the
1626 # user (run by exec in pdb itself).
1626 # user (run by exec in pdb itself).
1627 self.shell.InteractiveTB(etype,value,tb,tb_offset=3)
1627 self.shell.InteractiveTB(etype,value,tb,tb_offset=3)
1628 else:
1628 else:
1629 if runner is None:
1629 if runner is None:
1630 runner = self.shell.safe_execfile
1630 runner = self.shell.safe_execfile
1631 if opts.has_key('t'):
1631 if opts.has_key('t'):
1632 try:
1632 try:
1633 nruns = int(opts['N'][0])
1633 nruns = int(opts['N'][0])
1634 if nruns < 1:
1634 if nruns < 1:
1635 error('Number of runs must be >=1')
1635 error('Number of runs must be >=1')
1636 return
1636 return
1637 except (KeyError):
1637 except (KeyError):
1638 nruns = 1
1638 nruns = 1
1639 if nruns == 1:
1639 if nruns == 1:
1640 t0 = clock2()
1640 t0 = clock2()
1641 runner(filename,prog_ns,prog_ns,
1641 runner(filename,prog_ns,prog_ns,
1642 exit_ignore=exit_ignore)
1642 exit_ignore=exit_ignore)
1643 t1 = clock2()
1643 t1 = clock2()
1644 t_usr = t1[0]-t0[0]
1644 t_usr = t1[0]-t0[0]
1645 t_sys = t1[1]-t1[1]
1645 t_sys = t1[1]-t1[1]
1646 print "\nIPython CPU timings (estimated):"
1646 print "\nIPython CPU timings (estimated):"
1647 print " User : %10s s." % t_usr
1647 print " User : %10s s." % t_usr
1648 print " System: %10s s." % t_sys
1648 print " System: %10s s." % t_sys
1649 else:
1649 else:
1650 runs = range(nruns)
1650 runs = range(nruns)
1651 t0 = clock2()
1651 t0 = clock2()
1652 for nr in runs:
1652 for nr in runs:
1653 runner(filename,prog_ns,prog_ns,
1653 runner(filename,prog_ns,prog_ns,
1654 exit_ignore=exit_ignore)
1654 exit_ignore=exit_ignore)
1655 t1 = clock2()
1655 t1 = clock2()
1656 t_usr = t1[0]-t0[0]
1656 t_usr = t1[0]-t0[0]
1657 t_sys = t1[1]-t1[1]
1657 t_sys = t1[1]-t1[1]
1658 print "\nIPython CPU timings (estimated):"
1658 print "\nIPython CPU timings (estimated):"
1659 print "Total runs performed:",nruns
1659 print "Total runs performed:",nruns
1660 print " Times : %10s %10s" % ('Total','Per run')
1660 print " Times : %10s %10s" % ('Total','Per run')
1661 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1661 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1662 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1662 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1663
1663
1664 else:
1664 else:
1665 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1665 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1666 if opts.has_key('i'):
1666 if opts.has_key('i'):
1667 self.shell.user_ns['__name__'] = __name__save
1667 self.shell.user_ns['__name__'] = __name__save
1668 else:
1668 else:
1669 # update IPython interactive namespace
1669 # update IPython interactive namespace
1670 del prog_ns['__name__']
1670 del prog_ns['__name__']
1671 self.shell.user_ns.update(prog_ns)
1671 self.shell.user_ns.update(prog_ns)
1672 finally:
1672 finally:
1673 sys.argv = save_argv
1673 sys.argv = save_argv
1674 if restore_main:
1674 if restore_main:
1675 sys.modules['__main__'] = restore_main
1675 sys.modules['__main__'] = restore_main
1676 if self.shell.has_readline:
1676 self.shell.reloadhist()
1677 self.shell.readline.read_history_file(self.shell.histfile)
1678
1677
1679 return stats
1678 return stats
1680
1679
1681 def magic_runlog(self, parameter_s =''):
1680 def magic_runlog(self, parameter_s =''):
1682 """Run files as logs.
1681 """Run files as logs.
1683
1682
1684 Usage:\\
1683 Usage:\\
1685 %runlog file1 file2 ...
1684 %runlog file1 file2 ...
1686
1685
1687 Run the named files (treating them as log files) in sequence inside
1686 Run the named files (treating them as log files) in sequence inside
1688 the interpreter, and return to the prompt. This is much slower than
1687 the interpreter, and return to the prompt. This is much slower than
1689 %run because each line is executed in a try/except block, but it
1688 %run because each line is executed in a try/except block, but it
1690 allows running files with syntax errors in them.
1689 allows running files with syntax errors in them.
1691
1690
1692 Normally IPython will guess when a file is one of its own logfiles, so
1691 Normally IPython will guess when a file is one of its own logfiles, so
1693 you can typically use %run even for logs. This shorthand allows you to
1692 you can typically use %run even for logs. This shorthand allows you to
1694 force any file to be treated as a log file."""
1693 force any file to be treated as a log file."""
1695
1694
1696 for f in parameter_s.split():
1695 for f in parameter_s.split():
1697 self.shell.safe_execfile(f,self.shell.user_ns,
1696 self.shell.safe_execfile(f,self.shell.user_ns,
1698 self.shell.user_ns,islog=1)
1697 self.shell.user_ns,islog=1)
1699
1698
1700 def magic_timeit(self, parameter_s =''):
1699 def magic_timeit(self, parameter_s =''):
1701 """Time execution of a Python statement or expression
1700 """Time execution of a Python statement or expression
1702
1701
1703 Usage:\\
1702 Usage:\\
1704 %timeit [-n<N> -r<R> [-t|-c]] statement
1703 %timeit [-n<N> -r<R> [-t|-c]] statement
1705
1704
1706 Time execution of a Python statement or expression using the timeit
1705 Time execution of a Python statement or expression using the timeit
1707 module.
1706 module.
1708
1707
1709 Options:
1708 Options:
1710 -n<N>: execute the given statement <N> times in a loop. If this value
1709 -n<N>: execute the given statement <N> times in a loop. If this value
1711 is not given, a fitting value is chosen.
1710 is not given, a fitting value is chosen.
1712
1711
1713 -r<R>: repeat the loop iteration <R> times and take the best result.
1712 -r<R>: repeat the loop iteration <R> times and take the best result.
1714 Default: 3
1713 Default: 3
1715
1714
1716 -t: use time.time to measure the time, which is the default on Unix.
1715 -t: use time.time to measure the time, which is the default on Unix.
1717 This function measures wall time.
1716 This function measures wall time.
1718
1717
1719 -c: use time.clock to measure the time, which is the default on
1718 -c: use time.clock to measure the time, which is the default on
1720 Windows and measures wall time. On Unix, resource.getrusage is used
1719 Windows and measures wall time. On Unix, resource.getrusage is used
1721 instead and returns the CPU user time.
1720 instead and returns the CPU user time.
1722
1721
1723 -p<P>: use a precision of <P> digits to display the timing result.
1722 -p<P>: use a precision of <P> digits to display the timing result.
1724 Default: 3
1723 Default: 3
1725
1724
1726
1725
1727 Examples:\\
1726 Examples:\\
1728 In [1]: %timeit pass
1727 In [1]: %timeit pass
1729 10000000 loops, best of 3: 53.3 ns per loop
1728 10000000 loops, best of 3: 53.3 ns per loop
1730
1729
1731 In [2]: u = None
1730 In [2]: u = None
1732
1731
1733 In [3]: %timeit u is None
1732 In [3]: %timeit u is None
1734 10000000 loops, best of 3: 184 ns per loop
1733 10000000 loops, best of 3: 184 ns per loop
1735
1734
1736 In [4]: %timeit -r 4 u == None
1735 In [4]: %timeit -r 4 u == None
1737 1000000 loops, best of 4: 242 ns per loop
1736 1000000 loops, best of 4: 242 ns per loop
1738
1737
1739 In [5]: import time
1738 In [5]: import time
1740
1739
1741 In [6]: %timeit -n1 time.sleep(2)
1740 In [6]: %timeit -n1 time.sleep(2)
1742 1 loops, best of 3: 2 s per loop
1741 1 loops, best of 3: 2 s per loop
1743
1742
1744
1743
1745 The times reported by %timeit will be slightly higher than those
1744 The times reported by %timeit will be slightly higher than those
1746 reported by the timeit.py script when variables are accessed. This is
1745 reported by the timeit.py script when variables are accessed. This is
1747 due to the fact that %timeit executes the statement in the namespace
1746 due to the fact that %timeit executes the statement in the namespace
1748 of the shell, compared with timeit.py, which uses a single setup
1747 of the shell, compared with timeit.py, which uses a single setup
1749 statement to import function or create variables. Generally, the bias
1748 statement to import function or create variables. Generally, the bias
1750 does not matter as long as results from timeit.py are not mixed with
1749 does not matter as long as results from timeit.py are not mixed with
1751 those from %timeit."""
1750 those from %timeit."""
1752
1751
1753 import timeit
1752 import timeit
1754 import math
1753 import math
1755
1754
1756 units = ["s", "ms", "\xc2\xb5s", "ns"]
1755 units = ["s", "ms", "\xc2\xb5s", "ns"]
1757 scaling = [1, 1e3, 1e6, 1e9]
1756 scaling = [1, 1e3, 1e6, 1e9]
1758
1757
1759 opts, stmt = self.parse_options(parameter_s,'n:r:tcp:',
1758 opts, stmt = self.parse_options(parameter_s,'n:r:tcp:',
1760 posix=False)
1759 posix=False)
1761 if stmt == "":
1760 if stmt == "":
1762 return
1761 return
1763 timefunc = timeit.default_timer
1762 timefunc = timeit.default_timer
1764 number = int(getattr(opts, "n", 0))
1763 number = int(getattr(opts, "n", 0))
1765 repeat = int(getattr(opts, "r", timeit.default_repeat))
1764 repeat = int(getattr(opts, "r", timeit.default_repeat))
1766 precision = int(getattr(opts, "p", 3))
1765 precision = int(getattr(opts, "p", 3))
1767 if hasattr(opts, "t"):
1766 if hasattr(opts, "t"):
1768 timefunc = time.time
1767 timefunc = time.time
1769 if hasattr(opts, "c"):
1768 if hasattr(opts, "c"):
1770 timefunc = clock
1769 timefunc = clock
1771
1770
1772 timer = timeit.Timer(timer=timefunc)
1771 timer = timeit.Timer(timer=timefunc)
1773 # this code has tight coupling to the inner workings of timeit.Timer,
1772 # this code has tight coupling to the inner workings of timeit.Timer,
1774 # but is there a better way to achieve that the code stmt has access
1773 # but is there a better way to achieve that the code stmt has access
1775 # to the shell namespace?
1774 # to the shell namespace?
1776
1775
1777 src = timeit.template % {'stmt': timeit.reindent(stmt, 8),
1776 src = timeit.template % {'stmt': timeit.reindent(stmt, 8),
1778 'setup': "pass"}
1777 'setup': "pass"}
1779 code = compile(src, "<magic-timeit>", "exec")
1778 code = compile(src, "<magic-timeit>", "exec")
1780 ns = {}
1779 ns = {}
1781 exec code in self.shell.user_ns, ns
1780 exec code in self.shell.user_ns, ns
1782 timer.inner = ns["inner"]
1781 timer.inner = ns["inner"]
1783
1782
1784 if number == 0:
1783 if number == 0:
1785 # determine number so that 0.2 <= total time < 2.0
1784 # determine number so that 0.2 <= total time < 2.0
1786 number = 1
1785 number = 1
1787 for i in range(1, 10):
1786 for i in range(1, 10):
1788 number *= 10
1787 number *= 10
1789 if timer.timeit(number) >= 0.2:
1788 if timer.timeit(number) >= 0.2:
1790 break
1789 break
1791
1790
1792 best = min(timer.repeat(repeat, number)) / number
1791 best = min(timer.repeat(repeat, number)) / number
1793
1792
1794 if best > 0.0:
1793 if best > 0.0:
1795 order = min(-int(math.floor(math.log10(best)) // 3), 3)
1794 order = min(-int(math.floor(math.log10(best)) // 3), 3)
1796 else:
1795 else:
1797 order = 3
1796 order = 3
1798 print "%d loops, best of %d: %.*g %s per loop" % (number, repeat,
1797 print "%d loops, best of %d: %.*g %s per loop" % (number, repeat,
1799 precision,
1798 precision,
1800 best * scaling[order],
1799 best * scaling[order],
1801 units[order])
1800 units[order])
1802
1801
1803 def magic_time(self,parameter_s = ''):
1802 def magic_time(self,parameter_s = ''):
1804 """Time execution of a Python statement or expression.
1803 """Time execution of a Python statement or expression.
1805
1804
1806 The CPU and wall clock times are printed, and the value of the
1805 The CPU and wall clock times are printed, and the value of the
1807 expression (if any) is returned. Note that under Win32, system time
1806 expression (if any) is returned. Note that under Win32, system time
1808 is always reported as 0, since it can not be measured.
1807 is always reported as 0, since it can not be measured.
1809
1808
1810 This function provides very basic timing functionality. In Python
1809 This function provides very basic timing functionality. In Python
1811 2.3, the timeit module offers more control and sophistication, so this
1810 2.3, the timeit module offers more control and sophistication, so this
1812 could be rewritten to use it (patches welcome).
1811 could be rewritten to use it (patches welcome).
1813
1812
1814 Some examples:
1813 Some examples:
1815
1814
1816 In [1]: time 2**128
1815 In [1]: time 2**128
1817 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1816 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1818 Wall time: 0.00
1817 Wall time: 0.00
1819 Out[1]: 340282366920938463463374607431768211456L
1818 Out[1]: 340282366920938463463374607431768211456L
1820
1819
1821 In [2]: n = 1000000
1820 In [2]: n = 1000000
1822
1821
1823 In [3]: time sum(range(n))
1822 In [3]: time sum(range(n))
1824 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1823 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1825 Wall time: 1.37
1824 Wall time: 1.37
1826 Out[3]: 499999500000L
1825 Out[3]: 499999500000L
1827
1826
1828 In [4]: time print 'hello world'
1827 In [4]: time print 'hello world'
1829 hello world
1828 hello world
1830 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1829 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1831 Wall time: 0.00
1830 Wall time: 0.00
1832 """
1831 """
1833
1832
1834 # fail immediately if the given expression can't be compiled
1833 # fail immediately if the given expression can't be compiled
1835 try:
1834 try:
1836 mode = 'eval'
1835 mode = 'eval'
1837 code = compile(parameter_s,'<timed eval>',mode)
1836 code = compile(parameter_s,'<timed eval>',mode)
1838 except SyntaxError:
1837 except SyntaxError:
1839 mode = 'exec'
1838 mode = 'exec'
1840 code = compile(parameter_s,'<timed exec>',mode)
1839 code = compile(parameter_s,'<timed exec>',mode)
1841 # skew measurement as little as possible
1840 # skew measurement as little as possible
1842 glob = self.shell.user_ns
1841 glob = self.shell.user_ns
1843 clk = clock2
1842 clk = clock2
1844 wtime = time.time
1843 wtime = time.time
1845 # time execution
1844 # time execution
1846 wall_st = wtime()
1845 wall_st = wtime()
1847 if mode=='eval':
1846 if mode=='eval':
1848 st = clk()
1847 st = clk()
1849 out = eval(code,glob)
1848 out = eval(code,glob)
1850 end = clk()
1849 end = clk()
1851 else:
1850 else:
1852 st = clk()
1851 st = clk()
1853 exec code in glob
1852 exec code in glob
1854 end = clk()
1853 end = clk()
1855 out = None
1854 out = None
1856 wall_end = wtime()
1855 wall_end = wtime()
1857 # Compute actual times and report
1856 # Compute actual times and report
1858 wall_time = wall_end-wall_st
1857 wall_time = wall_end-wall_st
1859 cpu_user = end[0]-st[0]
1858 cpu_user = end[0]-st[0]
1860 cpu_sys = end[1]-st[1]
1859 cpu_sys = end[1]-st[1]
1861 cpu_tot = cpu_user+cpu_sys
1860 cpu_tot = cpu_user+cpu_sys
1862 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1861 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1863 (cpu_user,cpu_sys,cpu_tot)
1862 (cpu_user,cpu_sys,cpu_tot)
1864 print "Wall time: %.2f" % wall_time
1863 print "Wall time: %.2f" % wall_time
1865 return out
1864 return out
1866
1865
1867 def magic_macro(self,parameter_s = ''):
1866 def magic_macro(self,parameter_s = ''):
1868 """Define a set of input lines as a macro for future re-execution.
1867 """Define a set of input lines as a macro for future re-execution.
1869
1868
1870 Usage:\\
1869 Usage:\\
1871 %macro [options] name n1-n2 n3-n4 ... n5 .. n6 ...
1870 %macro [options] name n1-n2 n3-n4 ... n5 .. n6 ...
1872
1871
1873 Options:
1872 Options:
1874
1873
1875 -r: use 'raw' input. By default, the 'processed' history is used,
1874 -r: use 'raw' input. By default, the 'processed' history is used,
1876 so that magics are loaded in their transformed version to valid
1875 so that magics are loaded in their transformed version to valid
1877 Python. If this option is given, the raw input as typed as the
1876 Python. If this option is given, the raw input as typed as the
1878 command line is used instead.
1877 command line is used instead.
1879
1878
1880 This will define a global variable called `name` which is a string
1879 This will define a global variable called `name` which is a string
1881 made of joining the slices and lines you specify (n1,n2,... numbers
1880 made of joining the slices and lines you specify (n1,n2,... numbers
1882 above) from your input history into a single string. This variable
1881 above) from your input history into a single string. This variable
1883 acts like an automatic function which re-executes those lines as if
1882 acts like an automatic function which re-executes those lines as if
1884 you had typed them. You just type 'name' at the prompt and the code
1883 you had typed them. You just type 'name' at the prompt and the code
1885 executes.
1884 executes.
1886
1885
1887 The notation for indicating number ranges is: n1-n2 means 'use line
1886 The notation for indicating number ranges is: n1-n2 means 'use line
1888 numbers n1,...n2' (the endpoint is included). That is, '5-7' means
1887 numbers n1,...n2' (the endpoint is included). That is, '5-7' means
1889 using the lines numbered 5,6 and 7.
1888 using the lines numbered 5,6 and 7.
1890
1889
1891 Note: as a 'hidden' feature, you can also use traditional python slice
1890 Note: as a 'hidden' feature, you can also use traditional python slice
1892 notation, where N:M means numbers N through M-1.
1891 notation, where N:M means numbers N through M-1.
1893
1892
1894 For example, if your history contains (%hist prints it):
1893 For example, if your history contains (%hist prints it):
1895
1894
1896 44: x=1\\
1895 44: x=1\\
1897 45: y=3\\
1896 45: y=3\\
1898 46: z=x+y\\
1897 46: z=x+y\\
1899 47: print x\\
1898 47: print x\\
1900 48: a=5\\
1899 48: a=5\\
1901 49: print 'x',x,'y',y\\
1900 49: print 'x',x,'y',y\\
1902
1901
1903 you can create a macro with lines 44 through 47 (included) and line 49
1902 you can create a macro with lines 44 through 47 (included) and line 49
1904 called my_macro with:
1903 called my_macro with:
1905
1904
1906 In [51]: %macro my_macro 44-47 49
1905 In [51]: %macro my_macro 44-47 49
1907
1906
1908 Now, typing `my_macro` (without quotes) will re-execute all this code
1907 Now, typing `my_macro` (without quotes) will re-execute all this code
1909 in one pass.
1908 in one pass.
1910
1909
1911 You don't need to give the line-numbers in order, and any given line
1910 You don't need to give the line-numbers in order, and any given line
1912 number can appear multiple times. You can assemble macros with any
1911 number can appear multiple times. You can assemble macros with any
1913 lines from your input history in any order.
1912 lines from your input history in any order.
1914
1913
1915 The macro is a simple object which holds its value in an attribute,
1914 The macro is a simple object which holds its value in an attribute,
1916 but IPython's display system checks for macros and executes them as
1915 but IPython's display system checks for macros and executes them as
1917 code instead of printing them when you type their name.
1916 code instead of printing them when you type their name.
1918
1917
1919 You can view a macro's contents by explicitly printing it with:
1918 You can view a macro's contents by explicitly printing it with:
1920
1919
1921 'print macro_name'.
1920 'print macro_name'.
1922
1921
1923 For one-off cases which DON'T contain magic function calls in them you
1922 For one-off cases which DON'T contain magic function calls in them you
1924 can obtain similar results by explicitly executing slices from your
1923 can obtain similar results by explicitly executing slices from your
1925 input history with:
1924 input history with:
1926
1925
1927 In [60]: exec In[44:48]+In[49]"""
1926 In [60]: exec In[44:48]+In[49]"""
1928
1927
1929 opts,args = self.parse_options(parameter_s,'r',mode='list')
1928 opts,args = self.parse_options(parameter_s,'r',mode='list')
1930 name,ranges = args[0], args[1:]
1929 name,ranges = args[0], args[1:]
1931 #print 'rng',ranges # dbg
1930 #print 'rng',ranges # dbg
1932 lines = self.extract_input_slices(ranges,opts.has_key('r'))
1931 lines = self.extract_input_slices(ranges,opts.has_key('r'))
1933 macro = Macro(lines)
1932 macro = Macro(lines)
1934 self.shell.user_ns.update({name:macro})
1933 self.shell.user_ns.update({name:macro})
1935 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1934 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1936 print 'Macro contents:'
1935 print 'Macro contents:'
1937 print macro,
1936 print macro,
1938
1937
1939 def magic_save(self,parameter_s = ''):
1938 def magic_save(self,parameter_s = ''):
1940 """Save a set of lines to a given filename.
1939 """Save a set of lines to a given filename.
1941
1940
1942 Usage:\\
1941 Usage:\\
1943 %save [options] filename n1-n2 n3-n4 ... n5 .. n6 ...
1942 %save [options] filename n1-n2 n3-n4 ... n5 .. n6 ...
1944
1943
1945 Options:
1944 Options:
1946
1945
1947 -r: use 'raw' input. By default, the 'processed' history is used,
1946 -r: use 'raw' input. By default, the 'processed' history is used,
1948 so that magics are loaded in their transformed version to valid
1947 so that magics are loaded in their transformed version to valid
1949 Python. If this option is given, the raw input as typed as the
1948 Python. If this option is given, the raw input as typed as the
1950 command line is used instead.
1949 command line is used instead.
1951
1950
1952 This function uses the same syntax as %macro for line extraction, but
1951 This function uses the same syntax as %macro for line extraction, but
1953 instead of creating a macro it saves the resulting string to the
1952 instead of creating a macro it saves the resulting string to the
1954 filename you specify.
1953 filename you specify.
1955
1954
1956 It adds a '.py' extension to the file if you don't do so yourself, and
1955 It adds a '.py' extension to the file if you don't do so yourself, and
1957 it asks for confirmation before overwriting existing files."""
1956 it asks for confirmation before overwriting existing files."""
1958
1957
1959 opts,args = self.parse_options(parameter_s,'r',mode='list')
1958 opts,args = self.parse_options(parameter_s,'r',mode='list')
1960 fname,ranges = args[0], args[1:]
1959 fname,ranges = args[0], args[1:]
1961 if not fname.endswith('.py'):
1960 if not fname.endswith('.py'):
1962 fname += '.py'
1961 fname += '.py'
1963 if os.path.isfile(fname):
1962 if os.path.isfile(fname):
1964 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1963 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1965 if ans.lower() not in ['y','yes']:
1964 if ans.lower() not in ['y','yes']:
1966 print 'Operation cancelled.'
1965 print 'Operation cancelled.'
1967 return
1966 return
1968 cmds = ''.join(self.extract_input_slices(ranges,opts.has_key('r')))
1967 cmds = ''.join(self.extract_input_slices(ranges,opts.has_key('r')))
1969 f = file(fname,'w')
1968 f = file(fname,'w')
1970 f.write(cmds)
1969 f.write(cmds)
1971 f.close()
1970 f.close()
1972 print 'The following commands were written to file `%s`:' % fname
1971 print 'The following commands were written to file `%s`:' % fname
1973 print cmds
1972 print cmds
1974
1973
1975 def _edit_macro(self,mname,macro):
1974 def _edit_macro(self,mname,macro):
1976 """open an editor with the macro data in a file"""
1975 """open an editor with the macro data in a file"""
1977 filename = self.shell.mktempfile(macro.value)
1976 filename = self.shell.mktempfile(macro.value)
1978 self.shell.hooks.editor(filename)
1977 self.shell.hooks.editor(filename)
1979
1978
1980 # and make a new macro object, to replace the old one
1979 # and make a new macro object, to replace the old one
1981 mfile = open(filename)
1980 mfile = open(filename)
1982 mvalue = mfile.read()
1981 mvalue = mfile.read()
1983 mfile.close()
1982 mfile.close()
1984 self.shell.user_ns[mname] = Macro(mvalue)
1983 self.shell.user_ns[mname] = Macro(mvalue)
1985
1984
1986 def magic_ed(self,parameter_s=''):
1985 def magic_ed(self,parameter_s=''):
1987 """Alias to %edit."""
1986 """Alias to %edit."""
1988 return self.magic_edit(parameter_s)
1987 return self.magic_edit(parameter_s)
1989
1988
1990 def magic_edit(self,parameter_s='',last_call=['','']):
1989 def magic_edit(self,parameter_s='',last_call=['','']):
1991 """Bring up an editor and execute the resulting code.
1990 """Bring up an editor and execute the resulting code.
1992
1991
1993 Usage:
1992 Usage:
1994 %edit [options] [args]
1993 %edit [options] [args]
1995
1994
1996 %edit runs IPython's editor hook. The default version of this hook is
1995 %edit runs IPython's editor hook. The default version of this hook is
1997 set to call the __IPYTHON__.rc.editor command. This is read from your
1996 set to call the __IPYTHON__.rc.editor command. This is read from your
1998 environment variable $EDITOR. If this isn't found, it will default to
1997 environment variable $EDITOR. If this isn't found, it will default to
1999 vi under Linux/Unix and to notepad under Windows. See the end of this
1998 vi under Linux/Unix and to notepad under Windows. See the end of this
2000 docstring for how to change the editor hook.
1999 docstring for how to change the editor hook.
2001
2000
2002 You can also set the value of this editor via the command line option
2001 You can also set the value of this editor via the command line option
2003 '-editor' or in your ipythonrc file. This is useful if you wish to use
2002 '-editor' or in your ipythonrc file. This is useful if you wish to use
2004 specifically for IPython an editor different from your typical default
2003 specifically for IPython an editor different from your typical default
2005 (and for Windows users who typically don't set environment variables).
2004 (and for Windows users who typically don't set environment variables).
2006
2005
2007 This command allows you to conveniently edit multi-line code right in
2006 This command allows you to conveniently edit multi-line code right in
2008 your IPython session.
2007 your IPython session.
2009
2008
2010 If called without arguments, %edit opens up an empty editor with a
2009 If called without arguments, %edit opens up an empty editor with a
2011 temporary file and will execute the contents of this file when you
2010 temporary file and will execute the contents of this file when you
2012 close it (don't forget to save it!).
2011 close it (don't forget to save it!).
2013
2012
2014
2013
2015 Options:
2014 Options:
2016
2015
2017 -n <number>: open the editor at a specified line number. By default,
2016 -n <number>: open the editor at a specified line number. By default,
2018 the IPython editor hook uses the unix syntax 'editor +N filename', but
2017 the IPython editor hook uses the unix syntax 'editor +N filename', but
2019 you can configure this by providing your own modified hook if your
2018 you can configure this by providing your own modified hook if your
2020 favorite editor supports line-number specifications with a different
2019 favorite editor supports line-number specifications with a different
2021 syntax.
2020 syntax.
2022
2021
2023 -p: this will call the editor with the same data as the previous time
2022 -p: this will call the editor with the same data as the previous time
2024 it was used, regardless of how long ago (in your current session) it
2023 it was used, regardless of how long ago (in your current session) it
2025 was.
2024 was.
2026
2025
2027 -r: use 'raw' input. This option only applies to input taken from the
2026 -r: use 'raw' input. This option only applies to input taken from the
2028 user's history. By default, the 'processed' history is used, so that
2027 user's history. By default, the 'processed' history is used, so that
2029 magics are loaded in their transformed version to valid Python. If
2028 magics are loaded in their transformed version to valid Python. If
2030 this option is given, the raw input as typed as the command line is
2029 this option is given, the raw input as typed as the command line is
2031 used instead. When you exit the editor, it will be executed by
2030 used instead. When you exit the editor, it will be executed by
2032 IPython's own processor.
2031 IPython's own processor.
2033
2032
2034 -x: do not execute the edited code immediately upon exit. This is
2033 -x: do not execute the edited code immediately upon exit. This is
2035 mainly useful if you are editing programs which need to be called with
2034 mainly useful if you are editing programs which need to be called with
2036 command line arguments, which you can then do using %run.
2035 command line arguments, which you can then do using %run.
2037
2036
2038
2037
2039 Arguments:
2038 Arguments:
2040
2039
2041 If arguments are given, the following possibilites exist:
2040 If arguments are given, the following possibilites exist:
2042
2041
2043 - The arguments are numbers or pairs of colon-separated numbers (like
2042 - The arguments are numbers or pairs of colon-separated numbers (like
2044 1 4:8 9). These are interpreted as lines of previous input to be
2043 1 4:8 9). These are interpreted as lines of previous input to be
2045 loaded into the editor. The syntax is the same of the %macro command.
2044 loaded into the editor. The syntax is the same of the %macro command.
2046
2045
2047 - If the argument doesn't start with a number, it is evaluated as a
2046 - If the argument doesn't start with a number, it is evaluated as a
2048 variable and its contents loaded into the editor. You can thus edit
2047 variable and its contents loaded into the editor. You can thus edit
2049 any string which contains python code (including the result of
2048 any string which contains python code (including the result of
2050 previous edits).
2049 previous edits).
2051
2050
2052 - If the argument is the name of an object (other than a string),
2051 - If the argument is the name of an object (other than a string),
2053 IPython will try to locate the file where it was defined and open the
2052 IPython will try to locate the file where it was defined and open the
2054 editor at the point where it is defined. You can use `%edit function`
2053 editor at the point where it is defined. You can use `%edit function`
2055 to load an editor exactly at the point where 'function' is defined,
2054 to load an editor exactly at the point where 'function' is defined,
2056 edit it and have the file be executed automatically.
2055 edit it and have the file be executed automatically.
2057
2056
2058 If the object is a macro (see %macro for details), this opens up your
2057 If the object is a macro (see %macro for details), this opens up your
2059 specified editor with a temporary file containing the macro's data.
2058 specified editor with a temporary file containing the macro's data.
2060 Upon exit, the macro is reloaded with the contents of the file.
2059 Upon exit, the macro is reloaded with the contents of the file.
2061
2060
2062 Note: opening at an exact line is only supported under Unix, and some
2061 Note: opening at an exact line is only supported under Unix, and some
2063 editors (like kedit and gedit up to Gnome 2.8) do not understand the
2062 editors (like kedit and gedit up to Gnome 2.8) do not understand the
2064 '+NUMBER' parameter necessary for this feature. Good editors like
2063 '+NUMBER' parameter necessary for this feature. Good editors like
2065 (X)Emacs, vi, jed, pico and joe all do.
2064 (X)Emacs, vi, jed, pico and joe all do.
2066
2065
2067 - If the argument is not found as a variable, IPython will look for a
2066 - If the argument is not found as a variable, IPython will look for a
2068 file with that name (adding .py if necessary) and load it into the
2067 file with that name (adding .py if necessary) and load it into the
2069 editor. It will execute its contents with execfile() when you exit,
2068 editor. It will execute its contents with execfile() when you exit,
2070 loading any code in the file into your interactive namespace.
2069 loading any code in the file into your interactive namespace.
2071
2070
2072 After executing your code, %edit will return as output the code you
2071 After executing your code, %edit will return as output the code you
2073 typed in the editor (except when it was an existing file). This way
2072 typed in the editor (except when it was an existing file). This way
2074 you can reload the code in further invocations of %edit as a variable,
2073 you can reload the code in further invocations of %edit as a variable,
2075 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
2074 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
2076 the output.
2075 the output.
2077
2076
2078 Note that %edit is also available through the alias %ed.
2077 Note that %edit is also available through the alias %ed.
2079
2078
2080 This is an example of creating a simple function inside the editor and
2079 This is an example of creating a simple function inside the editor and
2081 then modifying it. First, start up the editor:
2080 then modifying it. First, start up the editor:
2082
2081
2083 In [1]: ed\\
2082 In [1]: ed\\
2084 Editing... done. Executing edited code...\\
2083 Editing... done. Executing edited code...\\
2085 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
2084 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
2086
2085
2087 We can then call the function foo():
2086 We can then call the function foo():
2088
2087
2089 In [2]: foo()\\
2088 In [2]: foo()\\
2090 foo() was defined in an editing session
2089 foo() was defined in an editing session
2091
2090
2092 Now we edit foo. IPython automatically loads the editor with the
2091 Now we edit foo. IPython automatically loads the editor with the
2093 (temporary) file where foo() was previously defined:
2092 (temporary) file where foo() was previously defined:
2094
2093
2095 In [3]: ed foo\\
2094 In [3]: ed foo\\
2096 Editing... done. Executing edited code...
2095 Editing... done. Executing edited code...
2097
2096
2098 And if we call foo() again we get the modified version:
2097 And if we call foo() again we get the modified version:
2099
2098
2100 In [4]: foo()\\
2099 In [4]: foo()\\
2101 foo() has now been changed!
2100 foo() has now been changed!
2102
2101
2103 Here is an example of how to edit a code snippet successive
2102 Here is an example of how to edit a code snippet successive
2104 times. First we call the editor:
2103 times. First we call the editor:
2105
2104
2106 In [8]: ed\\
2105 In [8]: ed\\
2107 Editing... done. Executing edited code...\\
2106 Editing... done. Executing edited code...\\
2108 hello\\
2107 hello\\
2109 Out[8]: "print 'hello'\\n"
2108 Out[8]: "print 'hello'\\n"
2110
2109
2111 Now we call it again with the previous output (stored in _):
2110 Now we call it again with the previous output (stored in _):
2112
2111
2113 In [9]: ed _\\
2112 In [9]: ed _\\
2114 Editing... done. Executing edited code...\\
2113 Editing... done. Executing edited code...\\
2115 hello world\\
2114 hello world\\
2116 Out[9]: "print 'hello world'\\n"
2115 Out[9]: "print 'hello world'\\n"
2117
2116
2118 Now we call it with the output #8 (stored in _8, also as Out[8]):
2117 Now we call it with the output #8 (stored in _8, also as Out[8]):
2119
2118
2120 In [10]: ed _8\\
2119 In [10]: ed _8\\
2121 Editing... done. Executing edited code...\\
2120 Editing... done. Executing edited code...\\
2122 hello again\\
2121 hello again\\
2123 Out[10]: "print 'hello again'\\n"
2122 Out[10]: "print 'hello again'\\n"
2124
2123
2125
2124
2126 Changing the default editor hook:
2125 Changing the default editor hook:
2127
2126
2128 If you wish to write your own editor hook, you can put it in a
2127 If you wish to write your own editor hook, you can put it in a
2129 configuration file which you load at startup time. The default hook
2128 configuration file which you load at startup time. The default hook
2130 is defined in the IPython.hooks module, and you can use that as a
2129 is defined in the IPython.hooks module, and you can use that as a
2131 starting example for further modifications. That file also has
2130 starting example for further modifications. That file also has
2132 general instructions on how to set a new hook for use once you've
2131 general instructions on how to set a new hook for use once you've
2133 defined it."""
2132 defined it."""
2134
2133
2135 # FIXME: This function has become a convoluted mess. It needs a
2134 # FIXME: This function has become a convoluted mess. It needs a
2136 # ground-up rewrite with clean, simple logic.
2135 # ground-up rewrite with clean, simple logic.
2137
2136
2138 def make_filename(arg):
2137 def make_filename(arg):
2139 "Make a filename from the given args"
2138 "Make a filename from the given args"
2140 try:
2139 try:
2141 filename = get_py_filename(arg)
2140 filename = get_py_filename(arg)
2142 except IOError:
2141 except IOError:
2143 if args.endswith('.py'):
2142 if args.endswith('.py'):
2144 filename = arg
2143 filename = arg
2145 else:
2144 else:
2146 filename = None
2145 filename = None
2147 return filename
2146 return filename
2148
2147
2149 # custom exceptions
2148 # custom exceptions
2150 class DataIsObject(Exception): pass
2149 class DataIsObject(Exception): pass
2151
2150
2152 opts,args = self.parse_options(parameter_s,'prxn:')
2151 opts,args = self.parse_options(parameter_s,'prxn:')
2153 # Set a few locals from the options for convenience:
2152 # Set a few locals from the options for convenience:
2154 opts_p = opts.has_key('p')
2153 opts_p = opts.has_key('p')
2155 opts_r = opts.has_key('r')
2154 opts_r = opts.has_key('r')
2156
2155
2157 # Default line number value
2156 # Default line number value
2158 lineno = opts.get('n',None)
2157 lineno = opts.get('n',None)
2159
2158
2160 if opts_p:
2159 if opts_p:
2161 args = '_%s' % last_call[0]
2160 args = '_%s' % last_call[0]
2162 if not self.shell.user_ns.has_key(args):
2161 if not self.shell.user_ns.has_key(args):
2163 args = last_call[1]
2162 args = last_call[1]
2164
2163
2165 # use last_call to remember the state of the previous call, but don't
2164 # use last_call to remember the state of the previous call, but don't
2166 # let it be clobbered by successive '-p' calls.
2165 # let it be clobbered by successive '-p' calls.
2167 try:
2166 try:
2168 last_call[0] = self.shell.outputcache.prompt_count
2167 last_call[0] = self.shell.outputcache.prompt_count
2169 if not opts_p:
2168 if not opts_p:
2170 last_call[1] = parameter_s
2169 last_call[1] = parameter_s
2171 except:
2170 except:
2172 pass
2171 pass
2173
2172
2174 # by default this is done with temp files, except when the given
2173 # by default this is done with temp files, except when the given
2175 # arg is a filename
2174 # arg is a filename
2176 use_temp = 1
2175 use_temp = 1
2177
2176
2178 if re.match(r'\d',args):
2177 if re.match(r'\d',args):
2179 # Mode where user specifies ranges of lines, like in %macro.
2178 # Mode where user specifies ranges of lines, like in %macro.
2180 # This means that you can't edit files whose names begin with
2179 # This means that you can't edit files whose names begin with
2181 # numbers this way. Tough.
2180 # numbers this way. Tough.
2182 ranges = args.split()
2181 ranges = args.split()
2183 data = ''.join(self.extract_input_slices(ranges,opts_r))
2182 data = ''.join(self.extract_input_slices(ranges,opts_r))
2184 elif args.endswith('.py'):
2183 elif args.endswith('.py'):
2185 filename = make_filename(args)
2184 filename = make_filename(args)
2186 data = ''
2185 data = ''
2187 use_temp = 0
2186 use_temp = 0
2188 elif args:
2187 elif args:
2189 try:
2188 try:
2190 # Load the parameter given as a variable. If not a string,
2189 # Load the parameter given as a variable. If not a string,
2191 # process it as an object instead (below)
2190 # process it as an object instead (below)
2192
2191
2193 #print '*** args',args,'type',type(args) # dbg
2192 #print '*** args',args,'type',type(args) # dbg
2194 data = eval(args,self.shell.user_ns)
2193 data = eval(args,self.shell.user_ns)
2195 if not type(data) in StringTypes:
2194 if not type(data) in StringTypes:
2196 raise DataIsObject
2195 raise DataIsObject
2197
2196
2198 except (NameError,SyntaxError):
2197 except (NameError,SyntaxError):
2199 # given argument is not a variable, try as a filename
2198 # given argument is not a variable, try as a filename
2200 filename = make_filename(args)
2199 filename = make_filename(args)
2201 if filename is None:
2200 if filename is None:
2202 warn("Argument given (%s) can't be found as a variable "
2201 warn("Argument given (%s) can't be found as a variable "
2203 "or as a filename." % args)
2202 "or as a filename." % args)
2204 return
2203 return
2205
2204
2206 data = ''
2205 data = ''
2207 use_temp = 0
2206 use_temp = 0
2208 except DataIsObject:
2207 except DataIsObject:
2209
2208
2210 # macros have a special edit function
2209 # macros have a special edit function
2211 if isinstance(data,Macro):
2210 if isinstance(data,Macro):
2212 self._edit_macro(args,data)
2211 self._edit_macro(args,data)
2213 return
2212 return
2214
2213
2215 # For objects, try to edit the file where they are defined
2214 # For objects, try to edit the file where they are defined
2216 try:
2215 try:
2217 filename = inspect.getabsfile(data)
2216 filename = inspect.getabsfile(data)
2218 datafile = 1
2217 datafile = 1
2219 except TypeError:
2218 except TypeError:
2220 filename = make_filename(args)
2219 filename = make_filename(args)
2221 datafile = 1
2220 datafile = 1
2222 warn('Could not find file where `%s` is defined.\n'
2221 warn('Could not find file where `%s` is defined.\n'
2223 'Opening a file named `%s`' % (args,filename))
2222 'Opening a file named `%s`' % (args,filename))
2224 # Now, make sure we can actually read the source (if it was in
2223 # Now, make sure we can actually read the source (if it was in
2225 # a temp file it's gone by now).
2224 # a temp file it's gone by now).
2226 if datafile:
2225 if datafile:
2227 try:
2226 try:
2228 if lineno is None:
2227 if lineno is None:
2229 lineno = inspect.getsourcelines(data)[1]
2228 lineno = inspect.getsourcelines(data)[1]
2230 except IOError:
2229 except IOError:
2231 filename = make_filename(args)
2230 filename = make_filename(args)
2232 if filename is None:
2231 if filename is None:
2233 warn('The file `%s` where `%s` was defined cannot '
2232 warn('The file `%s` where `%s` was defined cannot '
2234 'be read.' % (filename,data))
2233 'be read.' % (filename,data))
2235 return
2234 return
2236 use_temp = 0
2235 use_temp = 0
2237 else:
2236 else:
2238 data = ''
2237 data = ''
2239
2238
2240 if use_temp:
2239 if use_temp:
2241 filename = self.shell.mktempfile(data)
2240 filename = self.shell.mktempfile(data)
2242 print 'IPython will make a temporary file named:',filename
2241 print 'IPython will make a temporary file named:',filename
2243
2242
2244 # do actual editing here
2243 # do actual editing here
2245 print 'Editing...',
2244 print 'Editing...',
2246 sys.stdout.flush()
2245 sys.stdout.flush()
2247 self.shell.hooks.editor(filename,lineno)
2246 self.shell.hooks.editor(filename,lineno)
2248 if opts.has_key('x'): # -x prevents actual execution
2247 if opts.has_key('x'): # -x prevents actual execution
2249 print
2248 print
2250 else:
2249 else:
2251 print 'done. Executing edited code...'
2250 print 'done. Executing edited code...'
2252 if opts_r:
2251 if opts_r:
2253 self.shell.runlines(file_read(filename))
2252 self.shell.runlines(file_read(filename))
2254 else:
2253 else:
2255 self.shell.safe_execfile(filename,self.shell.user_ns)
2254 self.shell.safe_execfile(filename,self.shell.user_ns)
2256 if use_temp:
2255 if use_temp:
2257 try:
2256 try:
2258 return open(filename).read()
2257 return open(filename).read()
2259 except IOError,msg:
2258 except IOError,msg:
2260 if msg.filename == filename:
2259 if msg.filename == filename:
2261 warn('File not found. Did you forget to save?')
2260 warn('File not found. Did you forget to save?')
2262 return
2261 return
2263 else:
2262 else:
2264 self.shell.showtraceback()
2263 self.shell.showtraceback()
2265
2264
2266 def magic_xmode(self,parameter_s = ''):
2265 def magic_xmode(self,parameter_s = ''):
2267 """Switch modes for the exception handlers.
2266 """Switch modes for the exception handlers.
2268
2267
2269 Valid modes: Plain, Context and Verbose.
2268 Valid modes: Plain, Context and Verbose.
2270
2269
2271 If called without arguments, acts as a toggle."""
2270 If called without arguments, acts as a toggle."""
2272
2271
2273 def xmode_switch_err(name):
2272 def xmode_switch_err(name):
2274 warn('Error changing %s exception modes.\n%s' %
2273 warn('Error changing %s exception modes.\n%s' %
2275 (name,sys.exc_info()[1]))
2274 (name,sys.exc_info()[1]))
2276
2275
2277 shell = self.shell
2276 shell = self.shell
2278 new_mode = parameter_s.strip().capitalize()
2277 new_mode = parameter_s.strip().capitalize()
2279 try:
2278 try:
2280 shell.InteractiveTB.set_mode(mode=new_mode)
2279 shell.InteractiveTB.set_mode(mode=new_mode)
2281 print 'Exception reporting mode:',shell.InteractiveTB.mode
2280 print 'Exception reporting mode:',shell.InteractiveTB.mode
2282 except:
2281 except:
2283 xmode_switch_err('user')
2282 xmode_switch_err('user')
2284
2283
2285 # threaded shells use a special handler in sys.excepthook
2284 # threaded shells use a special handler in sys.excepthook
2286 if shell.isthreaded:
2285 if shell.isthreaded:
2287 try:
2286 try:
2288 shell.sys_excepthook.set_mode(mode=new_mode)
2287 shell.sys_excepthook.set_mode(mode=new_mode)
2289 except:
2288 except:
2290 xmode_switch_err('threaded')
2289 xmode_switch_err('threaded')
2291
2290
2292 def magic_colors(self,parameter_s = ''):
2291 def magic_colors(self,parameter_s = ''):
2293 """Switch color scheme for prompts, info system and exception handlers.
2292 """Switch color scheme for prompts, info system and exception handlers.
2294
2293
2295 Currently implemented schemes: NoColor, Linux, LightBG.
2294 Currently implemented schemes: NoColor, Linux, LightBG.
2296
2295
2297 Color scheme names are not case-sensitive."""
2296 Color scheme names are not case-sensitive."""
2298
2297
2299 def color_switch_err(name):
2298 def color_switch_err(name):
2300 warn('Error changing %s color schemes.\n%s' %
2299 warn('Error changing %s color schemes.\n%s' %
2301 (name,sys.exc_info()[1]))
2300 (name,sys.exc_info()[1]))
2302
2301
2303
2302
2304 new_scheme = parameter_s.strip()
2303 new_scheme = parameter_s.strip()
2305 if not new_scheme:
2304 if not new_scheme:
2306 print 'You must specify a color scheme.'
2305 print 'You must specify a color scheme.'
2307 return
2306 return
2308 import IPython.rlineimpl as readline
2307 import IPython.rlineimpl as readline
2309 if not readline.have_readline:
2308 if not readline.have_readline:
2310 msg = """\
2309 msg = """\
2311 Proper color support under MS Windows requires the pyreadline library.
2310 Proper color support under MS Windows requires the pyreadline library.
2312 You can find it at:
2311 You can find it at:
2313 http://ipython.scipy.org/moin/PyReadline/Intro
2312 http://ipython.scipy.org/moin/PyReadline/Intro
2314 Gary's readline needs the ctypes module, from:
2313 Gary's readline needs the ctypes module, from:
2315 http://starship.python.net/crew/theller/ctypes
2314 http://starship.python.net/crew/theller/ctypes
2316 (Note that ctypes is already part of Python versions 2.5 and newer).
2315 (Note that ctypes is already part of Python versions 2.5 and newer).
2317
2316
2318 Defaulting color scheme to 'NoColor'"""
2317 Defaulting color scheme to 'NoColor'"""
2319 new_scheme = 'NoColor'
2318 new_scheme = 'NoColor'
2320 warn(msg)
2319 warn(msg)
2321 # local shortcut
2320 # local shortcut
2322 shell = self.shell
2321 shell = self.shell
2323
2322
2324 # Set prompt colors
2323 # Set prompt colors
2325 try:
2324 try:
2326 shell.outputcache.set_colors(new_scheme)
2325 shell.outputcache.set_colors(new_scheme)
2327 except:
2326 except:
2328 color_switch_err('prompt')
2327 color_switch_err('prompt')
2329 else:
2328 else:
2330 shell.rc.colors = \
2329 shell.rc.colors = \
2331 shell.outputcache.color_table.active_scheme_name
2330 shell.outputcache.color_table.active_scheme_name
2332 # Set exception colors
2331 # Set exception colors
2333 try:
2332 try:
2334 shell.InteractiveTB.set_colors(scheme = new_scheme)
2333 shell.InteractiveTB.set_colors(scheme = new_scheme)
2335 shell.SyntaxTB.set_colors(scheme = new_scheme)
2334 shell.SyntaxTB.set_colors(scheme = new_scheme)
2336 except:
2335 except:
2337 color_switch_err('exception')
2336 color_switch_err('exception')
2338
2337
2339 # threaded shells use a verbose traceback in sys.excepthook
2338 # threaded shells use a verbose traceback in sys.excepthook
2340 if shell.isthreaded:
2339 if shell.isthreaded:
2341 try:
2340 try:
2342 shell.sys_excepthook.set_colors(scheme=new_scheme)
2341 shell.sys_excepthook.set_colors(scheme=new_scheme)
2343 except:
2342 except:
2344 color_switch_err('system exception handler')
2343 color_switch_err('system exception handler')
2345
2344
2346 # Set info (for 'object?') colors
2345 # Set info (for 'object?') colors
2347 if shell.rc.color_info:
2346 if shell.rc.color_info:
2348 try:
2347 try:
2349 shell.inspector.set_active_scheme(new_scheme)
2348 shell.inspector.set_active_scheme(new_scheme)
2350 except:
2349 except:
2351 color_switch_err('object inspector')
2350 color_switch_err('object inspector')
2352 else:
2351 else:
2353 shell.inspector.set_active_scheme('NoColor')
2352 shell.inspector.set_active_scheme('NoColor')
2354
2353
2355 def magic_color_info(self,parameter_s = ''):
2354 def magic_color_info(self,parameter_s = ''):
2356 """Toggle color_info.
2355 """Toggle color_info.
2357
2356
2358 The color_info configuration parameter controls whether colors are
2357 The color_info configuration parameter controls whether colors are
2359 used for displaying object details (by things like %psource, %pfile or
2358 used for displaying object details (by things like %psource, %pfile or
2360 the '?' system). This function toggles this value with each call.
2359 the '?' system). This function toggles this value with each call.
2361
2360
2362 Note that unless you have a fairly recent pager (less works better
2361 Note that unless you have a fairly recent pager (less works better
2363 than more) in your system, using colored object information displays
2362 than more) in your system, using colored object information displays
2364 will not work properly. Test it and see."""
2363 will not work properly. Test it and see."""
2365
2364
2366 self.shell.rc.color_info = 1 - self.shell.rc.color_info
2365 self.shell.rc.color_info = 1 - self.shell.rc.color_info
2367 self.magic_colors(self.shell.rc.colors)
2366 self.magic_colors(self.shell.rc.colors)
2368 print 'Object introspection functions have now coloring:',
2367 print 'Object introspection functions have now coloring:',
2369 print ['OFF','ON'][self.shell.rc.color_info]
2368 print ['OFF','ON'][self.shell.rc.color_info]
2370
2369
2371 def magic_Pprint(self, parameter_s=''):
2370 def magic_Pprint(self, parameter_s=''):
2372 """Toggle pretty printing on/off."""
2371 """Toggle pretty printing on/off."""
2373
2372
2374 self.shell.rc.pprint = 1 - self.shell.rc.pprint
2373 self.shell.rc.pprint = 1 - self.shell.rc.pprint
2375 print 'Pretty printing has been turned', \
2374 print 'Pretty printing has been turned', \
2376 ['OFF','ON'][self.shell.rc.pprint]
2375 ['OFF','ON'][self.shell.rc.pprint]
2377
2376
2378 def magic_exit(self, parameter_s=''):
2377 def magic_exit(self, parameter_s=''):
2379 """Exit IPython, confirming if configured to do so.
2378 """Exit IPython, confirming if configured to do so.
2380
2379
2381 You can configure whether IPython asks for confirmation upon exit by
2380 You can configure whether IPython asks for confirmation upon exit by
2382 setting the confirm_exit flag in the ipythonrc file."""
2381 setting the confirm_exit flag in the ipythonrc file."""
2383
2382
2384 self.shell.exit()
2383 self.shell.exit()
2385
2384
2386 def magic_quit(self, parameter_s=''):
2385 def magic_quit(self, parameter_s=''):
2387 """Exit IPython, confirming if configured to do so (like %exit)"""
2386 """Exit IPython, confirming if configured to do so (like %exit)"""
2388
2387
2389 self.shell.exit()
2388 self.shell.exit()
2390
2389
2391 def magic_Exit(self, parameter_s=''):
2390 def magic_Exit(self, parameter_s=''):
2392 """Exit IPython without confirmation."""
2391 """Exit IPython without confirmation."""
2393
2392
2394 self.shell.exit_now = True
2393 self.shell.exit_now = True
2395
2394
2396 def magic_Quit(self, parameter_s=''):
2395 def magic_Quit(self, parameter_s=''):
2397 """Exit IPython without confirmation (like %Exit)."""
2396 """Exit IPython without confirmation (like %Exit)."""
2398
2397
2399 self.shell.exit_now = True
2398 self.shell.exit_now = True
2400
2399
2401 #......................................................................
2400 #......................................................................
2402 # Functions to implement unix shell-type things
2401 # Functions to implement unix shell-type things
2403
2402
2404 def magic_alias(self, parameter_s = ''):
2403 def magic_alias(self, parameter_s = ''):
2405 """Define an alias for a system command.
2404 """Define an alias for a system command.
2406
2405
2407 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2406 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2408
2407
2409 Then, typing 'alias_name params' will execute the system command 'cmd
2408 Then, typing 'alias_name params' will execute the system command 'cmd
2410 params' (from your underlying operating system).
2409 params' (from your underlying operating system).
2411
2410
2412 Aliases have lower precedence than magic functions and Python normal
2411 Aliases have lower precedence than magic functions and Python normal
2413 variables, so if 'foo' is both a Python variable and an alias, the
2412 variables, so if 'foo' is both a Python variable and an alias, the
2414 alias can not be executed until 'del foo' removes the Python variable.
2413 alias can not be executed until 'del foo' removes the Python variable.
2415
2414
2416 You can use the %l specifier in an alias definition to represent the
2415 You can use the %l specifier in an alias definition to represent the
2417 whole line when the alias is called. For example:
2416 whole line when the alias is called. For example:
2418
2417
2419 In [2]: alias all echo "Input in brackets: <%l>"\\
2418 In [2]: alias all echo "Input in brackets: <%l>"\\
2420 In [3]: all hello world\\
2419 In [3]: all hello world\\
2421 Input in brackets: <hello world>
2420 Input in brackets: <hello world>
2422
2421
2423 You can also define aliases with parameters using %s specifiers (one
2422 You can also define aliases with parameters using %s specifiers (one
2424 per parameter):
2423 per parameter):
2425
2424
2426 In [1]: alias parts echo first %s second %s\\
2425 In [1]: alias parts echo first %s second %s\\
2427 In [2]: %parts A B\\
2426 In [2]: %parts A B\\
2428 first A second B\\
2427 first A second B\\
2429 In [3]: %parts A\\
2428 In [3]: %parts A\\
2430 Incorrect number of arguments: 2 expected.\\
2429 Incorrect number of arguments: 2 expected.\\
2431 parts is an alias to: 'echo first %s second %s'
2430 parts is an alias to: 'echo first %s second %s'
2432
2431
2433 Note that %l and %s are mutually exclusive. You can only use one or
2432 Note that %l and %s are mutually exclusive. You can only use one or
2434 the other in your aliases.
2433 the other in your aliases.
2435
2434
2436 Aliases expand Python variables just like system calls using ! or !!
2435 Aliases expand Python variables just like system calls using ! or !!
2437 do: all expressions prefixed with '$' get expanded. For details of
2436 do: all expressions prefixed with '$' get expanded. For details of
2438 the semantic rules, see PEP-215:
2437 the semantic rules, see PEP-215:
2439 http://www.python.org/peps/pep-0215.html. This is the library used by
2438 http://www.python.org/peps/pep-0215.html. This is the library used by
2440 IPython for variable expansion. If you want to access a true shell
2439 IPython for variable expansion. If you want to access a true shell
2441 variable, an extra $ is necessary to prevent its expansion by IPython:
2440 variable, an extra $ is necessary to prevent its expansion by IPython:
2442
2441
2443 In [6]: alias show echo\\
2442 In [6]: alias show echo\\
2444 In [7]: PATH='A Python string'\\
2443 In [7]: PATH='A Python string'\\
2445 In [8]: show $PATH\\
2444 In [8]: show $PATH\\
2446 A Python string\\
2445 A Python string\\
2447 In [9]: show $$PATH\\
2446 In [9]: show $$PATH\\
2448 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2447 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2449
2448
2450 You can use the alias facility to acess all of $PATH. See the %rehash
2449 You can use the alias facility to acess all of $PATH. See the %rehash
2451 and %rehashx functions, which automatically create aliases for the
2450 and %rehashx functions, which automatically create aliases for the
2452 contents of your $PATH.
2451 contents of your $PATH.
2453
2452
2454 If called with no parameters, %alias prints the current alias table."""
2453 If called with no parameters, %alias prints the current alias table."""
2455
2454
2456 par = parameter_s.strip()
2455 par = parameter_s.strip()
2457 if not par:
2456 if not par:
2458 stored = self.db.get('stored_aliases', {} )
2457 stored = self.db.get('stored_aliases', {} )
2459 atab = self.shell.alias_table
2458 atab = self.shell.alias_table
2460 aliases = atab.keys()
2459 aliases = atab.keys()
2461 aliases.sort()
2460 aliases.sort()
2462 res = []
2461 res = []
2463 showlast = []
2462 showlast = []
2464 for alias in aliases:
2463 for alias in aliases:
2465 tgt = atab[alias][1]
2464 tgt = atab[alias][1]
2466 # 'interesting' aliases
2465 # 'interesting' aliases
2467 if (alias in stored or
2466 if (alias in stored or
2468 alias != os.path.splitext(tgt)[0] or
2467 alias != os.path.splitext(tgt)[0] or
2469 ' ' in tgt):
2468 ' ' in tgt):
2470 showlast.append((alias, tgt))
2469 showlast.append((alias, tgt))
2471 else:
2470 else:
2472 res.append((alias, tgt ))
2471 res.append((alias, tgt ))
2473
2472
2474 # show most interesting aliases last
2473 # show most interesting aliases last
2475 res.extend(showlast)
2474 res.extend(showlast)
2476 print "Total number of aliases:",len(aliases)
2475 print "Total number of aliases:",len(aliases)
2477 return res
2476 return res
2478 try:
2477 try:
2479 alias,cmd = par.split(None,1)
2478 alias,cmd = par.split(None,1)
2480 except:
2479 except:
2481 print OInspect.getdoc(self.magic_alias)
2480 print OInspect.getdoc(self.magic_alias)
2482 else:
2481 else:
2483 nargs = cmd.count('%s')
2482 nargs = cmd.count('%s')
2484 if nargs>0 and cmd.find('%l')>=0:
2483 if nargs>0 and cmd.find('%l')>=0:
2485 error('The %s and %l specifiers are mutually exclusive '
2484 error('The %s and %l specifiers are mutually exclusive '
2486 'in alias definitions.')
2485 'in alias definitions.')
2487 else: # all looks OK
2486 else: # all looks OK
2488 self.shell.alias_table[alias] = (nargs,cmd)
2487 self.shell.alias_table[alias] = (nargs,cmd)
2489 self.shell.alias_table_validate(verbose=0)
2488 self.shell.alias_table_validate(verbose=0)
2490 # end magic_alias
2489 # end magic_alias
2491
2490
2492 def magic_unalias(self, parameter_s = ''):
2491 def magic_unalias(self, parameter_s = ''):
2493 """Remove an alias"""
2492 """Remove an alias"""
2494
2493
2495 aname = parameter_s.strip()
2494 aname = parameter_s.strip()
2496 if aname in self.shell.alias_table:
2495 if aname in self.shell.alias_table:
2497 del self.shell.alias_table[aname]
2496 del self.shell.alias_table[aname]
2498 stored = self.db.get('stored_aliases', {} )
2497 stored = self.db.get('stored_aliases', {} )
2499 if aname in stored:
2498 if aname in stored:
2500 print "Removing %stored alias",aname
2499 print "Removing %stored alias",aname
2501 del stored[aname]
2500 del stored[aname]
2502 self.db['stored_aliases'] = stored
2501 self.db['stored_aliases'] = stored
2503
2502
2504 def magic_rehash(self, parameter_s = ''):
2503 def magic_rehash(self, parameter_s = ''):
2505 """Update the alias table with all entries in $PATH.
2504 """Update the alias table with all entries in $PATH.
2506
2505
2507 This version does no checks on execute permissions or whether the
2506 This version does no checks on execute permissions or whether the
2508 contents of $PATH are truly files (instead of directories or something
2507 contents of $PATH are truly files (instead of directories or something
2509 else). For such a safer (but slower) version, use %rehashx."""
2508 else). For such a safer (but slower) version, use %rehashx."""
2510
2509
2511 # This function (and rehashx) manipulate the alias_table directly
2510 # This function (and rehashx) manipulate the alias_table directly
2512 # rather than calling magic_alias, for speed reasons. A rehash on a
2511 # rather than calling magic_alias, for speed reasons. A rehash on a
2513 # typical Linux box involves several thousand entries, so efficiency
2512 # typical Linux box involves several thousand entries, so efficiency
2514 # here is a top concern.
2513 # here is a top concern.
2515
2514
2516 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2515 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2517 alias_table = self.shell.alias_table
2516 alias_table = self.shell.alias_table
2518 for pdir in path:
2517 for pdir in path:
2519 for ff in os.listdir(pdir):
2518 for ff in os.listdir(pdir):
2520 # each entry in the alias table must be (N,name), where
2519 # each entry in the alias table must be (N,name), where
2521 # N is the number of positional arguments of the alias.
2520 # N is the number of positional arguments of the alias.
2522 alias_table[ff] = (0,ff)
2521 alias_table[ff] = (0,ff)
2523 # Make sure the alias table doesn't contain keywords or builtins
2522 # Make sure the alias table doesn't contain keywords or builtins
2524 self.shell.alias_table_validate()
2523 self.shell.alias_table_validate()
2525 # Call again init_auto_alias() so we get 'rm -i' and other modified
2524 # Call again init_auto_alias() so we get 'rm -i' and other modified
2526 # aliases since %rehash will probably clobber them
2525 # aliases since %rehash will probably clobber them
2527 self.shell.init_auto_alias()
2526 self.shell.init_auto_alias()
2528
2527
2529 def magic_rehashx(self, parameter_s = ''):
2528 def magic_rehashx(self, parameter_s = ''):
2530 """Update the alias table with all executable files in $PATH.
2529 """Update the alias table with all executable files in $PATH.
2531
2530
2532 This version explicitly checks that every entry in $PATH is a file
2531 This version explicitly checks that every entry in $PATH is a file
2533 with execute access (os.X_OK), so it is much slower than %rehash.
2532 with execute access (os.X_OK), so it is much slower than %rehash.
2534
2533
2535 Under Windows, it checks executability as a match agains a
2534 Under Windows, it checks executability as a match agains a
2536 '|'-separated string of extensions, stored in the IPython config
2535 '|'-separated string of extensions, stored in the IPython config
2537 variable win_exec_ext. This defaults to 'exe|com|bat'. """
2536 variable win_exec_ext. This defaults to 'exe|com|bat'. """
2538
2537
2539 path = [os.path.abspath(os.path.expanduser(p)) for p in
2538 path = [os.path.abspath(os.path.expanduser(p)) for p in
2540 os.environ['PATH'].split(os.pathsep)]
2539 os.environ['PATH'].split(os.pathsep)]
2541 path = filter(os.path.isdir,path)
2540 path = filter(os.path.isdir,path)
2542
2541
2543 alias_table = self.shell.alias_table
2542 alias_table = self.shell.alias_table
2544 syscmdlist = []
2543 syscmdlist = []
2545 if os.name == 'posix':
2544 if os.name == 'posix':
2546 isexec = lambda fname:os.path.isfile(fname) and \
2545 isexec = lambda fname:os.path.isfile(fname) and \
2547 os.access(fname,os.X_OK)
2546 os.access(fname,os.X_OK)
2548 else:
2547 else:
2549
2548
2550 try:
2549 try:
2551 winext = os.environ['pathext'].replace(';','|').replace('.','')
2550 winext = os.environ['pathext'].replace(';','|').replace('.','')
2552 except KeyError:
2551 except KeyError:
2553 winext = 'exe|com|bat|py'
2552 winext = 'exe|com|bat|py'
2554 if 'py' not in winext:
2553 if 'py' not in winext:
2555 winext += '|py'
2554 winext += '|py'
2556 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2555 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2557 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2556 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2558 savedir = os.getcwd()
2557 savedir = os.getcwd()
2559 try:
2558 try:
2560 # write the whole loop for posix/Windows so we don't have an if in
2559 # write the whole loop for posix/Windows so we don't have an if in
2561 # the innermost part
2560 # the innermost part
2562 if os.name == 'posix':
2561 if os.name == 'posix':
2563 for pdir in path:
2562 for pdir in path:
2564 os.chdir(pdir)
2563 os.chdir(pdir)
2565 for ff in os.listdir(pdir):
2564 for ff in os.listdir(pdir):
2566 if isexec(ff) and ff not in self.shell.no_alias:
2565 if isexec(ff) and ff not in self.shell.no_alias:
2567 # each entry in the alias table must be (N,name),
2566 # each entry in the alias table must be (N,name),
2568 # where N is the number of positional arguments of the
2567 # where N is the number of positional arguments of the
2569 # alias.
2568 # alias.
2570 alias_table[ff] = (0,ff)
2569 alias_table[ff] = (0,ff)
2571 syscmdlist.append(ff)
2570 syscmdlist.append(ff)
2572 else:
2571 else:
2573 for pdir in path:
2572 for pdir in path:
2574 os.chdir(pdir)
2573 os.chdir(pdir)
2575 for ff in os.listdir(pdir):
2574 for ff in os.listdir(pdir):
2576 base, ext = os.path.splitext(ff)
2575 base, ext = os.path.splitext(ff)
2577 if isexec(ff) and base not in self.shell.no_alias:
2576 if isexec(ff) and base not in self.shell.no_alias:
2578 if ext.lower() == '.exe':
2577 if ext.lower() == '.exe':
2579 ff = base
2578 ff = base
2580 alias_table[base] = (0,ff)
2579 alias_table[base] = (0,ff)
2581 syscmdlist.append(ff)
2580 syscmdlist.append(ff)
2582 # Make sure the alias table doesn't contain keywords or builtins
2581 # Make sure the alias table doesn't contain keywords or builtins
2583 self.shell.alias_table_validate()
2582 self.shell.alias_table_validate()
2584 # Call again init_auto_alias() so we get 'rm -i' and other
2583 # Call again init_auto_alias() so we get 'rm -i' and other
2585 # modified aliases since %rehashx will probably clobber them
2584 # modified aliases since %rehashx will probably clobber them
2586 self.shell.init_auto_alias()
2585 self.shell.init_auto_alias()
2587 db = self.getapi().db
2586 db = self.getapi().db
2588 db['syscmdlist'] = syscmdlist
2587 db['syscmdlist'] = syscmdlist
2589 finally:
2588 finally:
2590 os.chdir(savedir)
2589 os.chdir(savedir)
2591
2590
2592 def magic_pwd(self, parameter_s = ''):
2591 def magic_pwd(self, parameter_s = ''):
2593 """Return the current working directory path."""
2592 """Return the current working directory path."""
2594 return os.getcwd()
2593 return os.getcwd()
2595
2594
2596 def magic_cd(self, parameter_s=''):
2595 def magic_cd(self, parameter_s=''):
2597 """Change the current working directory.
2596 """Change the current working directory.
2598
2597
2599 This command automatically maintains an internal list of directories
2598 This command automatically maintains an internal list of directories
2600 you visit during your IPython session, in the variable _dh. The
2599 you visit during your IPython session, in the variable _dh. The
2601 command %dhist shows this history nicely formatted. You can also
2600 command %dhist shows this history nicely formatted. You can also
2602 do 'cd -<tab>' to see directory history conveniently.
2601 do 'cd -<tab>' to see directory history conveniently.
2603
2602
2604 Usage:
2603 Usage:
2605
2604
2606 cd 'dir': changes to directory 'dir'.
2605 cd 'dir': changes to directory 'dir'.
2607
2606
2608 cd -: changes to the last visited directory.
2607 cd -: changes to the last visited directory.
2609
2608
2610 cd -<n>: changes to the n-th directory in the directory history.
2609 cd -<n>: changes to the n-th directory in the directory history.
2611
2610
2612 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2611 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2613 (note: cd <bookmark_name> is enough if there is no
2612 (note: cd <bookmark_name> is enough if there is no
2614 directory <bookmark_name>, but a bookmark with the name exists.)
2613 directory <bookmark_name>, but a bookmark with the name exists.)
2615 'cd -b <tab>' allows you to tab-complete bookmark names.
2614 'cd -b <tab>' allows you to tab-complete bookmark names.
2616
2615
2617 Options:
2616 Options:
2618
2617
2619 -q: quiet. Do not print the working directory after the cd command is
2618 -q: quiet. Do not print the working directory after the cd command is
2620 executed. By default IPython's cd command does print this directory,
2619 executed. By default IPython's cd command does print this directory,
2621 since the default prompts do not display path information.
2620 since the default prompts do not display path information.
2622
2621
2623 Note that !cd doesn't work for this purpose because the shell where
2622 Note that !cd doesn't work for this purpose because the shell where
2624 !command runs is immediately discarded after executing 'command'."""
2623 !command runs is immediately discarded after executing 'command'."""
2625
2624
2626 parameter_s = parameter_s.strip()
2625 parameter_s = parameter_s.strip()
2627 #bkms = self.shell.persist.get("bookmarks",{})
2626 #bkms = self.shell.persist.get("bookmarks",{})
2628
2627
2629 numcd = re.match(r'(-)(\d+)$',parameter_s)
2628 numcd = re.match(r'(-)(\d+)$',parameter_s)
2630 # jump in directory history by number
2629 # jump in directory history by number
2631 if numcd:
2630 if numcd:
2632 nn = int(numcd.group(2))
2631 nn = int(numcd.group(2))
2633 try:
2632 try:
2634 ps = self.shell.user_ns['_dh'][nn]
2633 ps = self.shell.user_ns['_dh'][nn]
2635 except IndexError:
2634 except IndexError:
2636 print 'The requested directory does not exist in history.'
2635 print 'The requested directory does not exist in history.'
2637 return
2636 return
2638 else:
2637 else:
2639 opts = {}
2638 opts = {}
2640 else:
2639 else:
2641 #turn all non-space-escaping backslashes to slashes,
2640 #turn all non-space-escaping backslashes to slashes,
2642 # for c:\windows\directory\names\
2641 # for c:\windows\directory\names\
2643 parameter_s = re.sub(r'\\(?! )','/', parameter_s)
2642 parameter_s = re.sub(r'\\(?! )','/', parameter_s)
2644 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2643 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2645 # jump to previous
2644 # jump to previous
2646 if ps == '-':
2645 if ps == '-':
2647 try:
2646 try:
2648 ps = self.shell.user_ns['_dh'][-2]
2647 ps = self.shell.user_ns['_dh'][-2]
2649 except IndexError:
2648 except IndexError:
2650 print 'No previous directory to change to.'
2649 print 'No previous directory to change to.'
2651 return
2650 return
2652 # jump to bookmark if needed
2651 # jump to bookmark if needed
2653 else:
2652 else:
2654 if not os.path.isdir(ps) or opts.has_key('b'):
2653 if not os.path.isdir(ps) or opts.has_key('b'):
2655 bkms = self.db.get('bookmarks', {})
2654 bkms = self.db.get('bookmarks', {})
2656
2655
2657 if bkms.has_key(ps):
2656 if bkms.has_key(ps):
2658 target = bkms[ps]
2657 target = bkms[ps]
2659 print '(bookmark:%s) -> %s' % (ps,target)
2658 print '(bookmark:%s) -> %s' % (ps,target)
2660 ps = target
2659 ps = target
2661 else:
2660 else:
2662 if opts.has_key('b'):
2661 if opts.has_key('b'):
2663 error("Bookmark '%s' not found. "
2662 error("Bookmark '%s' not found. "
2664 "Use '%%bookmark -l' to see your bookmarks." % ps)
2663 "Use '%%bookmark -l' to see your bookmarks." % ps)
2665 return
2664 return
2666
2665
2667 # at this point ps should point to the target dir
2666 # at this point ps should point to the target dir
2668 if ps:
2667 if ps:
2669 try:
2668 try:
2670 os.chdir(os.path.expanduser(ps))
2669 os.chdir(os.path.expanduser(ps))
2671 if self.shell.rc.term_title:
2670 if self.shell.rc.term_title:
2672 #print 'set term title:',self.shell.rc.term_title # dbg
2671 #print 'set term title:',self.shell.rc.term_title # dbg
2673 ttitle = ("IPy:" + (
2672 ttitle = ("IPy:" + (
2674 os.getcwd() == '/' and '/' or \
2673 os.getcwd() == '/' and '/' or \
2675 os.path.basename(os.getcwd())))
2674 os.path.basename(os.getcwd())))
2676 platutils.set_term_title(ttitle)
2675 platutils.set_term_title(ttitle)
2677 except OSError:
2676 except OSError:
2678 print sys.exc_info()[1]
2677 print sys.exc_info()[1]
2679 else:
2678 else:
2680 self.shell.user_ns['_dh'].append(os.getcwd())
2679 self.shell.user_ns['_dh'].append(os.getcwd())
2681 else:
2680 else:
2682 os.chdir(self.shell.home_dir)
2681 os.chdir(self.shell.home_dir)
2683 if self.shell.rc.term_title:
2682 if self.shell.rc.term_title:
2684 platutils.set_term_title("IPy:~")
2683 platutils.set_term_title("IPy:~")
2685 self.shell.user_ns['_dh'].append(os.getcwd())
2684 self.shell.user_ns['_dh'].append(os.getcwd())
2686 if not 'q' in opts:
2685 if not 'q' in opts:
2687 print self.shell.user_ns['_dh'][-1]
2686 print self.shell.user_ns['_dh'][-1]
2688
2687
2689 def magic_dhist(self, parameter_s=''):
2688 def magic_dhist(self, parameter_s=''):
2690 """Print your history of visited directories.
2689 """Print your history of visited directories.
2691
2690
2692 %dhist -> print full history\\
2691 %dhist -> print full history\\
2693 %dhist n -> print last n entries only\\
2692 %dhist n -> print last n entries only\\
2694 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2693 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2695
2694
2696 This history is automatically maintained by the %cd command, and
2695 This history is automatically maintained by the %cd command, and
2697 always available as the global list variable _dh. You can use %cd -<n>
2696 always available as the global list variable _dh. You can use %cd -<n>
2698 to go to directory number <n>."""
2697 to go to directory number <n>."""
2699
2698
2700 dh = self.shell.user_ns['_dh']
2699 dh = self.shell.user_ns['_dh']
2701 if parameter_s:
2700 if parameter_s:
2702 try:
2701 try:
2703 args = map(int,parameter_s.split())
2702 args = map(int,parameter_s.split())
2704 except:
2703 except:
2705 self.arg_err(Magic.magic_dhist)
2704 self.arg_err(Magic.magic_dhist)
2706 return
2705 return
2707 if len(args) == 1:
2706 if len(args) == 1:
2708 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2707 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2709 elif len(args) == 2:
2708 elif len(args) == 2:
2710 ini,fin = args
2709 ini,fin = args
2711 else:
2710 else:
2712 self.arg_err(Magic.magic_dhist)
2711 self.arg_err(Magic.magic_dhist)
2713 return
2712 return
2714 else:
2713 else:
2715 ini,fin = 0,len(dh)
2714 ini,fin = 0,len(dh)
2716 nlprint(dh,
2715 nlprint(dh,
2717 header = 'Directory history (kept in _dh)',
2716 header = 'Directory history (kept in _dh)',
2718 start=ini,stop=fin)
2717 start=ini,stop=fin)
2719
2718
2720 def magic_env(self, parameter_s=''):
2719 def magic_env(self, parameter_s=''):
2721 """List environment variables."""
2720 """List environment variables."""
2722
2721
2723 return os.environ.data
2722 return os.environ.data
2724
2723
2725 def magic_pushd(self, parameter_s=''):
2724 def magic_pushd(self, parameter_s=''):
2726 """Place the current dir on stack and change directory.
2725 """Place the current dir on stack and change directory.
2727
2726
2728 Usage:\\
2727 Usage:\\
2729 %pushd ['dirname']
2728 %pushd ['dirname']
2730
2729
2731 %pushd with no arguments does a %pushd to your home directory.
2730 %pushd with no arguments does a %pushd to your home directory.
2732 """
2731 """
2733 if parameter_s == '': parameter_s = '~'
2732 if parameter_s == '': parameter_s = '~'
2734 dir_s = self.shell.dir_stack
2733 dir_s = self.shell.dir_stack
2735 if len(dir_s)>0 and os.path.expanduser(parameter_s) != \
2734 if len(dir_s)>0 and os.path.expanduser(parameter_s) != \
2736 os.path.expanduser(self.shell.dir_stack[0]):
2735 os.path.expanduser(self.shell.dir_stack[0]):
2737 try:
2736 try:
2738 self.magic_cd(parameter_s)
2737 self.magic_cd(parameter_s)
2739 dir_s.insert(0,os.getcwd().replace(self.home_dir,'~'))
2738 dir_s.insert(0,os.getcwd().replace(self.home_dir,'~'))
2740 self.magic_dirs()
2739 self.magic_dirs()
2741 except:
2740 except:
2742 print 'Invalid directory'
2741 print 'Invalid directory'
2743 else:
2742 else:
2744 print 'You are already there!'
2743 print 'You are already there!'
2745
2744
2746 def magic_popd(self, parameter_s=''):
2745 def magic_popd(self, parameter_s=''):
2747 """Change to directory popped off the top of the stack.
2746 """Change to directory popped off the top of the stack.
2748 """
2747 """
2749 if len (self.shell.dir_stack) > 1:
2748 if len (self.shell.dir_stack) > 1:
2750 self.shell.dir_stack.pop(0)
2749 self.shell.dir_stack.pop(0)
2751 self.magic_cd(self.shell.dir_stack[0])
2750 self.magic_cd(self.shell.dir_stack[0])
2752 print self.shell.dir_stack[0]
2751 print self.shell.dir_stack[0]
2753 else:
2752 else:
2754 print "You can't remove the starting directory from the stack:",\
2753 print "You can't remove the starting directory from the stack:",\
2755 self.shell.dir_stack
2754 self.shell.dir_stack
2756
2755
2757 def magic_dirs(self, parameter_s=''):
2756 def magic_dirs(self, parameter_s=''):
2758 """Return the current directory stack."""
2757 """Return the current directory stack."""
2759
2758
2760 return self.shell.dir_stack[:]
2759 return self.shell.dir_stack[:]
2761
2760
2762 def magic_sc(self, parameter_s=''):
2761 def magic_sc(self, parameter_s=''):
2763 """Shell capture - execute a shell command and capture its output.
2762 """Shell capture - execute a shell command and capture its output.
2764
2763
2765 DEPRECATED. Suboptimal, retained for backwards compatibility.
2764 DEPRECATED. Suboptimal, retained for backwards compatibility.
2766
2765
2767 You should use the form 'var = !command' instead. Example:
2766 You should use the form 'var = !command' instead. Example:
2768
2767
2769 "%sc -l myfiles = ls ~" should now be written as
2768 "%sc -l myfiles = ls ~" should now be written as
2770
2769
2771 "myfiles = !ls ~"
2770 "myfiles = !ls ~"
2772
2771
2773 myfiles.s, myfiles.l and myfiles.n still apply as documented
2772 myfiles.s, myfiles.l and myfiles.n still apply as documented
2774 below.
2773 below.
2775
2774
2776 --
2775 --
2777 %sc [options] varname=command
2776 %sc [options] varname=command
2778
2777
2779 IPython will run the given command using commands.getoutput(), and
2778 IPython will run the given command using commands.getoutput(), and
2780 will then update the user's interactive namespace with a variable
2779 will then update the user's interactive namespace with a variable
2781 called varname, containing the value of the call. Your command can
2780 called varname, containing the value of the call. Your command can
2782 contain shell wildcards, pipes, etc.
2781 contain shell wildcards, pipes, etc.
2783
2782
2784 The '=' sign in the syntax is mandatory, and the variable name you
2783 The '=' sign in the syntax is mandatory, and the variable name you
2785 supply must follow Python's standard conventions for valid names.
2784 supply must follow Python's standard conventions for valid names.
2786
2785
2787 (A special format without variable name exists for internal use)
2786 (A special format without variable name exists for internal use)
2788
2787
2789 Options:
2788 Options:
2790
2789
2791 -l: list output. Split the output on newlines into a list before
2790 -l: list output. Split the output on newlines into a list before
2792 assigning it to the given variable. By default the output is stored
2791 assigning it to the given variable. By default the output is stored
2793 as a single string.
2792 as a single string.
2794
2793
2795 -v: verbose. Print the contents of the variable.
2794 -v: verbose. Print the contents of the variable.
2796
2795
2797 In most cases you should not need to split as a list, because the
2796 In most cases you should not need to split as a list, because the
2798 returned value is a special type of string which can automatically
2797 returned value is a special type of string which can automatically
2799 provide its contents either as a list (split on newlines) or as a
2798 provide its contents either as a list (split on newlines) or as a
2800 space-separated string. These are convenient, respectively, either
2799 space-separated string. These are convenient, respectively, either
2801 for sequential processing or to be passed to a shell command.
2800 for sequential processing or to be passed to a shell command.
2802
2801
2803 For example:
2802 For example:
2804
2803
2805 # Capture into variable a
2804 # Capture into variable a
2806 In [9]: sc a=ls *py
2805 In [9]: sc a=ls *py
2807
2806
2808 # a is a string with embedded newlines
2807 # a is a string with embedded newlines
2809 In [10]: a
2808 In [10]: a
2810 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2809 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2811
2810
2812 # which can be seen as a list:
2811 # which can be seen as a list:
2813 In [11]: a.l
2812 In [11]: a.l
2814 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2813 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2815
2814
2816 # or as a whitespace-separated string:
2815 # or as a whitespace-separated string:
2817 In [12]: a.s
2816 In [12]: a.s
2818 Out[12]: 'setup.py win32_manual_post_install.py'
2817 Out[12]: 'setup.py win32_manual_post_install.py'
2819
2818
2820 # a.s is useful to pass as a single command line:
2819 # a.s is useful to pass as a single command line:
2821 In [13]: !wc -l $a.s
2820 In [13]: !wc -l $a.s
2822 146 setup.py
2821 146 setup.py
2823 130 win32_manual_post_install.py
2822 130 win32_manual_post_install.py
2824 276 total
2823 276 total
2825
2824
2826 # while the list form is useful to loop over:
2825 # while the list form is useful to loop over:
2827 In [14]: for f in a.l:
2826 In [14]: for f in a.l:
2828 ....: !wc -l $f
2827 ....: !wc -l $f
2829 ....:
2828 ....:
2830 146 setup.py
2829 146 setup.py
2831 130 win32_manual_post_install.py
2830 130 win32_manual_post_install.py
2832
2831
2833 Similiarly, the lists returned by the -l option are also special, in
2832 Similiarly, the lists returned by the -l option are also special, in
2834 the sense that you can equally invoke the .s attribute on them to
2833 the sense that you can equally invoke the .s attribute on them to
2835 automatically get a whitespace-separated string from their contents:
2834 automatically get a whitespace-separated string from their contents:
2836
2835
2837 In [1]: sc -l b=ls *py
2836 In [1]: sc -l b=ls *py
2838
2837
2839 In [2]: b
2838 In [2]: b
2840 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2839 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2841
2840
2842 In [3]: b.s
2841 In [3]: b.s
2843 Out[3]: 'setup.py win32_manual_post_install.py'
2842 Out[3]: 'setup.py win32_manual_post_install.py'
2844
2843
2845 In summary, both the lists and strings used for ouptut capture have
2844 In summary, both the lists and strings used for ouptut capture have
2846 the following special attributes:
2845 the following special attributes:
2847
2846
2848 .l (or .list) : value as list.
2847 .l (or .list) : value as list.
2849 .n (or .nlstr): value as newline-separated string.
2848 .n (or .nlstr): value as newline-separated string.
2850 .s (or .spstr): value as space-separated string.
2849 .s (or .spstr): value as space-separated string.
2851 """
2850 """
2852
2851
2853 opts,args = self.parse_options(parameter_s,'lv')
2852 opts,args = self.parse_options(parameter_s,'lv')
2854 # Try to get a variable name and command to run
2853 # Try to get a variable name and command to run
2855 try:
2854 try:
2856 # the variable name must be obtained from the parse_options
2855 # the variable name must be obtained from the parse_options
2857 # output, which uses shlex.split to strip options out.
2856 # output, which uses shlex.split to strip options out.
2858 var,_ = args.split('=',1)
2857 var,_ = args.split('=',1)
2859 var = var.strip()
2858 var = var.strip()
2860 # But the the command has to be extracted from the original input
2859 # But the the command has to be extracted from the original input
2861 # parameter_s, not on what parse_options returns, to avoid the
2860 # parameter_s, not on what parse_options returns, to avoid the
2862 # quote stripping which shlex.split performs on it.
2861 # quote stripping which shlex.split performs on it.
2863 _,cmd = parameter_s.split('=',1)
2862 _,cmd = parameter_s.split('=',1)
2864 except ValueError:
2863 except ValueError:
2865 var,cmd = '',''
2864 var,cmd = '',''
2866 # If all looks ok, proceed
2865 # If all looks ok, proceed
2867 out,err = self.shell.getoutputerror(cmd)
2866 out,err = self.shell.getoutputerror(cmd)
2868 if err:
2867 if err:
2869 print >> Term.cerr,err
2868 print >> Term.cerr,err
2870 if opts.has_key('l'):
2869 if opts.has_key('l'):
2871 out = SList(out.split('\n'))
2870 out = SList(out.split('\n'))
2872 else:
2871 else:
2873 out = LSString(out)
2872 out = LSString(out)
2874 if opts.has_key('v'):
2873 if opts.has_key('v'):
2875 print '%s ==\n%s' % (var,pformat(out))
2874 print '%s ==\n%s' % (var,pformat(out))
2876 if var:
2875 if var:
2877 self.shell.user_ns.update({var:out})
2876 self.shell.user_ns.update({var:out})
2878 else:
2877 else:
2879 return out
2878 return out
2880
2879
2881 def magic_sx(self, parameter_s=''):
2880 def magic_sx(self, parameter_s=''):
2882 """Shell execute - run a shell command and capture its output.
2881 """Shell execute - run a shell command and capture its output.
2883
2882
2884 %sx command
2883 %sx command
2885
2884
2886 IPython will run the given command using commands.getoutput(), and
2885 IPython will run the given command using commands.getoutput(), and
2887 return the result formatted as a list (split on '\\n'). Since the
2886 return the result formatted as a list (split on '\\n'). Since the
2888 output is _returned_, it will be stored in ipython's regular output
2887 output is _returned_, it will be stored in ipython's regular output
2889 cache Out[N] and in the '_N' automatic variables.
2888 cache Out[N] and in the '_N' automatic variables.
2890
2889
2891 Notes:
2890 Notes:
2892
2891
2893 1) If an input line begins with '!!', then %sx is automatically
2892 1) If an input line begins with '!!', then %sx is automatically
2894 invoked. That is, while:
2893 invoked. That is, while:
2895 !ls
2894 !ls
2896 causes ipython to simply issue system('ls'), typing
2895 causes ipython to simply issue system('ls'), typing
2897 !!ls
2896 !!ls
2898 is a shorthand equivalent to:
2897 is a shorthand equivalent to:
2899 %sx ls
2898 %sx ls
2900
2899
2901 2) %sx differs from %sc in that %sx automatically splits into a list,
2900 2) %sx differs from %sc in that %sx automatically splits into a list,
2902 like '%sc -l'. The reason for this is to make it as easy as possible
2901 like '%sc -l'. The reason for this is to make it as easy as possible
2903 to process line-oriented shell output via further python commands.
2902 to process line-oriented shell output via further python commands.
2904 %sc is meant to provide much finer control, but requires more
2903 %sc is meant to provide much finer control, but requires more
2905 typing.
2904 typing.
2906
2905
2907 3) Just like %sc -l, this is a list with special attributes:
2906 3) Just like %sc -l, this is a list with special attributes:
2908
2907
2909 .l (or .list) : value as list.
2908 .l (or .list) : value as list.
2910 .n (or .nlstr): value as newline-separated string.
2909 .n (or .nlstr): value as newline-separated string.
2911 .s (or .spstr): value as whitespace-separated string.
2910 .s (or .spstr): value as whitespace-separated string.
2912
2911
2913 This is very useful when trying to use such lists as arguments to
2912 This is very useful when trying to use such lists as arguments to
2914 system commands."""
2913 system commands."""
2915
2914
2916 if parameter_s:
2915 if parameter_s:
2917 out,err = self.shell.getoutputerror(parameter_s)
2916 out,err = self.shell.getoutputerror(parameter_s)
2918 if err:
2917 if err:
2919 print >> Term.cerr,err
2918 print >> Term.cerr,err
2920 return SList(out.split('\n'))
2919 return SList(out.split('\n'))
2921
2920
2922 def magic_bg(self, parameter_s=''):
2921 def magic_bg(self, parameter_s=''):
2923 """Run a job in the background, in a separate thread.
2922 """Run a job in the background, in a separate thread.
2924
2923
2925 For example,
2924 For example,
2926
2925
2927 %bg myfunc(x,y,z=1)
2926 %bg myfunc(x,y,z=1)
2928
2927
2929 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2928 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2930 execution starts, a message will be printed indicating the job
2929 execution starts, a message will be printed indicating the job
2931 number. If your job number is 5, you can use
2930 number. If your job number is 5, you can use
2932
2931
2933 myvar = jobs.result(5) or myvar = jobs[5].result
2932 myvar = jobs.result(5) or myvar = jobs[5].result
2934
2933
2935 to assign this result to variable 'myvar'.
2934 to assign this result to variable 'myvar'.
2936
2935
2937 IPython has a job manager, accessible via the 'jobs' object. You can
2936 IPython has a job manager, accessible via the 'jobs' object. You can
2938 type jobs? to get more information about it, and use jobs.<TAB> to see
2937 type jobs? to get more information about it, and use jobs.<TAB> to see
2939 its attributes. All attributes not starting with an underscore are
2938 its attributes. All attributes not starting with an underscore are
2940 meant for public use.
2939 meant for public use.
2941
2940
2942 In particular, look at the jobs.new() method, which is used to create
2941 In particular, look at the jobs.new() method, which is used to create
2943 new jobs. This magic %bg function is just a convenience wrapper
2942 new jobs. This magic %bg function is just a convenience wrapper
2944 around jobs.new(), for expression-based jobs. If you want to create a
2943 around jobs.new(), for expression-based jobs. If you want to create a
2945 new job with an explicit function object and arguments, you must call
2944 new job with an explicit function object and arguments, you must call
2946 jobs.new() directly.
2945 jobs.new() directly.
2947
2946
2948 The jobs.new docstring also describes in detail several important
2947 The jobs.new docstring also describes in detail several important
2949 caveats associated with a thread-based model for background job
2948 caveats associated with a thread-based model for background job
2950 execution. Type jobs.new? for details.
2949 execution. Type jobs.new? for details.
2951
2950
2952 You can check the status of all jobs with jobs.status().
2951 You can check the status of all jobs with jobs.status().
2953
2952
2954 The jobs variable is set by IPython into the Python builtin namespace.
2953 The jobs variable is set by IPython into the Python builtin namespace.
2955 If you ever declare a variable named 'jobs', you will shadow this
2954 If you ever declare a variable named 'jobs', you will shadow this
2956 name. You can either delete your global jobs variable to regain
2955 name. You can either delete your global jobs variable to regain
2957 access to the job manager, or make a new name and assign it manually
2956 access to the job manager, or make a new name and assign it manually
2958 to the manager (stored in IPython's namespace). For example, to
2957 to the manager (stored in IPython's namespace). For example, to
2959 assign the job manager to the Jobs name, use:
2958 assign the job manager to the Jobs name, use:
2960
2959
2961 Jobs = __builtins__.jobs"""
2960 Jobs = __builtins__.jobs"""
2962
2961
2963 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2962 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2964
2963
2965
2964
2966 def magic_bookmark(self, parameter_s=''):
2965 def magic_bookmark(self, parameter_s=''):
2967 """Manage IPython's bookmark system.
2966 """Manage IPython's bookmark system.
2968
2967
2969 %bookmark <name> - set bookmark to current dir
2968 %bookmark <name> - set bookmark to current dir
2970 %bookmark <name> <dir> - set bookmark to <dir>
2969 %bookmark <name> <dir> - set bookmark to <dir>
2971 %bookmark -l - list all bookmarks
2970 %bookmark -l - list all bookmarks
2972 %bookmark -d <name> - remove bookmark
2971 %bookmark -d <name> - remove bookmark
2973 %bookmark -r - remove all bookmarks
2972 %bookmark -r - remove all bookmarks
2974
2973
2975 You can later on access a bookmarked folder with:
2974 You can later on access a bookmarked folder with:
2976 %cd -b <name>
2975 %cd -b <name>
2977 or simply '%cd <name>' if there is no directory called <name> AND
2976 or simply '%cd <name>' if there is no directory called <name> AND
2978 there is such a bookmark defined.
2977 there is such a bookmark defined.
2979
2978
2980 Your bookmarks persist through IPython sessions, but they are
2979 Your bookmarks persist through IPython sessions, but they are
2981 associated with each profile."""
2980 associated with each profile."""
2982
2981
2983 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2982 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2984 if len(args) > 2:
2983 if len(args) > 2:
2985 error('You can only give at most two arguments')
2984 error('You can only give at most two arguments')
2986 return
2985 return
2987
2986
2988 bkms = self.db.get('bookmarks',{})
2987 bkms = self.db.get('bookmarks',{})
2989
2988
2990 if opts.has_key('d'):
2989 if opts.has_key('d'):
2991 try:
2990 try:
2992 todel = args[0]
2991 todel = args[0]
2993 except IndexError:
2992 except IndexError:
2994 error('You must provide a bookmark to delete')
2993 error('You must provide a bookmark to delete')
2995 else:
2994 else:
2996 try:
2995 try:
2997 del bkms[todel]
2996 del bkms[todel]
2998 except:
2997 except:
2999 error("Can't delete bookmark '%s'" % todel)
2998 error("Can't delete bookmark '%s'" % todel)
3000 elif opts.has_key('r'):
2999 elif opts.has_key('r'):
3001 bkms = {}
3000 bkms = {}
3002 elif opts.has_key('l'):
3001 elif opts.has_key('l'):
3003 bks = bkms.keys()
3002 bks = bkms.keys()
3004 bks.sort()
3003 bks.sort()
3005 if bks:
3004 if bks:
3006 size = max(map(len,bks))
3005 size = max(map(len,bks))
3007 else:
3006 else:
3008 size = 0
3007 size = 0
3009 fmt = '%-'+str(size)+'s -> %s'
3008 fmt = '%-'+str(size)+'s -> %s'
3010 print 'Current bookmarks:'
3009 print 'Current bookmarks:'
3011 for bk in bks:
3010 for bk in bks:
3012 print fmt % (bk,bkms[bk])
3011 print fmt % (bk,bkms[bk])
3013 else:
3012 else:
3014 if not args:
3013 if not args:
3015 error("You must specify the bookmark name")
3014 error("You must specify the bookmark name")
3016 elif len(args)==1:
3015 elif len(args)==1:
3017 bkms[args[0]] = os.getcwd()
3016 bkms[args[0]] = os.getcwd()
3018 elif len(args)==2:
3017 elif len(args)==2:
3019 bkms[args[0]] = args[1]
3018 bkms[args[0]] = args[1]
3020 self.db['bookmarks'] = bkms
3019 self.db['bookmarks'] = bkms
3021
3020
3022 def magic_pycat(self, parameter_s=''):
3021 def magic_pycat(self, parameter_s=''):
3023 """Show a syntax-highlighted file through a pager.
3022 """Show a syntax-highlighted file through a pager.
3024
3023
3025 This magic is similar to the cat utility, but it will assume the file
3024 This magic is similar to the cat utility, but it will assume the file
3026 to be Python source and will show it with syntax highlighting. """
3025 to be Python source and will show it with syntax highlighting. """
3027
3026
3028 try:
3027 try:
3029 filename = get_py_filename(parameter_s)
3028 filename = get_py_filename(parameter_s)
3030 cont = file_read(filename)
3029 cont = file_read(filename)
3031 except IOError:
3030 except IOError:
3032 try:
3031 try:
3033 cont = eval(parameter_s,self.user_ns)
3032 cont = eval(parameter_s,self.user_ns)
3034 except NameError:
3033 except NameError:
3035 cont = None
3034 cont = None
3036 if cont is None:
3035 if cont is None:
3037 print "Error: no such file or variable"
3036 print "Error: no such file or variable"
3038 return
3037 return
3039
3038
3040 page(self.shell.pycolorize(cont),
3039 page(self.shell.pycolorize(cont),
3041 screen_lines=self.shell.rc.screen_length)
3040 screen_lines=self.shell.rc.screen_length)
3042
3041
3043 def magic_cpaste(self, parameter_s=''):
3042 def magic_cpaste(self, parameter_s=''):
3044 """Allows you to paste & execute a pre-formatted code block from clipboard
3043 """Allows you to paste & execute a pre-formatted code block from clipboard
3045
3044
3046 You must terminate the block with '--' (two minus-signs) alone on the
3045 You must terminate the block with '--' (two minus-signs) alone on the
3047 line. You can also provide your own sentinel with '%paste -s %%' ('%%'
3046 line. You can also provide your own sentinel with '%paste -s %%' ('%%'
3048 is the new sentinel for this operation)
3047 is the new sentinel for this operation)
3049
3048
3050 The block is dedented prior to execution to enable execution of
3049 The block is dedented prior to execution to enable execution of
3051 method definitions. '>' characters at the beginning of a line is
3050 method definitions. '>' characters at the beginning of a line is
3052 ignored, to allow pasting directly from e-mails. The executed block
3051 ignored, to allow pasting directly from e-mails. The executed block
3053 is also assigned to variable named 'pasted_block' for later editing
3052 is also assigned to variable named 'pasted_block' for later editing
3054 with '%edit pasted_block'.
3053 with '%edit pasted_block'.
3055
3054
3056 You can also pass a variable name as an argument, e.g. '%cpaste foo'.
3055 You can also pass a variable name as an argument, e.g. '%cpaste foo'.
3057 This assigns the pasted block to variable 'foo' as string, without
3056 This assigns the pasted block to variable 'foo' as string, without
3058 dedenting or executing it.
3057 dedenting or executing it.
3059
3058
3060 Do not be alarmed by garbled output on Windows (it's a readline bug).
3059 Do not be alarmed by garbled output on Windows (it's a readline bug).
3061 Just press enter and type -- (and press enter again) and the block
3060 Just press enter and type -- (and press enter again) and the block
3062 will be what was just pasted.
3061 will be what was just pasted.
3063
3062
3064 IPython statements (magics, shell escapes) are not supported (yet).
3063 IPython statements (magics, shell escapes) are not supported (yet).
3065 """
3064 """
3066 opts,args = self.parse_options(parameter_s,'s:',mode='string')
3065 opts,args = self.parse_options(parameter_s,'s:',mode='string')
3067 par = args.strip()
3066 par = args.strip()
3068 sentinel = opts.get('s','--')
3067 sentinel = opts.get('s','--')
3069
3068
3070 from IPython import iplib
3069 from IPython import iplib
3071 lines = []
3070 lines = []
3072 print "Pasting code; enter '%s' alone on the line to stop." % sentinel
3071 print "Pasting code; enter '%s' alone on the line to stop." % sentinel
3073 while 1:
3072 while 1:
3074 l = iplib.raw_input_original(':')
3073 l = iplib.raw_input_original(':')
3075 if l ==sentinel:
3074 if l ==sentinel:
3076 break
3075 break
3077 lines.append(l.lstrip('>'))
3076 lines.append(l.lstrip('>'))
3078 block = "\n".join(lines) + '\n'
3077 block = "\n".join(lines) + '\n'
3079 #print "block:\n",block
3078 #print "block:\n",block
3080 if not par:
3079 if not par:
3081 b = textwrap.dedent(block)
3080 b = textwrap.dedent(block)
3082 exec b in self.user_ns
3081 exec b in self.user_ns
3083 self.user_ns['pasted_block'] = b
3082 self.user_ns['pasted_block'] = b
3084 else:
3083 else:
3085 self.user_ns[par] = block
3084 self.user_ns[par] = block
3086 print "Block assigned to '%s'" % par
3085 print "Block assigned to '%s'" % par
3087
3086
3088 def magic_quickref(self,arg):
3087 def magic_quickref(self,arg):
3089 """ Show a quick reference sheet """
3088 """ Show a quick reference sheet """
3090 import IPython.usage
3089 import IPython.usage
3091 qr = IPython.usage.quick_reference + self.magic_magic('-brief')
3090 qr = IPython.usage.quick_reference + self.magic_magic('-brief')
3092
3091
3093 page(qr)
3092 page(qr)
3094
3093
3095 def magic_upgrade(self,arg):
3094 def magic_upgrade(self,arg):
3096 """ Upgrade your IPython installation
3095 """ Upgrade your IPython installation
3097
3096
3098 This will copy the config files that don't yet exist in your
3097 This will copy the config files that don't yet exist in your
3099 ipython dir from the system config dir. Use this after upgrading
3098 ipython dir from the system config dir. Use this after upgrading
3100 IPython if you don't wish to delete your .ipython dir.
3099 IPython if you don't wish to delete your .ipython dir.
3101
3100
3102 Call with -nolegacy to get rid of ipythonrc* files (recommended for
3101 Call with -nolegacy to get rid of ipythonrc* files (recommended for
3103 new users)
3102 new users)
3104
3103
3105 """
3104 """
3106 ip = self.getapi()
3105 ip = self.getapi()
3107 ipinstallation = path(IPython.__file__).dirname()
3106 ipinstallation = path(IPython.__file__).dirname()
3108 upgrade_script = '%s "%s"' % (sys.executable,ipinstallation / 'upgrade_dir.py')
3107 upgrade_script = '%s "%s"' % (sys.executable,ipinstallation / 'upgrade_dir.py')
3109 src_config = ipinstallation / 'UserConfig'
3108 src_config = ipinstallation / 'UserConfig'
3110 userdir = path(ip.options.ipythondir)
3109 userdir = path(ip.options.ipythondir)
3111 cmd = '%s "%s" "%s"' % (upgrade_script, src_config, userdir)
3110 cmd = '%s "%s" "%s"' % (upgrade_script, src_config, userdir)
3112 print ">",cmd
3111 print ">",cmd
3113 shell(cmd)
3112 shell(cmd)
3114 if arg == '-nolegacy':
3113 if arg == '-nolegacy':
3115 legacy = userdir.files('ipythonrc*')
3114 legacy = userdir.files('ipythonrc*')
3116 print "Nuking legacy files:",legacy
3115 print "Nuking legacy files:",legacy
3117
3116
3118 [p.remove() for p in legacy]
3117 [p.remove() for p in legacy]
3119 suffix = (sys.platform == 'win32' and '.ini' or '')
3118 suffix = (sys.platform == 'win32' and '.ini' or '')
3120 (userdir / ('ipythonrc' + suffix)).write_text('# Empty, see ipy_user_conf.py\n')
3119 (userdir / ('ipythonrc' + suffix)).write_text('# Empty, see ipy_user_conf.py\n')
3121
3120
3122 # end Magic
3121 # end Magic
@@ -1,281 +1,282 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 Class and program to colorize python source code for ANSI terminals.
3 Class and program to colorize python source code for ANSI terminals.
4
4
5 Based on an HTML code highlighter by Jurgen Hermann found at:
5 Based on an HTML code highlighter by Jurgen Hermann found at:
6 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52298
6 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52298
7
7
8 Modifications by Fernando Perez (fperez@colorado.edu).
8 Modifications by Fernando Perez (fperez@colorado.edu).
9
9
10 Information on the original HTML highlighter follows:
10 Information on the original HTML highlighter follows:
11
11
12 MoinMoin - Python Source Parser
12 MoinMoin - Python Source Parser
13
13
14 Title:olorize Python source using the built-in tokenizer
14 Title:olorize Python source using the built-in tokenizer
15
15
16 Submitter: Jurgen Hermann
16 Submitter: Jurgen Hermann
17 Last Updated:2001/04/06
17 Last Updated:2001/04/06
18
18
19 Version no:1.2
19 Version no:1.2
20
20
21 Description:
21 Description:
22
22
23 This code is part of MoinMoin (http://moin.sourceforge.net/) and converts
23 This code is part of MoinMoin (http://moin.sourceforge.net/) and converts
24 Python source code to HTML markup, rendering comments, keywords,
24 Python source code to HTML markup, rendering comments, keywords,
25 operators, numeric and string literals in different colors.
25 operators, numeric and string literals in different colors.
26
26
27 It shows how to use the built-in keyword, token and tokenize modules to
27 It shows how to use the built-in keyword, token and tokenize modules to
28 scan Python source code and re-emit it with no changes to its original
28 scan Python source code and re-emit it with no changes to its original
29 formatting (which is the hard part).
29 formatting (which is the hard part).
30
30
31 $Id: PyColorize.py 2205 2007-04-04 06:04:01Z fperez $"""
31 $Id: PyColorize.py 2225 2007-04-08 02:48:16Z jdh2358 $"""
32
32
33 __all__ = ['ANSICodeColors','Parser']
33 __all__ = ['ANSICodeColors','Parser']
34
34
35 _scheme_default = 'Linux'
35 _scheme_default = 'Linux'
36
36
37 # Imports
37 # Imports
38 import cStringIO
38 import cStringIO
39 import keyword
39 import keyword
40 import os
40 import os
41 import string
41 import string
42 import sys
42 import sys
43 import token
43 import token
44 import tokenize
44 import tokenize
45
45
46 from IPython.ColorANSI import *
46 from IPython.ColorANSI import *
47
47
48 #############################################################################
48 #############################################################################
49 ### Python Source Parser (does Hilighting)
49 ### Python Source Parser (does Hilighting)
50 #############################################################################
50 #############################################################################
51
51
52 _KEYWORD = token.NT_OFFSET + 1
52 _KEYWORD = token.NT_OFFSET + 1
53 _TEXT = token.NT_OFFSET + 2
53 _TEXT = token.NT_OFFSET + 2
54
54
55 #****************************************************************************
55 #****************************************************************************
56 # Builtin color schemes
56 # Builtin color schemes
57
57
58 Colors = TermColors # just a shorthand
58 Colors = TermColors # just a shorthand
59
59
60 # Build a few color schemes
60 # Build a few color schemes
61 NoColor = ColorScheme(
61 NoColor = ColorScheme(
62 'NoColor',{
62 'NoColor',{
63 token.NUMBER : Colors.NoColor,
63 token.NUMBER : Colors.NoColor,
64 token.OP : Colors.NoColor,
64 token.OP : Colors.NoColor,
65 token.STRING : Colors.NoColor,
65 token.STRING : Colors.NoColor,
66 tokenize.COMMENT : Colors.NoColor,
66 tokenize.COMMENT : Colors.NoColor,
67 token.NAME : Colors.NoColor,
67 token.NAME : Colors.NoColor,
68 token.ERRORTOKEN : Colors.NoColor,
68 token.ERRORTOKEN : Colors.NoColor,
69
69
70 _KEYWORD : Colors.NoColor,
70 _KEYWORD : Colors.NoColor,
71 _TEXT : Colors.NoColor,
71 _TEXT : Colors.NoColor,
72
72
73 'normal' : Colors.NoColor # color off (usu. Colors.Normal)
73 'normal' : Colors.NoColor # color off (usu. Colors.Normal)
74 } )
74 } )
75
75
76 LinuxColors = ColorScheme(
76 LinuxColors = ColorScheme(
77 'Linux',{
77 'Linux',{
78 token.NUMBER : Colors.LightCyan,
78 token.NUMBER : Colors.LightCyan,
79 token.OP : Colors.Yellow,
79 token.OP : Colors.Yellow,
80 token.STRING : Colors.LightBlue,
80 token.STRING : Colors.LightBlue,
81 tokenize.COMMENT : Colors.LightRed,
81 tokenize.COMMENT : Colors.LightRed,
82 token.NAME : Colors.White,
82 token.NAME : Colors.White,
83 token.ERRORTOKEN : Colors.Red,
83 token.ERRORTOKEN : Colors.Red,
84
84
85 _KEYWORD : Colors.LightGreen,
85 _KEYWORD : Colors.LightGreen,
86 _TEXT : Colors.Yellow,
86 _TEXT : Colors.Yellow,
87
87
88 'normal' : Colors.Normal # color off (usu. Colors.Normal)
88 'normal' : Colors.Normal # color off (usu. Colors.Normal)
89 } )
89 } )
90
90
91 LightBGColors = ColorScheme(
91 LightBGColors = ColorScheme(
92 'LightBG',{
92 'LightBG',{
93 token.NUMBER : Colors.Cyan,
93 token.NUMBER : Colors.Cyan,
94 token.OP : Colors.Blue,
94 token.OP : Colors.Blue,
95 token.STRING : Colors.Blue,
95 token.STRING : Colors.Blue,
96 tokenize.COMMENT : Colors.Red,
96 tokenize.COMMENT : Colors.Red,
97 token.NAME : Colors.Black,
97 token.NAME : Colors.Black,
98 token.ERRORTOKEN : Colors.Red,
98 token.ERRORTOKEN : Colors.Red,
99
99
100 _KEYWORD : Colors.Green,
100 _KEYWORD : Colors.Green,
101 _TEXT : Colors.Blue,
101 _TEXT : Colors.Blue,
102
102
103 'normal' : Colors.Normal # color off (usu. Colors.Normal)
103 'normal' : Colors.Normal # color off (usu. Colors.Normal)
104 } )
104 } )
105
105
106 # Build table of color schemes (needed by the parser)
106 # Build table of color schemes (needed by the parser)
107 ANSICodeColors = ColorSchemeTable([NoColor,LinuxColors,LightBGColors],
107 ANSICodeColors = ColorSchemeTable([NoColor,LinuxColors,LightBGColors],
108 _scheme_default)
108 _scheme_default)
109
109
110 class Parser:
110 class Parser:
111 """ Format colored Python source.
111 """ Format colored Python source.
112 """
112 """
113
113
114 def __init__(self, color_table=None,out = sys.stdout):
114 def __init__(self, color_table=None,out = sys.stdout):
115 """ Create a parser with a specified color table and output channel.
115 """ Create a parser with a specified color table and output channel.
116
116
117 Call format() to process code.
117 Call format() to process code.
118 """
118 """
119 self.color_table = color_table and color_table or ANSICodeColors
119 self.color_table = color_table and color_table or ANSICodeColors
120 self.out = out
120 self.out = out
121
121
122 def format(self, raw, out = None, scheme = ''):
122 def format(self, raw, out = None, scheme = ''):
123 return self.format2(raw, out, scheme)[0]
123 return self.format2(raw, out, scheme)[0]
124
124
125 def format2(self, raw, out = None, scheme = ''):
125 def format2(self, raw, out = None, scheme = ''):
126 """ Parse and send the colored source.
126 """ Parse and send the colored source.
127
127
128 If out and scheme are not specified, the defaults (given to
128 If out and scheme are not specified, the defaults (given to
129 constructor) are used.
129 constructor) are used.
130
130
131 out should be a file-type object. Optionally, out can be given as the
131 out should be a file-type object. Optionally, out can be given as the
132 string 'str' and the parser will automatically return the output in a
132 string 'str' and the parser will automatically return the output in a
133 string."""
133 string."""
134
134
135 string_output = 0
135 string_output = 0
136 if out == 'str' or self.out == 'str':
136 if out == 'str' or self.out == 'str':
137 out_old = self.out
137 out_old = self.out
138 self.out = cStringIO.StringIO()
138 self.out = cStringIO.StringIO()
139 string_output = 1
139 string_output = 1
140 elif out is not None:
140 elif out is not None:
141 self.out = out
141 self.out = out
142
142
143 # Fast return of the unmodified input for NoColor scheme
143 # Fast return of the unmodified input for NoColor scheme
144 if scheme == 'NoColor':
144 if scheme == 'NoColor':
145 error = False
145 error = False
146 self.out.write(raw)
146 self.out.write(raw)
147 if string_output:
147 if string_output:
148 return raw,error
148 return raw,error
149 else:
149 else:
150 return None,error
150 return None,error
151
151
152 # local shorthands
152 # local shorthands
153 colors = self.color_table[scheme].colors
153 colors = self.color_table[scheme].colors
154 self.colors = colors # put in object so __call__ sees it
154 self.colors = colors # put in object so __call__ sees it
155
155
156 # Remove trailing whitespace and normalize tabs
156 # Remove trailing whitespace and normalize tabs
157 self.raw = raw.expandtabs().rstrip()
157 self.raw = raw.expandtabs().rstrip()
158
158 # store line offsets in self.lines
159 # store line offsets in self.lines
159 self.lines = [0, 0]
160 self.lines = [0, 0]
160 pos = 0
161 pos = 0
161 raw_find = raw.find
162 raw_find = self.raw.find
162 lines_append = self.lines.append
163 lines_append = self.lines.append
163 while 1:
164 while 1:
164 pos = raw_find('\n', pos) + 1
165 pos = raw_find('\n', pos) + 1
165 if not pos: break
166 if not pos: break
166 lines_append(pos)
167 lines_append(pos)
167 lines_append(len(self.raw))
168 lines_append(len(self.raw))
168
169
169 # parse the source and write it
170 # parse the source and write it
170 self.pos = 0
171 self.pos = 0
171 text = cStringIO.StringIO(self.raw)
172 text = cStringIO.StringIO(self.raw)
172
173
173 error = False
174 error = False
174 try:
175 try:
175 tokenize.tokenize(text.readline, self)
176 tokenize.tokenize(text.readline, self)
176 except tokenize.TokenError, ex:
177 except tokenize.TokenError, ex:
177 msg = ex[0]
178 msg = ex[0]
178 line = ex[1][0]
179 line = ex[1][0]
179 self.out.write("%s\n\n*** ERROR: %s%s%s\n" %
180 self.out.write("%s\n\n*** ERROR: %s%s%s\n" %
180 (colors[token.ERRORTOKEN],
181 (colors[token.ERRORTOKEN],
181 msg, self.raw[self.lines[line]:],
182 msg, self.raw[self.lines[line]:],
182 colors.normal)
183 colors.normal)
183 )
184 )
184 error = True
185 error = True
185 self.out.write(colors.normal+'\n')
186 self.out.write(colors.normal+'\n')
186 if string_output:
187 if string_output:
187 output = self.out.getvalue()
188 output = self.out.getvalue()
188 self.out = out_old
189 self.out = out_old
189 return (output, error)
190 return (output, error)
190 return (None, error)
191 return (None, error)
191
192
192 def __call__(self, toktype, toktext, (srow,scol), (erow,ecol), line):
193 def __call__(self, toktype, toktext, (srow,scol), (erow,ecol), line):
193 """ Token handler, with syntax highlighting."""
194 """ Token handler, with syntax highlighting."""
194
195
195 # local shorthands
196 # local shorthands
196 colors = self.colors
197 colors = self.colors
197 owrite = self.out.write
198 owrite = self.out.write
198
199
199 # line separator, so this works across platforms
200 # line separator, so this works across platforms
200 linesep = os.linesep
201 linesep = os.linesep
201
202
202 # calculate new positions
203 # calculate new positions
203 oldpos = self.pos
204 oldpos = self.pos
204 newpos = self.lines[srow] + scol
205 newpos = self.lines[srow] + scol
205 self.pos = newpos + len(toktext)
206 self.pos = newpos + len(toktext)
206
207
207 # handle newlines
208 # handle newlines
208 if toktype in [token.NEWLINE, tokenize.NL]:
209 if toktype in [token.NEWLINE, tokenize.NL]:
209 owrite(linesep)
210 owrite(linesep)
210 return
211 return
211
212
212 # send the original whitespace, if needed
213 # send the original whitespace, if needed
213 if newpos > oldpos:
214 if newpos > oldpos:
214 owrite(self.raw[oldpos:newpos])
215 owrite(self.raw[oldpos:newpos])
215
216
216 # skip indenting tokens
217 # skip indenting tokens
217 if toktype in [token.INDENT, token.DEDENT]:
218 if toktype in [token.INDENT, token.DEDENT]:
218 self.pos = newpos
219 self.pos = newpos
219 return
220 return
220
221
221 # map token type to a color group
222 # map token type to a color group
222 if token.LPAR <= toktype and toktype <= token.OP:
223 if token.LPAR <= toktype and toktype <= token.OP:
223 toktype = token.OP
224 toktype = token.OP
224 elif toktype == token.NAME and keyword.iskeyword(toktext):
225 elif toktype == token.NAME and keyword.iskeyword(toktext):
225 toktype = _KEYWORD
226 toktype = _KEYWORD
226 color = colors.get(toktype, colors[_TEXT])
227 color = colors.get(toktype, colors[_TEXT])
227
228
228 #print '<%s>' % toktext, # dbg
229 #print '<%s>' % toktext, # dbg
229
230
230 # Triple quoted strings must be handled carefully so that backtracking
231 # Triple quoted strings must be handled carefully so that backtracking
231 # in pagers works correctly. We need color terminators on _each_ line.
232 # in pagers works correctly. We need color terminators on _each_ line.
232 if linesep in toktext:
233 if linesep in toktext:
233 toktext = toktext.replace(linesep, '%s%s%s' %
234 toktext = toktext.replace(linesep, '%s%s%s' %
234 (colors.normal,linesep,color))
235 (colors.normal,linesep,color))
235
236
236 # send text
237 # send text
237 owrite('%s%s%s' % (color,toktext,colors.normal))
238 owrite('%s%s%s' % (color,toktext,colors.normal))
238
239
239 def main():
240 def main():
240 """Colorize a python file using ANSI color escapes and print to stdout.
241 """Colorize a python file using ANSI color escapes and print to stdout.
241
242
242 Usage:
243 Usage:
243 %s [-s scheme] filename
244 %s [-s scheme] filename
244
245
245 Options:
246 Options:
246
247
247 -s scheme: give the color scheme to use. Currently only 'Linux'
248 -s scheme: give the color scheme to use. Currently only 'Linux'
248 (default) and 'LightBG' and 'NoColor' are implemented (give without
249 (default) and 'LightBG' and 'NoColor' are implemented (give without
249 quotes). """
250 quotes). """
250
251
251 def usage():
252 def usage():
252 print >> sys.stderr, main.__doc__ % sys.argv[0]
253 print >> sys.stderr, main.__doc__ % sys.argv[0]
253 sys.exit(1)
254 sys.exit(1)
254
255
255 # FIXME: rewrite this to at least use getopt
256 # FIXME: rewrite this to at least use getopt
256 try:
257 try:
257 if sys.argv[1] == '-s':
258 if sys.argv[1] == '-s':
258 scheme_name = sys.argv[2]
259 scheme_name = sys.argv[2]
259 del sys.argv[1:3]
260 del sys.argv[1:3]
260 else:
261 else:
261 scheme_name = _scheme_default
262 scheme_name = _scheme_default
262
263
263 except:
264 except:
264 usage()
265 usage()
265
266
266 try:
267 try:
267 fname = sys.argv[1]
268 fname = sys.argv[1]
268 except:
269 except:
269 usage()
270 usage()
270
271
271 # write colorized version to stdout
272 # write colorized version to stdout
272 parser = Parser()
273 parser = Parser()
273 try:
274 try:
274 parser.format(file(fname).read(),scheme = scheme_name)
275 parser.format(file(fname).read(),scheme = scheme_name)
275 except IOError,msg:
276 except IOError,msg:
276 # if user reads through a pager and quits, don't print traceback
277 # if user reads through a pager and quits, don't print traceback
277 if msg.args != (32,'Broken pipe'):
278 if msg.args != (32,'Broken pipe'):
278 raise
279 raise
279
280
280 if __name__ == "__main__":
281 if __name__ == "__main__":
281 main()
282 main()
@@ -1,2599 +1,2611 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 IPython -- An enhanced Interactive Python
3 IPython -- An enhanced Interactive Python
4
4
5 Requires Python 2.3 or newer.
5 Requires Python 2.3 or newer.
6
6
7 This file contains all the classes and helper functions specific to IPython.
7 This file contains all the classes and helper functions specific to IPython.
8
8
9 $Id: iplib.py 2221 2007-04-06 02:58:37Z fperez $
9 $Id: iplib.py 2225 2007-04-08 02:48:16Z jdh2358 $
10 """
10 """
11
11
12 #*****************************************************************************
12 #*****************************************************************************
13 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
13 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
14 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
14 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
15 #
15 #
16 # Distributed under the terms of the BSD License. The full license is in
16 # Distributed under the terms of the BSD License. The full license is in
17 # the file COPYING, distributed as part of this software.
17 # the file COPYING, distributed as part of this software.
18 #
18 #
19 # Note: this code originally subclassed code.InteractiveConsole from the
19 # Note: this code originally subclassed code.InteractiveConsole from the
20 # Python standard library. Over time, all of that class has been copied
20 # Python standard library. Over time, all of that class has been copied
21 # verbatim here for modifications which could not be accomplished by
21 # verbatim here for modifications which could not be accomplished by
22 # subclassing. At this point, there are no dependencies at all on the code
22 # subclassing. At this point, there are no dependencies at all on the code
23 # module anymore (it is not even imported). The Python License (sec. 2)
23 # module anymore (it is not even imported). The Python License (sec. 2)
24 # allows for this, but it's always nice to acknowledge credit where credit is
24 # allows for this, but it's always nice to acknowledge credit where credit is
25 # due.
25 # due.
26 #*****************************************************************************
26 #*****************************************************************************
27
27
28 #****************************************************************************
28 #****************************************************************************
29 # Modules and globals
29 # Modules and globals
30
30
31 from IPython import Release
31 from IPython import Release
32 __author__ = '%s <%s>\n%s <%s>' % \
32 __author__ = '%s <%s>\n%s <%s>' % \
33 ( Release.authors['Janko'] + Release.authors['Fernando'] )
33 ( Release.authors['Janko'] + Release.authors['Fernando'] )
34 __license__ = Release.license
34 __license__ = Release.license
35 __version__ = Release.version
35 __version__ = Release.version
36
36
37 # Python standard modules
37 # Python standard modules
38 import __main__
38 import __main__
39 import __builtin__
39 import __builtin__
40 import StringIO
40 import StringIO
41 import bdb
41 import bdb
42 import cPickle as pickle
42 import cPickle as pickle
43 import codeop
43 import codeop
44 import exceptions
44 import exceptions
45 import glob
45 import glob
46 import inspect
46 import inspect
47 import keyword
47 import keyword
48 import new
48 import new
49 import os
49 import os
50 import pydoc
50 import pydoc
51 import re
51 import re
52 import shutil
52 import shutil
53 import string
53 import string
54 import sys
54 import sys
55 import tempfile
55 import tempfile
56 import traceback
56 import traceback
57 import types
57 import types
58 import pickleshare
58 import pickleshare
59 from sets import Set
59 from sets import Set
60 from pprint import pprint, pformat
60 from pprint import pprint, pformat
61
61
62 # IPython's own modules
62 # IPython's own modules
63 import IPython
63 import IPython
64 from IPython import Debugger,OInspect,PyColorize,ultraTB
64 from IPython import Debugger,OInspect,PyColorize,ultraTB
65 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
65 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
66 from IPython.FakeModule import FakeModule
66 from IPython.FakeModule import FakeModule
67 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
67 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
68 from IPython.Logger import Logger
68 from IPython.Logger import Logger
69 from IPython.Magic import Magic
69 from IPython.Magic import Magic
70 from IPython.Prompts import CachedOutput
70 from IPython.Prompts import CachedOutput
71 from IPython.ipstruct import Struct
71 from IPython.ipstruct import Struct
72 from IPython.background_jobs import BackgroundJobManager
72 from IPython.background_jobs import BackgroundJobManager
73 from IPython.usage import cmd_line_usage,interactive_usage
73 from IPython.usage import cmd_line_usage,interactive_usage
74 from IPython.genutils import *
74 from IPython.genutils import *
75 from IPython.strdispatch import StrDispatch
75 from IPython.strdispatch import StrDispatch
76 import IPython.ipapi
76 import IPython.ipapi
77
77
78 # Globals
78 # Globals
79
79
80 # store the builtin raw_input globally, and use this always, in case user code
80 # store the builtin raw_input globally, and use this always, in case user code
81 # overwrites it (like wx.py.PyShell does)
81 # overwrites it (like wx.py.PyShell does)
82 raw_input_original = raw_input
82 raw_input_original = raw_input
83
83
84 # compiled regexps for autoindent management
84 # compiled regexps for autoindent management
85 dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass')
85 dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass')
86
86
87
87
88 #****************************************************************************
88 #****************************************************************************
89 # Some utility function definitions
89 # Some utility function definitions
90
90
91 ini_spaces_re = re.compile(r'^(\s+)')
91 ini_spaces_re = re.compile(r'^(\s+)')
92
92
93 def num_ini_spaces(strng):
93 def num_ini_spaces(strng):
94 """Return the number of initial spaces in a string"""
94 """Return the number of initial spaces in a string"""
95
95
96 ini_spaces = ini_spaces_re.match(strng)
96 ini_spaces = ini_spaces_re.match(strng)
97 if ini_spaces:
97 if ini_spaces:
98 return ini_spaces.end()
98 return ini_spaces.end()
99 else:
99 else:
100 return 0
100 return 0
101
101
102 def softspace(file, newvalue):
102 def softspace(file, newvalue):
103 """Copied from code.py, to remove the dependency"""
103 """Copied from code.py, to remove the dependency"""
104
104
105 oldvalue = 0
105 oldvalue = 0
106 try:
106 try:
107 oldvalue = file.softspace
107 oldvalue = file.softspace
108 except AttributeError:
108 except AttributeError:
109 pass
109 pass
110 try:
110 try:
111 file.softspace = newvalue
111 file.softspace = newvalue
112 except (AttributeError, TypeError):
112 except (AttributeError, TypeError):
113 # "attribute-less object" or "read-only attributes"
113 # "attribute-less object" or "read-only attributes"
114 pass
114 pass
115 return oldvalue
115 return oldvalue
116
116
117
117
118 #****************************************************************************
118 #****************************************************************************
119 # Local use exceptions
119 # Local use exceptions
120 class SpaceInInput(exceptions.Exception): pass
120 class SpaceInInput(exceptions.Exception): pass
121
121
122
122
123 #****************************************************************************
123 #****************************************************************************
124 # Local use classes
124 # Local use classes
125 class Bunch: pass
125 class Bunch: pass
126
126
127 class Undefined: pass
127 class Undefined: pass
128
128
129 class Quitter(object):
129 class Quitter(object):
130 """Simple class to handle exit, similar to Python 2.5's.
130 """Simple class to handle exit, similar to Python 2.5's.
131
131
132 It handles exiting in an ipython-safe manner, which the one in Python 2.5
132 It handles exiting in an ipython-safe manner, which the one in Python 2.5
133 doesn't do (obviously, since it doesn't know about ipython)."""
133 doesn't do (obviously, since it doesn't know about ipython)."""
134
134
135 def __init__(self,shell,name):
135 def __init__(self,shell,name):
136 self.shell = shell
136 self.shell = shell
137 self.name = name
137 self.name = name
138
138
139 def __repr__(self):
139 def __repr__(self):
140 return 'Type %s() to exit.' % self.name
140 return 'Type %s() to exit.' % self.name
141 __str__ = __repr__
141 __str__ = __repr__
142
142
143 def __call__(self):
143 def __call__(self):
144 self.shell.exit()
144 self.shell.exit()
145
145
146 class InputList(list):
146 class InputList(list):
147 """Class to store user input.
147 """Class to store user input.
148
148
149 It's basically a list, but slices return a string instead of a list, thus
149 It's basically a list, but slices return a string instead of a list, thus
150 allowing things like (assuming 'In' is an instance):
150 allowing things like (assuming 'In' is an instance):
151
151
152 exec In[4:7]
152 exec In[4:7]
153
153
154 or
154 or
155
155
156 exec In[5:9] + In[14] + In[21:25]"""
156 exec In[5:9] + In[14] + In[21:25]"""
157
157
158 def __getslice__(self,i,j):
158 def __getslice__(self,i,j):
159 return ''.join(list.__getslice__(self,i,j))
159 return ''.join(list.__getslice__(self,i,j))
160
160
161 class SyntaxTB(ultraTB.ListTB):
161 class SyntaxTB(ultraTB.ListTB):
162 """Extension which holds some state: the last exception value"""
162 """Extension which holds some state: the last exception value"""
163
163
164 def __init__(self,color_scheme = 'NoColor'):
164 def __init__(self,color_scheme = 'NoColor'):
165 ultraTB.ListTB.__init__(self,color_scheme)
165 ultraTB.ListTB.__init__(self,color_scheme)
166 self.last_syntax_error = None
166 self.last_syntax_error = None
167
167
168 def __call__(self, etype, value, elist):
168 def __call__(self, etype, value, elist):
169 self.last_syntax_error = value
169 self.last_syntax_error = value
170 ultraTB.ListTB.__call__(self,etype,value,elist)
170 ultraTB.ListTB.__call__(self,etype,value,elist)
171
171
172 def clear_err_state(self):
172 def clear_err_state(self):
173 """Return the current error state and clear it"""
173 """Return the current error state and clear it"""
174 e = self.last_syntax_error
174 e = self.last_syntax_error
175 self.last_syntax_error = None
175 self.last_syntax_error = None
176 return e
176 return e
177
177
178 #****************************************************************************
178 #****************************************************************************
179 # Main IPython class
179 # Main IPython class
180
180
181 # FIXME: the Magic class is a mixin for now, and will unfortunately remain so
181 # FIXME: the Magic class is a mixin for now, and will unfortunately remain so
182 # until a full rewrite is made. I've cleaned all cross-class uses of
182 # until a full rewrite is made. I've cleaned all cross-class uses of
183 # attributes and methods, but too much user code out there relies on the
183 # attributes and methods, but too much user code out there relies on the
184 # equlity %foo == __IP.magic_foo, so I can't actually remove the mixin usage.
184 # equlity %foo == __IP.magic_foo, so I can't actually remove the mixin usage.
185 #
185 #
186 # But at least now, all the pieces have been separated and we could, in
186 # But at least now, all the pieces have been separated and we could, in
187 # principle, stop using the mixin. This will ease the transition to the
187 # principle, stop using the mixin. This will ease the transition to the
188 # chainsaw branch.
188 # chainsaw branch.
189
189
190 # For reference, the following is the list of 'self.foo' uses in the Magic
190 # For reference, the following is the list of 'self.foo' uses in the Magic
191 # class as of 2005-12-28. These are names we CAN'T use in the main ipython
191 # class as of 2005-12-28. These are names we CAN'T use in the main ipython
192 # class, to prevent clashes.
192 # class, to prevent clashes.
193
193
194 # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind',
194 # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind',
195 # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic',
195 # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic',
196 # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell',
196 # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell',
197 # 'self.value']
197 # 'self.value']
198
198
199 class InteractiveShell(object,Magic):
199 class InteractiveShell(object,Magic):
200 """An enhanced console for Python."""
200 """An enhanced console for Python."""
201
201
202 # class attribute to indicate whether the class supports threads or not.
202 # class attribute to indicate whether the class supports threads or not.
203 # Subclasses with thread support should override this as needed.
203 # Subclasses with thread support should override this as needed.
204 isthreaded = False
204 isthreaded = False
205
205
206 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
206 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
207 user_ns = None,user_global_ns=None,banner2='',
207 user_ns = None,user_global_ns=None,banner2='',
208 custom_exceptions=((),None),embedded=False):
208 custom_exceptions=((),None),embedded=False):
209
209
210 # log system
210 # log system
211 self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate')
211 self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate')
212
212
213 # some minimal strict typechecks. For some core data structures, I
213 # some minimal strict typechecks. For some core data structures, I
214 # want actual basic python types, not just anything that looks like
214 # want actual basic python types, not just anything that looks like
215 # one. This is especially true for namespaces.
215 # one. This is especially true for namespaces.
216 for ns in (user_ns,user_global_ns):
216 for ns in (user_ns,user_global_ns):
217 if ns is not None and type(ns) != types.DictType:
217 if ns is not None and type(ns) != types.DictType:
218 raise TypeError,'namespace must be a dictionary'
218 raise TypeError,'namespace must be a dictionary'
219
219
220 # Job manager (for jobs run as background threads)
220 # Job manager (for jobs run as background threads)
221 self.jobs = BackgroundJobManager()
221 self.jobs = BackgroundJobManager()
222
222
223 # Store the actual shell's name
223 # Store the actual shell's name
224 self.name = name
224 self.name = name
225
225
226 # We need to know whether the instance is meant for embedding, since
226 # We need to know whether the instance is meant for embedding, since
227 # global/local namespaces need to be handled differently in that case
227 # global/local namespaces need to be handled differently in that case
228 self.embedded = embedded
228 self.embedded = embedded
229
229
230 # command compiler
230 # command compiler
231 self.compile = codeop.CommandCompiler()
231 self.compile = codeop.CommandCompiler()
232
232
233 # User input buffer
233 # User input buffer
234 self.buffer = []
234 self.buffer = []
235
235
236 # Default name given in compilation of code
236 # Default name given in compilation of code
237 self.filename = '<ipython console>'
237 self.filename = '<ipython console>'
238
238
239 # Install our own quitter instead of the builtins. For python2.3-2.4,
239 # Install our own quitter instead of the builtins. For python2.3-2.4,
240 # this brings in behavior like 2.5, and for 2.5 it's identical.
240 # this brings in behavior like 2.5, and for 2.5 it's identical.
241 __builtin__.exit = Quitter(self,'exit')
241 __builtin__.exit = Quitter(self,'exit')
242 __builtin__.quit = Quitter(self,'quit')
242 __builtin__.quit = Quitter(self,'quit')
243
243
244 # Make an empty namespace, which extension writers can rely on both
244 # Make an empty namespace, which extension writers can rely on both
245 # existing and NEVER being used by ipython itself. This gives them a
245 # existing and NEVER being used by ipython itself. This gives them a
246 # convenient location for storing additional information and state
246 # convenient location for storing additional information and state
247 # their extensions may require, without fear of collisions with other
247 # their extensions may require, without fear of collisions with other
248 # ipython names that may develop later.
248 # ipython names that may develop later.
249 self.meta = Struct()
249 self.meta = Struct()
250
250
251 # Create the namespace where the user will operate. user_ns is
251 # Create the namespace where the user will operate. user_ns is
252 # normally the only one used, and it is passed to the exec calls as
252 # normally the only one used, and it is passed to the exec calls as
253 # the locals argument. But we do carry a user_global_ns namespace
253 # the locals argument. But we do carry a user_global_ns namespace
254 # given as the exec 'globals' argument, This is useful in embedding
254 # given as the exec 'globals' argument, This is useful in embedding
255 # situations where the ipython shell opens in a context where the
255 # situations where the ipython shell opens in a context where the
256 # distinction between locals and globals is meaningful.
256 # distinction between locals and globals is meaningful.
257
257
258 # FIXME. For some strange reason, __builtins__ is showing up at user
258 # FIXME. For some strange reason, __builtins__ is showing up at user
259 # level as a dict instead of a module. This is a manual fix, but I
259 # level as a dict instead of a module. This is a manual fix, but I
260 # should really track down where the problem is coming from. Alex
260 # should really track down where the problem is coming from. Alex
261 # Schmolck reported this problem first.
261 # Schmolck reported this problem first.
262
262
263 # A useful post by Alex Martelli on this topic:
263 # A useful post by Alex Martelli on this topic:
264 # Re: inconsistent value from __builtins__
264 # Re: inconsistent value from __builtins__
265 # Von: Alex Martelli <aleaxit@yahoo.com>
265 # Von: Alex Martelli <aleaxit@yahoo.com>
266 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
266 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
267 # Gruppen: comp.lang.python
267 # Gruppen: comp.lang.python
268
268
269 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
269 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
270 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
270 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
271 # > <type 'dict'>
271 # > <type 'dict'>
272 # > >>> print type(__builtins__)
272 # > >>> print type(__builtins__)
273 # > <type 'module'>
273 # > <type 'module'>
274 # > Is this difference in return value intentional?
274 # > Is this difference in return value intentional?
275
275
276 # Well, it's documented that '__builtins__' can be either a dictionary
276 # Well, it's documented that '__builtins__' can be either a dictionary
277 # or a module, and it's been that way for a long time. Whether it's
277 # or a module, and it's been that way for a long time. Whether it's
278 # intentional (or sensible), I don't know. In any case, the idea is
278 # intentional (or sensible), I don't know. In any case, the idea is
279 # that if you need to access the built-in namespace directly, you
279 # that if you need to access the built-in namespace directly, you
280 # should start with "import __builtin__" (note, no 's') which will
280 # should start with "import __builtin__" (note, no 's') which will
281 # definitely give you a module. Yeah, it's somewhat confusing:-(.
281 # definitely give you a module. Yeah, it's somewhat confusing:-(.
282
282
283 # These routines return properly built dicts as needed by the rest of
283 # These routines return properly built dicts as needed by the rest of
284 # the code, and can also be used by extension writers to generate
284 # the code, and can also be used by extension writers to generate
285 # properly initialized namespaces.
285 # properly initialized namespaces.
286 user_ns = IPython.ipapi.make_user_ns(user_ns)
286 user_ns = IPython.ipapi.make_user_ns(user_ns)
287 user_global_ns = IPython.ipapi.make_user_global_ns(user_global_ns)
287 user_global_ns = IPython.ipapi.make_user_global_ns(user_global_ns)
288
288
289 # Assign namespaces
289 # Assign namespaces
290 # This is the namespace where all normal user variables live
290 # This is the namespace where all normal user variables live
291 self.user_ns = user_ns
291 self.user_ns = user_ns
292 # Embedded instances require a separate namespace for globals.
292 # Embedded instances require a separate namespace for globals.
293 # Normally this one is unused by non-embedded instances.
293 # Normally this one is unused by non-embedded instances.
294 self.user_global_ns = user_global_ns
294 self.user_global_ns = user_global_ns
295 # A namespace to keep track of internal data structures to prevent
295 # A namespace to keep track of internal data structures to prevent
296 # them from cluttering user-visible stuff. Will be updated later
296 # them from cluttering user-visible stuff. Will be updated later
297 self.internal_ns = {}
297 self.internal_ns = {}
298
298
299 # Namespace of system aliases. Each entry in the alias
299 # Namespace of system aliases. Each entry in the alias
300 # table must be a 2-tuple of the form (N,name), where N is the number
300 # table must be a 2-tuple of the form (N,name), where N is the number
301 # of positional arguments of the alias.
301 # of positional arguments of the alias.
302 self.alias_table = {}
302 self.alias_table = {}
303
303
304 # A table holding all the namespaces IPython deals with, so that
304 # A table holding all the namespaces IPython deals with, so that
305 # introspection facilities can search easily.
305 # introspection facilities can search easily.
306 self.ns_table = {'user':user_ns,
306 self.ns_table = {'user':user_ns,
307 'user_global':user_global_ns,
307 'user_global':user_global_ns,
308 'alias':self.alias_table,
308 'alias':self.alias_table,
309 'internal':self.internal_ns,
309 'internal':self.internal_ns,
310 'builtin':__builtin__.__dict__
310 'builtin':__builtin__.__dict__
311 }
311 }
312
312
313 # The user namespace MUST have a pointer to the shell itself.
313 # The user namespace MUST have a pointer to the shell itself.
314 self.user_ns[name] = self
314 self.user_ns[name] = self
315
315
316 # We need to insert into sys.modules something that looks like a
316 # We need to insert into sys.modules something that looks like a
317 # module but which accesses the IPython namespace, for shelve and
317 # module but which accesses the IPython namespace, for shelve and
318 # pickle to work interactively. Normally they rely on getting
318 # pickle to work interactively. Normally they rely on getting
319 # everything out of __main__, but for embedding purposes each IPython
319 # everything out of __main__, but for embedding purposes each IPython
320 # instance has its own private namespace, so we can't go shoving
320 # instance has its own private namespace, so we can't go shoving
321 # everything into __main__.
321 # everything into __main__.
322
322
323 # note, however, that we should only do this for non-embedded
323 # note, however, that we should only do this for non-embedded
324 # ipythons, which really mimic the __main__.__dict__ with their own
324 # ipythons, which really mimic the __main__.__dict__ with their own
325 # namespace. Embedded instances, on the other hand, should not do
325 # namespace. Embedded instances, on the other hand, should not do
326 # this because they need to manage the user local/global namespaces
326 # this because they need to manage the user local/global namespaces
327 # only, but they live within a 'normal' __main__ (meaning, they
327 # only, but they live within a 'normal' __main__ (meaning, they
328 # shouldn't overtake the execution environment of the script they're
328 # shouldn't overtake the execution environment of the script they're
329 # embedded in).
329 # embedded in).
330
330
331 if not embedded:
331 if not embedded:
332 try:
332 try:
333 main_name = self.user_ns['__name__']
333 main_name = self.user_ns['__name__']
334 except KeyError:
334 except KeyError:
335 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
335 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
336 else:
336 else:
337 #print "pickle hack in place" # dbg
337 #print "pickle hack in place" # dbg
338 #print 'main_name:',main_name # dbg
338 #print 'main_name:',main_name # dbg
339 sys.modules[main_name] = FakeModule(self.user_ns)
339 sys.modules[main_name] = FakeModule(self.user_ns)
340
340
341 # List of input with multi-line handling.
341 # List of input with multi-line handling.
342 # Fill its zero entry, user counter starts at 1
342 # Fill its zero entry, user counter starts at 1
343 self.input_hist = InputList(['\n'])
343 self.input_hist = InputList(['\n'])
344 # This one will hold the 'raw' input history, without any
344 # This one will hold the 'raw' input history, without any
345 # pre-processing. This will allow users to retrieve the input just as
345 # pre-processing. This will allow users to retrieve the input just as
346 # it was exactly typed in by the user, with %hist -r.
346 # it was exactly typed in by the user, with %hist -r.
347 self.input_hist_raw = InputList(['\n'])
347 self.input_hist_raw = InputList(['\n'])
348
348
349 # list of visited directories
349 # list of visited directories
350 try:
350 try:
351 self.dir_hist = [os.getcwd()]
351 self.dir_hist = [os.getcwd()]
352 except IOError, e:
352 except IOError, e:
353 self.dir_hist = []
353 self.dir_hist = []
354
354
355 # dict of output history
355 # dict of output history
356 self.output_hist = {}
356 self.output_hist = {}
357
357
358 # Get system encoding at startup time. Certain terminals (like Emacs
359 # under Win32 have it set to None, and we need to have a known valid
360 # encoding to use in the raw_input() method
361 self.stdin_encoding = sys.stdin.encoding or 'ascii'
362
358 # dict of things NOT to alias (keywords, builtins and some magics)
363 # dict of things NOT to alias (keywords, builtins and some magics)
359 no_alias = {}
364 no_alias = {}
360 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
365 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
361 for key in keyword.kwlist + no_alias_magics:
366 for key in keyword.kwlist + no_alias_magics:
362 no_alias[key] = 1
367 no_alias[key] = 1
363 no_alias.update(__builtin__.__dict__)
368 no_alias.update(__builtin__.__dict__)
364 self.no_alias = no_alias
369 self.no_alias = no_alias
365
370
366 # make global variables for user access to these
371 # make global variables for user access to these
367 self.user_ns['_ih'] = self.input_hist
372 self.user_ns['_ih'] = self.input_hist
368 self.user_ns['_oh'] = self.output_hist
373 self.user_ns['_oh'] = self.output_hist
369 self.user_ns['_dh'] = self.dir_hist
374 self.user_ns['_dh'] = self.dir_hist
370
375
371 # user aliases to input and output histories
376 # user aliases to input and output histories
372 self.user_ns['In'] = self.input_hist
377 self.user_ns['In'] = self.input_hist
373 self.user_ns['Out'] = self.output_hist
378 self.user_ns['Out'] = self.output_hist
374
379
375 # Object variable to store code object waiting execution. This is
380 # Object variable to store code object waiting execution. This is
376 # used mainly by the multithreaded shells, but it can come in handy in
381 # used mainly by the multithreaded shells, but it can come in handy in
377 # other situations. No need to use a Queue here, since it's a single
382 # other situations. No need to use a Queue here, since it's a single
378 # item which gets cleared once run.
383 # item which gets cleared once run.
379 self.code_to_run = None
384 self.code_to_run = None
380
385
381 # escapes for automatic behavior on the command line
386 # escapes for automatic behavior on the command line
382 self.ESC_SHELL = '!'
387 self.ESC_SHELL = '!'
383 self.ESC_HELP = '?'
388 self.ESC_HELP = '?'
384 self.ESC_MAGIC = '%'
389 self.ESC_MAGIC = '%'
385 self.ESC_QUOTE = ','
390 self.ESC_QUOTE = ','
386 self.ESC_QUOTE2 = ';'
391 self.ESC_QUOTE2 = ';'
387 self.ESC_PAREN = '/'
392 self.ESC_PAREN = '/'
388
393
389 # And their associated handlers
394 # And their associated handlers
390 self.esc_handlers = {self.ESC_PAREN : self.handle_auto,
395 self.esc_handlers = {self.ESC_PAREN : self.handle_auto,
391 self.ESC_QUOTE : self.handle_auto,
396 self.ESC_QUOTE : self.handle_auto,
392 self.ESC_QUOTE2 : self.handle_auto,
397 self.ESC_QUOTE2 : self.handle_auto,
393 self.ESC_MAGIC : self.handle_magic,
398 self.ESC_MAGIC : self.handle_magic,
394 self.ESC_HELP : self.handle_help,
399 self.ESC_HELP : self.handle_help,
395 self.ESC_SHELL : self.handle_shell_escape,
400 self.ESC_SHELL : self.handle_shell_escape,
396 }
401 }
397
402
398 # class initializations
403 # class initializations
399 Magic.__init__(self,self)
404 Magic.__init__(self,self)
400
405
401 # Python source parser/formatter for syntax highlighting
406 # Python source parser/formatter for syntax highlighting
402 pyformat = PyColorize.Parser().format
407 pyformat = PyColorize.Parser().format
403 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
408 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
404
409
405 # hooks holds pointers used for user-side customizations
410 # hooks holds pointers used for user-side customizations
406 self.hooks = Struct()
411 self.hooks = Struct()
407
412
408 self.strdispatchers = {}
413 self.strdispatchers = {}
409
414
410 # Set all default hooks, defined in the IPython.hooks module.
415 # Set all default hooks, defined in the IPython.hooks module.
411 hooks = IPython.hooks
416 hooks = IPython.hooks
412 for hook_name in hooks.__all__:
417 for hook_name in hooks.__all__:
413 # default hooks have priority 100, i.e. low; user hooks should have 0-100 priority
418 # default hooks have priority 100, i.e. low; user hooks should have
419 # 0-100 priority
414 self.set_hook(hook_name,getattr(hooks,hook_name), 100)
420 self.set_hook(hook_name,getattr(hooks,hook_name), 100)
415 #print "bound hook",hook_name
421 #print "bound hook",hook_name
416
422
417 # Flag to mark unconditional exit
423 # Flag to mark unconditional exit
418 self.exit_now = False
424 self.exit_now = False
419
425
420 self.usage_min = """\
426 self.usage_min = """\
421 An enhanced console for Python.
427 An enhanced console for Python.
422 Some of its features are:
428 Some of its features are:
423 - Readline support if the readline library is present.
429 - Readline support if the readline library is present.
424 - Tab completion in the local namespace.
430 - Tab completion in the local namespace.
425 - Logging of input, see command-line options.
431 - Logging of input, see command-line options.
426 - System shell escape via ! , eg !ls.
432 - System shell escape via ! , eg !ls.
427 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
433 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
428 - Keeps track of locally defined variables via %who, %whos.
434 - Keeps track of locally defined variables via %who, %whos.
429 - Show object information with a ? eg ?x or x? (use ?? for more info).
435 - Show object information with a ? eg ?x or x? (use ?? for more info).
430 """
436 """
431 if usage: self.usage = usage
437 if usage: self.usage = usage
432 else: self.usage = self.usage_min
438 else: self.usage = self.usage_min
433
439
434 # Storage
440 # Storage
435 self.rc = rc # This will hold all configuration information
441 self.rc = rc # This will hold all configuration information
436 self.pager = 'less'
442 self.pager = 'less'
437 # temporary files used for various purposes. Deleted at exit.
443 # temporary files used for various purposes. Deleted at exit.
438 self.tempfiles = []
444 self.tempfiles = []
439
445
440 # Keep track of readline usage (later set by init_readline)
446 # Keep track of readline usage (later set by init_readline)
441 self.has_readline = False
447 self.has_readline = False
442
448
443 # template for logfile headers. It gets resolved at runtime by the
449 # template for logfile headers. It gets resolved at runtime by the
444 # logstart method.
450 # logstart method.
445 self.loghead_tpl = \
451 self.loghead_tpl = \
446 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
452 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
447 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
453 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
448 #log# opts = %s
454 #log# opts = %s
449 #log# args = %s
455 #log# args = %s
450 #log# It is safe to make manual edits below here.
456 #log# It is safe to make manual edits below here.
451 #log#-----------------------------------------------------------------------
457 #log#-----------------------------------------------------------------------
452 """
458 """
453 # for pushd/popd management
459 # for pushd/popd management
454 try:
460 try:
455 self.home_dir = get_home_dir()
461 self.home_dir = get_home_dir()
456 except HomeDirError,msg:
462 except HomeDirError,msg:
457 fatal(msg)
463 fatal(msg)
458
464
459 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
465 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
460
466
461 # Functions to call the underlying shell.
467 # Functions to call the underlying shell.
462
468
463 # The first is similar to os.system, but it doesn't return a value,
469 # The first is similar to os.system, but it doesn't return a value,
464 # and it allows interpolation of variables in the user's namespace.
470 # and it allows interpolation of variables in the user's namespace.
465 self.system = lambda cmd: \
471 self.system = lambda cmd: \
466 shell(self.var_expand(cmd,depth=2),
472 shell(self.var_expand(cmd,depth=2),
467 header=self.rc.system_header,
473 header=self.rc.system_header,
468 verbose=self.rc.system_verbose)
474 verbose=self.rc.system_verbose)
469
475
470 # These are for getoutput and getoutputerror:
476 # These are for getoutput and getoutputerror:
471 self.getoutput = lambda cmd: \
477 self.getoutput = lambda cmd: \
472 getoutput(self.var_expand(cmd,depth=2),
478 getoutput(self.var_expand(cmd,depth=2),
473 header=self.rc.system_header,
479 header=self.rc.system_header,
474 verbose=self.rc.system_verbose)
480 verbose=self.rc.system_verbose)
475
481
476 self.getoutputerror = lambda cmd: \
482 self.getoutputerror = lambda cmd: \
477 getoutputerror(self.var_expand(cmd,depth=2),
483 getoutputerror(self.var_expand(cmd,depth=2),
478 header=self.rc.system_header,
484 header=self.rc.system_header,
479 verbose=self.rc.system_verbose)
485 verbose=self.rc.system_verbose)
480
486
481 # RegExp for splitting line contents into pre-char//first
487 # RegExp for splitting line contents into pre-char//first
482 # word-method//rest. For clarity, each group in on one line.
488 # word-method//rest. For clarity, each group in on one line.
483
489
484 # WARNING: update the regexp if the above escapes are changed, as they
490 # WARNING: update the regexp if the above escapes are changed, as they
485 # are hardwired in.
491 # are hardwired in.
486
492
487 # Don't get carried away with trying to make the autocalling catch too
493 # Don't get carried away with trying to make the autocalling catch too
488 # much: it's better to be conservative rather than to trigger hidden
494 # much: it's better to be conservative rather than to trigger hidden
489 # evals() somewhere and end up causing side effects.
495 # evals() somewhere and end up causing side effects.
490 self.line_split = re.compile(r'^(\s*[,;/]?\s*)'
496 self.line_split = re.compile(r'^(\s*[,;/]?\s*)'
491 r'([\?\w\.]+\w*\s*)'
497 r'([\?\w\.]+\w*\s*)'
492 r'(\(?.*$)')
498 r'(\(?.*$)')
493
499
494 self.shell_line_split = re.compile(r'^(\s*)'
500 self.shell_line_split = re.compile(r'^(\s*)'
495 r'(\S*\s*)'
501 r'(\S*\s*)'
496 r'(\(?.*$)')
502 r'(\(?.*$)')
497
503
498
499 # A simpler regexp used as a fallback if the above doesn't work. This
504 # A simpler regexp used as a fallback if the above doesn't work. This
500 # one is more conservative in how it partitions the input. This code
505 # one is more conservative in how it partitions the input. This code
501 # can probably be cleaned up to do everything with just one regexp, but
506 # can probably be cleaned up to do everything with just one regexp, but
502 # I'm afraid of breaking something; do it once the unit tests are in
507 # I'm afraid of breaking something; do it once the unit tests are in
503 # place.
508 # place.
504 self.line_split_fallback = re.compile(r'^(\s*)'
509 self.line_split_fallback = re.compile(r'^(\s*)'
505 r'([%\!\?\w\.]*)'
510 r'([%\!\?\w\.]*)'
506 r'(.*)')
511 r'(.*)')
507
512
508 # Original re, keep around for a while in case changes break something
513 # Original re, keep around for a while in case changes break something
509 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
514 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
510 # r'(\s*[\?\w\.]+\w*\s*)'
515 # r'(\s*[\?\w\.]+\w*\s*)'
511 # r'(\(?.*$)')
516 # r'(\(?.*$)')
512
517
513 # RegExp to identify potential function names
518 # RegExp to identify potential function names
514 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
519 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
515
520
516 # RegExp to exclude strings with this start from autocalling. In
521 # RegExp to exclude strings with this start from autocalling. In
517 # particular, all binary operators should be excluded, so that if foo
522 # particular, all binary operators should be excluded, so that if foo
518 # is callable, foo OP bar doesn't become foo(OP bar), which is
523 # is callable, foo OP bar doesn't become foo(OP bar), which is
519 # invalid. The characters '!=()' don't need to be checked for, as the
524 # invalid. The characters '!=()' don't need to be checked for, as the
520 # _prefilter routine explicitely does so, to catch direct calls and
525 # _prefilter routine explicitely does so, to catch direct calls and
521 # rebindings of existing names.
526 # rebindings of existing names.
522
527
523 # Warning: the '-' HAS TO BE AT THE END of the first group, otherwise
528 # Warning: the '-' HAS TO BE AT THE END of the first group, otherwise
524 # it affects the rest of the group in square brackets.
529 # it affects the rest of the group in square brackets.
525 self.re_exclude_auto = re.compile(r'^[<>,&^\|\*/\+-]'
530 self.re_exclude_auto = re.compile(r'^[<>,&^\|\*/\+-]'
526 '|^is |^not |^in |^and |^or ')
531 '|^is |^not |^in |^and |^or ')
527
532
528 # 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
529 # (experimental). For this to work, the line_split regexp would need
534 # (experimental). For this to work, the line_split regexp would need
530 # 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
531 # 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_.
532 #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_.\[\]]*) ?$')
533
538
534 # 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)
535 self.starting_dir = os.getcwd()
540 self.starting_dir = os.getcwd()
536
541
537 # Various switches which can be set
542 # Various switches which can be set
538 self.CACHELENGTH = 5000 # this is cheap, it's just text
543 self.CACHELENGTH = 5000 # this is cheap, it's just text
539 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
544 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
540 self.banner2 = banner2
545 self.banner2 = banner2
541
546
542 # TraceBack handlers:
547 # TraceBack handlers:
543
548
544 # Syntax error handler.
549 # Syntax error handler.
545 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
550 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
546
551
547 # The interactive one is initialized with an offset, meaning we always
552 # The interactive one is initialized with an offset, meaning we always
548 # want to remove the topmost item in the traceback, which is our own
553 # want to remove the topmost item in the traceback, which is our own
549 # internal code. Valid modes: ['Plain','Context','Verbose']
554 # internal code. Valid modes: ['Plain','Context','Verbose']
550 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
555 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
551 color_scheme='NoColor',
556 color_scheme='NoColor',
552 tb_offset = 1)
557 tb_offset = 1)
553
558
554 # IPython itself shouldn't crash. This will produce a detailed
559 # IPython itself shouldn't crash. This will produce a detailed
555 # post-mortem if it does. But we only install the crash handler for
560 # post-mortem if it does. But we only install the crash handler for
556 # non-threaded shells, the threaded ones use a normal verbose reporter
561 # non-threaded shells, the threaded ones use a normal verbose reporter
557 # and lose the crash handler. This is because exceptions in the main
562 # and lose the crash handler. This is because exceptions in the main
558 # thread (such as in GUI code) propagate directly to sys.excepthook,
563 # thread (such as in GUI code) propagate directly to sys.excepthook,
559 # and there's no point in printing crash dumps for every user exception.
564 # and there's no point in printing crash dumps for every user exception.
560 if self.isthreaded:
565 if self.isthreaded:
561 ipCrashHandler = ultraTB.FormattedTB()
566 ipCrashHandler = ultraTB.FormattedTB()
562 else:
567 else:
563 from IPython import CrashHandler
568 from IPython import CrashHandler
564 ipCrashHandler = CrashHandler.IPythonCrashHandler(self)
569 ipCrashHandler = CrashHandler.IPythonCrashHandler(self)
565 self.set_crash_handler(ipCrashHandler)
570 self.set_crash_handler(ipCrashHandler)
566
571
567 # and add any custom exception handlers the user may have specified
572 # and add any custom exception handlers the user may have specified
568 self.set_custom_exc(*custom_exceptions)
573 self.set_custom_exc(*custom_exceptions)
569
574
570 # indentation management
575 # indentation management
571 self.autoindent = False
576 self.autoindent = False
572 self.indent_current_nsp = 0
577 self.indent_current_nsp = 0
573
578
574 # Make some aliases automatically
579 # Make some aliases automatically
575 # Prepare list of shell aliases to auto-define
580 # Prepare list of shell aliases to auto-define
576 if os.name == 'posix':
581 if os.name == 'posix':
577 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
582 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
578 'mv mv -i','rm rm -i','cp cp -i',
583 'mv mv -i','rm rm -i','cp cp -i',
579 'cat cat','less less','clear clear',
584 'cat cat','less less','clear clear',
580 # a better ls
585 # a better ls
581 'ls ls -F',
586 'ls ls -F',
582 # long ls
587 # long ls
583 'll ls -lF')
588 'll ls -lF')
584 # Extra ls aliases with color, which need special treatment on BSD
589 # Extra ls aliases with color, which need special treatment on BSD
585 # variants
590 # variants
586 ls_extra = ( # color ls
591 ls_extra = ( # color ls
587 'lc ls -F -o --color',
592 'lc ls -F -o --color',
588 # ls normal files only
593 # ls normal files only
589 'lf ls -F -o --color %l | grep ^-',
594 'lf ls -F -o --color %l | grep ^-',
590 # ls symbolic links
595 # ls symbolic links
591 'lk ls -F -o --color %l | grep ^l',
596 'lk ls -F -o --color %l | grep ^l',
592 # directories or links to directories,
597 # directories or links to directories,
593 'ldir ls -F -o --color %l | grep /$',
598 'ldir ls -F -o --color %l | grep /$',
594 # things which are executable
599 # things which are executable
595 'lx ls -F -o --color %l | grep ^-..x',
600 'lx ls -F -o --color %l | grep ^-..x',
596 )
601 )
597 # The BSDs don't ship GNU ls, so they don't understand the
602 # The BSDs don't ship GNU ls, so they don't understand the
598 # --color switch out of the box
603 # --color switch out of the box
599 if 'bsd' in sys.platform:
604 if 'bsd' in sys.platform:
600 ls_extra = ( # ls normal files only
605 ls_extra = ( # ls normal files only
601 'lf ls -lF | grep ^-',
606 'lf ls -lF | grep ^-',
602 # ls symbolic links
607 # ls symbolic links
603 'lk ls -lF | grep ^l',
608 'lk ls -lF | grep ^l',
604 # directories or links to directories,
609 # directories or links to directories,
605 'ldir ls -lF | grep /$',
610 'ldir ls -lF | grep /$',
606 # things which are executable
611 # things which are executable
607 'lx ls -lF | grep ^-..x',
612 'lx ls -lF | grep ^-..x',
608 )
613 )
609 auto_alias = auto_alias + ls_extra
614 auto_alias = auto_alias + ls_extra
610 elif os.name in ['nt','dos']:
615 elif os.name in ['nt','dos']:
611 auto_alias = ('dir dir /on', 'ls dir /on',
616 auto_alias = ('dir dir /on', 'ls dir /on',
612 'ddir dir /ad /on', 'ldir dir /ad /on',
617 'ddir dir /ad /on', 'ldir dir /ad /on',
613 'mkdir mkdir','rmdir rmdir','echo echo',
618 'mkdir mkdir','rmdir rmdir','echo echo',
614 'ren ren','cls cls','copy copy')
619 'ren ren','cls cls','copy copy')
615 else:
620 else:
616 auto_alias = ()
621 auto_alias = ()
617 self.auto_alias = [s.split(None,1) for s in auto_alias]
622 self.auto_alias = [s.split(None,1) for s in auto_alias]
618 # Call the actual (public) initializer
623 # Call the actual (public) initializer
619 self.init_auto_alias()
624 self.init_auto_alias()
620
625
621 # Produce a public API instance
626 # Produce a public API instance
622 self.api = IPython.ipapi.IPApi(self)
627 self.api = IPython.ipapi.IPApi(self)
623
628
624 # track which builtins we add, so we can clean up later
629 # track which builtins we add, so we can clean up later
625 self.builtins_added = {}
630 self.builtins_added = {}
626 # This method will add the necessary builtins for operation, but
631 # This method will add the necessary builtins for operation, but
627 # tracking what it did via the builtins_added dict.
632 # tracking what it did via the builtins_added dict.
628 self.add_builtins()
633 self.add_builtins()
629
634
630 # end __init__
635 # end __init__
631
636
632 def var_expand(self,cmd,depth=0):
637 def var_expand(self,cmd,depth=0):
633 """Expand python variables in a string.
638 """Expand python variables in a string.
634
639
635 The depth argument indicates how many frames above the caller should
640 The depth argument indicates how many frames above the caller should
636 be walked to look for the local namespace where to expand variables.
641 be walked to look for the local namespace where to expand variables.
637
642
638 The global namespace for expansion is always the user's interactive
643 The global namespace for expansion is always the user's interactive
639 namespace.
644 namespace.
640 """
645 """
641
646
642 return str(ItplNS(cmd.replace('#','\#'),
647 return str(ItplNS(cmd.replace('#','\#'),
643 self.user_ns, # globals
648 self.user_ns, # globals
644 # Skip our own frame in searching for locals:
649 # Skip our own frame in searching for locals:
645 sys._getframe(depth+1).f_locals # locals
650 sys._getframe(depth+1).f_locals # locals
646 ))
651 ))
647
652
648 def pre_config_initialization(self):
653 def pre_config_initialization(self):
649 """Pre-configuration init method
654 """Pre-configuration init method
650
655
651 This is called before the configuration files are processed to
656 This is called before the configuration files are processed to
652 prepare the services the config files might need.
657 prepare the services the config files might need.
653
658
654 self.rc already has reasonable default values at this point.
659 self.rc already has reasonable default values at this point.
655 """
660 """
656 rc = self.rc
661 rc = self.rc
657
662
658 self.db = pickleshare.PickleShareDB(rc.ipythondir + "/db")
663 self.db = pickleshare.PickleShareDB(rc.ipythondir + "/db")
659
664
660 def post_config_initialization(self):
665 def post_config_initialization(self):
661 """Post configuration init method
666 """Post configuration init method
662
667
663 This is called after the configuration files have been processed to
668 This is called after the configuration files have been processed to
664 'finalize' the initialization."""
669 'finalize' the initialization."""
665
670
666 rc = self.rc
671 rc = self.rc
667
672
668 # Object inspector
673 # Object inspector
669 self.inspector = OInspect.Inspector(OInspect.InspectColors,
674 self.inspector = OInspect.Inspector(OInspect.InspectColors,
670 PyColorize.ANSICodeColors,
675 PyColorize.ANSICodeColors,
671 'NoColor',
676 'NoColor',
672 rc.object_info_string_level)
677 rc.object_info_string_level)
673
678
674 # Load readline proper
679 # Load readline proper
675 if rc.readline:
680 if rc.readline:
676 self.init_readline()
681 self.init_readline()
677
682
678 # local shortcut, this is used a LOT
683 # local shortcut, this is used a LOT
679 self.log = self.logger.log
684 self.log = self.logger.log
680
685
681 # Initialize cache, set in/out prompts and printing system
686 # Initialize cache, set in/out prompts and printing system
682 self.outputcache = CachedOutput(self,
687 self.outputcache = CachedOutput(self,
683 rc.cache_size,
688 rc.cache_size,
684 rc.pprint,
689 rc.pprint,
685 input_sep = rc.separate_in,
690 input_sep = rc.separate_in,
686 output_sep = rc.separate_out,
691 output_sep = rc.separate_out,
687 output_sep2 = rc.separate_out2,
692 output_sep2 = rc.separate_out2,
688 ps1 = rc.prompt_in1,
693 ps1 = rc.prompt_in1,
689 ps2 = rc.prompt_in2,
694 ps2 = rc.prompt_in2,
690 ps_out = rc.prompt_out,
695 ps_out = rc.prompt_out,
691 pad_left = rc.prompts_pad_left)
696 pad_left = rc.prompts_pad_left)
692
697
693 # user may have over-ridden the default print hook:
698 # user may have over-ridden the default print hook:
694 try:
699 try:
695 self.outputcache.__class__.display = self.hooks.display
700 self.outputcache.__class__.display = self.hooks.display
696 except AttributeError:
701 except AttributeError:
697 pass
702 pass
698
703
699 # I don't like assigning globally to sys, because it means when
704 # I don't like assigning globally to sys, because it means when
700 # embedding instances, each embedded instance overrides the previous
705 # embedding instances, each embedded instance overrides the previous
701 # choice. But sys.displayhook seems to be called internally by exec,
706 # choice. But sys.displayhook seems to be called internally by exec,
702 # so I don't see a way around it. We first save the original and then
707 # so I don't see a way around it. We first save the original and then
703 # overwrite it.
708 # overwrite it.
704 self.sys_displayhook = sys.displayhook
709 self.sys_displayhook = sys.displayhook
705 sys.displayhook = self.outputcache
710 sys.displayhook = self.outputcache
706
711
707 # Set user colors (don't do it in the constructor above so that it
712 # Set user colors (don't do it in the constructor above so that it
708 # doesn't crash if colors option is invalid)
713 # doesn't crash if colors option is invalid)
709 self.magic_colors(rc.colors)
714 self.magic_colors(rc.colors)
710
715
711 # Set calling of pdb on exceptions
716 # Set calling of pdb on exceptions
712 self.call_pdb = rc.pdb
717 self.call_pdb = rc.pdb
713
718
714 # Load user aliases
719 # Load user aliases
715 for alias in rc.alias:
720 for alias in rc.alias:
716 self.magic_alias(alias)
721 self.magic_alias(alias)
717 self.hooks.late_startup_hook()
722 self.hooks.late_startup_hook()
718
723
719 batchrun = False
724 batchrun = False
720 for batchfile in [path(arg) for arg in self.rc.args
725 for batchfile in [path(arg) for arg in self.rc.args
721 if arg.lower().endswith('.ipy')]:
726 if arg.lower().endswith('.ipy')]:
722 if not batchfile.isfile():
727 if not batchfile.isfile():
723 print "No such batch file:", batchfile
728 print "No such batch file:", batchfile
724 continue
729 continue
725 self.api.runlines(batchfile.text())
730 self.api.runlines(batchfile.text())
726 batchrun = True
731 batchrun = True
727 if batchrun:
732 if batchrun:
728 self.exit_now = True
733 self.exit_now = True
729
734
730 def add_builtins(self):
735 def add_builtins(self):
731 """Store ipython references into the builtin namespace.
736 """Store ipython references into the builtin namespace.
732
737
733 Some parts of ipython operate via builtins injected here, which hold a
738 Some parts of ipython operate via builtins injected here, which hold a
734 reference to IPython itself."""
739 reference to IPython itself."""
735
740
736 # TODO: deprecate all except _ip; 'jobs' should be installed
741 # TODO: deprecate all except _ip; 'jobs' should be installed
737 # by an extension and the rest are under _ip, ipalias is redundant
742 # by an extension and the rest are under _ip, ipalias is redundant
738 builtins_new = dict(__IPYTHON__ = self,
743 builtins_new = dict(__IPYTHON__ = self,
739 ip_set_hook = self.set_hook,
744 ip_set_hook = self.set_hook,
740 jobs = self.jobs,
745 jobs = self.jobs,
741 ipmagic = wrap_deprecated(self.ipmagic,'_ip.magic()'),
746 ipmagic = wrap_deprecated(self.ipmagic,'_ip.magic()'),
742 ipalias = wrap_deprecated(self.ipalias),
747 ipalias = wrap_deprecated(self.ipalias),
743 ipsystem = wrap_deprecated(self.ipsystem,'_ip.system()'),
748 ipsystem = wrap_deprecated(self.ipsystem,'_ip.system()'),
744 _ip = self.api
749 _ip = self.api
745 )
750 )
746 for biname,bival in builtins_new.items():
751 for biname,bival in builtins_new.items():
747 try:
752 try:
748 # store the orignal value so we can restore it
753 # store the orignal value so we can restore it
749 self.builtins_added[biname] = __builtin__.__dict__[biname]
754 self.builtins_added[biname] = __builtin__.__dict__[biname]
750 except KeyError:
755 except KeyError:
751 # or mark that it wasn't defined, and we'll just delete it at
756 # or mark that it wasn't defined, and we'll just delete it at
752 # cleanup
757 # cleanup
753 self.builtins_added[biname] = Undefined
758 self.builtins_added[biname] = Undefined
754 __builtin__.__dict__[biname] = bival
759 __builtin__.__dict__[biname] = bival
755
760
756 # Keep in the builtins a flag for when IPython is active. We set it
761 # Keep in the builtins a flag for when IPython is active. We set it
757 # with setdefault so that multiple nested IPythons don't clobber one
762 # with setdefault so that multiple nested IPythons don't clobber one
758 # another. Each will increase its value by one upon being activated,
763 # another. Each will increase its value by one upon being activated,
759 # which also gives us a way to determine the nesting level.
764 # which also gives us a way to determine the nesting level.
760 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
765 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
761
766
762 def clean_builtins(self):
767 def clean_builtins(self):
763 """Remove any builtins which might have been added by add_builtins, or
768 """Remove any builtins which might have been added by add_builtins, or
764 restore overwritten ones to their previous values."""
769 restore overwritten ones to their previous values."""
765 for biname,bival in self.builtins_added.items():
770 for biname,bival in self.builtins_added.items():
766 if bival is Undefined:
771 if bival is Undefined:
767 del __builtin__.__dict__[biname]
772 del __builtin__.__dict__[biname]
768 else:
773 else:
769 __builtin__.__dict__[biname] = bival
774 __builtin__.__dict__[biname] = bival
770 self.builtins_added.clear()
775 self.builtins_added.clear()
771
776
772 def set_hook(self,name,hook, priority = 50, str_key = None, re_key = None):
777 def set_hook(self,name,hook, priority = 50, str_key = None, re_key = None):
773 """set_hook(name,hook) -> sets an internal IPython hook.
778 """set_hook(name,hook) -> sets an internal IPython hook.
774
779
775 IPython exposes some of its internal API as user-modifiable hooks. By
780 IPython exposes some of its internal API as user-modifiable hooks. By
776 adding your function to one of these hooks, you can modify IPython's
781 adding your function to one of these hooks, you can modify IPython's
777 behavior to call at runtime your own routines."""
782 behavior to call at runtime your own routines."""
778
783
779 # At some point in the future, this should validate the hook before it
784 # At some point in the future, this should validate the hook before it
780 # accepts it. Probably at least check that the hook takes the number
785 # accepts it. Probably at least check that the hook takes the number
781 # of args it's supposed to.
786 # of args it's supposed to.
782
787
783 f = new.instancemethod(hook,self,self.__class__)
788 f = new.instancemethod(hook,self,self.__class__)
784
789
785 # check if the hook is for strdispatcher first
790 # check if the hook is for strdispatcher first
786 if str_key is not None:
791 if str_key is not None:
787 sdp = self.strdispatchers.get(name, StrDispatch())
792 sdp = self.strdispatchers.get(name, StrDispatch())
788 sdp.add_s(str_key, f, priority )
793 sdp.add_s(str_key, f, priority )
789 self.strdispatchers[name] = sdp
794 self.strdispatchers[name] = sdp
790 return
795 return
791 if re_key is not None:
796 if re_key is not None:
792 sdp = self.strdispatchers.get(name, StrDispatch())
797 sdp = self.strdispatchers.get(name, StrDispatch())
793 sdp.add_re(re.compile(re_key), f, priority )
798 sdp.add_re(re.compile(re_key), f, priority )
794 self.strdispatchers[name] = sdp
799 self.strdispatchers[name] = sdp
795 return
800 return
796
801
797 dp = getattr(self.hooks, name, None)
802 dp = getattr(self.hooks, name, None)
798 if name not in IPython.hooks.__all__:
803 if name not in IPython.hooks.__all__:
799 print "Warning! Hook '%s' is not one of %s" % (name, IPython.hooks.__all__ )
804 print "Warning! Hook '%s' is not one of %s" % (name, IPython.hooks.__all__ )
800 if not dp:
805 if not dp:
801 dp = IPython.hooks.CommandChainDispatcher()
806 dp = IPython.hooks.CommandChainDispatcher()
802
807
803 try:
808 try:
804 dp.add(f,priority)
809 dp.add(f,priority)
805 except AttributeError:
810 except AttributeError:
806 # it was not commandchain, plain old func - replace
811 # it was not commandchain, plain old func - replace
807 dp = f
812 dp = f
808
813
809 setattr(self.hooks,name, dp)
814 setattr(self.hooks,name, dp)
810
815
811
816
812 #setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
817 #setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
813
818
814 def set_crash_handler(self,crashHandler):
819 def set_crash_handler(self,crashHandler):
815 """Set the IPython crash handler.
820 """Set the IPython crash handler.
816
821
817 This must be a callable with a signature suitable for use as
822 This must be a callable with a signature suitable for use as
818 sys.excepthook."""
823 sys.excepthook."""
819
824
820 # Install the given crash handler as the Python exception hook
825 # Install the given crash handler as the Python exception hook
821 sys.excepthook = crashHandler
826 sys.excepthook = crashHandler
822
827
823 # The instance will store a pointer to this, so that runtime code
828 # The instance will store a pointer to this, so that runtime code
824 # (such as magics) can access it. This is because during the
829 # (such as magics) can access it. This is because during the
825 # read-eval loop, it gets temporarily overwritten (to deal with GUI
830 # read-eval loop, it gets temporarily overwritten (to deal with GUI
826 # frameworks).
831 # frameworks).
827 self.sys_excepthook = sys.excepthook
832 self.sys_excepthook = sys.excepthook
828
833
829
834
830 def set_custom_exc(self,exc_tuple,handler):
835 def set_custom_exc(self,exc_tuple,handler):
831 """set_custom_exc(exc_tuple,handler)
836 """set_custom_exc(exc_tuple,handler)
832
837
833 Set a custom exception handler, which will be called if any of the
838 Set a custom exception handler, which will be called if any of the
834 exceptions in exc_tuple occur in the mainloop (specifically, in the
839 exceptions in exc_tuple occur in the mainloop (specifically, in the
835 runcode() method.
840 runcode() method.
836
841
837 Inputs:
842 Inputs:
838
843
839 - exc_tuple: a *tuple* of valid exceptions to call the defined
844 - exc_tuple: a *tuple* of valid exceptions to call the defined
840 handler for. It is very important that you use a tuple, and NOT A
845 handler for. It is very important that you use a tuple, and NOT A
841 LIST here, because of the way Python's except statement works. If
846 LIST here, because of the way Python's except statement works. If
842 you only want to trap a single exception, use a singleton tuple:
847 you only want to trap a single exception, use a singleton tuple:
843
848
844 exc_tuple == (MyCustomException,)
849 exc_tuple == (MyCustomException,)
845
850
846 - handler: this must be defined as a function with the following
851 - handler: this must be defined as a function with the following
847 basic interface: def my_handler(self,etype,value,tb).
852 basic interface: def my_handler(self,etype,value,tb).
848
853
849 This will be made into an instance method (via new.instancemethod)
854 This will be made into an instance method (via new.instancemethod)
850 of IPython itself, and it will be called if any of the exceptions
855 of IPython itself, and it will be called if any of the exceptions
851 listed in the exc_tuple are caught. If the handler is None, an
856 listed in the exc_tuple are caught. If the handler is None, an
852 internal basic one is used, which just prints basic info.
857 internal basic one is used, which just prints basic info.
853
858
854 WARNING: by putting in your own exception handler into IPython's main
859 WARNING: by putting in your own exception handler into IPython's main
855 execution loop, you run a very good chance of nasty crashes. This
860 execution loop, you run a very good chance of nasty crashes. This
856 facility should only be used if you really know what you are doing."""
861 facility should only be used if you really know what you are doing."""
857
862
858 assert type(exc_tuple)==type(()) , \
863 assert type(exc_tuple)==type(()) , \
859 "The custom exceptions must be given AS A TUPLE."
864 "The custom exceptions must be given AS A TUPLE."
860
865
861 def dummy_handler(self,etype,value,tb):
866 def dummy_handler(self,etype,value,tb):
862 print '*** Simple custom exception handler ***'
867 print '*** Simple custom exception handler ***'
863 print 'Exception type :',etype
868 print 'Exception type :',etype
864 print 'Exception value:',value
869 print 'Exception value:',value
865 print 'Traceback :',tb
870 print 'Traceback :',tb
866 print 'Source code :','\n'.join(self.buffer)
871 print 'Source code :','\n'.join(self.buffer)
867
872
868 if handler is None: handler = dummy_handler
873 if handler is None: handler = dummy_handler
869
874
870 self.CustomTB = new.instancemethod(handler,self,self.__class__)
875 self.CustomTB = new.instancemethod(handler,self,self.__class__)
871 self.custom_exceptions = exc_tuple
876 self.custom_exceptions = exc_tuple
872
877
873 def set_custom_completer(self,completer,pos=0):
878 def set_custom_completer(self,completer,pos=0):
874 """set_custom_completer(completer,pos=0)
879 """set_custom_completer(completer,pos=0)
875
880
876 Adds a new custom completer function.
881 Adds a new custom completer function.
877
882
878 The position argument (defaults to 0) is the index in the completers
883 The position argument (defaults to 0) is the index in the completers
879 list where you want the completer to be inserted."""
884 list where you want the completer to be inserted."""
880
885
881 newcomp = new.instancemethod(completer,self.Completer,
886 newcomp = new.instancemethod(completer,self.Completer,
882 self.Completer.__class__)
887 self.Completer.__class__)
883 self.Completer.matchers.insert(pos,newcomp)
888 self.Completer.matchers.insert(pos,newcomp)
884
889
885 def set_completer(self):
890 def set_completer(self):
886 """reset readline's completer to be our own."""
891 """reset readline's completer to be our own."""
887 self.readline.set_completer(self.Completer.complete)
892 self.readline.set_completer(self.Completer.complete)
888
893
889 def _get_call_pdb(self):
894 def _get_call_pdb(self):
890 return self._call_pdb
895 return self._call_pdb
891
896
892 def _set_call_pdb(self,val):
897 def _set_call_pdb(self,val):
893
898
894 if val not in (0,1,False,True):
899 if val not in (0,1,False,True):
895 raise ValueError,'new call_pdb value must be boolean'
900 raise ValueError,'new call_pdb value must be boolean'
896
901
897 # store value in instance
902 # store value in instance
898 self._call_pdb = val
903 self._call_pdb = val
899
904
900 # notify the actual exception handlers
905 # notify the actual exception handlers
901 self.InteractiveTB.call_pdb = val
906 self.InteractiveTB.call_pdb = val
902 if self.isthreaded:
907 if self.isthreaded:
903 try:
908 try:
904 self.sys_excepthook.call_pdb = val
909 self.sys_excepthook.call_pdb = val
905 except:
910 except:
906 warn('Failed to activate pdb for threaded exception handler')
911 warn('Failed to activate pdb for threaded exception handler')
907
912
908 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
913 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
909 'Control auto-activation of pdb at exceptions')
914 'Control auto-activation of pdb at exceptions')
910
915
911
916
912 # These special functions get installed in the builtin namespace, to
917 # These special functions get installed in the builtin namespace, to
913 # provide programmatic (pure python) access to magics, aliases and system
918 # provide programmatic (pure python) access to magics, aliases and system
914 # calls. This is important for logging, user scripting, and more.
919 # calls. This is important for logging, user scripting, and more.
915
920
916 # We are basically exposing, via normal python functions, the three
921 # We are basically exposing, via normal python functions, the three
917 # mechanisms in which ipython offers special call modes (magics for
922 # mechanisms in which ipython offers special call modes (magics for
918 # internal control, aliases for direct system access via pre-selected
923 # internal control, aliases for direct system access via pre-selected
919 # names, and !cmd for calling arbitrary system commands).
924 # names, and !cmd for calling arbitrary system commands).
920
925
921 def ipmagic(self,arg_s):
926 def ipmagic(self,arg_s):
922 """Call a magic function by name.
927 """Call a magic function by name.
923
928
924 Input: a string containing the name of the magic function to call and any
929 Input: a string containing the name of the magic function to call and any
925 additional arguments to be passed to the magic.
930 additional arguments to be passed to the magic.
926
931
927 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
932 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
928 prompt:
933 prompt:
929
934
930 In[1]: %name -opt foo bar
935 In[1]: %name -opt foo bar
931
936
932 To call a magic without arguments, simply use ipmagic('name').
937 To call a magic without arguments, simply use ipmagic('name').
933
938
934 This provides a proper Python function to call IPython's magics in any
939 This provides a proper Python function to call IPython's magics in any
935 valid Python code you can type at the interpreter, including loops and
940 valid Python code you can type at the interpreter, including loops and
936 compound statements. It is added by IPython to the Python builtin
941 compound statements. It is added by IPython to the Python builtin
937 namespace upon initialization."""
942 namespace upon initialization."""
938
943
939 args = arg_s.split(' ',1)
944 args = arg_s.split(' ',1)
940 magic_name = args[0]
945 magic_name = args[0]
941 magic_name = magic_name.lstrip(self.ESC_MAGIC)
946 magic_name = magic_name.lstrip(self.ESC_MAGIC)
942
947
943 try:
948 try:
944 magic_args = args[1]
949 magic_args = args[1]
945 except IndexError:
950 except IndexError:
946 magic_args = ''
951 magic_args = ''
947 fn = getattr(self,'magic_'+magic_name,None)
952 fn = getattr(self,'magic_'+magic_name,None)
948 if fn is None:
953 if fn is None:
949 error("Magic function `%s` not found." % magic_name)
954 error("Magic function `%s` not found." % magic_name)
950 else:
955 else:
951 magic_args = self.var_expand(magic_args,1)
956 magic_args = self.var_expand(magic_args,1)
952 return fn(magic_args)
957 return fn(magic_args)
953
958
954 def ipalias(self,arg_s):
959 def ipalias(self,arg_s):
955 """Call an alias by name.
960 """Call an alias by name.
956
961
957 Input: a string containing the name of the alias to call and any
962 Input: a string containing the name of the alias to call and any
958 additional arguments to be passed to the magic.
963 additional arguments to be passed to the magic.
959
964
960 ipalias('name -opt foo bar') is equivalent to typing at the ipython
965 ipalias('name -opt foo bar') is equivalent to typing at the ipython
961 prompt:
966 prompt:
962
967
963 In[1]: name -opt foo bar
968 In[1]: name -opt foo bar
964
969
965 To call an alias without arguments, simply use ipalias('name').
970 To call an alias without arguments, simply use ipalias('name').
966
971
967 This provides a proper Python function to call IPython's aliases in any
972 This provides a proper Python function to call IPython's aliases in any
968 valid Python code you can type at the interpreter, including loops and
973 valid Python code you can type at the interpreter, including loops and
969 compound statements. It is added by IPython to the Python builtin
974 compound statements. It is added by IPython to the Python builtin
970 namespace upon initialization."""
975 namespace upon initialization."""
971
976
972 args = arg_s.split(' ',1)
977 args = arg_s.split(' ',1)
973 alias_name = args[0]
978 alias_name = args[0]
974 try:
979 try:
975 alias_args = args[1]
980 alias_args = args[1]
976 except IndexError:
981 except IndexError:
977 alias_args = ''
982 alias_args = ''
978 if alias_name in self.alias_table:
983 if alias_name in self.alias_table:
979 self.call_alias(alias_name,alias_args)
984 self.call_alias(alias_name,alias_args)
980 else:
985 else:
981 error("Alias `%s` not found." % alias_name)
986 error("Alias `%s` not found." % alias_name)
982
987
983 def ipsystem(self,arg_s):
988 def ipsystem(self,arg_s):
984 """Make a system call, using IPython."""
989 """Make a system call, using IPython."""
985
990
986 self.system(arg_s)
991 self.system(arg_s)
987
992
988 def complete(self,text):
993 def complete(self,text):
989 """Return a sorted list of all possible completions on text.
994 """Return a sorted list of all possible completions on text.
990
995
991 Inputs:
996 Inputs:
992
997
993 - text: a string of text to be completed on.
998 - text: a string of text to be completed on.
994
999
995 This is a wrapper around the completion mechanism, similar to what
1000 This is a wrapper around the completion mechanism, similar to what
996 readline does at the command line when the TAB key is hit. By
1001 readline does at the command line when the TAB key is hit. By
997 exposing it as a method, it can be used by other non-readline
1002 exposing it as a method, it can be used by other non-readline
998 environments (such as GUIs) for text completion.
1003 environments (such as GUIs) for text completion.
999
1004
1000 Simple usage example:
1005 Simple usage example:
1001
1006
1002 In [1]: x = 'hello'
1007 In [1]: x = 'hello'
1003
1008
1004 In [2]: __IP.complete('x.l')
1009 In [2]: __IP.complete('x.l')
1005 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
1010 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
1006
1011
1007 complete = self.Completer.complete
1012 complete = self.Completer.complete
1008 state = 0
1013 state = 0
1009 # use a dict so we get unique keys, since ipyhton's multiple
1014 # use a dict so we get unique keys, since ipyhton's multiple
1010 # completers can return duplicates. When we make 2.4 a requirement,
1015 # completers can return duplicates. When we make 2.4 a requirement,
1011 # start using sets instead, which are faster.
1016 # start using sets instead, which are faster.
1012 comps = {}
1017 comps = {}
1013 while True:
1018 while True:
1014 newcomp = complete(text,state,line_buffer=text)
1019 newcomp = complete(text,state,line_buffer=text)
1015 if newcomp is None:
1020 if newcomp is None:
1016 break
1021 break
1017 comps[newcomp] = 1
1022 comps[newcomp] = 1
1018 state += 1
1023 state += 1
1019 outcomps = comps.keys()
1024 outcomps = comps.keys()
1020 outcomps.sort()
1025 outcomps.sort()
1021 return outcomps
1026 return outcomps
1022
1027
1023 def set_completer_frame(self, frame=None):
1028 def set_completer_frame(self, frame=None):
1024 if frame:
1029 if frame:
1025 self.Completer.namespace = frame.f_locals
1030 self.Completer.namespace = frame.f_locals
1026 self.Completer.global_namespace = frame.f_globals
1031 self.Completer.global_namespace = frame.f_globals
1027 else:
1032 else:
1028 self.Completer.namespace = self.user_ns
1033 self.Completer.namespace = self.user_ns
1029 self.Completer.global_namespace = self.user_global_ns
1034 self.Completer.global_namespace = self.user_global_ns
1030
1035
1031 def init_auto_alias(self):
1036 def init_auto_alias(self):
1032 """Define some aliases automatically.
1037 """Define some aliases automatically.
1033
1038
1034 These are ALL parameter-less aliases"""
1039 These are ALL parameter-less aliases"""
1035
1040
1036 for alias,cmd in self.auto_alias:
1041 for alias,cmd in self.auto_alias:
1037 self.alias_table[alias] = (0,cmd)
1042 self.alias_table[alias] = (0,cmd)
1038
1043
1039 def alias_table_validate(self,verbose=0):
1044 def alias_table_validate(self,verbose=0):
1040 """Update information about the alias table.
1045 """Update information about the alias table.
1041
1046
1042 In particular, make sure no Python keywords/builtins are in it."""
1047 In particular, make sure no Python keywords/builtins are in it."""
1043
1048
1044 no_alias = self.no_alias
1049 no_alias = self.no_alias
1045 for k in self.alias_table.keys():
1050 for k in self.alias_table.keys():
1046 if k in no_alias:
1051 if k in no_alias:
1047 del self.alias_table[k]
1052 del self.alias_table[k]
1048 if verbose:
1053 if verbose:
1049 print ("Deleting alias <%s>, it's a Python "
1054 print ("Deleting alias <%s>, it's a Python "
1050 "keyword or builtin." % k)
1055 "keyword or builtin." % k)
1051
1056
1052 def set_autoindent(self,value=None):
1057 def set_autoindent(self,value=None):
1053 """Set the autoindent flag, checking for readline support.
1058 """Set the autoindent flag, checking for readline support.
1054
1059
1055 If called with no arguments, it acts as a toggle."""
1060 If called with no arguments, it acts as a toggle."""
1056
1061
1057 if not self.has_readline:
1062 if not self.has_readline:
1058 if os.name == 'posix':
1063 if os.name == 'posix':
1059 warn("The auto-indent feature requires the readline library")
1064 warn("The auto-indent feature requires the readline library")
1060 self.autoindent = 0
1065 self.autoindent = 0
1061 return
1066 return
1062 if value is None:
1067 if value is None:
1063 self.autoindent = not self.autoindent
1068 self.autoindent = not self.autoindent
1064 else:
1069 else:
1065 self.autoindent = value
1070 self.autoindent = value
1066
1071
1067 def rc_set_toggle(self,rc_field,value=None):
1072 def rc_set_toggle(self,rc_field,value=None):
1068 """Set or toggle a field in IPython's rc config. structure.
1073 """Set or toggle a field in IPython's rc config. structure.
1069
1074
1070 If called with no arguments, it acts as a toggle.
1075 If called with no arguments, it acts as a toggle.
1071
1076
1072 If called with a non-existent field, the resulting AttributeError
1077 If called with a non-existent field, the resulting AttributeError
1073 exception will propagate out."""
1078 exception will propagate out."""
1074
1079
1075 rc_val = getattr(self.rc,rc_field)
1080 rc_val = getattr(self.rc,rc_field)
1076 if value is None:
1081 if value is None:
1077 value = not rc_val
1082 value = not rc_val
1078 setattr(self.rc,rc_field,value)
1083 setattr(self.rc,rc_field,value)
1079
1084
1080 def user_setup(self,ipythondir,rc_suffix,mode='install'):
1085 def user_setup(self,ipythondir,rc_suffix,mode='install'):
1081 """Install the user configuration directory.
1086 """Install the user configuration directory.
1082
1087
1083 Can be called when running for the first time or to upgrade the user's
1088 Can be called when running for the first time or to upgrade the user's
1084 .ipython/ directory with the mode parameter. Valid modes are 'install'
1089 .ipython/ directory with the mode parameter. Valid modes are 'install'
1085 and 'upgrade'."""
1090 and 'upgrade'."""
1086
1091
1087 def wait():
1092 def wait():
1088 try:
1093 try:
1089 raw_input("Please press <RETURN> to start IPython.")
1094 raw_input("Please press <RETURN> to start IPython.")
1090 except EOFError:
1095 except EOFError:
1091 print >> Term.cout
1096 print >> Term.cout
1092 print '*'*70
1097 print '*'*70
1093
1098
1094 cwd = os.getcwd() # remember where we started
1099 cwd = os.getcwd() # remember where we started
1095 glb = glob.glob
1100 glb = glob.glob
1096 print '*'*70
1101 print '*'*70
1097 if mode == 'install':
1102 if mode == 'install':
1098 print \
1103 print \
1099 """Welcome to IPython. I will try to create a personal configuration directory
1104 """Welcome to IPython. I will try to create a personal configuration directory
1100 where you can customize many aspects of IPython's functionality in:\n"""
1105 where you can customize many aspects of IPython's functionality in:\n"""
1101 else:
1106 else:
1102 print 'I am going to upgrade your configuration in:'
1107 print 'I am going to upgrade your configuration in:'
1103
1108
1104 print ipythondir
1109 print ipythondir
1105
1110
1106 rcdirend = os.path.join('IPython','UserConfig')
1111 rcdirend = os.path.join('IPython','UserConfig')
1107 cfg = lambda d: os.path.join(d,rcdirend)
1112 cfg = lambda d: os.path.join(d,rcdirend)
1108 try:
1113 try:
1109 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
1114 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
1110 except IOError:
1115 except IOError:
1111 warning = """
1116 warning = """
1112 Installation error. IPython's directory was not found.
1117 Installation error. IPython's directory was not found.
1113
1118
1114 Check the following:
1119 Check the following:
1115
1120
1116 The ipython/IPython directory should be in a directory belonging to your
1121 The ipython/IPython directory should be in a directory belonging to your
1117 PYTHONPATH environment variable (that is, it should be in a directory
1122 PYTHONPATH environment variable (that is, it should be in a directory
1118 belonging to sys.path). You can copy it explicitly there or just link to it.
1123 belonging to sys.path). You can copy it explicitly there or just link to it.
1119
1124
1120 IPython will proceed with builtin defaults.
1125 IPython will proceed with builtin defaults.
1121 """
1126 """
1122 warn(warning)
1127 warn(warning)
1123 wait()
1128 wait()
1124 return
1129 return
1125
1130
1126 if mode == 'install':
1131 if mode == 'install':
1127 try:
1132 try:
1128 shutil.copytree(rcdir,ipythondir)
1133 shutil.copytree(rcdir,ipythondir)
1129 os.chdir(ipythondir)
1134 os.chdir(ipythondir)
1130 rc_files = glb("ipythonrc*")
1135 rc_files = glb("ipythonrc*")
1131 for rc_file in rc_files:
1136 for rc_file in rc_files:
1132 os.rename(rc_file,rc_file+rc_suffix)
1137 os.rename(rc_file,rc_file+rc_suffix)
1133 except:
1138 except:
1134 warning = """
1139 warning = """
1135
1140
1136 There was a problem with the installation:
1141 There was a problem with the installation:
1137 %s
1142 %s
1138 Try to correct it or contact the developers if you think it's a bug.
1143 Try to correct it or contact the developers if you think it's a bug.
1139 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1144 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1140 warn(warning)
1145 warn(warning)
1141 wait()
1146 wait()
1142 return
1147 return
1143
1148
1144 elif mode == 'upgrade':
1149 elif mode == 'upgrade':
1145 try:
1150 try:
1146 os.chdir(ipythondir)
1151 os.chdir(ipythondir)
1147 except:
1152 except:
1148 print """
1153 print """
1149 Can not upgrade: changing to directory %s failed. Details:
1154 Can not upgrade: changing to directory %s failed. Details:
1150 %s
1155 %s
1151 """ % (ipythondir,sys.exc_info()[1])
1156 """ % (ipythondir,sys.exc_info()[1])
1152 wait()
1157 wait()
1153 return
1158 return
1154 else:
1159 else:
1155 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1160 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1156 for new_full_path in sources:
1161 for new_full_path in sources:
1157 new_filename = os.path.basename(new_full_path)
1162 new_filename = os.path.basename(new_full_path)
1158 if new_filename.startswith('ipythonrc'):
1163 if new_filename.startswith('ipythonrc'):
1159 new_filename = new_filename + rc_suffix
1164 new_filename = new_filename + rc_suffix
1160 # The config directory should only contain files, skip any
1165 # The config directory should only contain files, skip any
1161 # directories which may be there (like CVS)
1166 # directories which may be there (like CVS)
1162 if os.path.isdir(new_full_path):
1167 if os.path.isdir(new_full_path):
1163 continue
1168 continue
1164 if os.path.exists(new_filename):
1169 if os.path.exists(new_filename):
1165 old_file = new_filename+'.old'
1170 old_file = new_filename+'.old'
1166 if os.path.exists(old_file):
1171 if os.path.exists(old_file):
1167 os.remove(old_file)
1172 os.remove(old_file)
1168 os.rename(new_filename,old_file)
1173 os.rename(new_filename,old_file)
1169 shutil.copy(new_full_path,new_filename)
1174 shutil.copy(new_full_path,new_filename)
1170 else:
1175 else:
1171 raise ValueError,'unrecognized mode for install:',`mode`
1176 raise ValueError,'unrecognized mode for install:',`mode`
1172
1177
1173 # Fix line-endings to those native to each platform in the config
1178 # Fix line-endings to those native to each platform in the config
1174 # directory.
1179 # directory.
1175 try:
1180 try:
1176 os.chdir(ipythondir)
1181 os.chdir(ipythondir)
1177 except:
1182 except:
1178 print """
1183 print """
1179 Problem: changing to directory %s failed.
1184 Problem: changing to directory %s failed.
1180 Details:
1185 Details:
1181 %s
1186 %s
1182
1187
1183 Some configuration files may have incorrect line endings. This should not
1188 Some configuration files may have incorrect line endings. This should not
1184 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1189 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1185 wait()
1190 wait()
1186 else:
1191 else:
1187 for fname in glb('ipythonrc*'):
1192 for fname in glb('ipythonrc*'):
1188 try:
1193 try:
1189 native_line_ends(fname,backup=0)
1194 native_line_ends(fname,backup=0)
1190 except IOError:
1195 except IOError:
1191 pass
1196 pass
1192
1197
1193 if mode == 'install':
1198 if mode == 'install':
1194 print """
1199 print """
1195 Successful installation!
1200 Successful installation!
1196
1201
1197 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1202 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1198 IPython manual (there are both HTML and PDF versions supplied with the
1203 IPython manual (there are both HTML and PDF versions supplied with the
1199 distribution) to make sure that your system environment is properly configured
1204 distribution) to make sure that your system environment is properly configured
1200 to take advantage of IPython's features.
1205 to take advantage of IPython's features.
1201
1206
1202 Important note: the configuration system has changed! The old system is
1207 Important note: the configuration system has changed! The old system is
1203 still in place, but its setting may be partly overridden by the settings in
1208 still in place, but its setting may be partly overridden by the settings in
1204 "~/.ipython/ipy_user_conf.py" config file. Please take a look at the file
1209 "~/.ipython/ipy_user_conf.py" config file. Please take a look at the file
1205 if some of the new settings bother you.
1210 if some of the new settings bother you.
1206
1211
1207 """
1212 """
1208 else:
1213 else:
1209 print """
1214 print """
1210 Successful upgrade!
1215 Successful upgrade!
1211
1216
1212 All files in your directory:
1217 All files in your directory:
1213 %(ipythondir)s
1218 %(ipythondir)s
1214 which would have been overwritten by the upgrade were backed up with a .old
1219 which would have been overwritten by the upgrade were backed up with a .old
1215 extension. If you had made particular customizations in those files you may
1220 extension. If you had made particular customizations in those files you may
1216 want to merge them back into the new files.""" % locals()
1221 want to merge them back into the new files.""" % locals()
1217 wait()
1222 wait()
1218 os.chdir(cwd)
1223 os.chdir(cwd)
1219 # end user_setup()
1224 # end user_setup()
1220
1225
1221 def atexit_operations(self):
1226 def atexit_operations(self):
1222 """This will be executed at the time of exit.
1227 """This will be executed at the time of exit.
1223
1228
1224 Saving of persistent data should be performed here. """
1229 Saving of persistent data should be performed here. """
1225
1230
1226 #print '*** IPython exit cleanup ***' # dbg
1231 #print '*** IPython exit cleanup ***' # dbg
1227 # input history
1232 # input history
1228 self.savehist()
1233 self.savehist()
1229
1234
1230 # Cleanup all tempfiles left around
1235 # Cleanup all tempfiles left around
1231 for tfile in self.tempfiles:
1236 for tfile in self.tempfiles:
1232 try:
1237 try:
1233 os.unlink(tfile)
1238 os.unlink(tfile)
1234 except OSError:
1239 except OSError:
1235 pass
1240 pass
1236
1241
1237 # save the "persistent data" catch-all dictionary
1242 # save the "persistent data" catch-all dictionary
1238 self.hooks.shutdown_hook()
1243 self.hooks.shutdown_hook()
1239
1244
1240 def savehist(self):
1245 def savehist(self):
1241 """Save input history to a file (via readline library)."""
1246 """Save input history to a file (via readline library)."""
1242 try:
1247 try:
1243 self.readline.write_history_file(self.histfile)
1248 self.readline.write_history_file(self.histfile)
1244 except:
1249 except:
1245 print 'Unable to save IPython command history to file: ' + \
1250 print 'Unable to save IPython command history to file: ' + \
1246 `self.histfile`
1251 `self.histfile`
1247
1252
1253 def reloadhist(self):
1254 """Reload the input history from disk file."""
1255
1256 if self.has_readline:
1257 self.readline.clear_history()
1258 self.readline.read_history_file(self.shell.histfile)
1259
1248 def history_saving_wrapper(self, func):
1260 def history_saving_wrapper(self, func):
1249 """ Wrap func for readline history saving
1261 """ Wrap func for readline history saving
1250
1262
1251 Convert func into callable that saves & restores
1263 Convert func into callable that saves & restores
1252 history around the call """
1264 history around the call """
1253
1265
1254 if not self.has_readline:
1266 if not self.has_readline:
1255 return func
1267 return func
1256
1268
1257 def wrapper():
1269 def wrapper():
1258 self.savehist()
1270 self.savehist()
1259 try:
1271 try:
1260 func()
1272 func()
1261 finally:
1273 finally:
1262 readline.read_history_file(self.histfile)
1274 readline.read_history_file(self.histfile)
1263 return wrapper
1275 return wrapper
1264
1276
1265
1277
1266 def pre_readline(self):
1278 def pre_readline(self):
1267 """readline hook to be used at the start of each line.
1279 """readline hook to be used at the start of each line.
1268
1280
1269 Currently it handles auto-indent only."""
1281 Currently it handles auto-indent only."""
1270
1282
1271 #debugx('self.indent_current_nsp','pre_readline:')
1283 #debugx('self.indent_current_nsp','pre_readline:')
1272 self.readline.insert_text(self.indent_current_str())
1284 self.readline.insert_text(self.indent_current_str())
1273
1285
1274 def init_readline(self):
1286 def init_readline(self):
1275 """Command history completion/saving/reloading."""
1287 """Command history completion/saving/reloading."""
1276
1288
1277 import IPython.rlineimpl as readline
1289 import IPython.rlineimpl as readline
1278 if not readline.have_readline:
1290 if not readline.have_readline:
1279 self.has_readline = 0
1291 self.has_readline = 0
1280 self.readline = None
1292 self.readline = None
1281 # no point in bugging windows users with this every time:
1293 # no point in bugging windows users with this every time:
1282 warn('Readline services not available on this platform.')
1294 warn('Readline services not available on this platform.')
1283 else:
1295 else:
1284 sys.modules['readline'] = readline
1296 sys.modules['readline'] = readline
1285 import atexit
1297 import atexit
1286 from IPython.completer import IPCompleter
1298 from IPython.completer import IPCompleter
1287 self.Completer = IPCompleter(self,
1299 self.Completer = IPCompleter(self,
1288 self.user_ns,
1300 self.user_ns,
1289 self.user_global_ns,
1301 self.user_global_ns,
1290 self.rc.readline_omit__names,
1302 self.rc.readline_omit__names,
1291 self.alias_table)
1303 self.alias_table)
1292 sdisp = self.strdispatchers.get('complete_command', StrDispatch())
1304 sdisp = self.strdispatchers.get('complete_command', StrDispatch())
1293 self.strdispatchers['complete_command'] = sdisp
1305 self.strdispatchers['complete_command'] = sdisp
1294 self.Completer.custom_completers = sdisp
1306 self.Completer.custom_completers = sdisp
1295 # Platform-specific configuration
1307 # Platform-specific configuration
1296 if os.name == 'nt':
1308 if os.name == 'nt':
1297 self.readline_startup_hook = readline.set_pre_input_hook
1309 self.readline_startup_hook = readline.set_pre_input_hook
1298 else:
1310 else:
1299 self.readline_startup_hook = readline.set_startup_hook
1311 self.readline_startup_hook = readline.set_startup_hook
1300
1312
1301 # Load user's initrc file (readline config)
1313 # Load user's initrc file (readline config)
1302 inputrc_name = os.environ.get('INPUTRC')
1314 inputrc_name = os.environ.get('INPUTRC')
1303 if inputrc_name is None:
1315 if inputrc_name is None:
1304 home_dir = get_home_dir()
1316 home_dir = get_home_dir()
1305 if home_dir is not None:
1317 if home_dir is not None:
1306 inputrc_name = os.path.join(home_dir,'.inputrc')
1318 inputrc_name = os.path.join(home_dir,'.inputrc')
1307 if os.path.isfile(inputrc_name):
1319 if os.path.isfile(inputrc_name):
1308 try:
1320 try:
1309 readline.read_init_file(inputrc_name)
1321 readline.read_init_file(inputrc_name)
1310 except:
1322 except:
1311 warn('Problems reading readline initialization file <%s>'
1323 warn('Problems reading readline initialization file <%s>'
1312 % inputrc_name)
1324 % inputrc_name)
1313
1325
1314 self.has_readline = 1
1326 self.has_readline = 1
1315 self.readline = readline
1327 self.readline = readline
1316 # save this in sys so embedded copies can restore it properly
1328 # save this in sys so embedded copies can restore it properly
1317 sys.ipcompleter = self.Completer.complete
1329 sys.ipcompleter = self.Completer.complete
1318 self.set_completer()
1330 self.set_completer()
1319
1331
1320 # Configure readline according to user's prefs
1332 # Configure readline according to user's prefs
1321 for rlcommand in self.rc.readline_parse_and_bind:
1333 for rlcommand in self.rc.readline_parse_and_bind:
1322 readline.parse_and_bind(rlcommand)
1334 readline.parse_and_bind(rlcommand)
1323
1335
1324 # remove some chars from the delimiters list
1336 # remove some chars from the delimiters list
1325 delims = readline.get_completer_delims()
1337 delims = readline.get_completer_delims()
1326 delims = delims.translate(string._idmap,
1338 delims = delims.translate(string._idmap,
1327 self.rc.readline_remove_delims)
1339 self.rc.readline_remove_delims)
1328 readline.set_completer_delims(delims)
1340 readline.set_completer_delims(delims)
1329 # otherwise we end up with a monster history after a while:
1341 # otherwise we end up with a monster history after a while:
1330 readline.set_history_length(1000)
1342 readline.set_history_length(1000)
1331 try:
1343 try:
1332 #print '*** Reading readline history' # dbg
1344 #print '*** Reading readline history' # dbg
1333 readline.read_history_file(self.histfile)
1345 readline.read_history_file(self.histfile)
1334 except IOError:
1346 except IOError:
1335 pass # It doesn't exist yet.
1347 pass # It doesn't exist yet.
1336
1348
1337 atexit.register(self.atexit_operations)
1349 atexit.register(self.atexit_operations)
1338 del atexit
1350 del atexit
1339
1351
1340 # Configure auto-indent for all platforms
1352 # Configure auto-indent for all platforms
1341 self.set_autoindent(self.rc.autoindent)
1353 self.set_autoindent(self.rc.autoindent)
1342
1354
1343 def ask_yes_no(self,prompt,default=True):
1355 def ask_yes_no(self,prompt,default=True):
1344 if self.rc.quiet:
1356 if self.rc.quiet:
1345 return True
1357 return True
1346 return ask_yes_no(prompt,default)
1358 return ask_yes_no(prompt,default)
1347
1359
1348 def _should_recompile(self,e):
1360 def _should_recompile(self,e):
1349 """Utility routine for edit_syntax_error"""
1361 """Utility routine for edit_syntax_error"""
1350
1362
1351 if e.filename in ('<ipython console>','<input>','<string>',
1363 if e.filename in ('<ipython console>','<input>','<string>',
1352 '<console>','<BackgroundJob compilation>',
1364 '<console>','<BackgroundJob compilation>',
1353 None):
1365 None):
1354
1366
1355 return False
1367 return False
1356 try:
1368 try:
1357 if (self.rc.autoedit_syntax and
1369 if (self.rc.autoedit_syntax and
1358 not self.ask_yes_no('Return to editor to correct syntax error? '
1370 not self.ask_yes_no('Return to editor to correct syntax error? '
1359 '[Y/n] ','y')):
1371 '[Y/n] ','y')):
1360 return False
1372 return False
1361 except EOFError:
1373 except EOFError:
1362 return False
1374 return False
1363
1375
1364 def int0(x):
1376 def int0(x):
1365 try:
1377 try:
1366 return int(x)
1378 return int(x)
1367 except TypeError:
1379 except TypeError:
1368 return 0
1380 return 0
1369 # always pass integer line and offset values to editor hook
1381 # always pass integer line and offset values to editor hook
1370 self.hooks.fix_error_editor(e.filename,
1382 self.hooks.fix_error_editor(e.filename,
1371 int0(e.lineno),int0(e.offset),e.msg)
1383 int0(e.lineno),int0(e.offset),e.msg)
1372 return True
1384 return True
1373
1385
1374 def edit_syntax_error(self):
1386 def edit_syntax_error(self):
1375 """The bottom half of the syntax error handler called in the main loop.
1387 """The bottom half of the syntax error handler called in the main loop.
1376
1388
1377 Loop until syntax error is fixed or user cancels.
1389 Loop until syntax error is fixed or user cancels.
1378 """
1390 """
1379
1391
1380 while self.SyntaxTB.last_syntax_error:
1392 while self.SyntaxTB.last_syntax_error:
1381 # copy and clear last_syntax_error
1393 # copy and clear last_syntax_error
1382 err = self.SyntaxTB.clear_err_state()
1394 err = self.SyntaxTB.clear_err_state()
1383 if not self._should_recompile(err):
1395 if not self._should_recompile(err):
1384 return
1396 return
1385 try:
1397 try:
1386 # may set last_syntax_error again if a SyntaxError is raised
1398 # may set last_syntax_error again if a SyntaxError is raised
1387 self.safe_execfile(err.filename,self.user_ns)
1399 self.safe_execfile(err.filename,self.user_ns)
1388 except:
1400 except:
1389 self.showtraceback()
1401 self.showtraceback()
1390 else:
1402 else:
1391 try:
1403 try:
1392 f = file(err.filename)
1404 f = file(err.filename)
1393 try:
1405 try:
1394 sys.displayhook(f.read())
1406 sys.displayhook(f.read())
1395 finally:
1407 finally:
1396 f.close()
1408 f.close()
1397 except:
1409 except:
1398 self.showtraceback()
1410 self.showtraceback()
1399
1411
1400 def showsyntaxerror(self, filename=None):
1412 def showsyntaxerror(self, filename=None):
1401 """Display the syntax error that just occurred.
1413 """Display the syntax error that just occurred.
1402
1414
1403 This doesn't display a stack trace because there isn't one.
1415 This doesn't display a stack trace because there isn't one.
1404
1416
1405 If a filename is given, it is stuffed in the exception instead
1417 If a filename is given, it is stuffed in the exception instead
1406 of what was there before (because Python's parser always uses
1418 of what was there before (because Python's parser always uses
1407 "<string>" when reading from a string).
1419 "<string>" when reading from a string).
1408 """
1420 """
1409 etype, value, last_traceback = sys.exc_info()
1421 etype, value, last_traceback = sys.exc_info()
1410
1422
1411 # See note about these variables in showtraceback() below
1423 # See note about these variables in showtraceback() below
1412 sys.last_type = etype
1424 sys.last_type = etype
1413 sys.last_value = value
1425 sys.last_value = value
1414 sys.last_traceback = last_traceback
1426 sys.last_traceback = last_traceback
1415
1427
1416 if filename and etype is SyntaxError:
1428 if filename and etype is SyntaxError:
1417 # Work hard to stuff the correct filename in the exception
1429 # Work hard to stuff the correct filename in the exception
1418 try:
1430 try:
1419 msg, (dummy_filename, lineno, offset, line) = value
1431 msg, (dummy_filename, lineno, offset, line) = value
1420 except:
1432 except:
1421 # Not the format we expect; leave it alone
1433 # Not the format we expect; leave it alone
1422 pass
1434 pass
1423 else:
1435 else:
1424 # Stuff in the right filename
1436 # Stuff in the right filename
1425 try:
1437 try:
1426 # Assume SyntaxError is a class exception
1438 # Assume SyntaxError is a class exception
1427 value = SyntaxError(msg, (filename, lineno, offset, line))
1439 value = SyntaxError(msg, (filename, lineno, offset, line))
1428 except:
1440 except:
1429 # If that failed, assume SyntaxError is a string
1441 # If that failed, assume SyntaxError is a string
1430 value = msg, (filename, lineno, offset, line)
1442 value = msg, (filename, lineno, offset, line)
1431 self.SyntaxTB(etype,value,[])
1443 self.SyntaxTB(etype,value,[])
1432
1444
1433 def debugger(self,force=False):
1445 def debugger(self,force=False):
1434 """Call the pydb/pdb debugger.
1446 """Call the pydb/pdb debugger.
1435
1447
1436 Keywords:
1448 Keywords:
1437
1449
1438 - force(False): by default, this routine checks the instance call_pdb
1450 - force(False): by default, this routine checks the instance call_pdb
1439 flag and does not actually invoke the debugger if the flag is false.
1451 flag and does not actually invoke the debugger if the flag is false.
1440 The 'force' option forces the debugger to activate even if the flag
1452 The 'force' option forces the debugger to activate even if the flag
1441 is false.
1453 is false.
1442 """
1454 """
1443
1455
1444 if not (force or self.call_pdb):
1456 if not (force or self.call_pdb):
1445 return
1457 return
1446
1458
1447 if not hasattr(sys,'last_traceback'):
1459 if not hasattr(sys,'last_traceback'):
1448 error('No traceback has been produced, nothing to debug.')
1460 error('No traceback has been produced, nothing to debug.')
1449 return
1461 return
1450
1462
1451 # use pydb if available
1463 # use pydb if available
1452 if Debugger.has_pydb:
1464 if Debugger.has_pydb:
1453 from pydb import pm
1465 from pydb import pm
1454 else:
1466 else:
1455 # fallback to our internal debugger
1467 # fallback to our internal debugger
1456 pm = lambda : self.InteractiveTB.debugger(force=True)
1468 pm = lambda : self.InteractiveTB.debugger(force=True)
1457 self.history_saving_wrapper(pm)()
1469 self.history_saving_wrapper(pm)()
1458
1470
1459 def showtraceback(self,exc_tuple = None,filename=None,tb_offset=None):
1471 def showtraceback(self,exc_tuple = None,filename=None,tb_offset=None):
1460 """Display the exception that just occurred.
1472 """Display the exception that just occurred.
1461
1473
1462 If nothing is known about the exception, this is the method which
1474 If nothing is known about the exception, this is the method which
1463 should be used throughout the code for presenting user tracebacks,
1475 should be used throughout the code for presenting user tracebacks,
1464 rather than directly invoking the InteractiveTB object.
1476 rather than directly invoking the InteractiveTB object.
1465
1477
1466 A specific showsyntaxerror() also exists, but this method can take
1478 A specific showsyntaxerror() also exists, but this method can take
1467 care of calling it if needed, so unless you are explicitly catching a
1479 care of calling it if needed, so unless you are explicitly catching a
1468 SyntaxError exception, don't try to analyze the stack manually and
1480 SyntaxError exception, don't try to analyze the stack manually and
1469 simply call this method."""
1481 simply call this method."""
1470
1482
1471 # Though this won't be called by syntax errors in the input line,
1483 # Though this won't be called by syntax errors in the input line,
1472 # there may be SyntaxError cases whith imported code.
1484 # there may be SyntaxError cases whith imported code.
1473 if exc_tuple is None:
1485 if exc_tuple is None:
1474 etype, value, tb = sys.exc_info()
1486 etype, value, tb = sys.exc_info()
1475 else:
1487 else:
1476 etype, value, tb = exc_tuple
1488 etype, value, tb = exc_tuple
1477
1489
1478 if etype is SyntaxError:
1490 if etype is SyntaxError:
1479 self.showsyntaxerror(filename)
1491 self.showsyntaxerror(filename)
1480 else:
1492 else:
1481 # WARNING: these variables are somewhat deprecated and not
1493 # WARNING: these variables are somewhat deprecated and not
1482 # necessarily safe to use in a threaded environment, but tools
1494 # necessarily safe to use in a threaded environment, but tools
1483 # like pdb depend on their existence, so let's set them. If we
1495 # like pdb depend on their existence, so let's set them. If we
1484 # find problems in the field, we'll need to revisit their use.
1496 # find problems in the field, we'll need to revisit their use.
1485 sys.last_type = etype
1497 sys.last_type = etype
1486 sys.last_value = value
1498 sys.last_value = value
1487 sys.last_traceback = tb
1499 sys.last_traceback = tb
1488
1500
1489 if etype in self.custom_exceptions:
1501 if etype in self.custom_exceptions:
1490 self.CustomTB(etype,value,tb)
1502 self.CustomTB(etype,value,tb)
1491 else:
1503 else:
1492 self.InteractiveTB(etype,value,tb,tb_offset=tb_offset)
1504 self.InteractiveTB(etype,value,tb,tb_offset=tb_offset)
1493 if self.InteractiveTB.call_pdb and self.has_readline:
1505 if self.InteractiveTB.call_pdb and self.has_readline:
1494 # pdb mucks up readline, fix it back
1506 # pdb mucks up readline, fix it back
1495 self.set_completer()
1507 self.set_completer()
1496
1508
1497 def mainloop(self,banner=None):
1509 def mainloop(self,banner=None):
1498 """Creates the local namespace and starts the mainloop.
1510 """Creates the local namespace and starts the mainloop.
1499
1511
1500 If an optional banner argument is given, it will override the
1512 If an optional banner argument is given, it will override the
1501 internally created default banner."""
1513 internally created default banner."""
1502
1514
1503 if self.rc.c: # Emulate Python's -c option
1515 if self.rc.c: # Emulate Python's -c option
1504 self.exec_init_cmd()
1516 self.exec_init_cmd()
1505 if banner is None:
1517 if banner is None:
1506 if not self.rc.banner:
1518 if not self.rc.banner:
1507 banner = ''
1519 banner = ''
1508 # banner is string? Use it directly!
1520 # banner is string? Use it directly!
1509 elif isinstance(self.rc.banner,basestring):
1521 elif isinstance(self.rc.banner,basestring):
1510 banner = self.rc.banner
1522 banner = self.rc.banner
1511 else:
1523 else:
1512 banner = self.BANNER+self.banner2
1524 banner = self.BANNER+self.banner2
1513
1525
1514 self.interact(banner)
1526 self.interact(banner)
1515
1527
1516 def exec_init_cmd(self):
1528 def exec_init_cmd(self):
1517 """Execute a command given at the command line.
1529 """Execute a command given at the command line.
1518
1530
1519 This emulates Python's -c option."""
1531 This emulates Python's -c option."""
1520
1532
1521 #sys.argv = ['-c']
1533 #sys.argv = ['-c']
1522 self.push(self.rc.c)
1534 self.push(self.rc.c)
1523
1535
1524 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1536 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1525 """Embeds IPython into a running python program.
1537 """Embeds IPython into a running python program.
1526
1538
1527 Input:
1539 Input:
1528
1540
1529 - header: An optional header message can be specified.
1541 - header: An optional header message can be specified.
1530
1542
1531 - local_ns, global_ns: working namespaces. If given as None, the
1543 - local_ns, global_ns: working namespaces. If given as None, the
1532 IPython-initialized one is updated with __main__.__dict__, so that
1544 IPython-initialized one is updated with __main__.__dict__, so that
1533 program variables become visible but user-specific configuration
1545 program variables become visible but user-specific configuration
1534 remains possible.
1546 remains possible.
1535
1547
1536 - stack_depth: specifies how many levels in the stack to go to
1548 - stack_depth: specifies how many levels in the stack to go to
1537 looking for namespaces (when local_ns and global_ns are None). This
1549 looking for namespaces (when local_ns and global_ns are None). This
1538 allows an intermediate caller to make sure that this function gets
1550 allows an intermediate caller to make sure that this function gets
1539 the namespace from the intended level in the stack. By default (0)
1551 the namespace from the intended level in the stack. By default (0)
1540 it will get its locals and globals from the immediate caller.
1552 it will get its locals and globals from the immediate caller.
1541
1553
1542 Warning: it's possible to use this in a program which is being run by
1554 Warning: it's possible to use this in a program which is being run by
1543 IPython itself (via %run), but some funny things will happen (a few
1555 IPython itself (via %run), but some funny things will happen (a few
1544 globals get overwritten). In the future this will be cleaned up, as
1556 globals get overwritten). In the future this will be cleaned up, as
1545 there is no fundamental reason why it can't work perfectly."""
1557 there is no fundamental reason why it can't work perfectly."""
1546
1558
1547 # Get locals and globals from caller
1559 # Get locals and globals from caller
1548 if local_ns is None or global_ns is None:
1560 if local_ns is None or global_ns is None:
1549 call_frame = sys._getframe(stack_depth).f_back
1561 call_frame = sys._getframe(stack_depth).f_back
1550
1562
1551 if local_ns is None:
1563 if local_ns is None:
1552 local_ns = call_frame.f_locals
1564 local_ns = call_frame.f_locals
1553 if global_ns is None:
1565 if global_ns is None:
1554 global_ns = call_frame.f_globals
1566 global_ns = call_frame.f_globals
1555
1567
1556 # Update namespaces and fire up interpreter
1568 # Update namespaces and fire up interpreter
1557
1569
1558 # The global one is easy, we can just throw it in
1570 # The global one is easy, we can just throw it in
1559 self.user_global_ns = global_ns
1571 self.user_global_ns = global_ns
1560
1572
1561 # but the user/local one is tricky: ipython needs it to store internal
1573 # but the user/local one is tricky: ipython needs it to store internal
1562 # data, but we also need the locals. We'll copy locals in the user
1574 # data, but we also need the locals. We'll copy locals in the user
1563 # one, but will track what got copied so we can delete them at exit.
1575 # one, but will track what got copied so we can delete them at exit.
1564 # This is so that a later embedded call doesn't see locals from a
1576 # This is so that a later embedded call doesn't see locals from a
1565 # previous call (which most likely existed in a separate scope).
1577 # previous call (which most likely existed in a separate scope).
1566 local_varnames = local_ns.keys()
1578 local_varnames = local_ns.keys()
1567 self.user_ns.update(local_ns)
1579 self.user_ns.update(local_ns)
1568
1580
1569 # Patch for global embedding to make sure that things don't overwrite
1581 # Patch for global embedding to make sure that things don't overwrite
1570 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1582 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1571 # FIXME. Test this a bit more carefully (the if.. is new)
1583 # FIXME. Test this a bit more carefully (the if.. is new)
1572 if local_ns is None and global_ns is None:
1584 if local_ns is None and global_ns is None:
1573 self.user_global_ns.update(__main__.__dict__)
1585 self.user_global_ns.update(__main__.__dict__)
1574
1586
1575 # make sure the tab-completer has the correct frame information, so it
1587 # make sure the tab-completer has the correct frame information, so it
1576 # actually completes using the frame's locals/globals
1588 # actually completes using the frame's locals/globals
1577 self.set_completer_frame()
1589 self.set_completer_frame()
1578
1590
1579 # before activating the interactive mode, we need to make sure that
1591 # before activating the interactive mode, we need to make sure that
1580 # all names in the builtin namespace needed by ipython point to
1592 # all names in the builtin namespace needed by ipython point to
1581 # ourselves, and not to other instances.
1593 # ourselves, and not to other instances.
1582 self.add_builtins()
1594 self.add_builtins()
1583
1595
1584 self.interact(header)
1596 self.interact(header)
1585
1597
1586 # now, purge out the user namespace from anything we might have added
1598 # now, purge out the user namespace from anything we might have added
1587 # from the caller's local namespace
1599 # from the caller's local namespace
1588 delvar = self.user_ns.pop
1600 delvar = self.user_ns.pop
1589 for var in local_varnames:
1601 for var in local_varnames:
1590 delvar(var,None)
1602 delvar(var,None)
1591 # and clean builtins we may have overridden
1603 # and clean builtins we may have overridden
1592 self.clean_builtins()
1604 self.clean_builtins()
1593
1605
1594 def interact(self, banner=None):
1606 def interact(self, banner=None):
1595 """Closely emulate the interactive Python console.
1607 """Closely emulate the interactive Python console.
1596
1608
1597 The optional banner argument specify the banner to print
1609 The optional banner argument specify the banner to print
1598 before the first interaction; by default it prints a banner
1610 before the first interaction; by default it prints a banner
1599 similar to the one printed by the real Python interpreter,
1611 similar to the one printed by the real Python interpreter,
1600 followed by the current class name in parentheses (so as not
1612 followed by the current class name in parentheses (so as not
1601 to confuse this with the real interpreter -- since it's so
1613 to confuse this with the real interpreter -- since it's so
1602 close!).
1614 close!).
1603
1615
1604 """
1616 """
1605
1617
1606 if self.exit_now:
1618 if self.exit_now:
1607 # batch run -> do not interact
1619 # batch run -> do not interact
1608 return
1620 return
1609 cprt = 'Type "copyright", "credits" or "license" for more information.'
1621 cprt = 'Type "copyright", "credits" or "license" for more information.'
1610 if banner is None:
1622 if banner is None:
1611 self.write("Python %s on %s\n%s\n(%s)\n" %
1623 self.write("Python %s on %s\n%s\n(%s)\n" %
1612 (sys.version, sys.platform, cprt,
1624 (sys.version, sys.platform, cprt,
1613 self.__class__.__name__))
1625 self.__class__.__name__))
1614 else:
1626 else:
1615 self.write(banner)
1627 self.write(banner)
1616
1628
1617 more = 0
1629 more = 0
1618
1630
1619 # Mark activity in the builtins
1631 # Mark activity in the builtins
1620 __builtin__.__dict__['__IPYTHON__active'] += 1
1632 __builtin__.__dict__['__IPYTHON__active'] += 1
1621
1633
1622 # exit_now is set by a call to %Exit or %Quit
1634 # exit_now is set by a call to %Exit or %Quit
1623 while not self.exit_now:
1635 while not self.exit_now:
1624 if more:
1636 if more:
1625 prompt = self.hooks.generate_prompt(True)
1637 prompt = self.hooks.generate_prompt(True)
1626 if self.autoindent:
1638 if self.autoindent:
1627 self.readline_startup_hook(self.pre_readline)
1639 self.readline_startup_hook(self.pre_readline)
1628 else:
1640 else:
1629 prompt = self.hooks.generate_prompt(False)
1641 prompt = self.hooks.generate_prompt(False)
1630 try:
1642 try:
1631 line = self.raw_input(prompt,more)
1643 line = self.raw_input(prompt,more)
1632 if self.exit_now:
1644 if self.exit_now:
1633 # quick exit on sys.std[in|out] close
1645 # quick exit on sys.std[in|out] close
1634 break
1646 break
1635 if self.autoindent:
1647 if self.autoindent:
1636 self.readline_startup_hook(None)
1648 self.readline_startup_hook(None)
1637 except KeyboardInterrupt:
1649 except KeyboardInterrupt:
1638 self.write('\nKeyboardInterrupt\n')
1650 self.write('\nKeyboardInterrupt\n')
1639 self.resetbuffer()
1651 self.resetbuffer()
1640 # keep cache in sync with the prompt counter:
1652 # keep cache in sync with the prompt counter:
1641 self.outputcache.prompt_count -= 1
1653 self.outputcache.prompt_count -= 1
1642
1654
1643 if self.autoindent:
1655 if self.autoindent:
1644 self.indent_current_nsp = 0
1656 self.indent_current_nsp = 0
1645 more = 0
1657 more = 0
1646 except EOFError:
1658 except EOFError:
1647 if self.autoindent:
1659 if self.autoindent:
1648 self.readline_startup_hook(None)
1660 self.readline_startup_hook(None)
1649 self.write('\n')
1661 self.write('\n')
1650 self.exit()
1662 self.exit()
1651 except bdb.BdbQuit:
1663 except bdb.BdbQuit:
1652 warn('The Python debugger has exited with a BdbQuit exception.\n'
1664 warn('The Python debugger has exited with a BdbQuit exception.\n'
1653 'Because of how pdb handles the stack, it is impossible\n'
1665 'Because of how pdb handles the stack, it is impossible\n'
1654 'for IPython to properly format this particular exception.\n'
1666 'for IPython to properly format this particular exception.\n'
1655 'IPython will resume normal operation.')
1667 'IPython will resume normal operation.')
1656 except:
1668 except:
1657 # exceptions here are VERY RARE, but they can be triggered
1669 # exceptions here are VERY RARE, but they can be triggered
1658 # asynchronously by signal handlers, for example.
1670 # asynchronously by signal handlers, for example.
1659 self.showtraceback()
1671 self.showtraceback()
1660 else:
1672 else:
1661 more = self.push(line)
1673 more = self.push(line)
1662 if (self.SyntaxTB.last_syntax_error and
1674 if (self.SyntaxTB.last_syntax_error and
1663 self.rc.autoedit_syntax):
1675 self.rc.autoedit_syntax):
1664 self.edit_syntax_error()
1676 self.edit_syntax_error()
1665
1677
1666 # We are off again...
1678 # We are off again...
1667 __builtin__.__dict__['__IPYTHON__active'] -= 1
1679 __builtin__.__dict__['__IPYTHON__active'] -= 1
1668
1680
1669 def excepthook(self, etype, value, tb):
1681 def excepthook(self, etype, value, tb):
1670 """One more defense for GUI apps that call sys.excepthook.
1682 """One more defense for GUI apps that call sys.excepthook.
1671
1683
1672 GUI frameworks like wxPython trap exceptions and call
1684 GUI frameworks like wxPython trap exceptions and call
1673 sys.excepthook themselves. I guess this is a feature that
1685 sys.excepthook themselves. I guess this is a feature that
1674 enables them to keep running after exceptions that would
1686 enables them to keep running after exceptions that would
1675 otherwise kill their mainloop. This is a bother for IPython
1687 otherwise kill their mainloop. This is a bother for IPython
1676 which excepts to catch all of the program exceptions with a try:
1688 which excepts to catch all of the program exceptions with a try:
1677 except: statement.
1689 except: statement.
1678
1690
1679 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1691 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1680 any app directly invokes sys.excepthook, it will look to the user like
1692 any app directly invokes sys.excepthook, it will look to the user like
1681 IPython crashed. In order to work around this, we can disable the
1693 IPython crashed. In order to work around this, we can disable the
1682 CrashHandler and replace it with this excepthook instead, which prints a
1694 CrashHandler and replace it with this excepthook instead, which prints a
1683 regular traceback using our InteractiveTB. In this fashion, apps which
1695 regular traceback using our InteractiveTB. In this fashion, apps which
1684 call sys.excepthook will generate a regular-looking exception from
1696 call sys.excepthook will generate a regular-looking exception from
1685 IPython, and the CrashHandler will only be triggered by real IPython
1697 IPython, and the CrashHandler will only be triggered by real IPython
1686 crashes.
1698 crashes.
1687
1699
1688 This hook should be used sparingly, only in places which are not likely
1700 This hook should be used sparingly, only in places which are not likely
1689 to be true IPython errors.
1701 to be true IPython errors.
1690 """
1702 """
1691 self.showtraceback((etype,value,tb),tb_offset=0)
1703 self.showtraceback((etype,value,tb),tb_offset=0)
1692
1704
1693 def expand_aliases(self,fn,rest):
1705 def expand_aliases(self,fn,rest):
1694 """ Expand multiple levels of aliases:
1706 """ Expand multiple levels of aliases:
1695
1707
1696 if:
1708 if:
1697
1709
1698 alias foo bar /tmp
1710 alias foo bar /tmp
1699 alias baz foo
1711 alias baz foo
1700
1712
1701 then:
1713 then:
1702
1714
1703 baz huhhahhei -> bar /tmp huhhahhei
1715 baz huhhahhei -> bar /tmp huhhahhei
1704
1716
1705 """
1717 """
1706 line = fn + " " + rest
1718 line = fn + " " + rest
1707
1719
1708 done = Set()
1720 done = Set()
1709 while 1:
1721 while 1:
1710 pre,fn,rest = self.split_user_input(line, pattern = self.shell_line_split)
1722 pre,fn,rest = self.split_user_input(line, pattern = self.shell_line_split)
1711 # print "!",fn,"!",rest # dbg
1723 # print "!",fn,"!",rest # dbg
1712 if fn in self.alias_table:
1724 if fn in self.alias_table:
1713 if fn in done:
1725 if fn in done:
1714 warn("Cyclic alias definition, repeated '%s'" % fn)
1726 warn("Cyclic alias definition, repeated '%s'" % fn)
1715 return ""
1727 return ""
1716 done.add(fn)
1728 done.add(fn)
1717
1729
1718 l2 = self.transform_alias(fn,rest)
1730 l2 = self.transform_alias(fn,rest)
1719 # dir -> dir
1731 # dir -> dir
1720 # print "alias",line, "->",l2 #dbg
1732 # print "alias",line, "->",l2 #dbg
1721 if l2 == line:
1733 if l2 == line:
1722 break
1734 break
1723 # ls -> ls -F should not recurse forever
1735 # ls -> ls -F should not recurse forever
1724 if l2.split(None,1)[0] == line.split(None,1)[0]:
1736 if l2.split(None,1)[0] == line.split(None,1)[0]:
1725 line = l2
1737 line = l2
1726 break
1738 break
1727
1739
1728 line=l2
1740 line=l2
1729
1741
1730
1742
1731 # print "al expand to",line #dbg
1743 # print "al expand to",line #dbg
1732 else:
1744 else:
1733 break
1745 break
1734
1746
1735 return line
1747 return line
1736
1748
1737 def transform_alias(self, alias,rest=''):
1749 def transform_alias(self, alias,rest=''):
1738 """ Transform alias to system command string.
1750 """ Transform alias to system command string.
1739 """
1751 """
1740 nargs,cmd = self.alias_table[alias]
1752 nargs,cmd = self.alias_table[alias]
1741 if ' ' in cmd and os.path.isfile(cmd):
1753 if ' ' in cmd and os.path.isfile(cmd):
1742 cmd = '"%s"' % cmd
1754 cmd = '"%s"' % cmd
1743
1755
1744 # Expand the %l special to be the user's input line
1756 # Expand the %l special to be the user's input line
1745 if cmd.find('%l') >= 0:
1757 if cmd.find('%l') >= 0:
1746 cmd = cmd.replace('%l',rest)
1758 cmd = cmd.replace('%l',rest)
1747 rest = ''
1759 rest = ''
1748 if nargs==0:
1760 if nargs==0:
1749 # Simple, argument-less aliases
1761 # Simple, argument-less aliases
1750 cmd = '%s %s' % (cmd,rest)
1762 cmd = '%s %s' % (cmd,rest)
1751 else:
1763 else:
1752 # Handle aliases with positional arguments
1764 # Handle aliases with positional arguments
1753 args = rest.split(None,nargs)
1765 args = rest.split(None,nargs)
1754 if len(args)< nargs:
1766 if len(args)< nargs:
1755 error('Alias <%s> requires %s arguments, %s given.' %
1767 error('Alias <%s> requires %s arguments, %s given.' %
1756 (alias,nargs,len(args)))
1768 (alias,nargs,len(args)))
1757 return None
1769 return None
1758 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1770 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1759 # Now call the macro, evaluating in the user's namespace
1771 # Now call the macro, evaluating in the user's namespace
1760 #print 'new command: <%r>' % cmd # dbg
1772 #print 'new command: <%r>' % cmd # dbg
1761 return cmd
1773 return cmd
1762
1774
1763 def call_alias(self,alias,rest=''):
1775 def call_alias(self,alias,rest=''):
1764 """Call an alias given its name and the rest of the line.
1776 """Call an alias given its name and the rest of the line.
1765
1777
1766 This is only used to provide backwards compatibility for users of
1778 This is only used to provide backwards compatibility for users of
1767 ipalias(), use of which is not recommended for anymore."""
1779 ipalias(), use of which is not recommended for anymore."""
1768
1780
1769 # Now call the macro, evaluating in the user's namespace
1781 # Now call the macro, evaluating in the user's namespace
1770 cmd = self.transform_alias(alias, rest)
1782 cmd = self.transform_alias(alias, rest)
1771 try:
1783 try:
1772 self.system(cmd)
1784 self.system(cmd)
1773 except:
1785 except:
1774 self.showtraceback()
1786 self.showtraceback()
1775
1787
1776 def indent_current_str(self):
1788 def indent_current_str(self):
1777 """return the current level of indentation as a string"""
1789 """return the current level of indentation as a string"""
1778 return self.indent_current_nsp * ' '
1790 return self.indent_current_nsp * ' '
1779
1791
1780 def autoindent_update(self,line):
1792 def autoindent_update(self,line):
1781 """Keep track of the indent level."""
1793 """Keep track of the indent level."""
1782
1794
1783 #debugx('line')
1795 #debugx('line')
1784 #debugx('self.indent_current_nsp')
1796 #debugx('self.indent_current_nsp')
1785 if self.autoindent:
1797 if self.autoindent:
1786 if line:
1798 if line:
1787 inisp = num_ini_spaces(line)
1799 inisp = num_ini_spaces(line)
1788 if inisp < self.indent_current_nsp:
1800 if inisp < self.indent_current_nsp:
1789 self.indent_current_nsp = inisp
1801 self.indent_current_nsp = inisp
1790
1802
1791 if line[-1] == ':':
1803 if line[-1] == ':':
1792 self.indent_current_nsp += 4
1804 self.indent_current_nsp += 4
1793 elif dedent_re.match(line):
1805 elif dedent_re.match(line):
1794 self.indent_current_nsp -= 4
1806 self.indent_current_nsp -= 4
1795 else:
1807 else:
1796 self.indent_current_nsp = 0
1808 self.indent_current_nsp = 0
1797
1809
1798 def runlines(self,lines):
1810 def runlines(self,lines):
1799 """Run a string of one or more lines of source.
1811 """Run a string of one or more lines of source.
1800
1812
1801 This method is capable of running a string containing multiple source
1813 This method is capable of running a string containing multiple source
1802 lines, as if they had been entered at the IPython prompt. Since it
1814 lines, as if they had been entered at the IPython prompt. Since it
1803 exposes IPython's processing machinery, the given strings can contain
1815 exposes IPython's processing machinery, the given strings can contain
1804 magic calls (%magic), special shell access (!cmd), etc."""
1816 magic calls (%magic), special shell access (!cmd), etc."""
1805
1817
1806 # We must start with a clean buffer, in case this is run from an
1818 # We must start with a clean buffer, in case this is run from an
1807 # interactive IPython session (via a magic, for example).
1819 # interactive IPython session (via a magic, for example).
1808 self.resetbuffer()
1820 self.resetbuffer()
1809 lines = lines.split('\n')
1821 lines = lines.split('\n')
1810 more = 0
1822 more = 0
1811 for line in lines:
1823 for line in lines:
1812 # skip blank lines so we don't mess up the prompt counter, but do
1824 # skip blank lines so we don't mess up the prompt counter, but do
1813 # NOT skip even a blank line if we are in a code block (more is
1825 # NOT skip even a blank line if we are in a code block (more is
1814 # true)
1826 # true)
1815 if line or more:
1827 if line or more:
1816 more = self.push(self.prefilter(line,more))
1828 more = self.push(self.prefilter(line,more))
1817 # IPython's runsource returns None if there was an error
1829 # IPython's runsource returns None if there was an error
1818 # compiling the code. This allows us to stop processing right
1830 # compiling the code. This allows us to stop processing right
1819 # away, so the user gets the error message at the right place.
1831 # away, so the user gets the error message at the right place.
1820 if more is None:
1832 if more is None:
1821 break
1833 break
1822 # final newline in case the input didn't have it, so that the code
1834 # final newline in case the input didn't have it, so that the code
1823 # actually does get executed
1835 # actually does get executed
1824 if more:
1836 if more:
1825 self.push('\n')
1837 self.push('\n')
1826
1838
1827 def runsource(self, source, filename='<input>', symbol='single'):
1839 def runsource(self, source, filename='<input>', symbol='single'):
1828 """Compile and run some source in the interpreter.
1840 """Compile and run some source in the interpreter.
1829
1841
1830 Arguments are as for compile_command().
1842 Arguments are as for compile_command().
1831
1843
1832 One several things can happen:
1844 One several things can happen:
1833
1845
1834 1) The input is incorrect; compile_command() raised an
1846 1) The input is incorrect; compile_command() raised an
1835 exception (SyntaxError or OverflowError). A syntax traceback
1847 exception (SyntaxError or OverflowError). A syntax traceback
1836 will be printed by calling the showsyntaxerror() method.
1848 will be printed by calling the showsyntaxerror() method.
1837
1849
1838 2) The input is incomplete, and more input is required;
1850 2) The input is incomplete, and more input is required;
1839 compile_command() returned None. Nothing happens.
1851 compile_command() returned None. Nothing happens.
1840
1852
1841 3) The input is complete; compile_command() returned a code
1853 3) The input is complete; compile_command() returned a code
1842 object. The code is executed by calling self.runcode() (which
1854 object. The code is executed by calling self.runcode() (which
1843 also handles run-time exceptions, except for SystemExit).
1855 also handles run-time exceptions, except for SystemExit).
1844
1856
1845 The return value is:
1857 The return value is:
1846
1858
1847 - True in case 2
1859 - True in case 2
1848
1860
1849 - False in the other cases, unless an exception is raised, where
1861 - False in the other cases, unless an exception is raised, where
1850 None is returned instead. This can be used by external callers to
1862 None is returned instead. This can be used by external callers to
1851 know whether to continue feeding input or not.
1863 know whether to continue feeding input or not.
1852
1864
1853 The return value can be used to decide whether to use sys.ps1 or
1865 The return value can be used to decide whether to use sys.ps1 or
1854 sys.ps2 to prompt the next line."""
1866 sys.ps2 to prompt the next line."""
1855
1867
1856 # if the source code has leading blanks, add 'if 1:\n' to it
1868 # if the source code has leading blanks, add 'if 1:\n' to it
1857 # this allows execution of indented pasted code. It is tempting
1869 # this allows execution of indented pasted code. It is tempting
1858 # to add '\n' at the end of source to run commands like ' a=1'
1870 # to add '\n' at the end of source to run commands like ' a=1'
1859 # directly, but this fails for more complicated scenarios
1871 # directly, but this fails for more complicated scenarios
1860 if source[:1] in [' ', '\t']:
1872 if source[:1] in [' ', '\t']:
1861 source = 'if 1:\n%s' % source
1873 source = 'if 1:\n%s' % source
1862
1874
1863 try:
1875 try:
1864 code = self.compile(source,filename,symbol)
1876 code = self.compile(source,filename,symbol)
1865 except (OverflowError, SyntaxError, ValueError):
1877 except (OverflowError, SyntaxError, ValueError):
1866 # Case 1
1878 # Case 1
1867 self.showsyntaxerror(filename)
1879 self.showsyntaxerror(filename)
1868 return None
1880 return None
1869
1881
1870 if code is None:
1882 if code is None:
1871 # Case 2
1883 # Case 2
1872 return True
1884 return True
1873
1885
1874 # Case 3
1886 # Case 3
1875 # We store the code object so that threaded shells and
1887 # We store the code object so that threaded shells and
1876 # custom exception handlers can access all this info if needed.
1888 # custom exception handlers can access all this info if needed.
1877 # The source corresponding to this can be obtained from the
1889 # The source corresponding to this can be obtained from the
1878 # buffer attribute as '\n'.join(self.buffer).
1890 # buffer attribute as '\n'.join(self.buffer).
1879 self.code_to_run = code
1891 self.code_to_run = code
1880 # now actually execute the code object
1892 # now actually execute the code object
1881 if self.runcode(code) == 0:
1893 if self.runcode(code) == 0:
1882 return False
1894 return False
1883 else:
1895 else:
1884 return None
1896 return None
1885
1897
1886 def runcode(self,code_obj):
1898 def runcode(self,code_obj):
1887 """Execute a code object.
1899 """Execute a code object.
1888
1900
1889 When an exception occurs, self.showtraceback() is called to display a
1901 When an exception occurs, self.showtraceback() is called to display a
1890 traceback.
1902 traceback.
1891
1903
1892 Return value: a flag indicating whether the code to be run completed
1904 Return value: a flag indicating whether the code to be run completed
1893 successfully:
1905 successfully:
1894
1906
1895 - 0: successful execution.
1907 - 0: successful execution.
1896 - 1: an error occurred.
1908 - 1: an error occurred.
1897 """
1909 """
1898
1910
1899 # Set our own excepthook in case the user code tries to call it
1911 # Set our own excepthook in case the user code tries to call it
1900 # directly, so that the IPython crash handler doesn't get triggered
1912 # directly, so that the IPython crash handler doesn't get triggered
1901 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1913 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1902
1914
1903 # we save the original sys.excepthook in the instance, in case config
1915 # we save the original sys.excepthook in the instance, in case config
1904 # code (such as magics) needs access to it.
1916 # code (such as magics) needs access to it.
1905 self.sys_excepthook = old_excepthook
1917 self.sys_excepthook = old_excepthook
1906 outflag = 1 # happens in more places, so it's easier as default
1918 outflag = 1 # happens in more places, so it's easier as default
1907 try:
1919 try:
1908 try:
1920 try:
1909 # Embedded instances require separate global/local namespaces
1921 # Embedded instances require separate global/local namespaces
1910 # so they can see both the surrounding (local) namespace and
1922 # so they can see both the surrounding (local) namespace and
1911 # the module-level globals when called inside another function.
1923 # the module-level globals when called inside another function.
1912 if self.embedded:
1924 if self.embedded:
1913 exec code_obj in self.user_global_ns, self.user_ns
1925 exec code_obj in self.user_global_ns, self.user_ns
1914 # Normal (non-embedded) instances should only have a single
1926 # Normal (non-embedded) instances should only have a single
1915 # namespace for user code execution, otherwise functions won't
1927 # namespace for user code execution, otherwise functions won't
1916 # see interactive top-level globals.
1928 # see interactive top-level globals.
1917 else:
1929 else:
1918 exec code_obj in self.user_ns
1930 exec code_obj in self.user_ns
1919 finally:
1931 finally:
1920 # Reset our crash handler in place
1932 # Reset our crash handler in place
1921 sys.excepthook = old_excepthook
1933 sys.excepthook = old_excepthook
1922 except SystemExit:
1934 except SystemExit:
1923 self.resetbuffer()
1935 self.resetbuffer()
1924 self.showtraceback()
1936 self.showtraceback()
1925 warn("Type %exit or %quit to exit IPython "
1937 warn("Type %exit or %quit to exit IPython "
1926 "(%Exit or %Quit do so unconditionally).",level=1)
1938 "(%Exit or %Quit do so unconditionally).",level=1)
1927 except self.custom_exceptions:
1939 except self.custom_exceptions:
1928 etype,value,tb = sys.exc_info()
1940 etype,value,tb = sys.exc_info()
1929 self.CustomTB(etype,value,tb)
1941 self.CustomTB(etype,value,tb)
1930 except:
1942 except:
1931 self.showtraceback()
1943 self.showtraceback()
1932 else:
1944 else:
1933 outflag = 0
1945 outflag = 0
1934 if softspace(sys.stdout, 0):
1946 if softspace(sys.stdout, 0):
1935 print
1947 print
1936 # Flush out code object which has been run (and source)
1948 # Flush out code object which has been run (and source)
1937 self.code_to_run = None
1949 self.code_to_run = None
1938 return outflag
1950 return outflag
1939
1951
1940 def push(self, line):
1952 def push(self, line):
1941 """Push a line to the interpreter.
1953 """Push a line to the interpreter.
1942
1954
1943 The line should not have a trailing newline; it may have
1955 The line should not have a trailing newline; it may have
1944 internal newlines. The line is appended to a buffer and the
1956 internal newlines. The line is appended to a buffer and the
1945 interpreter's runsource() method is called with the
1957 interpreter's runsource() method is called with the
1946 concatenated contents of the buffer as source. If this
1958 concatenated contents of the buffer as source. If this
1947 indicates that the command was executed or invalid, the buffer
1959 indicates that the command was executed or invalid, the buffer
1948 is reset; otherwise, the command is incomplete, and the buffer
1960 is reset; otherwise, the command is incomplete, and the buffer
1949 is left as it was after the line was appended. The return
1961 is left as it was after the line was appended. The return
1950 value is 1 if more input is required, 0 if the line was dealt
1962 value is 1 if more input is required, 0 if the line was dealt
1951 with in some way (this is the same as runsource()).
1963 with in some way (this is the same as runsource()).
1952 """
1964 """
1953
1965
1954 # autoindent management should be done here, and not in the
1966 # autoindent management should be done here, and not in the
1955 # interactive loop, since that one is only seen by keyboard input. We
1967 # interactive loop, since that one is only seen by keyboard input. We
1956 # need this done correctly even for code run via runlines (which uses
1968 # need this done correctly even for code run via runlines (which uses
1957 # push).
1969 # push).
1958
1970
1959 #print 'push line: <%s>' % line # dbg
1971 #print 'push line: <%s>' % line # dbg
1960 for subline in line.splitlines():
1972 for subline in line.splitlines():
1961 self.autoindent_update(subline)
1973 self.autoindent_update(subline)
1962 self.buffer.append(line)
1974 self.buffer.append(line)
1963 more = self.runsource('\n'.join(self.buffer), self.filename)
1975 more = self.runsource('\n'.join(self.buffer), self.filename)
1964 if not more:
1976 if not more:
1965 self.resetbuffer()
1977 self.resetbuffer()
1966 return more
1978 return more
1967
1979
1968 def resetbuffer(self):
1980 def resetbuffer(self):
1969 """Reset the input buffer."""
1981 """Reset the input buffer."""
1970 self.buffer[:] = []
1982 self.buffer[:] = []
1971
1983
1972 def raw_input(self,prompt='',continue_prompt=False):
1984 def raw_input(self,prompt='',continue_prompt=False):
1973 """Write a prompt and read a line.
1985 """Write a prompt and read a line.
1974
1986
1975 The returned line does not include the trailing newline.
1987 The returned line does not include the trailing newline.
1976 When the user enters the EOF key sequence, EOFError is raised.
1988 When the user enters the EOF key sequence, EOFError is raised.
1977
1989
1978 Optional inputs:
1990 Optional inputs:
1979
1991
1980 - prompt(''): a string to be printed to prompt the user.
1992 - prompt(''): a string to be printed to prompt the user.
1981
1993
1982 - continue_prompt(False): whether this line is the first one or a
1994 - continue_prompt(False): whether this line is the first one or a
1983 continuation in a sequence of inputs.
1995 continuation in a sequence of inputs.
1984 """
1996 """
1985
1997
1986 # Code run by the user may have modified the readline completer state.
1998 # Code run by the user may have modified the readline completer state.
1987 # We must ensure that our completer is back in place.
1999 # We must ensure that our completer is back in place.
1988 self.set_completer()
2000 self.set_completer()
1989
2001
1990 try:
2002 try:
1991 line = raw_input_original(prompt).decode(sys.stdin.encoding)
2003 line = raw_input_original(prompt).decode(self.stdin_encoding)
1992 except ValueError:
2004 except ValueError:
1993 warn("\n********\nYou or a %run:ed script called sys.stdin.close()"
2005 warn("\n********\nYou or a %run:ed script called sys.stdin.close()"
1994 " or sys.stdout.close()!\nExiting IPython!")
2006 " or sys.stdout.close()!\nExiting IPython!")
1995 self.exit_now = True
2007 self.exit_now = True
1996 return ""
2008 return ""
1997
2009
1998 # Try to be reasonably smart about not re-indenting pasted input more
2010 # Try to be reasonably smart about not re-indenting pasted input more
1999 # than necessary. We do this by trimming out the auto-indent initial
2011 # than necessary. We do this by trimming out the auto-indent initial
2000 # spaces, if the user's actual input started itself with whitespace.
2012 # spaces, if the user's actual input started itself with whitespace.
2001 #debugx('self.buffer[-1]')
2013 #debugx('self.buffer[-1]')
2002
2014
2003 if self.autoindent:
2015 if self.autoindent:
2004 if num_ini_spaces(line) > self.indent_current_nsp:
2016 if num_ini_spaces(line) > self.indent_current_nsp:
2005 line = line[self.indent_current_nsp:]
2017 line = line[self.indent_current_nsp:]
2006 self.indent_current_nsp = 0
2018 self.indent_current_nsp = 0
2007
2019
2008 # store the unfiltered input before the user has any chance to modify
2020 # store the unfiltered input before the user has any chance to modify
2009 # it.
2021 # it.
2010 if line.strip():
2022 if line.strip():
2011 if continue_prompt:
2023 if continue_prompt:
2012 self.input_hist_raw[-1] += '%s\n' % line
2024 self.input_hist_raw[-1] += '%s\n' % line
2013 if self.has_readline: # and some config option is set?
2025 if self.has_readline: # and some config option is set?
2014 try:
2026 try:
2015 histlen = self.readline.get_current_history_length()
2027 histlen = self.readline.get_current_history_length()
2016 newhist = self.input_hist_raw[-1].rstrip()
2028 newhist = self.input_hist_raw[-1].rstrip()
2017 self.readline.remove_history_item(histlen-1)
2029 self.readline.remove_history_item(histlen-1)
2018 self.readline.replace_history_item(histlen-2,newhist)
2030 self.readline.replace_history_item(histlen-2,newhist)
2019 except AttributeError:
2031 except AttributeError:
2020 pass # re{move,place}_history_item are new in 2.4.
2032 pass # re{move,place}_history_item are new in 2.4.
2021 else:
2033 else:
2022 self.input_hist_raw.append('%s\n' % line)
2034 self.input_hist_raw.append('%s\n' % line)
2023
2035
2024 try:
2036 try:
2025 lineout = self.prefilter(line,continue_prompt)
2037 lineout = self.prefilter(line,continue_prompt)
2026 except:
2038 except:
2027 # blanket except, in case a user-defined prefilter crashes, so it
2039 # blanket except, in case a user-defined prefilter crashes, so it
2028 # can't take all of ipython with it.
2040 # can't take all of ipython with it.
2029 self.showtraceback()
2041 self.showtraceback()
2030 return ''
2042 return ''
2031 else:
2043 else:
2032 return lineout
2044 return lineout
2033
2045
2034 def split_user_input(self,line, pattern = None):
2046 def split_user_input(self,line, pattern = None):
2035 """Split user input into pre-char, function part and rest."""
2047 """Split user input into pre-char, function part and rest."""
2036
2048
2037 if pattern is None:
2049 if pattern is None:
2038 pattern = self.line_split
2050 pattern = self.line_split
2039
2051
2040 lsplit = pattern.match(line)
2052 lsplit = pattern.match(line)
2041 if lsplit is None: # no regexp match returns None
2053 if lsplit is None: # no regexp match returns None
2042 #print "match failed for line '%s'" % line # dbg
2054 #print "match failed for line '%s'" % line # dbg
2043 try:
2055 try:
2044 iFun,theRest = line.split(None,1)
2056 iFun,theRest = line.split(None,1)
2045 except ValueError:
2057 except ValueError:
2046 #print "split failed for line '%s'" % line # dbg
2058 #print "split failed for line '%s'" % line # dbg
2047 iFun,theRest = line,''
2059 iFun,theRest = line,''
2048 pre = re.match('^(\s*)(.*)',line).groups()[0]
2060 pre = re.match('^(\s*)(.*)',line).groups()[0]
2049 else:
2061 else:
2050 pre,iFun,theRest = lsplit.groups()
2062 pre,iFun,theRest = lsplit.groups()
2051
2063
2052 # iFun has to be a valid python identifier, so it better be only pure
2064 # iFun has to be a valid python identifier, so it better be only pure
2053 #ascii, no unicode:
2065 #ascii, no unicode:
2054 try:
2066 try:
2055 iFun = iFun.encode('ascii')
2067 iFun = iFun.encode('ascii')
2056 except UnicodeEncodeError:
2068 except UnicodeEncodeError:
2057 theRest = iFun+u' '+theRest
2069 theRest = iFun+u' '+theRest
2058 iFun = u''
2070 iFun = u''
2059
2071
2060 #print 'line:<%s>' % line # dbg
2072 #print 'line:<%s>' % line # dbg
2061 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
2073 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
2062 return pre,iFun.strip(),theRest
2074 return pre,iFun.strip(),theRest
2063
2075
2064 # THIS VERSION IS BROKEN!!! It was intended to prevent spurious attribute
2076 # THIS VERSION IS BROKEN!!! It was intended to prevent spurious attribute
2065 # accesses with a more stringent check of inputs, but it introduced other
2077 # accesses with a more stringent check of inputs, but it introduced other
2066 # bugs. Disable it for now until I can properly fix it.
2078 # bugs. Disable it for now until I can properly fix it.
2067 def split_user_inputBROKEN(self,line):
2079 def split_user_inputBROKEN(self,line):
2068 """Split user input into pre-char, function part and rest."""
2080 """Split user input into pre-char, function part and rest."""
2069
2081
2070 lsplit = self.line_split.match(line)
2082 lsplit = self.line_split.match(line)
2071 if lsplit is None: # no regexp match returns None
2083 if lsplit is None: # no regexp match returns None
2072 lsplit = self.line_split_fallback.match(line)
2084 lsplit = self.line_split_fallback.match(line)
2073
2085
2074 #pre,iFun,theRest = lsplit.groups() # dbg
2086 #pre,iFun,theRest = lsplit.groups() # dbg
2075 #print 'line:<%s>' % line # dbg
2087 #print 'line:<%s>' % line # dbg
2076 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
2088 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
2077 #return pre,iFun.strip(),theRest # dbg
2089 #return pre,iFun.strip(),theRest # dbg
2078
2090
2079 return lsplit.groups()
2091 return lsplit.groups()
2080
2092
2081 def _prefilter(self, line, continue_prompt):
2093 def _prefilter(self, line, continue_prompt):
2082 """Calls different preprocessors, depending on the form of line."""
2094 """Calls different preprocessors, depending on the form of line."""
2083
2095
2084 # All handlers *must* return a value, even if it's blank ('').
2096 # All handlers *must* return a value, even if it's blank ('').
2085
2097
2086 # Lines are NOT logged here. Handlers should process the line as
2098 # Lines are NOT logged here. Handlers should process the line as
2087 # needed, update the cache AND log it (so that the input cache array
2099 # needed, update the cache AND log it (so that the input cache array
2088 # stays synced).
2100 # stays synced).
2089
2101
2090 # This function is _very_ delicate, and since it's also the one which
2102 # This function is _very_ delicate, and since it's also the one which
2091 # determines IPython's response to user input, it must be as efficient
2103 # determines IPython's response to user input, it must be as efficient
2092 # as possible. For this reason it has _many_ returns in it, trying
2104 # as possible. For this reason it has _many_ returns in it, trying
2093 # always to exit as quickly as it can figure out what it needs to do.
2105 # always to exit as quickly as it can figure out what it needs to do.
2094
2106
2095 # This function is the main responsible for maintaining IPython's
2107 # This function is the main responsible for maintaining IPython's
2096 # behavior respectful of Python's semantics. So be _very_ careful if
2108 # behavior respectful of Python's semantics. So be _very_ careful if
2097 # making changes to anything here.
2109 # making changes to anything here.
2098
2110
2099 #.....................................................................
2111 #.....................................................................
2100 # Code begins
2112 # Code begins
2101
2113
2102 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
2114 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
2103
2115
2104 # save the line away in case we crash, so the post-mortem handler can
2116 # save the line away in case we crash, so the post-mortem handler can
2105 # record it
2117 # record it
2106 self._last_input_line = line
2118 self._last_input_line = line
2107
2119
2108 #print '***line: <%s>' % line # dbg
2120 #print '***line: <%s>' % line # dbg
2109
2121
2110 # the input history needs to track even empty lines
2122 # the input history needs to track even empty lines
2111 stripped = line.strip()
2123 stripped = line.strip()
2112
2124
2113 if not stripped:
2125 if not stripped:
2114 if not continue_prompt:
2126 if not continue_prompt:
2115 self.outputcache.prompt_count -= 1
2127 self.outputcache.prompt_count -= 1
2116 return self.handle_normal(line,continue_prompt)
2128 return self.handle_normal(line,continue_prompt)
2117 #return self.handle_normal('',continue_prompt)
2129 #return self.handle_normal('',continue_prompt)
2118
2130
2119 # print '***cont',continue_prompt # dbg
2131 # print '***cont',continue_prompt # dbg
2120 # special handlers are only allowed for single line statements
2132 # special handlers are only allowed for single line statements
2121 if continue_prompt and not self.rc.multi_line_specials:
2133 if continue_prompt and not self.rc.multi_line_specials:
2122 return self.handle_normal(line,continue_prompt)
2134 return self.handle_normal(line,continue_prompt)
2123
2135
2124
2136
2125 # For the rest, we need the structure of the input
2137 # For the rest, we need the structure of the input
2126 pre,iFun,theRest = self.split_user_input(line)
2138 pre,iFun,theRest = self.split_user_input(line)
2127
2139
2128 # See whether any pre-existing handler can take care of it
2140 # See whether any pre-existing handler can take care of it
2129
2141
2130 rewritten = self.hooks.input_prefilter(stripped)
2142 rewritten = self.hooks.input_prefilter(stripped)
2131 if rewritten != stripped: # ok, some prefilter did something
2143 if rewritten != stripped: # ok, some prefilter did something
2132 rewritten = pre + rewritten # add indentation
2144 rewritten = pre + rewritten # add indentation
2133 return self.handle_normal(rewritten)
2145 return self.handle_normal(rewritten)
2134
2146
2135 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2147 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2136
2148
2137 # Next, check if we can automatically execute this thing
2149 # Next, check if we can automatically execute this thing
2138
2150
2139 # Allow ! in multi-line statements if multi_line_specials is on:
2151 # Allow ! in multi-line statements if multi_line_specials is on:
2140 if continue_prompt and self.rc.multi_line_specials and \
2152 if continue_prompt and self.rc.multi_line_specials and \
2141 iFun.startswith(self.ESC_SHELL):
2153 iFun.startswith(self.ESC_SHELL):
2142 return self.handle_shell_escape(line,continue_prompt,
2154 return self.handle_shell_escape(line,continue_prompt,
2143 pre=pre,iFun=iFun,
2155 pre=pre,iFun=iFun,
2144 theRest=theRest)
2156 theRest=theRest)
2145
2157
2146 # First check for explicit escapes in the last/first character
2158 # First check for explicit escapes in the last/first character
2147 handler = None
2159 handler = None
2148 if line[-1] == self.ESC_HELP and line[0] != self.ESC_SHELL:
2160 if line[-1] == self.ESC_HELP and line[0] != self.ESC_SHELL:
2149 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
2161 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
2150 if handler is None:
2162 if handler is None:
2151 # look at the first character of iFun, NOT of line, so we skip
2163 # look at the first character of iFun, NOT of line, so we skip
2152 # leading whitespace in multiline input
2164 # leading whitespace in multiline input
2153 handler = self.esc_handlers.get(iFun[0:1])
2165 handler = self.esc_handlers.get(iFun[0:1])
2154 if handler is not None:
2166 if handler is not None:
2155 return handler(line,continue_prompt,pre,iFun,theRest)
2167 return handler(line,continue_prompt,pre,iFun,theRest)
2156 # Emacs ipython-mode tags certain input lines
2168 # Emacs ipython-mode tags certain input lines
2157 if line.endswith('# PYTHON-MODE'):
2169 if line.endswith('# PYTHON-MODE'):
2158 return self.handle_emacs(line,continue_prompt)
2170 return self.handle_emacs(line,continue_prompt)
2159
2171
2160 # Let's try to find if the input line is a magic fn
2172 # Let's try to find if the input line is a magic fn
2161 oinfo = None
2173 oinfo = None
2162 if hasattr(self,'magic_'+iFun):
2174 if hasattr(self,'magic_'+iFun):
2163 # WARNING: _ofind uses getattr(), so it can consume generators and
2175 # WARNING: _ofind uses getattr(), so it can consume generators and
2164 # cause other side effects.
2176 # cause other side effects.
2165 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
2177 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
2166 if oinfo['ismagic']:
2178 if oinfo['ismagic']:
2167 # Be careful not to call magics when a variable assignment is
2179 # Be careful not to call magics when a variable assignment is
2168 # being made (ls='hi', for example)
2180 # being made (ls='hi', for example)
2169 if self.rc.automagic and \
2181 if self.rc.automagic and \
2170 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
2182 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
2171 (self.rc.multi_line_specials or not continue_prompt):
2183 (self.rc.multi_line_specials or not continue_prompt):
2172 return self.handle_magic(line,continue_prompt,
2184 return self.handle_magic(line,continue_prompt,
2173 pre,iFun,theRest)
2185 pre,iFun,theRest)
2174 else:
2186 else:
2175 return self.handle_normal(line,continue_prompt)
2187 return self.handle_normal(line,continue_prompt)
2176
2188
2177 # If the rest of the line begins with an (in)equality, assginment or
2189 # If the rest of the line begins with an (in)equality, assginment or
2178 # function call, we should not call _ofind but simply execute it.
2190 # function call, we should not call _ofind but simply execute it.
2179 # This avoids spurious geattr() accesses on objects upon assignment.
2191 # This avoids spurious geattr() accesses on objects upon assignment.
2180 #
2192 #
2181 # It also allows users to assign to either alias or magic names true
2193 # It also allows users to assign to either alias or magic names true
2182 # python variables (the magic/alias systems always take second seat to
2194 # python variables (the magic/alias systems always take second seat to
2183 # true python code).
2195 # true python code).
2184 if theRest and theRest[0] in '!=()':
2196 if theRest and theRest[0] in '!=()':
2185 return self.handle_normal(line,continue_prompt)
2197 return self.handle_normal(line,continue_prompt)
2186
2198
2187 if oinfo is None:
2199 if oinfo is None:
2188 # let's try to ensure that _oinfo is ONLY called when autocall is
2200 # let's try to ensure that _oinfo is ONLY called when autocall is
2189 # on. Since it has inevitable potential side effects, at least
2201 # on. Since it has inevitable potential side effects, at least
2190 # having autocall off should be a guarantee to the user that no
2202 # having autocall off should be a guarantee to the user that no
2191 # weird things will happen.
2203 # weird things will happen.
2192
2204
2193 if self.rc.autocall:
2205 if self.rc.autocall:
2194 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
2206 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
2195 else:
2207 else:
2196 # in this case, all that's left is either an alias or
2208 # in this case, all that's left is either an alias or
2197 # processing the line normally.
2209 # processing the line normally.
2198 if iFun in self.alias_table:
2210 if iFun in self.alias_table:
2199 # if autocall is off, by not running _ofind we won't know
2211 # if autocall is off, by not running _ofind we won't know
2200 # whether the given name may also exist in one of the
2212 # whether the given name may also exist in one of the
2201 # user's namespace. At this point, it's best to do a
2213 # user's namespace. At this point, it's best to do a
2202 # quick check just to be sure that we don't let aliases
2214 # quick check just to be sure that we don't let aliases
2203 # shadow variables.
2215 # shadow variables.
2204 head = iFun.split('.',1)[0]
2216 head = iFun.split('.',1)[0]
2205 if head in self.user_ns or head in self.internal_ns \
2217 if head in self.user_ns or head in self.internal_ns \
2206 or head in __builtin__.__dict__:
2218 or head in __builtin__.__dict__:
2207 return self.handle_normal(line,continue_prompt)
2219 return self.handle_normal(line,continue_prompt)
2208 else:
2220 else:
2209 return self.handle_alias(line,continue_prompt,
2221 return self.handle_alias(line,continue_prompt,
2210 pre,iFun,theRest)
2222 pre,iFun,theRest)
2211
2223
2212 else:
2224 else:
2213 return self.handle_normal(line,continue_prompt)
2225 return self.handle_normal(line,continue_prompt)
2214
2226
2215 if not oinfo['found']:
2227 if not oinfo['found']:
2216 return self.handle_normal(line,continue_prompt)
2228 return self.handle_normal(line,continue_prompt)
2217 else:
2229 else:
2218 #print 'pre<%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2230 #print 'pre<%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2219 if oinfo['isalias']:
2231 if oinfo['isalias']:
2220 return self.handle_alias(line,continue_prompt,
2232 return self.handle_alias(line,continue_prompt,
2221 pre,iFun,theRest)
2233 pre,iFun,theRest)
2222
2234
2223 if (self.rc.autocall
2235 if (self.rc.autocall
2224 and
2236 and
2225 (
2237 (
2226 #only consider exclusion re if not "," or ";" autoquoting
2238 #only consider exclusion re if not "," or ";" autoquoting
2227 (pre == self.ESC_QUOTE or pre == self.ESC_QUOTE2
2239 (pre == self.ESC_QUOTE or pre == self.ESC_QUOTE2
2228 or pre == self.ESC_PAREN) or
2240 or pre == self.ESC_PAREN) or
2229 (not self.re_exclude_auto.match(theRest)))
2241 (not self.re_exclude_auto.match(theRest)))
2230 and
2242 and
2231 self.re_fun_name.match(iFun) and
2243 self.re_fun_name.match(iFun) and
2232 callable(oinfo['obj'])) :
2244 callable(oinfo['obj'])) :
2233 #print 'going auto' # dbg
2245 #print 'going auto' # dbg
2234 return self.handle_auto(line,continue_prompt,
2246 return self.handle_auto(line,continue_prompt,
2235 pre,iFun,theRest,oinfo['obj'])
2247 pre,iFun,theRest,oinfo['obj'])
2236 else:
2248 else:
2237 #print 'was callable?', callable(oinfo['obj']) # dbg
2249 #print 'was callable?', callable(oinfo['obj']) # dbg
2238 return self.handle_normal(line,continue_prompt)
2250 return self.handle_normal(line,continue_prompt)
2239
2251
2240 # If we get here, we have a normal Python line. Log and return.
2252 # If we get here, we have a normal Python line. Log and return.
2241 return self.handle_normal(line,continue_prompt)
2253 return self.handle_normal(line,continue_prompt)
2242
2254
2243 def _prefilter_dumb(self, line, continue_prompt):
2255 def _prefilter_dumb(self, line, continue_prompt):
2244 """simple prefilter function, for debugging"""
2256 """simple prefilter function, for debugging"""
2245 return self.handle_normal(line,continue_prompt)
2257 return self.handle_normal(line,continue_prompt)
2246
2258
2247
2259
2248 def multiline_prefilter(self, line, continue_prompt):
2260 def multiline_prefilter(self, line, continue_prompt):
2249 """ Run _prefilter for each line of input
2261 """ Run _prefilter for each line of input
2250
2262
2251 Covers cases where there are multiple lines in the user entry,
2263 Covers cases where there are multiple lines in the user entry,
2252 which is the case when the user goes back to a multiline history
2264 which is the case when the user goes back to a multiline history
2253 entry and presses enter.
2265 entry and presses enter.
2254
2266
2255 """
2267 """
2256 out = []
2268 out = []
2257 for l in line.rstrip('\n').split('\n'):
2269 for l in line.rstrip('\n').split('\n'):
2258 out.append(self._prefilter(l, continue_prompt))
2270 out.append(self._prefilter(l, continue_prompt))
2259 return '\n'.join(out)
2271 return '\n'.join(out)
2260
2272
2261 # Set the default prefilter() function (this can be user-overridden)
2273 # Set the default prefilter() function (this can be user-overridden)
2262 prefilter = multiline_prefilter
2274 prefilter = multiline_prefilter
2263
2275
2264 def handle_normal(self,line,continue_prompt=None,
2276 def handle_normal(self,line,continue_prompt=None,
2265 pre=None,iFun=None,theRest=None):
2277 pre=None,iFun=None,theRest=None):
2266 """Handle normal input lines. Use as a template for handlers."""
2278 """Handle normal input lines. Use as a template for handlers."""
2267
2279
2268 # With autoindent on, we need some way to exit the input loop, and I
2280 # With autoindent on, we need some way to exit the input loop, and I
2269 # don't want to force the user to have to backspace all the way to
2281 # don't want to force the user to have to backspace all the way to
2270 # clear the line. The rule will be in this case, that either two
2282 # clear the line. The rule will be in this case, that either two
2271 # lines of pure whitespace in a row, or a line of pure whitespace but
2283 # lines of pure whitespace in a row, or a line of pure whitespace but
2272 # of a size different to the indent level, will exit the input loop.
2284 # of a size different to the indent level, will exit the input loop.
2273
2285
2274 if (continue_prompt and self.autoindent and line.isspace() and
2286 if (continue_prompt and self.autoindent and line.isspace() and
2275 (0 < abs(len(line) - self.indent_current_nsp) <= 2 or
2287 (0 < abs(len(line) - self.indent_current_nsp) <= 2 or
2276 (self.buffer[-1]).isspace() )):
2288 (self.buffer[-1]).isspace() )):
2277 line = ''
2289 line = ''
2278
2290
2279 self.log(line,line,continue_prompt)
2291 self.log(line,line,continue_prompt)
2280 return line
2292 return line
2281
2293
2282 def handle_alias(self,line,continue_prompt=None,
2294 def handle_alias(self,line,continue_prompt=None,
2283 pre=None,iFun=None,theRest=None):
2295 pre=None,iFun=None,theRest=None):
2284 """Handle alias input lines. """
2296 """Handle alias input lines. """
2285
2297
2286 # pre is needed, because it carries the leading whitespace. Otherwise
2298 # pre is needed, because it carries the leading whitespace. Otherwise
2287 # aliases won't work in indented sections.
2299 # aliases won't work in indented sections.
2288 transformed = self.expand_aliases(iFun, theRest)
2300 transformed = self.expand_aliases(iFun, theRest)
2289 line_out = '%s_ip.system(%s)' % (pre, make_quoted_expr( transformed ))
2301 line_out = '%s_ip.system(%s)' % (pre, make_quoted_expr( transformed ))
2290 self.log(line,line_out,continue_prompt)
2302 self.log(line,line_out,continue_prompt)
2291 #print 'line out:',line_out # dbg
2303 #print 'line out:',line_out # dbg
2292 return line_out
2304 return line_out
2293
2305
2294 def handle_shell_escape(self, line, continue_prompt=None,
2306 def handle_shell_escape(self, line, continue_prompt=None,
2295 pre=None,iFun=None,theRest=None):
2307 pre=None,iFun=None,theRest=None):
2296 """Execute the line in a shell, empty return value"""
2308 """Execute the line in a shell, empty return value"""
2297
2309
2298 #print 'line in :', `line` # dbg
2310 #print 'line in :', `line` # dbg
2299 # Example of a special handler. Others follow a similar pattern.
2311 # Example of a special handler. Others follow a similar pattern.
2300 if line.lstrip().startswith('!!'):
2312 if line.lstrip().startswith('!!'):
2301 # rewrite iFun/theRest to properly hold the call to %sx and
2313 # rewrite iFun/theRest to properly hold the call to %sx and
2302 # the actual command to be executed, so handle_magic can work
2314 # the actual command to be executed, so handle_magic can work
2303 # correctly
2315 # correctly
2304 theRest = '%s %s' % (iFun[2:],theRest)
2316 theRest = '%s %s' % (iFun[2:],theRest)
2305 iFun = 'sx'
2317 iFun = 'sx'
2306 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,
2318 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,
2307 line.lstrip()[2:]),
2319 line.lstrip()[2:]),
2308 continue_prompt,pre,iFun,theRest)
2320 continue_prompt,pre,iFun,theRest)
2309 else:
2321 else:
2310 cmd=line.lstrip().lstrip('!')
2322 cmd=line.lstrip().lstrip('!')
2311 line_out = '%s_ip.system(%s)' % (pre,make_quoted_expr(cmd))
2323 line_out = '%s_ip.system(%s)' % (pre,make_quoted_expr(cmd))
2312 # update cache/log and return
2324 # update cache/log and return
2313 self.log(line,line_out,continue_prompt)
2325 self.log(line,line_out,continue_prompt)
2314 return line_out
2326 return line_out
2315
2327
2316 def handle_magic(self, line, continue_prompt=None,
2328 def handle_magic(self, line, continue_prompt=None,
2317 pre=None,iFun=None,theRest=None):
2329 pre=None,iFun=None,theRest=None):
2318 """Execute magic functions."""
2330 """Execute magic functions."""
2319
2331
2320
2332
2321 cmd = '%s_ip.magic(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
2333 cmd = '%s_ip.magic(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
2322 self.log(line,cmd,continue_prompt)
2334 self.log(line,cmd,continue_prompt)
2323 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
2335 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
2324 return cmd
2336 return cmd
2325
2337
2326 def handle_auto(self, line, continue_prompt=None,
2338 def handle_auto(self, line, continue_prompt=None,
2327 pre=None,iFun=None,theRest=None,obj=None):
2339 pre=None,iFun=None,theRest=None,obj=None):
2328 """Hande lines which can be auto-executed, quoting if requested."""
2340 """Hande lines which can be auto-executed, quoting if requested."""
2329
2341
2330 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2342 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2331
2343
2332 # This should only be active for single-line input!
2344 # This should only be active for single-line input!
2333 if continue_prompt:
2345 if continue_prompt:
2334 self.log(line,line,continue_prompt)
2346 self.log(line,line,continue_prompt)
2335 return line
2347 return line
2336
2348
2337 auto_rewrite = True
2349 auto_rewrite = True
2338
2350
2339 if pre == self.ESC_QUOTE:
2351 if pre == self.ESC_QUOTE:
2340 # Auto-quote splitting on whitespace
2352 # Auto-quote splitting on whitespace
2341 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
2353 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
2342 elif pre == self.ESC_QUOTE2:
2354 elif pre == self.ESC_QUOTE2:
2343 # Auto-quote whole string
2355 # Auto-quote whole string
2344 newcmd = '%s("%s")' % (iFun,theRest)
2356 newcmd = '%s("%s")' % (iFun,theRest)
2345 elif pre == self.ESC_PAREN:
2357 elif pre == self.ESC_PAREN:
2346 newcmd = '%s(%s)' % (iFun,",".join(theRest.split()))
2358 newcmd = '%s(%s)' % (iFun,",".join(theRest.split()))
2347 else:
2359 else:
2348 # Auto-paren.
2360 # Auto-paren.
2349 # We only apply it to argument-less calls if the autocall
2361 # We only apply it to argument-less calls if the autocall
2350 # parameter is set to 2. We only need to check that autocall is <
2362 # parameter is set to 2. We only need to check that autocall is <
2351 # 2, since this function isn't called unless it's at least 1.
2363 # 2, since this function isn't called unless it's at least 1.
2352 if not theRest and (self.rc.autocall < 2):
2364 if not theRest and (self.rc.autocall < 2):
2353 newcmd = '%s %s' % (iFun,theRest)
2365 newcmd = '%s %s' % (iFun,theRest)
2354 auto_rewrite = False
2366 auto_rewrite = False
2355 else:
2367 else:
2356 if theRest.startswith('['):
2368 if theRest.startswith('['):
2357 if hasattr(obj,'__getitem__'):
2369 if hasattr(obj,'__getitem__'):
2358 # Don't autocall in this case: item access for an object
2370 # Don't autocall in this case: item access for an object
2359 # which is BOTH callable and implements __getitem__.
2371 # which is BOTH callable and implements __getitem__.
2360 newcmd = '%s %s' % (iFun,theRest)
2372 newcmd = '%s %s' % (iFun,theRest)
2361 auto_rewrite = False
2373 auto_rewrite = False
2362 else:
2374 else:
2363 # if the object doesn't support [] access, go ahead and
2375 # if the object doesn't support [] access, go ahead and
2364 # autocall
2376 # autocall
2365 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
2377 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
2366 elif theRest.endswith(';'):
2378 elif theRest.endswith(';'):
2367 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
2379 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
2368 else:
2380 else:
2369 newcmd = '%s(%s)' % (iFun.rstrip(), theRest)
2381 newcmd = '%s(%s)' % (iFun.rstrip(), theRest)
2370
2382
2371 if auto_rewrite:
2383 if auto_rewrite:
2372 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
2384 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
2373 # log what is now valid Python, not the actual user input (without the
2385 # log what is now valid Python, not the actual user input (without the
2374 # final newline)
2386 # final newline)
2375 self.log(line,newcmd,continue_prompt)
2387 self.log(line,newcmd,continue_prompt)
2376 return newcmd
2388 return newcmd
2377
2389
2378 def handle_help(self, line, continue_prompt=None,
2390 def handle_help(self, line, continue_prompt=None,
2379 pre=None,iFun=None,theRest=None):
2391 pre=None,iFun=None,theRest=None):
2380 """Try to get some help for the object.
2392 """Try to get some help for the object.
2381
2393
2382 obj? or ?obj -> basic information.
2394 obj? or ?obj -> basic information.
2383 obj?? or ??obj -> more details.
2395 obj?? or ??obj -> more details.
2384 """
2396 """
2385
2397
2386 # We need to make sure that we don't process lines which would be
2398 # We need to make sure that we don't process lines which would be
2387 # otherwise valid python, such as "x=1 # what?"
2399 # otherwise valid python, such as "x=1 # what?"
2388 try:
2400 try:
2389 codeop.compile_command(line)
2401 codeop.compile_command(line)
2390 except SyntaxError:
2402 except SyntaxError:
2391 # We should only handle as help stuff which is NOT valid syntax
2403 # We should only handle as help stuff which is NOT valid syntax
2392 if line[0]==self.ESC_HELP:
2404 if line[0]==self.ESC_HELP:
2393 line = line[1:]
2405 line = line[1:]
2394 elif line[-1]==self.ESC_HELP:
2406 elif line[-1]==self.ESC_HELP:
2395 line = line[:-1]
2407 line = line[:-1]
2396 self.log(line,'#?'+line,continue_prompt)
2408 self.log(line,'#?'+line,continue_prompt)
2397 if line:
2409 if line:
2398 #print 'line:<%r>' % line # dbg
2410 #print 'line:<%r>' % line # dbg
2399 self.magic_pinfo(line)
2411 self.magic_pinfo(line)
2400 else:
2412 else:
2401 page(self.usage,screen_lines=self.rc.screen_length)
2413 page(self.usage,screen_lines=self.rc.screen_length)
2402 return '' # Empty string is needed here!
2414 return '' # Empty string is needed here!
2403 except:
2415 except:
2404 # Pass any other exceptions through to the normal handler
2416 # Pass any other exceptions through to the normal handler
2405 return self.handle_normal(line,continue_prompt)
2417 return self.handle_normal(line,continue_prompt)
2406 else:
2418 else:
2407 # If the code compiles ok, we should handle it normally
2419 # If the code compiles ok, we should handle it normally
2408 return self.handle_normal(line,continue_prompt)
2420 return self.handle_normal(line,continue_prompt)
2409
2421
2410 def getapi(self):
2422 def getapi(self):
2411 """ Get an IPApi object for this shell instance
2423 """ Get an IPApi object for this shell instance
2412
2424
2413 Getting an IPApi object is always preferable to accessing the shell
2425 Getting an IPApi object is always preferable to accessing the shell
2414 directly, but this holds true especially for extensions.
2426 directly, but this holds true especially for extensions.
2415
2427
2416 It should always be possible to implement an extension with IPApi
2428 It should always be possible to implement an extension with IPApi
2417 alone. If not, contact maintainer to request an addition.
2429 alone. If not, contact maintainer to request an addition.
2418
2430
2419 """
2431 """
2420 return self.api
2432 return self.api
2421
2433
2422 def handle_emacs(self,line,continue_prompt=None,
2434 def handle_emacs(self,line,continue_prompt=None,
2423 pre=None,iFun=None,theRest=None):
2435 pre=None,iFun=None,theRest=None):
2424 """Handle input lines marked by python-mode."""
2436 """Handle input lines marked by python-mode."""
2425
2437
2426 # Currently, nothing is done. Later more functionality can be added
2438 # Currently, nothing is done. Later more functionality can be added
2427 # here if needed.
2439 # here if needed.
2428
2440
2429 # The input cache shouldn't be updated
2441 # The input cache shouldn't be updated
2430
2442
2431 return line
2443 return line
2432
2444
2433 def mktempfile(self,data=None):
2445 def mktempfile(self,data=None):
2434 """Make a new tempfile and return its filename.
2446 """Make a new tempfile and return its filename.
2435
2447
2436 This makes a call to tempfile.mktemp, but it registers the created
2448 This makes a call to tempfile.mktemp, but it registers the created
2437 filename internally so ipython cleans it up at exit time.
2449 filename internally so ipython cleans it up at exit time.
2438
2450
2439 Optional inputs:
2451 Optional inputs:
2440
2452
2441 - data(None): if data is given, it gets written out to the temp file
2453 - data(None): if data is given, it gets written out to the temp file
2442 immediately, and the file is closed again."""
2454 immediately, and the file is closed again."""
2443
2455
2444 filename = tempfile.mktemp('.py','ipython_edit_')
2456 filename = tempfile.mktemp('.py','ipython_edit_')
2445 self.tempfiles.append(filename)
2457 self.tempfiles.append(filename)
2446
2458
2447 if data:
2459 if data:
2448 tmp_file = open(filename,'w')
2460 tmp_file = open(filename,'w')
2449 tmp_file.write(data)
2461 tmp_file.write(data)
2450 tmp_file.close()
2462 tmp_file.close()
2451 return filename
2463 return filename
2452
2464
2453 def write(self,data):
2465 def write(self,data):
2454 """Write a string to the default output"""
2466 """Write a string to the default output"""
2455 Term.cout.write(data)
2467 Term.cout.write(data)
2456
2468
2457 def write_err(self,data):
2469 def write_err(self,data):
2458 """Write a string to the default error output"""
2470 """Write a string to the default error output"""
2459 Term.cerr.write(data)
2471 Term.cerr.write(data)
2460
2472
2461 def exit(self):
2473 def exit(self):
2462 """Handle interactive exit.
2474 """Handle interactive exit.
2463
2475
2464 This method sets the exit_now attribute."""
2476 This method sets the exit_now attribute."""
2465
2477
2466 if self.rc.confirm_exit:
2478 if self.rc.confirm_exit:
2467 if self.ask_yes_no('Do you really want to exit ([y]/n)?','y'):
2479 if self.ask_yes_no('Do you really want to exit ([y]/n)?','y'):
2468 self.exit_now = True
2480 self.exit_now = True
2469 else:
2481 else:
2470 self.exit_now = True
2482 self.exit_now = True
2471
2483
2472 def safe_execfile(self,fname,*where,**kw):
2484 def safe_execfile(self,fname,*where,**kw):
2473 """A safe version of the builtin execfile().
2485 """A safe version of the builtin execfile().
2474
2486
2475 This version will never throw an exception, and knows how to handle
2487 This version will never throw an exception, and knows how to handle
2476 ipython logs as well."""
2488 ipython logs as well."""
2477
2489
2478 def syspath_cleanup():
2490 def syspath_cleanup():
2479 """Internal cleanup routine for sys.path."""
2491 """Internal cleanup routine for sys.path."""
2480 if add_dname:
2492 if add_dname:
2481 try:
2493 try:
2482 sys.path.remove(dname)
2494 sys.path.remove(dname)
2483 except ValueError:
2495 except ValueError:
2484 # For some reason the user has already removed it, ignore.
2496 # For some reason the user has already removed it, ignore.
2485 pass
2497 pass
2486
2498
2487 fname = os.path.expanduser(fname)
2499 fname = os.path.expanduser(fname)
2488
2500
2489 # Find things also in current directory. This is needed to mimic the
2501 # Find things also in current directory. This is needed to mimic the
2490 # behavior of running a script from the system command line, where
2502 # behavior of running a script from the system command line, where
2491 # Python inserts the script's directory into sys.path
2503 # Python inserts the script's directory into sys.path
2492 dname = os.path.dirname(os.path.abspath(fname))
2504 dname = os.path.dirname(os.path.abspath(fname))
2493 add_dname = False
2505 add_dname = False
2494 if dname not in sys.path:
2506 if dname not in sys.path:
2495 sys.path.insert(0,dname)
2507 sys.path.insert(0,dname)
2496 add_dname = True
2508 add_dname = True
2497
2509
2498 try:
2510 try:
2499 xfile = open(fname)
2511 xfile = open(fname)
2500 except:
2512 except:
2501 print >> Term.cerr, \
2513 print >> Term.cerr, \
2502 'Could not open file <%s> for safe execution.' % fname
2514 'Could not open file <%s> for safe execution.' % fname
2503 syspath_cleanup()
2515 syspath_cleanup()
2504 return None
2516 return None
2505
2517
2506 kw.setdefault('islog',0)
2518 kw.setdefault('islog',0)
2507 kw.setdefault('quiet',1)
2519 kw.setdefault('quiet',1)
2508 kw.setdefault('exit_ignore',0)
2520 kw.setdefault('exit_ignore',0)
2509 first = xfile.readline()
2521 first = xfile.readline()
2510 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
2522 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
2511 xfile.close()
2523 xfile.close()
2512 # line by line execution
2524 # line by line execution
2513 if first.startswith(loghead) or kw['islog']:
2525 if first.startswith(loghead) or kw['islog']:
2514 print 'Loading log file <%s> one line at a time...' % fname
2526 print 'Loading log file <%s> one line at a time...' % fname
2515 if kw['quiet']:
2527 if kw['quiet']:
2516 stdout_save = sys.stdout
2528 stdout_save = sys.stdout
2517 sys.stdout = StringIO.StringIO()
2529 sys.stdout = StringIO.StringIO()
2518 try:
2530 try:
2519 globs,locs = where[0:2]
2531 globs,locs = where[0:2]
2520 except:
2532 except:
2521 try:
2533 try:
2522 globs = locs = where[0]
2534 globs = locs = where[0]
2523 except:
2535 except:
2524 globs = locs = globals()
2536 globs = locs = globals()
2525 badblocks = []
2537 badblocks = []
2526
2538
2527 # we also need to identify indented blocks of code when replaying
2539 # we also need to identify indented blocks of code when replaying
2528 # logs and put them together before passing them to an exec
2540 # logs and put them together before passing them to an exec
2529 # statement. This takes a bit of regexp and look-ahead work in the
2541 # statement. This takes a bit of regexp and look-ahead work in the
2530 # file. It's easiest if we swallow the whole thing in memory
2542 # file. It's easiest if we swallow the whole thing in memory
2531 # first, and manually walk through the lines list moving the
2543 # first, and manually walk through the lines list moving the
2532 # counter ourselves.
2544 # counter ourselves.
2533 indent_re = re.compile('\s+\S')
2545 indent_re = re.compile('\s+\S')
2534 xfile = open(fname)
2546 xfile = open(fname)
2535 filelines = xfile.readlines()
2547 filelines = xfile.readlines()
2536 xfile.close()
2548 xfile.close()
2537 nlines = len(filelines)
2549 nlines = len(filelines)
2538 lnum = 0
2550 lnum = 0
2539 while lnum < nlines:
2551 while lnum < nlines:
2540 line = filelines[lnum]
2552 line = filelines[lnum]
2541 lnum += 1
2553 lnum += 1
2542 # don't re-insert logger status info into cache
2554 # don't re-insert logger status info into cache
2543 if line.startswith('#log#'):
2555 if line.startswith('#log#'):
2544 continue
2556 continue
2545 else:
2557 else:
2546 # build a block of code (maybe a single line) for execution
2558 # build a block of code (maybe a single line) for execution
2547 block = line
2559 block = line
2548 try:
2560 try:
2549 next = filelines[lnum] # lnum has already incremented
2561 next = filelines[lnum] # lnum has already incremented
2550 except:
2562 except:
2551 next = None
2563 next = None
2552 while next and indent_re.match(next):
2564 while next and indent_re.match(next):
2553 block += next
2565 block += next
2554 lnum += 1
2566 lnum += 1
2555 try:
2567 try:
2556 next = filelines[lnum]
2568 next = filelines[lnum]
2557 except:
2569 except:
2558 next = None
2570 next = None
2559 # now execute the block of one or more lines
2571 # now execute the block of one or more lines
2560 try:
2572 try:
2561 exec block in globs,locs
2573 exec block in globs,locs
2562 except SystemExit:
2574 except SystemExit:
2563 pass
2575 pass
2564 except:
2576 except:
2565 badblocks.append(block.rstrip())
2577 badblocks.append(block.rstrip())
2566 if kw['quiet']: # restore stdout
2578 if kw['quiet']: # restore stdout
2567 sys.stdout.close()
2579 sys.stdout.close()
2568 sys.stdout = stdout_save
2580 sys.stdout = stdout_save
2569 print 'Finished replaying log file <%s>' % fname
2581 print 'Finished replaying log file <%s>' % fname
2570 if badblocks:
2582 if badblocks:
2571 print >> sys.stderr, ('\nThe following lines/blocks in file '
2583 print >> sys.stderr, ('\nThe following lines/blocks in file '
2572 '<%s> reported errors:' % fname)
2584 '<%s> reported errors:' % fname)
2573
2585
2574 for badline in badblocks:
2586 for badline in badblocks:
2575 print >> sys.stderr, badline
2587 print >> sys.stderr, badline
2576 else: # regular file execution
2588 else: # regular file execution
2577 try:
2589 try:
2578 if sys.platform == 'win32':
2590 if sys.platform == 'win32':
2579 # Work around a bug in Python for Windows. The bug was
2591 # Work around a bug in Python for Windows. The bug was
2580 # fixed in in Python 2.5 r54159 and 54158, but that's still
2592 # fixed in in Python 2.5 r54159 and 54158, but that's still
2581 # SVN Python as of March/07. For details, see:
2593 # SVN Python as of March/07. For details, see:
2582 # http://projects.scipy.org/ipython/ipython/ticket/123
2594 # http://projects.scipy.org/ipython/ipython/ticket/123
2583 exec file(fname) in where[0],where[1]
2595 exec file(fname) in where[0],where[1]
2584 else:
2596 else:
2585 execfile(fname,*where)
2597 execfile(fname,*where)
2586 except SyntaxError:
2598 except SyntaxError:
2587 self.showsyntaxerror()
2599 self.showsyntaxerror()
2588 warn('Failure executing file: <%s>' % fname)
2600 warn('Failure executing file: <%s>' % fname)
2589 except SystemExit,status:
2601 except SystemExit,status:
2590 if not kw['exit_ignore']:
2602 if not kw['exit_ignore']:
2591 self.showtraceback()
2603 self.showtraceback()
2592 warn('Failure executing file: <%s>' % fname)
2604 warn('Failure executing file: <%s>' % fname)
2593 except:
2605 except:
2594 self.showtraceback()
2606 self.showtraceback()
2595 warn('Failure executing file: <%s>' % fname)
2607 warn('Failure executing file: <%s>' % fname)
2596
2608
2597 syspath_cleanup()
2609 syspath_cleanup()
2598
2610
2599 #************************* end of file <iplib.py> *****************************
2611 #************************* end of file <iplib.py> *****************************
@@ -1,6513 +1,6525 b''
1 2007-04-07 Fernando Perez <Fernando.Perez@colorado.edu>
2
3 * Tag 0.8.0 for release.
4
5 * IPython/iplib.py (reloadhist): add API function to cleanly
6 reload the readline history, which was growing inappropriately on
7 every %run call.
8
9 * win32_manual_post_install.py (run): apply last part of Nicolas
10 Pernetty's patch (I'd accidentally applied it in a different
11 directory and this particular file didn't get patched).
12
1 2007-04-05 Fernando Perez <Fernando.Perez@colorado.edu>
13 2007-04-05 Fernando Perez <Fernando.Perez@colorado.edu>
2
14
3 * IPython/Shell.py (MAIN_THREAD_ID): get rid of my stupid hack to
15 * IPython/Shell.py (MAIN_THREAD_ID): get rid of my stupid hack to
4 find the main thread id and use the proper API call. Thanks to
16 find the main thread id and use the proper API call. Thanks to
5 Stefan for the fix.
17 Stefan for the fix.
6
18
7 * test/test_prefilter.py (esc_handler_tests): udpate one of Dan's
19 * test/test_prefilter.py (esc_handler_tests): udpate one of Dan's
8 unit tests to reflect fixed ticket #52, and add more tests sent by
20 unit tests to reflect fixed ticket #52, and add more tests sent by
9 him.
21 him.
10
22
11 * IPython/iplib.py (raw_input): restore the readline completer
23 * IPython/iplib.py (raw_input): restore the readline completer
12 state on every input, in case third-party code messed it up.
24 state on every input, in case third-party code messed it up.
13 (_prefilter): revert recent addition of early-escape checks which
25 (_prefilter): revert recent addition of early-escape checks which
14 prevent many valid alias calls from working.
26 prevent many valid alias calls from working.
15
27
16 * IPython/Shell.py (MTInteractiveShell.runcode): add a tracking
28 * IPython/Shell.py (MTInteractiveShell.runcode): add a tracking
17 flag for sigint handler so we don't run a full signal() call on
29 flag for sigint handler so we don't run a full signal() call on
18 each runcode access.
30 each runcode access.
19
31
20 * IPython/Magic.py (magic_whos): small improvement to diagnostic
32 * IPython/Magic.py (magic_whos): small improvement to diagnostic
21 message.
33 message.
22
34
23 2007-04-04 Fernando Perez <Fernando.Perez@colorado.edu>
35 2007-04-04 Fernando Perez <Fernando.Perez@colorado.edu>
24
36
25 * IPython/Shell.py (sigint_handler): I *THINK* I finally got
37 * IPython/Shell.py (sigint_handler): I *THINK* I finally got
26 asynchronous exceptions working, i.e., Ctrl-C can actually
38 asynchronous exceptions working, i.e., Ctrl-C can actually
27 interrupt long-running code in the multithreaded shells.
39 interrupt long-running code in the multithreaded shells.
28
40
29 This is using Tomer Filiba's great ctypes-based trick:
41 This is using Tomer Filiba's great ctypes-based trick:
30 http://sebulba.wikispaces.com/recipe+thread2. I'd already tried
42 http://sebulba.wikispaces.com/recipe+thread2. I'd already tried
31 this in the past, but hadn't been able to make it work before. So
43 this in the past, but hadn't been able to make it work before. So
32 far it looks like it's actually running, but this needs more
44 far it looks like it's actually running, but this needs more
33 testing. If it really works, I'll be *very* happy, and we'll owe
45 testing. If it really works, I'll be *very* happy, and we'll owe
34 a huge thank you to Tomer. My current implementation is ugly,
46 a huge thank you to Tomer. My current implementation is ugly,
35 hackish and uses nasty globals, but I don't want to try and clean
47 hackish and uses nasty globals, but I don't want to try and clean
36 anything up until we know if it actually works.
48 anything up until we know if it actually works.
37
49
38 NOTE: this feature needs ctypes to work. ctypes is included in
50 NOTE: this feature needs ctypes to work. ctypes is included in
39 Python2.5, but 2.4 users will need to manually install it. This
51 Python2.5, but 2.4 users will need to manually install it. This
40 feature makes multi-threaded shells so much more usable that it's
52 feature makes multi-threaded shells so much more usable that it's
41 a minor price to pay (ctypes is very easy to install, already a
53 a minor price to pay (ctypes is very easy to install, already a
42 requirement for win32 and available in major linux distros).
54 requirement for win32 and available in major linux distros).
43
55
44 2007-04-04 Ville Vainio <vivainio@gmail.com>
56 2007-04-04 Ville Vainio <vivainio@gmail.com>
45
57
46 * Extensions/ipy_completers.py, ipy_stock_completers.py:
58 * Extensions/ipy_completers.py, ipy_stock_completers.py:
47 Moved implementations of 'bundled' completers to ipy_completers.py,
59 Moved implementations of 'bundled' completers to ipy_completers.py,
48 they are only enabled in ipy_stock_completers.py.
60 they are only enabled in ipy_stock_completers.py.
49
61
50 2007-04-04 Fernando Perez <Fernando.Perez@colorado.edu>
62 2007-04-04 Fernando Perez <Fernando.Perez@colorado.edu>
51
63
52 * IPython/PyColorize.py (Parser.format2): Fix identation of
64 * IPython/PyColorize.py (Parser.format2): Fix identation of
53 colorzied output and return early if color scheme is NoColor, to
65 colorzied output and return early if color scheme is NoColor, to
54 avoid unnecessary and expensive tokenization. Closes #131.
66 avoid unnecessary and expensive tokenization. Closes #131.
55
67
56 2007-04-03 Fernando Perez <Fernando.Perez@colorado.edu>
68 2007-04-03 Fernando Perez <Fernando.Perez@colorado.edu>
57
69
58 * IPython/Debugger.py: disable the use of pydb version 1.17. It
70 * IPython/Debugger.py: disable the use of pydb version 1.17. It
59 has a critical bug (a missing import that makes post-mortem not
71 has a critical bug (a missing import that makes post-mortem not
60 work at all). Unfortunately as of this time, this is the version
72 work at all). Unfortunately as of this time, this is the version
61 shipped with Ubuntu Edgy, so quite a few people have this one. I
73 shipped with Ubuntu Edgy, so quite a few people have this one. I
62 hope Edgy will update to a more recent package.
74 hope Edgy will update to a more recent package.
63
75
64 2007-04-02 Fernando Perez <Fernando.Perez@colorado.edu>
76 2007-04-02 Fernando Perez <Fernando.Perez@colorado.edu>
65
77
66 * IPython/iplib.py (_prefilter): close #52, second part of a patch
78 * IPython/iplib.py (_prefilter): close #52, second part of a patch
67 set by Stefan (only the first part had been applied before).
79 set by Stefan (only the first part had been applied before).
68
80
69 * IPython/Extensions/ipy_stock_completers.py (module_completer):
81 * IPython/Extensions/ipy_stock_completers.py (module_completer):
70 remove usage of the dangerous pkgutil.walk_packages(). See
82 remove usage of the dangerous pkgutil.walk_packages(). See
71 details in comments left in the code.
83 details in comments left in the code.
72
84
73 * IPython/Magic.py (magic_whos): add support for numpy arrays
85 * IPython/Magic.py (magic_whos): add support for numpy arrays
74 similar to what we had for Numeric.
86 similar to what we had for Numeric.
75
87
76 * IPython/completer.py (IPCompleter.complete): extend the
88 * IPython/completer.py (IPCompleter.complete): extend the
77 complete() call API to support completions by other mechanisms
89 complete() call API to support completions by other mechanisms
78 than readline. Closes #109.
90 than readline. Closes #109.
79
91
80 * IPython/iplib.py (safe_execfile): add a safeguard under Win32 to
92 * IPython/iplib.py (safe_execfile): add a safeguard under Win32 to
81 protect against a bug in Python's execfile(). Closes #123.
93 protect against a bug in Python's execfile(). Closes #123.
82
94
83 2007-04-01 Fernando Perez <Fernando.Perez@colorado.edu>
95 2007-04-01 Fernando Perez <Fernando.Perez@colorado.edu>
84
96
85 * IPython/iplib.py (split_user_input): ensure that when splitting
97 * IPython/iplib.py (split_user_input): ensure that when splitting
86 user input, the part that can be treated as a python name is pure
98 user input, the part that can be treated as a python name is pure
87 ascii (Python identifiers MUST be pure ascii). Part of the
99 ascii (Python identifiers MUST be pure ascii). Part of the
88 ongoing Unicode support work.
100 ongoing Unicode support work.
89
101
90 * IPython/Prompts.py (prompt_specials_color): Add \N for the
102 * IPython/Prompts.py (prompt_specials_color): Add \N for the
91 actual prompt number, without any coloring. This allows users to
103 actual prompt number, without any coloring. This allows users to
92 produce numbered prompts with their own colors. Added after a
104 produce numbered prompts with their own colors. Added after a
93 report/request by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
105 report/request by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
94
106
95 2007-03-31 Walter Doerwald <walter@livinglogic.de>
107 2007-03-31 Walter Doerwald <walter@livinglogic.de>
96
108
97 * IPython/Extensions/igrid.py: Map the return key
109 * IPython/Extensions/igrid.py: Map the return key
98 to enter() and shift-return to enterattr().
110 to enter() and shift-return to enterattr().
99
111
100 2007-03-30 Fernando Perez <Fernando.Perez@colorado.edu>
112 2007-03-30 Fernando Perez <Fernando.Perez@colorado.edu>
101
113
102 * IPython/Magic.py (magic_psearch): add unicode support by
114 * IPython/Magic.py (magic_psearch): add unicode support by
103 encoding to ascii the input, since this routine also only deals
115 encoding to ascii the input, since this routine also only deals
104 with valid Python names. Fixes a bug reported by Stefan.
116 with valid Python names. Fixes a bug reported by Stefan.
105
117
106 2007-03-29 Fernando Perez <Fernando.Perez@colorado.edu>
118 2007-03-29 Fernando Perez <Fernando.Perez@colorado.edu>
107
119
108 * IPython/Magic.py (_inspect): convert unicode input into ascii
120 * IPython/Magic.py (_inspect): convert unicode input into ascii
109 before trying to evaluate it as a Python identifier. This fixes a
121 before trying to evaluate it as a Python identifier. This fixes a
110 problem that the new unicode support had introduced when analyzing
122 problem that the new unicode support had introduced when analyzing
111 long definition lines for functions.
123 long definition lines for functions.
112
124
113 2007-03-24 Walter Doerwald <walter@livinglogic.de>
125 2007-03-24 Walter Doerwald <walter@livinglogic.de>
114
126
115 * IPython/Extensions/igrid.py: Fix picking. Using
127 * IPython/Extensions/igrid.py: Fix picking. Using
116 igrid with wxPython 2.6 and -wthread should work now.
128 igrid with wxPython 2.6 and -wthread should work now.
117 igrid.display() simply tries to create a frame without
129 igrid.display() simply tries to create a frame without
118 an application. Only if this fails an application is created.
130 an application. Only if this fails an application is created.
119
131
120 2007-03-23 Walter Doerwald <walter@livinglogic.de>
132 2007-03-23 Walter Doerwald <walter@livinglogic.de>
121
133
122 * IPython/Extensions/path.py: Updated to version 2.2.
134 * IPython/Extensions/path.py: Updated to version 2.2.
123
135
124 2007-03-23 Ville Vainio <vivainio@gmail.com>
136 2007-03-23 Ville Vainio <vivainio@gmail.com>
125
137
126 * iplib.py: recursive alias expansion now works better, so that
138 * iplib.py: recursive alias expansion now works better, so that
127 cases like 'top' -> 'd:/cygwin/top' -> 'ls :/cygwin/top'
139 cases like 'top' -> 'd:/cygwin/top' -> 'ls :/cygwin/top'
128 doesn't trip up the process, if 'd' has been aliased to 'ls'.
140 doesn't trip up the process, if 'd' has been aliased to 'ls'.
129
141
130 * Extensions/ipy_gnuglobal.py added, provides %global magic
142 * Extensions/ipy_gnuglobal.py added, provides %global magic
131 for users of http://www.gnu.org/software/global
143 for users of http://www.gnu.org/software/global
132
144
133 * iplib.py: '!command /?' now doesn't invoke IPython's help system.
145 * iplib.py: '!command /?' now doesn't invoke IPython's help system.
134 Closes #52. Patch by Stefan van der Walt.
146 Closes #52. Patch by Stefan van der Walt.
135
147
136 2007-03-23 Fernando Perez <Fernando.Perez@colorado.edu>
148 2007-03-23 Fernando Perez <Fernando.Perez@colorado.edu>
137
149
138 * IPython/FakeModule.py (FakeModule.__init__): Small fix to
150 * IPython/FakeModule.py (FakeModule.__init__): Small fix to
139 respect the __file__ attribute when using %run. Thanks to a bug
151 respect the __file__ attribute when using %run. Thanks to a bug
140 report by Sebastian Rooks <sebastian.rooks-AT-free.fr>.
152 report by Sebastian Rooks <sebastian.rooks-AT-free.fr>.
141
153
142 2007-03-22 Fernando Perez <Fernando.Perez@colorado.edu>
154 2007-03-22 Fernando Perez <Fernando.Perez@colorado.edu>
143
155
144 * IPython/iplib.py (raw_input): Fix mishandling of unicode at
156 * IPython/iplib.py (raw_input): Fix mishandling of unicode at
145 input. Patch sent by Stefan.
157 input. Patch sent by Stefan.
146
158
147 2007-03-20 JοΏ½rgen Stenarson <jorgen.stenarson@bostream.nu>
159 2007-03-20 JοΏ½rgen Stenarson <jorgen.stenarson@bostream.nu>
148 * IPython/Extensions/ipy_stock_completer.py
160 * IPython/Extensions/ipy_stock_completer.py
149 shlex_split, fix bug in shlex_split. len function
161 shlex_split, fix bug in shlex_split. len function
150 call was missing an if statement. Caused shlex_split to
162 call was missing an if statement. Caused shlex_split to
151 sometimes return "" as last element.
163 sometimes return "" as last element.
152
164
153 2007-03-18 Fernando Perez <Fernando.Perez@colorado.edu>
165 2007-03-18 Fernando Perez <Fernando.Perez@colorado.edu>
154
166
155 * IPython/completer.py
167 * IPython/completer.py
156 (IPCompleter.file_matches.single_dir_expand): fix a problem
168 (IPCompleter.file_matches.single_dir_expand): fix a problem
157 reported by Stefan, where directories containign a single subdir
169 reported by Stefan, where directories containign a single subdir
158 would be completed too early.
170 would be completed too early.
159
171
160 * IPython/Shell.py (_load_pylab): Make the execution of 'from
172 * IPython/Shell.py (_load_pylab): Make the execution of 'from
161 pylab import *' when -pylab is given be optional. A new flag,
173 pylab import *' when -pylab is given be optional. A new flag,
162 pylab_import_all controls this behavior, the default is True for
174 pylab_import_all controls this behavior, the default is True for
163 backwards compatibility.
175 backwards compatibility.
164
176
165 * IPython/ultraTB.py (_formatTracebackLines): Added (slightly
177 * IPython/ultraTB.py (_formatTracebackLines): Added (slightly
166 modified) R. Bernstein's patch for fully syntax highlighted
178 modified) R. Bernstein's patch for fully syntax highlighted
167 tracebacks. The functionality is also available under ultraTB for
179 tracebacks. The functionality is also available under ultraTB for
168 non-ipython users (someone using ultraTB but outside an ipython
180 non-ipython users (someone using ultraTB but outside an ipython
169 session). They can select the color scheme by setting the
181 session). They can select the color scheme by setting the
170 module-level global DEFAULT_SCHEME. The highlight functionality
182 module-level global DEFAULT_SCHEME. The highlight functionality
171 also works when debugging.
183 also works when debugging.
172
184
173 * IPython/genutils.py (IOStream.close): small patch by
185 * IPython/genutils.py (IOStream.close): small patch by
174 R. Bernstein for improved pydb support.
186 R. Bernstein for improved pydb support.
175
187
176 * IPython/Debugger.py (Pdb.format_stack_entry): Added patch by
188 * IPython/Debugger.py (Pdb.format_stack_entry): Added patch by
177 DaveS <davls@telus.net> to improve support of debugging under
189 DaveS <davls@telus.net> to improve support of debugging under
178 NTEmacs, including improved pydb behavior.
190 NTEmacs, including improved pydb behavior.
179
191
180 * IPython/Magic.py (magic_prun): Fix saving of profile info for
192 * IPython/Magic.py (magic_prun): Fix saving of profile info for
181 Python 2.5, where the stats object API changed a little. Thanks
193 Python 2.5, where the stats object API changed a little. Thanks
182 to a bug report by Paul Smith <paul.smith-AT-catugmt.com>.
194 to a bug report by Paul Smith <paul.smith-AT-catugmt.com>.
183
195
184 * IPython/ColorANSI.py (InputTermColors.Normal): applied Nicolas
196 * IPython/ColorANSI.py (InputTermColors.Normal): applied Nicolas
185 Pernetty's patch to improve support for (X)Emacs under Win32.
197 Pernetty's patch to improve support for (X)Emacs under Win32.
186
198
187 2007-03-17 Fernando Perez <Fernando.Perez@colorado.edu>
199 2007-03-17 Fernando Perez <Fernando.Perez@colorado.edu>
188
200
189 * IPython/Shell.py (hijack_wx): ipmort WX with current semantics
201 * IPython/Shell.py (hijack_wx): ipmort WX with current semantics
190 to quiet a deprecation warning that fires with Wx 2.8. Thanks to
202 to quiet a deprecation warning that fires with Wx 2.8. Thanks to
191 a report by Nik Tautenhahn.
203 a report by Nik Tautenhahn.
192
204
193 2007-03-16 Walter Doerwald <walter@livinglogic.de>
205 2007-03-16 Walter Doerwald <walter@livinglogic.de>
194
206
195 * setup.py: Add the igrid help files to the list of data files
207 * setup.py: Add the igrid help files to the list of data files
196 to be installed alongside igrid.
208 to be installed alongside igrid.
197 * IPython/Extensions/igrid.py: (Patch by Nik Tautenhahn)
209 * IPython/Extensions/igrid.py: (Patch by Nik Tautenhahn)
198 Show the input object of the igrid browser as the window tile.
210 Show the input object of the igrid browser as the window tile.
199 Show the object the cursor is on in the statusbar.
211 Show the object the cursor is on in the statusbar.
200
212
201 2007-03-15 Ville Vainio <vivainio@gmail.com>
213 2007-03-15 Ville Vainio <vivainio@gmail.com>
202
214
203 * Extensions/ipy_stock_completers.py: Fixed exception
215 * Extensions/ipy_stock_completers.py: Fixed exception
204 on mismatching quotes in %run completer. Patch by
216 on mismatching quotes in %run completer. Patch by
205 JοΏ½rgen Stenarson. Closes #127.
217 JοΏ½rgen Stenarson. Closes #127.
206
218
207 2007-03-14 Ville Vainio <vivainio@gmail.com>
219 2007-03-14 Ville Vainio <vivainio@gmail.com>
208
220
209 * Extensions/ext_rehashdir.py: Do not do auto_alias
221 * Extensions/ext_rehashdir.py: Do not do auto_alias
210 in %rehashdir, it clobbers %store'd aliases.
222 in %rehashdir, it clobbers %store'd aliases.
211
223
212 * UserConfig/ipy_profile_sh.py: envpersist.py extension
224 * UserConfig/ipy_profile_sh.py: envpersist.py extension
213 (beefed up %env) imported for sh profile.
225 (beefed up %env) imported for sh profile.
214
226
215 2007-03-10 Walter Doerwald <walter@livinglogic.de>
227 2007-03-10 Walter Doerwald <walter@livinglogic.de>
216
228
217 * IPython/Extensions/ipipe.py: Prefer ibrowse over igrid
229 * IPython/Extensions/ipipe.py: Prefer ibrowse over igrid
218 as the default browser.
230 as the default browser.
219 * IPython/Extensions/igrid.py: Make a few igrid attributes private.
231 * IPython/Extensions/igrid.py: Make a few igrid attributes private.
220 As igrid displays all attributes it ever encounters, fetch() (which has
232 As igrid displays all attributes it ever encounters, fetch() (which has
221 been renamed to _fetch()) doesn't have to recalculate the display attributes
233 been renamed to _fetch()) doesn't have to recalculate the display attributes
222 every time a new item is fetched. This should speed up scrolling.
234 every time a new item is fetched. This should speed up scrolling.
223
235
224 2007-03-10 Fernando Perez <Fernando.Perez@colorado.edu>
236 2007-03-10 Fernando Perez <Fernando.Perez@colorado.edu>
225
237
226 * IPython/iplib.py (InteractiveShell.__init__): fix for Alex
238 * IPython/iplib.py (InteractiveShell.__init__): fix for Alex
227 Schmolck's recently reported tab-completion bug (my previous one
239 Schmolck's recently reported tab-completion bug (my previous one
228 had a problem). Patch by Dan Milstein <danmil-AT-comcast.net>.
240 had a problem). Patch by Dan Milstein <danmil-AT-comcast.net>.
229
241
230 2007-03-09 Walter Doerwald <walter@livinglogic.de>
242 2007-03-09 Walter Doerwald <walter@livinglogic.de>
231
243
232 * IPython/Extensions/igrid.py: Patch by Nik Tautenhahn:
244 * IPython/Extensions/igrid.py: Patch by Nik Tautenhahn:
233 Close help window if exiting igrid.
245 Close help window if exiting igrid.
234
246
235 2007-03-02 JοΏ½rgen Stenarson <jorgen.stenarson@bostream.nu>
247 2007-03-02 JοΏ½rgen Stenarson <jorgen.stenarson@bostream.nu>
236
248
237 * IPython/Extensions/ipy_defaults.py: Check if readline is available
249 * IPython/Extensions/ipy_defaults.py: Check if readline is available
238 before calling functions from readline.
250 before calling functions from readline.
239
251
240 2007-03-02 Walter Doerwald <walter@livinglogic.de>
252 2007-03-02 Walter Doerwald <walter@livinglogic.de>
241
253
242 * IPython/Extensions/igrid.py: Add Nik Tautenhahns igrid extension.
254 * IPython/Extensions/igrid.py: Add Nik Tautenhahns igrid extension.
243 igrid is a wxPython-based display object for ipipe. If your system has
255 igrid is a wxPython-based display object for ipipe. If your system has
244 wx installed igrid will be the default display. Without wx ipipe falls
256 wx installed igrid will be the default display. Without wx ipipe falls
245 back to ibrowse (which needs curses). If no curses is installed ipipe
257 back to ibrowse (which needs curses). If no curses is installed ipipe
246 falls back to idump.
258 falls back to idump.
247
259
248 2007-03-01 Fernando Perez <Fernando.Perez@colorado.edu>
260 2007-03-01 Fernando Perez <Fernando.Perez@colorado.edu>
249
261
250 * IPython/iplib.py (split_user_inputBROKEN): temporarily disable
262 * IPython/iplib.py (split_user_inputBROKEN): temporarily disable
251 my changes from yesterday, they introduced bugs. Will reactivate
263 my changes from yesterday, they introduced bugs. Will reactivate
252 once I get a correct solution, which will be much easier thanks to
264 once I get a correct solution, which will be much easier thanks to
253 Dan Milstein's new prefilter test suite.
265 Dan Milstein's new prefilter test suite.
254
266
255 2007-02-28 Fernando Perez <Fernando.Perez@colorado.edu>
267 2007-02-28 Fernando Perez <Fernando.Perez@colorado.edu>
256
268
257 * IPython/iplib.py (split_user_input): fix input splitting so we
269 * IPython/iplib.py (split_user_input): fix input splitting so we
258 don't attempt attribute accesses on things that can't possibly be
270 don't attempt attribute accesses on things that can't possibly be
259 valid Python attributes. After a bug report by Alex Schmolck.
271 valid Python attributes. After a bug report by Alex Schmolck.
260 (InteractiveShell.__init__): brown-paper bag fix; regexp broke
272 (InteractiveShell.__init__): brown-paper bag fix; regexp broke
261 %magic with explicit % prefix.
273 %magic with explicit % prefix.
262
274
263 2007-02-27 Fernando Perez <Fernando.Perez@colorado.edu>
275 2007-02-27 Fernando Perez <Fernando.Perez@colorado.edu>
264
276
265 * IPython/Shell.py (IPShellGTK.mainloop): update threads calls to
277 * IPython/Shell.py (IPShellGTK.mainloop): update threads calls to
266 avoid a DeprecationWarning from GTK.
278 avoid a DeprecationWarning from GTK.
267
279
268 2007-02-22 Fernando Perez <Fernando.Perez@colorado.edu>
280 2007-02-22 Fernando Perez <Fernando.Perez@colorado.edu>
269
281
270 * IPython/genutils.py (clock): I modified clock() to return total
282 * IPython/genutils.py (clock): I modified clock() to return total
271 time, user+system. This is a more commonly needed metric. I also
283 time, user+system. This is a more commonly needed metric. I also
272 introduced the new clocku/clocks to get only user/system time if
284 introduced the new clocku/clocks to get only user/system time if
273 one wants those instead.
285 one wants those instead.
274
286
275 ***WARNING: API CHANGE*** clock() used to return only user time,
287 ***WARNING: API CHANGE*** clock() used to return only user time,
276 so if you want exactly the same results as before, use clocku
288 so if you want exactly the same results as before, use clocku
277 instead.
289 instead.
278
290
279 2007-02-22 Ville Vainio <vivainio@gmail.com>
291 2007-02-22 Ville Vainio <vivainio@gmail.com>
280
292
281 * IPython/Extensions/ipy_p4.py: Extension for improved
293 * IPython/Extensions/ipy_p4.py: Extension for improved
282 p4 (perforce version control system) experience.
294 p4 (perforce version control system) experience.
283 Adds %p4 magic with p4 command completion and
295 Adds %p4 magic with p4 command completion and
284 automatic -G argument (marshall output as python dict)
296 automatic -G argument (marshall output as python dict)
285
297
286 2007-02-19 Fernando Perez <Fernando.Perez@colorado.edu>
298 2007-02-19 Fernando Perez <Fernando.Perez@colorado.edu>
287
299
288 * IPython/demo.py (Demo.re_stop): make dashes optional in demo
300 * IPython/demo.py (Demo.re_stop): make dashes optional in demo
289 stop marks.
301 stop marks.
290 (ClearingMixin): a simple mixin to easily make a Demo class clear
302 (ClearingMixin): a simple mixin to easily make a Demo class clear
291 the screen in between blocks and have empty marquees. The
303 the screen in between blocks and have empty marquees. The
292 ClearDemo and ClearIPDemo classes that use it are included.
304 ClearDemo and ClearIPDemo classes that use it are included.
293
305
294 2007-02-18 Fernando Perez <Fernando.Perez@colorado.edu>
306 2007-02-18 Fernando Perez <Fernando.Perez@colorado.edu>
295
307
296 * IPython/irunner.py (pexpect_monkeypatch): patch pexpect to
308 * IPython/irunner.py (pexpect_monkeypatch): patch pexpect to
297 protect against exceptions at Python shutdown time. Patch
309 protect against exceptions at Python shutdown time. Patch
298 sumbmitted to upstream.
310 sumbmitted to upstream.
299
311
300 2007-02-14 Walter Doerwald <walter@livinglogic.de>
312 2007-02-14 Walter Doerwald <walter@livinglogic.de>
301
313
302 * IPython/Extensions/ibrowse.py: If entering the first object level
314 * IPython/Extensions/ibrowse.py: If entering the first object level
303 (i.e. the object for which the browser has been started) fails,
315 (i.e. the object for which the browser has been started) fails,
304 now the error is raised directly (aborting the browser) instead of
316 now the error is raised directly (aborting the browser) instead of
305 running into an empty levels list later.
317 running into an empty levels list later.
306
318
307 2007-02-03 Walter Doerwald <walter@livinglogic.de>
319 2007-02-03 Walter Doerwald <walter@livinglogic.de>
308
320
309 * IPython/Extensions/ipipe.py: Add an xrepr implementation
321 * IPython/Extensions/ipipe.py: Add an xrepr implementation
310 for the noitem object.
322 for the noitem object.
311
323
312 2007-01-31 Fernando Perez <Fernando.Perez@colorado.edu>
324 2007-01-31 Fernando Perez <Fernando.Perez@colorado.edu>
313
325
314 * IPython/completer.py (Completer.attr_matches): Fix small
326 * IPython/completer.py (Completer.attr_matches): Fix small
315 tab-completion bug with Enthought Traits objects with units.
327 tab-completion bug with Enthought Traits objects with units.
316 Thanks to a bug report by Tom Denniston
328 Thanks to a bug report by Tom Denniston
317 <tom.denniston-AT-alum.dartmouth.org>.
329 <tom.denniston-AT-alum.dartmouth.org>.
318
330
319 2007-01-27 Fernando Perez <Fernando.Perez@colorado.edu>
331 2007-01-27 Fernando Perez <Fernando.Perez@colorado.edu>
320
332
321 * IPython/Extensions/ipy_stock_completers.py (runlistpy): fix a
333 * IPython/Extensions/ipy_stock_completers.py (runlistpy): fix a
322 bug where only .ipy or .py would be completed. Once the first
334 bug where only .ipy or .py would be completed. Once the first
323 argument to %run has been given, all completions are valid because
335 argument to %run has been given, all completions are valid because
324 they are the arguments to the script, which may well be non-python
336 they are the arguments to the script, which may well be non-python
325 filenames.
337 filenames.
326
338
327 * IPython/irunner.py (InteractiveRunner.run_source): major updates
339 * IPython/irunner.py (InteractiveRunner.run_source): major updates
328 to irunner to allow it to correctly support real doctesting of
340 to irunner to allow it to correctly support real doctesting of
329 out-of-process ipython code.
341 out-of-process ipython code.
330
342
331 * IPython/Magic.py (magic_cd): Make the setting of the terminal
343 * IPython/Magic.py (magic_cd): Make the setting of the terminal
332 title an option (-noterm_title) because it completely breaks
344 title an option (-noterm_title) because it completely breaks
333 doctesting.
345 doctesting.
334
346
335 * IPython/demo.py: fix IPythonDemo class that was not actually working.
347 * IPython/demo.py: fix IPythonDemo class that was not actually working.
336
348
337 2007-01-24 Fernando Perez <Fernando.Perez@colorado.edu>
349 2007-01-24 Fernando Perez <Fernando.Perez@colorado.edu>
338
350
339 * IPython/irunner.py (main): fix small bug where extensions were
351 * IPython/irunner.py (main): fix small bug where extensions were
340 not being correctly recognized.
352 not being correctly recognized.
341
353
342 2007-01-23 Walter Doerwald <walter@livinglogic.de>
354 2007-01-23 Walter Doerwald <walter@livinglogic.de>
343
355
344 * IPython/Extensions/ipipe.py (xiter): Make sure that iterating
356 * IPython/Extensions/ipipe.py (xiter): Make sure that iterating
345 a string containing a single line yields the string itself as the
357 a string containing a single line yields the string itself as the
346 only item.
358 only item.
347
359
348 * IPython/Extensions/ibrowse.py (ibrowse): Avoid entering an
360 * IPython/Extensions/ibrowse.py (ibrowse): Avoid entering an
349 object if it's the same as the one on the last level (This avoids
361 object if it's the same as the one on the last level (This avoids
350 infinite recursion for one line strings).
362 infinite recursion for one line strings).
351
363
352 2007-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
364 2007-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
353
365
354 * IPython/ultraTB.py (AutoFormattedTB.__call__): properly flush
366 * IPython/ultraTB.py (AutoFormattedTB.__call__): properly flush
355 all output streams before printing tracebacks. This ensures that
367 all output streams before printing tracebacks. This ensures that
356 user output doesn't end up interleaved with traceback output.
368 user output doesn't end up interleaved with traceback output.
357
369
358 2007-01-10 Ville Vainio <vivainio@gmail.com>
370 2007-01-10 Ville Vainio <vivainio@gmail.com>
359
371
360 * Extensions/envpersist.py: Turbocharged %env that remembers
372 * Extensions/envpersist.py: Turbocharged %env that remembers
361 env vars across sessions; e.g. "%env PATH+=;/opt/scripts" or
373 env vars across sessions; e.g. "%env PATH+=;/opt/scripts" or
362 "%env VISUAL=jed".
374 "%env VISUAL=jed".
363
375
364 2007-01-05 Fernando Perez <Fernando.Perez@colorado.edu>
376 2007-01-05 Fernando Perez <Fernando.Perez@colorado.edu>
365
377
366 * IPython/iplib.py (showtraceback): ensure that we correctly call
378 * IPython/iplib.py (showtraceback): ensure that we correctly call
367 custom handlers in all cases (some with pdb were slipping through,
379 custom handlers in all cases (some with pdb were slipping through,
368 but I'm not exactly sure why).
380 but I'm not exactly sure why).
369
381
370 * IPython/Debugger.py (Tracer.__init__): added new class to
382 * IPython/Debugger.py (Tracer.__init__): added new class to
371 support set_trace-like usage of IPython's enhanced debugger.
383 support set_trace-like usage of IPython's enhanced debugger.
372
384
373 2006-12-24 Ville Vainio <vivainio@gmail.com>
385 2006-12-24 Ville Vainio <vivainio@gmail.com>
374
386
375 * ipmaker.py: more informative message when ipy_user_conf
387 * ipmaker.py: more informative message when ipy_user_conf
376 import fails (suggest running %upgrade).
388 import fails (suggest running %upgrade).
377
389
378 * tools/run_ipy_in_profiler.py: Utility to see where
390 * tools/run_ipy_in_profiler.py: Utility to see where
379 the time during IPython startup is spent.
391 the time during IPython startup is spent.
380
392
381 2006-12-20 Ville Vainio <vivainio@gmail.com>
393 2006-12-20 Ville Vainio <vivainio@gmail.com>
382
394
383 * 0.7.3 is out - merge all from 0.7.3 branch to trunk
395 * 0.7.3 is out - merge all from 0.7.3 branch to trunk
384
396
385 * ipapi.py: Add new ipapi method, expand_alias.
397 * ipapi.py: Add new ipapi method, expand_alias.
386
398
387 * Release.py: Bump up version to 0.7.4.svn
399 * Release.py: Bump up version to 0.7.4.svn
388
400
389 2006-12-17 Ville Vainio <vivainio@gmail.com>
401 2006-12-17 Ville Vainio <vivainio@gmail.com>
390
402
391 * Extensions/jobctrl.py: Fixed &cmd arg arg...
403 * Extensions/jobctrl.py: Fixed &cmd arg arg...
392 to work properly on posix too
404 to work properly on posix too
393
405
394 * Release.py: Update revnum (version is still just 0.7.3).
406 * Release.py: Update revnum (version is still just 0.7.3).
395
407
396 2006-12-15 Ville Vainio <vivainio@gmail.com>
408 2006-12-15 Ville Vainio <vivainio@gmail.com>
397
409
398 * scripts/ipython_win_post_install: create ipython.py in
410 * scripts/ipython_win_post_install: create ipython.py in
399 prefix + "/scripts".
411 prefix + "/scripts".
400
412
401 * Release.py: Update version to 0.7.3.
413 * Release.py: Update version to 0.7.3.
402
414
403 2006-12-14 Ville Vainio <vivainio@gmail.com>
415 2006-12-14 Ville Vainio <vivainio@gmail.com>
404
416
405 * scripts/ipython_win_post_install: Overwrite old shortcuts
417 * scripts/ipython_win_post_install: Overwrite old shortcuts
406 if they already exist
418 if they already exist
407
419
408 * Release.py: release 0.7.3rc2
420 * Release.py: release 0.7.3rc2
409
421
410 2006-12-13 Ville Vainio <vivainio@gmail.com>
422 2006-12-13 Ville Vainio <vivainio@gmail.com>
411
423
412 * Branch and update Release.py for 0.7.3rc1
424 * Branch and update Release.py for 0.7.3rc1
413
425
414 2006-12-13 Fernando Perez <Fernando.Perez@colorado.edu>
426 2006-12-13 Fernando Perez <Fernando.Perez@colorado.edu>
415
427
416 * IPython/Shell.py (IPShellWX): update for current WX naming
428 * IPython/Shell.py (IPShellWX): update for current WX naming
417 conventions, to avoid a deprecation warning with current WX
429 conventions, to avoid a deprecation warning with current WX
418 versions. Thanks to a report by Danny Shevitz.
430 versions. Thanks to a report by Danny Shevitz.
419
431
420 2006-12-12 Ville Vainio <vivainio@gmail.com>
432 2006-12-12 Ville Vainio <vivainio@gmail.com>
421
433
422 * ipmaker.py: apply david cournapeau's patch to make
434 * ipmaker.py: apply david cournapeau's patch to make
423 import_some work properly even when ipythonrc does
435 import_some work properly even when ipythonrc does
424 import_some on empty list (it was an old bug!).
436 import_some on empty list (it was an old bug!).
425
437
426 * UserConfig/ipy_user_conf.py, UserConfig/ipythonrc:
438 * UserConfig/ipy_user_conf.py, UserConfig/ipythonrc:
427 Add deprecation note to ipythonrc and a url to wiki
439 Add deprecation note to ipythonrc and a url to wiki
428 in ipy_user_conf.py
440 in ipy_user_conf.py
429
441
430
442
431 * Magic.py (%run): %run myscript.ipy now runs myscript.ipy
443 * Magic.py (%run): %run myscript.ipy now runs myscript.ipy
432 as if it was typed on IPython command prompt, i.e.
444 as if it was typed on IPython command prompt, i.e.
433 as IPython script.
445 as IPython script.
434
446
435 * example-magic.py, magic_grepl.py: remove outdated examples
447 * example-magic.py, magic_grepl.py: remove outdated examples
436
448
437 2006-12-11 Fernando Perez <Fernando.Perez@colorado.edu>
449 2006-12-11 Fernando Perez <Fernando.Perez@colorado.edu>
438
450
439 * IPython/iplib.py (debugger): prevent a nasty traceback if %debug
451 * IPython/iplib.py (debugger): prevent a nasty traceback if %debug
440 is called before any exception has occurred.
452 is called before any exception has occurred.
441
453
442 2006-12-08 Ville Vainio <vivainio@gmail.com>
454 2006-12-08 Ville Vainio <vivainio@gmail.com>
443
455
444 * Extensions/ipy_stock_completers.py: fix cd completer
456 * Extensions/ipy_stock_completers.py: fix cd completer
445 to translate /'s to \'s again.
457 to translate /'s to \'s again.
446
458
447 * completer.py: prevent traceback on file completions w/
459 * completer.py: prevent traceback on file completions w/
448 backslash.
460 backslash.
449
461
450 * Release.py: Update release number to 0.7.3b3 for release
462 * Release.py: Update release number to 0.7.3b3 for release
451
463
452 2006-12-07 Ville Vainio <vivainio@gmail.com>
464 2006-12-07 Ville Vainio <vivainio@gmail.com>
453
465
454 * Extensions/ipy_signals.py: Ignore ctrl+C in IPython process
466 * Extensions/ipy_signals.py: Ignore ctrl+C in IPython process
455 while executing external code. Provides more shell-like behaviour
467 while executing external code. Provides more shell-like behaviour
456 and overall better response to ctrl + C / ctrl + break.
468 and overall better response to ctrl + C / ctrl + break.
457
469
458 * tools/make_tarball.py: new script to create tarball straight from svn
470 * tools/make_tarball.py: new script to create tarball straight from svn
459 (setup.py sdist doesn't work on win32).
471 (setup.py sdist doesn't work on win32).
460
472
461 * Extensions/ipy_stock_completers.py: fix cd completer to give up
473 * Extensions/ipy_stock_completers.py: fix cd completer to give up
462 on dirnames with spaces and use the default completer instead.
474 on dirnames with spaces and use the default completer instead.
463
475
464 * Revision.py: Change version to 0.7.3b2 for release.
476 * Revision.py: Change version to 0.7.3b2 for release.
465
477
466 2006-12-05 Ville Vainio <vivainio@gmail.com>
478 2006-12-05 Ville Vainio <vivainio@gmail.com>
467
479
468 * Magic.py, iplib.py, completer.py: Apply R. Bernstein's
480 * Magic.py, iplib.py, completer.py: Apply R. Bernstein's
469 pydb patch 4 (rm debug printing, py 2.5 checking)
481 pydb patch 4 (rm debug printing, py 2.5 checking)
470
482
471 2006-11-30 Walter Doerwald <walter@livinglogic.de>
483 2006-11-30 Walter Doerwald <walter@livinglogic.de>
472 * IPython/Extensions/ibrowse.py: Add two new commands to ibrowse:
484 * IPython/Extensions/ibrowse.py: Add two new commands to ibrowse:
473 "refresh" (mapped to "r") refreshes the screen by restarting the iterator.
485 "refresh" (mapped to "r") refreshes the screen by restarting the iterator.
474 "refreshfind" (mapped to "R") does the same but tries to go back to the same
486 "refreshfind" (mapped to "R") does the same but tries to go back to the same
475 object the cursor was on before the refresh. The command "markrange" is
487 object the cursor was on before the refresh. The command "markrange" is
476 mapped to "%" now.
488 mapped to "%" now.
477 * IPython/Extensions/ibrowse.py: Make igrpentry and ipwdentry comparable.
489 * IPython/Extensions/ibrowse.py: Make igrpentry and ipwdentry comparable.
478
490
479 2006-11-29 Fernando Perez <Fernando.Perez@colorado.edu>
491 2006-11-29 Fernando Perez <Fernando.Perez@colorado.edu>
480
492
481 * IPython/Magic.py (magic_debug): new %debug magic to activate the
493 * IPython/Magic.py (magic_debug): new %debug magic to activate the
482 interactive debugger on the last traceback, without having to call
494 interactive debugger on the last traceback, without having to call
483 %pdb and rerun your code. Made minor changes in various modules,
495 %pdb and rerun your code. Made minor changes in various modules,
484 should automatically recognize pydb if available.
496 should automatically recognize pydb if available.
485
497
486 2006-11-28 Ville Vainio <vivainio@gmail.com>
498 2006-11-28 Ville Vainio <vivainio@gmail.com>
487
499
488 * completer.py: If the text start with !, show file completions
500 * completer.py: If the text start with !, show file completions
489 properly. This helps when trying to complete command name
501 properly. This helps when trying to complete command name
490 for shell escapes.
502 for shell escapes.
491
503
492 2006-11-27 Ville Vainio <vivainio@gmail.com>
504 2006-11-27 Ville Vainio <vivainio@gmail.com>
493
505
494 * ipy_stock_completers.py: bzr completer submitted by Stefan van
506 * ipy_stock_completers.py: bzr completer submitted by Stefan van
495 der Walt. Clean up svn and hg completers by using a common
507 der Walt. Clean up svn and hg completers by using a common
496 vcs_completer.
508 vcs_completer.
497
509
498 2006-11-26 Ville Vainio <vivainio@gmail.com>
510 2006-11-26 Ville Vainio <vivainio@gmail.com>
499
511
500 * Remove ipconfig and %config; you should use _ip.options structure
512 * Remove ipconfig and %config; you should use _ip.options structure
501 directly instead!
513 directly instead!
502
514
503 * genutils.py: add wrap_deprecated function for deprecating callables
515 * genutils.py: add wrap_deprecated function for deprecating callables
504
516
505 * iplib.py: deprecate ipmagic, ipsystem, ipalias. Use _ip.magic and
517 * iplib.py: deprecate ipmagic, ipsystem, ipalias. Use _ip.magic and
506 _ip.system instead. ipalias is redundant.
518 _ip.system instead. ipalias is redundant.
507
519
508 * Magic.py: %rehashdir no longer aliases 'cmdname' to 'cmdname.exe' on
520 * Magic.py: %rehashdir no longer aliases 'cmdname' to 'cmdname.exe' on
509 win32, but just 'cmdname'. Other extensions (non-'exe') are still made
521 win32, but just 'cmdname'. Other extensions (non-'exe') are still made
510 explicit.
522 explicit.
511
523
512 * ipy_stock_completers.py: 'hg' (mercurial VCS) now has a custom
524 * ipy_stock_completers.py: 'hg' (mercurial VCS) now has a custom
513 completer. Try it by entering 'hg ' and pressing tab.
525 completer. Try it by entering 'hg ' and pressing tab.
514
526
515 * macro.py: Give Macro a useful __repr__ method
527 * macro.py: Give Macro a useful __repr__ method
516
528
517 * Magic.py: %whos abbreviates the typename of Macro for brevity.
529 * Magic.py: %whos abbreviates the typename of Macro for brevity.
518
530
519 2006-11-24 Walter Doerwald <walter@livinglogic.de>
531 2006-11-24 Walter Doerwald <walter@livinglogic.de>
520 * IPython/Extensions/astyle.py: Do a relative import of ipipe, so that
532 * IPython/Extensions/astyle.py: Do a relative import of ipipe, so that
521 we don't get a duplicate ipipe module, where registration of the xrepr
533 we don't get a duplicate ipipe module, where registration of the xrepr
522 implementation for Text is useless.
534 implementation for Text is useless.
523
535
524 * IPython/Extensions/ipipe.py: Fix __xrepr__() implementation for ils.
536 * IPython/Extensions/ipipe.py: Fix __xrepr__() implementation for ils.
525
537
526 * IPython/Extensions/ibrowse.py: Fix keymapping for the enter command.
538 * IPython/Extensions/ibrowse.py: Fix keymapping for the enter command.
527
539
528 2006-11-24 Ville Vainio <vivainio@gmail.com>
540 2006-11-24 Ville Vainio <vivainio@gmail.com>
529
541
530 * Magic.py, manual_base.lyx: Kirill Smelkov patch:
542 * Magic.py, manual_base.lyx: Kirill Smelkov patch:
531 try to use "cProfile" instead of the slower pure python
543 try to use "cProfile" instead of the slower pure python
532 "profile"
544 "profile"
533
545
534 2006-11-23 Ville Vainio <vivainio@gmail.com>
546 2006-11-23 Ville Vainio <vivainio@gmail.com>
535
547
536 * manual_base.lyx: Kirill Smelkov patch: Fix wrong
548 * manual_base.lyx: Kirill Smelkov patch: Fix wrong
537 Qt+IPython+Designer link in documentation.
549 Qt+IPython+Designer link in documentation.
538
550
539 * Extensions/ipy_pydb.py: R. Bernstein's patch for passing
551 * Extensions/ipy_pydb.py: R. Bernstein's patch for passing
540 correct Pdb object to %pydb.
552 correct Pdb object to %pydb.
541
553
542
554
543 2006-11-22 Walter Doerwald <walter@livinglogic.de>
555 2006-11-22 Walter Doerwald <walter@livinglogic.de>
544 * IPython/Extensions/astyle.py: Text needs it's own implemenation of the
556 * IPython/Extensions/astyle.py: Text needs it's own implemenation of the
545 generic xrepr(), otherwise the list implementation would kick in.
557 generic xrepr(), otherwise the list implementation would kick in.
546
558
547 2006-11-21 Ville Vainio <vivainio@gmail.com>
559 2006-11-21 Ville Vainio <vivainio@gmail.com>
548
560
549 * upgrade_dir.py: Now actually overwrites a nonmodified user file
561 * upgrade_dir.py: Now actually overwrites a nonmodified user file
550 with one from UserConfig.
562 with one from UserConfig.
551
563
552 * ipy_profile_sh.py: Add dummy "depth" to var_expand lambda,
564 * ipy_profile_sh.py: Add dummy "depth" to var_expand lambda,
553 it was missing which broke the sh profile.
565 it was missing which broke the sh profile.
554
566
555 * completer.py: file completer now uses explicit '/' instead
567 * completer.py: file completer now uses explicit '/' instead
556 of os.path.join, expansion of 'foo' was broken on win32
568 of os.path.join, expansion of 'foo' was broken on win32
557 if there was one directory with name 'foobar'.
569 if there was one directory with name 'foobar'.
558
570
559 * A bunch of patches from Kirill Smelkov:
571 * A bunch of patches from Kirill Smelkov:
560
572
561 * [patch 9/9] doc: point bug-tracker URL to IPythons trac-tickets.
573 * [patch 9/9] doc: point bug-tracker URL to IPythons trac-tickets.
562
574
563 * [patch 7/9] Implement %page -r (page in raw mode) -
575 * [patch 7/9] Implement %page -r (page in raw mode) -
564
576
565 * [patch 5/9] ScientificPython webpage has moved
577 * [patch 5/9] ScientificPython webpage has moved
566
578
567 * [patch 4/9] The manual mentions %ds, should be %dhist
579 * [patch 4/9] The manual mentions %ds, should be %dhist
568
580
569 * [patch 3/9] Kill old bits from %prun doc.
581 * [patch 3/9] Kill old bits from %prun doc.
570
582
571 * [patch 1/9] Fix typos here and there.
583 * [patch 1/9] Fix typos here and there.
572
584
573 2006-11-08 Ville Vainio <vivainio@gmail.com>
585 2006-11-08 Ville Vainio <vivainio@gmail.com>
574
586
575 * completer.py (attr_matches): catch all exceptions raised
587 * completer.py (attr_matches): catch all exceptions raised
576 by eval of expr with dots.
588 by eval of expr with dots.
577
589
578 2006-11-07 Fernando Perez <Fernando.Perez@colorado.edu>
590 2006-11-07 Fernando Perez <Fernando.Perez@colorado.edu>
579
591
580 * IPython/iplib.py (runsource): Prepend an 'if 1:' to the user
592 * IPython/iplib.py (runsource): Prepend an 'if 1:' to the user
581 input if it starts with whitespace. This allows you to paste
593 input if it starts with whitespace. This allows you to paste
582 indented input from any editor without manually having to type in
594 indented input from any editor without manually having to type in
583 the 'if 1:', which is convenient when working interactively.
595 the 'if 1:', which is convenient when working interactively.
584 Slightly modifed version of a patch by Bo Peng
596 Slightly modifed version of a patch by Bo Peng
585 <bpeng-AT-rice.edu>.
597 <bpeng-AT-rice.edu>.
586
598
587 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
599 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
588
600
589 * IPython/irunner.py (main): modified irunner so it automatically
601 * IPython/irunner.py (main): modified irunner so it automatically
590 recognizes the right runner to use based on the extension (.py for
602 recognizes the right runner to use based on the extension (.py for
591 python, .ipy for ipython and .sage for sage).
603 python, .ipy for ipython and .sage for sage).
592
604
593 * IPython/iplib.py (InteractiveShell.ipconfig): new builtin, also
605 * IPython/iplib.py (InteractiveShell.ipconfig): new builtin, also
594 visible in ipapi as ip.config(), to programatically control the
606 visible in ipapi as ip.config(), to programatically control the
595 internal rc object. There's an accompanying %config magic for
607 internal rc object. There's an accompanying %config magic for
596 interactive use, which has been enhanced to match the
608 interactive use, which has been enhanced to match the
597 funtionality in ipconfig.
609 funtionality in ipconfig.
598
610
599 * IPython/Magic.py (magic_system_verbose): Change %system_verbose
611 * IPython/Magic.py (magic_system_verbose): Change %system_verbose
600 so it's not just a toggle, it now takes an argument. Add support
612 so it's not just a toggle, it now takes an argument. Add support
601 for a customizable header when making system calls, as the new
613 for a customizable header when making system calls, as the new
602 system_header variable in the ipythonrc file.
614 system_header variable in the ipythonrc file.
603
615
604 2006-11-03 Walter Doerwald <walter@livinglogic.de>
616 2006-11-03 Walter Doerwald <walter@livinglogic.de>
605
617
606 * IPython/Extensions/ipipe.py: xrepr(), xiter() and xattrs() are now
618 * IPython/Extensions/ipipe.py: xrepr(), xiter() and xattrs() are now
607 generic functions (using Philip J. Eby's simplegeneric package).
619 generic functions (using Philip J. Eby's simplegeneric package).
608 This makes it possible to customize the display of third-party classes
620 This makes it possible to customize the display of third-party classes
609 without having to monkeypatch them. xiter() no longer supports a mode
621 without having to monkeypatch them. xiter() no longer supports a mode
610 argument and the XMode class has been removed. The same functionality can
622 argument and the XMode class has been removed. The same functionality can
611 be implemented via IterAttributeDescriptor and IterMethodDescriptor.
623 be implemented via IterAttributeDescriptor and IterMethodDescriptor.
612 One consequence of the switch to generic functions is that xrepr() and
624 One consequence of the switch to generic functions is that xrepr() and
613 xattrs() implementation must define the default value for the mode
625 xattrs() implementation must define the default value for the mode
614 argument themselves and xattrs() implementations must return real
626 argument themselves and xattrs() implementations must return real
615 descriptors.
627 descriptors.
616
628
617 * IPython/external: This new subpackage will contain all third-party
629 * IPython/external: This new subpackage will contain all third-party
618 packages that are bundled with IPython. (The first one is simplegeneric).
630 packages that are bundled with IPython. (The first one is simplegeneric).
619
631
620 * IPython/Extensions/ipipe.py (ifile/ils): Readd output of the parent
632 * IPython/Extensions/ipipe.py (ifile/ils): Readd output of the parent
621 directory which as been dropped in r1703.
633 directory which as been dropped in r1703.
622
634
623 * IPython/Extensions/ipipe.py (iless): Fixed.
635 * IPython/Extensions/ipipe.py (iless): Fixed.
624
636
625 * IPython/Extensions/ibrowse: Fixed sorting under Python 2.3.
637 * IPython/Extensions/ibrowse: Fixed sorting under Python 2.3.
626
638
627 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
639 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
628
640
629 * IPython/iplib.py (InteractiveShell.var_expand): fix stack
641 * IPython/iplib.py (InteractiveShell.var_expand): fix stack
630 handling in variable expansion so that shells and magics recognize
642 handling in variable expansion so that shells and magics recognize
631 function local scopes correctly. Bug reported by Brian.
643 function local scopes correctly. Bug reported by Brian.
632
644
633 * scripts/ipython: remove the very first entry in sys.path which
645 * scripts/ipython: remove the very first entry in sys.path which
634 Python auto-inserts for scripts, so that sys.path under IPython is
646 Python auto-inserts for scripts, so that sys.path under IPython is
635 as similar as possible to that under plain Python.
647 as similar as possible to that under plain Python.
636
648
637 * IPython/completer.py (IPCompleter.file_matches): Fix
649 * IPython/completer.py (IPCompleter.file_matches): Fix
638 tab-completion so that quotes are not closed unless the completion
650 tab-completion so that quotes are not closed unless the completion
639 is unambiguous. After a request by Stefan. Minor cleanups in
651 is unambiguous. After a request by Stefan. Minor cleanups in
640 ipy_stock_completers.
652 ipy_stock_completers.
641
653
642 2006-11-02 Ville Vainio <vivainio@gmail.com>
654 2006-11-02 Ville Vainio <vivainio@gmail.com>
643
655
644 * ipy_stock_completers.py: Add %run and %cd completers.
656 * ipy_stock_completers.py: Add %run and %cd completers.
645
657
646 * completer.py: Try running custom completer for both
658 * completer.py: Try running custom completer for both
647 "foo" and "%foo" if the command is just "foo". Ignore case
659 "foo" and "%foo" if the command is just "foo". Ignore case
648 when filtering possible completions.
660 when filtering possible completions.
649
661
650 * UserConfig/ipy_user_conf.py: install stock completers as default
662 * UserConfig/ipy_user_conf.py: install stock completers as default
651
663
652 * iplib.py (history_saving_wrapper), debugger(), ipy_pydb.py:
664 * iplib.py (history_saving_wrapper), debugger(), ipy_pydb.py:
653 simplified readline history save / restore through a wrapper
665 simplified readline history save / restore through a wrapper
654 function
666 function
655
667
656
668
657 2006-10-31 Ville Vainio <vivainio@gmail.com>
669 2006-10-31 Ville Vainio <vivainio@gmail.com>
658
670
659 * strdispatch.py, completer.py, ipy_stock_completers.py:
671 * strdispatch.py, completer.py, ipy_stock_completers.py:
660 Allow str_key ("command") in completer hooks. Implement
672 Allow str_key ("command") in completer hooks. Implement
661 trivial completer for 'import' (stdlib modules only). Rename
673 trivial completer for 'import' (stdlib modules only). Rename
662 ipy_linux_package_managers.py to ipy_stock_completers.py.
674 ipy_linux_package_managers.py to ipy_stock_completers.py.
663 SVN completer.
675 SVN completer.
664
676
665 * Extensions/ledit.py: %magic line editor for easily and
677 * Extensions/ledit.py: %magic line editor for easily and
666 incrementally manipulating lists of strings. The magic command
678 incrementally manipulating lists of strings. The magic command
667 name is %led.
679 name is %led.
668
680
669 2006-10-30 Ville Vainio <vivainio@gmail.com>
681 2006-10-30 Ville Vainio <vivainio@gmail.com>
670
682
671 * Debugger.py, iplib.py (debugger()): Add last set of Rocky
683 * Debugger.py, iplib.py (debugger()): Add last set of Rocky
672 Bernsteins's patches for pydb integration.
684 Bernsteins's patches for pydb integration.
673 http://bashdb.sourceforge.net/pydb/
685 http://bashdb.sourceforge.net/pydb/
674
686
675 * strdispatch.py, iplib.py, completer.py, IPython/__init__.py,
687 * strdispatch.py, iplib.py, completer.py, IPython/__init__.py,
676 Extensions/ipy_linux_package_managers.py, hooks.py: Implement
688 Extensions/ipy_linux_package_managers.py, hooks.py: Implement
677 custom completer hook to allow the users to implement their own
689 custom completer hook to allow the users to implement their own
678 completers. See ipy_linux_package_managers.py for example. The
690 completers. See ipy_linux_package_managers.py for example. The
679 hook name is 'complete_command'.
691 hook name is 'complete_command'.
680
692
681 2006-10-28 Fernando Perez <Fernando.Perez@colorado.edu>
693 2006-10-28 Fernando Perez <Fernando.Perez@colorado.edu>
682
694
683 * IPython/UserConfig/ipythonrc-scipy: minor cleanups to remove old
695 * IPython/UserConfig/ipythonrc-scipy: minor cleanups to remove old
684 Numeric leftovers.
696 Numeric leftovers.
685
697
686 * ipython.el (py-execute-region): apply Stefan's patch to fix
698 * ipython.el (py-execute-region): apply Stefan's patch to fix
687 garbled results if the python shell hasn't been previously started.
699 garbled results if the python shell hasn't been previously started.
688
700
689 * IPython/genutils.py (arg_split): moved to genutils, since it's a
701 * IPython/genutils.py (arg_split): moved to genutils, since it's a
690 pretty generic function and useful for other things.
702 pretty generic function and useful for other things.
691
703
692 * IPython/OInspect.py (getsource): Add customizable source
704 * IPython/OInspect.py (getsource): Add customizable source
693 extractor. After a request/patch form W. Stein (SAGE).
705 extractor. After a request/patch form W. Stein (SAGE).
694
706
695 * IPython/irunner.py (InteractiveRunner.run_source): reset tty
707 * IPython/irunner.py (InteractiveRunner.run_source): reset tty
696 window size to a more reasonable value from what pexpect does,
708 window size to a more reasonable value from what pexpect does,
697 since their choice causes wrapping bugs with long input lines.
709 since their choice causes wrapping bugs with long input lines.
698
710
699 2006-10-28 Ville Vainio <vivainio@gmail.com>
711 2006-10-28 Ville Vainio <vivainio@gmail.com>
700
712
701 * Magic.py (%run): Save and restore the readline history from
713 * Magic.py (%run): Save and restore the readline history from
702 file around %run commands to prevent side effects from
714 file around %run commands to prevent side effects from
703 %runned programs that might use readline (e.g. pydb).
715 %runned programs that might use readline (e.g. pydb).
704
716
705 * extensions/ipy_pydb.py: Adds %pydb magic when imported, for
717 * extensions/ipy_pydb.py: Adds %pydb magic when imported, for
706 invoking the pydb enhanced debugger.
718 invoking the pydb enhanced debugger.
707
719
708 2006-10-23 Walter Doerwald <walter@livinglogic.de>
720 2006-10-23 Walter Doerwald <walter@livinglogic.de>
709
721
710 * IPython/Extensions/ipipe.py (ifile): Remove all methods that
722 * IPython/Extensions/ipipe.py (ifile): Remove all methods that
711 call the base class method and propagate the return value to
723 call the base class method and propagate the return value to
712 ifile. This is now done by path itself.
724 ifile. This is now done by path itself.
713
725
714 2006-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
726 2006-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
715
727
716 * IPython/ipapi.py (IPApi.__init__): Added new entry to public
728 * IPython/ipapi.py (IPApi.__init__): Added new entry to public
717 api: set_crash_handler(), to expose the ability to change the
729 api: set_crash_handler(), to expose the ability to change the
718 internal crash handler.
730 internal crash handler.
719
731
720 * IPython/CrashHandler.py (CrashHandler.__init__): abstract out
732 * IPython/CrashHandler.py (CrashHandler.__init__): abstract out
721 the various parameters of the crash handler so that apps using
733 the various parameters of the crash handler so that apps using
722 IPython as their engine can customize crash handling. Ipmlemented
734 IPython as their engine can customize crash handling. Ipmlemented
723 at the request of SAGE.
735 at the request of SAGE.
724
736
725 2006-10-14 Ville Vainio <vivainio@gmail.com>
737 2006-10-14 Ville Vainio <vivainio@gmail.com>
726
738
727 * Magic.py, ipython.el: applied first "safe" part of Rocky
739 * Magic.py, ipython.el: applied first "safe" part of Rocky
728 Bernstein's patch set for pydb integration.
740 Bernstein's patch set for pydb integration.
729
741
730 * Magic.py (%unalias, %alias): %store'd aliases can now be
742 * Magic.py (%unalias, %alias): %store'd aliases can now be
731 removed with '%unalias'. %alias w/o args now shows most
743 removed with '%unalias'. %alias w/o args now shows most
732 interesting (stored / manually defined) aliases last
744 interesting (stored / manually defined) aliases last
733 where they catch the eye w/o scrolling.
745 where they catch the eye w/o scrolling.
734
746
735 * Magic.py (%rehashx), ext_rehashdir.py: files with
747 * Magic.py (%rehashx), ext_rehashdir.py: files with
736 'py' extension are always considered executable, even
748 'py' extension are always considered executable, even
737 when not in PATHEXT environment variable.
749 when not in PATHEXT environment variable.
738
750
739 2006-10-12 Ville Vainio <vivainio@gmail.com>
751 2006-10-12 Ville Vainio <vivainio@gmail.com>
740
752
741 * jobctrl.py: Add new "jobctrl" extension for spawning background
753 * jobctrl.py: Add new "jobctrl" extension for spawning background
742 processes with "&find /". 'import jobctrl' to try it out. Requires
754 processes with "&find /". 'import jobctrl' to try it out. Requires
743 'subprocess' module, standard in python 2.4+.
755 'subprocess' module, standard in python 2.4+.
744
756
745 * iplib.py (expand_aliases, handle_alias): Aliases expand transitively,
757 * iplib.py (expand_aliases, handle_alias): Aliases expand transitively,
746 so if foo -> bar and bar -> baz, then foo -> baz.
758 so if foo -> bar and bar -> baz, then foo -> baz.
747
759
748 2006-10-09 Fernando Perez <Fernando.Perez@colorado.edu>
760 2006-10-09 Fernando Perez <Fernando.Perez@colorado.edu>
749
761
750 * IPython/Magic.py (Magic.parse_options): add a new posix option
762 * IPython/Magic.py (Magic.parse_options): add a new posix option
751 to allow parsing of input args in magics that doesn't strip quotes
763 to allow parsing of input args in magics that doesn't strip quotes
752 (if posix=False). This also closes %timeit bug reported by
764 (if posix=False). This also closes %timeit bug reported by
753 Stefan.
765 Stefan.
754
766
755 2006-10-03 Ville Vainio <vivainio@gmail.com>
767 2006-10-03 Ville Vainio <vivainio@gmail.com>
756
768
757 * iplib.py (raw_input, interact): Return ValueError catching for
769 * iplib.py (raw_input, interact): Return ValueError catching for
758 raw_input. Fixes infinite loop for sys.stdin.close() or
770 raw_input. Fixes infinite loop for sys.stdin.close() or
759 sys.stdout.close().
771 sys.stdout.close().
760
772
761 2006-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
773 2006-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
762
774
763 * IPython/irunner.py (InteractiveRunner.run_source): small fixes
775 * IPython/irunner.py (InteractiveRunner.run_source): small fixes
764 to help in handling doctests. irunner is now pretty useful for
776 to help in handling doctests. irunner is now pretty useful for
765 running standalone scripts and simulate a full interactive session
777 running standalone scripts and simulate a full interactive session
766 in a format that can be then pasted as a doctest.
778 in a format that can be then pasted as a doctest.
767
779
768 * IPython/iplib.py (InteractiveShell.__init__): Install exit/quit
780 * IPython/iplib.py (InteractiveShell.__init__): Install exit/quit
769 on top of the default (useless) ones. This also fixes the nasty
781 on top of the default (useless) ones. This also fixes the nasty
770 way in which 2.5's Quitter() exits (reverted [1785]).
782 way in which 2.5's Quitter() exits (reverted [1785]).
771
783
772 * IPython/Debugger.py (Pdb.__init__): Fix ipdb to work with python
784 * IPython/Debugger.py (Pdb.__init__): Fix ipdb to work with python
773 2.5.
785 2.5.
774
786
775 * IPython/ultraTB.py (TBTools.set_colors): Make sure that ipdb
787 * IPython/ultraTB.py (TBTools.set_colors): Make sure that ipdb
776 color scheme is updated as well when color scheme is changed
788 color scheme is updated as well when color scheme is changed
777 interactively.
789 interactively.
778
790
779 2006-09-27 Ville Vainio <vivainio@gmail.com>
791 2006-09-27 Ville Vainio <vivainio@gmail.com>
780
792
781 * iplib.py (raw_input): python 2.5 closes stdin on quit -> avoid
793 * iplib.py (raw_input): python 2.5 closes stdin on quit -> avoid
782 infinite loop and just exit. It's a hack, but will do for a while.
794 infinite loop and just exit. It's a hack, but will do for a while.
783
795
784 2006-08-25 Walter Doerwald <walter@livinglogic.de>
796 2006-08-25 Walter Doerwald <walter@livinglogic.de>
785
797
786 * IPython/Extensions/ipipe.py (ils): Add arguments dirs and files to
798 * IPython/Extensions/ipipe.py (ils): Add arguments dirs and files to
787 the constructor, this makes it possible to get a list of only directories
799 the constructor, this makes it possible to get a list of only directories
788 or only files.
800 or only files.
789
801
790 2006-08-12 Ville Vainio <vivainio@gmail.com>
802 2006-08-12 Ville Vainio <vivainio@gmail.com>
791
803
792 * Fakemodule.py, OInspect.py: Reverted 2006-08-11 mods,
804 * Fakemodule.py, OInspect.py: Reverted 2006-08-11 mods,
793 they broke unittest
805 they broke unittest
794
806
795 2006-08-11 Ville Vainio <vivainio@gmail.com>
807 2006-08-11 Ville Vainio <vivainio@gmail.com>
796
808
797 * Fakemodule.py, OInspect.py: remove 2006-08-09 monkepatch
809 * Fakemodule.py, OInspect.py: remove 2006-08-09 monkepatch
798 by resolving issue properly, i.e. by inheriting FakeModule
810 by resolving issue properly, i.e. by inheriting FakeModule
799 from types.ModuleType. Pickling ipython interactive data
811 from types.ModuleType. Pickling ipython interactive data
800 should still work as usual (testing appreciated).
812 should still work as usual (testing appreciated).
801
813
802 2006-08-09 Fernando Perez <Fernando.Perez@colorado.edu>
814 2006-08-09 Fernando Perez <Fernando.Perez@colorado.edu>
803
815
804 * IPython/OInspect.py: monkeypatch inspect from the stdlib if
816 * IPython/OInspect.py: monkeypatch inspect from the stdlib if
805 running under python 2.3 with code from 2.4 to fix a bug with
817 running under python 2.3 with code from 2.4 to fix a bug with
806 help(). Reported by the Debian maintainers, Norbert Tretkowski
818 help(). Reported by the Debian maintainers, Norbert Tretkowski
807 <norbert-AT-tretkowski.de> and Alexandre Fayolle
819 <norbert-AT-tretkowski.de> and Alexandre Fayolle
808 <afayolle-AT-debian.org>.
820 <afayolle-AT-debian.org>.
809
821
810 2006-08-04 Walter Doerwald <walter@livinglogic.de>
822 2006-08-04 Walter Doerwald <walter@livinglogic.de>
811
823
812 * IPython/Extensions/ibrowse.py: Fixed the help message in the footer
824 * IPython/Extensions/ibrowse.py: Fixed the help message in the footer
813 (which was displaying "quit" twice).
825 (which was displaying "quit" twice).
814
826
815 2006-07-28 Walter Doerwald <walter@livinglogic.de>
827 2006-07-28 Walter Doerwald <walter@livinglogic.de>
816
828
817 * IPython/Extensions/ipipe.py: Fix isort.__iter__() (was still using
829 * IPython/Extensions/ipipe.py: Fix isort.__iter__() (was still using
818 the mode argument).
830 the mode argument).
819
831
820 2006-07-27 Walter Doerwald <walter@livinglogic.de>
832 2006-07-27 Walter Doerwald <walter@livinglogic.de>
821
833
822 * IPython/Extensions/ipipe.py: Fix getglobals() if we're
834 * IPython/Extensions/ipipe.py: Fix getglobals() if we're
823 not running under IPython.
835 not running under IPython.
824
836
825 * IPython/Extensions/ipipe.py: Rename XAttr to AttributeDetail
837 * IPython/Extensions/ipipe.py: Rename XAttr to AttributeDetail
826 and make it iterable (iterating over the attribute itself). Add two new
838 and make it iterable (iterating over the attribute itself). Add two new
827 magic strings for __xattrs__(): If the string starts with "-", the attribute
839 magic strings for __xattrs__(): If the string starts with "-", the attribute
828 will not be displayed in ibrowse's detail view (but it can still be
840 will not be displayed in ibrowse's detail view (but it can still be
829 iterated over). This makes it possible to add attributes that are large
841 iterated over). This makes it possible to add attributes that are large
830 lists or generator methods to the detail view. Replace magic attribute names
842 lists or generator methods to the detail view. Replace magic attribute names
831 and _attrname() and _getattr() with "descriptors": For each type of magic
843 and _attrname() and _getattr() with "descriptors": For each type of magic
832 attribute name there's a subclass of Descriptor: None -> SelfDescriptor();
844 attribute name there's a subclass of Descriptor: None -> SelfDescriptor();
833 "foo" -> AttributeDescriptor("foo"); "foo()" -> MethodDescriptor("foo");
845 "foo" -> AttributeDescriptor("foo"); "foo()" -> MethodDescriptor("foo");
834 "-foo" -> IterAttributeDescriptor("foo"); "-foo()" -> IterMethodDescriptor("foo");
846 "-foo" -> IterAttributeDescriptor("foo"); "-foo()" -> IterMethodDescriptor("foo");
835 foo() -> FunctionDescriptor(foo). Magic strings returned from __xattrs__()
847 foo() -> FunctionDescriptor(foo). Magic strings returned from __xattrs__()
836 are still supported.
848 are still supported.
837
849
838 * IPython/Extensions/ibrowse.py: If fetching the next row from the input
850 * IPython/Extensions/ibrowse.py: If fetching the next row from the input
839 fails in ibrowse.fetch(), the exception object is added as the last item
851 fails in ibrowse.fetch(), the exception object is added as the last item
840 and item fetching is canceled. This prevents ibrowse from aborting if e.g.
852 and item fetching is canceled. This prevents ibrowse from aborting if e.g.
841 a generator throws an exception midway through execution.
853 a generator throws an exception midway through execution.
842
854
843 * IPython/Extensions/ipipe.py: Turn ifile's properties mimetype and
855 * IPython/Extensions/ipipe.py: Turn ifile's properties mimetype and
844 encoding into methods.
856 encoding into methods.
845
857
846 2006-07-26 Ville Vainio <vivainio@gmail.com>
858 2006-07-26 Ville Vainio <vivainio@gmail.com>
847
859
848 * iplib.py: history now stores multiline input as single
860 * iplib.py: history now stores multiline input as single
849 history entries. Patch by Jorgen Cederlof.
861 history entries. Patch by Jorgen Cederlof.
850
862
851 2006-07-18 Walter Doerwald <walter@livinglogic.de>
863 2006-07-18 Walter Doerwald <walter@livinglogic.de>
852
864
853 * IPython/Extensions/ibrowse.py: Make cursor visible over
865 * IPython/Extensions/ibrowse.py: Make cursor visible over
854 non existing attributes.
866 non existing attributes.
855
867
856 2006-07-14 Walter Doerwald <walter@livinglogic.de>
868 2006-07-14 Walter Doerwald <walter@livinglogic.de>
857
869
858 * IPython/Extensions/ipipe.py (ix): Use os.popen4() so that the
870 * IPython/Extensions/ipipe.py (ix): Use os.popen4() so that the
859 error output of the running command doesn't mess up the screen.
871 error output of the running command doesn't mess up the screen.
860
872
861 2006-07-13 Walter Doerwald <walter@livinglogic.de>
873 2006-07-13 Walter Doerwald <walter@livinglogic.de>
862
874
863 * IPython/Extensions/ipipe.py (isort): Make isort usable without
875 * IPython/Extensions/ipipe.py (isort): Make isort usable without
864 argument. This sorts the items themselves.
876 argument. This sorts the items themselves.
865
877
866 2006-07-12 Walter Doerwald <walter@livinglogic.de>
878 2006-07-12 Walter Doerwald <walter@livinglogic.de>
867
879
868 * IPython/Extensions/ipipe.py (eval, ifilter, isort, ieval):
880 * IPython/Extensions/ipipe.py (eval, ifilter, isort, ieval):
869 Compile expression strings into code objects. This should speed
881 Compile expression strings into code objects. This should speed
870 up ifilter and friends somewhat.
882 up ifilter and friends somewhat.
871
883
872 2006-07-08 Ville Vainio <vivainio@gmail.com>
884 2006-07-08 Ville Vainio <vivainio@gmail.com>
873
885
874 * Magic.py: %cpaste now strips > from the beginning of lines
886 * Magic.py: %cpaste now strips > from the beginning of lines
875 to ease pasting quoted code from emails. Contributed by
887 to ease pasting quoted code from emails. Contributed by
876 Stefan van der Walt.
888 Stefan van der Walt.
877
889
878 2006-06-29 Ville Vainio <vivainio@gmail.com>
890 2006-06-29 Ville Vainio <vivainio@gmail.com>
879
891
880 * ipmaker.py, Shell.py: qt4agg matplotlib backend support for pylab
892 * ipmaker.py, Shell.py: qt4agg matplotlib backend support for pylab
881 mode, patch contributed by Darren Dale. NEEDS TESTING!
893 mode, patch contributed by Darren Dale. NEEDS TESTING!
882
894
883 2006-06-28 Walter Doerwald <walter@livinglogic.de>
895 2006-06-28 Walter Doerwald <walter@livinglogic.de>
884
896
885 * IPython/Extensions/ibrowse.py: Give the ibrowse cursor row
897 * IPython/Extensions/ibrowse.py: Give the ibrowse cursor row
886 a blue background. Fix fetching new display rows when the browser
898 a blue background. Fix fetching new display rows when the browser
887 scrolls more than a screenful (e.g. by using the goto command).
899 scrolls more than a screenful (e.g. by using the goto command).
888
900
889 2006-06-27 Ville Vainio <vivainio@gmail.com>
901 2006-06-27 Ville Vainio <vivainio@gmail.com>
890
902
891 * Magic.py (_inspect, _ofind) Apply David Huard's
903 * Magic.py (_inspect, _ofind) Apply David Huard's
892 patch for displaying the correct docstring for 'property'
904 patch for displaying the correct docstring for 'property'
893 attributes.
905 attributes.
894
906
895 2006-06-23 Walter Doerwald <walter@livinglogic.de>
907 2006-06-23 Walter Doerwald <walter@livinglogic.de>
896
908
897 * IPython/Extensions/ibrowse.py: Put the documentation of the keyboard
909 * IPython/Extensions/ibrowse.py: Put the documentation of the keyboard
898 commands into the methods implementing them.
910 commands into the methods implementing them.
899
911
900 2006-06-22 Fernando Perez <Fernando.Perez@colorado.edu>
912 2006-06-22 Fernando Perez <Fernando.Perez@colorado.edu>
901
913
902 * ipython.el (ipython-indentation-hook): cleanup patch, submitted
914 * ipython.el (ipython-indentation-hook): cleanup patch, submitted
903 by Kov Chai <tchaikov-AT-gmail.com>. He notes that the original
915 by Kov Chai <tchaikov-AT-gmail.com>. He notes that the original
904 autoindent support was authored by Jin Liu.
916 autoindent support was authored by Jin Liu.
905
917
906 2006-06-22 Walter Doerwald <walter@livinglogic.de>
918 2006-06-22 Walter Doerwald <walter@livinglogic.de>
907
919
908 * IPython/Extensions/ibrowse.py: Replace the plain dictionaries used
920 * IPython/Extensions/ibrowse.py: Replace the plain dictionaries used
909 for keymaps with a custom class that simplifies handling.
921 for keymaps with a custom class that simplifies handling.
910
922
911 2006-06-19 Walter Doerwald <walter@livinglogic.de>
923 2006-06-19 Walter Doerwald <walter@livinglogic.de>
912
924
913 * IPython/Extensions/ibrowse.py: ibrowse now properly handles terminal
925 * IPython/Extensions/ibrowse.py: ibrowse now properly handles terminal
914 resizing. This requires Python 2.5 to work.
926 resizing. This requires Python 2.5 to work.
915
927
916 2006-06-16 Walter Doerwald <walter@livinglogic.de>
928 2006-06-16 Walter Doerwald <walter@livinglogic.de>
917
929
918 * IPython/Extensions/ibrowse.py: Add two new commands to
930 * IPython/Extensions/ibrowse.py: Add two new commands to
919 ibrowse: "hideattr" (mapped to "h") hides the attribute under
931 ibrowse: "hideattr" (mapped to "h") hides the attribute under
920 the cursor. "unhiderattrs" (mapped to "H") reveals all hidden
932 the cursor. "unhiderattrs" (mapped to "H") reveals all hidden
921 attributes again. Remapped the help command to "?". Display
933 attributes again. Remapped the help command to "?". Display
922 keycodes in the range 0x01-0x1F as CTRL-xx. Add CTRL-a and CTRL-e
934 keycodes in the range 0x01-0x1F as CTRL-xx. Add CTRL-a and CTRL-e
923 as keys for the "home" and "end" commands. Add three new commands
935 as keys for the "home" and "end" commands. Add three new commands
924 to the input mode for "find" and friends: "delend" (CTRL-K)
936 to the input mode for "find" and friends: "delend" (CTRL-K)
925 deletes to the end of line. "incsearchup" searches upwards in the
937 deletes to the end of line. "incsearchup" searches upwards in the
926 command history for an input that starts with the text before the cursor.
938 command history for an input that starts with the text before the cursor.
927 "incsearchdown" does the same downwards. Removed a bogus mapping of
939 "incsearchdown" does the same downwards. Removed a bogus mapping of
928 the x key to "delete".
940 the x key to "delete".
929
941
930 2006-06-15 Ville Vainio <vivainio@gmail.com>
942 2006-06-15 Ville Vainio <vivainio@gmail.com>
931
943
932 * iplib.py, hooks.py: Added new generate_prompt hook that can be
944 * iplib.py, hooks.py: Added new generate_prompt hook that can be
933 used to create prompts dynamically, instead of the "old" way of
945 used to create prompts dynamically, instead of the "old" way of
934 assigning "magic" strings to prompt_in1 and prompt_in2. The old
946 assigning "magic" strings to prompt_in1 and prompt_in2. The old
935 way still works (it's invoked by the default hook), of course.
947 way still works (it's invoked by the default hook), of course.
936
948
937 * Prompts.py: added generate_output_prompt hook for altering output
949 * Prompts.py: added generate_output_prompt hook for altering output
938 prompt
950 prompt
939
951
940 * Release.py: Changed version string to 0.7.3.svn.
952 * Release.py: Changed version string to 0.7.3.svn.
941
953
942 2006-06-15 Walter Doerwald <walter@livinglogic.de>
954 2006-06-15 Walter Doerwald <walter@livinglogic.de>
943
955
944 * IPython/Extensions/ibrowse.py: Change _BrowserLevel.moveto() so that
956 * IPython/Extensions/ibrowse.py: Change _BrowserLevel.moveto() so that
945 the call to fetch() always tries to fetch enough data for at least one
957 the call to fetch() always tries to fetch enough data for at least one
946 full screen. This makes it possible to simply call moveto(0,0,True) in
958 full screen. This makes it possible to simply call moveto(0,0,True) in
947 the constructor. Fix typos and removed the obsolete goto attribute.
959 the constructor. Fix typos and removed the obsolete goto attribute.
948
960
949 2006-06-12 Ville Vainio <vivainio@gmail.com>
961 2006-06-12 Ville Vainio <vivainio@gmail.com>
950
962
951 * ipy_profile_sh.py: applied Krisha Mohan Gundu's patch for
963 * ipy_profile_sh.py: applied Krisha Mohan Gundu's patch for
952 allowing $variable interpolation within multiline statements,
964 allowing $variable interpolation within multiline statements,
953 though so far only with "sh" profile for a testing period.
965 though so far only with "sh" profile for a testing period.
954 The patch also enables splitting long commands with \ but it
966 The patch also enables splitting long commands with \ but it
955 doesn't work properly yet.
967 doesn't work properly yet.
956
968
957 2006-06-12 Walter Doerwald <walter@livinglogic.de>
969 2006-06-12 Walter Doerwald <walter@livinglogic.de>
958
970
959 * IPython/Extensions/ibrowse.py (_dodisplay): Display the length of the
971 * IPython/Extensions/ibrowse.py (_dodisplay): Display the length of the
960 input history and the position of the cursor in the input history for
972 input history and the position of the cursor in the input history for
961 the find, findbackwards and goto command.
973 the find, findbackwards and goto command.
962
974
963 2006-06-10 Walter Doerwald <walter@livinglogic.de>
975 2006-06-10 Walter Doerwald <walter@livinglogic.de>
964
976
965 * IPython/Extensions/ibrowse.py: Add a class _CommandInput that
977 * IPython/Extensions/ibrowse.py: Add a class _CommandInput that
966 implements the basic functionality of browser commands that require
978 implements the basic functionality of browser commands that require
967 input. Reimplement the goto, find and findbackwards commands as
979 input. Reimplement the goto, find and findbackwards commands as
968 subclasses of _CommandInput. Add an input history and keymaps to those
980 subclasses of _CommandInput. Add an input history and keymaps to those
969 commands. Add "\r" as a keyboard shortcut for the enterdefault and
981 commands. Add "\r" as a keyboard shortcut for the enterdefault and
970 execute commands.
982 execute commands.
971
983
972 2006-06-07 Ville Vainio <vivainio@gmail.com>
984 2006-06-07 Ville Vainio <vivainio@gmail.com>
973
985
974 * iplib.py: ipython mybatch.ipy exits ipython immediately after
986 * iplib.py: ipython mybatch.ipy exits ipython immediately after
975 running the batch files instead of leaving the session open.
987 running the batch files instead of leaving the session open.
976
988
977 2006-06-07 Fernando Perez <Fernando.Perez@colorado.edu>
989 2006-06-07 Fernando Perez <Fernando.Perez@colorado.edu>
978
990
979 * IPython/iplib.py (InteractiveShell.__init__): update BSD fix, as
991 * IPython/iplib.py (InteractiveShell.__init__): update BSD fix, as
980 the original fix was incomplete. Patch submitted by W. Maier.
992 the original fix was incomplete. Patch submitted by W. Maier.
981
993
982 2006-06-07 Ville Vainio <vivainio@gmail.com>
994 2006-06-07 Ville Vainio <vivainio@gmail.com>
983
995
984 * iplib.py,Magic.py, ipmaker.py (magic_rehashx):
996 * iplib.py,Magic.py, ipmaker.py (magic_rehashx):
985 Confirmation prompts can be supressed by 'quiet' option.
997 Confirmation prompts can be supressed by 'quiet' option.
986 _ip.options.quiet = 1 means "assume yes for all yes/no queries".
998 _ip.options.quiet = 1 means "assume yes for all yes/no queries".
987
999
988 2006-06-06 *** Released version 0.7.2
1000 2006-06-06 *** Released version 0.7.2
989
1001
990 2006-06-06 Fernando Perez <Fernando.Perez@colorado.edu>
1002 2006-06-06 Fernando Perez <Fernando.Perez@colorado.edu>
991
1003
992 * IPython/Release.py (version): Made 0.7.2 final for release.
1004 * IPython/Release.py (version): Made 0.7.2 final for release.
993 Repo tagged and release cut.
1005 Repo tagged and release cut.
994
1006
995 2006-06-05 Ville Vainio <vivainio@gmail.com>
1007 2006-06-05 Ville Vainio <vivainio@gmail.com>
996
1008
997 * Magic.py (magic_rehashx): Honor no_alias list earlier in
1009 * Magic.py (magic_rehashx): Honor no_alias list earlier in
998 %rehashx, to avoid clobbering builtins in ipy_profile_sh.py
1010 %rehashx, to avoid clobbering builtins in ipy_profile_sh.py
999
1011
1000 * upgrade_dir.py: try import 'path' module a bit harder
1012 * upgrade_dir.py: try import 'path' module a bit harder
1001 (for %upgrade)
1013 (for %upgrade)
1002
1014
1003 2006-06-03 Fernando Perez <Fernando.Perez@colorado.edu>
1015 2006-06-03 Fernando Perez <Fernando.Perez@colorado.edu>
1004
1016
1005 * IPython/genutils.py (ask_yes_no): treat EOF as a default answer
1017 * IPython/genutils.py (ask_yes_no): treat EOF as a default answer
1006 instead of looping 20 times.
1018 instead of looping 20 times.
1007
1019
1008 * IPython/ipmaker.py (make_IPython): honor -ipythondir flag
1020 * IPython/ipmaker.py (make_IPython): honor -ipythondir flag
1009 correctly at initialization time. Bug reported by Krishna Mohan
1021 correctly at initialization time. Bug reported by Krishna Mohan
1010 Gundu <gkmohan-AT-gmail.com> on the user list.
1022 Gundu <gkmohan-AT-gmail.com> on the user list.
1011
1023
1012 * IPython/Release.py (version): Mark 0.7.2 version to start
1024 * IPython/Release.py (version): Mark 0.7.2 version to start
1013 testing for release on 06/06.
1025 testing for release on 06/06.
1014
1026
1015 2006-05-31 Fernando Perez <Fernando.Perez@colorado.edu>
1027 2006-05-31 Fernando Perez <Fernando.Perez@colorado.edu>
1016
1028
1017 * scripts/irunner: thin script interface so users don't have to
1029 * scripts/irunner: thin script interface so users don't have to
1018 find the module and call it as an executable, since modules rarely
1030 find the module and call it as an executable, since modules rarely
1019 live in people's PATH.
1031 live in people's PATH.
1020
1032
1021 * IPython/irunner.py (InteractiveRunner.__init__): added
1033 * IPython/irunner.py (InteractiveRunner.__init__): added
1022 delaybeforesend attribute to control delays with newer versions of
1034 delaybeforesend attribute to control delays with newer versions of
1023 pexpect. Thanks to detailed help from pexpect's author, Noah
1035 pexpect. Thanks to detailed help from pexpect's author, Noah
1024 Spurrier <noah-AT-noah.org>. Noted how to use the SAGE runner
1036 Spurrier <noah-AT-noah.org>. Noted how to use the SAGE runner
1025 correctly (it works in NoColor mode).
1037 correctly (it works in NoColor mode).
1026
1038
1027 * IPython/iplib.py (handle_normal): fix nasty crash reported on
1039 * IPython/iplib.py (handle_normal): fix nasty crash reported on
1028 SAGE list, from improper log() calls.
1040 SAGE list, from improper log() calls.
1029
1041
1030 2006-05-31 Ville Vainio <vivainio@gmail.com>
1042 2006-05-31 Ville Vainio <vivainio@gmail.com>
1031
1043
1032 * upgrade_dir.py, Magic.py (magic_upgrade): call upgrade_dir
1044 * upgrade_dir.py, Magic.py (magic_upgrade): call upgrade_dir
1033 with args in parens to work correctly with dirs that have spaces.
1045 with args in parens to work correctly with dirs that have spaces.
1034
1046
1035 2006-05-30 Fernando Perez <Fernando.Perez@colorado.edu>
1047 2006-05-30 Fernando Perez <Fernando.Perez@colorado.edu>
1036
1048
1037 * IPython/Logger.py (Logger.logstart): add option to log raw input
1049 * IPython/Logger.py (Logger.logstart): add option to log raw input
1038 instead of the processed one. A -r flag was added to the
1050 instead of the processed one. A -r flag was added to the
1039 %logstart magic used for controlling logging.
1051 %logstart magic used for controlling logging.
1040
1052
1041 2006-05-29 Fernando Perez <Fernando.Perez@colorado.edu>
1053 2006-05-29 Fernando Perez <Fernando.Perez@colorado.edu>
1042
1054
1043 * IPython/iplib.py (InteractiveShell.__init__): add check for the
1055 * IPython/iplib.py (InteractiveShell.__init__): add check for the
1044 *BSDs to omit --color from all 'ls' aliases, since *BSD ls doesn't
1056 *BSDs to omit --color from all 'ls' aliases, since *BSD ls doesn't
1045 recognize the option. After a bug report by Will Maier. This
1057 recognize the option. After a bug report by Will Maier. This
1046 closes #64 (will do it after confirmation from W. Maier).
1058 closes #64 (will do it after confirmation from W. Maier).
1047
1059
1048 * IPython/irunner.py: New module to run scripts as if manually
1060 * IPython/irunner.py: New module to run scripts as if manually
1049 typed into an interactive environment, based on pexpect. After a
1061 typed into an interactive environment, based on pexpect. After a
1050 submission by Ken Schutte <kschutte-AT-csail.mit.edu> on the
1062 submission by Ken Schutte <kschutte-AT-csail.mit.edu> on the
1051 ipython-user list. Simple unittests in the tests/ directory.
1063 ipython-user list. Simple unittests in the tests/ directory.
1052
1064
1053 * tools/release: add Will Maier, OpenBSD port maintainer, to
1065 * tools/release: add Will Maier, OpenBSD port maintainer, to
1054 recepients list. We are now officially part of the OpenBSD ports:
1066 recepients list. We are now officially part of the OpenBSD ports:
1055 http://www.openbsd.org/ports.html ! Many thanks to Will for the
1067 http://www.openbsd.org/ports.html ! Many thanks to Will for the
1056 work.
1068 work.
1057
1069
1058 2006-05-26 Fernando Perez <Fernando.Perez@colorado.edu>
1070 2006-05-26 Fernando Perez <Fernando.Perez@colorado.edu>
1059
1071
1060 * IPython/ipmaker.py (make_IPython): modify sys.argv fix (below)
1072 * IPython/ipmaker.py (make_IPython): modify sys.argv fix (below)
1061 so that it doesn't break tkinter apps.
1073 so that it doesn't break tkinter apps.
1062
1074
1063 * IPython/iplib.py (_prefilter): fix bug where aliases would
1075 * IPython/iplib.py (_prefilter): fix bug where aliases would
1064 shadow variables when autocall was fully off. Reported by SAGE
1076 shadow variables when autocall was fully off. Reported by SAGE
1065 author William Stein.
1077 author William Stein.
1066
1078
1067 * IPython/OInspect.py (Inspector.__init__): add a flag to control
1079 * IPython/OInspect.py (Inspector.__init__): add a flag to control
1068 at what detail level strings are computed when foo? is requested.
1080 at what detail level strings are computed when foo? is requested.
1069 This allows users to ask for example that the string form of an
1081 This allows users to ask for example that the string form of an
1070 object is only computed when foo?? is called, or even never, by
1082 object is only computed when foo?? is called, or even never, by
1071 setting the object_info_string_level >= 2 in the configuration
1083 setting the object_info_string_level >= 2 in the configuration
1072 file. This new option has been added and documented. After a
1084 file. This new option has been added and documented. After a
1073 request by SAGE to be able to control the printing of very large
1085 request by SAGE to be able to control the printing of very large
1074 objects more easily.
1086 objects more easily.
1075
1087
1076 2006-05-25 Fernando Perez <Fernando.Perez@colorado.edu>
1088 2006-05-25 Fernando Perez <Fernando.Perez@colorado.edu>
1077
1089
1078 * IPython/ipmaker.py (make_IPython): remove the ipython call path
1090 * IPython/ipmaker.py (make_IPython): remove the ipython call path
1079 from sys.argv, to be 100% consistent with how Python itself works
1091 from sys.argv, to be 100% consistent with how Python itself works
1080 (as seen for example with python -i file.py). After a bug report
1092 (as seen for example with python -i file.py). After a bug report
1081 by Jeffrey Collins.
1093 by Jeffrey Collins.
1082
1094
1083 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix
1095 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix
1084 nasty bug which was preventing custom namespaces with -pylab,
1096 nasty bug which was preventing custom namespaces with -pylab,
1085 reported by M. Foord. Minor cleanup, remove old matplotlib.matlab
1097 reported by M. Foord. Minor cleanup, remove old matplotlib.matlab
1086 compatibility (long gone from mpl).
1098 compatibility (long gone from mpl).
1087
1099
1088 * IPython/ipapi.py (make_session): name change: create->make. We
1100 * IPython/ipapi.py (make_session): name change: create->make. We
1089 use make in other places (ipmaker,...), it's shorter and easier to
1101 use make in other places (ipmaker,...), it's shorter and easier to
1090 type and say, etc. I'm trying to clean things before 0.7.2 so
1102 type and say, etc. I'm trying to clean things before 0.7.2 so
1091 that I can keep things stable wrt to ipapi in the chainsaw branch.
1103 that I can keep things stable wrt to ipapi in the chainsaw branch.
1092
1104
1093 * ipython.el: fix the py-pdbtrack-input-prompt variable so that
1105 * ipython.el: fix the py-pdbtrack-input-prompt variable so that
1094 python-mode recognizes our debugger mode. Add support for
1106 python-mode recognizes our debugger mode. Add support for
1095 autoindent inside (X)emacs. After a patch sent in by Jin Liu
1107 autoindent inside (X)emacs. After a patch sent in by Jin Liu
1096 <m.liu.jin-AT-gmail.com> originally written by
1108 <m.liu.jin-AT-gmail.com> originally written by
1097 doxgen-AT-newsmth.net (with minor modifications for xemacs
1109 doxgen-AT-newsmth.net (with minor modifications for xemacs
1098 compatibility)
1110 compatibility)
1099
1111
1100 * IPython/Debugger.py (Pdb.format_stack_entry): fix formatting of
1112 * IPython/Debugger.py (Pdb.format_stack_entry): fix formatting of
1101 tracebacks when walking the stack so that the stack tracking system
1113 tracebacks when walking the stack so that the stack tracking system
1102 in emacs' python-mode can identify the frames correctly.
1114 in emacs' python-mode can identify the frames correctly.
1103
1115
1104 * IPython/ipmaker.py (make_IPython): make the internal (and
1116 * IPython/ipmaker.py (make_IPython): make the internal (and
1105 default config) autoedit_syntax value false by default. Too many
1117 default config) autoedit_syntax value false by default. Too many
1106 users have complained to me (both on and off-list) about problems
1118 users have complained to me (both on and off-list) about problems
1107 with this option being on by default, so I'm making it default to
1119 with this option being on by default, so I'm making it default to
1108 off. It can still be enabled by anyone via the usual mechanisms.
1120 off. It can still be enabled by anyone via the usual mechanisms.
1109
1121
1110 * IPython/completer.py (Completer.attr_matches): add support for
1122 * IPython/completer.py (Completer.attr_matches): add support for
1111 PyCrust-style _getAttributeNames magic method. Patch contributed
1123 PyCrust-style _getAttributeNames magic method. Patch contributed
1112 by <mscott-AT-goldenspud.com>. Closes #50.
1124 by <mscott-AT-goldenspud.com>. Closes #50.
1113
1125
1114 * IPython/iplib.py (InteractiveShell.__init__): remove the
1126 * IPython/iplib.py (InteractiveShell.__init__): remove the
1115 deletion of exit/quit from __builtin__, which can break
1127 deletion of exit/quit from __builtin__, which can break
1116 third-party tools like the Zope debugging console. The
1128 third-party tools like the Zope debugging console. The
1117 %exit/%quit magics remain. In general, it's probably a good idea
1129 %exit/%quit magics remain. In general, it's probably a good idea
1118 not to delete anything from __builtin__, since we never know what
1130 not to delete anything from __builtin__, since we never know what
1119 that will break. In any case, python now (for 2.5) will support
1131 that will break. In any case, python now (for 2.5) will support
1120 'real' exit/quit, so this issue is moot. Closes #55.
1132 'real' exit/quit, so this issue is moot. Closes #55.
1121
1133
1122 * IPython/genutils.py (with_obj): rename the 'with' function to
1134 * IPython/genutils.py (with_obj): rename the 'with' function to
1123 'withobj' to avoid incompatibilities with Python 2.5, where 'with'
1135 'withobj' to avoid incompatibilities with Python 2.5, where 'with'
1124 becomes a language keyword. Closes #53.
1136 becomes a language keyword. Closes #53.
1125
1137
1126 * IPython/FakeModule.py (FakeModule.__init__): add a proper
1138 * IPython/FakeModule.py (FakeModule.__init__): add a proper
1127 __file__ attribute to this so it fools more things into thinking
1139 __file__ attribute to this so it fools more things into thinking
1128 it is a real module. Closes #59.
1140 it is a real module. Closes #59.
1129
1141
1130 * IPython/Magic.py (magic_edit): add -n option to open the editor
1142 * IPython/Magic.py (magic_edit): add -n option to open the editor
1131 at a specific line number. After a patch by Stefan van der Walt.
1143 at a specific line number. After a patch by Stefan van der Walt.
1132
1144
1133 2006-05-23 Fernando Perez <Fernando.Perez@colorado.edu>
1145 2006-05-23 Fernando Perez <Fernando.Perez@colorado.edu>
1134
1146
1135 * IPython/iplib.py (edit_syntax_error): fix crash when for some
1147 * IPython/iplib.py (edit_syntax_error): fix crash when for some
1136 reason the file could not be opened. After automatic crash
1148 reason the file could not be opened. After automatic crash
1137 reports sent by James Graham <jgraham-AT-ast.cam.ac.uk> and
1149 reports sent by James Graham <jgraham-AT-ast.cam.ac.uk> and
1138 Charles Dolan <charlespatrickdolan-AT-yahoo.com>.
1150 Charles Dolan <charlespatrickdolan-AT-yahoo.com>.
1139 (_should_recompile): Don't fire editor if using %bg, since there
1151 (_should_recompile): Don't fire editor if using %bg, since there
1140 is no file in the first place. From the same report as above.
1152 is no file in the first place. From the same report as above.
1141 (raw_input): protect against faulty third-party prefilters. After
1153 (raw_input): protect against faulty third-party prefilters. After
1142 an automatic crash report sent by Dirk Laurie <dirk-AT-sun.ac.za>
1154 an automatic crash report sent by Dirk Laurie <dirk-AT-sun.ac.za>
1143 while running under SAGE.
1155 while running under SAGE.
1144
1156
1145 2006-05-23 Ville Vainio <vivainio@gmail.com>
1157 2006-05-23 Ville Vainio <vivainio@gmail.com>
1146
1158
1147 * ipapi.py: Stripped down ip.to_user_ns() to work only as
1159 * ipapi.py: Stripped down ip.to_user_ns() to work only as
1148 ip.to_user_ns("x1 y1"), which exposes vars x1 and y1. ipapi.get()
1160 ip.to_user_ns("x1 y1"), which exposes vars x1 and y1. ipapi.get()
1149 now returns None (again), unless dummy is specifically allowed by
1161 now returns None (again), unless dummy is specifically allowed by
1150 ipapi.get(allow_dummy=True).
1162 ipapi.get(allow_dummy=True).
1151
1163
1152 2006-05-18 Fernando Perez <Fernando.Perez@colorado.edu>
1164 2006-05-18 Fernando Perez <Fernando.Perez@colorado.edu>
1153
1165
1154 * IPython: remove all 2.2-compatibility objects and hacks from
1166 * IPython: remove all 2.2-compatibility objects and hacks from
1155 everywhere, since we only support 2.3 at this point. Docs
1167 everywhere, since we only support 2.3 at this point. Docs
1156 updated.
1168 updated.
1157
1169
1158 * IPython/ipapi.py (IPApi.__init__): Cleanup of all getters.
1170 * IPython/ipapi.py (IPApi.__init__): Cleanup of all getters.
1159 Anything requiring extra validation can be turned into a Python
1171 Anything requiring extra validation can be turned into a Python
1160 property in the future. I used a property for the db one b/c
1172 property in the future. I used a property for the db one b/c
1161 there was a nasty circularity problem with the initialization
1173 there was a nasty circularity problem with the initialization
1162 order, which right now I don't have time to clean up.
1174 order, which right now I don't have time to clean up.
1163
1175
1164 * IPython/Shell.py (MTInteractiveShell.runcode): Fix, I think,
1176 * IPython/Shell.py (MTInteractiveShell.runcode): Fix, I think,
1165 another locking bug reported by Jorgen. I'm not 100% sure though,
1177 another locking bug reported by Jorgen. I'm not 100% sure though,
1166 so more testing is needed...
1178 so more testing is needed...
1167
1179
1168 2006-05-17 Fernando Perez <Fernando.Perez@colorado.edu>
1180 2006-05-17 Fernando Perez <Fernando.Perez@colorado.edu>
1169
1181
1170 * IPython/ipapi.py (IPApi.to_user_ns): New function to inject
1182 * IPython/ipapi.py (IPApi.to_user_ns): New function to inject
1171 local variables from any routine in user code (typically executed
1183 local variables from any routine in user code (typically executed
1172 with %run) directly into the interactive namespace. Very useful
1184 with %run) directly into the interactive namespace. Very useful
1173 when doing complex debugging.
1185 when doing complex debugging.
1174 (IPythonNotRunning): Changed the default None object to a dummy
1186 (IPythonNotRunning): Changed the default None object to a dummy
1175 whose attributes can be queried as well as called without
1187 whose attributes can be queried as well as called without
1176 exploding, to ease writing code which works transparently both in
1188 exploding, to ease writing code which works transparently both in
1177 and out of ipython and uses some of this API.
1189 and out of ipython and uses some of this API.
1178
1190
1179 2006-05-16 Fernando Perez <Fernando.Perez@colorado.edu>
1191 2006-05-16 Fernando Perez <Fernando.Perez@colorado.edu>
1180
1192
1181 * IPython/hooks.py (result_display): Fix the fact that our display
1193 * IPython/hooks.py (result_display): Fix the fact that our display
1182 hook was using str() instead of repr(), as the default python
1194 hook was using str() instead of repr(), as the default python
1183 console does. This had gone unnoticed b/c it only happened if
1195 console does. This had gone unnoticed b/c it only happened if
1184 %Pprint was off, but the inconsistency was there.
1196 %Pprint was off, but the inconsistency was there.
1185
1197
1186 2006-05-15 Ville Vainio <vivainio@gmail.com>
1198 2006-05-15 Ville Vainio <vivainio@gmail.com>
1187
1199
1188 * Oinspect.py: Only show docstring for nonexisting/binary files
1200 * Oinspect.py: Only show docstring for nonexisting/binary files
1189 when doing object??, closing ticket #62
1201 when doing object??, closing ticket #62
1190
1202
1191 2006-05-13 Fernando Perez <Fernando.Perez@colorado.edu>
1203 2006-05-13 Fernando Perez <Fernando.Perez@colorado.edu>
1192
1204
1193 * IPython/Shell.py (MTInteractiveShell.runsource): Fix threading
1205 * IPython/Shell.py (MTInteractiveShell.runsource): Fix threading
1194 bug, closes http://www.scipy.net/roundup/ipython/issue55. A lock
1206 bug, closes http://www.scipy.net/roundup/ipython/issue55. A lock
1195 was being released in a routine which hadn't checked if it had
1207 was being released in a routine which hadn't checked if it had
1196 been the one to acquire it.
1208 been the one to acquire it.
1197
1209
1198 2006-05-07 Fernando Perez <Fernando.Perez@colorado.edu>
1210 2006-05-07 Fernando Perez <Fernando.Perez@colorado.edu>
1199
1211
1200 * IPython/Release.py (version): put out 0.7.2.rc1 for testing.
1212 * IPython/Release.py (version): put out 0.7.2.rc1 for testing.
1201
1213
1202 2006-04-11 Ville Vainio <vivainio@gmail.com>
1214 2006-04-11 Ville Vainio <vivainio@gmail.com>
1203
1215
1204 * iplib.py, ipmaker.py: .ipy extension now means "ipython batch file"
1216 * iplib.py, ipmaker.py: .ipy extension now means "ipython batch file"
1205 in command line. E.g. "ipython test.ipy" runs test.ipy with ipython
1217 in command line. E.g. "ipython test.ipy" runs test.ipy with ipython
1206 prefilters, allowing stuff like magics and aliases in the file.
1218 prefilters, allowing stuff like magics and aliases in the file.
1207
1219
1208 * Prompts.py, Extensions/clearcmd.py, ipy_system_conf.py: %clear magic
1220 * Prompts.py, Extensions/clearcmd.py, ipy_system_conf.py: %clear magic
1209 added. Supported now are "%clear in" and "%clear out" (clear input and
1221 added. Supported now are "%clear in" and "%clear out" (clear input and
1210 output history, respectively). Also fixed CachedOutput.flush to
1222 output history, respectively). Also fixed CachedOutput.flush to
1211 properly flush the output cache.
1223 properly flush the output cache.
1212
1224
1213 * Extensions/pspersistence.py: Fix %store to avoid "%store obj.attr"
1225 * Extensions/pspersistence.py: Fix %store to avoid "%store obj.attr"
1214 half-success (and fail explicitly).
1226 half-success (and fail explicitly).
1215
1227
1216 2006-03-28 Ville Vainio <vivainio@gmail.com>
1228 2006-03-28 Ville Vainio <vivainio@gmail.com>
1217
1229
1218 * iplib.py: Fix quoting of aliases so that only argless ones
1230 * iplib.py: Fix quoting of aliases so that only argless ones
1219 are quoted
1231 are quoted
1220
1232
1221 2006-03-28 Ville Vainio <vivainio@gmail.com>
1233 2006-03-28 Ville Vainio <vivainio@gmail.com>
1222
1234
1223 * iplib.py: Quote aliases with spaces in the name.
1235 * iplib.py: Quote aliases with spaces in the name.
1224 "c:\program files\blah\bin" is now legal alias target.
1236 "c:\program files\blah\bin" is now legal alias target.
1225
1237
1226 * ext_rehashdir.py: Space no longer allowed as arg
1238 * ext_rehashdir.py: Space no longer allowed as arg
1227 separator, since space is legal in path names.
1239 separator, since space is legal in path names.
1228
1240
1229 2006-03-16 Ville Vainio <vivainio@gmail.com>
1241 2006-03-16 Ville Vainio <vivainio@gmail.com>
1230
1242
1231 * upgrade_dir.py: Take path.py from Extensions, correcting
1243 * upgrade_dir.py: Take path.py from Extensions, correcting
1232 %upgrade magic
1244 %upgrade magic
1233
1245
1234 * ipmaker.py: Suggest using %upgrade if ipy_user_conf.py isn't found.
1246 * ipmaker.py: Suggest using %upgrade if ipy_user_conf.py isn't found.
1235
1247
1236 * hooks.py: Only enclose editor binary in quotes if legal and
1248 * hooks.py: Only enclose editor binary in quotes if legal and
1237 necessary (space in the name, and is an existing file). Fixes a bug
1249 necessary (space in the name, and is an existing file). Fixes a bug
1238 reported by Zachary Pincus.
1250 reported by Zachary Pincus.
1239
1251
1240 2006-03-13 Fernando Perez <Fernando.Perez@colorado.edu>
1252 2006-03-13 Fernando Perez <Fernando.Perez@colorado.edu>
1241
1253
1242 * Manual: thanks to a tip on proper color handling for Emacs, by
1254 * Manual: thanks to a tip on proper color handling for Emacs, by
1243 Eric J Haywiser <ejh1-AT-MIT.EDU>.
1255 Eric J Haywiser <ejh1-AT-MIT.EDU>.
1244
1256
1245 * ipython.el: close http://www.scipy.net/roundup/ipython/issue57
1257 * ipython.el: close http://www.scipy.net/roundup/ipython/issue57
1246 by applying the provided patch. Thanks to Liu Jin
1258 by applying the provided patch. Thanks to Liu Jin
1247 <m.liu.jin-AT-gmail.com> for the contribution. No problems under
1259 <m.liu.jin-AT-gmail.com> for the contribution. No problems under
1248 XEmacs/Linux, I'm trusting the submitter that it actually helps
1260 XEmacs/Linux, I'm trusting the submitter that it actually helps
1249 under win32/GNU Emacs. Will revisit if any problems are reported.
1261 under win32/GNU Emacs. Will revisit if any problems are reported.
1250
1262
1251 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
1263 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
1252
1264
1253 * IPython/Gnuplot2.py (_FileClass): update for current Gnuplot.py
1265 * IPython/Gnuplot2.py (_FileClass): update for current Gnuplot.py
1254 from SVN, thanks to a patch by Ryan Woodard <rywo@bas.ac.uk>.
1266 from SVN, thanks to a patch by Ryan Woodard <rywo@bas.ac.uk>.
1255
1267
1256 2006-03-12 Ville Vainio <vivainio@gmail.com>
1268 2006-03-12 Ville Vainio <vivainio@gmail.com>
1257
1269
1258 * Magic.py (magic_timeit): Added %timeit magic, contributed by
1270 * Magic.py (magic_timeit): Added %timeit magic, contributed by
1259 Torsten Marek.
1271 Torsten Marek.
1260
1272
1261 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
1273 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
1262
1274
1263 * IPython/Magic.py (magic_macro): fix so that the n1-n2 syntax for
1275 * IPython/Magic.py (magic_macro): fix so that the n1-n2 syntax for
1264 line ranges works again.
1276 line ranges works again.
1265
1277
1266 2006-03-11 Fernando Perez <Fernando.Perez@colorado.edu>
1278 2006-03-11 Fernando Perez <Fernando.Perez@colorado.edu>
1267
1279
1268 * IPython/iplib.py (showtraceback): add back sys.last_traceback
1280 * IPython/iplib.py (showtraceback): add back sys.last_traceback
1269 and friends, after a discussion with Zach Pincus on ipython-user.
1281 and friends, after a discussion with Zach Pincus on ipython-user.
1270 I'm not 100% sure, but after thinking about it quite a bit, it may
1282 I'm not 100% sure, but after thinking about it quite a bit, it may
1271 be OK. Testing with the multithreaded shells didn't reveal any
1283 be OK. Testing with the multithreaded shells didn't reveal any
1272 problems, but let's keep an eye out.
1284 problems, but let's keep an eye out.
1273
1285
1274 In the process, I fixed a few things which were calling
1286 In the process, I fixed a few things which were calling
1275 self.InteractiveTB() directly (like safe_execfile), which is a
1287 self.InteractiveTB() directly (like safe_execfile), which is a
1276 mistake: ALL exception reporting should be done by calling
1288 mistake: ALL exception reporting should be done by calling
1277 self.showtraceback(), which handles state and tab-completion and
1289 self.showtraceback(), which handles state and tab-completion and
1278 more.
1290 more.
1279
1291
1280 2006-03-01 Ville Vainio <vivainio@gmail.com>
1292 2006-03-01 Ville Vainio <vivainio@gmail.com>
1281
1293
1282 * Extensions/ipipe.py: Added Walter Doerwald's "ipipe" module.
1294 * Extensions/ipipe.py: Added Walter Doerwald's "ipipe" module.
1283 To use, do "from ipipe import *".
1295 To use, do "from ipipe import *".
1284
1296
1285 2006-02-24 Ville Vainio <vivainio@gmail.com>
1297 2006-02-24 Ville Vainio <vivainio@gmail.com>
1286
1298
1287 * Magic.py, upgrade_dir.py: %upgrade magic added. Does things more
1299 * Magic.py, upgrade_dir.py: %upgrade magic added. Does things more
1288 "cleanly" and safely than the older upgrade mechanism.
1300 "cleanly" and safely than the older upgrade mechanism.
1289
1301
1290 2006-02-21 Ville Vainio <vivainio@gmail.com>
1302 2006-02-21 Ville Vainio <vivainio@gmail.com>
1291
1303
1292 * Magic.py: %save works again.
1304 * Magic.py: %save works again.
1293
1305
1294 2006-02-15 Ville Vainio <vivainio@gmail.com>
1306 2006-02-15 Ville Vainio <vivainio@gmail.com>
1295
1307
1296 * Magic.py: %Pprint works again
1308 * Magic.py: %Pprint works again
1297
1309
1298 * Extensions/ipy_sane_defaults.py: Provide everything provided
1310 * Extensions/ipy_sane_defaults.py: Provide everything provided
1299 in default ipythonrc, to make it possible to have a completely empty
1311 in default ipythonrc, to make it possible to have a completely empty
1300 ipythonrc (and thus completely rc-file free configuration)
1312 ipythonrc (and thus completely rc-file free configuration)
1301
1313
1302 2006-02-11 Fernando Perez <Fernando.Perez@colorado.edu>
1314 2006-02-11 Fernando Perez <Fernando.Perez@colorado.edu>
1303
1315
1304 * IPython/hooks.py (editor): quote the call to the editor command,
1316 * IPython/hooks.py (editor): quote the call to the editor command,
1305 to allow commands with spaces in them. Problem noted by watching
1317 to allow commands with spaces in them. Problem noted by watching
1306 Ian Oswald's video about textpad under win32 at
1318 Ian Oswald's video about textpad under win32 at
1307 http://showmedo.com/videoListPage?listKey=PythonIPythonSeries
1319 http://showmedo.com/videoListPage?listKey=PythonIPythonSeries
1308
1320
1309 * IPython/UserConfig/ipythonrc: Replace @ signs with % when
1321 * IPython/UserConfig/ipythonrc: Replace @ signs with % when
1310 describing magics (we haven't used @ for a loong time).
1322 describing magics (we haven't used @ for a loong time).
1311
1323
1312 * IPython/ultraTB.py (VerboseTB.text.text_repr): Added patch
1324 * IPython/ultraTB.py (VerboseTB.text.text_repr): Added patch
1313 contributed by marienz to close
1325 contributed by marienz to close
1314 http://www.scipy.net/roundup/ipython/issue53.
1326 http://www.scipy.net/roundup/ipython/issue53.
1315
1327
1316 2006-02-10 Ville Vainio <vivainio@gmail.com>
1328 2006-02-10 Ville Vainio <vivainio@gmail.com>
1317
1329
1318 * genutils.py: getoutput now works in win32 too
1330 * genutils.py: getoutput now works in win32 too
1319
1331
1320 * completer.py: alias and magic completion only invoked
1332 * completer.py: alias and magic completion only invoked
1321 at the first "item" in the line, to avoid "cd %store"
1333 at the first "item" in the line, to avoid "cd %store"
1322 nonsense.
1334 nonsense.
1323
1335
1324 2006-02-09 Ville Vainio <vivainio@gmail.com>
1336 2006-02-09 Ville Vainio <vivainio@gmail.com>
1325
1337
1326 * test/*: Added a unit testing framework (finally).
1338 * test/*: Added a unit testing framework (finally).
1327 '%run runtests.py' to run test_*.
1339 '%run runtests.py' to run test_*.
1328
1340
1329 * ipapi.py: Exposed runlines and set_custom_exc
1341 * ipapi.py: Exposed runlines and set_custom_exc
1330
1342
1331 2006-02-07 Ville Vainio <vivainio@gmail.com>
1343 2006-02-07 Ville Vainio <vivainio@gmail.com>
1332
1344
1333 * iplib.py: don't split "f 1 2" to "f(1,2)" in autocall,
1345 * iplib.py: don't split "f 1 2" to "f(1,2)" in autocall,
1334 instead use "f(1 2)" as before.
1346 instead use "f(1 2)" as before.
1335
1347
1336 2006-02-05 Fernando Perez <Fernando.Perez@colorado.edu>
1348 2006-02-05 Fernando Perez <Fernando.Perez@colorado.edu>
1337
1349
1338 * IPython/demo.py (IPythonDemo): Add new classes to the demo
1350 * IPython/demo.py (IPythonDemo): Add new classes to the demo
1339 facilities, for demos processed by the IPython input filter
1351 facilities, for demos processed by the IPython input filter
1340 (IPythonDemo), and for running a script one-line-at-a-time as a
1352 (IPythonDemo), and for running a script one-line-at-a-time as a
1341 demo, both for pure Python (LineDemo) and for IPython-processed
1353 demo, both for pure Python (LineDemo) and for IPython-processed
1342 input (IPythonLineDemo). After a request by Dave Kohel, from the
1354 input (IPythonLineDemo). After a request by Dave Kohel, from the
1343 SAGE team.
1355 SAGE team.
1344 (Demo.edit): added an edit() method to the demo objects, to edit
1356 (Demo.edit): added an edit() method to the demo objects, to edit
1345 the in-memory copy of the last executed block.
1357 the in-memory copy of the last executed block.
1346
1358
1347 * IPython/Magic.py (magic_edit): add '-r' option for 'raw'
1359 * IPython/Magic.py (magic_edit): add '-r' option for 'raw'
1348 processing to %edit, %macro and %save. These commands can now be
1360 processing to %edit, %macro and %save. These commands can now be
1349 invoked on the unprocessed input as it was typed by the user
1361 invoked on the unprocessed input as it was typed by the user
1350 (without any prefilters applied). After requests by the SAGE team
1362 (without any prefilters applied). After requests by the SAGE team
1351 at SAGE days 2006: http://modular.ucsd.edu/sage/days1/schedule.html.
1363 at SAGE days 2006: http://modular.ucsd.edu/sage/days1/schedule.html.
1352
1364
1353 2006-02-01 Ville Vainio <vivainio@gmail.com>
1365 2006-02-01 Ville Vainio <vivainio@gmail.com>
1354
1366
1355 * setup.py, eggsetup.py: easy_install ipython==dev works
1367 * setup.py, eggsetup.py: easy_install ipython==dev works
1356 correctly now (on Linux)
1368 correctly now (on Linux)
1357
1369
1358 * ipy_user_conf,ipmaker: user config changes, removed spurious
1370 * ipy_user_conf,ipmaker: user config changes, removed spurious
1359 warnings
1371 warnings
1360
1372
1361 * iplib: if rc.banner is string, use it as is.
1373 * iplib: if rc.banner is string, use it as is.
1362
1374
1363 * Magic: %pycat accepts a string argument and pages it's contents.
1375 * Magic: %pycat accepts a string argument and pages it's contents.
1364
1376
1365
1377
1366 2006-01-30 Ville Vainio <vivainio@gmail.com>
1378 2006-01-30 Ville Vainio <vivainio@gmail.com>
1367
1379
1368 * pickleshare,pspersistence,ipapi,Magic: persistence overhaul.
1380 * pickleshare,pspersistence,ipapi,Magic: persistence overhaul.
1369 Now %store and bookmarks work through PickleShare, meaning that
1381 Now %store and bookmarks work through PickleShare, meaning that
1370 concurrent access is possible and all ipython sessions see the
1382 concurrent access is possible and all ipython sessions see the
1371 same database situation all the time, instead of snapshot of
1383 same database situation all the time, instead of snapshot of
1372 the situation when the session was started. Hence, %bookmark
1384 the situation when the session was started. Hence, %bookmark
1373 results are immediately accessible from othes sessions. The database
1385 results are immediately accessible from othes sessions. The database
1374 is also available for use by user extensions. See:
1386 is also available for use by user extensions. See:
1375 http://www.python.org/pypi/pickleshare
1387 http://www.python.org/pypi/pickleshare
1376
1388
1377 * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'.
1389 * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'.
1378
1390
1379 * aliases can now be %store'd
1391 * aliases can now be %store'd
1380
1392
1381 * path.py moved to Extensions so that pickleshare does not need
1393 * path.py moved to Extensions so that pickleshare does not need
1382 IPython-specific import. Extensions added to pythonpath right
1394 IPython-specific import. Extensions added to pythonpath right
1383 at __init__.
1395 at __init__.
1384
1396
1385 * iplib.py: ipalias deprecated/redundant; aliases are converted and
1397 * iplib.py: ipalias deprecated/redundant; aliases are converted and
1386 called with _ip.system and the pre-transformed command string.
1398 called with _ip.system and the pre-transformed command string.
1387
1399
1388 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu>
1400 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu>
1389
1401
1390 * IPython/iplib.py (interact): Fix that we were not catching
1402 * IPython/iplib.py (interact): Fix that we were not catching
1391 KeyboardInterrupt exceptions properly. I'm not quite sure why the
1403 KeyboardInterrupt exceptions properly. I'm not quite sure why the
1392 logic here had to change, but it's fixed now.
1404 logic here had to change, but it's fixed now.
1393
1405
1394 2006-01-29 Ville Vainio <vivainio@gmail.com>
1406 2006-01-29 Ville Vainio <vivainio@gmail.com>
1395
1407
1396 * iplib.py: Try to import pyreadline on Windows.
1408 * iplib.py: Try to import pyreadline on Windows.
1397
1409
1398 2006-01-27 Ville Vainio <vivainio@gmail.com>
1410 2006-01-27 Ville Vainio <vivainio@gmail.com>
1399
1411
1400 * iplib.py: Expose ipapi as _ip in builtin namespace.
1412 * iplib.py: Expose ipapi as _ip in builtin namespace.
1401 Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system)
1413 Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system)
1402 and ip_set_hook (-> _ip.set_hook) redundant. % and !
1414 and ip_set_hook (-> _ip.set_hook) redundant. % and !
1403 syntax now produce _ip.* variant of the commands.
1415 syntax now produce _ip.* variant of the commands.
1404
1416
1405 * "_ip.options().autoedit_syntax = 2" automatically throws
1417 * "_ip.options().autoedit_syntax = 2" automatically throws
1406 user to editor for syntax error correction without prompting.
1418 user to editor for syntax error correction without prompting.
1407
1419
1408 2006-01-27 Ville Vainio <vivainio@gmail.com>
1420 2006-01-27 Ville Vainio <vivainio@gmail.com>
1409
1421
1410 * ipmaker.py: Give "realistic" sys.argv for scripts (without
1422 * ipmaker.py: Give "realistic" sys.argv for scripts (without
1411 'ipython' at argv[0]) executed through command line.
1423 'ipython' at argv[0]) executed through command line.
1412 NOTE: this DEPRECATES calling ipython with multiple scripts
1424 NOTE: this DEPRECATES calling ipython with multiple scripts
1413 ("ipython a.py b.py c.py")
1425 ("ipython a.py b.py c.py")
1414
1426
1415 * iplib.py, hooks.py: Added configurable input prefilter,
1427 * iplib.py, hooks.py: Added configurable input prefilter,
1416 named 'input_prefilter'. See ext_rescapture.py for example
1428 named 'input_prefilter'. See ext_rescapture.py for example
1417 usage.
1429 usage.
1418
1430
1419 * ext_rescapture.py, Magic.py: Better system command output capture
1431 * ext_rescapture.py, Magic.py: Better system command output capture
1420 through 'var = !ls' (deprecates user-visible %sc). Same notation
1432 through 'var = !ls' (deprecates user-visible %sc). Same notation
1421 applies for magics, 'var = %alias' assigns alias list to var.
1433 applies for magics, 'var = %alias' assigns alias list to var.
1422
1434
1423 * ipapi.py: added meta() for accessing extension-usable data store.
1435 * ipapi.py: added meta() for accessing extension-usable data store.
1424
1436
1425 * iplib.py: added InteractiveShell.getapi(). New magics should be
1437 * iplib.py: added InteractiveShell.getapi(). New magics should be
1426 written doing self.getapi() instead of using the shell directly.
1438 written doing self.getapi() instead of using the shell directly.
1427
1439
1428 * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and
1440 * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and
1429 %store foo >> ~/myfoo.txt to store variables to files (in clean
1441 %store foo >> ~/myfoo.txt to store variables to files (in clean
1430 textual form, not a restorable pickle).
1442 textual form, not a restorable pickle).
1431
1443
1432 * ipmaker.py: now import ipy_profile_PROFILENAME automatically
1444 * ipmaker.py: now import ipy_profile_PROFILENAME automatically
1433
1445
1434 * usage.py, Magic.py: added %quickref
1446 * usage.py, Magic.py: added %quickref
1435
1447
1436 * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2).
1448 * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2).
1437
1449
1438 * GetoptErrors when invoking magics etc. with wrong args
1450 * GetoptErrors when invoking magics etc. with wrong args
1439 are now more helpful:
1451 are now more helpful:
1440 GetoptError: option -l not recognized (allowed: "qb" )
1452 GetoptError: option -l not recognized (allowed: "qb" )
1441
1453
1442 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu>
1454 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu>
1443
1455
1444 * IPython/demo.py (Demo.show): Flush stdout after each block, so
1456 * IPython/demo.py (Demo.show): Flush stdout after each block, so
1445 computationally intensive blocks don't appear to stall the demo.
1457 computationally intensive blocks don't appear to stall the demo.
1446
1458
1447 2006-01-24 Ville Vainio <vivainio@gmail.com>
1459 2006-01-24 Ville Vainio <vivainio@gmail.com>
1448
1460
1449 * iplib.py, hooks.py: 'result_display' hook can return a non-None
1461 * iplib.py, hooks.py: 'result_display' hook can return a non-None
1450 value to manipulate resulting history entry.
1462 value to manipulate resulting history entry.
1451
1463
1452 * ipapi.py: Moved TryNext here from hooks.py. Moved functions
1464 * ipapi.py: Moved TryNext here from hooks.py. Moved functions
1453 to instance methods of IPApi class, to make extending an embedded
1465 to instance methods of IPApi class, to make extending an embedded
1454 IPython feasible. See ext_rehashdir.py for example usage.
1466 IPython feasible. See ext_rehashdir.py for example usage.
1455
1467
1456 * Merged 1071-1076 from branches/0.7.1
1468 * Merged 1071-1076 from branches/0.7.1
1457
1469
1458
1470
1459 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu>
1471 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu>
1460
1472
1461 * tools/release (daystamp): Fix build tools to use the new
1473 * tools/release (daystamp): Fix build tools to use the new
1462 eggsetup.py script to build lightweight eggs.
1474 eggsetup.py script to build lightweight eggs.
1463
1475
1464 * Applied changesets 1062 and 1064 before 0.7.1 release.
1476 * Applied changesets 1062 and 1064 before 0.7.1 release.
1465
1477
1466 * IPython/Magic.py (magic_history): Add '-r' option to %hist, to
1478 * IPython/Magic.py (magic_history): Add '-r' option to %hist, to
1467 see the raw input history (without conversions like %ls ->
1479 see the raw input history (without conversions like %ls ->
1468 ipmagic("ls")). After a request from W. Stein, SAGE
1480 ipmagic("ls")). After a request from W. Stein, SAGE
1469 (http://modular.ucsd.edu/sage) developer. This information is
1481 (http://modular.ucsd.edu/sage) developer. This information is
1470 stored in the input_hist_raw attribute of the IPython instance, so
1482 stored in the input_hist_raw attribute of the IPython instance, so
1471 developers can access it if needed (it's an InputList instance).
1483 developers can access it if needed (it's an InputList instance).
1472
1484
1473 * Versionstring = 0.7.2.svn
1485 * Versionstring = 0.7.2.svn
1474
1486
1475 * eggsetup.py: A separate script for constructing eggs, creates
1487 * eggsetup.py: A separate script for constructing eggs, creates
1476 proper launch scripts even on Windows (an .exe file in
1488 proper launch scripts even on Windows (an .exe file in
1477 \python24\scripts).
1489 \python24\scripts).
1478
1490
1479 * ipapi.py: launch_new_instance, launch entry point needed for the
1491 * ipapi.py: launch_new_instance, launch entry point needed for the
1480 egg.
1492 egg.
1481
1493
1482 2006-01-23 Ville Vainio <vivainio@gmail.com>
1494 2006-01-23 Ville Vainio <vivainio@gmail.com>
1483
1495
1484 * Added %cpaste magic for pasting python code
1496 * Added %cpaste magic for pasting python code
1485
1497
1486 2006-01-22 Ville Vainio <vivainio@gmail.com>
1498 2006-01-22 Ville Vainio <vivainio@gmail.com>
1487
1499
1488 * Merge from branches/0.7.1 into trunk, revs 1052-1057
1500 * Merge from branches/0.7.1 into trunk, revs 1052-1057
1489
1501
1490 * Versionstring = 0.7.2.svn
1502 * Versionstring = 0.7.2.svn
1491
1503
1492 * eggsetup.py: A separate script for constructing eggs, creates
1504 * eggsetup.py: A separate script for constructing eggs, creates
1493 proper launch scripts even on Windows (an .exe file in
1505 proper launch scripts even on Windows (an .exe file in
1494 \python24\scripts).
1506 \python24\scripts).
1495
1507
1496 * ipapi.py: launch_new_instance, launch entry point needed for the
1508 * ipapi.py: launch_new_instance, launch entry point needed for the
1497 egg.
1509 egg.
1498
1510
1499 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
1511 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
1500
1512
1501 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
1513 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
1502 %pfile foo would print the file for foo even if it was a binary.
1514 %pfile foo would print the file for foo even if it was a binary.
1503 Now, extensions '.so' and '.dll' are skipped.
1515 Now, extensions '.so' and '.dll' are skipped.
1504
1516
1505 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
1517 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
1506 bug, where macros would fail in all threaded modes. I'm not 100%
1518 bug, where macros would fail in all threaded modes. I'm not 100%
1507 sure, so I'm going to put out an rc instead of making a release
1519 sure, so I'm going to put out an rc instead of making a release
1508 today, and wait for feedback for at least a few days.
1520 today, and wait for feedback for at least a few days.
1509
1521
1510 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
1522 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
1511 it...) the handling of pasting external code with autoindent on.
1523 it...) the handling of pasting external code with autoindent on.
1512 To get out of a multiline input, the rule will appear for most
1524 To get out of a multiline input, the rule will appear for most
1513 users unchanged: two blank lines or change the indent level
1525 users unchanged: two blank lines or change the indent level
1514 proposed by IPython. But there is a twist now: you can
1526 proposed by IPython. But there is a twist now: you can
1515 add/subtract only *one or two spaces*. If you add/subtract three
1527 add/subtract only *one or two spaces*. If you add/subtract three
1516 or more (unless you completely delete the line), IPython will
1528 or more (unless you completely delete the line), IPython will
1517 accept that line, and you'll need to enter a second one of pure
1529 accept that line, and you'll need to enter a second one of pure
1518 whitespace. I know it sounds complicated, but I can't find a
1530 whitespace. I know it sounds complicated, but I can't find a
1519 different solution that covers all the cases, with the right
1531 different solution that covers all the cases, with the right
1520 heuristics. Hopefully in actual use, nobody will really notice
1532 heuristics. Hopefully in actual use, nobody will really notice
1521 all these strange rules and things will 'just work'.
1533 all these strange rules and things will 'just work'.
1522
1534
1523 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
1535 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
1524
1536
1525 * IPython/iplib.py (interact): catch exceptions which can be
1537 * IPython/iplib.py (interact): catch exceptions which can be
1526 triggered asynchronously by signal handlers. Thanks to an
1538 triggered asynchronously by signal handlers. Thanks to an
1527 automatic crash report, submitted by Colin Kingsley
1539 automatic crash report, submitted by Colin Kingsley
1528 <tercel-AT-gentoo.org>.
1540 <tercel-AT-gentoo.org>.
1529
1541
1530 2006-01-20 Ville Vainio <vivainio@gmail.com>
1542 2006-01-20 Ville Vainio <vivainio@gmail.com>
1531
1543
1532 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
1544 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
1533 (%rehashdir, very useful, try it out) of how to extend ipython
1545 (%rehashdir, very useful, try it out) of how to extend ipython
1534 with new magics. Also added Extensions dir to pythonpath to make
1546 with new magics. Also added Extensions dir to pythonpath to make
1535 importing extensions easy.
1547 importing extensions easy.
1536
1548
1537 * %store now complains when trying to store interactively declared
1549 * %store now complains when trying to store interactively declared
1538 classes / instances of those classes.
1550 classes / instances of those classes.
1539
1551
1540 * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py,
1552 * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py,
1541 ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported
1553 ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported
1542 if they exist, and ipy_user_conf.py with some defaults is created for
1554 if they exist, and ipy_user_conf.py with some defaults is created for
1543 the user.
1555 the user.
1544
1556
1545 * Startup rehashing done by the config file, not InterpreterExec.
1557 * Startup rehashing done by the config file, not InterpreterExec.
1546 This means system commands are available even without selecting the
1558 This means system commands are available even without selecting the
1547 pysh profile. It's the sensible default after all.
1559 pysh profile. It's the sensible default after all.
1548
1560
1549 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
1561 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
1550
1562
1551 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
1563 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
1552 multiline code with autoindent on working. But I am really not
1564 multiline code with autoindent on working. But I am really not
1553 sure, so this needs more testing. Will commit a debug-enabled
1565 sure, so this needs more testing. Will commit a debug-enabled
1554 version for now, while I test it some more, so that Ville and
1566 version for now, while I test it some more, so that Ville and
1555 others may also catch any problems. Also made
1567 others may also catch any problems. Also made
1556 self.indent_current_str() a method, to ensure that there's no
1568 self.indent_current_str() a method, to ensure that there's no
1557 chance of the indent space count and the corresponding string
1569 chance of the indent space count and the corresponding string
1558 falling out of sync. All code needing the string should just call
1570 falling out of sync. All code needing the string should just call
1559 the method.
1571 the method.
1560
1572
1561 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
1573 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
1562
1574
1563 * IPython/Magic.py (magic_edit): fix check for when users don't
1575 * IPython/Magic.py (magic_edit): fix check for when users don't
1564 save their output files, the try/except was in the wrong section.
1576 save their output files, the try/except was in the wrong section.
1565
1577
1566 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
1578 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
1567
1579
1568 * IPython/Magic.py (magic_run): fix __file__ global missing from
1580 * IPython/Magic.py (magic_run): fix __file__ global missing from
1569 script's namespace when executed via %run. After a report by
1581 script's namespace when executed via %run. After a report by
1570 Vivian.
1582 Vivian.
1571
1583
1572 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
1584 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
1573 when using python 2.4. The parent constructor changed in 2.4, and
1585 when using python 2.4. The parent constructor changed in 2.4, and
1574 we need to track it directly (we can't call it, as it messes up
1586 we need to track it directly (we can't call it, as it messes up
1575 readline and tab-completion inside our pdb would stop working).
1587 readline and tab-completion inside our pdb would stop working).
1576 After a bug report by R. Bernstein <rocky-AT-panix.com>.
1588 After a bug report by R. Bernstein <rocky-AT-panix.com>.
1577
1589
1578 2006-01-16 Ville Vainio <vivainio@gmail.com>
1590 2006-01-16 Ville Vainio <vivainio@gmail.com>
1579
1591
1580 * Ipython/magic.py: Reverted back to old %edit functionality
1592 * Ipython/magic.py: Reverted back to old %edit functionality
1581 that returns file contents on exit.
1593 that returns file contents on exit.
1582
1594
1583 * IPython/path.py: Added Jason Orendorff's "path" module to
1595 * IPython/path.py: Added Jason Orendorff's "path" module to
1584 IPython tree, http://www.jorendorff.com/articles/python/path/.
1596 IPython tree, http://www.jorendorff.com/articles/python/path/.
1585 You can get path objects conveniently through %sc, and !!, e.g.:
1597 You can get path objects conveniently through %sc, and !!, e.g.:
1586 sc files=ls
1598 sc files=ls
1587 for p in files.paths: # or files.p
1599 for p in files.paths: # or files.p
1588 print p,p.mtime
1600 print p,p.mtime
1589
1601
1590 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
1602 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
1591 now work again without considering the exclusion regexp -
1603 now work again without considering the exclusion regexp -
1592 hence, things like ',foo my/path' turn to 'foo("my/path")'
1604 hence, things like ',foo my/path' turn to 'foo("my/path")'
1593 instead of syntax error.
1605 instead of syntax error.
1594
1606
1595
1607
1596 2006-01-14 Ville Vainio <vivainio@gmail.com>
1608 2006-01-14 Ville Vainio <vivainio@gmail.com>
1597
1609
1598 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
1610 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
1599 ipapi decorators for python 2.4 users, options() provides access to rc
1611 ipapi decorators for python 2.4 users, options() provides access to rc
1600 data.
1612 data.
1601
1613
1602 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
1614 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
1603 as path separators (even on Linux ;-). Space character after
1615 as path separators (even on Linux ;-). Space character after
1604 backslash (as yielded by tab completer) is still space;
1616 backslash (as yielded by tab completer) is still space;
1605 "%cd long\ name" works as expected.
1617 "%cd long\ name" works as expected.
1606
1618
1607 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
1619 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
1608 as "chain of command", with priority. API stays the same,
1620 as "chain of command", with priority. API stays the same,
1609 TryNext exception raised by a hook function signals that
1621 TryNext exception raised by a hook function signals that
1610 current hook failed and next hook should try handling it, as
1622 current hook failed and next hook should try handling it, as
1611 suggested by Walter DΓΆrwald <walter@livinglogic.de>. Walter also
1623 suggested by Walter DΓΆrwald <walter@livinglogic.de>. Walter also
1612 requested configurable display hook, which is now implemented.
1624 requested configurable display hook, which is now implemented.
1613
1625
1614 2006-01-13 Ville Vainio <vivainio@gmail.com>
1626 2006-01-13 Ville Vainio <vivainio@gmail.com>
1615
1627
1616 * IPython/platutils*.py: platform specific utility functions,
1628 * IPython/platutils*.py: platform specific utility functions,
1617 so far only set_term_title is implemented (change terminal
1629 so far only set_term_title is implemented (change terminal
1618 label in windowing systems). %cd now changes the title to
1630 label in windowing systems). %cd now changes the title to
1619 current dir.
1631 current dir.
1620
1632
1621 * IPython/Release.py: Added myself to "authors" list,
1633 * IPython/Release.py: Added myself to "authors" list,
1622 had to create new files.
1634 had to create new files.
1623
1635
1624 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
1636 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
1625 shell escape; not a known bug but had potential to be one in the
1637 shell escape; not a known bug but had potential to be one in the
1626 future.
1638 future.
1627
1639
1628 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
1640 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
1629 extension API for IPython! See the module for usage example. Fix
1641 extension API for IPython! See the module for usage example. Fix
1630 OInspect for docstring-less magic functions.
1642 OInspect for docstring-less magic functions.
1631
1643
1632
1644
1633 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
1645 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
1634
1646
1635 * IPython/iplib.py (raw_input): temporarily deactivate all
1647 * IPython/iplib.py (raw_input): temporarily deactivate all
1636 attempts at allowing pasting of code with autoindent on. It
1648 attempts at allowing pasting of code with autoindent on. It
1637 introduced bugs (reported by Prabhu) and I can't seem to find a
1649 introduced bugs (reported by Prabhu) and I can't seem to find a
1638 robust combination which works in all cases. Will have to revisit
1650 robust combination which works in all cases. Will have to revisit
1639 later.
1651 later.
1640
1652
1641 * IPython/genutils.py: remove isspace() function. We've dropped
1653 * IPython/genutils.py: remove isspace() function. We've dropped
1642 2.2 compatibility, so it's OK to use the string method.
1654 2.2 compatibility, so it's OK to use the string method.
1643
1655
1644 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
1656 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
1645
1657
1646 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
1658 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
1647 matching what NOT to autocall on, to include all python binary
1659 matching what NOT to autocall on, to include all python binary
1648 operators (including things like 'and', 'or', 'is' and 'in').
1660 operators (including things like 'and', 'or', 'is' and 'in').
1649 Prompted by a bug report on 'foo & bar', but I realized we had
1661 Prompted by a bug report on 'foo & bar', but I realized we had
1650 many more potential bug cases with other operators. The regexp is
1662 many more potential bug cases with other operators. The regexp is
1651 self.re_exclude_auto, it's fairly commented.
1663 self.re_exclude_auto, it's fairly commented.
1652
1664
1653 2006-01-12 Ville Vainio <vivainio@gmail.com>
1665 2006-01-12 Ville Vainio <vivainio@gmail.com>
1654
1666
1655 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
1667 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
1656 Prettified and hardened string/backslash quoting with ipsystem(),
1668 Prettified and hardened string/backslash quoting with ipsystem(),
1657 ipalias() and ipmagic(). Now even \ characters are passed to
1669 ipalias() and ipmagic(). Now even \ characters are passed to
1658 %magics, !shell escapes and aliases exactly as they are in the
1670 %magics, !shell escapes and aliases exactly as they are in the
1659 ipython command line. Should improve backslash experience,
1671 ipython command line. Should improve backslash experience,
1660 particularly in Windows (path delimiter for some commands that
1672 particularly in Windows (path delimiter for some commands that
1661 won't understand '/'), but Unix benefits as well (regexps). %cd
1673 won't understand '/'), but Unix benefits as well (regexps). %cd
1662 magic still doesn't support backslash path delimiters, though. Also
1674 magic still doesn't support backslash path delimiters, though. Also
1663 deleted all pretense of supporting multiline command strings in
1675 deleted all pretense of supporting multiline command strings in
1664 !system or %magic commands. Thanks to Jerry McRae for suggestions.
1676 !system or %magic commands. Thanks to Jerry McRae for suggestions.
1665
1677
1666 * doc/build_doc_instructions.txt added. Documentation on how to
1678 * doc/build_doc_instructions.txt added. Documentation on how to
1667 use doc/update_manual.py, added yesterday. Both files contributed
1679 use doc/update_manual.py, added yesterday. Both files contributed
1668 by JΓΆrgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
1680 by JΓΆrgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
1669 doc/*.sh for deprecation at a later date.
1681 doc/*.sh for deprecation at a later date.
1670
1682
1671 * /ipython.py Added ipython.py to root directory for
1683 * /ipython.py Added ipython.py to root directory for
1672 zero-installation (tar xzvf ipython.tgz; cd ipython; python
1684 zero-installation (tar xzvf ipython.tgz; cd ipython; python
1673 ipython.py) and development convenience (no need to keep doing
1685 ipython.py) and development convenience (no need to keep doing
1674 "setup.py install" between changes).
1686 "setup.py install" between changes).
1675
1687
1676 * Made ! and !! shell escapes work (again) in multiline expressions:
1688 * Made ! and !! shell escapes work (again) in multiline expressions:
1677 if 1:
1689 if 1:
1678 !ls
1690 !ls
1679 !!ls
1691 !!ls
1680
1692
1681 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
1693 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
1682
1694
1683 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
1695 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
1684 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
1696 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
1685 module in case-insensitive installation. Was causing crashes
1697 module in case-insensitive installation. Was causing crashes
1686 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
1698 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
1687
1699
1688 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
1700 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
1689 <marienz-AT-gentoo.org>, closes
1701 <marienz-AT-gentoo.org>, closes
1690 http://www.scipy.net/roundup/ipython/issue51.
1702 http://www.scipy.net/roundup/ipython/issue51.
1691
1703
1692 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
1704 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
1693
1705
1694 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the
1706 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the
1695 problem of excessive CPU usage under *nix and keyboard lag under
1707 problem of excessive CPU usage under *nix and keyboard lag under
1696 win32.
1708 win32.
1697
1709
1698 2006-01-10 *** Released version 0.7.0
1710 2006-01-10 *** Released version 0.7.0
1699
1711
1700 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
1712 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
1701
1713
1702 * IPython/Release.py (revision): tag version number to 0.7.0,
1714 * IPython/Release.py (revision): tag version number to 0.7.0,
1703 ready for release.
1715 ready for release.
1704
1716
1705 * IPython/Magic.py (magic_edit): Add print statement to %edit so
1717 * IPython/Magic.py (magic_edit): Add print statement to %edit so
1706 it informs the user of the name of the temp. file used. This can
1718 it informs the user of the name of the temp. file used. This can
1707 help if you decide later to reuse that same file, so you know
1719 help if you decide later to reuse that same file, so you know
1708 where to copy the info from.
1720 where to copy the info from.
1709
1721
1710 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
1722 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
1711
1723
1712 * setup_bdist_egg.py: little script to build an egg. Added
1724 * setup_bdist_egg.py: little script to build an egg. Added
1713 support in the release tools as well.
1725 support in the release tools as well.
1714
1726
1715 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
1727 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
1716
1728
1717 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
1729 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
1718 version selection (new -wxversion command line and ipythonrc
1730 version selection (new -wxversion command line and ipythonrc
1719 parameter). Patch contributed by Arnd Baecker
1731 parameter). Patch contributed by Arnd Baecker
1720 <arnd.baecker-AT-web.de>.
1732 <arnd.baecker-AT-web.de>.
1721
1733
1722 * IPython/iplib.py (embed_mainloop): fix tab-completion in
1734 * IPython/iplib.py (embed_mainloop): fix tab-completion in
1723 embedded instances, for variables defined at the interactive
1735 embedded instances, for variables defined at the interactive
1724 prompt of the embedded ipython. Reported by Arnd.
1736 prompt of the embedded ipython. Reported by Arnd.
1725
1737
1726 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
1738 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
1727 it can be used as a (stateful) toggle, or with a direct parameter.
1739 it can be used as a (stateful) toggle, or with a direct parameter.
1728
1740
1729 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
1741 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
1730 could be triggered in certain cases and cause the traceback
1742 could be triggered in certain cases and cause the traceback
1731 printer not to work.
1743 printer not to work.
1732
1744
1733 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
1745 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
1734
1746
1735 * IPython/iplib.py (_should_recompile): Small fix, closes
1747 * IPython/iplib.py (_should_recompile): Small fix, closes
1736 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
1748 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
1737
1749
1738 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
1750 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
1739
1751
1740 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
1752 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
1741 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
1753 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
1742 Moad for help with tracking it down.
1754 Moad for help with tracking it down.
1743
1755
1744 * IPython/iplib.py (handle_auto): fix autocall handling for
1756 * IPython/iplib.py (handle_auto): fix autocall handling for
1745 objects which support BOTH __getitem__ and __call__ (so that f [x]
1757 objects which support BOTH __getitem__ and __call__ (so that f [x]
1746 is left alone, instead of becoming f([x]) automatically).
1758 is left alone, instead of becoming f([x]) automatically).
1747
1759
1748 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
1760 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
1749 Ville's patch.
1761 Ville's patch.
1750
1762
1751 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
1763 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
1752
1764
1753 * IPython/iplib.py (handle_auto): changed autocall semantics to
1765 * IPython/iplib.py (handle_auto): changed autocall semantics to
1754 include 'smart' mode, where the autocall transformation is NOT
1766 include 'smart' mode, where the autocall transformation is NOT
1755 applied if there are no arguments on the line. This allows you to
1767 applied if there are no arguments on the line. This allows you to
1756 just type 'foo' if foo is a callable to see its internal form,
1768 just type 'foo' if foo is a callable to see its internal form,
1757 instead of having it called with no arguments (typically a
1769 instead of having it called with no arguments (typically a
1758 mistake). The old 'full' autocall still exists: for that, you
1770 mistake). The old 'full' autocall still exists: for that, you
1759 need to set the 'autocall' parameter to 2 in your ipythonrc file.
1771 need to set the 'autocall' parameter to 2 in your ipythonrc file.
1760
1772
1761 * IPython/completer.py (Completer.attr_matches): add
1773 * IPython/completer.py (Completer.attr_matches): add
1762 tab-completion support for Enthoughts' traits. After a report by
1774 tab-completion support for Enthoughts' traits. After a report by
1763 Arnd and a patch by Prabhu.
1775 Arnd and a patch by Prabhu.
1764
1776
1765 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
1777 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
1766
1778
1767 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
1779 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
1768 Schmolck's patch to fix inspect.getinnerframes().
1780 Schmolck's patch to fix inspect.getinnerframes().
1769
1781
1770 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
1782 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
1771 for embedded instances, regarding handling of namespaces and items
1783 for embedded instances, regarding handling of namespaces and items
1772 added to the __builtin__ one. Multiple embedded instances and
1784 added to the __builtin__ one. Multiple embedded instances and
1773 recursive embeddings should work better now (though I'm not sure
1785 recursive embeddings should work better now (though I'm not sure
1774 I've got all the corner cases fixed, that code is a bit of a brain
1786 I've got all the corner cases fixed, that code is a bit of a brain
1775 twister).
1787 twister).
1776
1788
1777 * IPython/Magic.py (magic_edit): added support to edit in-memory
1789 * IPython/Magic.py (magic_edit): added support to edit in-memory
1778 macros (automatically creates the necessary temp files). %edit
1790 macros (automatically creates the necessary temp files). %edit
1779 also doesn't return the file contents anymore, it's just noise.
1791 also doesn't return the file contents anymore, it's just noise.
1780
1792
1781 * IPython/completer.py (Completer.attr_matches): revert change to
1793 * IPython/completer.py (Completer.attr_matches): revert change to
1782 complete only on attributes listed in __all__. I realized it
1794 complete only on attributes listed in __all__. I realized it
1783 cripples the tab-completion system as a tool for exploring the
1795 cripples the tab-completion system as a tool for exploring the
1784 internals of unknown libraries (it renders any non-__all__
1796 internals of unknown libraries (it renders any non-__all__
1785 attribute off-limits). I got bit by this when trying to see
1797 attribute off-limits). I got bit by this when trying to see
1786 something inside the dis module.
1798 something inside the dis module.
1787
1799
1788 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
1800 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
1789
1801
1790 * IPython/iplib.py (InteractiveShell.__init__): add .meta
1802 * IPython/iplib.py (InteractiveShell.__init__): add .meta
1791 namespace for users and extension writers to hold data in. This
1803 namespace for users and extension writers to hold data in. This
1792 follows the discussion in
1804 follows the discussion in
1793 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
1805 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
1794
1806
1795 * IPython/completer.py (IPCompleter.complete): small patch to help
1807 * IPython/completer.py (IPCompleter.complete): small patch to help
1796 tab-completion under Emacs, after a suggestion by John Barnard
1808 tab-completion under Emacs, after a suggestion by John Barnard
1797 <barnarj-AT-ccf.org>.
1809 <barnarj-AT-ccf.org>.
1798
1810
1799 * IPython/Magic.py (Magic.extract_input_slices): added support for
1811 * IPython/Magic.py (Magic.extract_input_slices): added support for
1800 the slice notation in magics to use N-M to represent numbers N...M
1812 the slice notation in magics to use N-M to represent numbers N...M
1801 (closed endpoints). This is used by %macro and %save.
1813 (closed endpoints). This is used by %macro and %save.
1802
1814
1803 * IPython/completer.py (Completer.attr_matches): for modules which
1815 * IPython/completer.py (Completer.attr_matches): for modules which
1804 define __all__, complete only on those. After a patch by Jeffrey
1816 define __all__, complete only on those. After a patch by Jeffrey
1805 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
1817 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
1806 speed up this routine.
1818 speed up this routine.
1807
1819
1808 * IPython/Logger.py (Logger.log): fix a history handling bug. I
1820 * IPython/Logger.py (Logger.log): fix a history handling bug. I
1809 don't know if this is the end of it, but the behavior now is
1821 don't know if this is the end of it, but the behavior now is
1810 certainly much more correct. Note that coupled with macros,
1822 certainly much more correct. Note that coupled with macros,
1811 slightly surprising (at first) behavior may occur: a macro will in
1823 slightly surprising (at first) behavior may occur: a macro will in
1812 general expand to multiple lines of input, so upon exiting, the
1824 general expand to multiple lines of input, so upon exiting, the
1813 in/out counters will both be bumped by the corresponding amount
1825 in/out counters will both be bumped by the corresponding amount
1814 (as if the macro's contents had been typed interactively). Typing
1826 (as if the macro's contents had been typed interactively). Typing
1815 %hist will reveal the intermediate (silently processed) lines.
1827 %hist will reveal the intermediate (silently processed) lines.
1816
1828
1817 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
1829 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
1818 pickle to fail (%run was overwriting __main__ and not restoring
1830 pickle to fail (%run was overwriting __main__ and not restoring
1819 it, but pickle relies on __main__ to operate).
1831 it, but pickle relies on __main__ to operate).
1820
1832
1821 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
1833 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
1822 using properties, but forgot to make the main InteractiveShell
1834 using properties, but forgot to make the main InteractiveShell
1823 class a new-style class. Properties fail silently, and
1835 class a new-style class. Properties fail silently, and
1824 mysteriously, with old-style class (getters work, but
1836 mysteriously, with old-style class (getters work, but
1825 setters don't do anything).
1837 setters don't do anything).
1826
1838
1827 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
1839 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
1828
1840
1829 * IPython/Magic.py (magic_history): fix history reporting bug (I
1841 * IPython/Magic.py (magic_history): fix history reporting bug (I
1830 know some nasties are still there, I just can't seem to find a
1842 know some nasties are still there, I just can't seem to find a
1831 reproducible test case to track them down; the input history is
1843 reproducible test case to track them down; the input history is
1832 falling out of sync...)
1844 falling out of sync...)
1833
1845
1834 * IPython/iplib.py (handle_shell_escape): fix bug where both
1846 * IPython/iplib.py (handle_shell_escape): fix bug where both
1835 aliases and system accesses where broken for indented code (such
1847 aliases and system accesses where broken for indented code (such
1836 as loops).
1848 as loops).
1837
1849
1838 * IPython/genutils.py (shell): fix small but critical bug for
1850 * IPython/genutils.py (shell): fix small but critical bug for
1839 win32 system access.
1851 win32 system access.
1840
1852
1841 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
1853 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
1842
1854
1843 * IPython/iplib.py (showtraceback): remove use of the
1855 * IPython/iplib.py (showtraceback): remove use of the
1844 sys.last_{type/value/traceback} structures, which are non
1856 sys.last_{type/value/traceback} structures, which are non
1845 thread-safe.
1857 thread-safe.
1846 (_prefilter): change control flow to ensure that we NEVER
1858 (_prefilter): change control flow to ensure that we NEVER
1847 introspect objects when autocall is off. This will guarantee that
1859 introspect objects when autocall is off. This will guarantee that
1848 having an input line of the form 'x.y', where access to attribute
1860 having an input line of the form 'x.y', where access to attribute
1849 'y' has side effects, doesn't trigger the side effect TWICE. It
1861 'y' has side effects, doesn't trigger the side effect TWICE. It
1850 is important to note that, with autocall on, these side effects
1862 is important to note that, with autocall on, these side effects
1851 can still happen.
1863 can still happen.
1852 (ipsystem): new builtin, to complete the ip{magic/alias/system}
1864 (ipsystem): new builtin, to complete the ip{magic/alias/system}
1853 trio. IPython offers these three kinds of special calls which are
1865 trio. IPython offers these three kinds of special calls which are
1854 not python code, and it's a good thing to have their call method
1866 not python code, and it's a good thing to have their call method
1855 be accessible as pure python functions (not just special syntax at
1867 be accessible as pure python functions (not just special syntax at
1856 the command line). It gives us a better internal implementation
1868 the command line). It gives us a better internal implementation
1857 structure, as well as exposing these for user scripting more
1869 structure, as well as exposing these for user scripting more
1858 cleanly.
1870 cleanly.
1859
1871
1860 * IPython/macro.py (Macro.__init__): moved macros to a standalone
1872 * IPython/macro.py (Macro.__init__): moved macros to a standalone
1861 file. Now that they'll be more likely to be used with the
1873 file. Now that they'll be more likely to be used with the
1862 persistance system (%store), I want to make sure their module path
1874 persistance system (%store), I want to make sure their module path
1863 doesn't change in the future, so that we don't break things for
1875 doesn't change in the future, so that we don't break things for
1864 users' persisted data.
1876 users' persisted data.
1865
1877
1866 * IPython/iplib.py (autoindent_update): move indentation
1878 * IPython/iplib.py (autoindent_update): move indentation
1867 management into the _text_ processing loop, not the keyboard
1879 management into the _text_ processing loop, not the keyboard
1868 interactive one. This is necessary to correctly process non-typed
1880 interactive one. This is necessary to correctly process non-typed
1869 multiline input (such as macros).
1881 multiline input (such as macros).
1870
1882
1871 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
1883 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
1872 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
1884 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
1873 which was producing problems in the resulting manual.
1885 which was producing problems in the resulting manual.
1874 (magic_whos): improve reporting of instances (show their class,
1886 (magic_whos): improve reporting of instances (show their class,
1875 instead of simply printing 'instance' which isn't terribly
1887 instead of simply printing 'instance' which isn't terribly
1876 informative).
1888 informative).
1877
1889
1878 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
1890 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
1879 (minor mods) to support network shares under win32.
1891 (minor mods) to support network shares under win32.
1880
1892
1881 * IPython/winconsole.py (get_console_size): add new winconsole
1893 * IPython/winconsole.py (get_console_size): add new winconsole
1882 module and fixes to page_dumb() to improve its behavior under
1894 module and fixes to page_dumb() to improve its behavior under
1883 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
1895 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
1884
1896
1885 * IPython/Magic.py (Macro): simplified Macro class to just
1897 * IPython/Magic.py (Macro): simplified Macro class to just
1886 subclass list. We've had only 2.2 compatibility for a very long
1898 subclass list. We've had only 2.2 compatibility for a very long
1887 time, yet I was still avoiding subclassing the builtin types. No
1899 time, yet I was still avoiding subclassing the builtin types. No
1888 more (I'm also starting to use properties, though I won't shift to
1900 more (I'm also starting to use properties, though I won't shift to
1889 2.3-specific features quite yet).
1901 2.3-specific features quite yet).
1890 (magic_store): added Ville's patch for lightweight variable
1902 (magic_store): added Ville's patch for lightweight variable
1891 persistence, after a request on the user list by Matt Wilkie
1903 persistence, after a request on the user list by Matt Wilkie
1892 <maphew-AT-gmail.com>. The new %store magic's docstring has full
1904 <maphew-AT-gmail.com>. The new %store magic's docstring has full
1893 details.
1905 details.
1894
1906
1895 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1907 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1896 changed the default logfile name from 'ipython.log' to
1908 changed the default logfile name from 'ipython.log' to
1897 'ipython_log.py'. These logs are real python files, and now that
1909 'ipython_log.py'. These logs are real python files, and now that
1898 we have much better multiline support, people are more likely to
1910 we have much better multiline support, people are more likely to
1899 want to use them as such. Might as well name them correctly.
1911 want to use them as such. Might as well name them correctly.
1900
1912
1901 * IPython/Magic.py: substantial cleanup. While we can't stop
1913 * IPython/Magic.py: substantial cleanup. While we can't stop
1902 using magics as mixins, due to the existing customizations 'out
1914 using magics as mixins, due to the existing customizations 'out
1903 there' which rely on the mixin naming conventions, at least I
1915 there' which rely on the mixin naming conventions, at least I
1904 cleaned out all cross-class name usage. So once we are OK with
1916 cleaned out all cross-class name usage. So once we are OK with
1905 breaking compatibility, the two systems can be separated.
1917 breaking compatibility, the two systems can be separated.
1906
1918
1907 * IPython/Logger.py: major cleanup. This one is NOT a mixin
1919 * IPython/Logger.py: major cleanup. This one is NOT a mixin
1908 anymore, and the class is a fair bit less hideous as well. New
1920 anymore, and the class is a fair bit less hideous as well. New
1909 features were also introduced: timestamping of input, and logging
1921 features were also introduced: timestamping of input, and logging
1910 of output results. These are user-visible with the -t and -o
1922 of output results. These are user-visible with the -t and -o
1911 options to %logstart. Closes
1923 options to %logstart. Closes
1912 http://www.scipy.net/roundup/ipython/issue11 and a request by
1924 http://www.scipy.net/roundup/ipython/issue11 and a request by
1913 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
1925 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
1914
1926
1915 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
1927 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
1916
1928
1917 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
1929 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
1918 better handle backslashes in paths. See the thread 'More Windows
1930 better handle backslashes in paths. See the thread 'More Windows
1919 questions part 2 - \/ characters revisited' on the iypthon user
1931 questions part 2 - \/ characters revisited' on the iypthon user
1920 list:
1932 list:
1921 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
1933 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
1922
1934
1923 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
1935 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
1924
1936
1925 (InteractiveShell.__init__): change threaded shells to not use the
1937 (InteractiveShell.__init__): change threaded shells to not use the
1926 ipython crash handler. This was causing more problems than not,
1938 ipython crash handler. This was causing more problems than not,
1927 as exceptions in the main thread (GUI code, typically) would
1939 as exceptions in the main thread (GUI code, typically) would
1928 always show up as a 'crash', when they really weren't.
1940 always show up as a 'crash', when they really weren't.
1929
1941
1930 The colors and exception mode commands (%colors/%xmode) have been
1942 The colors and exception mode commands (%colors/%xmode) have been
1931 synchronized to also take this into account, so users can get
1943 synchronized to also take this into account, so users can get
1932 verbose exceptions for their threaded code as well. I also added
1944 verbose exceptions for their threaded code as well. I also added
1933 support for activating pdb inside this exception handler as well,
1945 support for activating pdb inside this exception handler as well,
1934 so now GUI authors can use IPython's enhanced pdb at runtime.
1946 so now GUI authors can use IPython's enhanced pdb at runtime.
1935
1947
1936 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
1948 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
1937 true by default, and add it to the shipped ipythonrc file. Since
1949 true by default, and add it to the shipped ipythonrc file. Since
1938 this asks the user before proceeding, I think it's OK to make it
1950 this asks the user before proceeding, I think it's OK to make it
1939 true by default.
1951 true by default.
1940
1952
1941 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
1953 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
1942 of the previous special-casing of input in the eval loop. I think
1954 of the previous special-casing of input in the eval loop. I think
1943 this is cleaner, as they really are commands and shouldn't have
1955 this is cleaner, as they really are commands and shouldn't have
1944 a special role in the middle of the core code.
1956 a special role in the middle of the core code.
1945
1957
1946 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
1958 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
1947
1959
1948 * IPython/iplib.py (edit_syntax_error): added support for
1960 * IPython/iplib.py (edit_syntax_error): added support for
1949 automatically reopening the editor if the file had a syntax error
1961 automatically reopening the editor if the file had a syntax error
1950 in it. Thanks to scottt who provided the patch at:
1962 in it. Thanks to scottt who provided the patch at:
1951 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
1963 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
1952 version committed).
1964 version committed).
1953
1965
1954 * IPython/iplib.py (handle_normal): add suport for multi-line
1966 * IPython/iplib.py (handle_normal): add suport for multi-line
1955 input with emtpy lines. This fixes
1967 input with emtpy lines. This fixes
1956 http://www.scipy.net/roundup/ipython/issue43 and a similar
1968 http://www.scipy.net/roundup/ipython/issue43 and a similar
1957 discussion on the user list.
1969 discussion on the user list.
1958
1970
1959 WARNING: a behavior change is necessarily introduced to support
1971 WARNING: a behavior change is necessarily introduced to support
1960 blank lines: now a single blank line with whitespace does NOT
1972 blank lines: now a single blank line with whitespace does NOT
1961 break the input loop, which means that when autoindent is on, by
1973 break the input loop, which means that when autoindent is on, by
1962 default hitting return on the next (indented) line does NOT exit.
1974 default hitting return on the next (indented) line does NOT exit.
1963
1975
1964 Instead, to exit a multiline input you can either have:
1976 Instead, to exit a multiline input you can either have:
1965
1977
1966 - TWO whitespace lines (just hit return again), or
1978 - TWO whitespace lines (just hit return again), or
1967 - a single whitespace line of a different length than provided
1979 - a single whitespace line of a different length than provided
1968 by the autoindent (add or remove a space).
1980 by the autoindent (add or remove a space).
1969
1981
1970 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
1982 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
1971 module to better organize all readline-related functionality.
1983 module to better organize all readline-related functionality.
1972 I've deleted FlexCompleter and put all completion clases here.
1984 I've deleted FlexCompleter and put all completion clases here.
1973
1985
1974 * IPython/iplib.py (raw_input): improve indentation management.
1986 * IPython/iplib.py (raw_input): improve indentation management.
1975 It is now possible to paste indented code with autoindent on, and
1987 It is now possible to paste indented code with autoindent on, and
1976 the code is interpreted correctly (though it still looks bad on
1988 the code is interpreted correctly (though it still looks bad on
1977 screen, due to the line-oriented nature of ipython).
1989 screen, due to the line-oriented nature of ipython).
1978 (MagicCompleter.complete): change behavior so that a TAB key on an
1990 (MagicCompleter.complete): change behavior so that a TAB key on an
1979 otherwise empty line actually inserts a tab, instead of completing
1991 otherwise empty line actually inserts a tab, instead of completing
1980 on the entire global namespace. This makes it easier to use the
1992 on the entire global namespace. This makes it easier to use the
1981 TAB key for indentation. After a request by Hans Meine
1993 TAB key for indentation. After a request by Hans Meine
1982 <hans_meine-AT-gmx.net>
1994 <hans_meine-AT-gmx.net>
1983 (_prefilter): add support so that typing plain 'exit' or 'quit'
1995 (_prefilter): add support so that typing plain 'exit' or 'quit'
1984 does a sensible thing. Originally I tried to deviate as little as
1996 does a sensible thing. Originally I tried to deviate as little as
1985 possible from the default python behavior, but even that one may
1997 possible from the default python behavior, but even that one may
1986 change in this direction (thread on python-dev to that effect).
1998 change in this direction (thread on python-dev to that effect).
1987 Regardless, ipython should do the right thing even if CPython's
1999 Regardless, ipython should do the right thing even if CPython's
1988 '>>>' prompt doesn't.
2000 '>>>' prompt doesn't.
1989 (InteractiveShell): removed subclassing code.InteractiveConsole
2001 (InteractiveShell): removed subclassing code.InteractiveConsole
1990 class. By now we'd overridden just about all of its methods: I've
2002 class. By now we'd overridden just about all of its methods: I've
1991 copied the remaining two over, and now ipython is a standalone
2003 copied the remaining two over, and now ipython is a standalone
1992 class. This will provide a clearer picture for the chainsaw
2004 class. This will provide a clearer picture for the chainsaw
1993 branch refactoring.
2005 branch refactoring.
1994
2006
1995 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
2007 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
1996
2008
1997 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
2009 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
1998 failures for objects which break when dir() is called on them.
2010 failures for objects which break when dir() is called on them.
1999
2011
2000 * IPython/FlexCompleter.py (Completer.__init__): Added support for
2012 * IPython/FlexCompleter.py (Completer.__init__): Added support for
2001 distinct local and global namespaces in the completer API. This
2013 distinct local and global namespaces in the completer API. This
2002 change allows us to properly handle completion with distinct
2014 change allows us to properly handle completion with distinct
2003 scopes, including in embedded instances (this had never really
2015 scopes, including in embedded instances (this had never really
2004 worked correctly).
2016 worked correctly).
2005
2017
2006 Note: this introduces a change in the constructor for
2018 Note: this introduces a change in the constructor for
2007 MagicCompleter, as a new global_namespace parameter is now the
2019 MagicCompleter, as a new global_namespace parameter is now the
2008 second argument (the others were bumped one position).
2020 second argument (the others were bumped one position).
2009
2021
2010 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
2022 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
2011
2023
2012 * IPython/iplib.py (embed_mainloop): fix tab-completion in
2024 * IPython/iplib.py (embed_mainloop): fix tab-completion in
2013 embedded instances (which can be done now thanks to Vivian's
2025 embedded instances (which can be done now thanks to Vivian's
2014 frame-handling fixes for pdb).
2026 frame-handling fixes for pdb).
2015 (InteractiveShell.__init__): Fix namespace handling problem in
2027 (InteractiveShell.__init__): Fix namespace handling problem in
2016 embedded instances. We were overwriting __main__ unconditionally,
2028 embedded instances. We were overwriting __main__ unconditionally,
2017 and this should only be done for 'full' (non-embedded) IPython;
2029 and this should only be done for 'full' (non-embedded) IPython;
2018 embedded instances must respect the caller's __main__. Thanks to
2030 embedded instances must respect the caller's __main__. Thanks to
2019 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
2031 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
2020
2032
2021 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
2033 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
2022
2034
2023 * setup.py: added download_url to setup(). This registers the
2035 * setup.py: added download_url to setup(). This registers the
2024 download address at PyPI, which is not only useful to humans
2036 download address at PyPI, which is not only useful to humans
2025 browsing the site, but is also picked up by setuptools (the Eggs
2037 browsing the site, but is also picked up by setuptools (the Eggs
2026 machinery). Thanks to Ville and R. Kern for the info/discussion
2038 machinery). Thanks to Ville and R. Kern for the info/discussion
2027 on this.
2039 on this.
2028
2040
2029 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
2041 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
2030
2042
2031 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
2043 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
2032 This brings a lot of nice functionality to the pdb mode, which now
2044 This brings a lot of nice functionality to the pdb mode, which now
2033 has tab-completion, syntax highlighting, and better stack handling
2045 has tab-completion, syntax highlighting, and better stack handling
2034 than before. Many thanks to Vivian De Smedt
2046 than before. Many thanks to Vivian De Smedt
2035 <vivian-AT-vdesmedt.com> for the original patches.
2047 <vivian-AT-vdesmedt.com> for the original patches.
2036
2048
2037 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
2049 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
2038
2050
2039 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
2051 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
2040 sequence to consistently accept the banner argument. The
2052 sequence to consistently accept the banner argument. The
2041 inconsistency was tripping SAGE, thanks to Gary Zablackis
2053 inconsistency was tripping SAGE, thanks to Gary Zablackis
2042 <gzabl-AT-yahoo.com> for the report.
2054 <gzabl-AT-yahoo.com> for the report.
2043
2055
2044 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
2056 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
2045
2057
2046 * IPython/iplib.py (InteractiveShell.post_config_initialization):
2058 * IPython/iplib.py (InteractiveShell.post_config_initialization):
2047 Fix bug where a naked 'alias' call in the ipythonrc file would
2059 Fix bug where a naked 'alias' call in the ipythonrc file would
2048 cause a crash. Bug reported by Jorgen Stenarson.
2060 cause a crash. Bug reported by Jorgen Stenarson.
2049
2061
2050 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
2062 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
2051
2063
2052 * IPython/ipmaker.py (make_IPython): cleanups which should improve
2064 * IPython/ipmaker.py (make_IPython): cleanups which should improve
2053 startup time.
2065 startup time.
2054
2066
2055 * IPython/iplib.py (runcode): my globals 'fix' for embedded
2067 * IPython/iplib.py (runcode): my globals 'fix' for embedded
2056 instances had introduced a bug with globals in normal code. Now
2068 instances had introduced a bug with globals in normal code. Now
2057 it's working in all cases.
2069 it's working in all cases.
2058
2070
2059 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
2071 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
2060 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
2072 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
2061 has been introduced to set the default case sensitivity of the
2073 has been introduced to set the default case sensitivity of the
2062 searches. Users can still select either mode at runtime on a
2074 searches. Users can still select either mode at runtime on a
2063 per-search basis.
2075 per-search basis.
2064
2076
2065 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
2077 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
2066
2078
2067 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
2079 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
2068 attributes in wildcard searches for subclasses. Modified version
2080 attributes in wildcard searches for subclasses. Modified version
2069 of a patch by Jorgen.
2081 of a patch by Jorgen.
2070
2082
2071 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
2083 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
2072
2084
2073 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
2085 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
2074 embedded instances. I added a user_global_ns attribute to the
2086 embedded instances. I added a user_global_ns attribute to the
2075 InteractiveShell class to handle this.
2087 InteractiveShell class to handle this.
2076
2088
2077 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
2089 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
2078
2090
2079 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
2091 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
2080 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
2092 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
2081 (reported under win32, but may happen also in other platforms).
2093 (reported under win32, but may happen also in other platforms).
2082 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
2094 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
2083
2095
2084 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
2096 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
2085
2097
2086 * IPython/Magic.py (magic_psearch): new support for wildcard
2098 * IPython/Magic.py (magic_psearch): new support for wildcard
2087 patterns. Now, typing ?a*b will list all names which begin with a
2099 patterns. Now, typing ?a*b will list all names which begin with a
2088 and end in b, for example. The %psearch magic has full
2100 and end in b, for example. The %psearch magic has full
2089 docstrings. Many thanks to JΓΆrgen Stenarson
2101 docstrings. Many thanks to JΓΆrgen Stenarson
2090 <jorgen.stenarson-AT-bostream.nu>, author of the patches
2102 <jorgen.stenarson-AT-bostream.nu>, author of the patches
2091 implementing this functionality.
2103 implementing this functionality.
2092
2104
2093 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
2105 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
2094
2106
2095 * Manual: fixed long-standing annoyance of double-dashes (as in
2107 * Manual: fixed long-standing annoyance of double-dashes (as in
2096 --prefix=~, for example) being stripped in the HTML version. This
2108 --prefix=~, for example) being stripped in the HTML version. This
2097 is a latex2html bug, but a workaround was provided. Many thanks
2109 is a latex2html bug, but a workaround was provided. Many thanks
2098 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
2110 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
2099 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
2111 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
2100 rolling. This seemingly small issue had tripped a number of users
2112 rolling. This seemingly small issue had tripped a number of users
2101 when first installing, so I'm glad to see it gone.
2113 when first installing, so I'm glad to see it gone.
2102
2114
2103 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
2115 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
2104
2116
2105 * IPython/Extensions/numeric_formats.py: fix missing import,
2117 * IPython/Extensions/numeric_formats.py: fix missing import,
2106 reported by Stephen Walton.
2118 reported by Stephen Walton.
2107
2119
2108 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
2120 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
2109
2121
2110 * IPython/demo.py: finish demo module, fully documented now.
2122 * IPython/demo.py: finish demo module, fully documented now.
2111
2123
2112 * IPython/genutils.py (file_read): simple little utility to read a
2124 * IPython/genutils.py (file_read): simple little utility to read a
2113 file and ensure it's closed afterwards.
2125 file and ensure it's closed afterwards.
2114
2126
2115 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
2127 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
2116
2128
2117 * IPython/demo.py (Demo.__init__): added support for individually
2129 * IPython/demo.py (Demo.__init__): added support for individually
2118 tagging blocks for automatic execution.
2130 tagging blocks for automatic execution.
2119
2131
2120 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
2132 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
2121 syntax-highlighted python sources, requested by John.
2133 syntax-highlighted python sources, requested by John.
2122
2134
2123 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
2135 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
2124
2136
2125 * IPython/demo.py (Demo.again): fix bug where again() blocks after
2137 * IPython/demo.py (Demo.again): fix bug where again() blocks after
2126 finishing.
2138 finishing.
2127
2139
2128 * IPython/genutils.py (shlex_split): moved from Magic to here,
2140 * IPython/genutils.py (shlex_split): moved from Magic to here,
2129 where all 2.2 compatibility stuff lives. I needed it for demo.py.
2141 where all 2.2 compatibility stuff lives. I needed it for demo.py.
2130
2142
2131 * IPython/demo.py (Demo.__init__): added support for silent
2143 * IPython/demo.py (Demo.__init__): added support for silent
2132 blocks, improved marks as regexps, docstrings written.
2144 blocks, improved marks as regexps, docstrings written.
2133 (Demo.__init__): better docstring, added support for sys.argv.
2145 (Demo.__init__): better docstring, added support for sys.argv.
2134
2146
2135 * IPython/genutils.py (marquee): little utility used by the demo
2147 * IPython/genutils.py (marquee): little utility used by the demo
2136 code, handy in general.
2148 code, handy in general.
2137
2149
2138 * IPython/demo.py (Demo.__init__): new class for interactive
2150 * IPython/demo.py (Demo.__init__): new class for interactive
2139 demos. Not documented yet, I just wrote it in a hurry for
2151 demos. Not documented yet, I just wrote it in a hurry for
2140 scipy'05. Will docstring later.
2152 scipy'05. Will docstring later.
2141
2153
2142 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
2154 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
2143
2155
2144 * IPython/Shell.py (sigint_handler): Drastic simplification which
2156 * IPython/Shell.py (sigint_handler): Drastic simplification which
2145 also seems to make Ctrl-C work correctly across threads! This is
2157 also seems to make Ctrl-C work correctly across threads! This is
2146 so simple, that I can't beleive I'd missed it before. Needs more
2158 so simple, that I can't beleive I'd missed it before. Needs more
2147 testing, though.
2159 testing, though.
2148 (KBINT): Never mind, revert changes. I'm sure I'd tried something
2160 (KBINT): Never mind, revert changes. I'm sure I'd tried something
2149 like this before...
2161 like this before...
2150
2162
2151 * IPython/genutils.py (get_home_dir): add protection against
2163 * IPython/genutils.py (get_home_dir): add protection against
2152 non-dirs in win32 registry.
2164 non-dirs in win32 registry.
2153
2165
2154 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
2166 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
2155 bug where dict was mutated while iterating (pysh crash).
2167 bug where dict was mutated while iterating (pysh crash).
2156
2168
2157 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
2169 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
2158
2170
2159 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
2171 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
2160 spurious newlines added by this routine. After a report by
2172 spurious newlines added by this routine. After a report by
2161 F. Mantegazza.
2173 F. Mantegazza.
2162
2174
2163 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
2175 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
2164
2176
2165 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
2177 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
2166 calls. These were a leftover from the GTK 1.x days, and can cause
2178 calls. These were a leftover from the GTK 1.x days, and can cause
2167 problems in certain cases (after a report by John Hunter).
2179 problems in certain cases (after a report by John Hunter).
2168
2180
2169 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
2181 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
2170 os.getcwd() fails at init time. Thanks to patch from David Remahl
2182 os.getcwd() fails at init time. Thanks to patch from David Remahl
2171 <chmod007-AT-mac.com>.
2183 <chmod007-AT-mac.com>.
2172 (InteractiveShell.__init__): prevent certain special magics from
2184 (InteractiveShell.__init__): prevent certain special magics from
2173 being shadowed by aliases. Closes
2185 being shadowed by aliases. Closes
2174 http://www.scipy.net/roundup/ipython/issue41.
2186 http://www.scipy.net/roundup/ipython/issue41.
2175
2187
2176 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
2188 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
2177
2189
2178 * IPython/iplib.py (InteractiveShell.complete): Added new
2190 * IPython/iplib.py (InteractiveShell.complete): Added new
2179 top-level completion method to expose the completion mechanism
2191 top-level completion method to expose the completion mechanism
2180 beyond readline-based environments.
2192 beyond readline-based environments.
2181
2193
2182 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
2194 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
2183
2195
2184 * tools/ipsvnc (svnversion): fix svnversion capture.
2196 * tools/ipsvnc (svnversion): fix svnversion capture.
2185
2197
2186 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
2198 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
2187 attribute to self, which was missing. Before, it was set by a
2199 attribute to self, which was missing. Before, it was set by a
2188 routine which in certain cases wasn't being called, so the
2200 routine which in certain cases wasn't being called, so the
2189 instance could end up missing the attribute. This caused a crash.
2201 instance could end up missing the attribute. This caused a crash.
2190 Closes http://www.scipy.net/roundup/ipython/issue40.
2202 Closes http://www.scipy.net/roundup/ipython/issue40.
2191
2203
2192 2005-08-16 Fernando Perez <fperez@colorado.edu>
2204 2005-08-16 Fernando Perez <fperez@colorado.edu>
2193
2205
2194 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
2206 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
2195 contains non-string attribute. Closes
2207 contains non-string attribute. Closes
2196 http://www.scipy.net/roundup/ipython/issue38.
2208 http://www.scipy.net/roundup/ipython/issue38.
2197
2209
2198 2005-08-14 Fernando Perez <fperez@colorado.edu>
2210 2005-08-14 Fernando Perez <fperez@colorado.edu>
2199
2211
2200 * tools/ipsvnc: Minor improvements, to add changeset info.
2212 * tools/ipsvnc: Minor improvements, to add changeset info.
2201
2213
2202 2005-08-12 Fernando Perez <fperez@colorado.edu>
2214 2005-08-12 Fernando Perez <fperez@colorado.edu>
2203
2215
2204 * IPython/iplib.py (runsource): remove self.code_to_run_src
2216 * IPython/iplib.py (runsource): remove self.code_to_run_src
2205 attribute. I realized this is nothing more than
2217 attribute. I realized this is nothing more than
2206 '\n'.join(self.buffer), and having the same data in two different
2218 '\n'.join(self.buffer), and having the same data in two different
2207 places is just asking for synchronization bugs. This may impact
2219 places is just asking for synchronization bugs. This may impact
2208 people who have custom exception handlers, so I need to warn
2220 people who have custom exception handlers, so I need to warn
2209 ipython-dev about it (F. Mantegazza may use them).
2221 ipython-dev about it (F. Mantegazza may use them).
2210
2222
2211 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
2223 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
2212
2224
2213 * IPython/genutils.py: fix 2.2 compatibility (generators)
2225 * IPython/genutils.py: fix 2.2 compatibility (generators)
2214
2226
2215 2005-07-18 Fernando Perez <fperez@colorado.edu>
2227 2005-07-18 Fernando Perez <fperez@colorado.edu>
2216
2228
2217 * IPython/genutils.py (get_home_dir): fix to help users with
2229 * IPython/genutils.py (get_home_dir): fix to help users with
2218 invalid $HOME under win32.
2230 invalid $HOME under win32.
2219
2231
2220 2005-07-17 Fernando Perez <fperez@colorado.edu>
2232 2005-07-17 Fernando Perez <fperez@colorado.edu>
2221
2233
2222 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
2234 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
2223 some old hacks and clean up a bit other routines; code should be
2235 some old hacks and clean up a bit other routines; code should be
2224 simpler and a bit faster.
2236 simpler and a bit faster.
2225
2237
2226 * IPython/iplib.py (interact): removed some last-resort attempts
2238 * IPython/iplib.py (interact): removed some last-resort attempts
2227 to survive broken stdout/stderr. That code was only making it
2239 to survive broken stdout/stderr. That code was only making it
2228 harder to abstract out the i/o (necessary for gui integration),
2240 harder to abstract out the i/o (necessary for gui integration),
2229 and the crashes it could prevent were extremely rare in practice
2241 and the crashes it could prevent were extremely rare in practice
2230 (besides being fully user-induced in a pretty violent manner).
2242 (besides being fully user-induced in a pretty violent manner).
2231
2243
2232 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
2244 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
2233 Nothing major yet, but the code is simpler to read; this should
2245 Nothing major yet, but the code is simpler to read; this should
2234 make it easier to do more serious modifications in the future.
2246 make it easier to do more serious modifications in the future.
2235
2247
2236 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
2248 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
2237 which broke in .15 (thanks to a report by Ville).
2249 which broke in .15 (thanks to a report by Ville).
2238
2250
2239 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
2251 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
2240 be quite correct, I know next to nothing about unicode). This
2252 be quite correct, I know next to nothing about unicode). This
2241 will allow unicode strings to be used in prompts, amongst other
2253 will allow unicode strings to be used in prompts, amongst other
2242 cases. It also will prevent ipython from crashing when unicode
2254 cases. It also will prevent ipython from crashing when unicode
2243 shows up unexpectedly in many places. If ascii encoding fails, we
2255 shows up unexpectedly in many places. If ascii encoding fails, we
2244 assume utf_8. Currently the encoding is not a user-visible
2256 assume utf_8. Currently the encoding is not a user-visible
2245 setting, though it could be made so if there is demand for it.
2257 setting, though it could be made so if there is demand for it.
2246
2258
2247 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
2259 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
2248
2260
2249 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
2261 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
2250
2262
2251 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
2263 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
2252
2264
2253 * IPython/genutils.py: Add 2.2 compatibility here, so all other
2265 * IPython/genutils.py: Add 2.2 compatibility here, so all other
2254 code can work transparently for 2.2/2.3.
2266 code can work transparently for 2.2/2.3.
2255
2267
2256 2005-07-16 Fernando Perez <fperez@colorado.edu>
2268 2005-07-16 Fernando Perez <fperez@colorado.edu>
2257
2269
2258 * IPython/ultraTB.py (ExceptionColors): Make a global variable
2270 * IPython/ultraTB.py (ExceptionColors): Make a global variable
2259 out of the color scheme table used for coloring exception
2271 out of the color scheme table used for coloring exception
2260 tracebacks. This allows user code to add new schemes at runtime.
2272 tracebacks. This allows user code to add new schemes at runtime.
2261 This is a minimally modified version of the patch at
2273 This is a minimally modified version of the patch at
2262 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
2274 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
2263 for the contribution.
2275 for the contribution.
2264
2276
2265 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
2277 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
2266 slightly modified version of the patch in
2278 slightly modified version of the patch in
2267 http://www.scipy.net/roundup/ipython/issue34, which also allows me
2279 http://www.scipy.net/roundup/ipython/issue34, which also allows me
2268 to remove the previous try/except solution (which was costlier).
2280 to remove the previous try/except solution (which was costlier).
2269 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
2281 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
2270
2282
2271 2005-06-08 Fernando Perez <fperez@colorado.edu>
2283 2005-06-08 Fernando Perez <fperez@colorado.edu>
2272
2284
2273 * IPython/iplib.py (write/write_err): Add methods to abstract all
2285 * IPython/iplib.py (write/write_err): Add methods to abstract all
2274 I/O a bit more.
2286 I/O a bit more.
2275
2287
2276 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
2288 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
2277 warning, reported by Aric Hagberg, fix by JD Hunter.
2289 warning, reported by Aric Hagberg, fix by JD Hunter.
2278
2290
2279 2005-06-02 *** Released version 0.6.15
2291 2005-06-02 *** Released version 0.6.15
2280
2292
2281 2005-06-01 Fernando Perez <fperez@colorado.edu>
2293 2005-06-01 Fernando Perez <fperez@colorado.edu>
2282
2294
2283 * IPython/iplib.py (MagicCompleter.file_matches): Fix
2295 * IPython/iplib.py (MagicCompleter.file_matches): Fix
2284 tab-completion of filenames within open-quoted strings. Note that
2296 tab-completion of filenames within open-quoted strings. Note that
2285 this requires that in ~/.ipython/ipythonrc, users change the
2297 this requires that in ~/.ipython/ipythonrc, users change the
2286 readline delimiters configuration to read:
2298 readline delimiters configuration to read:
2287
2299
2288 readline_remove_delims -/~
2300 readline_remove_delims -/~
2289
2301
2290
2302
2291 2005-05-31 *** Released version 0.6.14
2303 2005-05-31 *** Released version 0.6.14
2292
2304
2293 2005-05-29 Fernando Perez <fperez@colorado.edu>
2305 2005-05-29 Fernando Perez <fperez@colorado.edu>
2294
2306
2295 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
2307 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
2296 with files not on the filesystem. Reported by Eliyahu Sandler
2308 with files not on the filesystem. Reported by Eliyahu Sandler
2297 <eli@gondolin.net>
2309 <eli@gondolin.net>
2298
2310
2299 2005-05-22 Fernando Perez <fperez@colorado.edu>
2311 2005-05-22 Fernando Perez <fperez@colorado.edu>
2300
2312
2301 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
2313 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
2302 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
2314 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
2303
2315
2304 2005-05-19 Fernando Perez <fperez@colorado.edu>
2316 2005-05-19 Fernando Perez <fperez@colorado.edu>
2305
2317
2306 * IPython/iplib.py (safe_execfile): close a file which could be
2318 * IPython/iplib.py (safe_execfile): close a file which could be
2307 left open (causing problems in win32, which locks open files).
2319 left open (causing problems in win32, which locks open files).
2308 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
2320 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
2309
2321
2310 2005-05-18 Fernando Perez <fperez@colorado.edu>
2322 2005-05-18 Fernando Perez <fperez@colorado.edu>
2311
2323
2312 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
2324 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
2313 keyword arguments correctly to safe_execfile().
2325 keyword arguments correctly to safe_execfile().
2314
2326
2315 2005-05-13 Fernando Perez <fperez@colorado.edu>
2327 2005-05-13 Fernando Perez <fperez@colorado.edu>
2316
2328
2317 * ipython.1: Added info about Qt to manpage, and threads warning
2329 * ipython.1: Added info about Qt to manpage, and threads warning
2318 to usage page (invoked with --help).
2330 to usage page (invoked with --help).
2319
2331
2320 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
2332 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
2321 new matcher (it goes at the end of the priority list) to do
2333 new matcher (it goes at the end of the priority list) to do
2322 tab-completion on named function arguments. Submitted by George
2334 tab-completion on named function arguments. Submitted by George
2323 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
2335 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
2324 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
2336 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
2325 for more details.
2337 for more details.
2326
2338
2327 * IPython/Magic.py (magic_run): Added new -e flag to ignore
2339 * IPython/Magic.py (magic_run): Added new -e flag to ignore
2328 SystemExit exceptions in the script being run. Thanks to a report
2340 SystemExit exceptions in the script being run. Thanks to a report
2329 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
2341 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
2330 producing very annoying behavior when running unit tests.
2342 producing very annoying behavior when running unit tests.
2331
2343
2332 2005-05-12 Fernando Perez <fperez@colorado.edu>
2344 2005-05-12 Fernando Perez <fperez@colorado.edu>
2333
2345
2334 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
2346 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
2335 which I'd broken (again) due to a changed regexp. In the process,
2347 which I'd broken (again) due to a changed regexp. In the process,
2336 added ';' as an escape to auto-quote the whole line without
2348 added ';' as an escape to auto-quote the whole line without
2337 splitting its arguments. Thanks to a report by Jerry McRae
2349 splitting its arguments. Thanks to a report by Jerry McRae
2338 <qrs0xyc02-AT-sneakemail.com>.
2350 <qrs0xyc02-AT-sneakemail.com>.
2339
2351
2340 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
2352 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
2341 possible crashes caused by a TokenError. Reported by Ed Schofield
2353 possible crashes caused by a TokenError. Reported by Ed Schofield
2342 <schofield-AT-ftw.at>.
2354 <schofield-AT-ftw.at>.
2343
2355
2344 2005-05-06 Fernando Perez <fperez@colorado.edu>
2356 2005-05-06 Fernando Perez <fperez@colorado.edu>
2345
2357
2346 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
2358 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
2347
2359
2348 2005-04-29 Fernando Perez <fperez@colorado.edu>
2360 2005-04-29 Fernando Perez <fperez@colorado.edu>
2349
2361
2350 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
2362 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
2351 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
2363 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
2352 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
2364 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
2353 which provides support for Qt interactive usage (similar to the
2365 which provides support for Qt interactive usage (similar to the
2354 existing one for WX and GTK). This had been often requested.
2366 existing one for WX and GTK). This had been often requested.
2355
2367
2356 2005-04-14 *** Released version 0.6.13
2368 2005-04-14 *** Released version 0.6.13
2357
2369
2358 2005-04-08 Fernando Perez <fperez@colorado.edu>
2370 2005-04-08 Fernando Perez <fperez@colorado.edu>
2359
2371
2360 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
2372 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
2361 from _ofind, which gets called on almost every input line. Now,
2373 from _ofind, which gets called on almost every input line. Now,
2362 we only try to get docstrings if they are actually going to be
2374 we only try to get docstrings if they are actually going to be
2363 used (the overhead of fetching unnecessary docstrings can be
2375 used (the overhead of fetching unnecessary docstrings can be
2364 noticeable for certain objects, such as Pyro proxies).
2376 noticeable for certain objects, such as Pyro proxies).
2365
2377
2366 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
2378 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
2367 for completers. For some reason I had been passing them the state
2379 for completers. For some reason I had been passing them the state
2368 variable, which completers never actually need, and was in
2380 variable, which completers never actually need, and was in
2369 conflict with the rlcompleter API. Custom completers ONLY need to
2381 conflict with the rlcompleter API. Custom completers ONLY need to
2370 take the text parameter.
2382 take the text parameter.
2371
2383
2372 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
2384 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
2373 work correctly in pysh. I've also moved all the logic which used
2385 work correctly in pysh. I've also moved all the logic which used
2374 to be in pysh.py here, which will prevent problems with future
2386 to be in pysh.py here, which will prevent problems with future
2375 upgrades. However, this time I must warn users to update their
2387 upgrades. However, this time I must warn users to update their
2376 pysh profile to include the line
2388 pysh profile to include the line
2377
2389
2378 import_all IPython.Extensions.InterpreterExec
2390 import_all IPython.Extensions.InterpreterExec
2379
2391
2380 because otherwise things won't work for them. They MUST also
2392 because otherwise things won't work for them. They MUST also
2381 delete pysh.py and the line
2393 delete pysh.py and the line
2382
2394
2383 execfile pysh.py
2395 execfile pysh.py
2384
2396
2385 from their ipythonrc-pysh.
2397 from their ipythonrc-pysh.
2386
2398
2387 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
2399 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
2388 robust in the face of objects whose dir() returns non-strings
2400 robust in the face of objects whose dir() returns non-strings
2389 (which it shouldn't, but some broken libs like ITK do). Thanks to
2401 (which it shouldn't, but some broken libs like ITK do). Thanks to
2390 a patch by John Hunter (implemented differently, though). Also
2402 a patch by John Hunter (implemented differently, though). Also
2391 minor improvements by using .extend instead of + on lists.
2403 minor improvements by using .extend instead of + on lists.
2392
2404
2393 * pysh.py:
2405 * pysh.py:
2394
2406
2395 2005-04-06 Fernando Perez <fperez@colorado.edu>
2407 2005-04-06 Fernando Perez <fperez@colorado.edu>
2396
2408
2397 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
2409 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
2398 by default, so that all users benefit from it. Those who don't
2410 by default, so that all users benefit from it. Those who don't
2399 want it can still turn it off.
2411 want it can still turn it off.
2400
2412
2401 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
2413 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
2402 config file, I'd forgotten about this, so users were getting it
2414 config file, I'd forgotten about this, so users were getting it
2403 off by default.
2415 off by default.
2404
2416
2405 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
2417 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
2406 consistency. Now magics can be called in multiline statements,
2418 consistency. Now magics can be called in multiline statements,
2407 and python variables can be expanded in magic calls via $var.
2419 and python variables can be expanded in magic calls via $var.
2408 This makes the magic system behave just like aliases or !system
2420 This makes the magic system behave just like aliases or !system
2409 calls.
2421 calls.
2410
2422
2411 2005-03-28 Fernando Perez <fperez@colorado.edu>
2423 2005-03-28 Fernando Perez <fperez@colorado.edu>
2412
2424
2413 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
2425 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
2414 expensive string additions for building command. Add support for
2426 expensive string additions for building command. Add support for
2415 trailing ';' when autocall is used.
2427 trailing ';' when autocall is used.
2416
2428
2417 2005-03-26 Fernando Perez <fperez@colorado.edu>
2429 2005-03-26 Fernando Perez <fperez@colorado.edu>
2418
2430
2419 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
2431 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
2420 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
2432 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
2421 ipython.el robust against prompts with any number of spaces
2433 ipython.el robust against prompts with any number of spaces
2422 (including 0) after the ':' character.
2434 (including 0) after the ':' character.
2423
2435
2424 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
2436 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
2425 continuation prompt, which misled users to think the line was
2437 continuation prompt, which misled users to think the line was
2426 already indented. Closes debian Bug#300847, reported to me by
2438 already indented. Closes debian Bug#300847, reported to me by
2427 Norbert Tretkowski <tretkowski-AT-inittab.de>.
2439 Norbert Tretkowski <tretkowski-AT-inittab.de>.
2428
2440
2429 2005-03-23 Fernando Perez <fperez@colorado.edu>
2441 2005-03-23 Fernando Perez <fperez@colorado.edu>
2430
2442
2431 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
2443 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
2432 properly aligned if they have embedded newlines.
2444 properly aligned if they have embedded newlines.
2433
2445
2434 * IPython/iplib.py (runlines): Add a public method to expose
2446 * IPython/iplib.py (runlines): Add a public method to expose
2435 IPython's code execution machinery, so that users can run strings
2447 IPython's code execution machinery, so that users can run strings
2436 as if they had been typed at the prompt interactively.
2448 as if they had been typed at the prompt interactively.
2437 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
2449 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
2438 methods which can call the system shell, but with python variable
2450 methods which can call the system shell, but with python variable
2439 expansion. The three such methods are: __IPYTHON__.system,
2451 expansion. The three such methods are: __IPYTHON__.system,
2440 .getoutput and .getoutputerror. These need to be documented in a
2452 .getoutput and .getoutputerror. These need to be documented in a
2441 'public API' section (to be written) of the manual.
2453 'public API' section (to be written) of the manual.
2442
2454
2443 2005-03-20 Fernando Perez <fperez@colorado.edu>
2455 2005-03-20 Fernando Perez <fperez@colorado.edu>
2444
2456
2445 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
2457 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
2446 for custom exception handling. This is quite powerful, and it
2458 for custom exception handling. This is quite powerful, and it
2447 allows for user-installable exception handlers which can trap
2459 allows for user-installable exception handlers which can trap
2448 custom exceptions at runtime and treat them separately from
2460 custom exceptions at runtime and treat them separately from
2449 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
2461 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
2450 Mantegazza <mantegazza-AT-ill.fr>.
2462 Mantegazza <mantegazza-AT-ill.fr>.
2451 (InteractiveShell.set_custom_completer): public API function to
2463 (InteractiveShell.set_custom_completer): public API function to
2452 add new completers at runtime.
2464 add new completers at runtime.
2453
2465
2454 2005-03-19 Fernando Perez <fperez@colorado.edu>
2466 2005-03-19 Fernando Perez <fperez@colorado.edu>
2455
2467
2456 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
2468 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
2457 allow objects which provide their docstrings via non-standard
2469 allow objects which provide their docstrings via non-standard
2458 mechanisms (like Pyro proxies) to still be inspected by ipython's
2470 mechanisms (like Pyro proxies) to still be inspected by ipython's
2459 ? system.
2471 ? system.
2460
2472
2461 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
2473 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
2462 automatic capture system. I tried quite hard to make it work
2474 automatic capture system. I tried quite hard to make it work
2463 reliably, and simply failed. I tried many combinations with the
2475 reliably, and simply failed. I tried many combinations with the
2464 subprocess module, but eventually nothing worked in all needed
2476 subprocess module, but eventually nothing worked in all needed
2465 cases (not blocking stdin for the child, duplicating stdout
2477 cases (not blocking stdin for the child, duplicating stdout
2466 without blocking, etc). The new %sc/%sx still do capture to these
2478 without blocking, etc). The new %sc/%sx still do capture to these
2467 magical list/string objects which make shell use much more
2479 magical list/string objects which make shell use much more
2468 conveninent, so not all is lost.
2480 conveninent, so not all is lost.
2469
2481
2470 XXX - FIX MANUAL for the change above!
2482 XXX - FIX MANUAL for the change above!
2471
2483
2472 (runsource): I copied code.py's runsource() into ipython to modify
2484 (runsource): I copied code.py's runsource() into ipython to modify
2473 it a bit. Now the code object and source to be executed are
2485 it a bit. Now the code object and source to be executed are
2474 stored in ipython. This makes this info accessible to third-party
2486 stored in ipython. This makes this info accessible to third-party
2475 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
2487 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
2476 Mantegazza <mantegazza-AT-ill.fr>.
2488 Mantegazza <mantegazza-AT-ill.fr>.
2477
2489
2478 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
2490 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
2479 history-search via readline (like C-p/C-n). I'd wanted this for a
2491 history-search via readline (like C-p/C-n). I'd wanted this for a
2480 long time, but only recently found out how to do it. For users
2492 long time, but only recently found out how to do it. For users
2481 who already have their ipythonrc files made and want this, just
2493 who already have their ipythonrc files made and want this, just
2482 add:
2494 add:
2483
2495
2484 readline_parse_and_bind "\e[A": history-search-backward
2496 readline_parse_and_bind "\e[A": history-search-backward
2485 readline_parse_and_bind "\e[B": history-search-forward
2497 readline_parse_and_bind "\e[B": history-search-forward
2486
2498
2487 2005-03-18 Fernando Perez <fperez@colorado.edu>
2499 2005-03-18 Fernando Perez <fperez@colorado.edu>
2488
2500
2489 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
2501 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
2490 LSString and SList classes which allow transparent conversions
2502 LSString and SList classes which allow transparent conversions
2491 between list mode and whitespace-separated string.
2503 between list mode and whitespace-separated string.
2492 (magic_r): Fix recursion problem in %r.
2504 (magic_r): Fix recursion problem in %r.
2493
2505
2494 * IPython/genutils.py (LSString): New class to be used for
2506 * IPython/genutils.py (LSString): New class to be used for
2495 automatic storage of the results of all alias/system calls in _o
2507 automatic storage of the results of all alias/system calls in _o
2496 and _e (stdout/err). These provide a .l/.list attribute which
2508 and _e (stdout/err). These provide a .l/.list attribute which
2497 does automatic splitting on newlines. This means that for most
2509 does automatic splitting on newlines. This means that for most
2498 uses, you'll never need to do capturing of output with %sc/%sx
2510 uses, you'll never need to do capturing of output with %sc/%sx
2499 anymore, since ipython keeps this always done for you. Note that
2511 anymore, since ipython keeps this always done for you. Note that
2500 only the LAST results are stored, the _o/e variables are
2512 only the LAST results are stored, the _o/e variables are
2501 overwritten on each call. If you need to save their contents
2513 overwritten on each call. If you need to save their contents
2502 further, simply bind them to any other name.
2514 further, simply bind them to any other name.
2503
2515
2504 2005-03-17 Fernando Perez <fperez@colorado.edu>
2516 2005-03-17 Fernando Perez <fperez@colorado.edu>
2505
2517
2506 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
2518 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
2507 prompt namespace handling.
2519 prompt namespace handling.
2508
2520
2509 2005-03-16 Fernando Perez <fperez@colorado.edu>
2521 2005-03-16 Fernando Perez <fperez@colorado.edu>
2510
2522
2511 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
2523 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
2512 classic prompts to be '>>> ' (final space was missing, and it
2524 classic prompts to be '>>> ' (final space was missing, and it
2513 trips the emacs python mode).
2525 trips the emacs python mode).
2514 (BasePrompt.__str__): Added safe support for dynamic prompt
2526 (BasePrompt.__str__): Added safe support for dynamic prompt
2515 strings. Now you can set your prompt string to be '$x', and the
2527 strings. Now you can set your prompt string to be '$x', and the
2516 value of x will be printed from your interactive namespace. The
2528 value of x will be printed from your interactive namespace. The
2517 interpolation syntax includes the full Itpl support, so
2529 interpolation syntax includes the full Itpl support, so
2518 ${foo()+x+bar()} is a valid prompt string now, and the function
2530 ${foo()+x+bar()} is a valid prompt string now, and the function
2519 calls will be made at runtime.
2531 calls will be made at runtime.
2520
2532
2521 2005-03-15 Fernando Perez <fperez@colorado.edu>
2533 2005-03-15 Fernando Perez <fperez@colorado.edu>
2522
2534
2523 * IPython/Magic.py (magic_history): renamed %hist to %history, to
2535 * IPython/Magic.py (magic_history): renamed %hist to %history, to
2524 avoid name clashes in pylab. %hist still works, it just forwards
2536 avoid name clashes in pylab. %hist still works, it just forwards
2525 the call to %history.
2537 the call to %history.
2526
2538
2527 2005-03-02 *** Released version 0.6.12
2539 2005-03-02 *** Released version 0.6.12
2528
2540
2529 2005-03-02 Fernando Perez <fperez@colorado.edu>
2541 2005-03-02 Fernando Perez <fperez@colorado.edu>
2530
2542
2531 * IPython/iplib.py (handle_magic): log magic calls properly as
2543 * IPython/iplib.py (handle_magic): log magic calls properly as
2532 ipmagic() function calls.
2544 ipmagic() function calls.
2533
2545
2534 * IPython/Magic.py (magic_time): Improved %time to support
2546 * IPython/Magic.py (magic_time): Improved %time to support
2535 statements and provide wall-clock as well as CPU time.
2547 statements and provide wall-clock as well as CPU time.
2536
2548
2537 2005-02-27 Fernando Perez <fperez@colorado.edu>
2549 2005-02-27 Fernando Perez <fperez@colorado.edu>
2538
2550
2539 * IPython/hooks.py: New hooks module, to expose user-modifiable
2551 * IPython/hooks.py: New hooks module, to expose user-modifiable
2540 IPython functionality in a clean manner. For now only the editor
2552 IPython functionality in a clean manner. For now only the editor
2541 hook is actually written, and other thigns which I intend to turn
2553 hook is actually written, and other thigns which I intend to turn
2542 into proper hooks aren't yet there. The display and prefilter
2554 into proper hooks aren't yet there. The display and prefilter
2543 stuff, for example, should be hooks. But at least now the
2555 stuff, for example, should be hooks. But at least now the
2544 framework is in place, and the rest can be moved here with more
2556 framework is in place, and the rest can be moved here with more
2545 time later. IPython had had a .hooks variable for a long time for
2557 time later. IPython had had a .hooks variable for a long time for
2546 this purpose, but I'd never actually used it for anything.
2558 this purpose, but I'd never actually used it for anything.
2547
2559
2548 2005-02-26 Fernando Perez <fperez@colorado.edu>
2560 2005-02-26 Fernando Perez <fperez@colorado.edu>
2549
2561
2550 * IPython/ipmaker.py (make_IPython): make the default ipython
2562 * IPython/ipmaker.py (make_IPython): make the default ipython
2551 directory be called _ipython under win32, to follow more the
2563 directory be called _ipython under win32, to follow more the
2552 naming peculiarities of that platform (where buggy software like
2564 naming peculiarities of that platform (where buggy software like
2553 Visual Sourcesafe breaks with .named directories). Reported by
2565 Visual Sourcesafe breaks with .named directories). Reported by
2554 Ville Vainio.
2566 Ville Vainio.
2555
2567
2556 2005-02-23 Fernando Perez <fperez@colorado.edu>
2568 2005-02-23 Fernando Perez <fperez@colorado.edu>
2557
2569
2558 * IPython/iplib.py (InteractiveShell.__init__): removed a few
2570 * IPython/iplib.py (InteractiveShell.__init__): removed a few
2559 auto_aliases for win32 which were causing problems. Users can
2571 auto_aliases for win32 which were causing problems. Users can
2560 define the ones they personally like.
2572 define the ones they personally like.
2561
2573
2562 2005-02-21 Fernando Perez <fperez@colorado.edu>
2574 2005-02-21 Fernando Perez <fperez@colorado.edu>
2563
2575
2564 * IPython/Magic.py (magic_time): new magic to time execution of
2576 * IPython/Magic.py (magic_time): new magic to time execution of
2565 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
2577 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
2566
2578
2567 2005-02-19 Fernando Perez <fperez@colorado.edu>
2579 2005-02-19 Fernando Perez <fperez@colorado.edu>
2568
2580
2569 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
2581 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
2570 into keys (for prompts, for example).
2582 into keys (for prompts, for example).
2571
2583
2572 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
2584 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
2573 prompts in case users want them. This introduces a small behavior
2585 prompts in case users want them. This introduces a small behavior
2574 change: ipython does not automatically add a space to all prompts
2586 change: ipython does not automatically add a space to all prompts
2575 anymore. To get the old prompts with a space, users should add it
2587 anymore. To get the old prompts with a space, users should add it
2576 manually to their ipythonrc file, so for example prompt_in1 should
2588 manually to their ipythonrc file, so for example prompt_in1 should
2577 now read 'In [\#]: ' instead of 'In [\#]:'.
2589 now read 'In [\#]: ' instead of 'In [\#]:'.
2578 (BasePrompt.__init__): New option prompts_pad_left (only in rc
2590 (BasePrompt.__init__): New option prompts_pad_left (only in rc
2579 file) to control left-padding of secondary prompts.
2591 file) to control left-padding of secondary prompts.
2580
2592
2581 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
2593 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
2582 the profiler can't be imported. Fix for Debian, which removed
2594 the profiler can't be imported. Fix for Debian, which removed
2583 profile.py because of License issues. I applied a slightly
2595 profile.py because of License issues. I applied a slightly
2584 modified version of the original Debian patch at
2596 modified version of the original Debian patch at
2585 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
2597 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
2586
2598
2587 2005-02-17 Fernando Perez <fperez@colorado.edu>
2599 2005-02-17 Fernando Perez <fperez@colorado.edu>
2588
2600
2589 * IPython/genutils.py (native_line_ends): Fix bug which would
2601 * IPython/genutils.py (native_line_ends): Fix bug which would
2590 cause improper line-ends under win32 b/c I was not opening files
2602 cause improper line-ends under win32 b/c I was not opening files
2591 in binary mode. Bug report and fix thanks to Ville.
2603 in binary mode. Bug report and fix thanks to Ville.
2592
2604
2593 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
2605 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
2594 trying to catch spurious foo[1] autocalls. My fix actually broke
2606 trying to catch spurious foo[1] autocalls. My fix actually broke
2595 ',/' autoquote/call with explicit escape (bad regexp).
2607 ',/' autoquote/call with explicit escape (bad regexp).
2596
2608
2597 2005-02-15 *** Released version 0.6.11
2609 2005-02-15 *** Released version 0.6.11
2598
2610
2599 2005-02-14 Fernando Perez <fperez@colorado.edu>
2611 2005-02-14 Fernando Perez <fperez@colorado.edu>
2600
2612
2601 * IPython/background_jobs.py: New background job management
2613 * IPython/background_jobs.py: New background job management
2602 subsystem. This is implemented via a new set of classes, and
2614 subsystem. This is implemented via a new set of classes, and
2603 IPython now provides a builtin 'jobs' object for background job
2615 IPython now provides a builtin 'jobs' object for background job
2604 execution. A convenience %bg magic serves as a lightweight
2616 execution. A convenience %bg magic serves as a lightweight
2605 frontend for starting the more common type of calls. This was
2617 frontend for starting the more common type of calls. This was
2606 inspired by discussions with B. Granger and the BackgroundCommand
2618 inspired by discussions with B. Granger and the BackgroundCommand
2607 class described in the book Python Scripting for Computational
2619 class described in the book Python Scripting for Computational
2608 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
2620 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
2609 (although ultimately no code from this text was used, as IPython's
2621 (although ultimately no code from this text was used, as IPython's
2610 system is a separate implementation).
2622 system is a separate implementation).
2611
2623
2612 * IPython/iplib.py (MagicCompleter.python_matches): add new option
2624 * IPython/iplib.py (MagicCompleter.python_matches): add new option
2613 to control the completion of single/double underscore names
2625 to control the completion of single/double underscore names
2614 separately. As documented in the example ipytonrc file, the
2626 separately. As documented in the example ipytonrc file, the
2615 readline_omit__names variable can now be set to 2, to omit even
2627 readline_omit__names variable can now be set to 2, to omit even
2616 single underscore names. Thanks to a patch by Brian Wong
2628 single underscore names. Thanks to a patch by Brian Wong
2617 <BrianWong-AT-AirgoNetworks.Com>.
2629 <BrianWong-AT-AirgoNetworks.Com>.
2618 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
2630 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
2619 be autocalled as foo([1]) if foo were callable. A problem for
2631 be autocalled as foo([1]) if foo were callable. A problem for
2620 things which are both callable and implement __getitem__.
2632 things which are both callable and implement __getitem__.
2621 (init_readline): Fix autoindentation for win32. Thanks to a patch
2633 (init_readline): Fix autoindentation for win32. Thanks to a patch
2622 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
2634 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
2623
2635
2624 2005-02-12 Fernando Perez <fperez@colorado.edu>
2636 2005-02-12 Fernando Perez <fperez@colorado.edu>
2625
2637
2626 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
2638 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
2627 which I had written long ago to sort out user error messages which
2639 which I had written long ago to sort out user error messages which
2628 may occur during startup. This seemed like a good idea initially,
2640 may occur during startup. This seemed like a good idea initially,
2629 but it has proven a disaster in retrospect. I don't want to
2641 but it has proven a disaster in retrospect. I don't want to
2630 change much code for now, so my fix is to set the internal 'debug'
2642 change much code for now, so my fix is to set the internal 'debug'
2631 flag to true everywhere, whose only job was precisely to control
2643 flag to true everywhere, whose only job was precisely to control
2632 this subsystem. This closes issue 28 (as well as avoiding all
2644 this subsystem. This closes issue 28 (as well as avoiding all
2633 sorts of strange hangups which occur from time to time).
2645 sorts of strange hangups which occur from time to time).
2634
2646
2635 2005-02-07 Fernando Perez <fperez@colorado.edu>
2647 2005-02-07 Fernando Perez <fperez@colorado.edu>
2636
2648
2637 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
2649 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
2638 previous call produced a syntax error.
2650 previous call produced a syntax error.
2639
2651
2640 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
2652 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
2641 classes without constructor.
2653 classes without constructor.
2642
2654
2643 2005-02-06 Fernando Perez <fperez@colorado.edu>
2655 2005-02-06 Fernando Perez <fperez@colorado.edu>
2644
2656
2645 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
2657 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
2646 completions with the results of each matcher, so we return results
2658 completions with the results of each matcher, so we return results
2647 to the user from all namespaces. This breaks with ipython
2659 to the user from all namespaces. This breaks with ipython
2648 tradition, but I think it's a nicer behavior. Now you get all
2660 tradition, but I think it's a nicer behavior. Now you get all
2649 possible completions listed, from all possible namespaces (python,
2661 possible completions listed, from all possible namespaces (python,
2650 filesystem, magics...) After a request by John Hunter
2662 filesystem, magics...) After a request by John Hunter
2651 <jdhunter-AT-nitace.bsd.uchicago.edu>.
2663 <jdhunter-AT-nitace.bsd.uchicago.edu>.
2652
2664
2653 2005-02-05 Fernando Perez <fperez@colorado.edu>
2665 2005-02-05 Fernando Perez <fperez@colorado.edu>
2654
2666
2655 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
2667 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
2656 the call had quote characters in it (the quotes were stripped).
2668 the call had quote characters in it (the quotes were stripped).
2657
2669
2658 2005-01-31 Fernando Perez <fperez@colorado.edu>
2670 2005-01-31 Fernando Perez <fperez@colorado.edu>
2659
2671
2660 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
2672 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
2661 Itpl.itpl() to make the code more robust against psyco
2673 Itpl.itpl() to make the code more robust against psyco
2662 optimizations.
2674 optimizations.
2663
2675
2664 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
2676 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
2665 of causing an exception. Quicker, cleaner.
2677 of causing an exception. Quicker, cleaner.
2666
2678
2667 2005-01-28 Fernando Perez <fperez@colorado.edu>
2679 2005-01-28 Fernando Perez <fperez@colorado.edu>
2668
2680
2669 * scripts/ipython_win_post_install.py (install): hardcode
2681 * scripts/ipython_win_post_install.py (install): hardcode
2670 sys.prefix+'python.exe' as the executable path. It turns out that
2682 sys.prefix+'python.exe' as the executable path. It turns out that
2671 during the post-installation run, sys.executable resolves to the
2683 during the post-installation run, sys.executable resolves to the
2672 name of the binary installer! I should report this as a distutils
2684 name of the binary installer! I should report this as a distutils
2673 bug, I think. I updated the .10 release with this tiny fix, to
2685 bug, I think. I updated the .10 release with this tiny fix, to
2674 avoid annoying the lists further.
2686 avoid annoying the lists further.
2675
2687
2676 2005-01-27 *** Released version 0.6.10
2688 2005-01-27 *** Released version 0.6.10
2677
2689
2678 2005-01-27 Fernando Perez <fperez@colorado.edu>
2690 2005-01-27 Fernando Perez <fperez@colorado.edu>
2679
2691
2680 * IPython/numutils.py (norm): Added 'inf' as optional name for
2692 * IPython/numutils.py (norm): Added 'inf' as optional name for
2681 L-infinity norm, included references to mathworld.com for vector
2693 L-infinity norm, included references to mathworld.com for vector
2682 norm definitions.
2694 norm definitions.
2683 (amin/amax): added amin/amax for array min/max. Similar to what
2695 (amin/amax): added amin/amax for array min/max. Similar to what
2684 pylab ships with after the recent reorganization of names.
2696 pylab ships with after the recent reorganization of names.
2685 (spike/spike_odd): removed deprecated spike/spike_odd functions.
2697 (spike/spike_odd): removed deprecated spike/spike_odd functions.
2686
2698
2687 * ipython.el: committed Alex's recent fixes and improvements.
2699 * ipython.el: committed Alex's recent fixes and improvements.
2688 Tested with python-mode from CVS, and it looks excellent. Since
2700 Tested with python-mode from CVS, and it looks excellent. Since
2689 python-mode hasn't released anything in a while, I'm temporarily
2701 python-mode hasn't released anything in a while, I'm temporarily
2690 putting a copy of today's CVS (v 4.70) of python-mode in:
2702 putting a copy of today's CVS (v 4.70) of python-mode in:
2691 http://ipython.scipy.org/tmp/python-mode.el
2703 http://ipython.scipy.org/tmp/python-mode.el
2692
2704
2693 * scripts/ipython_win_post_install.py (install): Win32 fix to use
2705 * scripts/ipython_win_post_install.py (install): Win32 fix to use
2694 sys.executable for the executable name, instead of assuming it's
2706 sys.executable for the executable name, instead of assuming it's
2695 called 'python.exe' (the post-installer would have produced broken
2707 called 'python.exe' (the post-installer would have produced broken
2696 setups on systems with a differently named python binary).
2708 setups on systems with a differently named python binary).
2697
2709
2698 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
2710 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
2699 references to os.linesep, to make the code more
2711 references to os.linesep, to make the code more
2700 platform-independent. This is also part of the win32 coloring
2712 platform-independent. This is also part of the win32 coloring
2701 fixes.
2713 fixes.
2702
2714
2703 * IPython/genutils.py (page_dumb): Remove attempts to chop long
2715 * IPython/genutils.py (page_dumb): Remove attempts to chop long
2704 lines, which actually cause coloring bugs because the length of
2716 lines, which actually cause coloring bugs because the length of
2705 the line is very difficult to correctly compute with embedded
2717 the line is very difficult to correctly compute with embedded
2706 escapes. This was the source of all the coloring problems under
2718 escapes. This was the source of all the coloring problems under
2707 Win32. I think that _finally_, Win32 users have a properly
2719 Win32. I think that _finally_, Win32 users have a properly
2708 working ipython in all respects. This would never have happened
2720 working ipython in all respects. This would never have happened
2709 if not for Gary Bishop and Viktor Ransmayr's great help and work.
2721 if not for Gary Bishop and Viktor Ransmayr's great help and work.
2710
2722
2711 2005-01-26 *** Released version 0.6.9
2723 2005-01-26 *** Released version 0.6.9
2712
2724
2713 2005-01-25 Fernando Perez <fperez@colorado.edu>
2725 2005-01-25 Fernando Perez <fperez@colorado.edu>
2714
2726
2715 * setup.py: finally, we have a true Windows installer, thanks to
2727 * setup.py: finally, we have a true Windows installer, thanks to
2716 the excellent work of Viktor Ransmayr
2728 the excellent work of Viktor Ransmayr
2717 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
2729 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
2718 Windows users. The setup routine is quite a bit cleaner thanks to
2730 Windows users. The setup routine is quite a bit cleaner thanks to
2719 this, and the post-install script uses the proper functions to
2731 this, and the post-install script uses the proper functions to
2720 allow a clean de-installation using the standard Windows Control
2732 allow a clean de-installation using the standard Windows Control
2721 Panel.
2733 Panel.
2722
2734
2723 * IPython/genutils.py (get_home_dir): changed to use the $HOME
2735 * IPython/genutils.py (get_home_dir): changed to use the $HOME
2724 environment variable under all OSes (including win32) if
2736 environment variable under all OSes (including win32) if
2725 available. This will give consistency to win32 users who have set
2737 available. This will give consistency to win32 users who have set
2726 this variable for any reason. If os.environ['HOME'] fails, the
2738 this variable for any reason. If os.environ['HOME'] fails, the
2727 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
2739 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
2728
2740
2729 2005-01-24 Fernando Perez <fperez@colorado.edu>
2741 2005-01-24 Fernando Perez <fperez@colorado.edu>
2730
2742
2731 * IPython/numutils.py (empty_like): add empty_like(), similar to
2743 * IPython/numutils.py (empty_like): add empty_like(), similar to
2732 zeros_like() but taking advantage of the new empty() Numeric routine.
2744 zeros_like() but taking advantage of the new empty() Numeric routine.
2733
2745
2734 2005-01-23 *** Released version 0.6.8
2746 2005-01-23 *** Released version 0.6.8
2735
2747
2736 2005-01-22 Fernando Perez <fperez@colorado.edu>
2748 2005-01-22 Fernando Perez <fperez@colorado.edu>
2737
2749
2738 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
2750 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
2739 automatic show() calls. After discussing things with JDH, it
2751 automatic show() calls. After discussing things with JDH, it
2740 turns out there are too many corner cases where this can go wrong.
2752 turns out there are too many corner cases where this can go wrong.
2741 It's best not to try to be 'too smart', and simply have ipython
2753 It's best not to try to be 'too smart', and simply have ipython
2742 reproduce as much as possible the default behavior of a normal
2754 reproduce as much as possible the default behavior of a normal
2743 python shell.
2755 python shell.
2744
2756
2745 * IPython/iplib.py (InteractiveShell.__init__): Modified the
2757 * IPython/iplib.py (InteractiveShell.__init__): Modified the
2746 line-splitting regexp and _prefilter() to avoid calling getattr()
2758 line-splitting regexp and _prefilter() to avoid calling getattr()
2747 on assignments. This closes
2759 on assignments. This closes
2748 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
2760 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
2749 readline uses getattr(), so a simple <TAB> keypress is still
2761 readline uses getattr(), so a simple <TAB> keypress is still
2750 enough to trigger getattr() calls on an object.
2762 enough to trigger getattr() calls on an object.
2751
2763
2752 2005-01-21 Fernando Perez <fperez@colorado.edu>
2764 2005-01-21 Fernando Perez <fperez@colorado.edu>
2753
2765
2754 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
2766 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
2755 docstring under pylab so it doesn't mask the original.
2767 docstring under pylab so it doesn't mask the original.
2756
2768
2757 2005-01-21 *** Released version 0.6.7
2769 2005-01-21 *** Released version 0.6.7
2758
2770
2759 2005-01-21 Fernando Perez <fperez@colorado.edu>
2771 2005-01-21 Fernando Perez <fperez@colorado.edu>
2760
2772
2761 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
2773 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
2762 signal handling for win32 users in multithreaded mode.
2774 signal handling for win32 users in multithreaded mode.
2763
2775
2764 2005-01-17 Fernando Perez <fperez@colorado.edu>
2776 2005-01-17 Fernando Perez <fperez@colorado.edu>
2765
2777
2766 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
2778 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
2767 instances with no __init__. After a crash report by Norbert Nemec
2779 instances with no __init__. After a crash report by Norbert Nemec
2768 <Norbert-AT-nemec-online.de>.
2780 <Norbert-AT-nemec-online.de>.
2769
2781
2770 2005-01-14 Fernando Perez <fperez@colorado.edu>
2782 2005-01-14 Fernando Perez <fperez@colorado.edu>
2771
2783
2772 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
2784 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
2773 names for verbose exceptions, when multiple dotted names and the
2785 names for verbose exceptions, when multiple dotted names and the
2774 'parent' object were present on the same line.
2786 'parent' object were present on the same line.
2775
2787
2776 2005-01-11 Fernando Perez <fperez@colorado.edu>
2788 2005-01-11 Fernando Perez <fperez@colorado.edu>
2777
2789
2778 * IPython/genutils.py (flag_calls): new utility to trap and flag
2790 * IPython/genutils.py (flag_calls): new utility to trap and flag
2779 calls in functions. I need it to clean up matplotlib support.
2791 calls in functions. I need it to clean up matplotlib support.
2780 Also removed some deprecated code in genutils.
2792 Also removed some deprecated code in genutils.
2781
2793
2782 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
2794 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
2783 that matplotlib scripts called with %run, which don't call show()
2795 that matplotlib scripts called with %run, which don't call show()
2784 themselves, still have their plotting windows open.
2796 themselves, still have their plotting windows open.
2785
2797
2786 2005-01-05 Fernando Perez <fperez@colorado.edu>
2798 2005-01-05 Fernando Perez <fperez@colorado.edu>
2787
2799
2788 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
2800 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
2789 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
2801 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
2790
2802
2791 2004-12-19 Fernando Perez <fperez@colorado.edu>
2803 2004-12-19 Fernando Perez <fperez@colorado.edu>
2792
2804
2793 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
2805 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
2794 parent_runcode, which was an eyesore. The same result can be
2806 parent_runcode, which was an eyesore. The same result can be
2795 obtained with Python's regular superclass mechanisms.
2807 obtained with Python's regular superclass mechanisms.
2796
2808
2797 2004-12-17 Fernando Perez <fperez@colorado.edu>
2809 2004-12-17 Fernando Perez <fperez@colorado.edu>
2798
2810
2799 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
2811 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
2800 reported by Prabhu.
2812 reported by Prabhu.
2801 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
2813 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
2802 sys.stderr) instead of explicitly calling sys.stderr. This helps
2814 sys.stderr) instead of explicitly calling sys.stderr. This helps
2803 maintain our I/O abstractions clean, for future GUI embeddings.
2815 maintain our I/O abstractions clean, for future GUI embeddings.
2804
2816
2805 * IPython/genutils.py (info): added new utility for sys.stderr
2817 * IPython/genutils.py (info): added new utility for sys.stderr
2806 unified info message handling (thin wrapper around warn()).
2818 unified info message handling (thin wrapper around warn()).
2807
2819
2808 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
2820 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
2809 composite (dotted) names on verbose exceptions.
2821 composite (dotted) names on verbose exceptions.
2810 (VerboseTB.nullrepr): harden against another kind of errors which
2822 (VerboseTB.nullrepr): harden against another kind of errors which
2811 Python's inspect module can trigger, and which were crashing
2823 Python's inspect module can trigger, and which were crashing
2812 IPython. Thanks to a report by Marco Lombardi
2824 IPython. Thanks to a report by Marco Lombardi
2813 <mlombard-AT-ma010192.hq.eso.org>.
2825 <mlombard-AT-ma010192.hq.eso.org>.
2814
2826
2815 2004-12-13 *** Released version 0.6.6
2827 2004-12-13 *** Released version 0.6.6
2816
2828
2817 2004-12-12 Fernando Perez <fperez@colorado.edu>
2829 2004-12-12 Fernando Perez <fperez@colorado.edu>
2818
2830
2819 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
2831 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
2820 generated by pygtk upon initialization if it was built without
2832 generated by pygtk upon initialization if it was built without
2821 threads (for matplotlib users). After a crash reported by
2833 threads (for matplotlib users). After a crash reported by
2822 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
2834 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
2823
2835
2824 * IPython/ipmaker.py (make_IPython): fix small bug in the
2836 * IPython/ipmaker.py (make_IPython): fix small bug in the
2825 import_some parameter for multiple imports.
2837 import_some parameter for multiple imports.
2826
2838
2827 * IPython/iplib.py (ipmagic): simplified the interface of
2839 * IPython/iplib.py (ipmagic): simplified the interface of
2828 ipmagic() to take a single string argument, just as it would be
2840 ipmagic() to take a single string argument, just as it would be
2829 typed at the IPython cmd line.
2841 typed at the IPython cmd line.
2830 (ipalias): Added new ipalias() with an interface identical to
2842 (ipalias): Added new ipalias() with an interface identical to
2831 ipmagic(). This completes exposing a pure python interface to the
2843 ipmagic(). This completes exposing a pure python interface to the
2832 alias and magic system, which can be used in loops or more complex
2844 alias and magic system, which can be used in loops or more complex
2833 code where IPython's automatic line mangling is not active.
2845 code where IPython's automatic line mangling is not active.
2834
2846
2835 * IPython/genutils.py (timing): changed interface of timing to
2847 * IPython/genutils.py (timing): changed interface of timing to
2836 simply run code once, which is the most common case. timings()
2848 simply run code once, which is the most common case. timings()
2837 remains unchanged, for the cases where you want multiple runs.
2849 remains unchanged, for the cases where you want multiple runs.
2838
2850
2839 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
2851 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
2840 bug where Python2.2 crashes with exec'ing code which does not end
2852 bug where Python2.2 crashes with exec'ing code which does not end
2841 in a single newline. Python 2.3 is OK, so I hadn't noticed this
2853 in a single newline. Python 2.3 is OK, so I hadn't noticed this
2842 before.
2854 before.
2843
2855
2844 2004-12-10 Fernando Perez <fperez@colorado.edu>
2856 2004-12-10 Fernando Perez <fperez@colorado.edu>
2845
2857
2846 * IPython/Magic.py (Magic.magic_prun): changed name of option from
2858 * IPython/Magic.py (Magic.magic_prun): changed name of option from
2847 -t to -T, to accomodate the new -t flag in %run (the %run and
2859 -t to -T, to accomodate the new -t flag in %run (the %run and
2848 %prun options are kind of intermixed, and it's not easy to change
2860 %prun options are kind of intermixed, and it's not easy to change
2849 this with the limitations of python's getopt).
2861 this with the limitations of python's getopt).
2850
2862
2851 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
2863 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
2852 the execution of scripts. It's not as fine-tuned as timeit.py,
2864 the execution of scripts. It's not as fine-tuned as timeit.py,
2853 but it works from inside ipython (and under 2.2, which lacks
2865 but it works from inside ipython (and under 2.2, which lacks
2854 timeit.py). Optionally a number of runs > 1 can be given for
2866 timeit.py). Optionally a number of runs > 1 can be given for
2855 timing very short-running code.
2867 timing very short-running code.
2856
2868
2857 * IPython/genutils.py (uniq_stable): new routine which returns a
2869 * IPython/genutils.py (uniq_stable): new routine which returns a
2858 list of unique elements in any iterable, but in stable order of
2870 list of unique elements in any iterable, but in stable order of
2859 appearance. I needed this for the ultraTB fixes, and it's a handy
2871 appearance. I needed this for the ultraTB fixes, and it's a handy
2860 utility.
2872 utility.
2861
2873
2862 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
2874 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
2863 dotted names in Verbose exceptions. This had been broken since
2875 dotted names in Verbose exceptions. This had been broken since
2864 the very start, now x.y will properly be printed in a Verbose
2876 the very start, now x.y will properly be printed in a Verbose
2865 traceback, instead of x being shown and y appearing always as an
2877 traceback, instead of x being shown and y appearing always as an
2866 'undefined global'. Getting this to work was a bit tricky,
2878 'undefined global'. Getting this to work was a bit tricky,
2867 because by default python tokenizers are stateless. Saved by
2879 because by default python tokenizers are stateless. Saved by
2868 python's ability to easily add a bit of state to an arbitrary
2880 python's ability to easily add a bit of state to an arbitrary
2869 function (without needing to build a full-blown callable object).
2881 function (without needing to build a full-blown callable object).
2870
2882
2871 Also big cleanup of this code, which had horrendous runtime
2883 Also big cleanup of this code, which had horrendous runtime
2872 lookups of zillions of attributes for colorization. Moved all
2884 lookups of zillions of attributes for colorization. Moved all
2873 this code into a few templates, which make it cleaner and quicker.
2885 this code into a few templates, which make it cleaner and quicker.
2874
2886
2875 Printout quality was also improved for Verbose exceptions: one
2887 Printout quality was also improved for Verbose exceptions: one
2876 variable per line, and memory addresses are printed (this can be
2888 variable per line, and memory addresses are printed (this can be
2877 quite handy in nasty debugging situations, which is what Verbose
2889 quite handy in nasty debugging situations, which is what Verbose
2878 is for).
2890 is for).
2879
2891
2880 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
2892 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
2881 the command line as scripts to be loaded by embedded instances.
2893 the command line as scripts to be loaded by embedded instances.
2882 Doing so has the potential for an infinite recursion if there are
2894 Doing so has the potential for an infinite recursion if there are
2883 exceptions thrown in the process. This fixes a strange crash
2895 exceptions thrown in the process. This fixes a strange crash
2884 reported by Philippe MULLER <muller-AT-irit.fr>.
2896 reported by Philippe MULLER <muller-AT-irit.fr>.
2885
2897
2886 2004-12-09 Fernando Perez <fperez@colorado.edu>
2898 2004-12-09 Fernando Perez <fperez@colorado.edu>
2887
2899
2888 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
2900 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
2889 to reflect new names in matplotlib, which now expose the
2901 to reflect new names in matplotlib, which now expose the
2890 matlab-compatible interface via a pylab module instead of the
2902 matlab-compatible interface via a pylab module instead of the
2891 'matlab' name. The new code is backwards compatible, so users of
2903 'matlab' name. The new code is backwards compatible, so users of
2892 all matplotlib versions are OK. Patch by J. Hunter.
2904 all matplotlib versions are OK. Patch by J. Hunter.
2893
2905
2894 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
2906 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
2895 of __init__ docstrings for instances (class docstrings are already
2907 of __init__ docstrings for instances (class docstrings are already
2896 automatically printed). Instances with customized docstrings
2908 automatically printed). Instances with customized docstrings
2897 (indep. of the class) are also recognized and all 3 separate
2909 (indep. of the class) are also recognized and all 3 separate
2898 docstrings are printed (instance, class, constructor). After some
2910 docstrings are printed (instance, class, constructor). After some
2899 comments/suggestions by J. Hunter.
2911 comments/suggestions by J. Hunter.
2900
2912
2901 2004-12-05 Fernando Perez <fperez@colorado.edu>
2913 2004-12-05 Fernando Perez <fperez@colorado.edu>
2902
2914
2903 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
2915 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
2904 warnings when tab-completion fails and triggers an exception.
2916 warnings when tab-completion fails and triggers an exception.
2905
2917
2906 2004-12-03 Fernando Perez <fperez@colorado.edu>
2918 2004-12-03 Fernando Perez <fperez@colorado.edu>
2907
2919
2908 * IPython/Magic.py (magic_prun): Fix bug where an exception would
2920 * IPython/Magic.py (magic_prun): Fix bug where an exception would
2909 be triggered when using 'run -p'. An incorrect option flag was
2921 be triggered when using 'run -p'. An incorrect option flag was
2910 being set ('d' instead of 'D').
2922 being set ('d' instead of 'D').
2911 (manpage): fix missing escaped \- sign.
2923 (manpage): fix missing escaped \- sign.
2912
2924
2913 2004-11-30 *** Released version 0.6.5
2925 2004-11-30 *** Released version 0.6.5
2914
2926
2915 2004-11-30 Fernando Perez <fperez@colorado.edu>
2927 2004-11-30 Fernando Perez <fperez@colorado.edu>
2916
2928
2917 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
2929 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
2918 setting with -d option.
2930 setting with -d option.
2919
2931
2920 * setup.py (docfiles): Fix problem where the doc glob I was using
2932 * setup.py (docfiles): Fix problem where the doc glob I was using
2921 was COMPLETELY BROKEN. It was giving the right files by pure
2933 was COMPLETELY BROKEN. It was giving the right files by pure
2922 accident, but failed once I tried to include ipython.el. Note:
2934 accident, but failed once I tried to include ipython.el. Note:
2923 glob() does NOT allow you to do exclusion on multiple endings!
2935 glob() does NOT allow you to do exclusion on multiple endings!
2924
2936
2925 2004-11-29 Fernando Perez <fperez@colorado.edu>
2937 2004-11-29 Fernando Perez <fperez@colorado.edu>
2926
2938
2927 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
2939 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
2928 the manpage as the source. Better formatting & consistency.
2940 the manpage as the source. Better formatting & consistency.
2929
2941
2930 * IPython/Magic.py (magic_run): Added new -d option, to run
2942 * IPython/Magic.py (magic_run): Added new -d option, to run
2931 scripts under the control of the python pdb debugger. Note that
2943 scripts under the control of the python pdb debugger. Note that
2932 this required changing the %prun option -d to -D, to avoid a clash
2944 this required changing the %prun option -d to -D, to avoid a clash
2933 (since %run must pass options to %prun, and getopt is too dumb to
2945 (since %run must pass options to %prun, and getopt is too dumb to
2934 handle options with string values with embedded spaces). Thanks
2946 handle options with string values with embedded spaces). Thanks
2935 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
2947 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
2936 (magic_who_ls): added type matching to %who and %whos, so that one
2948 (magic_who_ls): added type matching to %who and %whos, so that one
2937 can filter their output to only include variables of certain
2949 can filter their output to only include variables of certain
2938 types. Another suggestion by Matthew.
2950 types. Another suggestion by Matthew.
2939 (magic_whos): Added memory summaries in kb and Mb for arrays.
2951 (magic_whos): Added memory summaries in kb and Mb for arrays.
2940 (magic_who): Improve formatting (break lines every 9 vars).
2952 (magic_who): Improve formatting (break lines every 9 vars).
2941
2953
2942 2004-11-28 Fernando Perez <fperez@colorado.edu>
2954 2004-11-28 Fernando Perez <fperez@colorado.edu>
2943
2955
2944 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
2956 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
2945 cache when empty lines were present.
2957 cache when empty lines were present.
2946
2958
2947 2004-11-24 Fernando Perez <fperez@colorado.edu>
2959 2004-11-24 Fernando Perez <fperez@colorado.edu>
2948
2960
2949 * IPython/usage.py (__doc__): document the re-activated threading
2961 * IPython/usage.py (__doc__): document the re-activated threading
2950 options for WX and GTK.
2962 options for WX and GTK.
2951
2963
2952 2004-11-23 Fernando Perez <fperez@colorado.edu>
2964 2004-11-23 Fernando Perez <fperez@colorado.edu>
2953
2965
2954 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
2966 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
2955 the -wthread and -gthread options, along with a new -tk one to try
2967 the -wthread and -gthread options, along with a new -tk one to try
2956 and coordinate Tk threading with wx/gtk. The tk support is very
2968 and coordinate Tk threading with wx/gtk. The tk support is very
2957 platform dependent, since it seems to require Tcl and Tk to be
2969 platform dependent, since it seems to require Tcl and Tk to be
2958 built with threads (Fedora1/2 appears NOT to have it, but in
2970 built with threads (Fedora1/2 appears NOT to have it, but in
2959 Prabhu's Debian boxes it works OK). But even with some Tk
2971 Prabhu's Debian boxes it works OK). But even with some Tk
2960 limitations, this is a great improvement.
2972 limitations, this is a great improvement.
2961
2973
2962 * IPython/Prompts.py (prompt_specials_color): Added \t for time
2974 * IPython/Prompts.py (prompt_specials_color): Added \t for time
2963 info in user prompts. Patch by Prabhu.
2975 info in user prompts. Patch by Prabhu.
2964
2976
2965 2004-11-18 Fernando Perez <fperez@colorado.edu>
2977 2004-11-18 Fernando Perez <fperez@colorado.edu>
2966
2978
2967 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
2979 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
2968 EOFErrors and bail, to avoid infinite loops if a non-terminating
2980 EOFErrors and bail, to avoid infinite loops if a non-terminating
2969 file is fed into ipython. Patch submitted in issue 19 by user,
2981 file is fed into ipython. Patch submitted in issue 19 by user,
2970 many thanks.
2982 many thanks.
2971
2983
2972 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
2984 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
2973 autoquote/parens in continuation prompts, which can cause lots of
2985 autoquote/parens in continuation prompts, which can cause lots of
2974 problems. Closes roundup issue 20.
2986 problems. Closes roundup issue 20.
2975
2987
2976 2004-11-17 Fernando Perez <fperez@colorado.edu>
2988 2004-11-17 Fernando Perez <fperez@colorado.edu>
2977
2989
2978 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
2990 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
2979 reported as debian bug #280505. I'm not sure my local changelog
2991 reported as debian bug #280505. I'm not sure my local changelog
2980 entry has the proper debian format (Jack?).
2992 entry has the proper debian format (Jack?).
2981
2993
2982 2004-11-08 *** Released version 0.6.4
2994 2004-11-08 *** Released version 0.6.4
2983
2995
2984 2004-11-08 Fernando Perez <fperez@colorado.edu>
2996 2004-11-08 Fernando Perez <fperez@colorado.edu>
2985
2997
2986 * IPython/iplib.py (init_readline): Fix exit message for Windows
2998 * IPython/iplib.py (init_readline): Fix exit message for Windows
2987 when readline is active. Thanks to a report by Eric Jones
2999 when readline is active. Thanks to a report by Eric Jones
2988 <eric-AT-enthought.com>.
3000 <eric-AT-enthought.com>.
2989
3001
2990 2004-11-07 Fernando Perez <fperez@colorado.edu>
3002 2004-11-07 Fernando Perez <fperez@colorado.edu>
2991
3003
2992 * IPython/genutils.py (page): Add a trap for OSError exceptions,
3004 * IPython/genutils.py (page): Add a trap for OSError exceptions,
2993 sometimes seen by win2k/cygwin users.
3005 sometimes seen by win2k/cygwin users.
2994
3006
2995 2004-11-06 Fernando Perez <fperez@colorado.edu>
3007 2004-11-06 Fernando Perez <fperez@colorado.edu>
2996
3008
2997 * IPython/iplib.py (interact): Change the handling of %Exit from
3009 * IPython/iplib.py (interact): Change the handling of %Exit from
2998 trying to propagate a SystemExit to an internal ipython flag.
3010 trying to propagate a SystemExit to an internal ipython flag.
2999 This is less elegant than using Python's exception mechanism, but
3011 This is less elegant than using Python's exception mechanism, but
3000 I can't get that to work reliably with threads, so under -pylab
3012 I can't get that to work reliably with threads, so under -pylab
3001 %Exit was hanging IPython. Cross-thread exception handling is
3013 %Exit was hanging IPython. Cross-thread exception handling is
3002 really a bitch. Thaks to a bug report by Stephen Walton
3014 really a bitch. Thaks to a bug report by Stephen Walton
3003 <stephen.walton-AT-csun.edu>.
3015 <stephen.walton-AT-csun.edu>.
3004
3016
3005 2004-11-04 Fernando Perez <fperez@colorado.edu>
3017 2004-11-04 Fernando Perez <fperez@colorado.edu>
3006
3018
3007 * IPython/iplib.py (raw_input_original): store a pointer to the
3019 * IPython/iplib.py (raw_input_original): store a pointer to the
3008 true raw_input to harden against code which can modify it
3020 true raw_input to harden against code which can modify it
3009 (wx.py.PyShell does this and would otherwise crash ipython).
3021 (wx.py.PyShell does this and would otherwise crash ipython).
3010 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
3022 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
3011
3023
3012 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
3024 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
3013 Ctrl-C problem, which does not mess up the input line.
3025 Ctrl-C problem, which does not mess up the input line.
3014
3026
3015 2004-11-03 Fernando Perez <fperez@colorado.edu>
3027 2004-11-03 Fernando Perez <fperez@colorado.edu>
3016
3028
3017 * IPython/Release.py: Changed licensing to BSD, in all files.
3029 * IPython/Release.py: Changed licensing to BSD, in all files.
3018 (name): lowercase name for tarball/RPM release.
3030 (name): lowercase name for tarball/RPM release.
3019
3031
3020 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
3032 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
3021 use throughout ipython.
3033 use throughout ipython.
3022
3034
3023 * IPython/Magic.py (Magic._ofind): Switch to using the new
3035 * IPython/Magic.py (Magic._ofind): Switch to using the new
3024 OInspect.getdoc() function.
3036 OInspect.getdoc() function.
3025
3037
3026 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
3038 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
3027 of the line currently being canceled via Ctrl-C. It's extremely
3039 of the line currently being canceled via Ctrl-C. It's extremely
3028 ugly, but I don't know how to do it better (the problem is one of
3040 ugly, but I don't know how to do it better (the problem is one of
3029 handling cross-thread exceptions).
3041 handling cross-thread exceptions).
3030
3042
3031 2004-10-28 Fernando Perez <fperez@colorado.edu>
3043 2004-10-28 Fernando Perez <fperez@colorado.edu>
3032
3044
3033 * IPython/Shell.py (signal_handler): add signal handlers to trap
3045 * IPython/Shell.py (signal_handler): add signal handlers to trap
3034 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
3046 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
3035 report by Francesc Alted.
3047 report by Francesc Alted.
3036
3048
3037 2004-10-21 Fernando Perez <fperez@colorado.edu>
3049 2004-10-21 Fernando Perez <fperez@colorado.edu>
3038
3050
3039 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
3051 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
3040 to % for pysh syntax extensions.
3052 to % for pysh syntax extensions.
3041
3053
3042 2004-10-09 Fernando Perez <fperez@colorado.edu>
3054 2004-10-09 Fernando Perez <fperez@colorado.edu>
3043
3055
3044 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
3056 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
3045 arrays to print a more useful summary, without calling str(arr).
3057 arrays to print a more useful summary, without calling str(arr).
3046 This avoids the problem of extremely lengthy computations which
3058 This avoids the problem of extremely lengthy computations which
3047 occur if arr is large, and appear to the user as a system lockup
3059 occur if arr is large, and appear to the user as a system lockup
3048 with 100% cpu activity. After a suggestion by Kristian Sandberg
3060 with 100% cpu activity. After a suggestion by Kristian Sandberg
3049 <Kristian.Sandberg@colorado.edu>.
3061 <Kristian.Sandberg@colorado.edu>.
3050 (Magic.__init__): fix bug in global magic escapes not being
3062 (Magic.__init__): fix bug in global magic escapes not being
3051 correctly set.
3063 correctly set.
3052
3064
3053 2004-10-08 Fernando Perez <fperez@colorado.edu>
3065 2004-10-08 Fernando Perez <fperez@colorado.edu>
3054
3066
3055 * IPython/Magic.py (__license__): change to absolute imports of
3067 * IPython/Magic.py (__license__): change to absolute imports of
3056 ipython's own internal packages, to start adapting to the absolute
3068 ipython's own internal packages, to start adapting to the absolute
3057 import requirement of PEP-328.
3069 import requirement of PEP-328.
3058
3070
3059 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
3071 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
3060 files, and standardize author/license marks through the Release
3072 files, and standardize author/license marks through the Release
3061 module instead of having per/file stuff (except for files with
3073 module instead of having per/file stuff (except for files with
3062 particular licenses, like the MIT/PSF-licensed codes).
3074 particular licenses, like the MIT/PSF-licensed codes).
3063
3075
3064 * IPython/Debugger.py: remove dead code for python 2.1
3076 * IPython/Debugger.py: remove dead code for python 2.1
3065
3077
3066 2004-10-04 Fernando Perez <fperez@colorado.edu>
3078 2004-10-04 Fernando Perez <fperez@colorado.edu>
3067
3079
3068 * IPython/iplib.py (ipmagic): New function for accessing magics
3080 * IPython/iplib.py (ipmagic): New function for accessing magics
3069 via a normal python function call.
3081 via a normal python function call.
3070
3082
3071 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
3083 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
3072 from '@' to '%', to accomodate the new @decorator syntax of python
3084 from '@' to '%', to accomodate the new @decorator syntax of python
3073 2.4.
3085 2.4.
3074
3086
3075 2004-09-29 Fernando Perez <fperez@colorado.edu>
3087 2004-09-29 Fernando Perez <fperez@colorado.edu>
3076
3088
3077 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
3089 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
3078 matplotlib.use to prevent running scripts which try to switch
3090 matplotlib.use to prevent running scripts which try to switch
3079 interactive backends from within ipython. This will just crash
3091 interactive backends from within ipython. This will just crash
3080 the python interpreter, so we can't allow it (but a detailed error
3092 the python interpreter, so we can't allow it (but a detailed error
3081 is given to the user).
3093 is given to the user).
3082
3094
3083 2004-09-28 Fernando Perez <fperez@colorado.edu>
3095 2004-09-28 Fernando Perez <fperez@colorado.edu>
3084
3096
3085 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
3097 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
3086 matplotlib-related fixes so that using @run with non-matplotlib
3098 matplotlib-related fixes so that using @run with non-matplotlib
3087 scripts doesn't pop up spurious plot windows. This requires
3099 scripts doesn't pop up spurious plot windows. This requires
3088 matplotlib >= 0.63, where I had to make some changes as well.
3100 matplotlib >= 0.63, where I had to make some changes as well.
3089
3101
3090 * IPython/ipmaker.py (make_IPython): update version requirement to
3102 * IPython/ipmaker.py (make_IPython): update version requirement to
3091 python 2.2.
3103 python 2.2.
3092
3104
3093 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
3105 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
3094 banner arg for embedded customization.
3106 banner arg for embedded customization.
3095
3107
3096 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
3108 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
3097 explicit uses of __IP as the IPython's instance name. Now things
3109 explicit uses of __IP as the IPython's instance name. Now things
3098 are properly handled via the shell.name value. The actual code
3110 are properly handled via the shell.name value. The actual code
3099 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
3111 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
3100 is much better than before. I'll clean things completely when the
3112 is much better than before. I'll clean things completely when the
3101 magic stuff gets a real overhaul.
3113 magic stuff gets a real overhaul.
3102
3114
3103 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
3115 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
3104 minor changes to debian dir.
3116 minor changes to debian dir.
3105
3117
3106 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
3118 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
3107 pointer to the shell itself in the interactive namespace even when
3119 pointer to the shell itself in the interactive namespace even when
3108 a user-supplied dict is provided. This is needed for embedding
3120 a user-supplied dict is provided. This is needed for embedding
3109 purposes (found by tests with Michel Sanner).
3121 purposes (found by tests with Michel Sanner).
3110
3122
3111 2004-09-27 Fernando Perez <fperez@colorado.edu>
3123 2004-09-27 Fernando Perez <fperez@colorado.edu>
3112
3124
3113 * IPython/UserConfig/ipythonrc: remove []{} from
3125 * IPython/UserConfig/ipythonrc: remove []{} from
3114 readline_remove_delims, so that things like [modname.<TAB> do
3126 readline_remove_delims, so that things like [modname.<TAB> do
3115 proper completion. This disables [].TAB, but that's a less common
3127 proper completion. This disables [].TAB, but that's a less common
3116 case than module names in list comprehensions, for example.
3128 case than module names in list comprehensions, for example.
3117 Thanks to a report by Andrea Riciputi.
3129 Thanks to a report by Andrea Riciputi.
3118
3130
3119 2004-09-09 Fernando Perez <fperez@colorado.edu>
3131 2004-09-09 Fernando Perez <fperez@colorado.edu>
3120
3132
3121 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
3133 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
3122 blocking problems in win32 and osx. Fix by John.
3134 blocking problems in win32 and osx. Fix by John.
3123
3135
3124 2004-09-08 Fernando Perez <fperez@colorado.edu>
3136 2004-09-08 Fernando Perez <fperez@colorado.edu>
3125
3137
3126 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
3138 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
3127 for Win32 and OSX. Fix by John Hunter.
3139 for Win32 and OSX. Fix by John Hunter.
3128
3140
3129 2004-08-30 *** Released version 0.6.3
3141 2004-08-30 *** Released version 0.6.3
3130
3142
3131 2004-08-30 Fernando Perez <fperez@colorado.edu>
3143 2004-08-30 Fernando Perez <fperez@colorado.edu>
3132
3144
3133 * setup.py (isfile): Add manpages to list of dependent files to be
3145 * setup.py (isfile): Add manpages to list of dependent files to be
3134 updated.
3146 updated.
3135
3147
3136 2004-08-27 Fernando Perez <fperez@colorado.edu>
3148 2004-08-27 Fernando Perez <fperez@colorado.edu>
3137
3149
3138 * IPython/Shell.py (start): I've disabled -wthread and -gthread
3150 * IPython/Shell.py (start): I've disabled -wthread and -gthread
3139 for now. They don't really work with standalone WX/GTK code
3151 for now. They don't really work with standalone WX/GTK code
3140 (though matplotlib IS working fine with both of those backends).
3152 (though matplotlib IS working fine with both of those backends).
3141 This will neeed much more testing. I disabled most things with
3153 This will neeed much more testing. I disabled most things with
3142 comments, so turning it back on later should be pretty easy.
3154 comments, so turning it back on later should be pretty easy.
3143
3155
3144 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
3156 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
3145 autocalling of expressions like r'foo', by modifying the line
3157 autocalling of expressions like r'foo', by modifying the line
3146 split regexp. Closes
3158 split regexp. Closes
3147 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
3159 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
3148 Riley <ipythonbugs-AT-sabi.net>.
3160 Riley <ipythonbugs-AT-sabi.net>.
3149 (InteractiveShell.mainloop): honor --nobanner with banner
3161 (InteractiveShell.mainloop): honor --nobanner with banner
3150 extensions.
3162 extensions.
3151
3163
3152 * IPython/Shell.py: Significant refactoring of all classes, so
3164 * IPython/Shell.py: Significant refactoring of all classes, so
3153 that we can really support ALL matplotlib backends and threading
3165 that we can really support ALL matplotlib backends and threading
3154 models (John spotted a bug with Tk which required this). Now we
3166 models (John spotted a bug with Tk which required this). Now we
3155 should support single-threaded, WX-threads and GTK-threads, both
3167 should support single-threaded, WX-threads and GTK-threads, both
3156 for generic code and for matplotlib.
3168 for generic code and for matplotlib.
3157
3169
3158 * IPython/ipmaker.py (__call__): Changed -mpthread option to
3170 * IPython/ipmaker.py (__call__): Changed -mpthread option to
3159 -pylab, to simplify things for users. Will also remove the pylab
3171 -pylab, to simplify things for users. Will also remove the pylab
3160 profile, since now all of matplotlib configuration is directly
3172 profile, since now all of matplotlib configuration is directly
3161 handled here. This also reduces startup time.
3173 handled here. This also reduces startup time.
3162
3174
3163 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
3175 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
3164 shell wasn't being correctly called. Also in IPShellWX.
3176 shell wasn't being correctly called. Also in IPShellWX.
3165
3177
3166 * IPython/iplib.py (InteractiveShell.__init__): Added option to
3178 * IPython/iplib.py (InteractiveShell.__init__): Added option to
3167 fine-tune banner.
3179 fine-tune banner.
3168
3180
3169 * IPython/numutils.py (spike): Deprecate these spike functions,
3181 * IPython/numutils.py (spike): Deprecate these spike functions,
3170 delete (long deprecated) gnuplot_exec handler.
3182 delete (long deprecated) gnuplot_exec handler.
3171
3183
3172 2004-08-26 Fernando Perez <fperez@colorado.edu>
3184 2004-08-26 Fernando Perez <fperez@colorado.edu>
3173
3185
3174 * ipython.1: Update for threading options, plus some others which
3186 * ipython.1: Update for threading options, plus some others which
3175 were missing.
3187 were missing.
3176
3188
3177 * IPython/ipmaker.py (__call__): Added -wthread option for
3189 * IPython/ipmaker.py (__call__): Added -wthread option for
3178 wxpython thread handling. Make sure threading options are only
3190 wxpython thread handling. Make sure threading options are only
3179 valid at the command line.
3191 valid at the command line.
3180
3192
3181 * scripts/ipython: moved shell selection into a factory function
3193 * scripts/ipython: moved shell selection into a factory function
3182 in Shell.py, to keep the starter script to a minimum.
3194 in Shell.py, to keep the starter script to a minimum.
3183
3195
3184 2004-08-25 Fernando Perez <fperez@colorado.edu>
3196 2004-08-25 Fernando Perez <fperez@colorado.edu>
3185
3197
3186 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
3198 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
3187 John. Along with some recent changes he made to matplotlib, the
3199 John. Along with some recent changes he made to matplotlib, the
3188 next versions of both systems should work very well together.
3200 next versions of both systems should work very well together.
3189
3201
3190 2004-08-24 Fernando Perez <fperez@colorado.edu>
3202 2004-08-24 Fernando Perez <fperez@colorado.edu>
3191
3203
3192 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
3204 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
3193 tried to switch the profiling to using hotshot, but I'm getting
3205 tried to switch the profiling to using hotshot, but I'm getting
3194 strange errors from prof.runctx() there. I may be misreading the
3206 strange errors from prof.runctx() there. I may be misreading the
3195 docs, but it looks weird. For now the profiling code will
3207 docs, but it looks weird. For now the profiling code will
3196 continue to use the standard profiler.
3208 continue to use the standard profiler.
3197
3209
3198 2004-08-23 Fernando Perez <fperez@colorado.edu>
3210 2004-08-23 Fernando Perez <fperez@colorado.edu>
3199
3211
3200 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
3212 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
3201 threaded shell, by John Hunter. It's not quite ready yet, but
3213 threaded shell, by John Hunter. It's not quite ready yet, but
3202 close.
3214 close.
3203
3215
3204 2004-08-22 Fernando Perez <fperez@colorado.edu>
3216 2004-08-22 Fernando Perez <fperez@colorado.edu>
3205
3217
3206 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
3218 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
3207 in Magic and ultraTB.
3219 in Magic and ultraTB.
3208
3220
3209 * ipython.1: document threading options in manpage.
3221 * ipython.1: document threading options in manpage.
3210
3222
3211 * scripts/ipython: Changed name of -thread option to -gthread,
3223 * scripts/ipython: Changed name of -thread option to -gthread,
3212 since this is GTK specific. I want to leave the door open for a
3224 since this is GTK specific. I want to leave the door open for a
3213 -wthread option for WX, which will most likely be necessary. This
3225 -wthread option for WX, which will most likely be necessary. This
3214 change affects usage and ipmaker as well.
3226 change affects usage and ipmaker as well.
3215
3227
3216 * IPython/Shell.py (matplotlib_shell): Add a factory function to
3228 * IPython/Shell.py (matplotlib_shell): Add a factory function to
3217 handle the matplotlib shell issues. Code by John Hunter
3229 handle the matplotlib shell issues. Code by John Hunter
3218 <jdhunter-AT-nitace.bsd.uchicago.edu>.
3230 <jdhunter-AT-nitace.bsd.uchicago.edu>.
3219 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
3231 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
3220 broken (and disabled for end users) for now, but it puts the
3232 broken (and disabled for end users) for now, but it puts the
3221 infrastructure in place.
3233 infrastructure in place.
3222
3234
3223 2004-08-21 Fernando Perez <fperez@colorado.edu>
3235 2004-08-21 Fernando Perez <fperez@colorado.edu>
3224
3236
3225 * ipythonrc-pylab: Add matplotlib support.
3237 * ipythonrc-pylab: Add matplotlib support.
3226
3238
3227 * matplotlib_config.py: new files for matplotlib support, part of
3239 * matplotlib_config.py: new files for matplotlib support, part of
3228 the pylab profile.
3240 the pylab profile.
3229
3241
3230 * IPython/usage.py (__doc__): documented the threading options.
3242 * IPython/usage.py (__doc__): documented the threading options.
3231
3243
3232 2004-08-20 Fernando Perez <fperez@colorado.edu>
3244 2004-08-20 Fernando Perez <fperez@colorado.edu>
3233
3245
3234 * ipython: Modified the main calling routine to handle the -thread
3246 * ipython: Modified the main calling routine to handle the -thread
3235 and -mpthread options. This needs to be done as a top-level hack,
3247 and -mpthread options. This needs to be done as a top-level hack,
3236 because it determines which class to instantiate for IPython
3248 because it determines which class to instantiate for IPython
3237 itself.
3249 itself.
3238
3250
3239 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
3251 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
3240 classes to support multithreaded GTK operation without blocking,
3252 classes to support multithreaded GTK operation without blocking,
3241 and matplotlib with all backends. This is a lot of still very
3253 and matplotlib with all backends. This is a lot of still very
3242 experimental code, and threads are tricky. So it may still have a
3254 experimental code, and threads are tricky. So it may still have a
3243 few rough edges... This code owes a lot to
3255 few rough edges... This code owes a lot to
3244 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
3256 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
3245 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
3257 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
3246 to John Hunter for all the matplotlib work.
3258 to John Hunter for all the matplotlib work.
3247
3259
3248 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
3260 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
3249 options for gtk thread and matplotlib support.
3261 options for gtk thread and matplotlib support.
3250
3262
3251 2004-08-16 Fernando Perez <fperez@colorado.edu>
3263 2004-08-16 Fernando Perez <fperez@colorado.edu>
3252
3264
3253 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
3265 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
3254 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
3266 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
3255 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
3267 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
3256
3268
3257 2004-08-11 Fernando Perez <fperez@colorado.edu>
3269 2004-08-11 Fernando Perez <fperez@colorado.edu>
3258
3270
3259 * setup.py (isfile): Fix build so documentation gets updated for
3271 * setup.py (isfile): Fix build so documentation gets updated for
3260 rpms (it was only done for .tgz builds).
3272 rpms (it was only done for .tgz builds).
3261
3273
3262 2004-08-10 Fernando Perez <fperez@colorado.edu>
3274 2004-08-10 Fernando Perez <fperez@colorado.edu>
3263
3275
3264 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
3276 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
3265
3277
3266 * iplib.py : Silence syntax error exceptions in tab-completion.
3278 * iplib.py : Silence syntax error exceptions in tab-completion.
3267
3279
3268 2004-08-05 Fernando Perez <fperez@colorado.edu>
3280 2004-08-05 Fernando Perez <fperez@colorado.edu>
3269
3281
3270 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
3282 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
3271 'color off' mark for continuation prompts. This was causing long
3283 'color off' mark for continuation prompts. This was causing long
3272 continuation lines to mis-wrap.
3284 continuation lines to mis-wrap.
3273
3285
3274 2004-08-01 Fernando Perez <fperez@colorado.edu>
3286 2004-08-01 Fernando Perez <fperez@colorado.edu>
3275
3287
3276 * IPython/ipmaker.py (make_IPython): Allow the shell class used
3288 * IPython/ipmaker.py (make_IPython): Allow the shell class used
3277 for building ipython to be a parameter. All this is necessary
3289 for building ipython to be a parameter. All this is necessary
3278 right now to have a multithreaded version, but this insane
3290 right now to have a multithreaded version, but this insane
3279 non-design will be cleaned up soon. For now, it's a hack that
3291 non-design will be cleaned up soon. For now, it's a hack that
3280 works.
3292 works.
3281
3293
3282 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
3294 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
3283 args in various places. No bugs so far, but it's a dangerous
3295 args in various places. No bugs so far, but it's a dangerous
3284 practice.
3296 practice.
3285
3297
3286 2004-07-31 Fernando Perez <fperez@colorado.edu>
3298 2004-07-31 Fernando Perez <fperez@colorado.edu>
3287
3299
3288 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
3300 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
3289 fix completion of files with dots in their names under most
3301 fix completion of files with dots in their names under most
3290 profiles (pysh was OK because the completion order is different).
3302 profiles (pysh was OK because the completion order is different).
3291
3303
3292 2004-07-27 Fernando Perez <fperez@colorado.edu>
3304 2004-07-27 Fernando Perez <fperez@colorado.edu>
3293
3305
3294 * IPython/iplib.py (InteractiveShell.__init__): build dict of
3306 * IPython/iplib.py (InteractiveShell.__init__): build dict of
3295 keywords manually, b/c the one in keyword.py was removed in python
3307 keywords manually, b/c the one in keyword.py was removed in python
3296 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
3308 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
3297 This is NOT a bug under python 2.3 and earlier.
3309 This is NOT a bug under python 2.3 and earlier.
3298
3310
3299 2004-07-26 Fernando Perez <fperez@colorado.edu>
3311 2004-07-26 Fernando Perez <fperez@colorado.edu>
3300
3312
3301 * IPython/ultraTB.py (VerboseTB.text): Add another
3313 * IPython/ultraTB.py (VerboseTB.text): Add another
3302 linecache.checkcache() call to try to prevent inspect.py from
3314 linecache.checkcache() call to try to prevent inspect.py from
3303 crashing under python 2.3. I think this fixes
3315 crashing under python 2.3. I think this fixes
3304 http://www.scipy.net/roundup/ipython/issue17.
3316 http://www.scipy.net/roundup/ipython/issue17.
3305
3317
3306 2004-07-26 *** Released version 0.6.2
3318 2004-07-26 *** Released version 0.6.2
3307
3319
3308 2004-07-26 Fernando Perez <fperez@colorado.edu>
3320 2004-07-26 Fernando Perez <fperez@colorado.edu>
3309
3321
3310 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
3322 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
3311 fail for any number.
3323 fail for any number.
3312 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
3324 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
3313 empty bookmarks.
3325 empty bookmarks.
3314
3326
3315 2004-07-26 *** Released version 0.6.1
3327 2004-07-26 *** Released version 0.6.1
3316
3328
3317 2004-07-26 Fernando Perez <fperez@colorado.edu>
3329 2004-07-26 Fernando Perez <fperez@colorado.edu>
3318
3330
3319 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
3331 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
3320
3332
3321 * IPython/iplib.py (protect_filename): Applied Ville's patch for
3333 * IPython/iplib.py (protect_filename): Applied Ville's patch for
3322 escaping '()[]{}' in filenames.
3334 escaping '()[]{}' in filenames.
3323
3335
3324 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
3336 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
3325 Python 2.2 users who lack a proper shlex.split.
3337 Python 2.2 users who lack a proper shlex.split.
3326
3338
3327 2004-07-19 Fernando Perez <fperez@colorado.edu>
3339 2004-07-19 Fernando Perez <fperez@colorado.edu>
3328
3340
3329 * IPython/iplib.py (InteractiveShell.init_readline): Add support
3341 * IPython/iplib.py (InteractiveShell.init_readline): Add support
3330 for reading readline's init file. I follow the normal chain:
3342 for reading readline's init file. I follow the normal chain:
3331 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
3343 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
3332 report by Mike Heeter. This closes
3344 report by Mike Heeter. This closes
3333 http://www.scipy.net/roundup/ipython/issue16.
3345 http://www.scipy.net/roundup/ipython/issue16.
3334
3346
3335 2004-07-18 Fernando Perez <fperez@colorado.edu>
3347 2004-07-18 Fernando Perez <fperez@colorado.edu>
3336
3348
3337 * IPython/iplib.py (__init__): Add better handling of '\' under
3349 * IPython/iplib.py (__init__): Add better handling of '\' under
3338 Win32 for filenames. After a patch by Ville.
3350 Win32 for filenames. After a patch by Ville.
3339
3351
3340 2004-07-17 Fernando Perez <fperez@colorado.edu>
3352 2004-07-17 Fernando Perez <fperez@colorado.edu>
3341
3353
3342 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
3354 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
3343 autocalling would be triggered for 'foo is bar' if foo is
3355 autocalling would be triggered for 'foo is bar' if foo is
3344 callable. I also cleaned up the autocall detection code to use a
3356 callable. I also cleaned up the autocall detection code to use a
3345 regexp, which is faster. Bug reported by Alexander Schmolck.
3357 regexp, which is faster. Bug reported by Alexander Schmolck.
3346
3358
3347 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
3359 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
3348 '?' in them would confuse the help system. Reported by Alex
3360 '?' in them would confuse the help system. Reported by Alex
3349 Schmolck.
3361 Schmolck.
3350
3362
3351 2004-07-16 Fernando Perez <fperez@colorado.edu>
3363 2004-07-16 Fernando Perez <fperez@colorado.edu>
3352
3364
3353 * IPython/GnuplotInteractive.py (__all__): added plot2.
3365 * IPython/GnuplotInteractive.py (__all__): added plot2.
3354
3366
3355 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
3367 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
3356 plotting dictionaries, lists or tuples of 1d arrays.
3368 plotting dictionaries, lists or tuples of 1d arrays.
3357
3369
3358 * IPython/Magic.py (Magic.magic_hist): small clenaups and
3370 * IPython/Magic.py (Magic.magic_hist): small clenaups and
3359 optimizations.
3371 optimizations.
3360
3372
3361 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
3373 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
3362 the information which was there from Janko's original IPP code:
3374 the information which was there from Janko's original IPP code:
3363
3375
3364 03.05.99 20:53 porto.ifm.uni-kiel.de
3376 03.05.99 20:53 porto.ifm.uni-kiel.de
3365 --Started changelog.
3377 --Started changelog.
3366 --make clear do what it say it does
3378 --make clear do what it say it does
3367 --added pretty output of lines from inputcache
3379 --added pretty output of lines from inputcache
3368 --Made Logger a mixin class, simplifies handling of switches
3380 --Made Logger a mixin class, simplifies handling of switches
3369 --Added own completer class. .string<TAB> expands to last history
3381 --Added own completer class. .string<TAB> expands to last history
3370 line which starts with string. The new expansion is also present
3382 line which starts with string. The new expansion is also present
3371 with Ctrl-r from the readline library. But this shows, who this
3383 with Ctrl-r from the readline library. But this shows, who this
3372 can be done for other cases.
3384 can be done for other cases.
3373 --Added convention that all shell functions should accept a
3385 --Added convention that all shell functions should accept a
3374 parameter_string This opens the door for different behaviour for
3386 parameter_string This opens the door for different behaviour for
3375 each function. @cd is a good example of this.
3387 each function. @cd is a good example of this.
3376
3388
3377 04.05.99 12:12 porto.ifm.uni-kiel.de
3389 04.05.99 12:12 porto.ifm.uni-kiel.de
3378 --added logfile rotation
3390 --added logfile rotation
3379 --added new mainloop method which freezes first the namespace
3391 --added new mainloop method which freezes first the namespace
3380
3392
3381 07.05.99 21:24 porto.ifm.uni-kiel.de
3393 07.05.99 21:24 porto.ifm.uni-kiel.de
3382 --added the docreader classes. Now there is a help system.
3394 --added the docreader classes. Now there is a help system.
3383 -This is only a first try. Currently it's not easy to put new
3395 -This is only a first try. Currently it's not easy to put new
3384 stuff in the indices. But this is the way to go. Info would be
3396 stuff in the indices. But this is the way to go. Info would be
3385 better, but HTML is every where and not everybody has an info
3397 better, but HTML is every where and not everybody has an info
3386 system installed and it's not so easy to change html-docs to info.
3398 system installed and it's not so easy to change html-docs to info.
3387 --added global logfile option
3399 --added global logfile option
3388 --there is now a hook for object inspection method pinfo needs to
3400 --there is now a hook for object inspection method pinfo needs to
3389 be provided for this. Can be reached by two '??'.
3401 be provided for this. Can be reached by two '??'.
3390
3402
3391 08.05.99 20:51 porto.ifm.uni-kiel.de
3403 08.05.99 20:51 porto.ifm.uni-kiel.de
3392 --added a README
3404 --added a README
3393 --bug in rc file. Something has changed so functions in the rc
3405 --bug in rc file. Something has changed so functions in the rc
3394 file need to reference the shell and not self. Not clear if it's a
3406 file need to reference the shell and not self. Not clear if it's a
3395 bug or feature.
3407 bug or feature.
3396 --changed rc file for new behavior
3408 --changed rc file for new behavior
3397
3409
3398 2004-07-15 Fernando Perez <fperez@colorado.edu>
3410 2004-07-15 Fernando Perez <fperez@colorado.edu>
3399
3411
3400 * IPython/Logger.py (Logger.log): fixed recent bug where the input
3412 * IPython/Logger.py (Logger.log): fixed recent bug where the input
3401 cache was falling out of sync in bizarre manners when multi-line
3413 cache was falling out of sync in bizarre manners when multi-line
3402 input was present. Minor optimizations and cleanup.
3414 input was present. Minor optimizations and cleanup.
3403
3415
3404 (Logger): Remove old Changelog info for cleanup. This is the
3416 (Logger): Remove old Changelog info for cleanup. This is the
3405 information which was there from Janko's original code:
3417 information which was there from Janko's original code:
3406
3418
3407 Changes to Logger: - made the default log filename a parameter
3419 Changes to Logger: - made the default log filename a parameter
3408
3420
3409 - put a check for lines beginning with !@? in log(). Needed
3421 - put a check for lines beginning with !@? in log(). Needed
3410 (even if the handlers properly log their lines) for mid-session
3422 (even if the handlers properly log their lines) for mid-session
3411 logging activation to work properly. Without this, lines logged
3423 logging activation to work properly. Without this, lines logged
3412 in mid session, which get read from the cache, would end up
3424 in mid session, which get read from the cache, would end up
3413 'bare' (with !@? in the open) in the log. Now they are caught
3425 'bare' (with !@? in the open) in the log. Now they are caught
3414 and prepended with a #.
3426 and prepended with a #.
3415
3427
3416 * IPython/iplib.py (InteractiveShell.init_readline): added check
3428 * IPython/iplib.py (InteractiveShell.init_readline): added check
3417 in case MagicCompleter fails to be defined, so we don't crash.
3429 in case MagicCompleter fails to be defined, so we don't crash.
3418
3430
3419 2004-07-13 Fernando Perez <fperez@colorado.edu>
3431 2004-07-13 Fernando Perez <fperez@colorado.edu>
3420
3432
3421 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
3433 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
3422 of EPS if the requested filename ends in '.eps'.
3434 of EPS if the requested filename ends in '.eps'.
3423
3435
3424 2004-07-04 Fernando Perez <fperez@colorado.edu>
3436 2004-07-04 Fernando Perez <fperez@colorado.edu>
3425
3437
3426 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
3438 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
3427 escaping of quotes when calling the shell.
3439 escaping of quotes when calling the shell.
3428
3440
3429 2004-07-02 Fernando Perez <fperez@colorado.edu>
3441 2004-07-02 Fernando Perez <fperez@colorado.edu>
3430
3442
3431 * IPython/Prompts.py (CachedOutput.update): Fix problem with
3443 * IPython/Prompts.py (CachedOutput.update): Fix problem with
3432 gettext not working because we were clobbering '_'. Fixes
3444 gettext not working because we were clobbering '_'. Fixes
3433 http://www.scipy.net/roundup/ipython/issue6.
3445 http://www.scipy.net/roundup/ipython/issue6.
3434
3446
3435 2004-07-01 Fernando Perez <fperez@colorado.edu>
3447 2004-07-01 Fernando Perez <fperez@colorado.edu>
3436
3448
3437 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
3449 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
3438 into @cd. Patch by Ville.
3450 into @cd. Patch by Ville.
3439
3451
3440 * IPython/iplib.py (InteractiveShell.post_config_initialization):
3452 * IPython/iplib.py (InteractiveShell.post_config_initialization):
3441 new function to store things after ipmaker runs. Patch by Ville.
3453 new function to store things after ipmaker runs. Patch by Ville.
3442 Eventually this will go away once ipmaker is removed and the class
3454 Eventually this will go away once ipmaker is removed and the class
3443 gets cleaned up, but for now it's ok. Key functionality here is
3455 gets cleaned up, but for now it's ok. Key functionality here is
3444 the addition of the persistent storage mechanism, a dict for
3456 the addition of the persistent storage mechanism, a dict for
3445 keeping data across sessions (for now just bookmarks, but more can
3457 keeping data across sessions (for now just bookmarks, but more can
3446 be implemented later).
3458 be implemented later).
3447
3459
3448 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
3460 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
3449 persistent across sections. Patch by Ville, I modified it
3461 persistent across sections. Patch by Ville, I modified it
3450 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
3462 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
3451 added a '-l' option to list all bookmarks.
3463 added a '-l' option to list all bookmarks.
3452
3464
3453 * IPython/iplib.py (InteractiveShell.atexit_operations): new
3465 * IPython/iplib.py (InteractiveShell.atexit_operations): new
3454 center for cleanup. Registered with atexit.register(). I moved
3466 center for cleanup. Registered with atexit.register(). I moved
3455 here the old exit_cleanup(). After a patch by Ville.
3467 here the old exit_cleanup(). After a patch by Ville.
3456
3468
3457 * IPython/Magic.py (get_py_filename): added '~' to the accepted
3469 * IPython/Magic.py (get_py_filename): added '~' to the accepted
3458 characters in the hacked shlex_split for python 2.2.
3470 characters in the hacked shlex_split for python 2.2.
3459
3471
3460 * IPython/iplib.py (file_matches): more fixes to filenames with
3472 * IPython/iplib.py (file_matches): more fixes to filenames with
3461 whitespace in them. It's not perfect, but limitations in python's
3473 whitespace in them. It's not perfect, but limitations in python's
3462 readline make it impossible to go further.
3474 readline make it impossible to go further.
3463
3475
3464 2004-06-29 Fernando Perez <fperez@colorado.edu>
3476 2004-06-29 Fernando Perez <fperez@colorado.edu>
3465
3477
3466 * IPython/iplib.py (file_matches): escape whitespace correctly in
3478 * IPython/iplib.py (file_matches): escape whitespace correctly in
3467 filename completions. Bug reported by Ville.
3479 filename completions. Bug reported by Ville.
3468
3480
3469 2004-06-28 Fernando Perez <fperez@colorado.edu>
3481 2004-06-28 Fernando Perez <fperez@colorado.edu>
3470
3482
3471 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
3483 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
3472 the history file will be called 'history-PROFNAME' (or just
3484 the history file will be called 'history-PROFNAME' (or just
3473 'history' if no profile is loaded). I was getting annoyed at
3485 'history' if no profile is loaded). I was getting annoyed at
3474 getting my Numerical work history clobbered by pysh sessions.
3486 getting my Numerical work history clobbered by pysh sessions.
3475
3487
3476 * IPython/iplib.py (InteractiveShell.__init__): Internal
3488 * IPython/iplib.py (InteractiveShell.__init__): Internal
3477 getoutputerror() function so that we can honor the system_verbose
3489 getoutputerror() function so that we can honor the system_verbose
3478 flag for _all_ system calls. I also added escaping of #
3490 flag for _all_ system calls. I also added escaping of #
3479 characters here to avoid confusing Itpl.
3491 characters here to avoid confusing Itpl.
3480
3492
3481 * IPython/Magic.py (shlex_split): removed call to shell in
3493 * IPython/Magic.py (shlex_split): removed call to shell in
3482 parse_options and replaced it with shlex.split(). The annoying
3494 parse_options and replaced it with shlex.split(). The annoying
3483 part was that in Python 2.2, shlex.split() doesn't exist, so I had
3495 part was that in Python 2.2, shlex.split() doesn't exist, so I had
3484 to backport it from 2.3, with several frail hacks (the shlex
3496 to backport it from 2.3, with several frail hacks (the shlex
3485 module is rather limited in 2.2). Thanks to a suggestion by Ville
3497 module is rather limited in 2.2). Thanks to a suggestion by Ville
3486 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
3498 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
3487 problem.
3499 problem.
3488
3500
3489 (Magic.magic_system_verbose): new toggle to print the actual
3501 (Magic.magic_system_verbose): new toggle to print the actual
3490 system calls made by ipython. Mainly for debugging purposes.
3502 system calls made by ipython. Mainly for debugging purposes.
3491
3503
3492 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
3504 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
3493 doesn't support persistence. Reported (and fix suggested) by
3505 doesn't support persistence. Reported (and fix suggested) by
3494 Travis Caldwell <travis_caldwell2000@yahoo.com>.
3506 Travis Caldwell <travis_caldwell2000@yahoo.com>.
3495
3507
3496 2004-06-26 Fernando Perez <fperez@colorado.edu>
3508 2004-06-26 Fernando Perez <fperez@colorado.edu>
3497
3509
3498 * IPython/Logger.py (Logger.log): fix to handle correctly empty
3510 * IPython/Logger.py (Logger.log): fix to handle correctly empty
3499 continue prompts.
3511 continue prompts.
3500
3512
3501 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
3513 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
3502 function (basically a big docstring) and a few more things here to
3514 function (basically a big docstring) and a few more things here to
3503 speedup startup. pysh.py is now very lightweight. We want because
3515 speedup startup. pysh.py is now very lightweight. We want because
3504 it gets execfile'd, while InterpreterExec gets imported, so
3516 it gets execfile'd, while InterpreterExec gets imported, so
3505 byte-compilation saves time.
3517 byte-compilation saves time.
3506
3518
3507 2004-06-25 Fernando Perez <fperez@colorado.edu>
3519 2004-06-25 Fernando Perez <fperez@colorado.edu>
3508
3520
3509 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
3521 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
3510 -NUM', which was recently broken.
3522 -NUM', which was recently broken.
3511
3523
3512 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
3524 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
3513 in multi-line input (but not !!, which doesn't make sense there).
3525 in multi-line input (but not !!, which doesn't make sense there).
3514
3526
3515 * IPython/UserConfig/ipythonrc: made autoindent on by default.
3527 * IPython/UserConfig/ipythonrc: made autoindent on by default.
3516 It's just too useful, and people can turn it off in the less
3528 It's just too useful, and people can turn it off in the less
3517 common cases where it's a problem.
3529 common cases where it's a problem.
3518
3530
3519 2004-06-24 Fernando Perez <fperez@colorado.edu>
3531 2004-06-24 Fernando Perez <fperez@colorado.edu>
3520
3532
3521 * IPython/iplib.py (InteractiveShell._prefilter): big change -
3533 * IPython/iplib.py (InteractiveShell._prefilter): big change -
3522 special syntaxes (like alias calling) is now allied in multi-line
3534 special syntaxes (like alias calling) is now allied in multi-line
3523 input. This is still _very_ experimental, but it's necessary for
3535 input. This is still _very_ experimental, but it's necessary for
3524 efficient shell usage combining python looping syntax with system
3536 efficient shell usage combining python looping syntax with system
3525 calls. For now it's restricted to aliases, I don't think it
3537 calls. For now it's restricted to aliases, I don't think it
3526 really even makes sense to have this for magics.
3538 really even makes sense to have this for magics.
3527
3539
3528 2004-06-23 Fernando Perez <fperez@colorado.edu>
3540 2004-06-23 Fernando Perez <fperez@colorado.edu>
3529
3541
3530 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
3542 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
3531 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
3543 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
3532
3544
3533 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
3545 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
3534 extensions under Windows (after code sent by Gary Bishop). The
3546 extensions under Windows (after code sent by Gary Bishop). The
3535 extensions considered 'executable' are stored in IPython's rc
3547 extensions considered 'executable' are stored in IPython's rc
3536 structure as win_exec_ext.
3548 structure as win_exec_ext.
3537
3549
3538 * IPython/genutils.py (shell): new function, like system() but
3550 * IPython/genutils.py (shell): new function, like system() but
3539 without return value. Very useful for interactive shell work.
3551 without return value. Very useful for interactive shell work.
3540
3552
3541 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
3553 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
3542 delete aliases.
3554 delete aliases.
3543
3555
3544 * IPython/iplib.py (InteractiveShell.alias_table_update): make
3556 * IPython/iplib.py (InteractiveShell.alias_table_update): make
3545 sure that the alias table doesn't contain python keywords.
3557 sure that the alias table doesn't contain python keywords.
3546
3558
3547 2004-06-21 Fernando Perez <fperez@colorado.edu>
3559 2004-06-21 Fernando Perez <fperez@colorado.edu>
3548
3560
3549 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
3561 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
3550 non-existent items are found in $PATH. Reported by Thorsten.
3562 non-existent items are found in $PATH. Reported by Thorsten.
3551
3563
3552 2004-06-20 Fernando Perez <fperez@colorado.edu>
3564 2004-06-20 Fernando Perez <fperez@colorado.edu>
3553
3565
3554 * IPython/iplib.py (complete): modified the completer so that the
3566 * IPython/iplib.py (complete): modified the completer so that the
3555 order of priorities can be easily changed at runtime.
3567 order of priorities can be easily changed at runtime.
3556
3568
3557 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
3569 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
3558 Modified to auto-execute all lines beginning with '~', '/' or '.'.
3570 Modified to auto-execute all lines beginning with '~', '/' or '.'.
3559
3571
3560 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
3572 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
3561 expand Python variables prepended with $ in all system calls. The
3573 expand Python variables prepended with $ in all system calls. The
3562 same was done to InteractiveShell.handle_shell_escape. Now all
3574 same was done to InteractiveShell.handle_shell_escape. Now all
3563 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
3575 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
3564 expansion of python variables and expressions according to the
3576 expansion of python variables and expressions according to the
3565 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
3577 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
3566
3578
3567 Though PEP-215 has been rejected, a similar (but simpler) one
3579 Though PEP-215 has been rejected, a similar (but simpler) one
3568 seems like it will go into Python 2.4, PEP-292 -
3580 seems like it will go into Python 2.4, PEP-292 -
3569 http://www.python.org/peps/pep-0292.html.
3581 http://www.python.org/peps/pep-0292.html.
3570
3582
3571 I'll keep the full syntax of PEP-215, since IPython has since the
3583 I'll keep the full syntax of PEP-215, since IPython has since the
3572 start used Ka-Ping Yee's reference implementation discussed there
3584 start used Ka-Ping Yee's reference implementation discussed there
3573 (Itpl), and I actually like the powerful semantics it offers.
3585 (Itpl), and I actually like the powerful semantics it offers.
3574
3586
3575 In order to access normal shell variables, the $ has to be escaped
3587 In order to access normal shell variables, the $ has to be escaped
3576 via an extra $. For example:
3588 via an extra $. For example:
3577
3589
3578 In [7]: PATH='a python variable'
3590 In [7]: PATH='a python variable'
3579
3591
3580 In [8]: !echo $PATH
3592 In [8]: !echo $PATH
3581 a python variable
3593 a python variable
3582
3594
3583 In [9]: !echo $$PATH
3595 In [9]: !echo $$PATH
3584 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
3596 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
3585
3597
3586 (Magic.parse_options): escape $ so the shell doesn't evaluate
3598 (Magic.parse_options): escape $ so the shell doesn't evaluate
3587 things prematurely.
3599 things prematurely.
3588
3600
3589 * IPython/iplib.py (InteractiveShell.call_alias): added the
3601 * IPython/iplib.py (InteractiveShell.call_alias): added the
3590 ability for aliases to expand python variables via $.
3602 ability for aliases to expand python variables via $.
3591
3603
3592 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
3604 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
3593 system, now there's a @rehash/@rehashx pair of magics. These work
3605 system, now there's a @rehash/@rehashx pair of magics. These work
3594 like the csh rehash command, and can be invoked at any time. They
3606 like the csh rehash command, and can be invoked at any time. They
3595 build a table of aliases to everything in the user's $PATH
3607 build a table of aliases to everything in the user's $PATH
3596 (@rehash uses everything, @rehashx is slower but only adds
3608 (@rehash uses everything, @rehashx is slower but only adds
3597 executable files). With this, the pysh.py-based shell profile can
3609 executable files). With this, the pysh.py-based shell profile can
3598 now simply call rehash upon startup, and full access to all
3610 now simply call rehash upon startup, and full access to all
3599 programs in the user's path is obtained.
3611 programs in the user's path is obtained.
3600
3612
3601 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
3613 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
3602 functionality is now fully in place. I removed the old dynamic
3614 functionality is now fully in place. I removed the old dynamic
3603 code generation based approach, in favor of a much lighter one
3615 code generation based approach, in favor of a much lighter one
3604 based on a simple dict. The advantage is that this allows me to
3616 based on a simple dict. The advantage is that this allows me to
3605 now have thousands of aliases with negligible cost (unthinkable
3617 now have thousands of aliases with negligible cost (unthinkable
3606 with the old system).
3618 with the old system).
3607
3619
3608 2004-06-19 Fernando Perez <fperez@colorado.edu>
3620 2004-06-19 Fernando Perez <fperez@colorado.edu>
3609
3621
3610 * IPython/iplib.py (__init__): extended MagicCompleter class to
3622 * IPython/iplib.py (__init__): extended MagicCompleter class to
3611 also complete (last in priority) on user aliases.
3623 also complete (last in priority) on user aliases.
3612
3624
3613 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
3625 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
3614 call to eval.
3626 call to eval.
3615 (ItplNS.__init__): Added a new class which functions like Itpl,
3627 (ItplNS.__init__): Added a new class which functions like Itpl,
3616 but allows configuring the namespace for the evaluation to occur
3628 but allows configuring the namespace for the evaluation to occur
3617 in.
3629 in.
3618
3630
3619 2004-06-18 Fernando Perez <fperez@colorado.edu>
3631 2004-06-18 Fernando Perez <fperez@colorado.edu>
3620
3632
3621 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
3633 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
3622 better message when 'exit' or 'quit' are typed (a common newbie
3634 better message when 'exit' or 'quit' are typed (a common newbie
3623 confusion).
3635 confusion).
3624
3636
3625 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
3637 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
3626 check for Windows users.
3638 check for Windows users.
3627
3639
3628 * IPython/iplib.py (InteractiveShell.user_setup): removed
3640 * IPython/iplib.py (InteractiveShell.user_setup): removed
3629 disabling of colors for Windows. I'll test at runtime and issue a
3641 disabling of colors for Windows. I'll test at runtime and issue a
3630 warning if Gary's readline isn't found, as to nudge users to
3642 warning if Gary's readline isn't found, as to nudge users to
3631 download it.
3643 download it.
3632
3644
3633 2004-06-16 Fernando Perez <fperez@colorado.edu>
3645 2004-06-16 Fernando Perez <fperez@colorado.edu>
3634
3646
3635 * IPython/genutils.py (Stream.__init__): changed to print errors
3647 * IPython/genutils.py (Stream.__init__): changed to print errors
3636 to sys.stderr. I had a circular dependency here. Now it's
3648 to sys.stderr. I had a circular dependency here. Now it's
3637 possible to run ipython as IDLE's shell (consider this pre-alpha,
3649 possible to run ipython as IDLE's shell (consider this pre-alpha,
3638 since true stdout things end up in the starting terminal instead
3650 since true stdout things end up in the starting terminal instead
3639 of IDLE's out).
3651 of IDLE's out).
3640
3652
3641 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
3653 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
3642 users who haven't # updated their prompt_in2 definitions. Remove
3654 users who haven't # updated their prompt_in2 definitions. Remove
3643 eventually.
3655 eventually.
3644 (multiple_replace): added credit to original ASPN recipe.
3656 (multiple_replace): added credit to original ASPN recipe.
3645
3657
3646 2004-06-15 Fernando Perez <fperez@colorado.edu>
3658 2004-06-15 Fernando Perez <fperez@colorado.edu>
3647
3659
3648 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
3660 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
3649 list of auto-defined aliases.
3661 list of auto-defined aliases.
3650
3662
3651 2004-06-13 Fernando Perez <fperez@colorado.edu>
3663 2004-06-13 Fernando Perez <fperez@colorado.edu>
3652
3664
3653 * setup.py (scriptfiles): Don't trigger win_post_install unless an
3665 * setup.py (scriptfiles): Don't trigger win_post_install unless an
3654 install was really requested (so setup.py can be used for other
3666 install was really requested (so setup.py can be used for other
3655 things under Windows).
3667 things under Windows).
3656
3668
3657 2004-06-10 Fernando Perez <fperez@colorado.edu>
3669 2004-06-10 Fernando Perez <fperez@colorado.edu>
3658
3670
3659 * IPython/Logger.py (Logger.create_log): Manually remove any old
3671 * IPython/Logger.py (Logger.create_log): Manually remove any old
3660 backup, since os.remove may fail under Windows. Fixes bug
3672 backup, since os.remove may fail under Windows. Fixes bug
3661 reported by Thorsten.
3673 reported by Thorsten.
3662
3674
3663 2004-06-09 Fernando Perez <fperez@colorado.edu>
3675 2004-06-09 Fernando Perez <fperez@colorado.edu>
3664
3676
3665 * examples/example-embed.py: fixed all references to %n (replaced
3677 * examples/example-embed.py: fixed all references to %n (replaced
3666 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
3678 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
3667 for all examples and the manual as well.
3679 for all examples and the manual as well.
3668
3680
3669 2004-06-08 Fernando Perez <fperez@colorado.edu>
3681 2004-06-08 Fernando Perez <fperez@colorado.edu>
3670
3682
3671 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
3683 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
3672 alignment and color management. All 3 prompt subsystems now
3684 alignment and color management. All 3 prompt subsystems now
3673 inherit from BasePrompt.
3685 inherit from BasePrompt.
3674
3686
3675 * tools/release: updates for windows installer build and tag rpms
3687 * tools/release: updates for windows installer build and tag rpms
3676 with python version (since paths are fixed).
3688 with python version (since paths are fixed).
3677
3689
3678 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
3690 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
3679 which will become eventually obsolete. Also fixed the default
3691 which will become eventually obsolete. Also fixed the default
3680 prompt_in2 to use \D, so at least new users start with the correct
3692 prompt_in2 to use \D, so at least new users start with the correct
3681 defaults.
3693 defaults.
3682 WARNING: Users with existing ipythonrc files will need to apply
3694 WARNING: Users with existing ipythonrc files will need to apply
3683 this fix manually!
3695 this fix manually!
3684
3696
3685 * setup.py: make windows installer (.exe). This is finally the
3697 * setup.py: make windows installer (.exe). This is finally the
3686 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
3698 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
3687 which I hadn't included because it required Python 2.3 (or recent
3699 which I hadn't included because it required Python 2.3 (or recent
3688 distutils).
3700 distutils).
3689
3701
3690 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
3702 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
3691 usage of new '\D' escape.
3703 usage of new '\D' escape.
3692
3704
3693 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
3705 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
3694 lacks os.getuid())
3706 lacks os.getuid())
3695 (CachedOutput.set_colors): Added the ability to turn coloring
3707 (CachedOutput.set_colors): Added the ability to turn coloring
3696 on/off with @colors even for manually defined prompt colors. It
3708 on/off with @colors even for manually defined prompt colors. It
3697 uses a nasty global, but it works safely and via the generic color
3709 uses a nasty global, but it works safely and via the generic color
3698 handling mechanism.
3710 handling mechanism.
3699 (Prompt2.__init__): Introduced new escape '\D' for continuation
3711 (Prompt2.__init__): Introduced new escape '\D' for continuation
3700 prompts. It represents the counter ('\#') as dots.
3712 prompts. It represents the counter ('\#') as dots.
3701 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
3713 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
3702 need to update their ipythonrc files and replace '%n' with '\D' in
3714 need to update their ipythonrc files and replace '%n' with '\D' in
3703 their prompt_in2 settings everywhere. Sorry, but there's
3715 their prompt_in2 settings everywhere. Sorry, but there's
3704 otherwise no clean way to get all prompts to properly align. The
3716 otherwise no clean way to get all prompts to properly align. The
3705 ipythonrc shipped with IPython has been updated.
3717 ipythonrc shipped with IPython has been updated.
3706
3718
3707 2004-06-07 Fernando Perez <fperez@colorado.edu>
3719 2004-06-07 Fernando Perez <fperez@colorado.edu>
3708
3720
3709 * setup.py (isfile): Pass local_icons option to latex2html, so the
3721 * setup.py (isfile): Pass local_icons option to latex2html, so the
3710 resulting HTML file is self-contained. Thanks to
3722 resulting HTML file is self-contained. Thanks to
3711 dryice-AT-liu.com.cn for the tip.
3723 dryice-AT-liu.com.cn for the tip.
3712
3724
3713 * pysh.py: I created a new profile 'shell', which implements a
3725 * pysh.py: I created a new profile 'shell', which implements a
3714 _rudimentary_ IPython-based shell. This is in NO WAY a realy
3726 _rudimentary_ IPython-based shell. This is in NO WAY a realy
3715 system shell, nor will it become one anytime soon. It's mainly
3727 system shell, nor will it become one anytime soon. It's mainly
3716 meant to illustrate the use of the new flexible bash-like prompts.
3728 meant to illustrate the use of the new flexible bash-like prompts.
3717 I guess it could be used by hardy souls for true shell management,
3729 I guess it could be used by hardy souls for true shell management,
3718 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
3730 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
3719 profile. This uses the InterpreterExec extension provided by
3731 profile. This uses the InterpreterExec extension provided by
3720 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
3732 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
3721
3733
3722 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
3734 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
3723 auto-align itself with the length of the previous input prompt
3735 auto-align itself with the length of the previous input prompt
3724 (taking into account the invisible color escapes).
3736 (taking into account the invisible color escapes).
3725 (CachedOutput.__init__): Large restructuring of this class. Now
3737 (CachedOutput.__init__): Large restructuring of this class. Now
3726 all three prompts (primary1, primary2, output) are proper objects,
3738 all three prompts (primary1, primary2, output) are proper objects,
3727 managed by the 'parent' CachedOutput class. The code is still a
3739 managed by the 'parent' CachedOutput class. The code is still a
3728 bit hackish (all prompts share state via a pointer to the cache),
3740 bit hackish (all prompts share state via a pointer to the cache),
3729 but it's overall far cleaner than before.
3741 but it's overall far cleaner than before.
3730
3742
3731 * IPython/genutils.py (getoutputerror): modified to add verbose,
3743 * IPython/genutils.py (getoutputerror): modified to add verbose,
3732 debug and header options. This makes the interface of all getout*
3744 debug and header options. This makes the interface of all getout*
3733 functions uniform.
3745 functions uniform.
3734 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
3746 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
3735
3747
3736 * IPython/Magic.py (Magic.default_option): added a function to
3748 * IPython/Magic.py (Magic.default_option): added a function to
3737 allow registering default options for any magic command. This
3749 allow registering default options for any magic command. This
3738 makes it easy to have profiles which customize the magics globally
3750 makes it easy to have profiles which customize the magics globally
3739 for a certain use. The values set through this function are
3751 for a certain use. The values set through this function are
3740 picked up by the parse_options() method, which all magics should
3752 picked up by the parse_options() method, which all magics should
3741 use to parse their options.
3753 use to parse their options.
3742
3754
3743 * IPython/genutils.py (warn): modified the warnings framework to
3755 * IPython/genutils.py (warn): modified the warnings framework to
3744 use the Term I/O class. I'm trying to slowly unify all of
3756 use the Term I/O class. I'm trying to slowly unify all of
3745 IPython's I/O operations to pass through Term.
3757 IPython's I/O operations to pass through Term.
3746
3758
3747 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
3759 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
3748 the secondary prompt to correctly match the length of the primary
3760 the secondary prompt to correctly match the length of the primary
3749 one for any prompt. Now multi-line code will properly line up
3761 one for any prompt. Now multi-line code will properly line up
3750 even for path dependent prompts, such as the new ones available
3762 even for path dependent prompts, such as the new ones available
3751 via the prompt_specials.
3763 via the prompt_specials.
3752
3764
3753 2004-06-06 Fernando Perez <fperez@colorado.edu>
3765 2004-06-06 Fernando Perez <fperez@colorado.edu>
3754
3766
3755 * IPython/Prompts.py (prompt_specials): Added the ability to have
3767 * IPython/Prompts.py (prompt_specials): Added the ability to have
3756 bash-like special sequences in the prompts, which get
3768 bash-like special sequences in the prompts, which get
3757 automatically expanded. Things like hostname, current working
3769 automatically expanded. Things like hostname, current working
3758 directory and username are implemented already, but it's easy to
3770 directory and username are implemented already, but it's easy to
3759 add more in the future. Thanks to a patch by W.J. van der Laan
3771 add more in the future. Thanks to a patch by W.J. van der Laan
3760 <gnufnork-AT-hetdigitalegat.nl>
3772 <gnufnork-AT-hetdigitalegat.nl>
3761 (prompt_specials): Added color support for prompt strings, so
3773 (prompt_specials): Added color support for prompt strings, so
3762 users can define arbitrary color setups for their prompts.
3774 users can define arbitrary color setups for their prompts.
3763
3775
3764 2004-06-05 Fernando Perez <fperez@colorado.edu>
3776 2004-06-05 Fernando Perez <fperez@colorado.edu>
3765
3777
3766 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
3778 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
3767 code to load Gary Bishop's readline and configure it
3779 code to load Gary Bishop's readline and configure it
3768 automatically. Thanks to Gary for help on this.
3780 automatically. Thanks to Gary for help on this.
3769
3781
3770 2004-06-01 Fernando Perez <fperez@colorado.edu>
3782 2004-06-01 Fernando Perez <fperez@colorado.edu>
3771
3783
3772 * IPython/Logger.py (Logger.create_log): fix bug for logging
3784 * IPython/Logger.py (Logger.create_log): fix bug for logging
3773 with no filename (previous fix was incomplete).
3785 with no filename (previous fix was incomplete).
3774
3786
3775 2004-05-25 Fernando Perez <fperez@colorado.edu>
3787 2004-05-25 Fernando Perez <fperez@colorado.edu>
3776
3788
3777 * IPython/Magic.py (Magic.parse_options): fix bug where naked
3789 * IPython/Magic.py (Magic.parse_options): fix bug where naked
3778 parens would get passed to the shell.
3790 parens would get passed to the shell.
3779
3791
3780 2004-05-20 Fernando Perez <fperez@colorado.edu>
3792 2004-05-20 Fernando Perez <fperez@colorado.edu>
3781
3793
3782 * IPython/Magic.py (Magic.magic_prun): changed default profile
3794 * IPython/Magic.py (Magic.magic_prun): changed default profile
3783 sort order to 'time' (the more common profiling need).
3795 sort order to 'time' (the more common profiling need).
3784
3796
3785 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
3797 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
3786 so that source code shown is guaranteed in sync with the file on
3798 so that source code shown is guaranteed in sync with the file on
3787 disk (also changed in psource). Similar fix to the one for
3799 disk (also changed in psource). Similar fix to the one for
3788 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
3800 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
3789 <yann.ledu-AT-noos.fr>.
3801 <yann.ledu-AT-noos.fr>.
3790
3802
3791 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
3803 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
3792 with a single option would not be correctly parsed. Closes
3804 with a single option would not be correctly parsed. Closes
3793 http://www.scipy.net/roundup/ipython/issue14. This bug had been
3805 http://www.scipy.net/roundup/ipython/issue14. This bug had been
3794 introduced in 0.6.0 (on 2004-05-06).
3806 introduced in 0.6.0 (on 2004-05-06).
3795
3807
3796 2004-05-13 *** Released version 0.6.0
3808 2004-05-13 *** Released version 0.6.0
3797
3809
3798 2004-05-13 Fernando Perez <fperez@colorado.edu>
3810 2004-05-13 Fernando Perez <fperez@colorado.edu>
3799
3811
3800 * debian/: Added debian/ directory to CVS, so that debian support
3812 * debian/: Added debian/ directory to CVS, so that debian support
3801 is publicly accessible. The debian package is maintained by Jack
3813 is publicly accessible. The debian package is maintained by Jack
3802 Moffit <jack-AT-xiph.org>.
3814 Moffit <jack-AT-xiph.org>.
3803
3815
3804 * Documentation: included the notes about an ipython-based system
3816 * Documentation: included the notes about an ipython-based system
3805 shell (the hypothetical 'pysh') into the new_design.pdf document,
3817 shell (the hypothetical 'pysh') into the new_design.pdf document,
3806 so that these ideas get distributed to users along with the
3818 so that these ideas get distributed to users along with the
3807 official documentation.
3819 official documentation.
3808
3820
3809 2004-05-10 Fernando Perez <fperez@colorado.edu>
3821 2004-05-10 Fernando Perez <fperez@colorado.edu>
3810
3822
3811 * IPython/Logger.py (Logger.create_log): fix recently introduced
3823 * IPython/Logger.py (Logger.create_log): fix recently introduced
3812 bug (misindented line) where logstart would fail when not given an
3824 bug (misindented line) where logstart would fail when not given an
3813 explicit filename.
3825 explicit filename.
3814
3826
3815 2004-05-09 Fernando Perez <fperez@colorado.edu>
3827 2004-05-09 Fernando Perez <fperez@colorado.edu>
3816
3828
3817 * IPython/Magic.py (Magic.parse_options): skip system call when
3829 * IPython/Magic.py (Magic.parse_options): skip system call when
3818 there are no options to look for. Faster, cleaner for the common
3830 there are no options to look for. Faster, cleaner for the common
3819 case.
3831 case.
3820
3832
3821 * Documentation: many updates to the manual: describing Windows
3833 * Documentation: many updates to the manual: describing Windows
3822 support better, Gnuplot updates, credits, misc small stuff. Also
3834 support better, Gnuplot updates, credits, misc small stuff. Also
3823 updated the new_design doc a bit.
3835 updated the new_design doc a bit.
3824
3836
3825 2004-05-06 *** Released version 0.6.0.rc1
3837 2004-05-06 *** Released version 0.6.0.rc1
3826
3838
3827 2004-05-06 Fernando Perez <fperez@colorado.edu>
3839 2004-05-06 Fernando Perez <fperez@colorado.edu>
3828
3840
3829 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
3841 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
3830 operations to use the vastly more efficient list/''.join() method.
3842 operations to use the vastly more efficient list/''.join() method.
3831 (FormattedTB.text): Fix
3843 (FormattedTB.text): Fix
3832 http://www.scipy.net/roundup/ipython/issue12 - exception source
3844 http://www.scipy.net/roundup/ipython/issue12 - exception source
3833 extract not updated after reload. Thanks to Mike Salib
3845 extract not updated after reload. Thanks to Mike Salib
3834 <msalib-AT-mit.edu> for pinning the source of the problem.
3846 <msalib-AT-mit.edu> for pinning the source of the problem.
3835 Fortunately, the solution works inside ipython and doesn't require
3847 Fortunately, the solution works inside ipython and doesn't require
3836 any changes to python proper.
3848 any changes to python proper.
3837
3849
3838 * IPython/Magic.py (Magic.parse_options): Improved to process the
3850 * IPython/Magic.py (Magic.parse_options): Improved to process the
3839 argument list as a true shell would (by actually using the
3851 argument list as a true shell would (by actually using the
3840 underlying system shell). This way, all @magics automatically get
3852 underlying system shell). This way, all @magics automatically get
3841 shell expansion for variables. Thanks to a comment by Alex
3853 shell expansion for variables. Thanks to a comment by Alex
3842 Schmolck.
3854 Schmolck.
3843
3855
3844 2004-04-04 Fernando Perez <fperez@colorado.edu>
3856 2004-04-04 Fernando Perez <fperez@colorado.edu>
3845
3857
3846 * IPython/iplib.py (InteractiveShell.interact): Added a special
3858 * IPython/iplib.py (InteractiveShell.interact): Added a special
3847 trap for a debugger quit exception, which is basically impossible
3859 trap for a debugger quit exception, which is basically impossible
3848 to handle by normal mechanisms, given what pdb does to the stack.
3860 to handle by normal mechanisms, given what pdb does to the stack.
3849 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
3861 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
3850
3862
3851 2004-04-03 Fernando Perez <fperez@colorado.edu>
3863 2004-04-03 Fernando Perez <fperez@colorado.edu>
3852
3864
3853 * IPython/genutils.py (Term): Standardized the names of the Term
3865 * IPython/genutils.py (Term): Standardized the names of the Term
3854 class streams to cin/cout/cerr, following C++ naming conventions
3866 class streams to cin/cout/cerr, following C++ naming conventions
3855 (I can't use in/out/err because 'in' is not a valid attribute
3867 (I can't use in/out/err because 'in' is not a valid attribute
3856 name).
3868 name).
3857
3869
3858 * IPython/iplib.py (InteractiveShell.interact): don't increment
3870 * IPython/iplib.py (InteractiveShell.interact): don't increment
3859 the prompt if there's no user input. By Daniel 'Dang' Griffith
3871 the prompt if there's no user input. By Daniel 'Dang' Griffith
3860 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
3872 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
3861 Francois Pinard.
3873 Francois Pinard.
3862
3874
3863 2004-04-02 Fernando Perez <fperez@colorado.edu>
3875 2004-04-02 Fernando Perez <fperez@colorado.edu>
3864
3876
3865 * IPython/genutils.py (Stream.__init__): Modified to survive at
3877 * IPython/genutils.py (Stream.__init__): Modified to survive at
3866 least importing in contexts where stdin/out/err aren't true file
3878 least importing in contexts where stdin/out/err aren't true file
3867 objects, such as PyCrust (they lack fileno() and mode). However,
3879 objects, such as PyCrust (they lack fileno() and mode). However,
3868 the recovery facilities which rely on these things existing will
3880 the recovery facilities which rely on these things existing will
3869 not work.
3881 not work.
3870
3882
3871 2004-04-01 Fernando Perez <fperez@colorado.edu>
3883 2004-04-01 Fernando Perez <fperez@colorado.edu>
3872
3884
3873 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
3885 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
3874 use the new getoutputerror() function, so it properly
3886 use the new getoutputerror() function, so it properly
3875 distinguishes stdout/err.
3887 distinguishes stdout/err.
3876
3888
3877 * IPython/genutils.py (getoutputerror): added a function to
3889 * IPython/genutils.py (getoutputerror): added a function to
3878 capture separately the standard output and error of a command.
3890 capture separately the standard output and error of a command.
3879 After a comment from dang on the mailing lists. This code is
3891 After a comment from dang on the mailing lists. This code is
3880 basically a modified version of commands.getstatusoutput(), from
3892 basically a modified version of commands.getstatusoutput(), from
3881 the standard library.
3893 the standard library.
3882
3894
3883 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
3895 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
3884 '!!' as a special syntax (shorthand) to access @sx.
3896 '!!' as a special syntax (shorthand) to access @sx.
3885
3897
3886 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
3898 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
3887 command and return its output as a list split on '\n'.
3899 command and return its output as a list split on '\n'.
3888
3900
3889 2004-03-31 Fernando Perez <fperez@colorado.edu>
3901 2004-03-31 Fernando Perez <fperez@colorado.edu>
3890
3902
3891 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
3903 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
3892 method to dictionaries used as FakeModule instances if they lack
3904 method to dictionaries used as FakeModule instances if they lack
3893 it. At least pydoc in python2.3 breaks for runtime-defined
3905 it. At least pydoc in python2.3 breaks for runtime-defined
3894 functions without this hack. At some point I need to _really_
3906 functions without this hack. At some point I need to _really_
3895 understand what FakeModule is doing, because it's a gross hack.
3907 understand what FakeModule is doing, because it's a gross hack.
3896 But it solves Arnd's problem for now...
3908 But it solves Arnd's problem for now...
3897
3909
3898 2004-02-27 Fernando Perez <fperez@colorado.edu>
3910 2004-02-27 Fernando Perez <fperez@colorado.edu>
3899
3911
3900 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
3912 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
3901 mode would behave erratically. Also increased the number of
3913 mode would behave erratically. Also increased the number of
3902 possible logs in rotate mod to 999. Thanks to Rod Holland
3914 possible logs in rotate mod to 999. Thanks to Rod Holland
3903 <rhh@StructureLABS.com> for the report and fixes.
3915 <rhh@StructureLABS.com> for the report and fixes.
3904
3916
3905 2004-02-26 Fernando Perez <fperez@colorado.edu>
3917 2004-02-26 Fernando Perez <fperez@colorado.edu>
3906
3918
3907 * IPython/genutils.py (page): Check that the curses module really
3919 * IPython/genutils.py (page): Check that the curses module really
3908 has the initscr attribute before trying to use it. For some
3920 has the initscr attribute before trying to use it. For some
3909 reason, the Solaris curses module is missing this. I think this
3921 reason, the Solaris curses module is missing this. I think this
3910 should be considered a Solaris python bug, but I'm not sure.
3922 should be considered a Solaris python bug, but I'm not sure.
3911
3923
3912 2004-01-17 Fernando Perez <fperez@colorado.edu>
3924 2004-01-17 Fernando Perez <fperez@colorado.edu>
3913
3925
3914 * IPython/genutils.py (Stream.__init__): Changes to try to make
3926 * IPython/genutils.py (Stream.__init__): Changes to try to make
3915 ipython robust against stdin/out/err being closed by the user.
3927 ipython robust against stdin/out/err being closed by the user.
3916 This is 'user error' (and blocks a normal python session, at least
3928 This is 'user error' (and blocks a normal python session, at least
3917 the stdout case). However, Ipython should be able to survive such
3929 the stdout case). However, Ipython should be able to survive such
3918 instances of abuse as gracefully as possible. To simplify the
3930 instances of abuse as gracefully as possible. To simplify the
3919 coding and maintain compatibility with Gary Bishop's Term
3931 coding and maintain compatibility with Gary Bishop's Term
3920 contributions, I've made use of classmethods for this. I think
3932 contributions, I've made use of classmethods for this. I think
3921 this introduces a dependency on python 2.2.
3933 this introduces a dependency on python 2.2.
3922
3934
3923 2004-01-13 Fernando Perez <fperez@colorado.edu>
3935 2004-01-13 Fernando Perez <fperez@colorado.edu>
3924
3936
3925 * IPython/numutils.py (exp_safe): simplified the code a bit and
3937 * IPython/numutils.py (exp_safe): simplified the code a bit and
3926 removed the need for importing the kinds module altogether.
3938 removed the need for importing the kinds module altogether.
3927
3939
3928 2004-01-06 Fernando Perez <fperez@colorado.edu>
3940 2004-01-06 Fernando Perez <fperez@colorado.edu>
3929
3941
3930 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
3942 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
3931 a magic function instead, after some community feedback. No
3943 a magic function instead, after some community feedback. No
3932 special syntax will exist for it, but its name is deliberately
3944 special syntax will exist for it, but its name is deliberately
3933 very short.
3945 very short.
3934
3946
3935 2003-12-20 Fernando Perez <fperez@colorado.edu>
3947 2003-12-20 Fernando Perez <fperez@colorado.edu>
3936
3948
3937 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
3949 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
3938 new functionality, to automagically assign the result of a shell
3950 new functionality, to automagically assign the result of a shell
3939 command to a variable. I'll solicit some community feedback on
3951 command to a variable. I'll solicit some community feedback on
3940 this before making it permanent.
3952 this before making it permanent.
3941
3953
3942 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
3954 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
3943 requested about callables for which inspect couldn't obtain a
3955 requested about callables for which inspect couldn't obtain a
3944 proper argspec. Thanks to a crash report sent by Etienne
3956 proper argspec. Thanks to a crash report sent by Etienne
3945 Posthumus <etienne-AT-apple01.cs.vu.nl>.
3957 Posthumus <etienne-AT-apple01.cs.vu.nl>.
3946
3958
3947 2003-12-09 Fernando Perez <fperez@colorado.edu>
3959 2003-12-09 Fernando Perez <fperez@colorado.edu>
3948
3960
3949 * IPython/genutils.py (page): patch for the pager to work across
3961 * IPython/genutils.py (page): patch for the pager to work across
3950 various versions of Windows. By Gary Bishop.
3962 various versions of Windows. By Gary Bishop.
3951
3963
3952 2003-12-04 Fernando Perez <fperez@colorado.edu>
3964 2003-12-04 Fernando Perez <fperez@colorado.edu>
3953
3965
3954 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
3966 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
3955 Gnuplot.py version 1.7, whose internal names changed quite a bit.
3967 Gnuplot.py version 1.7, whose internal names changed quite a bit.
3956 While I tested this and it looks ok, there may still be corner
3968 While I tested this and it looks ok, there may still be corner
3957 cases I've missed.
3969 cases I've missed.
3958
3970
3959 2003-12-01 Fernando Perez <fperez@colorado.edu>
3971 2003-12-01 Fernando Perez <fperez@colorado.edu>
3960
3972
3961 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
3973 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
3962 where a line like 'p,q=1,2' would fail because the automagic
3974 where a line like 'p,q=1,2' would fail because the automagic
3963 system would be triggered for @p.
3975 system would be triggered for @p.
3964
3976
3965 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
3977 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
3966 cleanups, code unmodified.
3978 cleanups, code unmodified.
3967
3979
3968 * IPython/genutils.py (Term): added a class for IPython to handle
3980 * IPython/genutils.py (Term): added a class for IPython to handle
3969 output. In most cases it will just be a proxy for stdout/err, but
3981 output. In most cases it will just be a proxy for stdout/err, but
3970 having this allows modifications to be made for some platforms,
3982 having this allows modifications to be made for some platforms,
3971 such as handling color escapes under Windows. All of this code
3983 such as handling color escapes under Windows. All of this code
3972 was contributed by Gary Bishop, with minor modifications by me.
3984 was contributed by Gary Bishop, with minor modifications by me.
3973 The actual changes affect many files.
3985 The actual changes affect many files.
3974
3986
3975 2003-11-30 Fernando Perez <fperez@colorado.edu>
3987 2003-11-30 Fernando Perez <fperez@colorado.edu>
3976
3988
3977 * IPython/iplib.py (file_matches): new completion code, courtesy
3989 * IPython/iplib.py (file_matches): new completion code, courtesy
3978 of Jeff Collins. This enables filename completion again under
3990 of Jeff Collins. This enables filename completion again under
3979 python 2.3, which disabled it at the C level.
3991 python 2.3, which disabled it at the C level.
3980
3992
3981 2003-11-11 Fernando Perez <fperez@colorado.edu>
3993 2003-11-11 Fernando Perez <fperez@colorado.edu>
3982
3994
3983 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
3995 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
3984 for Numeric.array(map(...)), but often convenient.
3996 for Numeric.array(map(...)), but often convenient.
3985
3997
3986 2003-11-05 Fernando Perez <fperez@colorado.edu>
3998 2003-11-05 Fernando Perez <fperez@colorado.edu>
3987
3999
3988 * IPython/numutils.py (frange): Changed a call from int() to
4000 * IPython/numutils.py (frange): Changed a call from int() to
3989 int(round()) to prevent a problem reported with arange() in the
4001 int(round()) to prevent a problem reported with arange() in the
3990 numpy list.
4002 numpy list.
3991
4003
3992 2003-10-06 Fernando Perez <fperez@colorado.edu>
4004 2003-10-06 Fernando Perez <fperez@colorado.edu>
3993
4005
3994 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
4006 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
3995 prevent crashes if sys lacks an argv attribute (it happens with
4007 prevent crashes if sys lacks an argv attribute (it happens with
3996 embedded interpreters which build a bare-bones sys module).
4008 embedded interpreters which build a bare-bones sys module).
3997 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
4009 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
3998
4010
3999 2003-09-24 Fernando Perez <fperez@colorado.edu>
4011 2003-09-24 Fernando Perez <fperez@colorado.edu>
4000
4012
4001 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
4013 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
4002 to protect against poorly written user objects where __getattr__
4014 to protect against poorly written user objects where __getattr__
4003 raises exceptions other than AttributeError. Thanks to a bug
4015 raises exceptions other than AttributeError. Thanks to a bug
4004 report by Oliver Sander <osander-AT-gmx.de>.
4016 report by Oliver Sander <osander-AT-gmx.de>.
4005
4017
4006 * IPython/FakeModule.py (FakeModule.__repr__): this method was
4018 * IPython/FakeModule.py (FakeModule.__repr__): this method was
4007 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
4019 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
4008
4020
4009 2003-09-09 Fernando Perez <fperez@colorado.edu>
4021 2003-09-09 Fernando Perez <fperez@colorado.edu>
4010
4022
4011 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
4023 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
4012 unpacking a list whith a callable as first element would
4024 unpacking a list whith a callable as first element would
4013 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
4025 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
4014 Collins.
4026 Collins.
4015
4027
4016 2003-08-25 *** Released version 0.5.0
4028 2003-08-25 *** Released version 0.5.0
4017
4029
4018 2003-08-22 Fernando Perez <fperez@colorado.edu>
4030 2003-08-22 Fernando Perez <fperez@colorado.edu>
4019
4031
4020 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
4032 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
4021 improperly defined user exceptions. Thanks to feedback from Mark
4033 improperly defined user exceptions. Thanks to feedback from Mark
4022 Russell <mrussell-AT-verio.net>.
4034 Russell <mrussell-AT-verio.net>.
4023
4035
4024 2003-08-20 Fernando Perez <fperez@colorado.edu>
4036 2003-08-20 Fernando Perez <fperez@colorado.edu>
4025
4037
4026 * IPython/OInspect.py (Inspector.pinfo): changed String Form
4038 * IPython/OInspect.py (Inspector.pinfo): changed String Form
4027 printing so that it would print multi-line string forms starting
4039 printing so that it would print multi-line string forms starting
4028 with a new line. This way the formatting is better respected for
4040 with a new line. This way the formatting is better respected for
4029 objects which work hard to make nice string forms.
4041 objects which work hard to make nice string forms.
4030
4042
4031 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
4043 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
4032 autocall would overtake data access for objects with both
4044 autocall would overtake data access for objects with both
4033 __getitem__ and __call__.
4045 __getitem__ and __call__.
4034
4046
4035 2003-08-19 *** Released version 0.5.0-rc1
4047 2003-08-19 *** Released version 0.5.0-rc1
4036
4048
4037 2003-08-19 Fernando Perez <fperez@colorado.edu>
4049 2003-08-19 Fernando Perez <fperez@colorado.edu>
4038
4050
4039 * IPython/deep_reload.py (load_tail): single tiny change here
4051 * IPython/deep_reload.py (load_tail): single tiny change here
4040 seems to fix the long-standing bug of dreload() failing to work
4052 seems to fix the long-standing bug of dreload() failing to work
4041 for dotted names. But this module is pretty tricky, so I may have
4053 for dotted names. But this module is pretty tricky, so I may have
4042 missed some subtlety. Needs more testing!.
4054 missed some subtlety. Needs more testing!.
4043
4055
4044 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
4056 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
4045 exceptions which have badly implemented __str__ methods.
4057 exceptions which have badly implemented __str__ methods.
4046 (VerboseTB.text): harden against inspect.getinnerframes crashing,
4058 (VerboseTB.text): harden against inspect.getinnerframes crashing,
4047 which I've been getting reports about from Python 2.3 users. I
4059 which I've been getting reports about from Python 2.3 users. I
4048 wish I had a simple test case to reproduce the problem, so I could
4060 wish I had a simple test case to reproduce the problem, so I could
4049 either write a cleaner workaround or file a bug report if
4061 either write a cleaner workaround or file a bug report if
4050 necessary.
4062 necessary.
4051
4063
4052 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
4064 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
4053 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
4065 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
4054 a bug report by Tjabo Kloppenburg.
4066 a bug report by Tjabo Kloppenburg.
4055
4067
4056 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
4068 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
4057 crashes. Wrapped the pdb call in a blanket try/except, since pdb
4069 crashes. Wrapped the pdb call in a blanket try/except, since pdb
4058 seems rather unstable. Thanks to a bug report by Tjabo
4070 seems rather unstable. Thanks to a bug report by Tjabo
4059 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
4071 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
4060
4072
4061 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
4073 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
4062 this out soon because of the critical fixes in the inner loop for
4074 this out soon because of the critical fixes in the inner loop for
4063 generators.
4075 generators.
4064
4076
4065 * IPython/Magic.py (Magic.getargspec): removed. This (and
4077 * IPython/Magic.py (Magic.getargspec): removed. This (and
4066 _get_def) have been obsoleted by OInspect for a long time, I
4078 _get_def) have been obsoleted by OInspect for a long time, I
4067 hadn't noticed that they were dead code.
4079 hadn't noticed that they were dead code.
4068 (Magic._ofind): restored _ofind functionality for a few literals
4080 (Magic._ofind): restored _ofind functionality for a few literals
4069 (those in ["''",'""','[]','{}','()']). But it won't work anymore
4081 (those in ["''",'""','[]','{}','()']). But it won't work anymore
4070 for things like "hello".capitalize?, since that would require a
4082 for things like "hello".capitalize?, since that would require a
4071 potentially dangerous eval() again.
4083 potentially dangerous eval() again.
4072
4084
4073 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
4085 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
4074 logic a bit more to clean up the escapes handling and minimize the
4086 logic a bit more to clean up the escapes handling and minimize the
4075 use of _ofind to only necessary cases. The interactive 'feel' of
4087 use of _ofind to only necessary cases. The interactive 'feel' of
4076 IPython should have improved quite a bit with the changes in
4088 IPython should have improved quite a bit with the changes in
4077 _prefilter and _ofind (besides being far safer than before).
4089 _prefilter and _ofind (besides being far safer than before).
4078
4090
4079 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
4091 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
4080 obscure, never reported). Edit would fail to find the object to
4092 obscure, never reported). Edit would fail to find the object to
4081 edit under some circumstances.
4093 edit under some circumstances.
4082 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
4094 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
4083 which were causing double-calling of generators. Those eval calls
4095 which were causing double-calling of generators. Those eval calls
4084 were _very_ dangerous, since code with side effects could be
4096 were _very_ dangerous, since code with side effects could be
4085 triggered. As they say, 'eval is evil'... These were the
4097 triggered. As they say, 'eval is evil'... These were the
4086 nastiest evals in IPython. Besides, _ofind is now far simpler,
4098 nastiest evals in IPython. Besides, _ofind is now far simpler,
4087 and it should also be quite a bit faster. Its use of inspect is
4099 and it should also be quite a bit faster. Its use of inspect is
4088 also safer, so perhaps some of the inspect-related crashes I've
4100 also safer, so perhaps some of the inspect-related crashes I've
4089 seen lately with Python 2.3 might be taken care of. That will
4101 seen lately with Python 2.3 might be taken care of. That will
4090 need more testing.
4102 need more testing.
4091
4103
4092 2003-08-17 Fernando Perez <fperez@colorado.edu>
4104 2003-08-17 Fernando Perez <fperez@colorado.edu>
4093
4105
4094 * IPython/iplib.py (InteractiveShell._prefilter): significant
4106 * IPython/iplib.py (InteractiveShell._prefilter): significant
4095 simplifications to the logic for handling user escapes. Faster
4107 simplifications to the logic for handling user escapes. Faster
4096 and simpler code.
4108 and simpler code.
4097
4109
4098 2003-08-14 Fernando Perez <fperez@colorado.edu>
4110 2003-08-14 Fernando Perez <fperez@colorado.edu>
4099
4111
4100 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
4112 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
4101 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
4113 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
4102 but it should be quite a bit faster. And the recursive version
4114 but it should be quite a bit faster. And the recursive version
4103 generated O(log N) intermediate storage for all rank>1 arrays,
4115 generated O(log N) intermediate storage for all rank>1 arrays,
4104 even if they were contiguous.
4116 even if they were contiguous.
4105 (l1norm): Added this function.
4117 (l1norm): Added this function.
4106 (norm): Added this function for arbitrary norms (including
4118 (norm): Added this function for arbitrary norms (including
4107 l-infinity). l1 and l2 are still special cases for convenience
4119 l-infinity). l1 and l2 are still special cases for convenience
4108 and speed.
4120 and speed.
4109
4121
4110 2003-08-03 Fernando Perez <fperez@colorado.edu>
4122 2003-08-03 Fernando Perez <fperez@colorado.edu>
4111
4123
4112 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
4124 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
4113 exceptions, which now raise PendingDeprecationWarnings in Python
4125 exceptions, which now raise PendingDeprecationWarnings in Python
4114 2.3. There were some in Magic and some in Gnuplot2.
4126 2.3. There were some in Magic and some in Gnuplot2.
4115
4127
4116 2003-06-30 Fernando Perez <fperez@colorado.edu>
4128 2003-06-30 Fernando Perez <fperez@colorado.edu>
4117
4129
4118 * IPython/genutils.py (page): modified to call curses only for
4130 * IPython/genutils.py (page): modified to call curses only for
4119 terminals where TERM=='xterm'. After problems under many other
4131 terminals where TERM=='xterm'. After problems under many other
4120 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
4132 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
4121
4133
4122 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
4134 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
4123 would be triggered when readline was absent. This was just an old
4135 would be triggered when readline was absent. This was just an old
4124 debugging statement I'd forgotten to take out.
4136 debugging statement I'd forgotten to take out.
4125
4137
4126 2003-06-20 Fernando Perez <fperez@colorado.edu>
4138 2003-06-20 Fernando Perez <fperez@colorado.edu>
4127
4139
4128 * IPython/genutils.py (clock): modified to return only user time
4140 * IPython/genutils.py (clock): modified to return only user time
4129 (not counting system time), after a discussion on scipy. While
4141 (not counting system time), after a discussion on scipy. While
4130 system time may be a useful quantity occasionally, it may much
4142 system time may be a useful quantity occasionally, it may much
4131 more easily be skewed by occasional swapping or other similar
4143 more easily be skewed by occasional swapping or other similar
4132 activity.
4144 activity.
4133
4145
4134 2003-06-05 Fernando Perez <fperez@colorado.edu>
4146 2003-06-05 Fernando Perez <fperez@colorado.edu>
4135
4147
4136 * IPython/numutils.py (identity): new function, for building
4148 * IPython/numutils.py (identity): new function, for building
4137 arbitrary rank Kronecker deltas (mostly backwards compatible with
4149 arbitrary rank Kronecker deltas (mostly backwards compatible with
4138 Numeric.identity)
4150 Numeric.identity)
4139
4151
4140 2003-06-03 Fernando Perez <fperez@colorado.edu>
4152 2003-06-03 Fernando Perez <fperez@colorado.edu>
4141
4153
4142 * IPython/iplib.py (InteractiveShell.handle_magic): protect
4154 * IPython/iplib.py (InteractiveShell.handle_magic): protect
4143 arguments passed to magics with spaces, to allow trailing '\' to
4155 arguments passed to magics with spaces, to allow trailing '\' to
4144 work normally (mainly for Windows users).
4156 work normally (mainly for Windows users).
4145
4157
4146 2003-05-29 Fernando Perez <fperez@colorado.edu>
4158 2003-05-29 Fernando Perez <fperez@colorado.edu>
4147
4159
4148 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
4160 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
4149 instead of pydoc.help. This fixes a bizarre behavior where
4161 instead of pydoc.help. This fixes a bizarre behavior where
4150 printing '%s' % locals() would trigger the help system. Now
4162 printing '%s' % locals() would trigger the help system. Now
4151 ipython behaves like normal python does.
4163 ipython behaves like normal python does.
4152
4164
4153 Note that if one does 'from pydoc import help', the bizarre
4165 Note that if one does 'from pydoc import help', the bizarre
4154 behavior returns, but this will also happen in normal python, so
4166 behavior returns, but this will also happen in normal python, so
4155 it's not an ipython bug anymore (it has to do with how pydoc.help
4167 it's not an ipython bug anymore (it has to do with how pydoc.help
4156 is implemented).
4168 is implemented).
4157
4169
4158 2003-05-22 Fernando Perez <fperez@colorado.edu>
4170 2003-05-22 Fernando Perez <fperez@colorado.edu>
4159
4171
4160 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
4172 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
4161 return [] instead of None when nothing matches, also match to end
4173 return [] instead of None when nothing matches, also match to end
4162 of line. Patch by Gary Bishop.
4174 of line. Patch by Gary Bishop.
4163
4175
4164 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
4176 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
4165 protection as before, for files passed on the command line. This
4177 protection as before, for files passed on the command line. This
4166 prevents the CrashHandler from kicking in if user files call into
4178 prevents the CrashHandler from kicking in if user files call into
4167 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
4179 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
4168 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
4180 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
4169
4181
4170 2003-05-20 *** Released version 0.4.0
4182 2003-05-20 *** Released version 0.4.0
4171
4183
4172 2003-05-20 Fernando Perez <fperez@colorado.edu>
4184 2003-05-20 Fernando Perez <fperez@colorado.edu>
4173
4185
4174 * setup.py: added support for manpages. It's a bit hackish b/c of
4186 * setup.py: added support for manpages. It's a bit hackish b/c of
4175 a bug in the way the bdist_rpm distutils target handles gzipped
4187 a bug in the way the bdist_rpm distutils target handles gzipped
4176 manpages, but it works. After a patch by Jack.
4188 manpages, but it works. After a patch by Jack.
4177
4189
4178 2003-05-19 Fernando Perez <fperez@colorado.edu>
4190 2003-05-19 Fernando Perez <fperez@colorado.edu>
4179
4191
4180 * IPython/numutils.py: added a mockup of the kinds module, since
4192 * IPython/numutils.py: added a mockup of the kinds module, since
4181 it was recently removed from Numeric. This way, numutils will
4193 it was recently removed from Numeric. This way, numutils will
4182 work for all users even if they are missing kinds.
4194 work for all users even if they are missing kinds.
4183
4195
4184 * IPython/Magic.py (Magic._ofind): Harden against an inspect
4196 * IPython/Magic.py (Magic._ofind): Harden against an inspect
4185 failure, which can occur with SWIG-wrapped extensions. After a
4197 failure, which can occur with SWIG-wrapped extensions. After a
4186 crash report from Prabhu.
4198 crash report from Prabhu.
4187
4199
4188 2003-05-16 Fernando Perez <fperez@colorado.edu>
4200 2003-05-16 Fernando Perez <fperez@colorado.edu>
4189
4201
4190 * IPython/iplib.py (InteractiveShell.excepthook): New method to
4202 * IPython/iplib.py (InteractiveShell.excepthook): New method to
4191 protect ipython from user code which may call directly
4203 protect ipython from user code which may call directly
4192 sys.excepthook (this looks like an ipython crash to the user, even
4204 sys.excepthook (this looks like an ipython crash to the user, even
4193 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
4205 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
4194 This is especially important to help users of WxWindows, but may
4206 This is especially important to help users of WxWindows, but may
4195 also be useful in other cases.
4207 also be useful in other cases.
4196
4208
4197 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
4209 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
4198 an optional tb_offset to be specified, and to preserve exception
4210 an optional tb_offset to be specified, and to preserve exception
4199 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
4211 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
4200
4212
4201 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
4213 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
4202
4214
4203 2003-05-15 Fernando Perez <fperez@colorado.edu>
4215 2003-05-15 Fernando Perez <fperez@colorado.edu>
4204
4216
4205 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
4217 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
4206 installing for a new user under Windows.
4218 installing for a new user under Windows.
4207
4219
4208 2003-05-12 Fernando Perez <fperez@colorado.edu>
4220 2003-05-12 Fernando Perez <fperez@colorado.edu>
4209
4221
4210 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
4222 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
4211 handler for Emacs comint-based lines. Currently it doesn't do
4223 handler for Emacs comint-based lines. Currently it doesn't do
4212 much (but importantly, it doesn't update the history cache). In
4224 much (but importantly, it doesn't update the history cache). In
4213 the future it may be expanded if Alex needs more functionality
4225 the future it may be expanded if Alex needs more functionality
4214 there.
4226 there.
4215
4227
4216 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
4228 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
4217 info to crash reports.
4229 info to crash reports.
4218
4230
4219 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
4231 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
4220 just like Python's -c. Also fixed crash with invalid -color
4232 just like Python's -c. Also fixed crash with invalid -color
4221 option value at startup. Thanks to Will French
4233 option value at startup. Thanks to Will French
4222 <wfrench-AT-bestweb.net> for the bug report.
4234 <wfrench-AT-bestweb.net> for the bug report.
4223
4235
4224 2003-05-09 Fernando Perez <fperez@colorado.edu>
4236 2003-05-09 Fernando Perez <fperez@colorado.edu>
4225
4237
4226 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
4238 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
4227 to EvalDict (it's a mapping, after all) and simplified its code
4239 to EvalDict (it's a mapping, after all) and simplified its code
4228 quite a bit, after a nice discussion on c.l.py where Gustavo
4240 quite a bit, after a nice discussion on c.l.py where Gustavo
4229 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
4241 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
4230
4242
4231 2003-04-30 Fernando Perez <fperez@colorado.edu>
4243 2003-04-30 Fernando Perez <fperez@colorado.edu>
4232
4244
4233 * IPython/genutils.py (timings_out): modified it to reduce its
4245 * IPython/genutils.py (timings_out): modified it to reduce its
4234 overhead in the common reps==1 case.
4246 overhead in the common reps==1 case.
4235
4247
4236 2003-04-29 Fernando Perez <fperez@colorado.edu>
4248 2003-04-29 Fernando Perez <fperez@colorado.edu>
4237
4249
4238 * IPython/genutils.py (timings_out): Modified to use the resource
4250 * IPython/genutils.py (timings_out): Modified to use the resource
4239 module, which avoids the wraparound problems of time.clock().
4251 module, which avoids the wraparound problems of time.clock().
4240
4252
4241 2003-04-17 *** Released version 0.2.15pre4
4253 2003-04-17 *** Released version 0.2.15pre4
4242
4254
4243 2003-04-17 Fernando Perez <fperez@colorado.edu>
4255 2003-04-17 Fernando Perez <fperez@colorado.edu>
4244
4256
4245 * setup.py (scriptfiles): Split windows-specific stuff over to a
4257 * setup.py (scriptfiles): Split windows-specific stuff over to a
4246 separate file, in an attempt to have a Windows GUI installer.
4258 separate file, in an attempt to have a Windows GUI installer.
4247 That didn't work, but part of the groundwork is done.
4259 That didn't work, but part of the groundwork is done.
4248
4260
4249 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
4261 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
4250 indent/unindent with 4 spaces. Particularly useful in combination
4262 indent/unindent with 4 spaces. Particularly useful in combination
4251 with the new auto-indent option.
4263 with the new auto-indent option.
4252
4264
4253 2003-04-16 Fernando Perez <fperez@colorado.edu>
4265 2003-04-16 Fernando Perez <fperez@colorado.edu>
4254
4266
4255 * IPython/Magic.py: various replacements of self.rc for
4267 * IPython/Magic.py: various replacements of self.rc for
4256 self.shell.rc. A lot more remains to be done to fully disentangle
4268 self.shell.rc. A lot more remains to be done to fully disentangle
4257 this class from the main Shell class.
4269 this class from the main Shell class.
4258
4270
4259 * IPython/GnuplotRuntime.py: added checks for mouse support so
4271 * IPython/GnuplotRuntime.py: added checks for mouse support so
4260 that we don't try to enable it if the current gnuplot doesn't
4272 that we don't try to enable it if the current gnuplot doesn't
4261 really support it. Also added checks so that we don't try to
4273 really support it. Also added checks so that we don't try to
4262 enable persist under Windows (where Gnuplot doesn't recognize the
4274 enable persist under Windows (where Gnuplot doesn't recognize the
4263 option).
4275 option).
4264
4276
4265 * IPython/iplib.py (InteractiveShell.interact): Added optional
4277 * IPython/iplib.py (InteractiveShell.interact): Added optional
4266 auto-indenting code, after a patch by King C. Shu
4278 auto-indenting code, after a patch by King C. Shu
4267 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
4279 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
4268 get along well with pasting indented code. If I ever figure out
4280 get along well with pasting indented code. If I ever figure out
4269 how to make that part go well, it will become on by default.
4281 how to make that part go well, it will become on by default.
4270
4282
4271 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
4283 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
4272 crash ipython if there was an unmatched '%' in the user's prompt
4284 crash ipython if there was an unmatched '%' in the user's prompt
4273 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
4285 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
4274
4286
4275 * IPython/iplib.py (InteractiveShell.interact): removed the
4287 * IPython/iplib.py (InteractiveShell.interact): removed the
4276 ability to ask the user whether he wants to crash or not at the
4288 ability to ask the user whether he wants to crash or not at the
4277 'last line' exception handler. Calling functions at that point
4289 'last line' exception handler. Calling functions at that point
4278 changes the stack, and the error reports would have incorrect
4290 changes the stack, and the error reports would have incorrect
4279 tracebacks.
4291 tracebacks.
4280
4292
4281 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
4293 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
4282 pass through a peger a pretty-printed form of any object. After a
4294 pass through a peger a pretty-printed form of any object. After a
4283 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
4295 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
4284
4296
4285 2003-04-14 Fernando Perez <fperez@colorado.edu>
4297 2003-04-14 Fernando Perez <fperez@colorado.edu>
4286
4298
4287 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
4299 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
4288 all files in ~ would be modified at first install (instead of
4300 all files in ~ would be modified at first install (instead of
4289 ~/.ipython). This could be potentially disastrous, as the
4301 ~/.ipython). This could be potentially disastrous, as the
4290 modification (make line-endings native) could damage binary files.
4302 modification (make line-endings native) could damage binary files.
4291
4303
4292 2003-04-10 Fernando Perez <fperez@colorado.edu>
4304 2003-04-10 Fernando Perez <fperez@colorado.edu>
4293
4305
4294 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
4306 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
4295 handle only lines which are invalid python. This now means that
4307 handle only lines which are invalid python. This now means that
4296 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
4308 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
4297 for the bug report.
4309 for the bug report.
4298
4310
4299 2003-04-01 Fernando Perez <fperez@colorado.edu>
4311 2003-04-01 Fernando Perez <fperez@colorado.edu>
4300
4312
4301 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
4313 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
4302 where failing to set sys.last_traceback would crash pdb.pm().
4314 where failing to set sys.last_traceback would crash pdb.pm().
4303 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
4315 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
4304 report.
4316 report.
4305
4317
4306 2003-03-25 Fernando Perez <fperez@colorado.edu>
4318 2003-03-25 Fernando Perez <fperez@colorado.edu>
4307
4319
4308 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
4320 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
4309 before printing it (it had a lot of spurious blank lines at the
4321 before printing it (it had a lot of spurious blank lines at the
4310 end).
4322 end).
4311
4323
4312 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
4324 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
4313 output would be sent 21 times! Obviously people don't use this
4325 output would be sent 21 times! Obviously people don't use this
4314 too often, or I would have heard about it.
4326 too often, or I would have heard about it.
4315
4327
4316 2003-03-24 Fernando Perez <fperez@colorado.edu>
4328 2003-03-24 Fernando Perez <fperez@colorado.edu>
4317
4329
4318 * setup.py (scriptfiles): renamed the data_files parameter from
4330 * setup.py (scriptfiles): renamed the data_files parameter from
4319 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
4331 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
4320 for the patch.
4332 for the patch.
4321
4333
4322 2003-03-20 Fernando Perez <fperez@colorado.edu>
4334 2003-03-20 Fernando Perez <fperez@colorado.edu>
4323
4335
4324 * IPython/genutils.py (error): added error() and fatal()
4336 * IPython/genutils.py (error): added error() and fatal()
4325 functions.
4337 functions.
4326
4338
4327 2003-03-18 *** Released version 0.2.15pre3
4339 2003-03-18 *** Released version 0.2.15pre3
4328
4340
4329 2003-03-18 Fernando Perez <fperez@colorado.edu>
4341 2003-03-18 Fernando Perez <fperez@colorado.edu>
4330
4342
4331 * setupext/install_data_ext.py
4343 * setupext/install_data_ext.py
4332 (install_data_ext.initialize_options): Class contributed by Jack
4344 (install_data_ext.initialize_options): Class contributed by Jack
4333 Moffit for fixing the old distutils hack. He is sending this to
4345 Moffit for fixing the old distutils hack. He is sending this to
4334 the distutils folks so in the future we may not need it as a
4346 the distutils folks so in the future we may not need it as a
4335 private fix.
4347 private fix.
4336
4348
4337 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
4349 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
4338 changes for Debian packaging. See his patch for full details.
4350 changes for Debian packaging. See his patch for full details.
4339 The old distutils hack of making the ipythonrc* files carry a
4351 The old distutils hack of making the ipythonrc* files carry a
4340 bogus .py extension is gone, at last. Examples were moved to a
4352 bogus .py extension is gone, at last. Examples were moved to a
4341 separate subdir under doc/, and the separate executable scripts
4353 separate subdir under doc/, and the separate executable scripts
4342 now live in their own directory. Overall a great cleanup. The
4354 now live in their own directory. Overall a great cleanup. The
4343 manual was updated to use the new files, and setup.py has been
4355 manual was updated to use the new files, and setup.py has been
4344 fixed for this setup.
4356 fixed for this setup.
4345
4357
4346 * IPython/PyColorize.py (Parser.usage): made non-executable and
4358 * IPython/PyColorize.py (Parser.usage): made non-executable and
4347 created a pycolor wrapper around it to be included as a script.
4359 created a pycolor wrapper around it to be included as a script.
4348
4360
4349 2003-03-12 *** Released version 0.2.15pre2
4361 2003-03-12 *** Released version 0.2.15pre2
4350
4362
4351 2003-03-12 Fernando Perez <fperez@colorado.edu>
4363 2003-03-12 Fernando Perez <fperez@colorado.edu>
4352
4364
4353 * IPython/ColorANSI.py (make_color_table): Finally fixed the
4365 * IPython/ColorANSI.py (make_color_table): Finally fixed the
4354 long-standing problem with garbage characters in some terminals.
4366 long-standing problem with garbage characters in some terminals.
4355 The issue was really that the \001 and \002 escapes must _only_ be
4367 The issue was really that the \001 and \002 escapes must _only_ be
4356 passed to input prompts (which call readline), but _never_ to
4368 passed to input prompts (which call readline), but _never_ to
4357 normal text to be printed on screen. I changed ColorANSI to have
4369 normal text to be printed on screen. I changed ColorANSI to have
4358 two classes: TermColors and InputTermColors, each with the
4370 two classes: TermColors and InputTermColors, each with the
4359 appropriate escapes for input prompts or normal text. The code in
4371 appropriate escapes for input prompts or normal text. The code in
4360 Prompts.py got slightly more complicated, but this very old and
4372 Prompts.py got slightly more complicated, but this very old and
4361 annoying bug is finally fixed.
4373 annoying bug is finally fixed.
4362
4374
4363 All the credit for nailing down the real origin of this problem
4375 All the credit for nailing down the real origin of this problem
4364 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
4376 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
4365 *Many* thanks to him for spending quite a bit of effort on this.
4377 *Many* thanks to him for spending quite a bit of effort on this.
4366
4378
4367 2003-03-05 *** Released version 0.2.15pre1
4379 2003-03-05 *** Released version 0.2.15pre1
4368
4380
4369 2003-03-03 Fernando Perez <fperez@colorado.edu>
4381 2003-03-03 Fernando Perez <fperez@colorado.edu>
4370
4382
4371 * IPython/FakeModule.py: Moved the former _FakeModule to a
4383 * IPython/FakeModule.py: Moved the former _FakeModule to a
4372 separate file, because it's also needed by Magic (to fix a similar
4384 separate file, because it's also needed by Magic (to fix a similar
4373 pickle-related issue in @run).
4385 pickle-related issue in @run).
4374
4386
4375 2003-03-02 Fernando Perez <fperez@colorado.edu>
4387 2003-03-02 Fernando Perez <fperez@colorado.edu>
4376
4388
4377 * IPython/Magic.py (Magic.magic_autocall): new magic to control
4389 * IPython/Magic.py (Magic.magic_autocall): new magic to control
4378 the autocall option at runtime.
4390 the autocall option at runtime.
4379 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
4391 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
4380 across Magic.py to start separating Magic from InteractiveShell.
4392 across Magic.py to start separating Magic from InteractiveShell.
4381 (Magic._ofind): Fixed to return proper namespace for dotted
4393 (Magic._ofind): Fixed to return proper namespace for dotted
4382 names. Before, a dotted name would always return 'not currently
4394 names. Before, a dotted name would always return 'not currently
4383 defined', because it would find the 'parent'. s.x would be found,
4395 defined', because it would find the 'parent'. s.x would be found,
4384 but since 'x' isn't defined by itself, it would get confused.
4396 but since 'x' isn't defined by itself, it would get confused.
4385 (Magic.magic_run): Fixed pickling problems reported by Ralf
4397 (Magic.magic_run): Fixed pickling problems reported by Ralf
4386 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
4398 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
4387 that I'd used when Mike Heeter reported similar issues at the
4399 that I'd used when Mike Heeter reported similar issues at the
4388 top-level, but now for @run. It boils down to injecting the
4400 top-level, but now for @run. It boils down to injecting the
4389 namespace where code is being executed with something that looks
4401 namespace where code is being executed with something that looks
4390 enough like a module to fool pickle.dump(). Since a pickle stores
4402 enough like a module to fool pickle.dump(). Since a pickle stores
4391 a named reference to the importing module, we need this for
4403 a named reference to the importing module, we need this for
4392 pickles to save something sensible.
4404 pickles to save something sensible.
4393
4405
4394 * IPython/ipmaker.py (make_IPython): added an autocall option.
4406 * IPython/ipmaker.py (make_IPython): added an autocall option.
4395
4407
4396 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
4408 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
4397 the auto-eval code. Now autocalling is an option, and the code is
4409 the auto-eval code. Now autocalling is an option, and the code is
4398 also vastly safer. There is no more eval() involved at all.
4410 also vastly safer. There is no more eval() involved at all.
4399
4411
4400 2003-03-01 Fernando Perez <fperez@colorado.edu>
4412 2003-03-01 Fernando Perez <fperez@colorado.edu>
4401
4413
4402 * IPython/Magic.py (Magic._ofind): Changed interface to return a
4414 * IPython/Magic.py (Magic._ofind): Changed interface to return a
4403 dict with named keys instead of a tuple.
4415 dict with named keys instead of a tuple.
4404
4416
4405 * IPython: Started using CVS for IPython as of 0.2.15pre1.
4417 * IPython: Started using CVS for IPython as of 0.2.15pre1.
4406
4418
4407 * setup.py (make_shortcut): Fixed message about directories
4419 * setup.py (make_shortcut): Fixed message about directories
4408 created during Windows installation (the directories were ok, just
4420 created during Windows installation (the directories were ok, just
4409 the printed message was misleading). Thanks to Chris Liechti
4421 the printed message was misleading). Thanks to Chris Liechti
4410 <cliechti-AT-gmx.net> for the heads up.
4422 <cliechti-AT-gmx.net> for the heads up.
4411
4423
4412 2003-02-21 Fernando Perez <fperez@colorado.edu>
4424 2003-02-21 Fernando Perez <fperez@colorado.edu>
4413
4425
4414 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
4426 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
4415 of ValueError exception when checking for auto-execution. This
4427 of ValueError exception when checking for auto-execution. This
4416 one is raised by things like Numeric arrays arr.flat when the
4428 one is raised by things like Numeric arrays arr.flat when the
4417 array is non-contiguous.
4429 array is non-contiguous.
4418
4430
4419 2003-01-31 Fernando Perez <fperez@colorado.edu>
4431 2003-01-31 Fernando Perez <fperez@colorado.edu>
4420
4432
4421 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
4433 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
4422 not return any value at all (even though the command would get
4434 not return any value at all (even though the command would get
4423 executed).
4435 executed).
4424 (xsys): Flush stdout right after printing the command to ensure
4436 (xsys): Flush stdout right after printing the command to ensure
4425 proper ordering of commands and command output in the total
4437 proper ordering of commands and command output in the total
4426 output.
4438 output.
4427 (SystemExec/xsys/bq): Switched the names of xsys/bq and
4439 (SystemExec/xsys/bq): Switched the names of xsys/bq and
4428 system/getoutput as defaults. The old ones are kept for
4440 system/getoutput as defaults. The old ones are kept for
4429 compatibility reasons, so no code which uses this library needs
4441 compatibility reasons, so no code which uses this library needs
4430 changing.
4442 changing.
4431
4443
4432 2003-01-27 *** Released version 0.2.14
4444 2003-01-27 *** Released version 0.2.14
4433
4445
4434 2003-01-25 Fernando Perez <fperez@colorado.edu>
4446 2003-01-25 Fernando Perez <fperez@colorado.edu>
4435
4447
4436 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
4448 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
4437 functions defined in previous edit sessions could not be re-edited
4449 functions defined in previous edit sessions could not be re-edited
4438 (because the temp files were immediately removed). Now temp files
4450 (because the temp files were immediately removed). Now temp files
4439 are removed only at IPython's exit.
4451 are removed only at IPython's exit.
4440 (Magic.magic_run): Improved @run to perform shell-like expansions
4452 (Magic.magic_run): Improved @run to perform shell-like expansions
4441 on its arguments (~users and $VARS). With this, @run becomes more
4453 on its arguments (~users and $VARS). With this, @run becomes more
4442 like a normal command-line.
4454 like a normal command-line.
4443
4455
4444 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
4456 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
4445 bugs related to embedding and cleaned up that code. A fairly
4457 bugs related to embedding and cleaned up that code. A fairly
4446 important one was the impossibility to access the global namespace
4458 important one was the impossibility to access the global namespace
4447 through the embedded IPython (only local variables were visible).
4459 through the embedded IPython (only local variables were visible).
4448
4460
4449 2003-01-14 Fernando Perez <fperez@colorado.edu>
4461 2003-01-14 Fernando Perez <fperez@colorado.edu>
4450
4462
4451 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
4463 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
4452 auto-calling to be a bit more conservative. Now it doesn't get
4464 auto-calling to be a bit more conservative. Now it doesn't get
4453 triggered if any of '!=()<>' are in the rest of the input line, to
4465 triggered if any of '!=()<>' are in the rest of the input line, to
4454 allow comparing callables. Thanks to Alex for the heads up.
4466 allow comparing callables. Thanks to Alex for the heads up.
4455
4467
4456 2003-01-07 Fernando Perez <fperez@colorado.edu>
4468 2003-01-07 Fernando Perez <fperez@colorado.edu>
4457
4469
4458 * IPython/genutils.py (page): fixed estimation of the number of
4470 * IPython/genutils.py (page): fixed estimation of the number of
4459 lines in a string to be paged to simply count newlines. This
4471 lines in a string to be paged to simply count newlines. This
4460 prevents over-guessing due to embedded escape sequences. A better
4472 prevents over-guessing due to embedded escape sequences. A better
4461 long-term solution would involve stripping out the control chars
4473 long-term solution would involve stripping out the control chars
4462 for the count, but it's potentially so expensive I just don't
4474 for the count, but it's potentially so expensive I just don't
4463 think it's worth doing.
4475 think it's worth doing.
4464
4476
4465 2002-12-19 *** Released version 0.2.14pre50
4477 2002-12-19 *** Released version 0.2.14pre50
4466
4478
4467 2002-12-19 Fernando Perez <fperez@colorado.edu>
4479 2002-12-19 Fernando Perez <fperez@colorado.edu>
4468
4480
4469 * tools/release (version): Changed release scripts to inform
4481 * tools/release (version): Changed release scripts to inform
4470 Andrea and build a NEWS file with a list of recent changes.
4482 Andrea and build a NEWS file with a list of recent changes.
4471
4483
4472 * IPython/ColorANSI.py (__all__): changed terminal detection
4484 * IPython/ColorANSI.py (__all__): changed terminal detection
4473 code. Seems to work better for xterms without breaking
4485 code. Seems to work better for xterms without breaking
4474 konsole. Will need more testing to determine if WinXP and Mac OSX
4486 konsole. Will need more testing to determine if WinXP and Mac OSX
4475 also work ok.
4487 also work ok.
4476
4488
4477 2002-12-18 *** Released version 0.2.14pre49
4489 2002-12-18 *** Released version 0.2.14pre49
4478
4490
4479 2002-12-18 Fernando Perez <fperez@colorado.edu>
4491 2002-12-18 Fernando Perez <fperez@colorado.edu>
4480
4492
4481 * Docs: added new info about Mac OSX, from Andrea.
4493 * Docs: added new info about Mac OSX, from Andrea.
4482
4494
4483 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
4495 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
4484 allow direct plotting of python strings whose format is the same
4496 allow direct plotting of python strings whose format is the same
4485 of gnuplot data files.
4497 of gnuplot data files.
4486
4498
4487 2002-12-16 Fernando Perez <fperez@colorado.edu>
4499 2002-12-16 Fernando Perez <fperez@colorado.edu>
4488
4500
4489 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
4501 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
4490 value of exit question to be acknowledged.
4502 value of exit question to be acknowledged.
4491
4503
4492 2002-12-03 Fernando Perez <fperez@colorado.edu>
4504 2002-12-03 Fernando Perez <fperez@colorado.edu>
4493
4505
4494 * IPython/ipmaker.py: removed generators, which had been added
4506 * IPython/ipmaker.py: removed generators, which had been added
4495 by mistake in an earlier debugging run. This was causing trouble
4507 by mistake in an earlier debugging run. This was causing trouble
4496 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
4508 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
4497 for pointing this out.
4509 for pointing this out.
4498
4510
4499 2002-11-17 Fernando Perez <fperez@colorado.edu>
4511 2002-11-17 Fernando Perez <fperez@colorado.edu>
4500
4512
4501 * Manual: updated the Gnuplot section.
4513 * Manual: updated the Gnuplot section.
4502
4514
4503 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
4515 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
4504 a much better split of what goes in Runtime and what goes in
4516 a much better split of what goes in Runtime and what goes in
4505 Interactive.
4517 Interactive.
4506
4518
4507 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
4519 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
4508 being imported from iplib.
4520 being imported from iplib.
4509
4521
4510 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
4522 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
4511 for command-passing. Now the global Gnuplot instance is called
4523 for command-passing. Now the global Gnuplot instance is called
4512 'gp' instead of 'g', which was really a far too fragile and
4524 'gp' instead of 'g', which was really a far too fragile and
4513 common name.
4525 common name.
4514
4526
4515 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
4527 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
4516 bounding boxes generated by Gnuplot for square plots.
4528 bounding boxes generated by Gnuplot for square plots.
4517
4529
4518 * IPython/genutils.py (popkey): new function added. I should
4530 * IPython/genutils.py (popkey): new function added. I should
4519 suggest this on c.l.py as a dict method, it seems useful.
4531 suggest this on c.l.py as a dict method, it seems useful.
4520
4532
4521 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
4533 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
4522 to transparently handle PostScript generation. MUCH better than
4534 to transparently handle PostScript generation. MUCH better than
4523 the previous plot_eps/replot_eps (which I removed now). The code
4535 the previous plot_eps/replot_eps (which I removed now). The code
4524 is also fairly clean and well documented now (including
4536 is also fairly clean and well documented now (including
4525 docstrings).
4537 docstrings).
4526
4538
4527 2002-11-13 Fernando Perez <fperez@colorado.edu>
4539 2002-11-13 Fernando Perez <fperez@colorado.edu>
4528
4540
4529 * IPython/Magic.py (Magic.magic_edit): fixed docstring
4541 * IPython/Magic.py (Magic.magic_edit): fixed docstring
4530 (inconsistent with options).
4542 (inconsistent with options).
4531
4543
4532 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
4544 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
4533 manually disabled, I don't know why. Fixed it.
4545 manually disabled, I don't know why. Fixed it.
4534 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
4546 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
4535 eps output.
4547 eps output.
4536
4548
4537 2002-11-12 Fernando Perez <fperez@colorado.edu>
4549 2002-11-12 Fernando Perez <fperez@colorado.edu>
4538
4550
4539 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
4551 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
4540 don't propagate up to caller. Fixes crash reported by François
4552 don't propagate up to caller. Fixes crash reported by François
4541 Pinard.
4553 Pinard.
4542
4554
4543 2002-11-09 Fernando Perez <fperez@colorado.edu>
4555 2002-11-09 Fernando Perez <fperez@colorado.edu>
4544
4556
4545 * IPython/ipmaker.py (make_IPython): fixed problem with writing
4557 * IPython/ipmaker.py (make_IPython): fixed problem with writing
4546 history file for new users.
4558 history file for new users.
4547 (make_IPython): fixed bug where initial install would leave the
4559 (make_IPython): fixed bug where initial install would leave the
4548 user running in the .ipython dir.
4560 user running in the .ipython dir.
4549 (make_IPython): fixed bug where config dir .ipython would be
4561 (make_IPython): fixed bug where config dir .ipython would be
4550 created regardless of the given -ipythondir option. Thanks to Cory
4562 created regardless of the given -ipythondir option. Thanks to Cory
4551 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
4563 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
4552
4564
4553 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
4565 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
4554 type confirmations. Will need to use it in all of IPython's code
4566 type confirmations. Will need to use it in all of IPython's code
4555 consistently.
4567 consistently.
4556
4568
4557 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
4569 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
4558 context to print 31 lines instead of the default 5. This will make
4570 context to print 31 lines instead of the default 5. This will make
4559 the crash reports extremely detailed in case the problem is in
4571 the crash reports extremely detailed in case the problem is in
4560 libraries I don't have access to.
4572 libraries I don't have access to.
4561
4573
4562 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
4574 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
4563 line of defense' code to still crash, but giving users fair
4575 line of defense' code to still crash, but giving users fair
4564 warning. I don't want internal errors to go unreported: if there's
4576 warning. I don't want internal errors to go unreported: if there's
4565 an internal problem, IPython should crash and generate a full
4577 an internal problem, IPython should crash and generate a full
4566 report.
4578 report.
4567
4579
4568 2002-11-08 Fernando Perez <fperez@colorado.edu>
4580 2002-11-08 Fernando Perez <fperez@colorado.edu>
4569
4581
4570 * IPython/iplib.py (InteractiveShell.interact): added code to trap
4582 * IPython/iplib.py (InteractiveShell.interact): added code to trap
4571 otherwise uncaught exceptions which can appear if people set
4583 otherwise uncaught exceptions which can appear if people set
4572 sys.stdout to something badly broken. Thanks to a crash report
4584 sys.stdout to something badly broken. Thanks to a crash report
4573 from henni-AT-mail.brainbot.com.
4585 from henni-AT-mail.brainbot.com.
4574
4586
4575 2002-11-04 Fernando Perez <fperez@colorado.edu>
4587 2002-11-04 Fernando Perez <fperez@colorado.edu>
4576
4588
4577 * IPython/iplib.py (InteractiveShell.interact): added
4589 * IPython/iplib.py (InteractiveShell.interact): added
4578 __IPYTHON__active to the builtins. It's a flag which goes on when
4590 __IPYTHON__active to the builtins. It's a flag which goes on when
4579 the interaction starts and goes off again when it stops. This
4591 the interaction starts and goes off again when it stops. This
4580 allows embedding code to detect being inside IPython. Before this
4592 allows embedding code to detect being inside IPython. Before this
4581 was done via __IPYTHON__, but that only shows that an IPython
4593 was done via __IPYTHON__, but that only shows that an IPython
4582 instance has been created.
4594 instance has been created.
4583
4595
4584 * IPython/Magic.py (Magic.magic_env): I realized that in a
4596 * IPython/Magic.py (Magic.magic_env): I realized that in a
4585 UserDict, instance.data holds the data as a normal dict. So I
4597 UserDict, instance.data holds the data as a normal dict. So I
4586 modified @env to return os.environ.data instead of rebuilding a
4598 modified @env to return os.environ.data instead of rebuilding a
4587 dict by hand.
4599 dict by hand.
4588
4600
4589 2002-11-02 Fernando Perez <fperez@colorado.edu>
4601 2002-11-02 Fernando Perez <fperez@colorado.edu>
4590
4602
4591 * IPython/genutils.py (warn): changed so that level 1 prints no
4603 * IPython/genutils.py (warn): changed so that level 1 prints no
4592 header. Level 2 is now the default (with 'WARNING' header, as
4604 header. Level 2 is now the default (with 'WARNING' header, as
4593 before). I think I tracked all places where changes were needed in
4605 before). I think I tracked all places where changes were needed in
4594 IPython, but outside code using the old level numbering may have
4606 IPython, but outside code using the old level numbering may have
4595 broken.
4607 broken.
4596
4608
4597 * IPython/iplib.py (InteractiveShell.runcode): added this to
4609 * IPython/iplib.py (InteractiveShell.runcode): added this to
4598 handle the tracebacks in SystemExit traps correctly. The previous
4610 handle the tracebacks in SystemExit traps correctly. The previous
4599 code (through interact) was printing more of the stack than
4611 code (through interact) was printing more of the stack than
4600 necessary, showing IPython internal code to the user.
4612 necessary, showing IPython internal code to the user.
4601
4613
4602 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
4614 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
4603 default. Now that the default at the confirmation prompt is yes,
4615 default. Now that the default at the confirmation prompt is yes,
4604 it's not so intrusive. François' argument that ipython sessions
4616 it's not so intrusive. François' argument that ipython sessions
4605 tend to be complex enough not to lose them from an accidental C-d,
4617 tend to be complex enough not to lose them from an accidental C-d,
4606 is a valid one.
4618 is a valid one.
4607
4619
4608 * IPython/iplib.py (InteractiveShell.interact): added a
4620 * IPython/iplib.py (InteractiveShell.interact): added a
4609 showtraceback() call to the SystemExit trap, and modified the exit
4621 showtraceback() call to the SystemExit trap, and modified the exit
4610 confirmation to have yes as the default.
4622 confirmation to have yes as the default.
4611
4623
4612 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
4624 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
4613 this file. It's been gone from the code for a long time, this was
4625 this file. It's been gone from the code for a long time, this was
4614 simply leftover junk.
4626 simply leftover junk.
4615
4627
4616 2002-11-01 Fernando Perez <fperez@colorado.edu>
4628 2002-11-01 Fernando Perez <fperez@colorado.edu>
4617
4629
4618 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
4630 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
4619 added. If set, IPython now traps EOF and asks for
4631 added. If set, IPython now traps EOF and asks for
4620 confirmation. After a request by François Pinard.
4632 confirmation. After a request by François Pinard.
4621
4633
4622 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
4634 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
4623 of @abort, and with a new (better) mechanism for handling the
4635 of @abort, and with a new (better) mechanism for handling the
4624 exceptions.
4636 exceptions.
4625
4637
4626 2002-10-27 Fernando Perez <fperez@colorado.edu>
4638 2002-10-27 Fernando Perez <fperez@colorado.edu>
4627
4639
4628 * IPython/usage.py (__doc__): updated the --help information and
4640 * IPython/usage.py (__doc__): updated the --help information and
4629 the ipythonrc file to indicate that -log generates
4641 the ipythonrc file to indicate that -log generates
4630 ./ipython.log. Also fixed the corresponding info in @logstart.
4642 ./ipython.log. Also fixed the corresponding info in @logstart.
4631 This and several other fixes in the manuals thanks to reports by
4643 This and several other fixes in the manuals thanks to reports by
4632 François Pinard <pinard-AT-iro.umontreal.ca>.
4644 François Pinard <pinard-AT-iro.umontreal.ca>.
4633
4645
4634 * IPython/Logger.py (Logger.switch_log): Fixed error message to
4646 * IPython/Logger.py (Logger.switch_log): Fixed error message to
4635 refer to @logstart (instead of @log, which doesn't exist).
4647 refer to @logstart (instead of @log, which doesn't exist).
4636
4648
4637 * IPython/iplib.py (InteractiveShell._prefilter): fixed
4649 * IPython/iplib.py (InteractiveShell._prefilter): fixed
4638 AttributeError crash. Thanks to Christopher Armstrong
4650 AttributeError crash. Thanks to Christopher Armstrong
4639 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
4651 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
4640 introduced recently (in 0.2.14pre37) with the fix to the eval
4652 introduced recently (in 0.2.14pre37) with the fix to the eval
4641 problem mentioned below.
4653 problem mentioned below.
4642
4654
4643 2002-10-17 Fernando Perez <fperez@colorado.edu>
4655 2002-10-17 Fernando Perez <fperez@colorado.edu>
4644
4656
4645 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
4657 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
4646 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
4658 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
4647
4659
4648 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
4660 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
4649 this function to fix a problem reported by Alex Schmolck. He saw
4661 this function to fix a problem reported by Alex Schmolck. He saw
4650 it with list comprehensions and generators, which were getting
4662 it with list comprehensions and generators, which were getting
4651 called twice. The real problem was an 'eval' call in testing for
4663 called twice. The real problem was an 'eval' call in testing for
4652 automagic which was evaluating the input line silently.
4664 automagic which was evaluating the input line silently.
4653
4665
4654 This is a potentially very nasty bug, if the input has side
4666 This is a potentially very nasty bug, if the input has side
4655 effects which must not be repeated. The code is much cleaner now,
4667 effects which must not be repeated. The code is much cleaner now,
4656 without any blanket 'except' left and with a regexp test for
4668 without any blanket 'except' left and with a regexp test for
4657 actual function names.
4669 actual function names.
4658
4670
4659 But an eval remains, which I'm not fully comfortable with. I just
4671 But an eval remains, which I'm not fully comfortable with. I just
4660 don't know how to find out if an expression could be a callable in
4672 don't know how to find out if an expression could be a callable in
4661 the user's namespace without doing an eval on the string. However
4673 the user's namespace without doing an eval on the string. However
4662 that string is now much more strictly checked so that no code
4674 that string is now much more strictly checked so that no code
4663 slips by, so the eval should only happen for things that can
4675 slips by, so the eval should only happen for things that can
4664 really be only function/method names.
4676 really be only function/method names.
4665
4677
4666 2002-10-15 Fernando Perez <fperez@colorado.edu>
4678 2002-10-15 Fernando Perez <fperez@colorado.edu>
4667
4679
4668 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
4680 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
4669 OSX information to main manual, removed README_Mac_OSX file from
4681 OSX information to main manual, removed README_Mac_OSX file from
4670 distribution. Also updated credits for recent additions.
4682 distribution. Also updated credits for recent additions.
4671
4683
4672 2002-10-10 Fernando Perez <fperez@colorado.edu>
4684 2002-10-10 Fernando Perez <fperez@colorado.edu>
4673
4685
4674 * README_Mac_OSX: Added a README for Mac OSX users for fixing
4686 * README_Mac_OSX: Added a README for Mac OSX users for fixing
4675 terminal-related issues. Many thanks to Andrea Riciputi
4687 terminal-related issues. Many thanks to Andrea Riciputi
4676 <andrea.riciputi-AT-libero.it> for writing it.
4688 <andrea.riciputi-AT-libero.it> for writing it.
4677
4689
4678 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
4690 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
4679 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
4691 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
4680
4692
4681 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
4693 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
4682 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
4694 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
4683 <syver-en-AT-online.no> who both submitted patches for this problem.
4695 <syver-en-AT-online.no> who both submitted patches for this problem.
4684
4696
4685 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
4697 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
4686 global embedding to make sure that things don't overwrite user
4698 global embedding to make sure that things don't overwrite user
4687 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
4699 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
4688
4700
4689 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
4701 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
4690 compatibility. Thanks to Hayden Callow
4702 compatibility. Thanks to Hayden Callow
4691 <h.callow-AT-elec.canterbury.ac.nz>
4703 <h.callow-AT-elec.canterbury.ac.nz>
4692
4704
4693 2002-10-04 Fernando Perez <fperez@colorado.edu>
4705 2002-10-04 Fernando Perez <fperez@colorado.edu>
4694
4706
4695 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
4707 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
4696 Gnuplot.File objects.
4708 Gnuplot.File objects.
4697
4709
4698 2002-07-23 Fernando Perez <fperez@colorado.edu>
4710 2002-07-23 Fernando Perez <fperez@colorado.edu>
4699
4711
4700 * IPython/genutils.py (timing): Added timings() and timing() for
4712 * IPython/genutils.py (timing): Added timings() and timing() for
4701 quick access to the most commonly needed data, the execution
4713 quick access to the most commonly needed data, the execution
4702 times. Old timing() renamed to timings_out().
4714 times. Old timing() renamed to timings_out().
4703
4715
4704 2002-07-18 Fernando Perez <fperez@colorado.edu>
4716 2002-07-18 Fernando Perez <fperez@colorado.edu>
4705
4717
4706 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
4718 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
4707 bug with nested instances disrupting the parent's tab completion.
4719 bug with nested instances disrupting the parent's tab completion.
4708
4720
4709 * IPython/iplib.py (all_completions): Added Alex Schmolck's
4721 * IPython/iplib.py (all_completions): Added Alex Schmolck's
4710 all_completions code to begin the emacs integration.
4722 all_completions code to begin the emacs integration.
4711
4723
4712 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
4724 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
4713 argument to allow titling individual arrays when plotting.
4725 argument to allow titling individual arrays when plotting.
4714
4726
4715 2002-07-15 Fernando Perez <fperez@colorado.edu>
4727 2002-07-15 Fernando Perez <fperez@colorado.edu>
4716
4728
4717 * setup.py (make_shortcut): changed to retrieve the value of
4729 * setup.py (make_shortcut): changed to retrieve the value of
4718 'Program Files' directory from the registry (this value changes in
4730 'Program Files' directory from the registry (this value changes in
4719 non-english versions of Windows). Thanks to Thomas Fanslau
4731 non-english versions of Windows). Thanks to Thomas Fanslau
4720 <tfanslau-AT-gmx.de> for the report.
4732 <tfanslau-AT-gmx.de> for the report.
4721
4733
4722 2002-07-10 Fernando Perez <fperez@colorado.edu>
4734 2002-07-10 Fernando Perez <fperez@colorado.edu>
4723
4735
4724 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
4736 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
4725 a bug in pdb, which crashes if a line with only whitespace is
4737 a bug in pdb, which crashes if a line with only whitespace is
4726 entered. Bug report submitted to sourceforge.
4738 entered. Bug report submitted to sourceforge.
4727
4739
4728 2002-07-09 Fernando Perez <fperez@colorado.edu>
4740 2002-07-09 Fernando Perez <fperez@colorado.edu>
4729
4741
4730 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
4742 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
4731 reporting exceptions (it's a bug in inspect.py, I just set a
4743 reporting exceptions (it's a bug in inspect.py, I just set a
4732 workaround).
4744 workaround).
4733
4745
4734 2002-07-08 Fernando Perez <fperez@colorado.edu>
4746 2002-07-08 Fernando Perez <fperez@colorado.edu>
4735
4747
4736 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
4748 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
4737 __IPYTHON__ in __builtins__ to show up in user_ns.
4749 __IPYTHON__ in __builtins__ to show up in user_ns.
4738
4750
4739 2002-07-03 Fernando Perez <fperez@colorado.edu>
4751 2002-07-03 Fernando Perez <fperez@colorado.edu>
4740
4752
4741 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
4753 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
4742 name from @gp_set_instance to @gp_set_default.
4754 name from @gp_set_instance to @gp_set_default.
4743
4755
4744 * IPython/ipmaker.py (make_IPython): default editor value set to
4756 * IPython/ipmaker.py (make_IPython): default editor value set to
4745 '0' (a string), to match the rc file. Otherwise will crash when
4757 '0' (a string), to match the rc file. Otherwise will crash when
4746 .strip() is called on it.
4758 .strip() is called on it.
4747
4759
4748
4760
4749 2002-06-28 Fernando Perez <fperez@colorado.edu>
4761 2002-06-28 Fernando Perez <fperez@colorado.edu>
4750
4762
4751 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
4763 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
4752 of files in current directory when a file is executed via
4764 of files in current directory when a file is executed via
4753 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
4765 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
4754
4766
4755 * setup.py (manfiles): fix for rpm builds, submitted by RA
4767 * setup.py (manfiles): fix for rpm builds, submitted by RA
4756 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
4768 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
4757
4769
4758 * IPython/ipmaker.py (make_IPython): fixed lookup of default
4770 * IPython/ipmaker.py (make_IPython): fixed lookup of default
4759 editor when set to '0'. Problem was, '0' evaluates to True (it's a
4771 editor when set to '0'. Problem was, '0' evaluates to True (it's a
4760 string!). A. Schmolck caught this one.
4772 string!). A. Schmolck caught this one.
4761
4773
4762 2002-06-27 Fernando Perez <fperez@colorado.edu>
4774 2002-06-27 Fernando Perez <fperez@colorado.edu>
4763
4775
4764 * IPython/ipmaker.py (make_IPython): fixed bug when running user
4776 * IPython/ipmaker.py (make_IPython): fixed bug when running user
4765 defined files at the cmd line. __name__ wasn't being set to
4777 defined files at the cmd line. __name__ wasn't being set to
4766 __main__.
4778 __main__.
4767
4779
4768 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
4780 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
4769 regular lists and tuples besides Numeric arrays.
4781 regular lists and tuples besides Numeric arrays.
4770
4782
4771 * IPython/Prompts.py (CachedOutput.__call__): Added output
4783 * IPython/Prompts.py (CachedOutput.__call__): Added output
4772 supression for input ending with ';'. Similar to Mathematica and
4784 supression for input ending with ';'. Similar to Mathematica and
4773 Matlab. The _* vars and Out[] list are still updated, just like
4785 Matlab. The _* vars and Out[] list are still updated, just like
4774 Mathematica behaves.
4786 Mathematica behaves.
4775
4787
4776 2002-06-25 Fernando Perez <fperez@colorado.edu>
4788 2002-06-25 Fernando Perez <fperez@colorado.edu>
4777
4789
4778 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
4790 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
4779 .ini extensions for profiels under Windows.
4791 .ini extensions for profiels under Windows.
4780
4792
4781 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
4793 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
4782 string form. Fix contributed by Alexander Schmolck
4794 string form. Fix contributed by Alexander Schmolck
4783 <a.schmolck-AT-gmx.net>
4795 <a.schmolck-AT-gmx.net>
4784
4796
4785 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
4797 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
4786 pre-configured Gnuplot instance.
4798 pre-configured Gnuplot instance.
4787
4799
4788 2002-06-21 Fernando Perez <fperez@colorado.edu>
4800 2002-06-21 Fernando Perez <fperez@colorado.edu>
4789
4801
4790 * IPython/numutils.py (exp_safe): new function, works around the
4802 * IPython/numutils.py (exp_safe): new function, works around the
4791 underflow problems in Numeric.
4803 underflow problems in Numeric.
4792 (log2): New fn. Safe log in base 2: returns exact integer answer
4804 (log2): New fn. Safe log in base 2: returns exact integer answer
4793 for exact integer powers of 2.
4805 for exact integer powers of 2.
4794
4806
4795 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
4807 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
4796 properly.
4808 properly.
4797
4809
4798 2002-06-20 Fernando Perez <fperez@colorado.edu>
4810 2002-06-20 Fernando Perez <fperez@colorado.edu>
4799
4811
4800 * IPython/genutils.py (timing): new function like
4812 * IPython/genutils.py (timing): new function like
4801 Mathematica's. Similar to time_test, but returns more info.
4813 Mathematica's. Similar to time_test, but returns more info.
4802
4814
4803 2002-06-18 Fernando Perez <fperez@colorado.edu>
4815 2002-06-18 Fernando Perez <fperez@colorado.edu>
4804
4816
4805 * IPython/Magic.py (Magic.magic_save): modified @save and @r
4817 * IPython/Magic.py (Magic.magic_save): modified @save and @r
4806 according to Mike Heeter's suggestions.
4818 according to Mike Heeter's suggestions.
4807
4819
4808 2002-06-16 Fernando Perez <fperez@colorado.edu>
4820 2002-06-16 Fernando Perez <fperez@colorado.edu>
4809
4821
4810 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
4822 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
4811 system. GnuplotMagic is gone as a user-directory option. New files
4823 system. GnuplotMagic is gone as a user-directory option. New files
4812 make it easier to use all the gnuplot stuff both from external
4824 make it easier to use all the gnuplot stuff both from external
4813 programs as well as from IPython. Had to rewrite part of
4825 programs as well as from IPython. Had to rewrite part of
4814 hardcopy() b/c of a strange bug: often the ps files simply don't
4826 hardcopy() b/c of a strange bug: often the ps files simply don't
4815 get created, and require a repeat of the command (often several
4827 get created, and require a repeat of the command (often several
4816 times).
4828 times).
4817
4829
4818 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
4830 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
4819 resolve output channel at call time, so that if sys.stderr has
4831 resolve output channel at call time, so that if sys.stderr has
4820 been redirected by user this gets honored.
4832 been redirected by user this gets honored.
4821
4833
4822 2002-06-13 Fernando Perez <fperez@colorado.edu>
4834 2002-06-13 Fernando Perez <fperez@colorado.edu>
4823
4835
4824 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
4836 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
4825 IPShell. Kept a copy with the old names to avoid breaking people's
4837 IPShell. Kept a copy with the old names to avoid breaking people's
4826 embedded code.
4838 embedded code.
4827
4839
4828 * IPython/ipython: simplified it to the bare minimum after
4840 * IPython/ipython: simplified it to the bare minimum after
4829 Holger's suggestions. Added info about how to use it in
4841 Holger's suggestions. Added info about how to use it in
4830 PYTHONSTARTUP.
4842 PYTHONSTARTUP.
4831
4843
4832 * IPython/Shell.py (IPythonShell): changed the options passing
4844 * IPython/Shell.py (IPythonShell): changed the options passing
4833 from a string with funky %s replacements to a straight list. Maybe
4845 from a string with funky %s replacements to a straight list. Maybe
4834 a bit more typing, but it follows sys.argv conventions, so there's
4846 a bit more typing, but it follows sys.argv conventions, so there's
4835 less special-casing to remember.
4847 less special-casing to remember.
4836
4848
4837 2002-06-12 Fernando Perez <fperez@colorado.edu>
4849 2002-06-12 Fernando Perez <fperez@colorado.edu>
4838
4850
4839 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
4851 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
4840 command. Thanks to a suggestion by Mike Heeter.
4852 command. Thanks to a suggestion by Mike Heeter.
4841 (Magic.magic_pfile): added behavior to look at filenames if given
4853 (Magic.magic_pfile): added behavior to look at filenames if given
4842 arg is not a defined object.
4854 arg is not a defined object.
4843 (Magic.magic_save): New @save function to save code snippets. Also
4855 (Magic.magic_save): New @save function to save code snippets. Also
4844 a Mike Heeter idea.
4856 a Mike Heeter idea.
4845
4857
4846 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
4858 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
4847 plot() and replot(). Much more convenient now, especially for
4859 plot() and replot(). Much more convenient now, especially for
4848 interactive use.
4860 interactive use.
4849
4861
4850 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
4862 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
4851 filenames.
4863 filenames.
4852
4864
4853 2002-06-02 Fernando Perez <fperez@colorado.edu>
4865 2002-06-02 Fernando Perez <fperez@colorado.edu>
4854
4866
4855 * IPython/Struct.py (Struct.__init__): modified to admit
4867 * IPython/Struct.py (Struct.__init__): modified to admit
4856 initialization via another struct.
4868 initialization via another struct.
4857
4869
4858 * IPython/genutils.py (SystemExec.__init__): New stateful
4870 * IPython/genutils.py (SystemExec.__init__): New stateful
4859 interface to xsys and bq. Useful for writing system scripts.
4871 interface to xsys and bq. Useful for writing system scripts.
4860
4872
4861 2002-05-30 Fernando Perez <fperez@colorado.edu>
4873 2002-05-30 Fernando Perez <fperez@colorado.edu>
4862
4874
4863 * MANIFEST.in: Changed docfile selection to exclude all the lyx
4875 * MANIFEST.in: Changed docfile selection to exclude all the lyx
4864 documents. This will make the user download smaller (it's getting
4876 documents. This will make the user download smaller (it's getting
4865 too big).
4877 too big).
4866
4878
4867 2002-05-29 Fernando Perez <fperez@colorado.edu>
4879 2002-05-29 Fernando Perez <fperez@colorado.edu>
4868
4880
4869 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
4881 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
4870 fix problems with shelve and pickle. Seems to work, but I don't
4882 fix problems with shelve and pickle. Seems to work, but I don't
4871 know if corner cases break it. Thanks to Mike Heeter
4883 know if corner cases break it. Thanks to Mike Heeter
4872 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
4884 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
4873
4885
4874 2002-05-24 Fernando Perez <fperez@colorado.edu>
4886 2002-05-24 Fernando Perez <fperez@colorado.edu>
4875
4887
4876 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
4888 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
4877 macros having broken.
4889 macros having broken.
4878
4890
4879 2002-05-21 Fernando Perez <fperez@colorado.edu>
4891 2002-05-21 Fernando Perez <fperez@colorado.edu>
4880
4892
4881 * IPython/Magic.py (Magic.magic_logstart): fixed recently
4893 * IPython/Magic.py (Magic.magic_logstart): fixed recently
4882 introduced logging bug: all history before logging started was
4894 introduced logging bug: all history before logging started was
4883 being written one character per line! This came from the redesign
4895 being written one character per line! This came from the redesign
4884 of the input history as a special list which slices to strings,
4896 of the input history as a special list which slices to strings,
4885 not to lists.
4897 not to lists.
4886
4898
4887 2002-05-20 Fernando Perez <fperez@colorado.edu>
4899 2002-05-20 Fernando Perez <fperez@colorado.edu>
4888
4900
4889 * IPython/Prompts.py (CachedOutput.__init__): made the color table
4901 * IPython/Prompts.py (CachedOutput.__init__): made the color table
4890 be an attribute of all classes in this module. The design of these
4902 be an attribute of all classes in this module. The design of these
4891 classes needs some serious overhauling.
4903 classes needs some serious overhauling.
4892
4904
4893 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
4905 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
4894 which was ignoring '_' in option names.
4906 which was ignoring '_' in option names.
4895
4907
4896 * IPython/ultraTB.py (FormattedTB.__init__): Changed
4908 * IPython/ultraTB.py (FormattedTB.__init__): Changed
4897 'Verbose_novars' to 'Context' and made it the new default. It's a
4909 'Verbose_novars' to 'Context' and made it the new default. It's a
4898 bit more readable and also safer than verbose.
4910 bit more readable and also safer than verbose.
4899
4911
4900 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
4912 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
4901 triple-quoted strings.
4913 triple-quoted strings.
4902
4914
4903 * IPython/OInspect.py (__all__): new module exposing the object
4915 * IPython/OInspect.py (__all__): new module exposing the object
4904 introspection facilities. Now the corresponding magics are dummy
4916 introspection facilities. Now the corresponding magics are dummy
4905 wrappers around this. Having this module will make it much easier
4917 wrappers around this. Having this module will make it much easier
4906 to put these functions into our modified pdb.
4918 to put these functions into our modified pdb.
4907 This new object inspector system uses the new colorizing module,
4919 This new object inspector system uses the new colorizing module,
4908 so source code and other things are nicely syntax highlighted.
4920 so source code and other things are nicely syntax highlighted.
4909
4921
4910 2002-05-18 Fernando Perez <fperez@colorado.edu>
4922 2002-05-18 Fernando Perez <fperez@colorado.edu>
4911
4923
4912 * IPython/ColorANSI.py: Split the coloring tools into a separate
4924 * IPython/ColorANSI.py: Split the coloring tools into a separate
4913 module so I can use them in other code easier (they were part of
4925 module so I can use them in other code easier (they were part of
4914 ultraTB).
4926 ultraTB).
4915
4927
4916 2002-05-17 Fernando Perez <fperez@colorado.edu>
4928 2002-05-17 Fernando Perez <fperez@colorado.edu>
4917
4929
4918 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
4930 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
4919 fixed it to set the global 'g' also to the called instance, as
4931 fixed it to set the global 'g' also to the called instance, as
4920 long as 'g' was still a gnuplot instance (so it doesn't overwrite
4932 long as 'g' was still a gnuplot instance (so it doesn't overwrite
4921 user's 'g' variables).
4933 user's 'g' variables).
4922
4934
4923 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
4935 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
4924 global variables (aliases to _ih,_oh) so that users which expect
4936 global variables (aliases to _ih,_oh) so that users which expect
4925 In[5] or Out[7] to work aren't unpleasantly surprised.
4937 In[5] or Out[7] to work aren't unpleasantly surprised.
4926 (InputList.__getslice__): new class to allow executing slices of
4938 (InputList.__getslice__): new class to allow executing slices of
4927 input history directly. Very simple class, complements the use of
4939 input history directly. Very simple class, complements the use of
4928 macros.
4940 macros.
4929
4941
4930 2002-05-16 Fernando Perez <fperez@colorado.edu>
4942 2002-05-16 Fernando Perez <fperez@colorado.edu>
4931
4943
4932 * setup.py (docdirbase): make doc directory be just doc/IPython
4944 * setup.py (docdirbase): make doc directory be just doc/IPython
4933 without version numbers, it will reduce clutter for users.
4945 without version numbers, it will reduce clutter for users.
4934
4946
4935 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
4947 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
4936 execfile call to prevent possible memory leak. See for details:
4948 execfile call to prevent possible memory leak. See for details:
4937 http://mail.python.org/pipermail/python-list/2002-February/088476.html
4949 http://mail.python.org/pipermail/python-list/2002-February/088476.html
4938
4950
4939 2002-05-15 Fernando Perez <fperez@colorado.edu>
4951 2002-05-15 Fernando Perez <fperez@colorado.edu>
4940
4952
4941 * IPython/Magic.py (Magic.magic_psource): made the object
4953 * IPython/Magic.py (Magic.magic_psource): made the object
4942 introspection names be more standard: pdoc, pdef, pfile and
4954 introspection names be more standard: pdoc, pdef, pfile and
4943 psource. They all print/page their output, and it makes
4955 psource. They all print/page their output, and it makes
4944 remembering them easier. Kept old names for compatibility as
4956 remembering them easier. Kept old names for compatibility as
4945 aliases.
4957 aliases.
4946
4958
4947 2002-05-14 Fernando Perez <fperez@colorado.edu>
4959 2002-05-14 Fernando Perez <fperez@colorado.edu>
4948
4960
4949 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
4961 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
4950 what the mouse problem was. The trick is to use gnuplot with temp
4962 what the mouse problem was. The trick is to use gnuplot with temp
4951 files and NOT with pipes (for data communication), because having
4963 files and NOT with pipes (for data communication), because having
4952 both pipes and the mouse on is bad news.
4964 both pipes and the mouse on is bad news.
4953
4965
4954 2002-05-13 Fernando Perez <fperez@colorado.edu>
4966 2002-05-13 Fernando Perez <fperez@colorado.edu>
4955
4967
4956 * IPython/Magic.py (Magic._ofind): fixed namespace order search
4968 * IPython/Magic.py (Magic._ofind): fixed namespace order search
4957 bug. Information would be reported about builtins even when
4969 bug. Information would be reported about builtins even when
4958 user-defined functions overrode them.
4970 user-defined functions overrode them.
4959
4971
4960 2002-05-11 Fernando Perez <fperez@colorado.edu>
4972 2002-05-11 Fernando Perez <fperez@colorado.edu>
4961
4973
4962 * IPython/__init__.py (__all__): removed FlexCompleter from
4974 * IPython/__init__.py (__all__): removed FlexCompleter from
4963 __all__ so that things don't fail in platforms without readline.
4975 __all__ so that things don't fail in platforms without readline.
4964
4976
4965 2002-05-10 Fernando Perez <fperez@colorado.edu>
4977 2002-05-10 Fernando Perez <fperez@colorado.edu>
4966
4978
4967 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
4979 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
4968 it requires Numeric, effectively making Numeric a dependency for
4980 it requires Numeric, effectively making Numeric a dependency for
4969 IPython.
4981 IPython.
4970
4982
4971 * Released 0.2.13
4983 * Released 0.2.13
4972
4984
4973 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
4985 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
4974 profiler interface. Now all the major options from the profiler
4986 profiler interface. Now all the major options from the profiler
4975 module are directly supported in IPython, both for single
4987 module are directly supported in IPython, both for single
4976 expressions (@prun) and for full programs (@run -p).
4988 expressions (@prun) and for full programs (@run -p).
4977
4989
4978 2002-05-09 Fernando Perez <fperez@colorado.edu>
4990 2002-05-09 Fernando Perez <fperez@colorado.edu>
4979
4991
4980 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
4992 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
4981 magic properly formatted for screen.
4993 magic properly formatted for screen.
4982
4994
4983 * setup.py (make_shortcut): Changed things to put pdf version in
4995 * setup.py (make_shortcut): Changed things to put pdf version in
4984 doc/ instead of doc/manual (had to change lyxport a bit).
4996 doc/ instead of doc/manual (had to change lyxport a bit).
4985
4997
4986 * IPython/Magic.py (Profile.string_stats): made profile runs go
4998 * IPython/Magic.py (Profile.string_stats): made profile runs go
4987 through pager (they are long and a pager allows searching, saving,
4999 through pager (they are long and a pager allows searching, saving,
4988 etc.)
5000 etc.)
4989
5001
4990 2002-05-08 Fernando Perez <fperez@colorado.edu>
5002 2002-05-08 Fernando Perez <fperez@colorado.edu>
4991
5003
4992 * Released 0.2.12
5004 * Released 0.2.12
4993
5005
4994 2002-05-06 Fernando Perez <fperez@colorado.edu>
5006 2002-05-06 Fernando Perez <fperez@colorado.edu>
4995
5007
4996 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
5008 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
4997 introduced); 'hist n1 n2' was broken.
5009 introduced); 'hist n1 n2' was broken.
4998 (Magic.magic_pdb): added optional on/off arguments to @pdb
5010 (Magic.magic_pdb): added optional on/off arguments to @pdb
4999 (Magic.magic_run): added option -i to @run, which executes code in
5011 (Magic.magic_run): added option -i to @run, which executes code in
5000 the IPython namespace instead of a clean one. Also added @irun as
5012 the IPython namespace instead of a clean one. Also added @irun as
5001 an alias to @run -i.
5013 an alias to @run -i.
5002
5014
5003 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
5015 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
5004 fixed (it didn't really do anything, the namespaces were wrong).
5016 fixed (it didn't really do anything, the namespaces were wrong).
5005
5017
5006 * IPython/Debugger.py (__init__): Added workaround for python 2.1
5018 * IPython/Debugger.py (__init__): Added workaround for python 2.1
5007
5019
5008 * IPython/__init__.py (__all__): Fixed package namespace, now
5020 * IPython/__init__.py (__all__): Fixed package namespace, now
5009 'import IPython' does give access to IPython.<all> as
5021 'import IPython' does give access to IPython.<all> as
5010 expected. Also renamed __release__ to Release.
5022 expected. Also renamed __release__ to Release.
5011
5023
5012 * IPython/Debugger.py (__license__): created new Pdb class which
5024 * IPython/Debugger.py (__license__): created new Pdb class which
5013 functions like a drop-in for the normal pdb.Pdb but does NOT
5025 functions like a drop-in for the normal pdb.Pdb but does NOT
5014 import readline by default. This way it doesn't muck up IPython's
5026 import readline by default. This way it doesn't muck up IPython's
5015 readline handling, and now tab-completion finally works in the
5027 readline handling, and now tab-completion finally works in the
5016 debugger -- sort of. It completes things globally visible, but the
5028 debugger -- sort of. It completes things globally visible, but the
5017 completer doesn't track the stack as pdb walks it. That's a bit
5029 completer doesn't track the stack as pdb walks it. That's a bit
5018 tricky, and I'll have to implement it later.
5030 tricky, and I'll have to implement it later.
5019
5031
5020 2002-05-05 Fernando Perez <fperez@colorado.edu>
5032 2002-05-05 Fernando Perez <fperez@colorado.edu>
5021
5033
5022 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
5034 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
5023 magic docstrings when printed via ? (explicit \'s were being
5035 magic docstrings when printed via ? (explicit \'s were being
5024 printed).
5036 printed).
5025
5037
5026 * IPython/ipmaker.py (make_IPython): fixed namespace
5038 * IPython/ipmaker.py (make_IPython): fixed namespace
5027 identification bug. Now variables loaded via logs or command-line
5039 identification bug. Now variables loaded via logs or command-line
5028 files are recognized in the interactive namespace by @who.
5040 files are recognized in the interactive namespace by @who.
5029
5041
5030 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
5042 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
5031 log replay system stemming from the string form of Structs.
5043 log replay system stemming from the string form of Structs.
5032
5044
5033 * IPython/Magic.py (Macro.__init__): improved macros to properly
5045 * IPython/Magic.py (Macro.__init__): improved macros to properly
5034 handle magic commands in them.
5046 handle magic commands in them.
5035 (Magic.magic_logstart): usernames are now expanded so 'logstart
5047 (Magic.magic_logstart): usernames are now expanded so 'logstart
5036 ~/mylog' now works.
5048 ~/mylog' now works.
5037
5049
5038 * IPython/iplib.py (complete): fixed bug where paths starting with
5050 * IPython/iplib.py (complete): fixed bug where paths starting with
5039 '/' would be completed as magic names.
5051 '/' would be completed as magic names.
5040
5052
5041 2002-05-04 Fernando Perez <fperez@colorado.edu>
5053 2002-05-04 Fernando Perez <fperez@colorado.edu>
5042
5054
5043 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
5055 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
5044 allow running full programs under the profiler's control.
5056 allow running full programs under the profiler's control.
5045
5057
5046 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
5058 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
5047 mode to report exceptions verbosely but without formatting
5059 mode to report exceptions verbosely but without formatting
5048 variables. This addresses the issue of ipython 'freezing' (it's
5060 variables. This addresses the issue of ipython 'freezing' (it's
5049 not frozen, but caught in an expensive formatting loop) when huge
5061 not frozen, but caught in an expensive formatting loop) when huge
5050 variables are in the context of an exception.
5062 variables are in the context of an exception.
5051 (VerboseTB.text): Added '--->' markers at line where exception was
5063 (VerboseTB.text): Added '--->' markers at line where exception was
5052 triggered. Much clearer to read, especially in NoColor modes.
5064 triggered. Much clearer to read, especially in NoColor modes.
5053
5065
5054 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
5066 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
5055 implemented in reverse when changing to the new parse_options().
5067 implemented in reverse when changing to the new parse_options().
5056
5068
5057 2002-05-03 Fernando Perez <fperez@colorado.edu>
5069 2002-05-03 Fernando Perez <fperez@colorado.edu>
5058
5070
5059 * IPython/Magic.py (Magic.parse_options): new function so that
5071 * IPython/Magic.py (Magic.parse_options): new function so that
5060 magics can parse options easier.
5072 magics can parse options easier.
5061 (Magic.magic_prun): new function similar to profile.run(),
5073 (Magic.magic_prun): new function similar to profile.run(),
5062 suggested by Chris Hart.
5074 suggested by Chris Hart.
5063 (Magic.magic_cd): fixed behavior so that it only changes if
5075 (Magic.magic_cd): fixed behavior so that it only changes if
5064 directory actually is in history.
5076 directory actually is in history.
5065
5077
5066 * IPython/usage.py (__doc__): added information about potential
5078 * IPython/usage.py (__doc__): added information about potential
5067 slowness of Verbose exception mode when there are huge data
5079 slowness of Verbose exception mode when there are huge data
5068 structures to be formatted (thanks to Archie Paulson).
5080 structures to be formatted (thanks to Archie Paulson).
5069
5081
5070 * IPython/ipmaker.py (make_IPython): Changed default logging
5082 * IPython/ipmaker.py (make_IPython): Changed default logging
5071 (when simply called with -log) to use curr_dir/ipython.log in
5083 (when simply called with -log) to use curr_dir/ipython.log in
5072 rotate mode. Fixed crash which was occuring with -log before
5084 rotate mode. Fixed crash which was occuring with -log before
5073 (thanks to Jim Boyle).
5085 (thanks to Jim Boyle).
5074
5086
5075 2002-05-01 Fernando Perez <fperez@colorado.edu>
5087 2002-05-01 Fernando Perez <fperez@colorado.edu>
5076
5088
5077 * Released 0.2.11 for these fixes (mainly the ultraTB one which
5089 * Released 0.2.11 for these fixes (mainly the ultraTB one which
5078 was nasty -- though somewhat of a corner case).
5090 was nasty -- though somewhat of a corner case).
5079
5091
5080 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
5092 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
5081 text (was a bug).
5093 text (was a bug).
5082
5094
5083 2002-04-30 Fernando Perez <fperez@colorado.edu>
5095 2002-04-30 Fernando Perez <fperez@colorado.edu>
5084
5096
5085 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
5097 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
5086 a print after ^D or ^C from the user so that the In[] prompt
5098 a print after ^D or ^C from the user so that the In[] prompt
5087 doesn't over-run the gnuplot one.
5099 doesn't over-run the gnuplot one.
5088
5100
5089 2002-04-29 Fernando Perez <fperez@colorado.edu>
5101 2002-04-29 Fernando Perez <fperez@colorado.edu>
5090
5102
5091 * Released 0.2.10
5103 * Released 0.2.10
5092
5104
5093 * IPython/__release__.py (version): get date dynamically.
5105 * IPython/__release__.py (version): get date dynamically.
5094
5106
5095 * Misc. documentation updates thanks to Arnd's comments. Also ran
5107 * Misc. documentation updates thanks to Arnd's comments. Also ran
5096 a full spellcheck on the manual (hadn't been done in a while).
5108 a full spellcheck on the manual (hadn't been done in a while).
5097
5109
5098 2002-04-27 Fernando Perez <fperez@colorado.edu>
5110 2002-04-27 Fernando Perez <fperez@colorado.edu>
5099
5111
5100 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
5112 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
5101 starting a log in mid-session would reset the input history list.
5113 starting a log in mid-session would reset the input history list.
5102
5114
5103 2002-04-26 Fernando Perez <fperez@colorado.edu>
5115 2002-04-26 Fernando Perez <fperez@colorado.edu>
5104
5116
5105 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
5117 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
5106 all files were being included in an update. Now anything in
5118 all files were being included in an update. Now anything in
5107 UserConfig that matches [A-Za-z]*.py will go (this excludes
5119 UserConfig that matches [A-Za-z]*.py will go (this excludes
5108 __init__.py)
5120 __init__.py)
5109
5121
5110 2002-04-25 Fernando Perez <fperez@colorado.edu>
5122 2002-04-25 Fernando Perez <fperez@colorado.edu>
5111
5123
5112 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
5124 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
5113 to __builtins__ so that any form of embedded or imported code can
5125 to __builtins__ so that any form of embedded or imported code can
5114 test for being inside IPython.
5126 test for being inside IPython.
5115
5127
5116 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
5128 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
5117 changed to GnuplotMagic because it's now an importable module,
5129 changed to GnuplotMagic because it's now an importable module,
5118 this makes the name follow that of the standard Gnuplot module.
5130 this makes the name follow that of the standard Gnuplot module.
5119 GnuplotMagic can now be loaded at any time in mid-session.
5131 GnuplotMagic can now be loaded at any time in mid-session.
5120
5132
5121 2002-04-24 Fernando Perez <fperez@colorado.edu>
5133 2002-04-24 Fernando Perez <fperez@colorado.edu>
5122
5134
5123 * IPython/numutils.py: removed SIUnits. It doesn't properly set
5135 * IPython/numutils.py: removed SIUnits. It doesn't properly set
5124 the globals (IPython has its own namespace) and the
5136 the globals (IPython has its own namespace) and the
5125 PhysicalQuantity stuff is much better anyway.
5137 PhysicalQuantity stuff is much better anyway.
5126
5138
5127 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
5139 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
5128 embedding example to standard user directory for
5140 embedding example to standard user directory for
5129 distribution. Also put it in the manual.
5141 distribution. Also put it in the manual.
5130
5142
5131 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
5143 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
5132 instance as first argument (so it doesn't rely on some obscure
5144 instance as first argument (so it doesn't rely on some obscure
5133 hidden global).
5145 hidden global).
5134
5146
5135 * IPython/UserConfig/ipythonrc.py: put () back in accepted
5147 * IPython/UserConfig/ipythonrc.py: put () back in accepted
5136 delimiters. While it prevents ().TAB from working, it allows
5148 delimiters. While it prevents ().TAB from working, it allows
5137 completions in open (... expressions. This is by far a more common
5149 completions in open (... expressions. This is by far a more common
5138 case.
5150 case.
5139
5151
5140 2002-04-23 Fernando Perez <fperez@colorado.edu>
5152 2002-04-23 Fernando Perez <fperez@colorado.edu>
5141
5153
5142 * IPython/Extensions/InterpreterPasteInput.py: new
5154 * IPython/Extensions/InterpreterPasteInput.py: new
5143 syntax-processing module for pasting lines with >>> or ... at the
5155 syntax-processing module for pasting lines with >>> or ... at the
5144 start.
5156 start.
5145
5157
5146 * IPython/Extensions/PhysicalQ_Interactive.py
5158 * IPython/Extensions/PhysicalQ_Interactive.py
5147 (PhysicalQuantityInteractive.__int__): fixed to work with either
5159 (PhysicalQuantityInteractive.__int__): fixed to work with either
5148 Numeric or math.
5160 Numeric or math.
5149
5161
5150 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
5162 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
5151 provided profiles. Now we have:
5163 provided profiles. Now we have:
5152 -math -> math module as * and cmath with its own namespace.
5164 -math -> math module as * and cmath with its own namespace.
5153 -numeric -> Numeric as *, plus gnuplot & grace
5165 -numeric -> Numeric as *, plus gnuplot & grace
5154 -physics -> same as before
5166 -physics -> same as before
5155
5167
5156 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
5168 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
5157 user-defined magics wouldn't be found by @magic if they were
5169 user-defined magics wouldn't be found by @magic if they were
5158 defined as class methods. Also cleaned up the namespace search
5170 defined as class methods. Also cleaned up the namespace search
5159 logic and the string building (to use %s instead of many repeated
5171 logic and the string building (to use %s instead of many repeated
5160 string adds).
5172 string adds).
5161
5173
5162 * IPython/UserConfig/example-magic.py (magic_foo): updated example
5174 * IPython/UserConfig/example-magic.py (magic_foo): updated example
5163 of user-defined magics to operate with class methods (cleaner, in
5175 of user-defined magics to operate with class methods (cleaner, in
5164 line with the gnuplot code).
5176 line with the gnuplot code).
5165
5177
5166 2002-04-22 Fernando Perez <fperez@colorado.edu>
5178 2002-04-22 Fernando Perez <fperez@colorado.edu>
5167
5179
5168 * setup.py: updated dependency list so that manual is updated when
5180 * setup.py: updated dependency list so that manual is updated when
5169 all included files change.
5181 all included files change.
5170
5182
5171 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
5183 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
5172 the delimiter removal option (the fix is ugly right now).
5184 the delimiter removal option (the fix is ugly right now).
5173
5185
5174 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
5186 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
5175 all of the math profile (quicker loading, no conflict between
5187 all of the math profile (quicker loading, no conflict between
5176 g-9.8 and g-gnuplot).
5188 g-9.8 and g-gnuplot).
5177
5189
5178 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
5190 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
5179 name of post-mortem files to IPython_crash_report.txt.
5191 name of post-mortem files to IPython_crash_report.txt.
5180
5192
5181 * Cleanup/update of the docs. Added all the new readline info and
5193 * Cleanup/update of the docs. Added all the new readline info and
5182 formatted all lists as 'real lists'.
5194 formatted all lists as 'real lists'.
5183
5195
5184 * IPython/ipmaker.py (make_IPython): removed now-obsolete
5196 * IPython/ipmaker.py (make_IPython): removed now-obsolete
5185 tab-completion options, since the full readline parse_and_bind is
5197 tab-completion options, since the full readline parse_and_bind is
5186 now accessible.
5198 now accessible.
5187
5199
5188 * IPython/iplib.py (InteractiveShell.init_readline): Changed
5200 * IPython/iplib.py (InteractiveShell.init_readline): Changed
5189 handling of readline options. Now users can specify any string to
5201 handling of readline options. Now users can specify any string to
5190 be passed to parse_and_bind(), as well as the delimiters to be
5202 be passed to parse_and_bind(), as well as the delimiters to be
5191 removed.
5203 removed.
5192 (InteractiveShell.__init__): Added __name__ to the global
5204 (InteractiveShell.__init__): Added __name__ to the global
5193 namespace so that things like Itpl which rely on its existence
5205 namespace so that things like Itpl which rely on its existence
5194 don't crash.
5206 don't crash.
5195 (InteractiveShell._prefilter): Defined the default with a _ so
5207 (InteractiveShell._prefilter): Defined the default with a _ so
5196 that prefilter() is easier to override, while the default one
5208 that prefilter() is easier to override, while the default one
5197 remains available.
5209 remains available.
5198
5210
5199 2002-04-18 Fernando Perez <fperez@colorado.edu>
5211 2002-04-18 Fernando Perez <fperez@colorado.edu>
5200
5212
5201 * Added information about pdb in the docs.
5213 * Added information about pdb in the docs.
5202
5214
5203 2002-04-17 Fernando Perez <fperez@colorado.edu>
5215 2002-04-17 Fernando Perez <fperez@colorado.edu>
5204
5216
5205 * IPython/ipmaker.py (make_IPython): added rc_override option to
5217 * IPython/ipmaker.py (make_IPython): added rc_override option to
5206 allow passing config options at creation time which may override
5218 allow passing config options at creation time which may override
5207 anything set in the config files or command line. This is
5219 anything set in the config files or command line. This is
5208 particularly useful for configuring embedded instances.
5220 particularly useful for configuring embedded instances.
5209
5221
5210 2002-04-15 Fernando Perez <fperez@colorado.edu>
5222 2002-04-15 Fernando Perez <fperez@colorado.edu>
5211
5223
5212 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
5224 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
5213 crash embedded instances because of the input cache falling out of
5225 crash embedded instances because of the input cache falling out of
5214 sync with the output counter.
5226 sync with the output counter.
5215
5227
5216 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
5228 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
5217 mode which calls pdb after an uncaught exception in IPython itself.
5229 mode which calls pdb after an uncaught exception in IPython itself.
5218
5230
5219 2002-04-14 Fernando Perez <fperez@colorado.edu>
5231 2002-04-14 Fernando Perez <fperez@colorado.edu>
5220
5232
5221 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
5233 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
5222 readline, fix it back after each call.
5234 readline, fix it back after each call.
5223
5235
5224 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
5236 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
5225 method to force all access via __call__(), which guarantees that
5237 method to force all access via __call__(), which guarantees that
5226 traceback references are properly deleted.
5238 traceback references are properly deleted.
5227
5239
5228 * IPython/Prompts.py (CachedOutput._display): minor fixes to
5240 * IPython/Prompts.py (CachedOutput._display): minor fixes to
5229 improve printing when pprint is in use.
5241 improve printing when pprint is in use.
5230
5242
5231 2002-04-13 Fernando Perez <fperez@colorado.edu>
5243 2002-04-13 Fernando Perez <fperez@colorado.edu>
5232
5244
5233 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
5245 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
5234 exceptions aren't caught anymore. If the user triggers one, he
5246 exceptions aren't caught anymore. If the user triggers one, he
5235 should know why he's doing it and it should go all the way up,
5247 should know why he's doing it and it should go all the way up,
5236 just like any other exception. So now @abort will fully kill the
5248 just like any other exception. So now @abort will fully kill the
5237 embedded interpreter and the embedding code (unless that happens
5249 embedded interpreter and the embedding code (unless that happens
5238 to catch SystemExit).
5250 to catch SystemExit).
5239
5251
5240 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
5252 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
5241 and a debugger() method to invoke the interactive pdb debugger
5253 and a debugger() method to invoke the interactive pdb debugger
5242 after printing exception information. Also added the corresponding
5254 after printing exception information. Also added the corresponding
5243 -pdb option and @pdb magic to control this feature, and updated
5255 -pdb option and @pdb magic to control this feature, and updated
5244 the docs. After a suggestion from Christopher Hart
5256 the docs. After a suggestion from Christopher Hart
5245 (hart-AT-caltech.edu).
5257 (hart-AT-caltech.edu).
5246
5258
5247 2002-04-12 Fernando Perez <fperez@colorado.edu>
5259 2002-04-12 Fernando Perez <fperez@colorado.edu>
5248
5260
5249 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
5261 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
5250 the exception handlers defined by the user (not the CrashHandler)
5262 the exception handlers defined by the user (not the CrashHandler)
5251 so that user exceptions don't trigger an ipython bug report.
5263 so that user exceptions don't trigger an ipython bug report.
5252
5264
5253 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
5265 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
5254 configurable (it should have always been so).
5266 configurable (it should have always been so).
5255
5267
5256 2002-03-26 Fernando Perez <fperez@colorado.edu>
5268 2002-03-26 Fernando Perez <fperez@colorado.edu>
5257
5269
5258 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
5270 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
5259 and there to fix embedding namespace issues. This should all be
5271 and there to fix embedding namespace issues. This should all be
5260 done in a more elegant way.
5272 done in a more elegant way.
5261
5273
5262 2002-03-25 Fernando Perez <fperez@colorado.edu>
5274 2002-03-25 Fernando Perez <fperez@colorado.edu>
5263
5275
5264 * IPython/genutils.py (get_home_dir): Try to make it work under
5276 * IPython/genutils.py (get_home_dir): Try to make it work under
5265 win9x also.
5277 win9x also.
5266
5278
5267 2002-03-20 Fernando Perez <fperez@colorado.edu>
5279 2002-03-20 Fernando Perez <fperez@colorado.edu>
5268
5280
5269 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
5281 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
5270 sys.displayhook untouched upon __init__.
5282 sys.displayhook untouched upon __init__.
5271
5283
5272 2002-03-19 Fernando Perez <fperez@colorado.edu>
5284 2002-03-19 Fernando Perez <fperez@colorado.edu>
5273
5285
5274 * Released 0.2.9 (for embedding bug, basically).
5286 * Released 0.2.9 (for embedding bug, basically).
5275
5287
5276 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
5288 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
5277 exceptions so that enclosing shell's state can be restored.
5289 exceptions so that enclosing shell's state can be restored.
5278
5290
5279 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
5291 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
5280 naming conventions in the .ipython/ dir.
5292 naming conventions in the .ipython/ dir.
5281
5293
5282 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
5294 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
5283 from delimiters list so filenames with - in them get expanded.
5295 from delimiters list so filenames with - in them get expanded.
5284
5296
5285 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
5297 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
5286 sys.displayhook not being properly restored after an embedded call.
5298 sys.displayhook not being properly restored after an embedded call.
5287
5299
5288 2002-03-18 Fernando Perez <fperez@colorado.edu>
5300 2002-03-18 Fernando Perez <fperez@colorado.edu>
5289
5301
5290 * Released 0.2.8
5302 * Released 0.2.8
5291
5303
5292 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
5304 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
5293 some files weren't being included in a -upgrade.
5305 some files weren't being included in a -upgrade.
5294 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
5306 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
5295 on' so that the first tab completes.
5307 on' so that the first tab completes.
5296 (InteractiveShell.handle_magic): fixed bug with spaces around
5308 (InteractiveShell.handle_magic): fixed bug with spaces around
5297 quotes breaking many magic commands.
5309 quotes breaking many magic commands.
5298
5310
5299 * setup.py: added note about ignoring the syntax error messages at
5311 * setup.py: added note about ignoring the syntax error messages at
5300 installation.
5312 installation.
5301
5313
5302 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
5314 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
5303 streamlining the gnuplot interface, now there's only one magic @gp.
5315 streamlining the gnuplot interface, now there's only one magic @gp.
5304
5316
5305 2002-03-17 Fernando Perez <fperez@colorado.edu>
5317 2002-03-17 Fernando Perez <fperez@colorado.edu>
5306
5318
5307 * IPython/UserConfig/magic_gnuplot.py: new name for the
5319 * IPython/UserConfig/magic_gnuplot.py: new name for the
5308 example-magic_pm.py file. Much enhanced system, now with a shell
5320 example-magic_pm.py file. Much enhanced system, now with a shell
5309 for communicating directly with gnuplot, one command at a time.
5321 for communicating directly with gnuplot, one command at a time.
5310
5322
5311 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
5323 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
5312 setting __name__=='__main__'.
5324 setting __name__=='__main__'.
5313
5325
5314 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
5326 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
5315 mini-shell for accessing gnuplot from inside ipython. Should
5327 mini-shell for accessing gnuplot from inside ipython. Should
5316 extend it later for grace access too. Inspired by Arnd's
5328 extend it later for grace access too. Inspired by Arnd's
5317 suggestion.
5329 suggestion.
5318
5330
5319 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
5331 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
5320 calling magic functions with () in their arguments. Thanks to Arnd
5332 calling magic functions with () in their arguments. Thanks to Arnd
5321 Baecker for pointing this to me.
5333 Baecker for pointing this to me.
5322
5334
5323 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
5335 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
5324 infinitely for integer or complex arrays (only worked with floats).
5336 infinitely for integer or complex arrays (only worked with floats).
5325
5337
5326 2002-03-16 Fernando Perez <fperez@colorado.edu>
5338 2002-03-16 Fernando Perez <fperez@colorado.edu>
5327
5339
5328 * setup.py: Merged setup and setup_windows into a single script
5340 * setup.py: Merged setup and setup_windows into a single script
5329 which properly handles things for windows users.
5341 which properly handles things for windows users.
5330
5342
5331 2002-03-15 Fernando Perez <fperez@colorado.edu>
5343 2002-03-15 Fernando Perez <fperez@colorado.edu>
5332
5344
5333 * Big change to the manual: now the magics are all automatically
5345 * Big change to the manual: now the magics are all automatically
5334 documented. This information is generated from their docstrings
5346 documented. This information is generated from their docstrings
5335 and put in a latex file included by the manual lyx file. This way
5347 and put in a latex file included by the manual lyx file. This way
5336 we get always up to date information for the magics. The manual
5348 we get always up to date information for the magics. The manual
5337 now also has proper version information, also auto-synced.
5349 now also has proper version information, also auto-synced.
5338
5350
5339 For this to work, an undocumented --magic_docstrings option was added.
5351 For this to work, an undocumented --magic_docstrings option was added.
5340
5352
5341 2002-03-13 Fernando Perez <fperez@colorado.edu>
5353 2002-03-13 Fernando Perez <fperez@colorado.edu>
5342
5354
5343 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
5355 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
5344 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
5356 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
5345
5357
5346 2002-03-12 Fernando Perez <fperez@colorado.edu>
5358 2002-03-12 Fernando Perez <fperez@colorado.edu>
5347
5359
5348 * IPython/ultraTB.py (TermColors): changed color escapes again to
5360 * IPython/ultraTB.py (TermColors): changed color escapes again to
5349 fix the (old, reintroduced) line-wrapping bug. Basically, if
5361 fix the (old, reintroduced) line-wrapping bug. Basically, if
5350 \001..\002 aren't given in the color escapes, lines get wrapped
5362 \001..\002 aren't given in the color escapes, lines get wrapped
5351 weirdly. But giving those screws up old xterms and emacs terms. So
5363 weirdly. But giving those screws up old xterms and emacs terms. So
5352 I added some logic for emacs terms to be ok, but I can't identify old
5364 I added some logic for emacs terms to be ok, but I can't identify old
5353 xterms separately ($TERM=='xterm' for many terminals, like konsole).
5365 xterms separately ($TERM=='xterm' for many terminals, like konsole).
5354
5366
5355 2002-03-10 Fernando Perez <fperez@colorado.edu>
5367 2002-03-10 Fernando Perez <fperez@colorado.edu>
5356
5368
5357 * IPython/usage.py (__doc__): Various documentation cleanups and
5369 * IPython/usage.py (__doc__): Various documentation cleanups and
5358 updates, both in usage docstrings and in the manual.
5370 updates, both in usage docstrings and in the manual.
5359
5371
5360 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
5372 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
5361 handling of caching. Set minimum acceptabe value for having a
5373 handling of caching. Set minimum acceptabe value for having a
5362 cache at 20 values.
5374 cache at 20 values.
5363
5375
5364 * IPython/iplib.py (InteractiveShell.user_setup): moved the
5376 * IPython/iplib.py (InteractiveShell.user_setup): moved the
5365 install_first_time function to a method, renamed it and added an
5377 install_first_time function to a method, renamed it and added an
5366 'upgrade' mode. Now people can update their config directory with
5378 'upgrade' mode. Now people can update their config directory with
5367 a simple command line switch (-upgrade, also new).
5379 a simple command line switch (-upgrade, also new).
5368
5380
5369 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
5381 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
5370 @file (convenient for automagic users under Python >= 2.2).
5382 @file (convenient for automagic users under Python >= 2.2).
5371 Removed @files (it seemed more like a plural than an abbrev. of
5383 Removed @files (it seemed more like a plural than an abbrev. of
5372 'file show').
5384 'file show').
5373
5385
5374 * IPython/iplib.py (install_first_time): Fixed crash if there were
5386 * IPython/iplib.py (install_first_time): Fixed crash if there were
5375 backup files ('~') in .ipython/ install directory.
5387 backup files ('~') in .ipython/ install directory.
5376
5388
5377 * IPython/ipmaker.py (make_IPython): fixes for new prompt
5389 * IPython/ipmaker.py (make_IPython): fixes for new prompt
5378 system. Things look fine, but these changes are fairly
5390 system. Things look fine, but these changes are fairly
5379 intrusive. Test them for a few days.
5391 intrusive. Test them for a few days.
5380
5392
5381 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
5393 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
5382 the prompts system. Now all in/out prompt strings are user
5394 the prompts system. Now all in/out prompt strings are user
5383 controllable. This is particularly useful for embedding, as one
5395 controllable. This is particularly useful for embedding, as one
5384 can tag embedded instances with particular prompts.
5396 can tag embedded instances with particular prompts.
5385
5397
5386 Also removed global use of sys.ps1/2, which now allows nested
5398 Also removed global use of sys.ps1/2, which now allows nested
5387 embeddings without any problems. Added command-line options for
5399 embeddings without any problems. Added command-line options for
5388 the prompt strings.
5400 the prompt strings.
5389
5401
5390 2002-03-08 Fernando Perez <fperez@colorado.edu>
5402 2002-03-08 Fernando Perez <fperez@colorado.edu>
5391
5403
5392 * IPython/UserConfig/example-embed-short.py (ipshell): added
5404 * IPython/UserConfig/example-embed-short.py (ipshell): added
5393 example file with the bare minimum code for embedding.
5405 example file with the bare minimum code for embedding.
5394
5406
5395 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
5407 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
5396 functionality for the embeddable shell to be activated/deactivated
5408 functionality for the embeddable shell to be activated/deactivated
5397 either globally or at each call.
5409 either globally or at each call.
5398
5410
5399 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
5411 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
5400 rewriting the prompt with '--->' for auto-inputs with proper
5412 rewriting the prompt with '--->' for auto-inputs with proper
5401 coloring. Now the previous UGLY hack in handle_auto() is gone, and
5413 coloring. Now the previous UGLY hack in handle_auto() is gone, and
5402 this is handled by the prompts class itself, as it should.
5414 this is handled by the prompts class itself, as it should.
5403
5415
5404 2002-03-05 Fernando Perez <fperez@colorado.edu>
5416 2002-03-05 Fernando Perez <fperez@colorado.edu>
5405
5417
5406 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
5418 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
5407 @logstart to avoid name clashes with the math log function.
5419 @logstart to avoid name clashes with the math log function.
5408
5420
5409 * Big updates to X/Emacs section of the manual.
5421 * Big updates to X/Emacs section of the manual.
5410
5422
5411 * Removed ipython_emacs. Milan explained to me how to pass
5423 * Removed ipython_emacs. Milan explained to me how to pass
5412 arguments to ipython through Emacs. Some day I'm going to end up
5424 arguments to ipython through Emacs. Some day I'm going to end up
5413 learning some lisp...
5425 learning some lisp...
5414
5426
5415 2002-03-04 Fernando Perez <fperez@colorado.edu>
5427 2002-03-04 Fernando Perez <fperez@colorado.edu>
5416
5428
5417 * IPython/ipython_emacs: Created script to be used as the
5429 * IPython/ipython_emacs: Created script to be used as the
5418 py-python-command Emacs variable so we can pass IPython
5430 py-python-command Emacs variable so we can pass IPython
5419 parameters. I can't figure out how to tell Emacs directly to pass
5431 parameters. I can't figure out how to tell Emacs directly to pass
5420 parameters to IPython, so a dummy shell script will do it.
5432 parameters to IPython, so a dummy shell script will do it.
5421
5433
5422 Other enhancements made for things to work better under Emacs'
5434 Other enhancements made for things to work better under Emacs'
5423 various types of terminals. Many thanks to Milan Zamazal
5435 various types of terminals. Many thanks to Milan Zamazal
5424 <pdm-AT-zamazal.org> for all the suggestions and pointers.
5436 <pdm-AT-zamazal.org> for all the suggestions and pointers.
5425
5437
5426 2002-03-01 Fernando Perez <fperez@colorado.edu>
5438 2002-03-01 Fernando Perez <fperez@colorado.edu>
5427
5439
5428 * IPython/ipmaker.py (make_IPython): added a --readline! option so
5440 * IPython/ipmaker.py (make_IPython): added a --readline! option so
5429 that loading of readline is now optional. This gives better
5441 that loading of readline is now optional. This gives better
5430 control to emacs users.
5442 control to emacs users.
5431
5443
5432 * IPython/ultraTB.py (__date__): Modified color escape sequences
5444 * IPython/ultraTB.py (__date__): Modified color escape sequences
5433 and now things work fine under xterm and in Emacs' term buffers
5445 and now things work fine under xterm and in Emacs' term buffers
5434 (though not shell ones). Well, in emacs you get colors, but all
5446 (though not shell ones). Well, in emacs you get colors, but all
5435 seem to be 'light' colors (no difference between dark and light
5447 seem to be 'light' colors (no difference between dark and light
5436 ones). But the garbage chars are gone, and also in xterms. It
5448 ones). But the garbage chars are gone, and also in xterms. It
5437 seems that now I'm using 'cleaner' ansi sequences.
5449 seems that now I'm using 'cleaner' ansi sequences.
5438
5450
5439 2002-02-21 Fernando Perez <fperez@colorado.edu>
5451 2002-02-21 Fernando Perez <fperez@colorado.edu>
5440
5452
5441 * Released 0.2.7 (mainly to publish the scoping fix).
5453 * Released 0.2.7 (mainly to publish the scoping fix).
5442
5454
5443 * IPython/Logger.py (Logger.logstate): added. A corresponding
5455 * IPython/Logger.py (Logger.logstate): added. A corresponding
5444 @logstate magic was created.
5456 @logstate magic was created.
5445
5457
5446 * IPython/Magic.py: fixed nested scoping problem under Python
5458 * IPython/Magic.py: fixed nested scoping problem under Python
5447 2.1.x (automagic wasn't working).
5459 2.1.x (automagic wasn't working).
5448
5460
5449 2002-02-20 Fernando Perez <fperez@colorado.edu>
5461 2002-02-20 Fernando Perez <fperez@colorado.edu>
5450
5462
5451 * Released 0.2.6.
5463 * Released 0.2.6.
5452
5464
5453 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
5465 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
5454 option so that logs can come out without any headers at all.
5466 option so that logs can come out without any headers at all.
5455
5467
5456 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
5468 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
5457 SciPy.
5469 SciPy.
5458
5470
5459 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
5471 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
5460 that embedded IPython calls don't require vars() to be explicitly
5472 that embedded IPython calls don't require vars() to be explicitly
5461 passed. Now they are extracted from the caller's frame (code
5473 passed. Now they are extracted from the caller's frame (code
5462 snatched from Eric Jones' weave). Added better documentation to
5474 snatched from Eric Jones' weave). Added better documentation to
5463 the section on embedding and the example file.
5475 the section on embedding and the example file.
5464
5476
5465 * IPython/genutils.py (page): Changed so that under emacs, it just
5477 * IPython/genutils.py (page): Changed so that under emacs, it just
5466 prints the string. You can then page up and down in the emacs
5478 prints the string. You can then page up and down in the emacs
5467 buffer itself. This is how the builtin help() works.
5479 buffer itself. This is how the builtin help() works.
5468
5480
5469 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
5481 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
5470 macro scoping: macros need to be executed in the user's namespace
5482 macro scoping: macros need to be executed in the user's namespace
5471 to work as if they had been typed by the user.
5483 to work as if they had been typed by the user.
5472
5484
5473 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
5485 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
5474 execute automatically (no need to type 'exec...'). They then
5486 execute automatically (no need to type 'exec...'). They then
5475 behave like 'true macros'. The printing system was also modified
5487 behave like 'true macros'. The printing system was also modified
5476 for this to work.
5488 for this to work.
5477
5489
5478 2002-02-19 Fernando Perez <fperez@colorado.edu>
5490 2002-02-19 Fernando Perez <fperez@colorado.edu>
5479
5491
5480 * IPython/genutils.py (page_file): new function for paging files
5492 * IPython/genutils.py (page_file): new function for paging files
5481 in an OS-independent way. Also necessary for file viewing to work
5493 in an OS-independent way. Also necessary for file viewing to work
5482 well inside Emacs buffers.
5494 well inside Emacs buffers.
5483 (page): Added checks for being in an emacs buffer.
5495 (page): Added checks for being in an emacs buffer.
5484 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
5496 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
5485 same bug in iplib.
5497 same bug in iplib.
5486
5498
5487 2002-02-18 Fernando Perez <fperez@colorado.edu>
5499 2002-02-18 Fernando Perez <fperez@colorado.edu>
5488
5500
5489 * IPython/iplib.py (InteractiveShell.init_readline): modified use
5501 * IPython/iplib.py (InteractiveShell.init_readline): modified use
5490 of readline so that IPython can work inside an Emacs buffer.
5502 of readline so that IPython can work inside an Emacs buffer.
5491
5503
5492 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
5504 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
5493 method signatures (they weren't really bugs, but it looks cleaner
5505 method signatures (they weren't really bugs, but it looks cleaner
5494 and keeps PyChecker happy).
5506 and keeps PyChecker happy).
5495
5507
5496 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
5508 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
5497 for implementing various user-defined hooks. Currently only
5509 for implementing various user-defined hooks. Currently only
5498 display is done.
5510 display is done.
5499
5511
5500 * IPython/Prompts.py (CachedOutput._display): changed display
5512 * IPython/Prompts.py (CachedOutput._display): changed display
5501 functions so that they can be dynamically changed by users easily.
5513 functions so that they can be dynamically changed by users easily.
5502
5514
5503 * IPython/Extensions/numeric_formats.py (num_display): added an
5515 * IPython/Extensions/numeric_formats.py (num_display): added an
5504 extension for printing NumPy arrays in flexible manners. It
5516 extension for printing NumPy arrays in flexible manners. It
5505 doesn't do anything yet, but all the structure is in
5517 doesn't do anything yet, but all the structure is in
5506 place. Ultimately the plan is to implement output format control
5518 place. Ultimately the plan is to implement output format control
5507 like in Octave.
5519 like in Octave.
5508
5520
5509 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
5521 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
5510 methods are found at run-time by all the automatic machinery.
5522 methods are found at run-time by all the automatic machinery.
5511
5523
5512 2002-02-17 Fernando Perez <fperez@colorado.edu>
5524 2002-02-17 Fernando Perez <fperez@colorado.edu>
5513
5525
5514 * setup_Windows.py (make_shortcut): documented. Cleaned up the
5526 * setup_Windows.py (make_shortcut): documented. Cleaned up the
5515 whole file a little.
5527 whole file a little.
5516
5528
5517 * ToDo: closed this document. Now there's a new_design.lyx
5529 * ToDo: closed this document. Now there's a new_design.lyx
5518 document for all new ideas. Added making a pdf of it for the
5530 document for all new ideas. Added making a pdf of it for the
5519 end-user distro.
5531 end-user distro.
5520
5532
5521 * IPython/Logger.py (Logger.switch_log): Created this to replace
5533 * IPython/Logger.py (Logger.switch_log): Created this to replace
5522 logon() and logoff(). It also fixes a nasty crash reported by
5534 logon() and logoff(). It also fixes a nasty crash reported by
5523 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
5535 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
5524
5536
5525 * IPython/iplib.py (complete): got auto-completion to work with
5537 * IPython/iplib.py (complete): got auto-completion to work with
5526 automagic (I had wanted this for a long time).
5538 automagic (I had wanted this for a long time).
5527
5539
5528 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
5540 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
5529 to @file, since file() is now a builtin and clashes with automagic
5541 to @file, since file() is now a builtin and clashes with automagic
5530 for @file.
5542 for @file.
5531
5543
5532 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
5544 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
5533 of this was previously in iplib, which had grown to more than 2000
5545 of this was previously in iplib, which had grown to more than 2000
5534 lines, way too long. No new functionality, but it makes managing
5546 lines, way too long. No new functionality, but it makes managing
5535 the code a bit easier.
5547 the code a bit easier.
5536
5548
5537 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
5549 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
5538 information to crash reports.
5550 information to crash reports.
5539
5551
5540 2002-02-12 Fernando Perez <fperez@colorado.edu>
5552 2002-02-12 Fernando Perez <fperez@colorado.edu>
5541
5553
5542 * Released 0.2.5.
5554 * Released 0.2.5.
5543
5555
5544 2002-02-11 Fernando Perez <fperez@colorado.edu>
5556 2002-02-11 Fernando Perez <fperez@colorado.edu>
5545
5557
5546 * Wrote a relatively complete Windows installer. It puts
5558 * Wrote a relatively complete Windows installer. It puts
5547 everything in place, creates Start Menu entries and fixes the
5559 everything in place, creates Start Menu entries and fixes the
5548 color issues. Nothing fancy, but it works.
5560 color issues. Nothing fancy, but it works.
5549
5561
5550 2002-02-10 Fernando Perez <fperez@colorado.edu>
5562 2002-02-10 Fernando Perez <fperez@colorado.edu>
5551
5563
5552 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
5564 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
5553 os.path.expanduser() call so that we can type @run ~/myfile.py and
5565 os.path.expanduser() call so that we can type @run ~/myfile.py and
5554 have thigs work as expected.
5566 have thigs work as expected.
5555
5567
5556 * IPython/genutils.py (page): fixed exception handling so things
5568 * IPython/genutils.py (page): fixed exception handling so things
5557 work both in Unix and Windows correctly. Quitting a pager triggers
5569 work both in Unix and Windows correctly. Quitting a pager triggers
5558 an IOError/broken pipe in Unix, and in windows not finding a pager
5570 an IOError/broken pipe in Unix, and in windows not finding a pager
5559 is also an IOError, so I had to actually look at the return value
5571 is also an IOError, so I had to actually look at the return value
5560 of the exception, not just the exception itself. Should be ok now.
5572 of the exception, not just the exception itself. Should be ok now.
5561
5573
5562 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
5574 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
5563 modified to allow case-insensitive color scheme changes.
5575 modified to allow case-insensitive color scheme changes.
5564
5576
5565 2002-02-09 Fernando Perez <fperez@colorado.edu>
5577 2002-02-09 Fernando Perez <fperez@colorado.edu>
5566
5578
5567 * IPython/genutils.py (native_line_ends): new function to leave
5579 * IPython/genutils.py (native_line_ends): new function to leave
5568 user config files with os-native line-endings.
5580 user config files with os-native line-endings.
5569
5581
5570 * README and manual updates.
5582 * README and manual updates.
5571
5583
5572 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
5584 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
5573 instead of StringType to catch Unicode strings.
5585 instead of StringType to catch Unicode strings.
5574
5586
5575 * IPython/genutils.py (filefind): fixed bug for paths with
5587 * IPython/genutils.py (filefind): fixed bug for paths with
5576 embedded spaces (very common in Windows).
5588 embedded spaces (very common in Windows).
5577
5589
5578 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
5590 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
5579 files under Windows, so that they get automatically associated
5591 files under Windows, so that they get automatically associated
5580 with a text editor. Windows makes it a pain to handle
5592 with a text editor. Windows makes it a pain to handle
5581 extension-less files.
5593 extension-less files.
5582
5594
5583 * IPython/iplib.py (InteractiveShell.init_readline): Made the
5595 * IPython/iplib.py (InteractiveShell.init_readline): Made the
5584 warning about readline only occur for Posix. In Windows there's no
5596 warning about readline only occur for Posix. In Windows there's no
5585 way to get readline, so why bother with the warning.
5597 way to get readline, so why bother with the warning.
5586
5598
5587 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
5599 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
5588 for __str__ instead of dir(self), since dir() changed in 2.2.
5600 for __str__ instead of dir(self), since dir() changed in 2.2.
5589
5601
5590 * Ported to Windows! Tested on XP, I suspect it should work fine
5602 * Ported to Windows! Tested on XP, I suspect it should work fine
5591 on NT/2000, but I don't think it will work on 98 et al. That
5603 on NT/2000, but I don't think it will work on 98 et al. That
5592 series of Windows is such a piece of junk anyway that I won't try
5604 series of Windows is such a piece of junk anyway that I won't try
5593 porting it there. The XP port was straightforward, showed a few
5605 porting it there. The XP port was straightforward, showed a few
5594 bugs here and there (fixed all), in particular some string
5606 bugs here and there (fixed all), in particular some string
5595 handling stuff which required considering Unicode strings (which
5607 handling stuff which required considering Unicode strings (which
5596 Windows uses). This is good, but hasn't been too tested :) No
5608 Windows uses). This is good, but hasn't been too tested :) No
5597 fancy installer yet, I'll put a note in the manual so people at
5609 fancy installer yet, I'll put a note in the manual so people at
5598 least make manually a shortcut.
5610 least make manually a shortcut.
5599
5611
5600 * IPython/iplib.py (Magic.magic_colors): Unified the color options
5612 * IPython/iplib.py (Magic.magic_colors): Unified the color options
5601 into a single one, "colors". This now controls both prompt and
5613 into a single one, "colors". This now controls both prompt and
5602 exception color schemes, and can be changed both at startup
5614 exception color schemes, and can be changed both at startup
5603 (either via command-line switches or via ipythonrc files) and at
5615 (either via command-line switches or via ipythonrc files) and at
5604 runtime, with @colors.
5616 runtime, with @colors.
5605 (Magic.magic_run): renamed @prun to @run and removed the old
5617 (Magic.magic_run): renamed @prun to @run and removed the old
5606 @run. The two were too similar to warrant keeping both.
5618 @run. The two were too similar to warrant keeping both.
5607
5619
5608 2002-02-03 Fernando Perez <fperez@colorado.edu>
5620 2002-02-03 Fernando Perez <fperez@colorado.edu>
5609
5621
5610 * IPython/iplib.py (install_first_time): Added comment on how to
5622 * IPython/iplib.py (install_first_time): Added comment on how to
5611 configure the color options for first-time users. Put a <return>
5623 configure the color options for first-time users. Put a <return>
5612 request at the end so that small-terminal users get a chance to
5624 request at the end so that small-terminal users get a chance to
5613 read the startup info.
5625 read the startup info.
5614
5626
5615 2002-01-23 Fernando Perez <fperez@colorado.edu>
5627 2002-01-23 Fernando Perez <fperez@colorado.edu>
5616
5628
5617 * IPython/iplib.py (CachedOutput.update): Changed output memory
5629 * IPython/iplib.py (CachedOutput.update): Changed output memory
5618 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
5630 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
5619 input history we still use _i. Did this b/c these variable are
5631 input history we still use _i. Did this b/c these variable are
5620 very commonly used in interactive work, so the less we need to
5632 very commonly used in interactive work, so the less we need to
5621 type the better off we are.
5633 type the better off we are.
5622 (Magic.magic_prun): updated @prun to better handle the namespaces
5634 (Magic.magic_prun): updated @prun to better handle the namespaces
5623 the file will run in, including a fix for __name__ not being set
5635 the file will run in, including a fix for __name__ not being set
5624 before.
5636 before.
5625
5637
5626 2002-01-20 Fernando Perez <fperez@colorado.edu>
5638 2002-01-20 Fernando Perez <fperez@colorado.edu>
5627
5639
5628 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
5640 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
5629 extra garbage for Python 2.2. Need to look more carefully into
5641 extra garbage for Python 2.2. Need to look more carefully into
5630 this later.
5642 this later.
5631
5643
5632 2002-01-19 Fernando Perez <fperez@colorado.edu>
5644 2002-01-19 Fernando Perez <fperez@colorado.edu>
5633
5645
5634 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
5646 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
5635 display SyntaxError exceptions properly formatted when they occur
5647 display SyntaxError exceptions properly formatted when they occur
5636 (they can be triggered by imported code).
5648 (they can be triggered by imported code).
5637
5649
5638 2002-01-18 Fernando Perez <fperez@colorado.edu>
5650 2002-01-18 Fernando Perez <fperez@colorado.edu>
5639
5651
5640 * IPython/iplib.py (InteractiveShell.safe_execfile): now
5652 * IPython/iplib.py (InteractiveShell.safe_execfile): now
5641 SyntaxError exceptions are reported nicely formatted, instead of
5653 SyntaxError exceptions are reported nicely formatted, instead of
5642 spitting out only offset information as before.
5654 spitting out only offset information as before.
5643 (Magic.magic_prun): Added the @prun function for executing
5655 (Magic.magic_prun): Added the @prun function for executing
5644 programs with command line args inside IPython.
5656 programs with command line args inside IPython.
5645
5657
5646 2002-01-16 Fernando Perez <fperez@colorado.edu>
5658 2002-01-16 Fernando Perez <fperez@colorado.edu>
5647
5659
5648 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
5660 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
5649 to *not* include the last item given in a range. This brings their
5661 to *not* include the last item given in a range. This brings their
5650 behavior in line with Python's slicing:
5662 behavior in line with Python's slicing:
5651 a[n1:n2] -> a[n1]...a[n2-1]
5663 a[n1:n2] -> a[n1]...a[n2-1]
5652 It may be a bit less convenient, but I prefer to stick to Python's
5664 It may be a bit less convenient, but I prefer to stick to Python's
5653 conventions *everywhere*, so users never have to wonder.
5665 conventions *everywhere*, so users never have to wonder.
5654 (Magic.magic_macro): Added @macro function to ease the creation of
5666 (Magic.magic_macro): Added @macro function to ease the creation of
5655 macros.
5667 macros.
5656
5668
5657 2002-01-05 Fernando Perez <fperez@colorado.edu>
5669 2002-01-05 Fernando Perez <fperez@colorado.edu>
5658
5670
5659 * Released 0.2.4.
5671 * Released 0.2.4.
5660
5672
5661 * IPython/iplib.py (Magic.magic_pdef):
5673 * IPython/iplib.py (Magic.magic_pdef):
5662 (InteractiveShell.safe_execfile): report magic lines and error
5674 (InteractiveShell.safe_execfile): report magic lines and error
5663 lines without line numbers so one can easily copy/paste them for
5675 lines without line numbers so one can easily copy/paste them for
5664 re-execution.
5676 re-execution.
5665
5677
5666 * Updated manual with recent changes.
5678 * Updated manual with recent changes.
5667
5679
5668 * IPython/iplib.py (Magic.magic_oinfo): added constructor
5680 * IPython/iplib.py (Magic.magic_oinfo): added constructor
5669 docstring printing when class? is called. Very handy for knowing
5681 docstring printing when class? is called. Very handy for knowing
5670 how to create class instances (as long as __init__ is well
5682 how to create class instances (as long as __init__ is well
5671 documented, of course :)
5683 documented, of course :)
5672 (Magic.magic_doc): print both class and constructor docstrings.
5684 (Magic.magic_doc): print both class and constructor docstrings.
5673 (Magic.magic_pdef): give constructor info if passed a class and
5685 (Magic.magic_pdef): give constructor info if passed a class and
5674 __call__ info for callable object instances.
5686 __call__ info for callable object instances.
5675
5687
5676 2002-01-04 Fernando Perez <fperez@colorado.edu>
5688 2002-01-04 Fernando Perez <fperez@colorado.edu>
5677
5689
5678 * Made deep_reload() off by default. It doesn't always work
5690 * Made deep_reload() off by default. It doesn't always work
5679 exactly as intended, so it's probably safer to have it off. It's
5691 exactly as intended, so it's probably safer to have it off. It's
5680 still available as dreload() anyway, so nothing is lost.
5692 still available as dreload() anyway, so nothing is lost.
5681
5693
5682 2002-01-02 Fernando Perez <fperez@colorado.edu>
5694 2002-01-02 Fernando Perez <fperez@colorado.edu>
5683
5695
5684 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
5696 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
5685 so I wanted an updated release).
5697 so I wanted an updated release).
5686
5698
5687 2001-12-27 Fernando Perez <fperez@colorado.edu>
5699 2001-12-27 Fernando Perez <fperez@colorado.edu>
5688
5700
5689 * IPython/iplib.py (InteractiveShell.interact): Added the original
5701 * IPython/iplib.py (InteractiveShell.interact): Added the original
5690 code from 'code.py' for this module in order to change the
5702 code from 'code.py' for this module in order to change the
5691 handling of a KeyboardInterrupt. This was necessary b/c otherwise
5703 handling of a KeyboardInterrupt. This was necessary b/c otherwise
5692 the history cache would break when the user hit Ctrl-C, and
5704 the history cache would break when the user hit Ctrl-C, and
5693 interact() offers no way to add any hooks to it.
5705 interact() offers no way to add any hooks to it.
5694
5706
5695 2001-12-23 Fernando Perez <fperez@colorado.edu>
5707 2001-12-23 Fernando Perez <fperez@colorado.edu>
5696
5708
5697 * setup.py: added check for 'MANIFEST' before trying to remove
5709 * setup.py: added check for 'MANIFEST' before trying to remove
5698 it. Thanks to Sean Reifschneider.
5710 it. Thanks to Sean Reifschneider.
5699
5711
5700 2001-12-22 Fernando Perez <fperez@colorado.edu>
5712 2001-12-22 Fernando Perez <fperez@colorado.edu>
5701
5713
5702 * Released 0.2.2.
5714 * Released 0.2.2.
5703
5715
5704 * Finished (reasonably) writing the manual. Later will add the
5716 * Finished (reasonably) writing the manual. Later will add the
5705 python-standard navigation stylesheets, but for the time being
5717 python-standard navigation stylesheets, but for the time being
5706 it's fairly complete. Distribution will include html and pdf
5718 it's fairly complete. Distribution will include html and pdf
5707 versions.
5719 versions.
5708
5720
5709 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
5721 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
5710 (MayaVi author).
5722 (MayaVi author).
5711
5723
5712 2001-12-21 Fernando Perez <fperez@colorado.edu>
5724 2001-12-21 Fernando Perez <fperez@colorado.edu>
5713
5725
5714 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
5726 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
5715 good public release, I think (with the manual and the distutils
5727 good public release, I think (with the manual and the distutils
5716 installer). The manual can use some work, but that can go
5728 installer). The manual can use some work, but that can go
5717 slowly. Otherwise I think it's quite nice for end users. Next
5729 slowly. Otherwise I think it's quite nice for end users. Next
5718 summer, rewrite the guts of it...
5730 summer, rewrite the guts of it...
5719
5731
5720 * Changed format of ipythonrc files to use whitespace as the
5732 * Changed format of ipythonrc files to use whitespace as the
5721 separator instead of an explicit '='. Cleaner.
5733 separator instead of an explicit '='. Cleaner.
5722
5734
5723 2001-12-20 Fernando Perez <fperez@colorado.edu>
5735 2001-12-20 Fernando Perez <fperez@colorado.edu>
5724
5736
5725 * Started a manual in LyX. For now it's just a quick merge of the
5737 * Started a manual in LyX. For now it's just a quick merge of the
5726 various internal docstrings and READMEs. Later it may grow into a
5738 various internal docstrings and READMEs. Later it may grow into a
5727 nice, full-blown manual.
5739 nice, full-blown manual.
5728
5740
5729 * Set up a distutils based installer. Installation should now be
5741 * Set up a distutils based installer. Installation should now be
5730 trivially simple for end-users.
5742 trivially simple for end-users.
5731
5743
5732 2001-12-11 Fernando Perez <fperez@colorado.edu>
5744 2001-12-11 Fernando Perez <fperez@colorado.edu>
5733
5745
5734 * Released 0.2.0. First public release, announced it at
5746 * Released 0.2.0. First public release, announced it at
5735 comp.lang.python. From now on, just bugfixes...
5747 comp.lang.python. From now on, just bugfixes...
5736
5748
5737 * Went through all the files, set copyright/license notices and
5749 * Went through all the files, set copyright/license notices and
5738 cleaned up things. Ready for release.
5750 cleaned up things. Ready for release.
5739
5751
5740 2001-12-10 Fernando Perez <fperez@colorado.edu>
5752 2001-12-10 Fernando Perez <fperez@colorado.edu>
5741
5753
5742 * Changed the first-time installer not to use tarfiles. It's more
5754 * Changed the first-time installer not to use tarfiles. It's more
5743 robust now and less unix-dependent. Also makes it easier for
5755 robust now and less unix-dependent. Also makes it easier for
5744 people to later upgrade versions.
5756 people to later upgrade versions.
5745
5757
5746 * Changed @exit to @abort to reflect the fact that it's pretty
5758 * Changed @exit to @abort to reflect the fact that it's pretty
5747 brutal (a sys.exit()). The difference between @abort and Ctrl-D
5759 brutal (a sys.exit()). The difference between @abort and Ctrl-D
5748 becomes significant only when IPyhton is embedded: in that case,
5760 becomes significant only when IPyhton is embedded: in that case,
5749 C-D closes IPython only, but @abort kills the enclosing program
5761 C-D closes IPython only, but @abort kills the enclosing program
5750 too (unless it had called IPython inside a try catching
5762 too (unless it had called IPython inside a try catching
5751 SystemExit).
5763 SystemExit).
5752
5764
5753 * Created Shell module which exposes the actuall IPython Shell
5765 * Created Shell module which exposes the actuall IPython Shell
5754 classes, currently the normal and the embeddable one. This at
5766 classes, currently the normal and the embeddable one. This at
5755 least offers a stable interface we won't need to change when
5767 least offers a stable interface we won't need to change when
5756 (later) the internals are rewritten. That rewrite will be confined
5768 (later) the internals are rewritten. That rewrite will be confined
5757 to iplib and ipmaker, but the Shell interface should remain as is.
5769 to iplib and ipmaker, but the Shell interface should remain as is.
5758
5770
5759 * Added embed module which offers an embeddable IPShell object,
5771 * Added embed module which offers an embeddable IPShell object,
5760 useful to fire up IPython *inside* a running program. Great for
5772 useful to fire up IPython *inside* a running program. Great for
5761 debugging or dynamical data analysis.
5773 debugging or dynamical data analysis.
5762
5774
5763 2001-12-08 Fernando Perez <fperez@colorado.edu>
5775 2001-12-08 Fernando Perez <fperez@colorado.edu>
5764
5776
5765 * Fixed small bug preventing seeing info from methods of defined
5777 * Fixed small bug preventing seeing info from methods of defined
5766 objects (incorrect namespace in _ofind()).
5778 objects (incorrect namespace in _ofind()).
5767
5779
5768 * Documentation cleanup. Moved the main usage docstrings to a
5780 * Documentation cleanup. Moved the main usage docstrings to a
5769 separate file, usage.py (cleaner to maintain, and hopefully in the
5781 separate file, usage.py (cleaner to maintain, and hopefully in the
5770 future some perlpod-like way of producing interactive, man and
5782 future some perlpod-like way of producing interactive, man and
5771 html docs out of it will be found).
5783 html docs out of it will be found).
5772
5784
5773 * Added @profile to see your profile at any time.
5785 * Added @profile to see your profile at any time.
5774
5786
5775 * Added @p as an alias for 'print'. It's especially convenient if
5787 * Added @p as an alias for 'print'. It's especially convenient if
5776 using automagic ('p x' prints x).
5788 using automagic ('p x' prints x).
5777
5789
5778 * Small cleanups and fixes after a pychecker run.
5790 * Small cleanups and fixes after a pychecker run.
5779
5791
5780 * Changed the @cd command to handle @cd - and @cd -<n> for
5792 * Changed the @cd command to handle @cd - and @cd -<n> for
5781 visiting any directory in _dh.
5793 visiting any directory in _dh.
5782
5794
5783 * Introduced _dh, a history of visited directories. @dhist prints
5795 * Introduced _dh, a history of visited directories. @dhist prints
5784 it out with numbers.
5796 it out with numbers.
5785
5797
5786 2001-12-07 Fernando Perez <fperez@colorado.edu>
5798 2001-12-07 Fernando Perez <fperez@colorado.edu>
5787
5799
5788 * Released 0.1.22
5800 * Released 0.1.22
5789
5801
5790 * Made initialization a bit more robust against invalid color
5802 * Made initialization a bit more robust against invalid color
5791 options in user input (exit, not traceback-crash).
5803 options in user input (exit, not traceback-crash).
5792
5804
5793 * Changed the bug crash reporter to write the report only in the
5805 * Changed the bug crash reporter to write the report only in the
5794 user's .ipython directory. That way IPython won't litter people's
5806 user's .ipython directory. That way IPython won't litter people's
5795 hard disks with crash files all over the place. Also print on
5807 hard disks with crash files all over the place. Also print on
5796 screen the necessary mail command.
5808 screen the necessary mail command.
5797
5809
5798 * With the new ultraTB, implemented LightBG color scheme for light
5810 * With the new ultraTB, implemented LightBG color scheme for light
5799 background terminals. A lot of people like white backgrounds, so I
5811 background terminals. A lot of people like white backgrounds, so I
5800 guess we should at least give them something readable.
5812 guess we should at least give them something readable.
5801
5813
5802 2001-12-06 Fernando Perez <fperez@colorado.edu>
5814 2001-12-06 Fernando Perez <fperez@colorado.edu>
5803
5815
5804 * Modified the structure of ultraTB. Now there's a proper class
5816 * Modified the structure of ultraTB. Now there's a proper class
5805 for tables of color schemes which allow adding schemes easily and
5817 for tables of color schemes which allow adding schemes easily and
5806 switching the active scheme without creating a new instance every
5818 switching the active scheme without creating a new instance every
5807 time (which was ridiculous). The syntax for creating new schemes
5819 time (which was ridiculous). The syntax for creating new schemes
5808 is also cleaner. I think ultraTB is finally done, with a clean
5820 is also cleaner. I think ultraTB is finally done, with a clean
5809 class structure. Names are also much cleaner (now there's proper
5821 class structure. Names are also much cleaner (now there's proper
5810 color tables, no need for every variable to also have 'color' in
5822 color tables, no need for every variable to also have 'color' in
5811 its name).
5823 its name).
5812
5824
5813 * Broke down genutils into separate files. Now genutils only
5825 * Broke down genutils into separate files. Now genutils only
5814 contains utility functions, and classes have been moved to their
5826 contains utility functions, and classes have been moved to their
5815 own files (they had enough independent functionality to warrant
5827 own files (they had enough independent functionality to warrant
5816 it): ConfigLoader, OutputTrap, Struct.
5828 it): ConfigLoader, OutputTrap, Struct.
5817
5829
5818 2001-12-05 Fernando Perez <fperez@colorado.edu>
5830 2001-12-05 Fernando Perez <fperez@colorado.edu>
5819
5831
5820 * IPython turns 21! Released version 0.1.21, as a candidate for
5832 * IPython turns 21! Released version 0.1.21, as a candidate for
5821 public consumption. If all goes well, release in a few days.
5833 public consumption. If all goes well, release in a few days.
5822
5834
5823 * Fixed path bug (files in Extensions/ directory wouldn't be found
5835 * Fixed path bug (files in Extensions/ directory wouldn't be found
5824 unless IPython/ was explicitly in sys.path).
5836 unless IPython/ was explicitly in sys.path).
5825
5837
5826 * Extended the FlexCompleter class as MagicCompleter to allow
5838 * Extended the FlexCompleter class as MagicCompleter to allow
5827 completion of @-starting lines.
5839 completion of @-starting lines.
5828
5840
5829 * Created __release__.py file as a central repository for release
5841 * Created __release__.py file as a central repository for release
5830 info that other files can read from.
5842 info that other files can read from.
5831
5843
5832 * Fixed small bug in logging: when logging was turned on in
5844 * Fixed small bug in logging: when logging was turned on in
5833 mid-session, old lines with special meanings (!@?) were being
5845 mid-session, old lines with special meanings (!@?) were being
5834 logged without the prepended comment, which is necessary since
5846 logged without the prepended comment, which is necessary since
5835 they are not truly valid python syntax. This should make session
5847 they are not truly valid python syntax. This should make session
5836 restores produce less errors.
5848 restores produce less errors.
5837
5849
5838 * The namespace cleanup forced me to make a FlexCompleter class
5850 * The namespace cleanup forced me to make a FlexCompleter class
5839 which is nothing but a ripoff of rlcompleter, but with selectable
5851 which is nothing but a ripoff of rlcompleter, but with selectable
5840 namespace (rlcompleter only works in __main__.__dict__). I'll try
5852 namespace (rlcompleter only works in __main__.__dict__). I'll try
5841 to submit a note to the authors to see if this change can be
5853 to submit a note to the authors to see if this change can be
5842 incorporated in future rlcompleter releases (Dec.6: done)
5854 incorporated in future rlcompleter releases (Dec.6: done)
5843
5855
5844 * More fixes to namespace handling. It was a mess! Now all
5856 * More fixes to namespace handling. It was a mess! Now all
5845 explicit references to __main__.__dict__ are gone (except when
5857 explicit references to __main__.__dict__ are gone (except when
5846 really needed) and everything is handled through the namespace
5858 really needed) and everything is handled through the namespace
5847 dicts in the IPython instance. We seem to be getting somewhere
5859 dicts in the IPython instance. We seem to be getting somewhere
5848 with this, finally...
5860 with this, finally...
5849
5861
5850 * Small documentation updates.
5862 * Small documentation updates.
5851
5863
5852 * Created the Extensions directory under IPython (with an
5864 * Created the Extensions directory under IPython (with an
5853 __init__.py). Put the PhysicalQ stuff there. This directory should
5865 __init__.py). Put the PhysicalQ stuff there. This directory should
5854 be used for all special-purpose extensions.
5866 be used for all special-purpose extensions.
5855
5867
5856 * File renaming:
5868 * File renaming:
5857 ipythonlib --> ipmaker
5869 ipythonlib --> ipmaker
5858 ipplib --> iplib
5870 ipplib --> iplib
5859 This makes a bit more sense in terms of what these files actually do.
5871 This makes a bit more sense in terms of what these files actually do.
5860
5872
5861 * Moved all the classes and functions in ipythonlib to ipplib, so
5873 * Moved all the classes and functions in ipythonlib to ipplib, so
5862 now ipythonlib only has make_IPython(). This will ease up its
5874 now ipythonlib only has make_IPython(). This will ease up its
5863 splitting in smaller functional chunks later.
5875 splitting in smaller functional chunks later.
5864
5876
5865 * Cleaned up (done, I think) output of @whos. Better column
5877 * Cleaned up (done, I think) output of @whos. Better column
5866 formatting, and now shows str(var) for as much as it can, which is
5878 formatting, and now shows str(var) for as much as it can, which is
5867 typically what one gets with a 'print var'.
5879 typically what one gets with a 'print var'.
5868
5880
5869 2001-12-04 Fernando Perez <fperez@colorado.edu>
5881 2001-12-04 Fernando Perez <fperez@colorado.edu>
5870
5882
5871 * Fixed namespace problems. Now builtin/IPyhton/user names get
5883 * Fixed namespace problems. Now builtin/IPyhton/user names get
5872 properly reported in their namespace. Internal namespace handling
5884 properly reported in their namespace. Internal namespace handling
5873 is finally getting decent (not perfect yet, but much better than
5885 is finally getting decent (not perfect yet, but much better than
5874 the ad-hoc mess we had).
5886 the ad-hoc mess we had).
5875
5887
5876 * Removed -exit option. If people just want to run a python
5888 * Removed -exit option. If people just want to run a python
5877 script, that's what the normal interpreter is for. Less
5889 script, that's what the normal interpreter is for. Less
5878 unnecessary options, less chances for bugs.
5890 unnecessary options, less chances for bugs.
5879
5891
5880 * Added a crash handler which generates a complete post-mortem if
5892 * Added a crash handler which generates a complete post-mortem if
5881 IPython crashes. This will help a lot in tracking bugs down the
5893 IPython crashes. This will help a lot in tracking bugs down the
5882 road.
5894 road.
5883
5895
5884 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
5896 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
5885 which were boud to functions being reassigned would bypass the
5897 which were boud to functions being reassigned would bypass the
5886 logger, breaking the sync of _il with the prompt counter. This
5898 logger, breaking the sync of _il with the prompt counter. This
5887 would then crash IPython later when a new line was logged.
5899 would then crash IPython later when a new line was logged.
5888
5900
5889 2001-12-02 Fernando Perez <fperez@colorado.edu>
5901 2001-12-02 Fernando Perez <fperez@colorado.edu>
5890
5902
5891 * Made IPython a package. This means people don't have to clutter
5903 * Made IPython a package. This means people don't have to clutter
5892 their sys.path with yet another directory. Changed the INSTALL
5904 their sys.path with yet another directory. Changed the INSTALL
5893 file accordingly.
5905 file accordingly.
5894
5906
5895 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
5907 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
5896 sorts its output (so @who shows it sorted) and @whos formats the
5908 sorts its output (so @who shows it sorted) and @whos formats the
5897 table according to the width of the first column. Nicer, easier to
5909 table according to the width of the first column. Nicer, easier to
5898 read. Todo: write a generic table_format() which takes a list of
5910 read. Todo: write a generic table_format() which takes a list of
5899 lists and prints it nicely formatted, with optional row/column
5911 lists and prints it nicely formatted, with optional row/column
5900 separators and proper padding and justification.
5912 separators and proper padding and justification.
5901
5913
5902 * Released 0.1.20
5914 * Released 0.1.20
5903
5915
5904 * Fixed bug in @log which would reverse the inputcache list (a
5916 * Fixed bug in @log which would reverse the inputcache list (a
5905 copy operation was missing).
5917 copy operation was missing).
5906
5918
5907 * Code cleanup. @config was changed to use page(). Better, since
5919 * Code cleanup. @config was changed to use page(). Better, since
5908 its output is always quite long.
5920 its output is always quite long.
5909
5921
5910 * Itpl is back as a dependency. I was having too many problems
5922 * Itpl is back as a dependency. I was having too many problems
5911 getting the parametric aliases to work reliably, and it's just
5923 getting the parametric aliases to work reliably, and it's just
5912 easier to code weird string operations with it than playing %()s
5924 easier to code weird string operations with it than playing %()s
5913 games. It's only ~6k, so I don't think it's too big a deal.
5925 games. It's only ~6k, so I don't think it's too big a deal.
5914
5926
5915 * Found (and fixed) a very nasty bug with history. !lines weren't
5927 * Found (and fixed) a very nasty bug with history. !lines weren't
5916 getting cached, and the out of sync caches would crash
5928 getting cached, and the out of sync caches would crash
5917 IPython. Fixed it by reorganizing the prefilter/handlers/logger
5929 IPython. Fixed it by reorganizing the prefilter/handlers/logger
5918 division of labor a bit better. Bug fixed, cleaner structure.
5930 division of labor a bit better. Bug fixed, cleaner structure.
5919
5931
5920 2001-12-01 Fernando Perez <fperez@colorado.edu>
5932 2001-12-01 Fernando Perez <fperez@colorado.edu>
5921
5933
5922 * Released 0.1.19
5934 * Released 0.1.19
5923
5935
5924 * Added option -n to @hist to prevent line number printing. Much
5936 * Added option -n to @hist to prevent line number printing. Much
5925 easier to copy/paste code this way.
5937 easier to copy/paste code this way.
5926
5938
5927 * Created global _il to hold the input list. Allows easy
5939 * Created global _il to hold the input list. Allows easy
5928 re-execution of blocks of code by slicing it (inspired by Janko's
5940 re-execution of blocks of code by slicing it (inspired by Janko's
5929 comment on 'macros').
5941 comment on 'macros').
5930
5942
5931 * Small fixes and doc updates.
5943 * Small fixes and doc updates.
5932
5944
5933 * Rewrote @history function (was @h). Renamed it to @hist, @h is
5945 * Rewrote @history function (was @h). Renamed it to @hist, @h is
5934 much too fragile with automagic. Handles properly multi-line
5946 much too fragile with automagic. Handles properly multi-line
5935 statements and takes parameters.
5947 statements and takes parameters.
5936
5948
5937 2001-11-30 Fernando Perez <fperez@colorado.edu>
5949 2001-11-30 Fernando Perez <fperez@colorado.edu>
5938
5950
5939 * Version 0.1.18 released.
5951 * Version 0.1.18 released.
5940
5952
5941 * Fixed nasty namespace bug in initial module imports.
5953 * Fixed nasty namespace bug in initial module imports.
5942
5954
5943 * Added copyright/license notes to all code files (except
5955 * Added copyright/license notes to all code files (except
5944 DPyGetOpt). For the time being, LGPL. That could change.
5956 DPyGetOpt). For the time being, LGPL. That could change.
5945
5957
5946 * Rewrote a much nicer README, updated INSTALL, cleaned up
5958 * Rewrote a much nicer README, updated INSTALL, cleaned up
5947 ipythonrc-* samples.
5959 ipythonrc-* samples.
5948
5960
5949 * Overall code/documentation cleanup. Basically ready for
5961 * Overall code/documentation cleanup. Basically ready for
5950 release. Only remaining thing: licence decision (LGPL?).
5962 release. Only remaining thing: licence decision (LGPL?).
5951
5963
5952 * Converted load_config to a class, ConfigLoader. Now recursion
5964 * Converted load_config to a class, ConfigLoader. Now recursion
5953 control is better organized. Doesn't include the same file twice.
5965 control is better organized. Doesn't include the same file twice.
5954
5966
5955 2001-11-29 Fernando Perez <fperez@colorado.edu>
5967 2001-11-29 Fernando Perez <fperez@colorado.edu>
5956
5968
5957 * Got input history working. Changed output history variables from
5969 * Got input history working. Changed output history variables from
5958 _p to _o so that _i is for input and _o for output. Just cleaner
5970 _p to _o so that _i is for input and _o for output. Just cleaner
5959 convention.
5971 convention.
5960
5972
5961 * Implemented parametric aliases. This pretty much allows the
5973 * Implemented parametric aliases. This pretty much allows the
5962 alias system to offer full-blown shell convenience, I think.
5974 alias system to offer full-blown shell convenience, I think.
5963
5975
5964 * Version 0.1.17 released, 0.1.18 opened.
5976 * Version 0.1.17 released, 0.1.18 opened.
5965
5977
5966 * dot_ipython/ipythonrc (alias): added documentation.
5978 * dot_ipython/ipythonrc (alias): added documentation.
5967 (xcolor): Fixed small bug (xcolors -> xcolor)
5979 (xcolor): Fixed small bug (xcolors -> xcolor)
5968
5980
5969 * Changed the alias system. Now alias is a magic command to define
5981 * Changed the alias system. Now alias is a magic command to define
5970 aliases just like the shell. Rationale: the builtin magics should
5982 aliases just like the shell. Rationale: the builtin magics should
5971 be there for things deeply connected to IPython's
5983 be there for things deeply connected to IPython's
5972 architecture. And this is a much lighter system for what I think
5984 architecture. And this is a much lighter system for what I think
5973 is the really important feature: allowing users to define quickly
5985 is the really important feature: allowing users to define quickly
5974 magics that will do shell things for them, so they can customize
5986 magics that will do shell things for them, so they can customize
5975 IPython easily to match their work habits. If someone is really
5987 IPython easily to match their work habits. If someone is really
5976 desperate to have another name for a builtin alias, they can
5988 desperate to have another name for a builtin alias, they can
5977 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
5989 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
5978 works.
5990 works.
5979
5991
5980 2001-11-28 Fernando Perez <fperez@colorado.edu>
5992 2001-11-28 Fernando Perez <fperez@colorado.edu>
5981
5993
5982 * Changed @file so that it opens the source file at the proper
5994 * Changed @file so that it opens the source file at the proper
5983 line. Since it uses less, if your EDITOR environment is
5995 line. Since it uses less, if your EDITOR environment is
5984 configured, typing v will immediately open your editor of choice
5996 configured, typing v will immediately open your editor of choice
5985 right at the line where the object is defined. Not as quick as
5997 right at the line where the object is defined. Not as quick as
5986 having a direct @edit command, but for all intents and purposes it
5998 having a direct @edit command, but for all intents and purposes it
5987 works. And I don't have to worry about writing @edit to deal with
5999 works. And I don't have to worry about writing @edit to deal with
5988 all the editors, less does that.
6000 all the editors, less does that.
5989
6001
5990 * Version 0.1.16 released, 0.1.17 opened.
6002 * Version 0.1.16 released, 0.1.17 opened.
5991
6003
5992 * Fixed some nasty bugs in the page/page_dumb combo that could
6004 * Fixed some nasty bugs in the page/page_dumb combo that could
5993 crash IPython.
6005 crash IPython.
5994
6006
5995 2001-11-27 Fernando Perez <fperez@colorado.edu>
6007 2001-11-27 Fernando Perez <fperez@colorado.edu>
5996
6008
5997 * Version 0.1.15 released, 0.1.16 opened.
6009 * Version 0.1.15 released, 0.1.16 opened.
5998
6010
5999 * Finally got ? and ?? to work for undefined things: now it's
6011 * Finally got ? and ?? to work for undefined things: now it's
6000 possible to type {}.get? and get information about the get method
6012 possible to type {}.get? and get information about the get method
6001 of dicts, or os.path? even if only os is defined (so technically
6013 of dicts, or os.path? even if only os is defined (so technically
6002 os.path isn't). Works at any level. For example, after import os,
6014 os.path isn't). Works at any level. For example, after import os,
6003 os?, os.path?, os.path.abspath? all work. This is great, took some
6015 os?, os.path?, os.path.abspath? all work. This is great, took some
6004 work in _ofind.
6016 work in _ofind.
6005
6017
6006 * Fixed more bugs with logging. The sanest way to do it was to add
6018 * Fixed more bugs with logging. The sanest way to do it was to add
6007 to @log a 'mode' parameter. Killed two in one shot (this mode
6019 to @log a 'mode' parameter. Killed two in one shot (this mode
6008 option was a request of Janko's). I think it's finally clean
6020 option was a request of Janko's). I think it's finally clean
6009 (famous last words).
6021 (famous last words).
6010
6022
6011 * Added a page_dumb() pager which does a decent job of paging on
6023 * Added a page_dumb() pager which does a decent job of paging on
6012 screen, if better things (like less) aren't available. One less
6024 screen, if better things (like less) aren't available. One less
6013 unix dependency (someday maybe somebody will port this to
6025 unix dependency (someday maybe somebody will port this to
6014 windows).
6026 windows).
6015
6027
6016 * Fixed problem in magic_log: would lock of logging out if log
6028 * Fixed problem in magic_log: would lock of logging out if log
6017 creation failed (because it would still think it had succeeded).
6029 creation failed (because it would still think it had succeeded).
6018
6030
6019 * Improved the page() function using curses to auto-detect screen
6031 * Improved the page() function using curses to auto-detect screen
6020 size. Now it can make a much better decision on whether to print
6032 size. Now it can make a much better decision on whether to print
6021 or page a string. Option screen_length was modified: a value 0
6033 or page a string. Option screen_length was modified: a value 0
6022 means auto-detect, and that's the default now.
6034 means auto-detect, and that's the default now.
6023
6035
6024 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
6036 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
6025 go out. I'll test it for a few days, then talk to Janko about
6037 go out. I'll test it for a few days, then talk to Janko about
6026 licences and announce it.
6038 licences and announce it.
6027
6039
6028 * Fixed the length of the auto-generated ---> prompt which appears
6040 * Fixed the length of the auto-generated ---> prompt which appears
6029 for auto-parens and auto-quotes. Getting this right isn't trivial,
6041 for auto-parens and auto-quotes. Getting this right isn't trivial,
6030 with all the color escapes, different prompt types and optional
6042 with all the color escapes, different prompt types and optional
6031 separators. But it seems to be working in all the combinations.
6043 separators. But it seems to be working in all the combinations.
6032
6044
6033 2001-11-26 Fernando Perez <fperez@colorado.edu>
6045 2001-11-26 Fernando Perez <fperez@colorado.edu>
6034
6046
6035 * Wrote a regexp filter to get option types from the option names
6047 * Wrote a regexp filter to get option types from the option names
6036 string. This eliminates the need to manually keep two duplicate
6048 string. This eliminates the need to manually keep two duplicate
6037 lists.
6049 lists.
6038
6050
6039 * Removed the unneeded check_option_names. Now options are handled
6051 * Removed the unneeded check_option_names. Now options are handled
6040 in a much saner manner and it's easy to visually check that things
6052 in a much saner manner and it's easy to visually check that things
6041 are ok.
6053 are ok.
6042
6054
6043 * Updated version numbers on all files I modified to carry a
6055 * Updated version numbers on all files I modified to carry a
6044 notice so Janko and Nathan have clear version markers.
6056 notice so Janko and Nathan have clear version markers.
6045
6057
6046 * Updated docstring for ultraTB with my changes. I should send
6058 * Updated docstring for ultraTB with my changes. I should send
6047 this to Nathan.
6059 this to Nathan.
6048
6060
6049 * Lots of small fixes. Ran everything through pychecker again.
6061 * Lots of small fixes. Ran everything through pychecker again.
6050
6062
6051 * Made loading of deep_reload an cmd line option. If it's not too
6063 * Made loading of deep_reload an cmd line option. If it's not too
6052 kosher, now people can just disable it. With -nodeep_reload it's
6064 kosher, now people can just disable it. With -nodeep_reload it's
6053 still available as dreload(), it just won't overwrite reload().
6065 still available as dreload(), it just won't overwrite reload().
6054
6066
6055 * Moved many options to the no| form (-opt and -noopt
6067 * Moved many options to the no| form (-opt and -noopt
6056 accepted). Cleaner.
6068 accepted). Cleaner.
6057
6069
6058 * Changed magic_log so that if called with no parameters, it uses
6070 * Changed magic_log so that if called with no parameters, it uses
6059 'rotate' mode. That way auto-generated logs aren't automatically
6071 'rotate' mode. That way auto-generated logs aren't automatically
6060 over-written. For normal logs, now a backup is made if it exists
6072 over-written. For normal logs, now a backup is made if it exists
6061 (only 1 level of backups). A new 'backup' mode was added to the
6073 (only 1 level of backups). A new 'backup' mode was added to the
6062 Logger class to support this. This was a request by Janko.
6074 Logger class to support this. This was a request by Janko.
6063
6075
6064 * Added @logoff/@logon to stop/restart an active log.
6076 * Added @logoff/@logon to stop/restart an active log.
6065
6077
6066 * Fixed a lot of bugs in log saving/replay. It was pretty
6078 * Fixed a lot of bugs in log saving/replay. It was pretty
6067 broken. Now special lines (!@,/) appear properly in the command
6079 broken. Now special lines (!@,/) appear properly in the command
6068 history after a log replay.
6080 history after a log replay.
6069
6081
6070 * Tried and failed to implement full session saving via pickle. My
6082 * Tried and failed to implement full session saving via pickle. My
6071 idea was to pickle __main__.__dict__, but modules can't be
6083 idea was to pickle __main__.__dict__, but modules can't be
6072 pickled. This would be a better alternative to replaying logs, but
6084 pickled. This would be a better alternative to replaying logs, but
6073 seems quite tricky to get to work. Changed -session to be called
6085 seems quite tricky to get to work. Changed -session to be called
6074 -logplay, which more accurately reflects what it does. And if we
6086 -logplay, which more accurately reflects what it does. And if we
6075 ever get real session saving working, -session is now available.
6087 ever get real session saving working, -session is now available.
6076
6088
6077 * Implemented color schemes for prompts also. As for tracebacks,
6089 * Implemented color schemes for prompts also. As for tracebacks,
6078 currently only NoColor and Linux are supported. But now the
6090 currently only NoColor and Linux are supported. But now the
6079 infrastructure is in place, based on a generic ColorScheme
6091 infrastructure is in place, based on a generic ColorScheme
6080 class. So writing and activating new schemes both for the prompts
6092 class. So writing and activating new schemes both for the prompts
6081 and the tracebacks should be straightforward.
6093 and the tracebacks should be straightforward.
6082
6094
6083 * Version 0.1.13 released, 0.1.14 opened.
6095 * Version 0.1.13 released, 0.1.14 opened.
6084
6096
6085 * Changed handling of options for output cache. Now counter is
6097 * Changed handling of options for output cache. Now counter is
6086 hardwired starting at 1 and one specifies the maximum number of
6098 hardwired starting at 1 and one specifies the maximum number of
6087 entries *in the outcache* (not the max prompt counter). This is
6099 entries *in the outcache* (not the max prompt counter). This is
6088 much better, since many statements won't increase the cache
6100 much better, since many statements won't increase the cache
6089 count. It also eliminated some confusing options, now there's only
6101 count. It also eliminated some confusing options, now there's only
6090 one: cache_size.
6102 one: cache_size.
6091
6103
6092 * Added 'alias' magic function and magic_alias option in the
6104 * Added 'alias' magic function and magic_alias option in the
6093 ipythonrc file. Now the user can easily define whatever names he
6105 ipythonrc file. Now the user can easily define whatever names he
6094 wants for the magic functions without having to play weird
6106 wants for the magic functions without having to play weird
6095 namespace games. This gives IPython a real shell-like feel.
6107 namespace games. This gives IPython a real shell-like feel.
6096
6108
6097 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
6109 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
6098 @ or not).
6110 @ or not).
6099
6111
6100 This was one of the last remaining 'visible' bugs (that I know
6112 This was one of the last remaining 'visible' bugs (that I know
6101 of). I think if I can clean up the session loading so it works
6113 of). I think if I can clean up the session loading so it works
6102 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
6114 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
6103 about licensing).
6115 about licensing).
6104
6116
6105 2001-11-25 Fernando Perez <fperez@colorado.edu>
6117 2001-11-25 Fernando Perez <fperez@colorado.edu>
6106
6118
6107 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
6119 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
6108 there's a cleaner distinction between what ? and ?? show.
6120 there's a cleaner distinction between what ? and ?? show.
6109
6121
6110 * Added screen_length option. Now the user can define his own
6122 * Added screen_length option. Now the user can define his own
6111 screen size for page() operations.
6123 screen size for page() operations.
6112
6124
6113 * Implemented magic shell-like functions with automatic code
6125 * Implemented magic shell-like functions with automatic code
6114 generation. Now adding another function is just a matter of adding
6126 generation. Now adding another function is just a matter of adding
6115 an entry to a dict, and the function is dynamically generated at
6127 an entry to a dict, and the function is dynamically generated at
6116 run-time. Python has some really cool features!
6128 run-time. Python has some really cool features!
6117
6129
6118 * Renamed many options to cleanup conventions a little. Now all
6130 * Renamed many options to cleanup conventions a little. Now all
6119 are lowercase, and only underscores where needed. Also in the code
6131 are lowercase, and only underscores where needed. Also in the code
6120 option name tables are clearer.
6132 option name tables are clearer.
6121
6133
6122 * Changed prompts a little. Now input is 'In [n]:' instead of
6134 * Changed prompts a little. Now input is 'In [n]:' instead of
6123 'In[n]:='. This allows it the numbers to be aligned with the
6135 'In[n]:='. This allows it the numbers to be aligned with the
6124 Out[n] numbers, and removes usage of ':=' which doesn't exist in
6136 Out[n] numbers, and removes usage of ':=' which doesn't exist in
6125 Python (it was a Mathematica thing). The '...' continuation prompt
6137 Python (it was a Mathematica thing). The '...' continuation prompt
6126 was also changed a little to align better.
6138 was also changed a little to align better.
6127
6139
6128 * Fixed bug when flushing output cache. Not all _p<n> variables
6140 * Fixed bug when flushing output cache. Not all _p<n> variables
6129 exist, so their deletion needs to be wrapped in a try:
6141 exist, so their deletion needs to be wrapped in a try:
6130
6142
6131 * Figured out how to properly use inspect.formatargspec() (it
6143 * Figured out how to properly use inspect.formatargspec() (it
6132 requires the args preceded by *). So I removed all the code from
6144 requires the args preceded by *). So I removed all the code from
6133 _get_pdef in Magic, which was just replicating that.
6145 _get_pdef in Magic, which was just replicating that.
6134
6146
6135 * Added test to prefilter to allow redefining magic function names
6147 * Added test to prefilter to allow redefining magic function names
6136 as variables. This is ok, since the @ form is always available,
6148 as variables. This is ok, since the @ form is always available,
6137 but whe should allow the user to define a variable called 'ls' if
6149 but whe should allow the user to define a variable called 'ls' if
6138 he needs it.
6150 he needs it.
6139
6151
6140 * Moved the ToDo information from README into a separate ToDo.
6152 * Moved the ToDo information from README into a separate ToDo.
6141
6153
6142 * General code cleanup and small bugfixes. I think it's close to a
6154 * General code cleanup and small bugfixes. I think it's close to a
6143 state where it can be released, obviously with a big 'beta'
6155 state where it can be released, obviously with a big 'beta'
6144 warning on it.
6156 warning on it.
6145
6157
6146 * Got the magic function split to work. Now all magics are defined
6158 * Got the magic function split to work. Now all magics are defined
6147 in a separate class. It just organizes things a bit, and now
6159 in a separate class. It just organizes things a bit, and now
6148 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
6160 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
6149 was too long).
6161 was too long).
6150
6162
6151 * Changed @clear to @reset to avoid potential confusions with
6163 * Changed @clear to @reset to avoid potential confusions with
6152 the shell command clear. Also renamed @cl to @clear, which does
6164 the shell command clear. Also renamed @cl to @clear, which does
6153 exactly what people expect it to from their shell experience.
6165 exactly what people expect it to from their shell experience.
6154
6166
6155 Added a check to the @reset command (since it's so
6167 Added a check to the @reset command (since it's so
6156 destructive, it's probably a good idea to ask for confirmation).
6168 destructive, it's probably a good idea to ask for confirmation).
6157 But now reset only works for full namespace resetting. Since the
6169 But now reset only works for full namespace resetting. Since the
6158 del keyword is already there for deleting a few specific
6170 del keyword is already there for deleting a few specific
6159 variables, I don't see the point of having a redundant magic
6171 variables, I don't see the point of having a redundant magic
6160 function for the same task.
6172 function for the same task.
6161
6173
6162 2001-11-24 Fernando Perez <fperez@colorado.edu>
6174 2001-11-24 Fernando Perez <fperez@colorado.edu>
6163
6175
6164 * Updated the builtin docs (esp. the ? ones).
6176 * Updated the builtin docs (esp. the ? ones).
6165
6177
6166 * Ran all the code through pychecker. Not terribly impressed with
6178 * Ran all the code through pychecker. Not terribly impressed with
6167 it: lots of spurious warnings and didn't really find anything of
6179 it: lots of spurious warnings and didn't really find anything of
6168 substance (just a few modules being imported and not used).
6180 substance (just a few modules being imported and not used).
6169
6181
6170 * Implemented the new ultraTB functionality into IPython. New
6182 * Implemented the new ultraTB functionality into IPython. New
6171 option: xcolors. This chooses color scheme. xmode now only selects
6183 option: xcolors. This chooses color scheme. xmode now only selects
6172 between Plain and Verbose. Better orthogonality.
6184 between Plain and Verbose. Better orthogonality.
6173
6185
6174 * Large rewrite of ultraTB. Much cleaner now, with a separation of
6186 * Large rewrite of ultraTB. Much cleaner now, with a separation of
6175 mode and color scheme for the exception handlers. Now it's
6187 mode and color scheme for the exception handlers. Now it's
6176 possible to have the verbose traceback with no coloring.
6188 possible to have the verbose traceback with no coloring.
6177
6189
6178 2001-11-23 Fernando Perez <fperez@colorado.edu>
6190 2001-11-23 Fernando Perez <fperez@colorado.edu>
6179
6191
6180 * Version 0.1.12 released, 0.1.13 opened.
6192 * Version 0.1.12 released, 0.1.13 opened.
6181
6193
6182 * Removed option to set auto-quote and auto-paren escapes by
6194 * Removed option to set auto-quote and auto-paren escapes by
6183 user. The chances of breaking valid syntax are just too high. If
6195 user. The chances of breaking valid syntax are just too high. If
6184 someone *really* wants, they can always dig into the code.
6196 someone *really* wants, they can always dig into the code.
6185
6197
6186 * Made prompt separators configurable.
6198 * Made prompt separators configurable.
6187
6199
6188 2001-11-22 Fernando Perez <fperez@colorado.edu>
6200 2001-11-22 Fernando Perez <fperez@colorado.edu>
6189
6201
6190 * Small bugfixes in many places.
6202 * Small bugfixes in many places.
6191
6203
6192 * Removed the MyCompleter class from ipplib. It seemed redundant
6204 * Removed the MyCompleter class from ipplib. It seemed redundant
6193 with the C-p,C-n history search functionality. Less code to
6205 with the C-p,C-n history search functionality. Less code to
6194 maintain.
6206 maintain.
6195
6207
6196 * Moved all the original ipython.py code into ipythonlib.py. Right
6208 * Moved all the original ipython.py code into ipythonlib.py. Right
6197 now it's just one big dump into a function called make_IPython, so
6209 now it's just one big dump into a function called make_IPython, so
6198 no real modularity has been gained. But at least it makes the
6210 no real modularity has been gained. But at least it makes the
6199 wrapper script tiny, and since ipythonlib is a module, it gets
6211 wrapper script tiny, and since ipythonlib is a module, it gets
6200 compiled and startup is much faster.
6212 compiled and startup is much faster.
6201
6213
6202 This is a reasobably 'deep' change, so we should test it for a
6214 This is a reasobably 'deep' change, so we should test it for a
6203 while without messing too much more with the code.
6215 while without messing too much more with the code.
6204
6216
6205 2001-11-21 Fernando Perez <fperez@colorado.edu>
6217 2001-11-21 Fernando Perez <fperez@colorado.edu>
6206
6218
6207 * Version 0.1.11 released, 0.1.12 opened for further work.
6219 * Version 0.1.11 released, 0.1.12 opened for further work.
6208
6220
6209 * Removed dependency on Itpl. It was only needed in one place. It
6221 * Removed dependency on Itpl. It was only needed in one place. It
6210 would be nice if this became part of python, though. It makes life
6222 would be nice if this became part of python, though. It makes life
6211 *a lot* easier in some cases.
6223 *a lot* easier in some cases.
6212
6224
6213 * Simplified the prefilter code a bit. Now all handlers are
6225 * Simplified the prefilter code a bit. Now all handlers are
6214 expected to explicitly return a value (at least a blank string).
6226 expected to explicitly return a value (at least a blank string).
6215
6227
6216 * Heavy edits in ipplib. Removed the help system altogether. Now
6228 * Heavy edits in ipplib. Removed the help system altogether. Now
6217 obj?/?? is used for inspecting objects, a magic @doc prints
6229 obj?/?? is used for inspecting objects, a magic @doc prints
6218 docstrings, and full-blown Python help is accessed via the 'help'
6230 docstrings, and full-blown Python help is accessed via the 'help'
6219 keyword. This cleans up a lot of code (less to maintain) and does
6231 keyword. This cleans up a lot of code (less to maintain) and does
6220 the job. Since 'help' is now a standard Python component, might as
6232 the job. Since 'help' is now a standard Python component, might as
6221 well use it and remove duplicate functionality.
6233 well use it and remove duplicate functionality.
6222
6234
6223 Also removed the option to use ipplib as a standalone program. By
6235 Also removed the option to use ipplib as a standalone program. By
6224 now it's too dependent on other parts of IPython to function alone.
6236 now it's too dependent on other parts of IPython to function alone.
6225
6237
6226 * Fixed bug in genutils.pager. It would crash if the pager was
6238 * Fixed bug in genutils.pager. It would crash if the pager was
6227 exited immediately after opening (broken pipe).
6239 exited immediately after opening (broken pipe).
6228
6240
6229 * Trimmed down the VerboseTB reporting a little. The header is
6241 * Trimmed down the VerboseTB reporting a little. The header is
6230 much shorter now and the repeated exception arguments at the end
6242 much shorter now and the repeated exception arguments at the end
6231 have been removed. For interactive use the old header seemed a bit
6243 have been removed. For interactive use the old header seemed a bit
6232 excessive.
6244 excessive.
6233
6245
6234 * Fixed small bug in output of @whos for variables with multi-word
6246 * Fixed small bug in output of @whos for variables with multi-word
6235 types (only first word was displayed).
6247 types (only first word was displayed).
6236
6248
6237 2001-11-17 Fernando Perez <fperez@colorado.edu>
6249 2001-11-17 Fernando Perez <fperez@colorado.edu>
6238
6250
6239 * Version 0.1.10 released, 0.1.11 opened for further work.
6251 * Version 0.1.10 released, 0.1.11 opened for further work.
6240
6252
6241 * Modified dirs and friends. dirs now *returns* the stack (not
6253 * Modified dirs and friends. dirs now *returns* the stack (not
6242 prints), so one can manipulate it as a variable. Convenient to
6254 prints), so one can manipulate it as a variable. Convenient to
6243 travel along many directories.
6255 travel along many directories.
6244
6256
6245 * Fixed bug in magic_pdef: would only work with functions with
6257 * Fixed bug in magic_pdef: would only work with functions with
6246 arguments with default values.
6258 arguments with default values.
6247
6259
6248 2001-11-14 Fernando Perez <fperez@colorado.edu>
6260 2001-11-14 Fernando Perez <fperez@colorado.edu>
6249
6261
6250 * Added the PhysicsInput stuff to dot_ipython so it ships as an
6262 * Added the PhysicsInput stuff to dot_ipython so it ships as an
6251 example with IPython. Various other minor fixes and cleanups.
6263 example with IPython. Various other minor fixes and cleanups.
6252
6264
6253 * Version 0.1.9 released, 0.1.10 opened for further work.
6265 * Version 0.1.9 released, 0.1.10 opened for further work.
6254
6266
6255 * Added sys.path to the list of directories searched in the
6267 * Added sys.path to the list of directories searched in the
6256 execfile= option. It used to be the current directory and the
6268 execfile= option. It used to be the current directory and the
6257 user's IPYTHONDIR only.
6269 user's IPYTHONDIR only.
6258
6270
6259 2001-11-13 Fernando Perez <fperez@colorado.edu>
6271 2001-11-13 Fernando Perez <fperez@colorado.edu>
6260
6272
6261 * Reinstated the raw_input/prefilter separation that Janko had
6273 * Reinstated the raw_input/prefilter separation that Janko had
6262 initially. This gives a more convenient setup for extending the
6274 initially. This gives a more convenient setup for extending the
6263 pre-processor from the outside: raw_input always gets a string,
6275 pre-processor from the outside: raw_input always gets a string,
6264 and prefilter has to process it. We can then redefine prefilter
6276 and prefilter has to process it. We can then redefine prefilter
6265 from the outside and implement extensions for special
6277 from the outside and implement extensions for special
6266 purposes.
6278 purposes.
6267
6279
6268 Today I got one for inputting PhysicalQuantity objects
6280 Today I got one for inputting PhysicalQuantity objects
6269 (from Scientific) without needing any function calls at
6281 (from Scientific) without needing any function calls at
6270 all. Extremely convenient, and it's all done as a user-level
6282 all. Extremely convenient, and it's all done as a user-level
6271 extension (no IPython code was touched). Now instead of:
6283 extension (no IPython code was touched). Now instead of:
6272 a = PhysicalQuantity(4.2,'m/s**2')
6284 a = PhysicalQuantity(4.2,'m/s**2')
6273 one can simply say
6285 one can simply say
6274 a = 4.2 m/s**2
6286 a = 4.2 m/s**2
6275 or even
6287 or even
6276 a = 4.2 m/s^2
6288 a = 4.2 m/s^2
6277
6289
6278 I use this, but it's also a proof of concept: IPython really is
6290 I use this, but it's also a proof of concept: IPython really is
6279 fully user-extensible, even at the level of the parsing of the
6291 fully user-extensible, even at the level of the parsing of the
6280 command line. It's not trivial, but it's perfectly doable.
6292 command line. It's not trivial, but it's perfectly doable.
6281
6293
6282 * Added 'add_flip' method to inclusion conflict resolver. Fixes
6294 * Added 'add_flip' method to inclusion conflict resolver. Fixes
6283 the problem of modules being loaded in the inverse order in which
6295 the problem of modules being loaded in the inverse order in which
6284 they were defined in
6296 they were defined in
6285
6297
6286 * Version 0.1.8 released, 0.1.9 opened for further work.
6298 * Version 0.1.8 released, 0.1.9 opened for further work.
6287
6299
6288 * Added magics pdef, source and file. They respectively show the
6300 * Added magics pdef, source and file. They respectively show the
6289 definition line ('prototype' in C), source code and full python
6301 definition line ('prototype' in C), source code and full python
6290 file for any callable object. The object inspector oinfo uses
6302 file for any callable object. The object inspector oinfo uses
6291 these to show the same information.
6303 these to show the same information.
6292
6304
6293 * Version 0.1.7 released, 0.1.8 opened for further work.
6305 * Version 0.1.7 released, 0.1.8 opened for further work.
6294
6306
6295 * Separated all the magic functions into a class called Magic. The
6307 * Separated all the magic functions into a class called Magic. The
6296 InteractiveShell class was becoming too big for Xemacs to handle
6308 InteractiveShell class was becoming too big for Xemacs to handle
6297 (de-indenting a line would lock it up for 10 seconds while it
6309 (de-indenting a line would lock it up for 10 seconds while it
6298 backtracked on the whole class!)
6310 backtracked on the whole class!)
6299
6311
6300 FIXME: didn't work. It can be done, but right now namespaces are
6312 FIXME: didn't work. It can be done, but right now namespaces are
6301 all messed up. Do it later (reverted it for now, so at least
6313 all messed up. Do it later (reverted it for now, so at least
6302 everything works as before).
6314 everything works as before).
6303
6315
6304 * Got the object introspection system (magic_oinfo) working! I
6316 * Got the object introspection system (magic_oinfo) working! I
6305 think this is pretty much ready for release to Janko, so he can
6317 think this is pretty much ready for release to Janko, so he can
6306 test it for a while and then announce it. Pretty much 100% of what
6318 test it for a while and then announce it. Pretty much 100% of what
6307 I wanted for the 'phase 1' release is ready. Happy, tired.
6319 I wanted for the 'phase 1' release is ready. Happy, tired.
6308
6320
6309 2001-11-12 Fernando Perez <fperez@colorado.edu>
6321 2001-11-12 Fernando Perez <fperez@colorado.edu>
6310
6322
6311 * Version 0.1.6 released, 0.1.7 opened for further work.
6323 * Version 0.1.6 released, 0.1.7 opened for further work.
6312
6324
6313 * Fixed bug in printing: it used to test for truth before
6325 * Fixed bug in printing: it used to test for truth before
6314 printing, so 0 wouldn't print. Now checks for None.
6326 printing, so 0 wouldn't print. Now checks for None.
6315
6327
6316 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
6328 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
6317 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
6329 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
6318 reaches by hand into the outputcache. Think of a better way to do
6330 reaches by hand into the outputcache. Think of a better way to do
6319 this later.
6331 this later.
6320
6332
6321 * Various small fixes thanks to Nathan's comments.
6333 * Various small fixes thanks to Nathan's comments.
6322
6334
6323 * Changed magic_pprint to magic_Pprint. This way it doesn't
6335 * Changed magic_pprint to magic_Pprint. This way it doesn't
6324 collide with pprint() and the name is consistent with the command
6336 collide with pprint() and the name is consistent with the command
6325 line option.
6337 line option.
6326
6338
6327 * Changed prompt counter behavior to be fully like
6339 * Changed prompt counter behavior to be fully like
6328 Mathematica's. That is, even input that doesn't return a result
6340 Mathematica's. That is, even input that doesn't return a result
6329 raises the prompt counter. The old behavior was kind of confusing
6341 raises the prompt counter. The old behavior was kind of confusing
6330 (getting the same prompt number several times if the operation
6342 (getting the same prompt number several times if the operation
6331 didn't return a result).
6343 didn't return a result).
6332
6344
6333 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
6345 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
6334
6346
6335 * Fixed -Classic mode (wasn't working anymore).
6347 * Fixed -Classic mode (wasn't working anymore).
6336
6348
6337 * Added colored prompts using Nathan's new code. Colors are
6349 * Added colored prompts using Nathan's new code. Colors are
6338 currently hardwired, they can be user-configurable. For
6350 currently hardwired, they can be user-configurable. For
6339 developers, they can be chosen in file ipythonlib.py, at the
6351 developers, they can be chosen in file ipythonlib.py, at the
6340 beginning of the CachedOutput class def.
6352 beginning of the CachedOutput class def.
6341
6353
6342 2001-11-11 Fernando Perez <fperez@colorado.edu>
6354 2001-11-11 Fernando Perez <fperez@colorado.edu>
6343
6355
6344 * Version 0.1.5 released, 0.1.6 opened for further work.
6356 * Version 0.1.5 released, 0.1.6 opened for further work.
6345
6357
6346 * Changed magic_env to *return* the environment as a dict (not to
6358 * Changed magic_env to *return* the environment as a dict (not to
6347 print it). This way it prints, but it can also be processed.
6359 print it). This way it prints, but it can also be processed.
6348
6360
6349 * Added Verbose exception reporting to interactive
6361 * Added Verbose exception reporting to interactive
6350 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
6362 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
6351 traceback. Had to make some changes to the ultraTB file. This is
6363 traceback. Had to make some changes to the ultraTB file. This is
6352 probably the last 'big' thing in my mental todo list. This ties
6364 probably the last 'big' thing in my mental todo list. This ties
6353 in with the next entry:
6365 in with the next entry:
6354
6366
6355 * Changed -Xi and -Xf to a single -xmode option. Now all the user
6367 * Changed -Xi and -Xf to a single -xmode option. Now all the user
6356 has to specify is Plain, Color or Verbose for all exception
6368 has to specify is Plain, Color or Verbose for all exception
6357 handling.
6369 handling.
6358
6370
6359 * Removed ShellServices option. All this can really be done via
6371 * Removed ShellServices option. All this can really be done via
6360 the magic system. It's easier to extend, cleaner and has automatic
6372 the magic system. It's easier to extend, cleaner and has automatic
6361 namespace protection and documentation.
6373 namespace protection and documentation.
6362
6374
6363 2001-11-09 Fernando Perez <fperez@colorado.edu>
6375 2001-11-09 Fernando Perez <fperez@colorado.edu>
6364
6376
6365 * Fixed bug in output cache flushing (missing parameter to
6377 * Fixed bug in output cache flushing (missing parameter to
6366 __init__). Other small bugs fixed (found using pychecker).
6378 __init__). Other small bugs fixed (found using pychecker).
6367
6379
6368 * Version 0.1.4 opened for bugfixing.
6380 * Version 0.1.4 opened for bugfixing.
6369
6381
6370 2001-11-07 Fernando Perez <fperez@colorado.edu>
6382 2001-11-07 Fernando Perez <fperez@colorado.edu>
6371
6383
6372 * Version 0.1.3 released, mainly because of the raw_input bug.
6384 * Version 0.1.3 released, mainly because of the raw_input bug.
6373
6385
6374 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
6386 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
6375 and when testing for whether things were callable, a call could
6387 and when testing for whether things were callable, a call could
6376 actually be made to certain functions. They would get called again
6388 actually be made to certain functions. They would get called again
6377 once 'really' executed, with a resulting double call. A disaster
6389 once 'really' executed, with a resulting double call. A disaster
6378 in many cases (list.reverse() would never work!).
6390 in many cases (list.reverse() would never work!).
6379
6391
6380 * Removed prefilter() function, moved its code to raw_input (which
6392 * Removed prefilter() function, moved its code to raw_input (which
6381 after all was just a near-empty caller for prefilter). This saves
6393 after all was just a near-empty caller for prefilter). This saves
6382 a function call on every prompt, and simplifies the class a tiny bit.
6394 a function call on every prompt, and simplifies the class a tiny bit.
6383
6395
6384 * Fix _ip to __ip name in magic example file.
6396 * Fix _ip to __ip name in magic example file.
6385
6397
6386 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
6398 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
6387 work with non-gnu versions of tar.
6399 work with non-gnu versions of tar.
6388
6400
6389 2001-11-06 Fernando Perez <fperez@colorado.edu>
6401 2001-11-06 Fernando Perez <fperez@colorado.edu>
6390
6402
6391 * Version 0.1.2. Just to keep track of the recent changes.
6403 * Version 0.1.2. Just to keep track of the recent changes.
6392
6404
6393 * Fixed nasty bug in output prompt routine. It used to check 'if
6405 * Fixed nasty bug in output prompt routine. It used to check 'if
6394 arg != None...'. Problem is, this fails if arg implements a
6406 arg != None...'. Problem is, this fails if arg implements a
6395 special comparison (__cmp__) which disallows comparing to
6407 special comparison (__cmp__) which disallows comparing to
6396 None. Found it when trying to use the PhysicalQuantity module from
6408 None. Found it when trying to use the PhysicalQuantity module from
6397 ScientificPython.
6409 ScientificPython.
6398
6410
6399 2001-11-05 Fernando Perez <fperez@colorado.edu>
6411 2001-11-05 Fernando Perez <fperez@colorado.edu>
6400
6412
6401 * Also added dirs. Now the pushd/popd/dirs family functions
6413 * Also added dirs. Now the pushd/popd/dirs family functions
6402 basically like the shell, with the added convenience of going home
6414 basically like the shell, with the added convenience of going home
6403 when called with no args.
6415 when called with no args.
6404
6416
6405 * pushd/popd slightly modified to mimic shell behavior more
6417 * pushd/popd slightly modified to mimic shell behavior more
6406 closely.
6418 closely.
6407
6419
6408 * Added env,pushd,popd from ShellServices as magic functions. I
6420 * Added env,pushd,popd from ShellServices as magic functions. I
6409 think the cleanest will be to port all desired functions from
6421 think the cleanest will be to port all desired functions from
6410 ShellServices as magics and remove ShellServices altogether. This
6422 ShellServices as magics and remove ShellServices altogether. This
6411 will provide a single, clean way of adding functionality
6423 will provide a single, clean way of adding functionality
6412 (shell-type or otherwise) to IP.
6424 (shell-type or otherwise) to IP.
6413
6425
6414 2001-11-04 Fernando Perez <fperez@colorado.edu>
6426 2001-11-04 Fernando Perez <fperez@colorado.edu>
6415
6427
6416 * Added .ipython/ directory to sys.path. This way users can keep
6428 * Added .ipython/ directory to sys.path. This way users can keep
6417 customizations there and access them via import.
6429 customizations there and access them via import.
6418
6430
6419 2001-11-03 Fernando Perez <fperez@colorado.edu>
6431 2001-11-03 Fernando Perez <fperez@colorado.edu>
6420
6432
6421 * Opened version 0.1.1 for new changes.
6433 * Opened version 0.1.1 for new changes.
6422
6434
6423 * Changed version number to 0.1.0: first 'public' release, sent to
6435 * Changed version number to 0.1.0: first 'public' release, sent to
6424 Nathan and Janko.
6436 Nathan and Janko.
6425
6437
6426 * Lots of small fixes and tweaks.
6438 * Lots of small fixes and tweaks.
6427
6439
6428 * Minor changes to whos format. Now strings are shown, snipped if
6440 * Minor changes to whos format. Now strings are shown, snipped if
6429 too long.
6441 too long.
6430
6442
6431 * Changed ShellServices to work on __main__ so they show up in @who
6443 * Changed ShellServices to work on __main__ so they show up in @who
6432
6444
6433 * Help also works with ? at the end of a line:
6445 * Help also works with ? at the end of a line:
6434 ?sin and sin?
6446 ?sin and sin?
6435 both produce the same effect. This is nice, as often I use the
6447 both produce the same effect. This is nice, as often I use the
6436 tab-complete to find the name of a method, but I used to then have
6448 tab-complete to find the name of a method, but I used to then have
6437 to go to the beginning of the line to put a ? if I wanted more
6449 to go to the beginning of the line to put a ? if I wanted more
6438 info. Now I can just add the ? and hit return. Convenient.
6450 info. Now I can just add the ? and hit return. Convenient.
6439
6451
6440 2001-11-02 Fernando Perez <fperez@colorado.edu>
6452 2001-11-02 Fernando Perez <fperez@colorado.edu>
6441
6453
6442 * Python version check (>=2.1) added.
6454 * Python version check (>=2.1) added.
6443
6455
6444 * Added LazyPython documentation. At this point the docs are quite
6456 * Added LazyPython documentation. At this point the docs are quite
6445 a mess. A cleanup is in order.
6457 a mess. A cleanup is in order.
6446
6458
6447 * Auto-installer created. For some bizarre reason, the zipfiles
6459 * Auto-installer created. For some bizarre reason, the zipfiles
6448 module isn't working on my system. So I made a tar version
6460 module isn't working on my system. So I made a tar version
6449 (hopefully the command line options in various systems won't kill
6461 (hopefully the command line options in various systems won't kill
6450 me).
6462 me).
6451
6463
6452 * Fixes to Struct in genutils. Now all dictionary-like methods are
6464 * Fixes to Struct in genutils. Now all dictionary-like methods are
6453 protected (reasonably).
6465 protected (reasonably).
6454
6466
6455 * Added pager function to genutils and changed ? to print usage
6467 * Added pager function to genutils and changed ? to print usage
6456 note through it (it was too long).
6468 note through it (it was too long).
6457
6469
6458 * Added the LazyPython functionality. Works great! I changed the
6470 * Added the LazyPython functionality. Works great! I changed the
6459 auto-quote escape to ';', it's on home row and next to '. But
6471 auto-quote escape to ';', it's on home row and next to '. But
6460 both auto-quote and auto-paren (still /) escapes are command-line
6472 both auto-quote and auto-paren (still /) escapes are command-line
6461 parameters.
6473 parameters.
6462
6474
6463
6475
6464 2001-11-01 Fernando Perez <fperez@colorado.edu>
6476 2001-11-01 Fernando Perez <fperez@colorado.edu>
6465
6477
6466 * Version changed to 0.0.7. Fairly large change: configuration now
6478 * Version changed to 0.0.7. Fairly large change: configuration now
6467 is all stored in a directory, by default .ipython. There, all
6479 is all stored in a directory, by default .ipython. There, all
6468 config files have normal looking names (not .names)
6480 config files have normal looking names (not .names)
6469
6481
6470 * Version 0.0.6 Released first to Lucas and Archie as a test
6482 * Version 0.0.6 Released first to Lucas and Archie as a test
6471 run. Since it's the first 'semi-public' release, change version to
6483 run. Since it's the first 'semi-public' release, change version to
6472 > 0.0.6 for any changes now.
6484 > 0.0.6 for any changes now.
6473
6485
6474 * Stuff I had put in the ipplib.py changelog:
6486 * Stuff I had put in the ipplib.py changelog:
6475
6487
6476 Changes to InteractiveShell:
6488 Changes to InteractiveShell:
6477
6489
6478 - Made the usage message a parameter.
6490 - Made the usage message a parameter.
6479
6491
6480 - Require the name of the shell variable to be given. It's a bit
6492 - Require the name of the shell variable to be given. It's a bit
6481 of a hack, but allows the name 'shell' not to be hardwired in the
6493 of a hack, but allows the name 'shell' not to be hardwired in the
6482 magic (@) handler, which is problematic b/c it requires
6494 magic (@) handler, which is problematic b/c it requires
6483 polluting the global namespace with 'shell'. This in turn is
6495 polluting the global namespace with 'shell'. This in turn is
6484 fragile: if a user redefines a variable called shell, things
6496 fragile: if a user redefines a variable called shell, things
6485 break.
6497 break.
6486
6498
6487 - magic @: all functions available through @ need to be defined
6499 - magic @: all functions available through @ need to be defined
6488 as magic_<name>, even though they can be called simply as
6500 as magic_<name>, even though they can be called simply as
6489 @<name>. This allows the special command @magic to gather
6501 @<name>. This allows the special command @magic to gather
6490 information automatically about all existing magic functions,
6502 information automatically about all existing magic functions,
6491 even if they are run-time user extensions, by parsing the shell
6503 even if they are run-time user extensions, by parsing the shell
6492 instance __dict__ looking for special magic_ names.
6504 instance __dict__ looking for special magic_ names.
6493
6505
6494 - mainloop: added *two* local namespace parameters. This allows
6506 - mainloop: added *two* local namespace parameters. This allows
6495 the class to differentiate between parameters which were there
6507 the class to differentiate between parameters which were there
6496 before and after command line initialization was processed. This
6508 before and after command line initialization was processed. This
6497 way, later @who can show things loaded at startup by the
6509 way, later @who can show things loaded at startup by the
6498 user. This trick was necessary to make session saving/reloading
6510 user. This trick was necessary to make session saving/reloading
6499 really work: ideally after saving/exiting/reloading a session,
6511 really work: ideally after saving/exiting/reloading a session,
6500 *everything* should look the same, including the output of @who. I
6512 *everything* should look the same, including the output of @who. I
6501 was only able to make this work with this double namespace
6513 was only able to make this work with this double namespace
6502 trick.
6514 trick.
6503
6515
6504 - added a header to the logfile which allows (almost) full
6516 - added a header to the logfile which allows (almost) full
6505 session restoring.
6517 session restoring.
6506
6518
6507 - prepend lines beginning with @ or !, with a and log
6519 - prepend lines beginning with @ or !, with a and log
6508 them. Why? !lines: may be useful to know what you did @lines:
6520 them. Why? !lines: may be useful to know what you did @lines:
6509 they may affect session state. So when restoring a session, at
6521 they may affect session state. So when restoring a session, at
6510 least inform the user of their presence. I couldn't quite get
6522 least inform the user of their presence. I couldn't quite get
6511 them to properly re-execute, but at least the user is warned.
6523 them to properly re-execute, but at least the user is warned.
6512
6524
6513 * Started ChangeLog.
6525 * Started ChangeLog.
@@ -1,10476 +1,10495 b''
1 #LyX 1.4.3 created this file. For more info see http://www.lyx.org/
1 #LyX 1.4.3 created this file. For more info see http://www.lyx.org/
2 \lyxformat 245
2 \lyxformat 245
3 \begin_document
3 \begin_document
4 \begin_header
4 \begin_header
5 \textclass article
5 \textclass article
6 \begin_preamble
6 \begin_preamble
7 %\usepackage{ae,aecompl}
7 %\usepackage{ae,aecompl}
8 \usepackage{color}
8 \usepackage{color}
9
9
10 % A few colors to replace the defaults for certain link types
10 % A few colors to replace the defaults for certain link types
11 \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
11 \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
12 \definecolor{darkorange}{rgb}{.71,0.21,0.01}
12 \definecolor{darkorange}{rgb}{.71,0.21,0.01}
13 \definecolor{darkred}{rgb}{.52,0.08,0.01}
13 \definecolor{darkred}{rgb}{.52,0.08,0.01}
14 \definecolor{darkgreen}{rgb}{.12,.54,.11}
14 \definecolor{darkgreen}{rgb}{.12,.54,.11}
15
15
16 % Use and configure listings package for nicely formatted code
16 % Use and configure listings package for nicely formatted code
17 \usepackage{listings}
17 \usepackage{listings}
18 \lstset{
18 \lstset{
19 language=Python,
19 language=Python,
20 basicstyle=\small\ttfamily,
20 basicstyle=\small\ttfamily,
21 commentstyle=\ttfamily\color{blue},
21 commentstyle=\ttfamily\color{blue},
22 stringstyle=\ttfamily\color{darkorange},
22 stringstyle=\ttfamily\color{darkorange},
23 showstringspaces=false,
23 showstringspaces=false,
24 breaklines=true,
24 breaklines=true,
25 postbreak = \space\dots
25 postbreak = \space\dots
26 }
26 }
27
27
28 \usepackage[%pdftex, % needed for pdflatex
28 \usepackage[%pdftex, % needed for pdflatex
29 breaklinks=true, % so long urls are correctly broken across lines
29 breaklinks=true, % so long urls are correctly broken across lines
30 colorlinks=true,
30 colorlinks=true,
31 urlcolor=blue,
31 urlcolor=blue,
32 linkcolor=darkred,
32 linkcolor=darkred,
33 citecolor=darkgreen,
33 citecolor=darkgreen,
34 ]{hyperref}
34 ]{hyperref}
35
35
36 \usepackage{html}
36 \usepackage{html}
37
37
38 % This helps prevent overly long lines that stretch beyond the margins
38 % This helps prevent overly long lines that stretch beyond the margins
39 \sloppy
39 \sloppy
40
40
41 % Define a \codelist command which either uses listings for latex, or
41 % Define a \codelist command which either uses listings for latex, or
42 % plain verbatim for html (since latex2html doesn't understand the
42 % plain verbatim for html (since latex2html doesn't understand the
43 % listings package).
43 % listings package).
44 \usepackage{verbatim}
44 \usepackage{verbatim}
45 \newcommand{\codelist}[1] {
45 \newcommand{\codelist}[1] {
46 \latex{\lstinputlisting{#1}}
46 \latex{\lstinputlisting{#1}}
47 \html{\verbatiminput{#1}}
47 \html{\verbatiminput{#1}}
48 }
48 }
49 \end_preamble
49 \end_preamble
50 \language english
50 \language english
51 \inputencoding latin1
51 \inputencoding latin1
52 \fontscheme palatino
52 \fontscheme palatino
53 \graphics default
53 \graphics default
54 \paperfontsize 11
54 \paperfontsize 11
55 \spacing single
55 \spacing single
56 \papersize default
56 \papersize default
57 \use_geometry true
57 \use_geometry true
58 \use_amsmath 1
58 \use_amsmath 1
59 \cite_engine basic
59 \cite_engine basic
60 \use_bibtopic false
60 \use_bibtopic false
61 \paperorientation portrait
61 \paperorientation portrait
62 \leftmargin 1in
62 \leftmargin 1in
63 \topmargin 1in
63 \topmargin 1in
64 \rightmargin 1in
64 \rightmargin 1in
65 \bottommargin 1in
65 \bottommargin 1in
66 \secnumdepth 3
66 \secnumdepth 3
67 \tocdepth 3
67 \tocdepth 3
68 \paragraph_separation skip
68 \paragraph_separation skip
69 \defskip medskip
69 \defskip medskip
70 \quotes_language english
70 \quotes_language english
71 \papercolumns 1
71 \papercolumns 1
72 \papersides 2
72 \papersides 2
73 \paperpagestyle fancy
73 \paperpagestyle fancy
74 \tracking_changes false
74 \tracking_changes false
75 \output_changes true
75 \output_changes true
76 \end_header
76 \end_header
77
77
78 \begin_body
78 \begin_body
79
79
80 \begin_layout Title
80 \begin_layout Title
81 IPython
81 IPython
82 \newline
82 \newline
83
83
84 \size larger
84 \size larger
85 An enhanced Interactive Python
85 An enhanced Interactive Python
86 \size large
86 \size large
87
87
88 \newline
88 \newline
89 User Manual, v.
89 User Manual, v.
90 __version__
90 __version__
91 \end_layout
91 \end_layout
92
92
93 \begin_layout Author
93 \begin_layout Author
94 Fernando PοΏ½rez
94 Fernando PοΏ½rez
95 \begin_inset Foot
95 \begin_inset Foot
96 status collapsed
96 status collapsed
97
97
98 \begin_layout Standard
98 \begin_layout Standard
99
99
100 \size scriptsize
100 \size scriptsize
101 Department of Applied Mathematics, University of Colorado at Boulder.
101 Department of Applied Mathematics, University of Colorado at Boulder.
102
102
103 \family typewriter
103 \family typewriter
104 <Fernando.Perez@colorado.edu>
104 <Fernando.Perez@colorado.edu>
105 \end_layout
105 \end_layout
106
106
107 \end_inset
107 \end_inset
108
108
109
109
110 \end_layout
110 \end_layout
111
111
112 \begin_layout Standard
112 \begin_layout Standard
113 \begin_inset ERT
113 \begin_inset ERT
114 status collapsed
114 status collapsed
115
115
116 \begin_layout Standard
116 \begin_layout Standard
117
117
118
118
119 \backslash
119 \backslash
120 latex{
120 latex{
121 \end_layout
121 \end_layout
122
122
123 \end_inset
123 \end_inset
124
124
125
125
126 \begin_inset LatexCommand \tableofcontents{}
126 \begin_inset LatexCommand \tableofcontents{}
127
127
128 \end_inset
128 \end_inset
129
129
130
130
131 \begin_inset ERT
131 \begin_inset ERT
132 status collapsed
132 status collapsed
133
133
134 \begin_layout Standard
134 \begin_layout Standard
135
135
136 }
136 }
137 \end_layout
137 \end_layout
138
138
139 \end_inset
139 \end_inset
140
140
141
141
142 \end_layout
142 \end_layout
143
143
144 \begin_layout Standard
144 \begin_layout Standard
145 \begin_inset ERT
145 \begin_inset ERT
146 status open
146 status open
147
147
148 \begin_layout Standard
148 \begin_layout Standard
149
149
150
150
151 \backslash
151 \backslash
152 html{
152 html{
153 \backslash
153 \backslash
154 bodytext{bgcolor=#ffffff}}
154 bodytext{bgcolor=#ffffff}}
155 \end_layout
155 \end_layout
156
156
157 \end_inset
157 \end_inset
158
158
159
159
160 \end_layout
160 \end_layout
161
161
162 \begin_layout Standard
162 \begin_layout Standard
163
163
164 \newpage
164 \newpage
165
165
166 \end_layout
166 \end_layout
167
167
168 \begin_layout Section
168 \begin_layout Section
169 Overview
169 Overview
170 \end_layout
170 \end_layout
171
171
172 \begin_layout Standard
172 \begin_layout Standard
173 One of Python's most useful features is its interactive interpreter.
173 One of Python's most useful features is its interactive interpreter.
174 This system allows very fast testing of ideas without the overhead of creating
174 This system allows very fast testing of ideas without the overhead of creating
175 test files as is typical in most programming languages.
175 test files as is typical in most programming languages.
176 However, the interpreter supplied with the standard Python distribution
176 However, the interpreter supplied with the standard Python distribution
177 is somewhat limited for extended interactive use.
177 is somewhat limited for extended interactive use.
178 \end_layout
178 \end_layout
179
179
180 \begin_layout Standard
180 \begin_layout Standard
181 IPython is a free software project (released under the BSD license) which
181 IPython is a free software project (released under the BSD license) which
182 tries to:
182 tries to:
183 \end_layout
183 \end_layout
184
184
185 \begin_layout Enumerate
185 \begin_layout Enumerate
186 Provide an interactive shell superior to Python's default.
186 Provide an interactive shell superior to Python's default.
187 IPython has many features for object introspection, system shell access,
187 IPython has many features for object introspection, system shell access,
188 and its own special command system for adding functionality when working
188 and its own special command system for adding functionality when working
189 interactively.
189 interactively.
190 It tries to be a very efficient environment both for Python code development
190 It tries to be a very efficient environment both for Python code development
191 and for exploration of problems using Python objects (in situations like
191 and for exploration of problems using Python objects (in situations like
192 data analysis).
192 data analysis).
193 \end_layout
193 \end_layout
194
194
195 \begin_layout Enumerate
195 \begin_layout Enumerate
196 Serve as an embeddable, ready to use interpreter for your own programs.
196 Serve as an embeddable, ready to use interpreter for your own programs.
197 IPython can be started with a single call from inside another program,
197 IPython can be started with a single call from inside another program,
198 providing access to the current namespace.
198 providing access to the current namespace.
199 This can be very useful both for debugging purposes and for situations
199 This can be very useful both for debugging purposes and for situations
200 where a blend of batch-processing and interactive exploration are needed.
200 where a blend of batch-processing and interactive exploration are needed.
201 \end_layout
201 \end_layout
202
202
203 \begin_layout Enumerate
203 \begin_layout Enumerate
204 Offer a flexible framework which can be used as the base environment for
204 Offer a flexible framework which can be used as the base environment for
205 other systems with Python as the underlying language.
205 other systems with Python as the underlying language.
206 Specifically scientific environments like Mathematica, IDL and Matlab inspired
206 Specifically scientific environments like Mathematica, IDL and Matlab inspired
207 its design, but similar ideas can be useful in many fields.
207 its design, but similar ideas can be useful in many fields.
208 \end_layout
208 \end_layout
209
209
210 \begin_layout Enumerate
210 \begin_layout Enumerate
211 Allow interactive testing of threaded graphical toolkits.
211 Allow interactive testing of threaded graphical toolkits.
212 IPython has support for interactive, non-blocking control of GTK, Qt and
212 IPython has support for interactive, non-blocking control of GTK, Qt and
213 WX applications via special threading flags.
213 WX applications via special threading flags.
214 The normal Python shell can only do this for Tkinter applications.
214 The normal Python shell can only do this for Tkinter applications.
215 \end_layout
215 \end_layout
216
216
217 \begin_layout Subsection
217 \begin_layout Subsection
218 Main features
218 Main features
219 \end_layout
219 \end_layout
220
220
221 \begin_layout Itemize
221 \begin_layout Itemize
222 Dynamic object introspection.
222 Dynamic object introspection.
223 One can access docstrings, function definition prototypes, source code,
223 One can access docstrings, function definition prototypes, source code,
224 source files and other details of any object accessible to the interpreter
224 source files and other details of any object accessible to the interpreter
225 with a single keystroke (`
225 with a single keystroke (`
226 \family typewriter
226 \family typewriter
227 ?
227 ?
228 \family default
228 \family default
229 ', and using `
229 ', and using `
230 \family typewriter
230 \family typewriter
231 ??
231 ??
232 \family default
232 \family default
233 ' provides additional detail).
233 ' provides additional detail).
234 \end_layout
234 \end_layout
235
235
236 \begin_layout Itemize
236 \begin_layout Itemize
237 Searching through modules and namespaces with `
237 Searching through modules and namespaces with `
238 \family typewriter
238 \family typewriter
239 *
239 *
240 \family default
240 \family default
241 ' wildcards, both when using the `
241 ' wildcards, both when using the `
242 \family typewriter
242 \family typewriter
243 ?
243 ?
244 \family default
244 \family default
245 ' system and via the
245 ' system and via the
246 \family typewriter
246 \family typewriter
247 %psearch
247 %psearch
248 \family default
248 \family default
249 command.
249 command.
250 \end_layout
250 \end_layout
251
251
252 \begin_layout Itemize
252 \begin_layout Itemize
253 Completion in the local namespace, by typing TAB at the prompt.
253 Completion in the local namespace, by typing TAB at the prompt.
254 This works for keywords, methods, variables and files in the current directory.
254 This works for keywords, methods, variables and files in the current directory.
255 This is supported via the readline library, and full access to configuring
255 This is supported via the readline library, and full access to configuring
256 readline's behavior is provided.
256 readline's behavior is provided.
257 \end_layout
257 \end_layout
258
258
259 \begin_layout Itemize
259 \begin_layout Itemize
260 Numbered input/output prompts with command history (persistent across sessions
260 Numbered input/output prompts with command history (persistent across sessions
261 and tied to each profile), full searching in this history and caching of
261 and tied to each profile), full searching in this history and caching of
262 all input and output.
262 all input and output.
263 \end_layout
263 \end_layout
264
264
265 \begin_layout Itemize
265 \begin_layout Itemize
266 User-extensible `magic' commands.
266 User-extensible `magic' commands.
267 A set of commands prefixed with
267 A set of commands prefixed with
268 \family typewriter
268 \family typewriter
269 %
269 %
270 \family default
270 \family default
271 is available for controlling IPython itself and provides directory control,
271 is available for controlling IPython itself and provides directory control,
272 namespace information and many aliases to common system shell commands.
272 namespace information and many aliases to common system shell commands.
273 \end_layout
273 \end_layout
274
274
275 \begin_layout Itemize
275 \begin_layout Itemize
276 Alias facility for defining your own system aliases.
276 Alias facility for defining your own system aliases.
277 \end_layout
277 \end_layout
278
278
279 \begin_layout Itemize
279 \begin_layout Itemize
280 Complete system shell access.
280 Complete system shell access.
281 Lines starting with ! are passed directly to the system shell, and using
281 Lines starting with ! are passed directly to the system shell, and using
282 !! captures shell output into python variables for further use.
282 !! captures shell output into python variables for further use.
283 \end_layout
283 \end_layout
284
284
285 \begin_layout Itemize
285 \begin_layout Itemize
286 Background execution of Python commands in a separate thread.
286 Background execution of Python commands in a separate thread.
287 IPython has an internal job manager called
287 IPython has an internal job manager called
288 \family typewriter
288 \family typewriter
289 jobs
289 jobs
290 \family default
290 \family default
291 , and a conveninence backgrounding magic function called
291 , and a conveninence backgrounding magic function called
292 \family typewriter
292 \family typewriter
293 %bg
293 %bg
294 \family default
294 \family default
295 .
295 .
296 \end_layout
296 \end_layout
297
297
298 \begin_layout Itemize
298 \begin_layout Itemize
299 The ability to expand python variables when calling the system shell.
299 The ability to expand python variables when calling the system shell.
300 In a shell command, any python variable prefixed with
300 In a shell command, any python variable prefixed with
301 \family typewriter
301 \family typewriter
302 $
302 $
303 \family default
303 \family default
304 is expanded.
304 is expanded.
305 A double
305 A double
306 \family typewriter
306 \family typewriter
307 $$
307 $$
308 \family default
308 \family default
309 allows passing a literal
309 allows passing a literal
310 \family typewriter
310 \family typewriter
311 $
311 $
312 \family default
312 \family default
313 to the shell (for access to shell and environment variables like
313 to the shell (for access to shell and environment variables like
314 \family typewriter
314 \family typewriter
315 $PATH
315 $PATH
316 \family default
316 \family default
317 ).
317 ).
318 \end_layout
318 \end_layout
319
319
320 \begin_layout Itemize
320 \begin_layout Itemize
321 Filesystem navigation, via a magic
321 Filesystem navigation, via a magic
322 \family typewriter
322 \family typewriter
323 %cd
323 %cd
324 \family default
324 \family default
325 command, along with a persistent bookmark system (using
325 command, along with a persistent bookmark system (using
326 \family typewriter
326 \family typewriter
327 %bookmark
327 %bookmark
328 \family default
328 \family default
329 ) for fast access to frequently visited directories.
329 ) for fast access to frequently visited directories.
330 \end_layout
330 \end_layout
331
331
332 \begin_layout Itemize
332 \begin_layout Itemize
333 A lightweight persistence framework via the
333 A lightweight persistence framework via the
334 \family typewriter
334 \family typewriter
335 %store
335 %store
336 \family default
336 \family default
337 command, which allows you to save arbitrary Python variables.
337 command, which allows you to save arbitrary Python variables.
338 These get restored automatically when your session restarts.
338 These get restored automatically when your session restarts.
339 \end_layout
339 \end_layout
340
340
341 \begin_layout Itemize
341 \begin_layout Itemize
342 Automatic indentation (optional) of code as you type (through the readline
342 Automatic indentation (optional) of code as you type (through the readline
343 library).
343 library).
344 \end_layout
344 \end_layout
345
345
346 \begin_layout Itemize
346 \begin_layout Itemize
347 Macro system for quickly re-executing multiple lines of previous input with
347 Macro system for quickly re-executing multiple lines of previous input with
348 a single name.
348 a single name.
349 Macros can be stored persistently via
349 Macros can be stored persistently via
350 \family typewriter
350 \family typewriter
351 %store
351 %store
352 \family default
352 \family default
353 and edited via
353 and edited via
354 \family typewriter
354 \family typewriter
355 %edit
355 %edit
356 \family default
356 \family default
357 .
357 .
358
358
359 \end_layout
359 \end_layout
360
360
361 \begin_layout Itemize
361 \begin_layout Itemize
362 Session logging (you can then later use these logs as code in your programs).
362 Session logging (you can then later use these logs as code in your programs).
363 Logs can optionally timestamp all input, and also store session output
363 Logs can optionally timestamp all input, and also store session output
364 (marked as comments, so the log remains valid Python source code).
364 (marked as comments, so the log remains valid Python source code).
365 \end_layout
365 \end_layout
366
366
367 \begin_layout Itemize
367 \begin_layout Itemize
368 Session restoring: logs can be replayed to restore a previous session to
368 Session restoring: logs can be replayed to restore a previous session to
369 the state where you left it.
369 the state where you left it.
370 \end_layout
370 \end_layout
371
371
372 \begin_layout Itemize
372 \begin_layout Itemize
373 Verbose and colored exception traceback printouts.
373 Verbose and colored exception traceback printouts.
374 Easier to parse visually, and in verbose mode they produce a lot of useful
374 Easier to parse visually, and in verbose mode they produce a lot of useful
375 debugging information (basically a terminal version of the cgitb module).
375 debugging information (basically a terminal version of the cgitb module).
376 \end_layout
376 \end_layout
377
377
378 \begin_layout Itemize
378 \begin_layout Itemize
379 Auto-parentheses: callable objects can be executed without parentheses:
379 Auto-parentheses: callable objects can be executed without parentheses:
380
380
381 \family typewriter
381 \family typewriter
382 `sin 3'
382 `sin 3'
383 \family default
383 \family default
384 is automatically converted to
384 is automatically converted to
385 \family typewriter
385 \family typewriter
386 `sin(3)
386 `sin(3)
387 \family default
387 \family default
388 '.
388 '.
389 \end_layout
389 \end_layout
390
390
391 \begin_layout Itemize
391 \begin_layout Itemize
392 Auto-quoting: using `
392 Auto-quoting: using `
393 \family typewriter
393 \family typewriter
394 ,
394 ,
395 \family default
395 \family default
396 ' or `
396 ' or `
397 \family typewriter
397 \family typewriter
398 ;
398 ;
399 \family default
399 \family default
400 ' as the first character forces auto-quoting of the rest of the line:
400 ' as the first character forces auto-quoting of the rest of the line:
401 \family typewriter
401 \family typewriter
402 `,my_function a\InsetSpace ~
402 `,my_function a\InsetSpace ~
403 b'
403 b'
404 \family default
404 \family default
405 becomes automatically
405 becomes automatically
406 \family typewriter
406 \family typewriter
407 `my_function("a","b")'
407 `my_function("a","b")'
408 \family default
408 \family default
409 , while
409 , while
410 \family typewriter
410 \family typewriter
411 `;my_function a\InsetSpace ~
411 `;my_function a\InsetSpace ~
412 b'
412 b'
413 \family default
413 \family default
414 becomes
414 becomes
415 \family typewriter
415 \family typewriter
416 `my_function("a b")'
416 `my_function("a b")'
417 \family default
417 \family default
418 .
418 .
419 \end_layout
419 \end_layout
420
420
421 \begin_layout Itemize
421 \begin_layout Itemize
422 Extensible input syntax.
422 Extensible input syntax.
423 You can define filters that pre-process user input to simplify input in
423 You can define filters that pre-process user input to simplify input in
424 special situations.
424 special situations.
425 This allows for example pasting multi-line code fragments which start with
425 This allows for example pasting multi-line code fragments which start with
426
426
427 \family typewriter
427 \family typewriter
428 `>>>'
428 `>>>'
429 \family default
429 \family default
430 or
430 or
431 \family typewriter
431 \family typewriter
432 `...'
432 `...'
433 \family default
433 \family default
434 such as those from other python sessions or the standard Python documentation.
434 such as those from other python sessions or the standard Python documentation.
435 \end_layout
435 \end_layout
436
436
437 \begin_layout Itemize
437 \begin_layout Itemize
438 Flexible configuration system.
438 Flexible configuration system.
439 It uses a configuration file which allows permanent setting of all command-line
439 It uses a configuration file which allows permanent setting of all command-line
440 options, module loading, code and file execution.
440 options, module loading, code and file execution.
441 The system allows recursive file inclusion, so you can have a base file
441 The system allows recursive file inclusion, so you can have a base file
442 with defaults and layers which load other customizations for particular
442 with defaults and layers which load other customizations for particular
443 projects.
443 projects.
444 \end_layout
444 \end_layout
445
445
446 \begin_layout Itemize
446 \begin_layout Itemize
447 Embeddable.
447 Embeddable.
448 You can call IPython as a python shell inside your own python programs.
448 You can call IPython as a python shell inside your own python programs.
449 This can be used both for debugging code or for providing interactive abilities
449 This can be used both for debugging code or for providing interactive abilities
450 to your programs with knowledge about the local namespaces (very useful
450 to your programs with knowledge about the local namespaces (very useful
451 in debugging and data analysis situations).
451 in debugging and data analysis situations).
452 \end_layout
452 \end_layout
453
453
454 \begin_layout Itemize
454 \begin_layout Itemize
455 Easy debugger access.
455 Easy debugger access.
456 You can set IPython to call up an enhanced version of the Python debugger
456 You can set IPython to call up an enhanced version of the Python debugger
457 (
457 (
458 \family typewriter
458 \family typewriter
459 pdb
459 pdb
460 \family default
460 \family default
461 ) every time there is an uncaught exception.
461 ) every time there is an uncaught exception.
462 This drops you inside the code which triggered the exception with all the
462 This drops you inside the code which triggered the exception with all the
463 data live and it is possible to navigate the stack to rapidly isolate the
463 data live and it is possible to navigate the stack to rapidly isolate the
464 source of a bug.
464 source of a bug.
465 The
465 The
466 \family typewriter
466 \family typewriter
467 %run
467 %run
468 \family default
468 \family default
469 magic command --with the
469 magic command --with the
470 \family typewriter
470 \family typewriter
471 -d
471 -d
472 \family default
472 \family default
473 option-- can run any script under
473 option-- can run any script under
474 \family typewriter
474 \family typewriter
475 pdb
475 pdb
476 \family default
476 \family default
477 's control, automatically setting initial breakpoints for you.
477 's control, automatically setting initial breakpoints for you.
478 This version of
478 This version of
479 \family typewriter
479 \family typewriter
480 pdb
480 pdb
481 \family default
481 \family default
482 has IPython-specific improvements, including tab-completion and traceback
482 has IPython-specific improvements, including tab-completion and traceback
483 coloring support.
483 coloring support.
484 \end_layout
484 \end_layout
485
485
486 \begin_layout Itemize
486 \begin_layout Itemize
487 Profiler support.
487 Profiler support.
488 You can run single statements (similar to
488 You can run single statements (similar to
489 \family typewriter
489 \family typewriter
490 profile.run()
490 profile.run()
491 \family default
491 \family default
492 ) or complete programs under the profiler's control.
492 ) or complete programs under the profiler's control.
493 While this is possible with standard
493 While this is possible with standard
494 \family typewriter
494 \family typewriter
495 cProfile
495 cProfile
496 \family default
496 \family default
497 or
497 or
498 \family typewriter
498 \family typewriter
499 profile
499 profile
500 \family default
500 \family default
501 modules, IPython wraps this functionality with magic commands (see
501 modules, IPython wraps this functionality with magic commands (see
502 \family typewriter
502 \family typewriter
503 `%prun'
503 `%prun'
504 \family default
504 \family default
505 and
505 and
506 \family typewriter
506 \family typewriter
507 `%run -p
507 `%run -p
508 \family default
508 \family default
509 ') convenient for rapid interactive work.
509 ') convenient for rapid interactive work.
510 \end_layout
510 \end_layout
511
511
512 \begin_layout Subsection
512 \begin_layout Subsection
513 Portability and Python requirements
513 Portability and Python requirements
514 \end_layout
514 \end_layout
515
515
516 \begin_layout Standard
516 \begin_layout Standard
517
517
518 \series bold
518 \series bold
519 Python requirements:
519 Python requirements:
520 \series default
520 \series default
521 IPython requires with Python version 2.3 or newer.
521 IPython requires with Python version 2.3 or newer.
522 If you are still using Python 2.2 and can not upgrade, the last version
522 If you are still using Python 2.2 and can not upgrade, the last version
523 of IPython which worked with Python 2.2 was 0.6.15, so you will have to use
523 of IPython which worked with Python 2.2 was 0.6.15, so you will have to use
524 that.
524 that.
525 \end_layout
525 \end_layout
526
526
527 \begin_layout Standard
527 \begin_layout Standard
528 IPython is developed under
528 IPython is developed under
529 \series bold
529 \series bold
530 Linux
530 Linux
531 \series default
531 \series default
532 , but it should work in any reasonable Unix-type system (tested OK under
532 , but it should work in any reasonable Unix-type system (tested OK under
533 Solaris and the *BSD family, for which a port exists thanks to Dryice Liu).
533 Solaris and the *BSD family, for which a port exists thanks to Dryice Liu).
534 \end_layout
534 \end_layout
535
535
536 \begin_layout Standard
536 \begin_layout Standard
537
537
538 \series bold
538 \series bold
539 Mac OS X
539 Mac OS X
540 \series default
540 \series default
541 : it works, apparently without any problems (thanks to Jim Boyle at Lawrence
541 : it works, apparently without any problems (thanks to Jim Boyle at Lawrence
542 Livermore for the information).
542 Livermore for the information).
543 Thanks to Andrea Riciputi, Fink support is available.
543 Thanks to Andrea Riciputi, Fink support is available.
544 \end_layout
544 \end_layout
545
545
546 \begin_layout Standard
546 \begin_layout Standard
547
547
548 \series bold
548 \series bold
549 CygWin
549 CygWin
550 \series default
550 \series default
551 : it works mostly OK, though some users have reported problems with prompt
551 : it works mostly OK, though some users have reported problems with prompt
552 coloring.
552 coloring.
553 No satisfactory solution to this has been found so far, you may want to
553 No satisfactory solution to this has been found so far, you may want to
554 disable colors permanently in the
554 disable colors permanently in the
555 \family typewriter
555 \family typewriter
556 ipythonrc
556 ipythonrc
557 \family default
557 \family default
558 configuration file if you experience problems.
558 configuration file if you experience problems.
559 If you have proper color support under cygwin, please post to the IPython
559 If you have proper color support under cygwin, please post to the IPython
560 mailing list so this issue can be resolved for all users.
560 mailing list so this issue can be resolved for all users.
561 \end_layout
561 \end_layout
562
562
563 \begin_layout Standard
563 \begin_layout Standard
564
564
565 \series bold
565 \series bold
566 Windows
566 Windows
567 \series default
567 \series default
568 : it works well under Windows XP/2k, and I suspect NT should behave similarly.
568 : it works well under Windows XP/2k, and I suspect NT should behave similarly.
569 Section\InsetSpace ~
569 Section\InsetSpace ~
570
570
571 \begin_inset LatexCommand \ref{sub:Under-Windows}
571 \begin_inset LatexCommand \ref{sub:Under-Windows}
572
572
573 \end_inset
573 \end_inset
574
574
575 describes installation details for Windows, including some additional tools
575 describes installation details for Windows, including some additional tools
576 needed on this platform.
576 needed on this platform.
577 \end_layout
577 \end_layout
578
578
579 \begin_layout Standard
579 \begin_layout Standard
580 Windows 9x support is present, and has been reported to work fine (at least
580 Windows 9x support is present, and has been reported to work fine (at least
581 on WinME).
581 on WinME).
582 \end_layout
582 \end_layout
583
583
584 \begin_layout Standard
584 \begin_layout Standard
585 Note, that I have very little access to and experience with Windows development.
585 Note, that I have very little access to and experience with Windows development.
586 However, an excellent group of Win32 users (led by Ville Vainio), consistently
586 However, an excellent group of Win32 users (led by Ville Vainio), consistently
587 contribute bugfixes and platform-specific enhancements, so they more than
587 contribute bugfixes and platform-specific enhancements, so they more than
588 make up for my deficiencies on that front.
588 make up for my deficiencies on that front.
589 In fact, Win32 users report using IPython as a system shell (see Sec.\InsetSpace ~
589 In fact, Win32 users report using IPython as a system shell (see Sec.\InsetSpace ~
590
590
591 \begin_inset LatexCommand \ref{sec:IPython-as-shell}
591 \begin_inset LatexCommand \ref{sec:IPython-as-shell}
592
592
593 \end_inset
593 \end_inset
594
594
595 for details), as it offers a level of control and features which the default
595 for details), as it offers a level of control and features which the default
596
596
597 \family typewriter
597 \family typewriter
598 cmd.exe
598 cmd.exe
599 \family default
599 \family default
600 doesn't provide.
600 doesn't provide.
601 \end_layout
601 \end_layout
602
602
603 \begin_layout Subsection
603 \begin_layout Subsection
604 Location
604 Location
605 \end_layout
605 \end_layout
606
606
607 \begin_layout Standard
607 \begin_layout Standard
608 IPython is generously hosted at
608 IPython is generously hosted at
609 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
609 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
610
610
611 \end_inset
611 \end_inset
612
612
613 by the Enthought, Inc and the SciPy project.
613 by the Enthought, Inc and the SciPy project.
614 This site offers downloads, subversion access, mailing lists and a bug
614 This site offers downloads, subversion access, mailing lists and a bug
615 tracking system.
615 tracking system.
616 I am very grateful to Enthought (
616 I am very grateful to Enthought (
617 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
617 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
618
618
619 \end_inset
619 \end_inset
620
620
621 ) and all of the SciPy team for their contribution.
621 ) and all of the SciPy team for their contribution.
622 \end_layout
622 \end_layout
623
623
624 \begin_layout Section
624 \begin_layout Section
625 \begin_inset LatexCommand \label{sec:install}
625 \begin_inset LatexCommand \label{sec:install}
626
626
627 \end_inset
627 \end_inset
628
628
629 Installation
629 Installation
630 \end_layout
630 \end_layout
631
631
632 \begin_layout Subsection
632 \begin_layout Subsection
633 Instant instructions
633 Instant instructions
634 \end_layout
634 \end_layout
635
635
636 \begin_layout Standard
636 \begin_layout Standard
637 If you are of the impatient kind, under Linux/Unix simply untar/unzip the
637 If you are of the impatient kind, under Linux/Unix simply untar/unzip the
638 download, then install with
638 download, then install with
639 \family typewriter
639 \family typewriter
640 `python setup.py install'
640 `python setup.py install'
641 \family default
641 \family default
642 .
642 .
643 Under Windows, double-click on the provided
643 Under Windows, double-click on the provided
644 \family typewriter
644 \family typewriter
645 .exe
645 .exe
646 \family default
646 \family default
647 binary installer.
647 binary installer.
648 \end_layout
648 \end_layout
649
649
650 \begin_layout Standard
650 \begin_layout Standard
651 Then, take a look at Sections
651 Then, take a look at Sections
652 \begin_inset LatexCommand \ref{sec:good_config}
652 \begin_inset LatexCommand \ref{sec:good_config}
653
653
654 \end_inset
654 \end_inset
655
655
656 for configuring things optimally and
656 for configuring things optimally and
657 \begin_inset LatexCommand \ref{sec:quick_tips}
657 \begin_inset LatexCommand \ref{sec:quick_tips}
658
658
659 \end_inset
659 \end_inset
660
660
661 for quick tips on efficient use of IPython.
661 for quick tips on efficient use of IPython.
662 You can later refer to the rest of the manual for all the gory details.
662 You can later refer to the rest of the manual for all the gory details.
663 \end_layout
663 \end_layout
664
664
665 \begin_layout Standard
665 \begin_layout Standard
666 See the notes in sec.
666 See the notes in sec.
667
667
668 \begin_inset LatexCommand \ref{sec:upgrade}
668 \begin_inset LatexCommand \ref{sec:upgrade}
669
669
670 \end_inset
670 \end_inset
671
671
672 for upgrading IPython versions.
672 for upgrading IPython versions.
673 \end_layout
673 \end_layout
674
674
675 \begin_layout Subsection
675 \begin_layout Subsection
676 Detailed Unix instructions (Linux, Mac OS X, etc.)
676 Detailed Unix instructions (Linux, Mac OS X, etc.)
677 \end_layout
677 \end_layout
678
678
679 \begin_layout Standard
679 \begin_layout Standard
680 For RPM based systems, simply install the supplied package in the usual
680 For RPM based systems, simply install the supplied package in the usual
681 manner.
681 manner.
682 If you download the tar archive, the process is:
682 If you download the tar archive, the process is:
683 \end_layout
683 \end_layout
684
684
685 \begin_layout Enumerate
685 \begin_layout Enumerate
686 Unzip/untar the
686 Unzip/untar the
687 \family typewriter
687 \family typewriter
688 ipython-XXX.tar.gz
688 ipython-XXX.tar.gz
689 \family default
689 \family default
690 file wherever you want (
690 file wherever you want (
691 \family typewriter
691 \family typewriter
692 XXX
692 XXX
693 \family default
693 \family default
694 is the version number).
694 is the version number).
695 It will make a directory called
695 It will make a directory called
696 \family typewriter
696 \family typewriter
697 ipython-XXX.
697 ipython-XXX.
698
698
699 \family default
699 \family default
700 Change into that directory where you will find the files
700 Change into that directory where you will find the files
701 \family typewriter
701 \family typewriter
702 README
702 README
703 \family default
703 \family default
704 and
704 and
705 \family typewriter
705 \family typewriter
706 setup.py
706 setup.py
707 \family default
707 \family default
708 .
708 .
709
709
710 \family typewriter
710 \family typewriter
711 O
711 O
712 \family default
712 \family default
713 nce you've completed the installation, you can safely remove this directory.
713 nce you've completed the installation, you can safely remove this directory.
714
714
715 \end_layout
715 \end_layout
716
716
717 \begin_layout Enumerate
717 \begin_layout Enumerate
718 If you are installing over a previous installation of version 0.2.0 or earlier,
718 If you are installing over a previous installation of version 0.2.0 or earlier,
719 first remove your
719 first remove your
720 \family typewriter
720 \family typewriter
721 $HOME/.ipython
721 $HOME/.ipython
722 \family default
722 \family default
723 directory, since the configuration file format has changed somewhat (the
723 directory, since the configuration file format has changed somewhat (the
724 '=' were removed from all option specifications).
724 '=' were removed from all option specifications).
725 Or you can call ipython with the
725 Or you can call ipython with the
726 \family typewriter
726 \family typewriter
727 -upgrade
727 -upgrade
728 \family default
728 \family default
729 option and it will do this automatically for you.
729 option and it will do this automatically for you.
730 \end_layout
730 \end_layout
731
731
732 \begin_layout Enumerate
732 \begin_layout Enumerate
733 IPython uses distutils, so you can install it by simply typing at the system
733 IPython uses distutils, so you can install it by simply typing at the system
734 prompt (don't type the
734 prompt (don't type the
735 \family typewriter
735 \family typewriter
736 $
736 $
737 \family default
737 \family default
738 )
738 )
739 \newline
739 \newline
740
740
741 \family typewriter
741 \family typewriter
742 $ python setup.py install
742 $ python setup.py install
743 \family default
743 \family default
744
744
745 \newline
745 \newline
746 Note that this assumes you have root access to your machine.
746 Note that this assumes you have root access to your machine.
747 If you don't have root access or don't want IPython to go in the default
747 If you don't have root access or don't want IPython to go in the default
748 python directories, you'll need to use the
748 python directories, you'll need to use the
749 \begin_inset ERT
749 \begin_inset ERT
750 status collapsed
750 status collapsed
751
751
752 \begin_layout Standard
752 \begin_layout Standard
753
753
754
754
755 \backslash
755 \backslash
756 verb|--home|
756 verb|--home|
757 \end_layout
757 \end_layout
758
758
759 \end_inset
759 \end_inset
760
760
761 option (or
761 option (or
762 \begin_inset ERT
762 \begin_inset ERT
763 status collapsed
763 status collapsed
764
764
765 \begin_layout Standard
765 \begin_layout Standard
766
766
767
767
768 \backslash
768 \backslash
769 verb|--prefix|
769 verb|--prefix|
770 \end_layout
770 \end_layout
771
771
772 \end_inset
772 \end_inset
773
773
774 ).
774 ).
775 For example:
775 For example:
776 \newline
776 \newline
777
777
778 \begin_inset ERT
778 \begin_inset ERT
779 status collapsed
779 status collapsed
780
780
781 \begin_layout Standard
781 \begin_layout Standard
782
782
783
783
784 \backslash
784 \backslash
785 verb|$ python setup.py install --home $HOME/local|
785 verb|$ python setup.py install --home $HOME/local|
786 \end_layout
786 \end_layout
787
787
788 \end_inset
788 \end_inset
789
789
790
790
791 \newline
791 \newline
792 will install IPython into
792 will install IPython into
793 \family typewriter
793 \family typewriter
794 $HOME/local
794 $HOME/local
795 \family default
795 \family default
796 and its subdirectories (creating them if necessary).
796 and its subdirectories (creating them if necessary).
797 \newline
797 \newline
798 You can type
798 You can type
799 \newline
799 \newline
800
800
801 \begin_inset ERT
801 \begin_inset ERT
802 status collapsed
802 status collapsed
803
803
804 \begin_layout Standard
804 \begin_layout Standard
805
805
806
806
807 \backslash
807 \backslash
808 verb|$ python setup.py --help|
808 verb|$ python setup.py --help|
809 \end_layout
809 \end_layout
810
810
811 \end_inset
811 \end_inset
812
812
813
813
814 \newline
814 \newline
815 for more details.
815 for more details.
816 \newline
816 \newline
817 Note that if you change the default location for
817 Note that if you change the default location for
818 \begin_inset ERT
818 \begin_inset ERT
819 status collapsed
819 status collapsed
820
820
821 \begin_layout Standard
821 \begin_layout Standard
822
822
823
823
824 \backslash
824 \backslash
825 verb|--home|
825 verb|--home|
826 \end_layout
826 \end_layout
827
827
828 \end_inset
828 \end_inset
829
829
830 at installation, IPython may end up installed at a location which is not
830 at installation, IPython may end up installed at a location which is not
831 part of your
831 part of your
832 \family typewriter
832 \family typewriter
833 $PYTHONPATH
833 $PYTHONPATH
834 \family default
834 \family default
835 environment variable.
835 environment variable.
836 In this case, you'll need to configure this variable to include the actual
836 In this case, you'll need to configure this variable to include the actual
837 directory where the
837 directory where the
838 \family typewriter
838 \family typewriter
839 IPython/
839 IPython/
840 \family default
840 \family default
841 directory ended (typically the value you give to
841 directory ended (typically the value you give to
842 \begin_inset ERT
842 \begin_inset ERT
843 status collapsed
843 status collapsed
844
844
845 \begin_layout Standard
845 \begin_layout Standard
846
846
847
847
848 \backslash
848 \backslash
849 verb|--home|
849 verb|--home|
850 \end_layout
850 \end_layout
851
851
852 \end_inset
852 \end_inset
853
853
854 plus
854 plus
855 \family typewriter
855 \family typewriter
856 /lib/python
856 /lib/python
857 \family default
857 \family default
858 ).
858 ).
859 \end_layout
859 \end_layout
860
860
861 \begin_layout Subsubsection
861 \begin_layout Subsubsection
862 Mac OSX information
862 Mac OSX information
863 \end_layout
863 \end_layout
864
864
865 \begin_layout Standard
865 \begin_layout Standard
866 Under OSX, there is a choice you need to make.
866 Under OSX, there is a choice you need to make.
867 Apple ships its own build of Python, which lives in the core OSX filesystem
867 Apple ships its own build of Python, which lives in the core OSX filesystem
868 hierarchy.
868 hierarchy.
869 You can also manually install a separate Python, either purely by hand
869 You can also manually install a separate Python, either purely by hand
870 (typically in
870 (typically in
871 \family typewriter
871 \family typewriter
872 /usr/local
872 /usr/local
873 \family default
873 \family default
874 ) or by using Fink, which puts everything under
874 ) or by using Fink, which puts everything under
875 \family typewriter
875 \family typewriter
876 /sw
876 /sw
877 \family default
877 \family default
878 .
878 .
879 Which route to follow is a matter of personal preference, as I've seen
879 Which route to follow is a matter of personal preference, as I've seen
880 users who favor each of the approaches.
880 users who favor each of the approaches.
881 Here I will simply list the known installation issues under OSX, along
881 Here I will simply list the known installation issues under OSX, along
882 with their solutions.
882 with their solutions.
883 \end_layout
883 \end_layout
884
884
885 \begin_layout Standard
885 \begin_layout Standard
886 This page:
886 This page:
887 \begin_inset LatexCommand \htmlurl{http://geosci.uchicago.edu/~tobis/pylab.html}
887 \begin_inset LatexCommand \htmlurl{http://geosci.uchicago.edu/~tobis/pylab.html}
888
888
889 \end_inset
889 \end_inset
890
890
891 contains information on this topic, with additional details on how to make
891 contains information on this topic, with additional details on how to make
892 IPython and matplotlib play nicely under OSX.
892 IPython and matplotlib play nicely under OSX.
893 \end_layout
893 \end_layout
894
894
895 \begin_layout Subsubsection*
895 \begin_layout Subsubsection*
896 GUI problems
896 GUI problems
897 \end_layout
897 \end_layout
898
898
899 \begin_layout Standard
899 \begin_layout Standard
900 The following instructions apply to an install of IPython under OSX from
900 The following instructions apply to an install of IPython under OSX from
901 unpacking the
901 unpacking the
902 \family typewriter
902 \family typewriter
903 .tar.gz
903 .tar.gz
904 \family default
904 \family default
905 distribution and installing it for the default Python interpreter shipped
905 distribution and installing it for the default Python interpreter shipped
906 by Apple.
906 by Apple.
907 If you are using a fink install, fink will take care of these details for
907 If you are using a fink install, fink will take care of these details for
908 you, by installing IPython against fink's Python.
908 you, by installing IPython against fink's Python.
909 \end_layout
909 \end_layout
910
910
911 \begin_layout Standard
911 \begin_layout Standard
912 IPython offers various forms of support for interacting with graphical applicati
912 IPython offers various forms of support for interacting with graphical applicati
913 ons from the command line, from simple Tk apps (which are in principle always
913 ons from the command line, from simple Tk apps (which are in principle always
914 supported by Python) to interactive control of WX, Qt and GTK apps.
914 supported by Python) to interactive control of WX, Qt and GTK apps.
915 Under OSX, however, this requires that ipython is installed by calling
915 Under OSX, however, this requires that ipython is installed by calling
916 the special
916 the special
917 \family typewriter
917 \family typewriter
918 pythonw
918 pythonw
919 \family default
919 \family default
920 script at installation time, which takes care of coordinating things with
920 script at installation time, which takes care of coordinating things with
921 Apple's graphical environment.
921 Apple's graphical environment.
922 \end_layout
922 \end_layout
923
923
924 \begin_layout Standard
924 \begin_layout Standard
925 So when installing under OSX, it is best to use the following command:
925 So when installing under OSX, it is best to use the following command:
926 \family typewriter
926 \family typewriter
927
927
928 \newline
928 \newline
929
929
930 \family default
930 \family default
931
931
932 \begin_inset ERT
932 \begin_inset ERT
933 status collapsed
933 status collapsed
934
934
935 \begin_layout Standard
935 \begin_layout Standard
936
936
937
937
938 \backslash
938 \backslash
939 verb| $ sudo pythonw setup.py install --install-scripts=/usr/local/bin|
939 verb| $ sudo pythonw setup.py install --install-scripts=/usr/local/bin|
940 \end_layout
940 \end_layout
941
941
942 \end_inset
942 \end_inset
943
943
944
944
945 \newline
945 \newline
946 or
946 or
947 \newline
947 \newline
948
948
949 \begin_inset ERT
949 \begin_inset ERT
950 status collapsed
950 status collapsed
951
951
952 \begin_layout Standard
952 \begin_layout Standard
953
953
954
954
955 \backslash
955 \backslash
956 verb| $ sudo pythonw setup.py install --install-scripts=/usr/bin|
956 verb| $ sudo pythonw setup.py install --install-scripts=/usr/bin|
957 \end_layout
957 \end_layout
958
958
959 \end_inset
959 \end_inset
960
960
961
961
962 \newline
962 \newline
963 depending on where you like to keep hand-installed executables.
963 depending on where you like to keep hand-installed executables.
964 \end_layout
964 \end_layout
965
965
966 \begin_layout Standard
966 \begin_layout Standard
967 The resulting script will have an appropriate shebang line (the first line
967 The resulting script will have an appropriate shebang line (the first line
968 in the script whic begins with
968 in the script whic begins with
969 \family typewriter
969 \family typewriter
970 #!...
970 #!...
971 \family default
971 \family default
972 ) such that the ipython interpreter can interact with the OS X GUI.
972 ) such that the ipython interpreter can interact with the OS X GUI.
973 If the installed version does not work and has a shebang line that points
973 If the installed version does not work and has a shebang line that points
974 to, for example, just
974 to, for example, just
975 \family typewriter
975 \family typewriter
976 /usr/bin/python
976 /usr/bin/python
977 \family default
977 \family default
978 , then you might have a stale, cached version in your
978 , then you might have a stale, cached version in your
979 \family typewriter
979 \family typewriter
980 build/scripts-<python-version>
980 build/scripts-<python-version>
981 \family default
981 \family default
982 directory.
982 directory.
983 Delete that directory and rerun the
983 Delete that directory and rerun the
984 \family typewriter
984 \family typewriter
985 setup.py
985 setup.py
986 \family default
986 \family default
987 .
987 .
988
988
989 \end_layout
989 \end_layout
990
990
991 \begin_layout Standard
991 \begin_layout Standard
992 It is also a good idea to use the special flag
992 It is also a good idea to use the special flag
993 \begin_inset ERT
993 \begin_inset ERT
994 status collapsed
994 status collapsed
995
995
996 \begin_layout Standard
996 \begin_layout Standard
997
997
998
998
999 \backslash
999 \backslash
1000 verb|--install-scripts|
1000 verb|--install-scripts|
1001 \end_layout
1001 \end_layout
1002
1002
1003 \end_inset
1003 \end_inset
1004
1004
1005 as indicated above, to ensure that the ipython scripts end up in a location
1005 as indicated above, to ensure that the ipython scripts end up in a location
1006 which is part of your
1006 which is part of your
1007 \family typewriter
1007 \family typewriter
1008 $PATH
1008 $PATH
1009 \family default
1009 \family default
1010 .
1010 .
1011 Otherwise Apple's Python will put the scripts in an internal directory
1011 Otherwise Apple's Python will put the scripts in an internal directory
1012 not available by default at the command line (if you use
1012 not available by default at the command line (if you use
1013 \family typewriter
1013 \family typewriter
1014 /usr/local/bin
1014 /usr/local/bin
1015 \family default
1015 \family default
1016 , you need to make sure this is in your
1016 , you need to make sure this is in your
1017 \family typewriter
1017 \family typewriter
1018 $PATH
1018 $PATH
1019 \family default
1019 \family default
1020 , which may not be true by default).
1020 , which may not be true by default).
1021 \end_layout
1021 \end_layout
1022
1022
1023 \begin_layout Subsubsection*
1023 \begin_layout Subsubsection*
1024 Readline problems
1024 Readline problems
1025 \end_layout
1025 \end_layout
1026
1026
1027 \begin_layout Standard
1027 \begin_layout Standard
1028 By default, the Python version shipped by Apple does
1028 By default, the Python version shipped by Apple does
1029 \emph on
1029 \emph on
1030 not
1030 not
1031 \emph default
1031 \emph default
1032 include the readline library, so central to IPython's behavior.
1032 include the readline library, so central to IPython's behavior.
1033 If you install IPython against Apple's Python, you will not have arrow
1033 If you install IPython against Apple's Python, you will not have arrow
1034 keys, tab completion, etc.
1034 keys, tab completion, etc.
1035 For Mac OSX 10.3 (Panther), you can find a prebuilt readline library here:
1035 For Mac OSX 10.3 (Panther), you can find a prebuilt readline library here:
1036 \newline
1036 \newline
1037
1037
1038 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/readline-5.0-py2.3-macosx10.3.zip}
1038 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/readline-5.0-py2.3-macosx10.3.zip}
1039
1039
1040 \end_inset
1040 \end_inset
1041
1041
1042
1042
1043 \end_layout
1043 \end_layout
1044
1044
1045 \begin_layout Standard
1045 \begin_layout Standard
1046 If you are using OSX 10.4 (Tiger), after installing this package you need
1046 If you are using OSX 10.4 (Tiger), after installing this package you need
1047 to either:
1047 to either:
1048 \end_layout
1048 \end_layout
1049
1049
1050 \begin_layout Enumerate
1050 \begin_layout Enumerate
1051 move
1051 move
1052 \family typewriter
1052 \family typewriter
1053 readline.so
1053 readline.so
1054 \family default
1054 \family default
1055 from
1055 from
1056 \family typewriter
1056 \family typewriter
1057 /Library/Python/2.3
1057 /Library/Python/2.3
1058 \family default
1058 \family default
1059 to
1059 to
1060 \family typewriter
1060 \family typewriter
1061 /Library/Python/2.3/site-packages
1061 /Library/Python/2.3/site-packages
1062 \family default
1062 \family default
1063 , or
1063 , or
1064 \end_layout
1064 \end_layout
1065
1065
1066 \begin_layout Enumerate
1066 \begin_layout Enumerate
1067 install
1067 install
1068 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/TigerPython23Compat.pkg.zip}
1068 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/TigerPython23Compat.pkg.zip}
1069
1069
1070 \end_inset
1070 \end_inset
1071
1071
1072
1072
1073 \end_layout
1073 \end_layout
1074
1074
1075 \begin_layout Standard
1075 \begin_layout Standard
1076 Users installing against Fink's Python or a properly hand-built one should
1076 Users installing against Fink's Python or a properly hand-built one should
1077 not have this problem.
1077 not have this problem.
1078 \end_layout
1078 \end_layout
1079
1079
1080 \begin_layout Subsubsection*
1080 \begin_layout Subsubsection*
1081 DarwinPorts
1081 DarwinPorts
1082 \end_layout
1082 \end_layout
1083
1083
1084 \begin_layout Standard
1084 \begin_layout Standard
1085 I report here a message from an OSX user, who suggests an alternative means
1085 I report here a message from an OSX user, who suggests an alternative means
1086 of using IPython under this operating system with good results.
1086 of using IPython under this operating system with good results.
1087 Please let me know of any updates that may be useful for this section.
1087 Please let me know of any updates that may be useful for this section.
1088 His message is reproduced verbatim below:
1088 His message is reproduced verbatim below:
1089 \end_layout
1089 \end_layout
1090
1090
1091 \begin_layout Quote
1091 \begin_layout Quote
1092 From: Markus Banfi
1092 From: Markus Banfi
1093 \family typewriter
1093 \family typewriter
1094 <markus.banfi-AT-mospheira.net>
1094 <markus.banfi-AT-mospheira.net>
1095 \end_layout
1095 \end_layout
1096
1096
1097 \begin_layout Quote
1097 \begin_layout Quote
1098 As a MacOS X (10.4.2) user I prefer to install software using DawinPorts instead
1098 As a MacOS X (10.4.2) user I prefer to install software using DawinPorts instead
1099 of Fink.
1099 of Fink.
1100 I had no problems installing ipython with DarwinPorts.
1100 I had no problems installing ipython with DarwinPorts.
1101 It's just:
1101 It's just:
1102 \end_layout
1102 \end_layout
1103
1103
1104 \begin_layout Quote
1104 \begin_layout Quote
1105
1105
1106 \family typewriter
1106 \family typewriter
1107 sudo port install py-ipython
1107 sudo port install py-ipython
1108 \end_layout
1108 \end_layout
1109
1109
1110 \begin_layout Quote
1110 \begin_layout Quote
1111 It automatically resolved all dependencies (python24, readline, py-readline).
1111 It automatically resolved all dependencies (python24, readline, py-readline).
1112 So far I did not encounter any problems with the DarwinPorts port of ipython.
1112 So far I did not encounter any problems with the DarwinPorts port of ipython.
1113
1113
1114 \end_layout
1114 \end_layout
1115
1115
1116 \begin_layout Subsection
1116 \begin_layout Subsection
1117 \begin_inset LatexCommand \label{sub:Under-Windows}
1117 \begin_inset LatexCommand \label{sub:Under-Windows}
1118
1118
1119 \end_inset
1119 \end_inset
1120
1120
1121 Windows instructions
1121 Windows instructions
1122 \end_layout
1122 \end_layout
1123
1123
1124 \begin_layout Standard
1124 \begin_layout Standard
1125 Some of IPython's very useful features are:
1125 Some of IPython's very useful features are:
1126 \end_layout
1126 \end_layout
1127
1127
1128 \begin_layout Itemize
1128 \begin_layout Itemize
1129 Integrated readline support (Tab-based file, object and attribute completion,
1129 Integrated readline support (Tab-based file, object and attribute completion,
1130 input history across sessions, editable command line, etc.)
1130 input history across sessions, editable command line, etc.)
1131 \end_layout
1131 \end_layout
1132
1132
1133 \begin_layout Itemize
1133 \begin_layout Itemize
1134 Coloring of prompts, code and tracebacks.
1134 Coloring of prompts, code and tracebacks.
1135 \end_layout
1135 \end_layout
1136
1136
1137 \begin_layout Standard
1137 \begin_layout Standard
1138 These, by default, are only available under Unix-like operating systems.
1138 These, by default, are only available under Unix-like operating systems.
1139 However, thanks to Gary Bishop's work, Windows XP/2k users can also benefit
1139 However, thanks to Gary Bishop's work, Windows XP/2k users can also benefit
1140 from them.
1140 from them.
1141 His readline library originally implemented both GNU readline functionality
1141 His readline library originally implemented both GNU readline functionality
1142 and color support, so that IPython under Windows XP/2k can be as friendly
1142 and color support, so that IPython under Windows XP/2k can be as friendly
1143 and powerful as under Unix-like environments.
1143 and powerful as under Unix-like environments.
1144
1144
1145 \end_layout
1145 \end_layout
1146
1146
1147 \begin_layout Standard
1147 \begin_layout Standard
1148 This library, now named
1148 This library, now named
1149 \family typewriter
1149 \family typewriter
1150 PyReadline
1150 PyReadline
1151 \family default
1151 \family default
1152 , has been absorbed by the IPython team (JοΏ½rgen Stenarson, in particular),
1152 , has been absorbed by the IPython team (JοΏ½rgen Stenarson, in particular),
1153 and it continues to be developed with new features, as well as being distribute
1153 and it continues to be developed with new features, as well as being distribute
1154 d directly from the IPython site.
1154 d directly from the IPython site.
1155 \end_layout
1155 \end_layout
1156
1156
1157 \begin_layout Standard
1157 \begin_layout Standard
1158 The
1158 The
1159 \family typewriter
1159 \family typewriter
1160 PyReadline
1160 PyReadline
1161 \family default
1161 \family default
1162 extension requires
1162 extension requires
1163 \family typewriter
1163 \family typewriter
1164 CTypes
1164 CTypes
1165 \family default
1165 \family default
1166 and the windows IPython installer needs
1166 and the windows IPython installer needs
1167 \family typewriter
1167 \family typewriter
1168 PyWin32
1168 PyWin32
1169 \family default
1169 \family default
1170 , so in all you need:
1170 , so in all you need:
1171 \end_layout
1171 \end_layout
1172
1172
1173 \begin_layout Enumerate
1173 \begin_layout Enumerate
1174
1174
1175 \family typewriter
1175 \family typewriter
1176 PyWin32
1176 PyWin32
1177 \family default
1177 \family default
1178 from
1178 from
1179 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/pywin32}
1179 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/pywin32}
1180
1180
1181 \end_inset
1181 \end_inset
1182
1182
1183 .
1183 .
1184 \end_layout
1184 \end_layout
1185
1185
1186 \begin_layout Enumerate
1186 \begin_layout Enumerate
1187
1187
1188 \family typewriter
1188 \family typewriter
1189 PyReadline
1189 PyReadline
1190 \family default
1190 \family default
1191 for Windows from
1191 for Windows from
1192 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org/moin/PyReadline/Intro}
1192 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org/moin/PyReadline/Intro}
1193
1193
1194 \end_inset
1194 \end_inset
1195
1195
1196 .
1196 .
1197 That page contains further details on using and configuring the system
1197 That page contains further details on using and configuring the system
1198 to your liking.
1198 to your liking.
1199 \end_layout
1199 \end_layout
1200
1200
1201 \begin_layout Enumerate
1201 \begin_layout Enumerate
1202 Finally,
1202 Finally,
1203 \emph on
1203 \emph on
1204 only
1204 only
1205 \emph default
1205 \emph default
1206 if you are using Python 2.3 or 2.4, you need
1206 if you are using Python 2.3 or 2.4, you need
1207 \family typewriter
1207 \family typewriter
1208 CTypes
1208 CTypes
1209 \family default
1209 \family default
1210 from
1210 from
1211 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/theller/ctypes}
1211 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/theller/ctypes}
1212
1212
1213 \end_inset
1213 \end_inset
1214
1214
1215 (you
1215 (you
1216 \emph on
1216 \emph on
1217 must
1217 must
1218 \emph default
1218 \emph default
1219 use version 0.9.1 or newer).
1219 use version 0.9.1 or newer).
1220 This package is included in Python 2.5, so you don't need to manually get
1220 This package is included in Python 2.5, so you don't need to manually get
1221 it if your Python version is 2.5 or newer.
1221 it if your Python version is 2.5 or newer.
1222 \end_layout
1222 \end_layout
1223
1223
1224 \begin_layout Standard
1224 \begin_layout Standard
1225
1225
1226 \series bold
1226 \series bold
1227 Warning about a broken readline-like library:
1227 Warning about a broken readline-like library:
1228 \series default
1228 \series default
1229 several users have reported problems stemming from using the pseudo-readline
1229 several users have reported problems stemming from using the pseudo-readline
1230 library at
1230 library at
1231 \begin_inset LatexCommand \htmlurl{http://newcenturycomputers.net/projects/readline.html}
1231 \begin_inset LatexCommand \htmlurl{http://newcenturycomputers.net/projects/readline.html}
1232
1232
1233 \end_inset
1233 \end_inset
1234
1234
1235 .
1235 .
1236 This is a broken library which, while called readline, only implements
1236 This is a broken library which, while called readline, only implements
1237 an incomplete subset of the readline API.
1237 an incomplete subset of the readline API.
1238 Since it is still called readline, it fools IPython's detection mechanisms
1238 Since it is still called readline, it fools IPython's detection mechanisms
1239 and causes unpredictable crashes later.
1239 and causes unpredictable crashes later.
1240 If you wish to use IPython under Windows, you must NOT use this library,
1240 If you wish to use IPython under Windows, you must NOT use this library,
1241 which for all purposes is (at least as of version 1.6) terminally broken.
1241 which for all purposes is (at least as of version 1.6) terminally broken.
1242 \end_layout
1242 \end_layout
1243
1243
1244 \begin_layout Subsubsection
1244 \begin_layout Subsubsection
1245 Installation procedure
1245 Installation procedure
1246 \end_layout
1246 \end_layout
1247
1247
1248 \begin_layout Standard
1248 \begin_layout Standard
1249 Once you have the above installed, from the IPython download directory grab
1249 Once you have the above installed, from the IPython download directory grab
1250 the
1250 the
1251 \family typewriter
1251 \family typewriter
1252 ipython-XXX.win32.exe
1252 ipython-XXX.win32.exe
1253 \family default
1253 \family default
1254 file, where
1254 file, where
1255 \family typewriter
1255 \family typewriter
1256 XXX
1256 XXX
1257 \family default
1257 \family default
1258 represents the version number.
1258 represents the version number.
1259 This is a regular windows executable installer, which you can simply double-cli
1259 This is a regular windows executable installer, which you can simply double-cli
1260 ck to install.
1260 ck to install.
1261 It will add an entry for IPython to your Start Menu, as well as registering
1261 It will add an entry for IPython to your Start Menu, as well as registering
1262 IPython in the Windows list of applications, so you can later uninstall
1262 IPython in the Windows list of applications, so you can later uninstall
1263 it from the Control Panel.
1263 it from the Control Panel.
1264
1264
1265 \end_layout
1265 \end_layout
1266
1266
1267 \begin_layout Standard
1267 \begin_layout Standard
1268 IPython tries to install the configuration information in a directory named
1268 IPython tries to install the configuration information in a directory named
1269
1269
1270 \family typewriter
1270 \family typewriter
1271 .ipython
1271 .ipython
1272 \family default
1272 \family default
1273 (
1273 (
1274 \family typewriter
1274 \family typewriter
1275 _ipython
1275 _ipython
1276 \family default
1276 \family default
1277 under Windows) located in your `home' directory.
1277 under Windows) located in your `home' directory.
1278 IPython sets this directory by looking for a
1278 IPython sets this directory by looking for a
1279 \family typewriter
1279 \family typewriter
1280 HOME
1280 HOME
1281 \family default
1281 \family default
1282 environment variable; if such a variable does not exist, it uses
1282 environment variable; if such a variable does not exist, it uses
1283 \family typewriter
1283 \family typewriter
1284 HOMEDRIVE
1284 HOMEDRIVE
1285 \backslash
1285 \backslash
1286 HOMEPATH
1286 HOMEPATH
1287 \family default
1287 \family default
1288 (these are always defined by Windows).
1288 (these are always defined by Windows).
1289 This typically gives something like
1289 This typically gives something like
1290 \family typewriter
1290 \family typewriter
1291 C:
1291 C:
1292 \backslash
1292 \backslash
1293 Documents and Settings
1293 Documents and Settings
1294 \backslash
1294 \backslash
1295 YourUserName
1295 YourUserName
1296 \family default
1296 \family default
1297 , but your local details may vary.
1297 , but your local details may vary.
1298 In this directory you will find all the files that configure IPython's
1298 In this directory you will find all the files that configure IPython's
1299 defaults, and you can put there your profiles and extensions.
1299 defaults, and you can put there your profiles and extensions.
1300 This directory is automatically added by IPython to
1300 This directory is automatically added by IPython to
1301 \family typewriter
1301 \family typewriter
1302 sys.path
1302 sys.path
1303 \family default
1303 \family default
1304 , so anything you place there can be found by
1304 , so anything you place there can be found by
1305 \family typewriter
1305 \family typewriter
1306 import
1306 import
1307 \family default
1307 \family default
1308 statements.
1308 statements.
1309 \end_layout
1309 \end_layout
1310
1310
1311 \begin_layout Paragraph
1311 \begin_layout Paragraph
1312 Upgrading
1312 Upgrading
1313 \end_layout
1313 \end_layout
1314
1314
1315 \begin_layout Standard
1315 \begin_layout Standard
1316 For an IPython upgrade, you should first uninstall the previous version.
1316 For an IPython upgrade, you should first uninstall the previous version.
1317 This will ensure that all files and directories (such as the documentation)
1317 This will ensure that all files and directories (such as the documentation)
1318 which carry embedded version strings in their names are properly removed.
1318 which carry embedded version strings in their names are properly removed.
1319 \end_layout
1319 \end_layout
1320
1320
1321 \begin_layout Paragraph
1321 \begin_layout Paragraph
1322 Manual installation under Win32
1322 Manual installation under Win32
1323 \end_layout
1323 \end_layout
1324
1324
1325 \begin_layout Standard
1325 \begin_layout Standard
1326 In case the automatic installer does not work for some reason, you can download
1326 In case the automatic installer does not work for some reason, you can download
1327 the
1327 the
1328 \family typewriter
1328 \family typewriter
1329 ipython-XXX.tar.gz
1329 ipython-XXX.tar.gz
1330 \family default
1330 \family default
1331 file, which contains the full IPython source distribution (the popular
1331 file, which contains the full IPython source distribution (the popular
1332 WinZip can read
1332 WinZip can read
1333 \family typewriter
1333 \family typewriter
1334 .tar.gz
1334 .tar.gz
1335 \family default
1335 \family default
1336 files).
1336 files).
1337 After uncompressing the archive, you can install it at a command terminal
1337 After uncompressing the archive, you can install it at a command terminal
1338 just like any other Python module, by using
1338 just like any other Python module, by using
1339 \family typewriter
1339 \family typewriter
1340 `python setup.py install'
1340 `python setup.py install'
1341 \family default
1341 \family default
1342 .
1342 .
1343
1343
1344 \end_layout
1344 \end_layout
1345
1345
1346 \begin_layout Standard
1346 \begin_layout Standard
1347 After the installation, run the supplied
1347 After the installation, run the supplied
1348 \family typewriter
1348 \family typewriter
1349 win32_manual_post_install.py
1349 win32_manual_post_install.py
1350 \family default
1350 \family default
1351 script, which creates the necessary Start Menu shortcuts for you.
1351 script, which creates the necessary Start Menu shortcuts for you.
1352 \end_layout
1352 \end_layout
1353
1353
1354 \begin_layout Subsection
1354 \begin_layout Subsection
1355 \begin_inset LatexCommand \label{sec:upgrade}
1355 \begin_inset LatexCommand \label{sec:upgrade}
1356
1356
1357 \end_inset
1357 \end_inset
1358
1358
1359 Upgrading from a previous version
1359 Upgrading from a previous version
1360 \end_layout
1360 \end_layout
1361
1361
1362 \begin_layout Standard
1362 \begin_layout Standard
1363 If you are upgrading from a previous version of IPython, after doing the
1363 If you are upgrading from a previous version of IPython, after doing the
1364 routine installation described above, you should call IPython with the
1364 routine installation described above, you should call IPython with the
1365
1365
1366 \family typewriter
1366 \family typewriter
1367 -upgrade
1367 -upgrade
1368 \family default
1368 \family default
1369 option the first time you run your new copy.
1369 option the first time you run your new copy.
1370 This will automatically update your configuration directory while preserving
1370 This will automatically update your configuration directory while preserving
1371 copies of your old files.
1371 copies of your old files.
1372 You can then later merge back any personal customizations you may have
1372 You can then later merge back any personal customizations you may have
1373 made into the new files.
1373 made into the new files.
1374 It is a good idea to do this as there may be new options available in the
1374 It is a good idea to do this as there may be new options available in the
1375 new configuration files which you will not have.
1375 new configuration files which you will not have.
1376 \end_layout
1376 \end_layout
1377
1377
1378 \begin_layout Standard
1378 \begin_layout Standard
1379 Under Windows, if you don't know how to call python scripts with arguments
1379 Under Windows, if you don't know how to call python scripts with arguments
1380 from a command line, simply delete the old config directory and IPython
1380 from a command line, simply delete the old config directory and IPython
1381 will make a new one.
1381 will make a new one.
1382 Win2k and WinXP users will find it in
1382 Win2k and WinXP users will find it in
1383 \family typewriter
1383 \family typewriter
1384 C:
1384 C:
1385 \backslash
1385 \backslash
1386 Documents and Settings
1386 Documents and Settings
1387 \backslash
1387 \backslash
1388 YourUserName
1388 YourUserName
1389 \backslash
1389 \backslash
1390 _ipython
1390 _ipython
1391 \family default
1391 \family default
1392 , and Win 9x users under
1392 , and Win 9x users under
1393 \family typewriter
1393 \family typewriter
1394 C:
1394 C:
1395 \backslash
1395 \backslash
1396 Program Files
1396 Program Files
1397 \backslash
1397 \backslash
1398 IPython
1398 IPython
1399 \backslash
1399 \backslash
1400 _ipython.
1400 _ipython.
1401 \end_layout
1401 \end_layout
1402
1402
1403 \begin_layout Section
1403 \begin_layout Section
1404 \begin_inset LatexCommand \label{sec:good_config}
1404 \begin_inset LatexCommand \label{sec:good_config}
1405
1405
1406 \end_inset
1406 \end_inset
1407
1407
1408
1408
1409 \begin_inset OptArg
1409 \begin_inset OptArg
1410 status collapsed
1410 status collapsed
1411
1411
1412 \begin_layout Standard
1412 \begin_layout Standard
1413 Initial configuration
1413 Initial configuration
1414 \begin_inset ERT
1414 \begin_inset ERT
1415 status collapsed
1415 status collapsed
1416
1416
1417 \begin_layout Standard
1417 \begin_layout Standard
1418
1418
1419
1419
1420 \backslash
1420 \backslash
1421 ldots
1421 ldots
1422 \end_layout
1422 \end_layout
1423
1423
1424 \end_inset
1424 \end_inset
1425
1425
1426
1426
1427 \end_layout
1427 \end_layout
1428
1428
1429 \end_inset
1429 \end_inset
1430
1430
1431 Initial configuration of your environment
1431 Initial configuration of your environment
1432 \end_layout
1432 \end_layout
1433
1433
1434 \begin_layout Standard
1434 \begin_layout Standard
1435 This section will help you set various things in your environment for your
1435 This section will help you set various things in your environment for your
1436 IPython sessions to be as efficient as possible.
1436 IPython sessions to be as efficient as possible.
1437 All of IPython's configuration information, along with several example
1437 All of IPython's configuration information, along with several example
1438 files, is stored in a directory named by default
1438 files, is stored in a directory named by default
1439 \family typewriter
1439 \family typewriter
1440 $HOME/.ipython
1440 $HOME/.ipython
1441 \family default
1441 \family default
1442 .
1442 .
1443 You can change this by defining the environment variable
1443 You can change this by defining the environment variable
1444 \family typewriter
1444 \family typewriter
1445 IPYTHONDIR
1445 IPYTHONDIR
1446 \family default
1446 \family default
1447 , or at runtime with the command line option
1447 , or at runtime with the command line option
1448 \family typewriter
1448 \family typewriter
1449 -ipythondir
1449 -ipythondir
1450 \family default
1450 \family default
1451 .
1451 .
1452 \end_layout
1452 \end_layout
1453
1453
1454 \begin_layout Standard
1454 \begin_layout Standard
1455 If all goes well, the first time you run IPython it should automatically
1455 If all goes well, the first time you run IPython it should automatically
1456 create a user copy of the config directory for you, based on its builtin
1456 create a user copy of the config directory for you, based on its builtin
1457 defaults.
1457 defaults.
1458 You can look at the files it creates to learn more about configuring the
1458 You can look at the files it creates to learn more about configuring the
1459 system.
1459 system.
1460 The main file you will modify to configure IPython's behavior is called
1460 The main file you will modify to configure IPython's behavior is called
1461
1461
1462 \family typewriter
1462 \family typewriter
1463 ipythonrc
1463 ipythonrc
1464 \family default
1464 \family default
1465 (with a
1465 (with a
1466 \family typewriter
1466 \family typewriter
1467 .ini
1467 .ini
1468 \family default
1468 \family default
1469 extension under Windows), included for reference in Sec.
1469 extension under Windows), included for reference in Sec.
1470
1470
1471 \begin_inset LatexCommand \ref{sec:ipytonrc-sample}
1471 \begin_inset LatexCommand \ref{sec:ipytonrc-sample}
1472
1472
1473 \end_inset
1473 \end_inset
1474
1474
1475 .
1475 .
1476 This file is very commented and has many variables you can change to suit
1476 This file is very commented and has many variables you can change to suit
1477 your taste, you can find more details in Sec.
1477 your taste, you can find more details in Sec.
1478
1478
1479 \begin_inset LatexCommand \ref{sec:customization}
1479 \begin_inset LatexCommand \ref{sec:customization}
1480
1480
1481 \end_inset
1481 \end_inset
1482
1482
1483 .
1483 .
1484 Here we discuss the basic things you will want to make sure things are
1484 Here we discuss the basic things you will want to make sure things are
1485 working properly from the beginning.
1485 working properly from the beginning.
1486 \end_layout
1486 \end_layout
1487
1487
1488 \begin_layout Subsection
1488 \begin_layout Subsection
1489 \begin_inset LatexCommand \label{sec:help-access}
1489 \begin_inset LatexCommand \label{sec:help-access}
1490
1490
1491 \end_inset
1491 \end_inset
1492
1492
1493 Access to the Python help system
1493 Access to the Python help system
1494 \end_layout
1494 \end_layout
1495
1495
1496 \begin_layout Standard
1496 \begin_layout Standard
1497 This is true for Python in general (not just for IPython): you should have
1497 This is true for Python in general (not just for IPython): you should have
1498 an environment variable called
1498 an environment variable called
1499 \family typewriter
1499 \family typewriter
1500 PYTHONDOCS
1500 PYTHONDOCS
1501 \family default
1501 \family default
1502 pointing to the directory where your HTML Python documentation lives.
1502 pointing to the directory where your HTML Python documentation lives.
1503 In my system it's
1503 In my system it's
1504 \family typewriter
1504 \family typewriter
1505 /usr/share/doc/python-docs-2.3.4/html
1505 /usr/share/doc/python-docs-2.3.4/html
1506 \family default
1506 \family default
1507 , check your local details or ask your systems administrator.
1507 , check your local details or ask your systems administrator.
1508
1508
1509 \end_layout
1509 \end_layout
1510
1510
1511 \begin_layout Standard
1511 \begin_layout Standard
1512 This is the directory which holds the HTML version of the Python manuals.
1512 This is the directory which holds the HTML version of the Python manuals.
1513 Unfortunately it seems that different Linux distributions package these
1513 Unfortunately it seems that different Linux distributions package these
1514 files differently, so you may have to look around a bit.
1514 files differently, so you may have to look around a bit.
1515 Below I show the contents of this directory on my system for reference:
1515 Below I show the contents of this directory on my system for reference:
1516 \end_layout
1516 \end_layout
1517
1517
1518 \begin_layout Standard
1518 \begin_layout Standard
1519
1519
1520 \family typewriter
1520 \family typewriter
1521 [html]> ls
1521 [html]> ls
1522 \newline
1522 \newline
1523 about.dat acks.html dist/ ext/ index.html lib/ modindex.html stdabout.dat
1523 about.dat acks.html dist/ ext/ index.html lib/ modindex.html stdabout.dat
1524 tut/ about.html api/ doc/ icons/ inst/ mac/ ref/ style.css
1524 tut/ about.html api/ doc/ icons/ inst/ mac/ ref/ style.css
1525 \end_layout
1525 \end_layout
1526
1526
1527 \begin_layout Standard
1527 \begin_layout Standard
1528 You should really make sure this variable is correctly set so that Python's
1528 You should really make sure this variable is correctly set so that Python's
1529 pydoc-based help system works.
1529 pydoc-based help system works.
1530 It is a powerful and convenient system with full access to the Python manuals
1530 It is a powerful and convenient system with full access to the Python manuals
1531 and all modules accessible to you.
1531 and all modules accessible to you.
1532 \end_layout
1532 \end_layout
1533
1533
1534 \begin_layout Standard
1534 \begin_layout Standard
1535 Under Windows it seems that pydoc finds the documentation automatically,
1535 Under Windows it seems that pydoc finds the documentation automatically,
1536 so no extra setup appears necessary.
1536 so no extra setup appears necessary.
1537 \end_layout
1537 \end_layout
1538
1538
1539 \begin_layout Subsection
1539 \begin_layout Subsection
1540 Editor
1540 Editor
1541 \end_layout
1541 \end_layout
1542
1542
1543 \begin_layout Standard
1543 \begin_layout Standard
1544 The
1544 The
1545 \family typewriter
1545 \family typewriter
1546 %edit
1546 %edit
1547 \family default
1547 \family default
1548 command (and its alias
1548 command (and its alias
1549 \family typewriter
1549 \family typewriter
1550 %ed
1550 %ed
1551 \family default
1551 \family default
1552 ) will invoke the editor set in your environment as
1552 ) will invoke the editor set in your environment as
1553 \family typewriter
1553 \family typewriter
1554 EDITOR
1554 EDITOR
1555 \family default
1555 \family default
1556 .
1556 .
1557 If this variable is not set, it will default to
1557 If this variable is not set, it will default to
1558 \family typewriter
1558 \family typewriter
1559 vi
1559 vi
1560 \family default
1560 \family default
1561 under Linux/Unix and to
1561 under Linux/Unix and to
1562 \family typewriter
1562 \family typewriter
1563 notepad
1563 notepad
1564 \family default
1564 \family default
1565 under Windows.
1565 under Windows.
1566 You may want to set this variable properly and to a lightweight editor
1566 You may want to set this variable properly and to a lightweight editor
1567 which doesn't take too long to start (that is, something other than a new
1567 which doesn't take too long to start (that is, something other than a new
1568 instance of
1568 instance of
1569 \family typewriter
1569 \family typewriter
1570 Emacs
1570 Emacs
1571 \family default
1571 \family default
1572 ).
1572 ).
1573 This way you can edit multi-line code quickly and with the power of a real
1573 This way you can edit multi-line code quickly and with the power of a real
1574 editor right inside IPython.
1574 editor right inside IPython.
1575
1575
1576 \end_layout
1576 \end_layout
1577
1577
1578 \begin_layout Standard
1578 \begin_layout Standard
1579 If you are a dedicated
1579 If you are a dedicated
1580 \family typewriter
1580 \family typewriter
1581 Emacs
1581 Emacs
1582 \family default
1582 \family default
1583 user, you should set up the
1583 user, you should set up the
1584 \family typewriter
1584 \family typewriter
1585 Emacs
1585 Emacs
1586 \family default
1586 \family default
1587 server so that new requests are handled by the original process.
1587 server so that new requests are handled by the original process.
1588 This means that almost no time is spent in handling the request (assuming
1588 This means that almost no time is spent in handling the request (assuming
1589 an
1589 an
1590 \family typewriter
1590 \family typewriter
1591 Emacs
1591 Emacs
1592 \family default
1592 \family default
1593 process is already running).
1593 process is already running).
1594 For this to work, you need to set your
1594 For this to work, you need to set your
1595 \family typewriter
1595 \family typewriter
1596 EDITOR
1596 EDITOR
1597 \family default
1597 \family default
1598 environment variable to
1598 environment variable to
1599 \family typewriter
1599 \family typewriter
1600 'emacsclient'
1600 'emacsclient'
1601 \family default
1601 \family default
1602 .
1602 .
1603
1603
1604 \family typewriter
1604 \family typewriter
1605
1605
1606 \family default
1606 \family default
1607 The code below, supplied by Francois Pinard, can then be used in your
1607 The code below, supplied by Francois Pinard, can then be used in your
1608 \family typewriter
1608 \family typewriter
1609 .emacs
1609 .emacs
1610 \family default
1610 \family default
1611 file to enable the server:
1611 file to enable the server:
1612 \end_layout
1612 \end_layout
1613
1613
1614 \begin_layout Standard
1614 \begin_layout Standard
1615
1615
1616 \family typewriter
1616 \family typewriter
1617 (defvar server-buffer-clients)
1617 (defvar server-buffer-clients)
1618 \newline
1618 \newline
1619 (when (and (fboundp 'server-start) (string-equal
1619 (when (and (fboundp 'server-start) (string-equal
1620 (getenv "TERM") 'xterm))
1620 (getenv "TERM") 'xterm))
1621 \newline
1621 \newline
1622
1622
1623 \begin_inset ERT
1623 \begin_inset ERT
1624 status collapsed
1624 status collapsed
1625
1625
1626 \begin_layout Standard
1626 \begin_layout Standard
1627
1627
1628
1628
1629 \backslash
1629 \backslash
1630 hspace*{0mm}
1630 hspace*{0mm}
1631 \end_layout
1631 \end_layout
1632
1632
1633 \end_inset
1633 \end_inset
1634
1634
1635 \InsetSpace ~
1635 \InsetSpace ~
1636 \InsetSpace ~
1636 \InsetSpace ~
1637 (server-start)
1637 (server-start)
1638 \newline
1638 \newline
1639
1639
1640 \begin_inset ERT
1640 \begin_inset ERT
1641 status collapsed
1641 status collapsed
1642
1642
1643 \begin_layout Standard
1643 \begin_layout Standard
1644
1644
1645
1645
1646 \backslash
1646 \backslash
1647 hspace*{0mm}
1647 hspace*{0mm}
1648 \end_layout
1648 \end_layout
1649
1649
1650 \end_inset
1650 \end_inset
1651
1651
1652 \InsetSpace ~
1652 \InsetSpace ~
1653 \InsetSpace ~
1653 \InsetSpace ~
1654 (defun fp-kill-server-with-buffer-routine ()
1654 (defun fp-kill-server-with-buffer-routine ()
1655 \newline
1655 \newline
1656
1656
1657 \begin_inset ERT
1657 \begin_inset ERT
1658 status collapsed
1658 status collapsed
1659
1659
1660 \begin_layout Standard
1660 \begin_layout Standard
1661
1661
1662
1662
1663 \backslash
1663 \backslash
1664 hspace*{0mm}
1664 hspace*{0mm}
1665 \end_layout
1665 \end_layout
1666
1666
1667 \end_inset
1667 \end_inset
1668
1668
1669 \InsetSpace ~
1669 \InsetSpace ~
1670 \InsetSpace ~
1670 \InsetSpace ~
1671 \InsetSpace ~
1671 \InsetSpace ~
1672 \InsetSpace ~
1672 \InsetSpace ~
1673 (and server-buffer-clients (server-done)))
1673 (and server-buffer-clients (server-done)))
1674 \newline
1674 \newline
1675
1675
1676 \begin_inset ERT
1676 \begin_inset ERT
1677 status collapsed
1677 status collapsed
1678
1678
1679 \begin_layout Standard
1679 \begin_layout Standard
1680
1680
1681
1681
1682 \backslash
1682 \backslash
1683 hspace*{0mm}
1683 hspace*{0mm}
1684 \end_layout
1684 \end_layout
1685
1685
1686 \end_inset
1686 \end_inset
1687
1687
1688 \InsetSpace ~
1688 \InsetSpace ~
1689 \InsetSpace ~
1689 \InsetSpace ~
1690 (add-hook 'kill-buffer-hook 'fp-kill-server-with-buffer-routine))
1690 (add-hook 'kill-buffer-hook 'fp-kill-server-with-buffer-routine))
1691 \end_layout
1691 \end_layout
1692
1692
1693 \begin_layout Standard
1693 \begin_layout Standard
1694 You can also set the value of this editor via the commmand-line option '-
1694 You can also set the value of this editor via the commmand-line option '-
1695 \family typewriter
1695 \family typewriter
1696 editor'
1696 editor'
1697 \family default
1697 \family default
1698 or in your
1698 or in your
1699 \family typewriter
1699 \family typewriter
1700 ipythonrc
1700 ipythonrc
1701 \family default
1701 \family default
1702 file.
1702 file.
1703 This is useful if you wish to use specifically for IPython an editor different
1703 This is useful if you wish to use specifically for IPython an editor different
1704 from your typical default (and for Windows users who tend to use fewer
1704 from your typical default (and for Windows users who tend to use fewer
1705 environment variables).
1705 environment variables).
1706 \end_layout
1706 \end_layout
1707
1707
1708 \begin_layout Subsection
1708 \begin_layout Subsection
1709 Color
1709 Color
1710 \end_layout
1710 \end_layout
1711
1711
1712 \begin_layout Standard
1712 \begin_layout Standard
1713 The default IPython configuration has most bells and whistles turned on
1713 The default IPython configuration has most bells and whistles turned on
1714 (they're pretty safe).
1714 (they're pretty safe).
1715 But there's one that
1715 But there's one that
1716 \emph on
1716 \emph on
1717 may
1717 may
1718 \emph default
1718 \emph default
1719 cause problems on some systems: the use of color on screen for displaying
1719 cause problems on some systems: the use of color on screen for displaying
1720 information.
1720 information.
1721 This is very useful, since IPython can show prompts and exception tracebacks
1721 This is very useful, since IPython can show prompts and exception tracebacks
1722 with various colors, display syntax-highlighted source code, and in general
1722 with various colors, display syntax-highlighted source code, and in general
1723 make it easier to visually parse information.
1723 make it easier to visually parse information.
1724 \end_layout
1724 \end_layout
1725
1725
1726 \begin_layout Standard
1726 \begin_layout Standard
1727 The following terminals seem to handle the color sequences fine:
1727 The following terminals seem to handle the color sequences fine:
1728 \end_layout
1728 \end_layout
1729
1729
1730 \begin_layout Itemize
1730 \begin_layout Itemize
1731 Linux main text console, KDE Konsole, Gnome Terminal, E-term, rxvt, xterm.
1731 Linux main text console, KDE Konsole, Gnome Terminal, E-term, rxvt, xterm.
1732 \end_layout
1732 \end_layout
1733
1733
1734 \begin_layout Itemize
1734 \begin_layout Itemize
1735 CDE terminal (tested under Solaris).
1735 CDE terminal (tested under Solaris).
1736 This one boldfaces light colors.
1736 This one boldfaces light colors.
1737 \end_layout
1737 \end_layout
1738
1738
1739 \begin_layout Itemize
1739 \begin_layout Itemize
1740 (X)Emacs buffers.
1740 (X)Emacs buffers.
1741 See sec.
1741 See sec.
1742 \begin_inset LatexCommand \ref{sec:emacs}
1742 \begin_inset LatexCommand \ref{sec:emacs}
1743
1743
1744 \end_inset
1744 \end_inset
1745
1745
1746 for more details on using IPython with (X)Emacs.
1746 for more details on using IPython with (X)Emacs.
1747 \end_layout
1747 \end_layout
1748
1748
1749 \begin_layout Itemize
1749 \begin_layout Itemize
1750 A Windows (XP/2k) command prompt
1750 A Windows (XP/2k) command prompt
1751 \emph on
1751 \emph on
1752 with Gary Bishop's support extensions
1752 with Gary Bishop's support extensions
1753 \emph default
1753 \emph default
1754 .
1754 .
1755 Gary's extensions are discussed in Sec.\InsetSpace ~
1755 Gary's extensions are discussed in Sec.\InsetSpace ~
1756
1756
1757 \begin_inset LatexCommand \ref{sub:Under-Windows}
1757 \begin_inset LatexCommand \ref{sub:Under-Windows}
1758
1758
1759 \end_inset
1759 \end_inset
1760
1760
1761 .
1761 .
1762 \end_layout
1762 \end_layout
1763
1763
1764 \begin_layout Itemize
1764 \begin_layout Itemize
1765 A Windows (XP/2k) CygWin shell.
1765 A Windows (XP/2k) CygWin shell.
1766 Although some users have reported problems; it is not clear whether there
1766 Although some users have reported problems; it is not clear whether there
1767 is an issue for everyone or only under specific configurations.
1767 is an issue for everyone or only under specific configurations.
1768 If you have full color support under cygwin, please post to the IPython
1768 If you have full color support under cygwin, please post to the IPython
1769 mailing list so this issue can be resolved for all users.
1769 mailing list so this issue can be resolved for all users.
1770 \end_layout
1770 \end_layout
1771
1771
1772 \begin_layout Standard
1772 \begin_layout Standard
1773 These have shown problems:
1773 These have shown problems:
1774 \end_layout
1774 \end_layout
1775
1775
1776 \begin_layout Itemize
1776 \begin_layout Itemize
1777 Windows command prompt in WinXP/2k logged into a Linux machine via telnet
1777 Windows command prompt in WinXP/2k logged into a Linux machine via telnet
1778 or ssh.
1778 or ssh.
1779 \end_layout
1779 \end_layout
1780
1780
1781 \begin_layout Itemize
1781 \begin_layout Itemize
1782 Windows native command prompt in WinXP/2k,
1782 Windows native command prompt in WinXP/2k,
1783 \emph on
1783 \emph on
1784 without
1784 without
1785 \emph default
1785 \emph default
1786 Gary Bishop's extensions.
1786 Gary Bishop's extensions.
1787 Once Gary's readline library is installed, the normal WinXP/2k command
1787 Once Gary's readline library is installed, the normal WinXP/2k command
1788 prompt works perfectly.
1788 prompt works perfectly.
1789 \end_layout
1789 \end_layout
1790
1790
1791 \begin_layout Standard
1791 \begin_layout Standard
1792 Currently the following color schemes are available:
1792 Currently the following color schemes are available:
1793 \end_layout
1793 \end_layout
1794
1794
1795 \begin_layout Itemize
1795 \begin_layout Itemize
1796
1796
1797 \family typewriter
1797 \family typewriter
1798 NoColor
1798 NoColor
1799 \family default
1799 \family default
1800 : uses no color escapes at all (all escapes are empty
1800 : uses no color escapes at all (all escapes are empty
1801 \begin_inset Quotes eld
1801 \begin_inset Quotes eld
1802 \end_inset
1802 \end_inset
1803
1803
1804
1804
1805 \begin_inset Quotes eld
1805 \begin_inset Quotes eld
1806 \end_inset
1806 \end_inset
1807
1807
1808 strings).
1808 strings).
1809 This 'scheme' is thus fully safe to use in any terminal.
1809 This 'scheme' is thus fully safe to use in any terminal.
1810 \end_layout
1810 \end_layout
1811
1811
1812 \begin_layout Itemize
1812 \begin_layout Itemize
1813
1813
1814 \family typewriter
1814 \family typewriter
1815 Linux
1815 Linux
1816 \family default
1816 \family default
1817 : works well in Linux console type environments: dark background with light
1817 : works well in Linux console type environments: dark background with light
1818 fonts.
1818 fonts.
1819 It uses bright colors for information, so it is difficult to read if you
1819 It uses bright colors for information, so it is difficult to read if you
1820 have a light colored background.
1820 have a light colored background.
1821 \end_layout
1821 \end_layout
1822
1822
1823 \begin_layout Itemize
1823 \begin_layout Itemize
1824
1824
1825 \family typewriter
1825 \family typewriter
1826 LightBG
1826 LightBG
1827 \family default
1827 \family default
1828 : the basic colors are similar to those in the
1828 : the basic colors are similar to those in the
1829 \family typewriter
1829 \family typewriter
1830 Linux
1830 Linux
1831 \family default
1831 \family default
1832 scheme but darker.
1832 scheme but darker.
1833 It is easy to read in terminals with light backgrounds.
1833 It is easy to read in terminals with light backgrounds.
1834 \end_layout
1834 \end_layout
1835
1835
1836 \begin_layout Standard
1836 \begin_layout Standard
1837 IPython uses colors for two main groups of things: prompts and tracebacks
1837 IPython uses colors for two main groups of things: prompts and tracebacks
1838 which are directly printed to the terminal, and the object introspection
1838 which are directly printed to the terminal, and the object introspection
1839 system which passes large sets of data through a pager.
1839 system which passes large sets of data through a pager.
1840 \end_layout
1840 \end_layout
1841
1841
1842 \begin_layout Subsubsection
1842 \begin_layout Subsubsection
1843 Input/Output prompts and exception tracebacks
1843 Input/Output prompts and exception tracebacks
1844 \end_layout
1844 \end_layout
1845
1845
1846 \begin_layout Standard
1846 \begin_layout Standard
1847 You can test whether the colored prompts and tracebacks work on your system
1847 You can test whether the colored prompts and tracebacks work on your system
1848 interactively by typing
1848 interactively by typing
1849 \family typewriter
1849 \family typewriter
1850 '%colors Linux'
1850 '%colors Linux'
1851 \family default
1851 \family default
1852 at the prompt (use '
1852 at the prompt (use '
1853 \family typewriter
1853 \family typewriter
1854 %colors LightBG'
1854 %colors LightBG'
1855 \family default
1855 \family default
1856 if your terminal has a light background).
1856 if your terminal has a light background).
1857 If the input prompt shows garbage like:
1857 If the input prompt shows garbage like:
1858 \newline
1858 \newline
1859
1859
1860 \family typewriter
1860 \family typewriter
1861 [0;32mIn [[1;32m1[0;32m]: [0;00m
1861 [0;32mIn [[1;32m1[0;32m]: [0;00m
1862 \family default
1862 \family default
1863
1863
1864 \newline
1864 \newline
1865 instead of (in color) something like:
1865 instead of (in color) something like:
1866 \newline
1866 \newline
1867
1867
1868 \family typewriter
1868 \family typewriter
1869 In [1]:
1869 In [1]:
1870 \family default
1870 \family default
1871
1871
1872 \newline
1872 \newline
1873 this means that your terminal doesn't properly handle color escape sequences.
1873 this means that your terminal doesn't properly handle color escape sequences.
1874 You can go to a 'no color' mode by typing '
1874 You can go to a 'no color' mode by typing '
1875 \family typewriter
1875 \family typewriter
1876 %colors NoColor
1876 %colors NoColor
1877 \family default
1877 \family default
1878 '.
1878 '.
1879
1879
1880 \end_layout
1880 \end_layout
1881
1881
1882 \begin_layout Standard
1882 \begin_layout Standard
1883 You can try using a different terminal emulator program (Emacs users, see
1883 You can try using a different terminal emulator program (Emacs users, see
1884 below).
1884 below).
1885 To permanently set your color preferences, edit the file
1885 To permanently set your color preferences, edit the file
1886 \family typewriter
1886 \family typewriter
1887 $HOME/.ipython/ipythonrc
1887 $HOME/.ipython/ipythonrc
1888 \family default
1888 \family default
1889 and set the
1889 and set the
1890 \family typewriter
1890 \family typewriter
1891 colors
1891 colors
1892 \family default
1892 \family default
1893 option to the desired value.
1893 option to the desired value.
1894 \end_layout
1894 \end_layout
1895
1895
1896 \begin_layout Subsubsection
1896 \begin_layout Subsubsection
1897 Object details (types, docstrings, source code, etc.)
1897 Object details (types, docstrings, source code, etc.)
1898 \end_layout
1898 \end_layout
1899
1899
1900 \begin_layout Standard
1900 \begin_layout Standard
1901 IPython has a set of special functions for studying the objects you are
1901 IPython has a set of special functions for studying the objects you are
1902 working with, discussed in detail in Sec.
1902 working with, discussed in detail in Sec.
1903
1903
1904 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1904 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1905
1905
1906 \end_inset
1906 \end_inset
1907
1907
1908 .
1908 .
1909 But this system relies on passing information which is longer than your
1909 But this system relies on passing information which is longer than your
1910 screen through a data pager, such as the common Unix
1910 screen through a data pager, such as the common Unix
1911 \family typewriter
1911 \family typewriter
1912 less
1912 less
1913 \family default
1913 \family default
1914 and
1914 and
1915 \family typewriter
1915 \family typewriter
1916 more
1916 more
1917 \family default
1917 \family default
1918 programs.
1918 programs.
1919 In order to be able to see this information in color, your pager needs
1919 In order to be able to see this information in color, your pager needs
1920 to be properly configured.
1920 to be properly configured.
1921 I strongly recommend using
1921 I strongly recommend using
1922 \family typewriter
1922 \family typewriter
1923 less
1923 less
1924 \family default
1924 \family default
1925 instead of
1925 instead of
1926 \family typewriter
1926 \family typewriter
1927 more
1927 more
1928 \family default
1928 \family default
1929 , as it seems that
1929 , as it seems that
1930 \family typewriter
1930 \family typewriter
1931 more
1931 more
1932 \family default
1932 \family default
1933 simply can not understand colored text correctly.
1933 simply can not understand colored text correctly.
1934 \end_layout
1934 \end_layout
1935
1935
1936 \begin_layout Standard
1936 \begin_layout Standard
1937 In order to configure
1937 In order to configure
1938 \family typewriter
1938 \family typewriter
1939 less
1939 less
1940 \family default
1940 \family default
1941 as your default pager, do the following:
1941 as your default pager, do the following:
1942 \end_layout
1942 \end_layout
1943
1943
1944 \begin_layout Enumerate
1944 \begin_layout Enumerate
1945 Set the environment
1945 Set the environment
1946 \family typewriter
1946 \family typewriter
1947 PAGER
1947 PAGER
1948 \family default
1948 \family default
1949 variable to
1949 variable to
1950 \family typewriter
1950 \family typewriter
1951 less
1951 less
1952 \family default
1952 \family default
1953 .
1953 .
1954 \end_layout
1954 \end_layout
1955
1955
1956 \begin_layout Enumerate
1956 \begin_layout Enumerate
1957 Set the environment
1957 Set the environment
1958 \family typewriter
1958 \family typewriter
1959 LESS
1959 LESS
1960 \family default
1960 \family default
1961 variable to
1961 variable to
1962 \family typewriter
1962 \family typewriter
1963 -r
1963 -r
1964 \family default
1964 \family default
1965 (plus any other options you always want to pass to
1965 (plus any other options you always want to pass to
1966 \family typewriter
1966 \family typewriter
1967 less
1967 less
1968 \family default
1968 \family default
1969 by default).
1969 by default).
1970 This tells
1970 This tells
1971 \family typewriter
1971 \family typewriter
1972 less
1972 less
1973 \family default
1973 \family default
1974 to properly interpret control sequences, which is how color information
1974 to properly interpret control sequences, which is how color information
1975 is given to your terminal.
1975 is given to your terminal.
1976 \end_layout
1976 \end_layout
1977
1977
1978 \begin_layout Standard
1978 \begin_layout Standard
1979 For the
1979 For the
1980 \family typewriter
1980 \family typewriter
1981 csh
1981 csh
1982 \family default
1982 \family default
1983 or
1983 or
1984 \family typewriter
1984 \family typewriter
1985 tcsh
1985 tcsh
1986 \family default
1986 \family default
1987 shells, add to your
1987 shells, add to your
1988 \family typewriter
1988 \family typewriter
1989 ~/.cshrc
1989 ~/.cshrc
1990 \family default
1990 \family default
1991 file the lines:
1991 file the lines:
1992 \end_layout
1992 \end_layout
1993
1993
1994 \begin_layout Standard
1994 \begin_layout Standard
1995
1995
1996 \family typewriter
1996 \family typewriter
1997 setenv PAGER less
1997 setenv PAGER less
1998 \newline
1998 \newline
1999 setenv LESS -r
1999 setenv LESS -r
2000 \end_layout
2000 \end_layout
2001
2001
2002 \begin_layout Standard
2002 \begin_layout Standard
2003 There is similar syntax for other Unix shells, look at your system documentation
2003 There is similar syntax for other Unix shells, look at your system documentation
2004 for details.
2004 for details.
2005 \end_layout
2005 \end_layout
2006
2006
2007 \begin_layout Standard
2007 \begin_layout Standard
2008 If you are on a system which lacks proper data pagers (such as Windows),
2008 If you are on a system which lacks proper data pagers (such as Windows),
2009 IPython will use a very limited builtin pager.
2009 IPython will use a very limited builtin pager.
2010 \end_layout
2010 \end_layout
2011
2011
2012 \begin_layout Subsection
2012 \begin_layout Subsection
2013 \begin_inset LatexCommand \label{sec:emacs}
2013 \begin_inset LatexCommand \label{sec:emacs}
2014
2014
2015 \end_inset
2015 \end_inset
2016
2016
2017 (X)Emacs configuration
2017 (X)Emacs configuration
2018 \end_layout
2018 \end_layout
2019
2019
2020 \begin_layout Standard
2020 \begin_layout Standard
2021 Thanks to the work of Alexander Schmolck and Prabhu Ramachandran, currently
2021 Thanks to the work of Alexander Schmolck and Prabhu Ramachandran, currently
2022 (X)Emacs and IPython get along very well.
2022 (X)Emacs and IPython get along very well.
2023
2023
2024 \end_layout
2024 \end_layout
2025
2025
2026 \begin_layout Standard
2026 \begin_layout Standard
2027
2027
2028 \series bold
2028 \series bold
2029 Important note:
2029 Important note:
2030 \series default
2030 \series default
2031 You will need to use a recent enough version of
2031 You will need to use a recent enough version of
2032 \family typewriter
2032 \family typewriter
2033 python-mode.el
2033 python-mode.el
2034 \family default
2034 \family default
2035 , along with the file
2035 , along with the file
2036 \family typewriter
2036 \family typewriter
2037 ipython.el
2037 ipython.el
2038 \family default
2038 \family default
2039 .
2039 .
2040 You can check that the version you have of
2040 You can check that the version you have of
2041 \family typewriter
2041 \family typewriter
2042 python-mode.el
2042 python-mode.el
2043 \family default
2043 \family default
2044 is new enough by either looking at the revision number in the file itself,
2044 is new enough by either looking at the revision number in the file itself,
2045 or asking for it in (X)Emacs via
2045 or asking for it in (X)Emacs via
2046 \family typewriter
2046 \family typewriter
2047 M-x py-version
2047 M-x py-version
2048 \family default
2048 \family default
2049 .
2049 .
2050 Versions 4.68 and newer contain the necessary fixes for proper IPython support.
2050 Versions 4.68 and newer contain the necessary fixes for proper IPython support.
2051 \end_layout
2051 \end_layout
2052
2052
2053 \begin_layout Standard
2053 \begin_layout Standard
2054 The file
2054 The file
2055 \family typewriter
2055 \family typewriter
2056 ipython.el
2056 ipython.el
2057 \family default
2057 \family default
2058 is included with the IPython distribution, in the documentation directory
2058 is included with the IPython distribution, in the documentation directory
2059 (where this manual resides in PDF and HTML formats).
2059 (where this manual resides in PDF and HTML formats).
2060 \end_layout
2060 \end_layout
2061
2061
2062 \begin_layout Standard
2062 \begin_layout Standard
2063 Once you put these files in your Emacs path, all you need in your
2063 Once you put these files in your Emacs path, all you need in your
2064 \family typewriter
2064 \family typewriter
2065 .emacs
2065 .emacs
2066 \family default
2066 \family default
2067 file is:
2067 file is:
2068 \end_layout
2068 \end_layout
2069
2069
2070 \begin_layout LyX-Code
2070 \begin_layout LyX-Code
2071 (require 'ipython)
2071 (require 'ipython)
2072 \end_layout
2072 \end_layout
2073
2073
2074 \begin_layout Standard
2074 \begin_layout Standard
2075 This should give you full support for executing code snippets via IPython,
2075 This should give you full support for executing code snippets via IPython,
2076 opening IPython as your Python shell via
2076 opening IPython as your Python shell via
2077 \family typewriter
2077 \family typewriter
2078 C-c\InsetSpace ~
2078 C-c\InsetSpace ~
2079 !
2079 !
2080 \family default
2080 \family default
2081 , etc.
2081 , etc.
2082
2082
2083 \end_layout
2083 \end_layout
2084
2084
2085 \begin_layout Standard
2085 \begin_layout Standard
2086 If you happen to get garbage instead of colored prompts as described in
2086 If you happen to get garbage instead of colored prompts as described in
2087 the previous section, you may need to set also in your
2087 the previous section, you may need to set also in your
2088 \family typewriter
2088 \family typewriter
2089 .emacs
2089 .emacs
2090 \family default
2090 \family default
2091 file:
2091 file:
2092 \end_layout
2092 \end_layout
2093
2093
2094 \begin_layout LyX-Code
2094 \begin_layout LyX-Code
2095 (setq ansi-color-for-comint-mode t)
2095 (setq ansi-color-for-comint-mode t)
2096 \end_layout
2096 \end_layout
2097
2097
2098 \begin_layout Subsubsection*
2098 \begin_layout Subsubsection*
2099 Notes
2099 Notes
2100 \end_layout
2100 \end_layout
2101
2101
2102 \begin_layout Itemize
2102 \begin_layout Itemize
2103 There is one caveat you should be aware of: you must start the IPython shell
2103 There is one caveat you should be aware of: you must start the IPython shell
2104
2104
2105 \emph on
2105 \emph on
2106 before
2106 before
2107 \emph default
2107 \emph default
2108 attempting to execute any code regions via
2108 attempting to execute any code regions via
2109 \family typewriter
2109 \family typewriter
2110 C-c\InsetSpace ~
2110 C-c\InsetSpace ~
2111 |
2111 |
2112 \family default
2112 \family default
2113 .
2113 .
2114 Simply type
2114 Simply type
2115 \family typewriter
2115 \family typewriter
2116 C-c\InsetSpace ~
2116 C-c\InsetSpace ~
2117 !
2117 !
2118 \family default
2118 \family default
2119 to start IPython before passing any code regions to the interpreter, and
2119 to start IPython before passing any code regions to the interpreter, and
2120 you shouldn't experience any problems.
2120 you shouldn't experience any problems.
2121 \newline
2121 \newline
2122 This is due to a bug in Python itself,
2122 This is due to a bug in Python itself,
2123 which has been fixed for Python 2.3, but exists as of Python 2.2.2 (reported
2123 which has been fixed for Python 2.3, but exists as of Python 2.2.2 (reported
2124 as SF bug [ 737947 ]).
2124 as SF bug [ 737947 ]).
2125 \end_layout
2125 \end_layout
2126
2126
2127 \begin_layout Itemize
2127 \begin_layout Itemize
2128 The (X)Emacs support is maintained by Alexander Schmolck, so all comments/reques
2128 The (X)Emacs support is maintained by Alexander Schmolck, so all comments/reques
2129 ts should be directed to him through the IPython mailing lists.
2129 ts should be directed to him through the IPython mailing lists.
2130
2130
2131 \end_layout
2131 \end_layout
2132
2132
2133 \begin_layout Itemize
2133 \begin_layout Itemize
2134 This code is still somewhat experimental so it's a bit rough around the
2134 This code is still somewhat experimental so it's a bit rough around the
2135 edges (although in practice, it works quite well).
2135 edges (although in practice, it works quite well).
2136 \end_layout
2136 \end_layout
2137
2137
2138 \begin_layout Itemize
2138 \begin_layout Itemize
2139 Be aware that if you customize
2139 Be aware that if you customize
2140 \family typewriter
2140 \family typewriter
2141 py-python-command
2141 py-python-command
2142 \family default
2142 \family default
2143 previously, this value will override what
2143 previously, this value will override what
2144 \family typewriter
2144 \family typewriter
2145 ipython.el
2145 ipython.el
2146 \family default
2146 \family default
2147 does (because loading the customization variables comes later).
2147 does (because loading the customization variables comes later).
2148 \end_layout
2148 \end_layout
2149
2149
2150 \begin_layout Section
2150 \begin_layout Section
2151 \begin_inset LatexCommand \label{sec:quick_tips}
2151 \begin_inset LatexCommand \label{sec:quick_tips}
2152
2152
2153 \end_inset
2153 \end_inset
2154
2154
2155 Quick tips
2155 Quick tips
2156 \end_layout
2156 \end_layout
2157
2157
2158 \begin_layout Standard
2158 \begin_layout Standard
2159 IPython can be used as an improved replacement for the Python prompt, and
2159 IPython can be used as an improved replacement for the Python prompt, and
2160 for that you don't really need to read any more of this manual.
2160 for that you don't really need to read any more of this manual.
2161 But in this section we'll try to summarize a few tips on how to make the
2161 But in this section we'll try to summarize a few tips on how to make the
2162 most effective use of it for everyday Python development, highlighting
2162 most effective use of it for everyday Python development, highlighting
2163 things you might miss in the rest of the manual (which is getting long).
2163 things you might miss in the rest of the manual (which is getting long).
2164 We'll give references to parts in the manual which provide more detail
2164 We'll give references to parts in the manual which provide more detail
2165 when appropriate.
2165 when appropriate.
2166 \end_layout
2166 \end_layout
2167
2167
2168 \begin_layout Standard
2168 \begin_layout Standard
2169 The following article by Jeremy Jones provides an introductory tutorial
2169 The following article by Jeremy Jones provides an introductory tutorial
2170 about IPython:
2170 about IPython:
2171 \newline
2171 \newline
2172
2172
2173 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2005/01/27/ipython.html}
2173 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2005/01/27/ipython.html}
2174
2174
2175 \end_inset
2175 \end_inset
2176
2176
2177
2177
2178 \end_layout
2178 \end_layout
2179
2179
2180 \begin_layout Itemize
2180 \begin_layout Itemize
2181 The TAB key.
2181 The TAB key.
2182 TAB-completion, especially for attributes, is a convenient way to explore
2182 TAB-completion, especially for attributes, is a convenient way to explore
2183 the structure of any object you're dealing with.
2183 the structure of any object you're dealing with.
2184 Simply type
2184 Simply type
2185 \family typewriter
2185 \family typewriter
2186 object_name.<TAB>
2186 object_name.<TAB>
2187 \family default
2187 \family default
2188 and a list of the object's attributes will be printed (see sec.
2188 and a list of the object's attributes will be printed (see sec.
2189
2189
2190 \begin_inset LatexCommand \ref{sec:readline}
2190 \begin_inset LatexCommand \ref{sec:readline}
2191
2191
2192 \end_inset
2192 \end_inset
2193
2193
2194 for more).
2194 for more).
2195 Tab completion also works on file and directory names, which combined with
2195 Tab completion also works on file and directory names, which combined with
2196 IPython's alias system allows you to do from within IPython many of the
2196 IPython's alias system allows you to do from within IPython many of the
2197 things you normally would need the system shell for.
2197 things you normally would need the system shell for.
2198
2198
2199 \end_layout
2199 \end_layout
2200
2200
2201 \begin_layout Itemize
2201 \begin_layout Itemize
2202 Explore your objects.
2202 Explore your objects.
2203 Typing
2203 Typing
2204 \family typewriter
2204 \family typewriter
2205 object_name?
2205 object_name?
2206 \family default
2206 \family default
2207 will print all sorts of details about any object, including docstrings,
2207 will print all sorts of details about any object, including docstrings,
2208 function definition lines (for call arguments) and constructor details
2208 function definition lines (for call arguments) and constructor details
2209 for classes.
2209 for classes.
2210 The magic commands
2210 The magic commands
2211 \family typewriter
2211 \family typewriter
2212 %pdoc
2212 %pdoc
2213 \family default
2213 \family default
2214 ,
2214 ,
2215 \family typewriter
2215 \family typewriter
2216 %pdef
2216 %pdef
2217 \family default
2217 \family default
2218 ,
2218 ,
2219 \family typewriter
2219 \family typewriter
2220 %psource
2220 %psource
2221 \family default
2221 \family default
2222 and
2222 and
2223 \family typewriter
2223 \family typewriter
2224 %pfile
2224 %pfile
2225 \family default
2225 \family default
2226 will respectively print the docstring, function definition line, full source
2226 will respectively print the docstring, function definition line, full source
2227 code and the complete file for any object (when they can be found).
2227 code and the complete file for any object (when they can be found).
2228 If automagic is on (it is by default), you don't need to type the '
2228 If automagic is on (it is by default), you don't need to type the '
2229 \family typewriter
2229 \family typewriter
2230 %
2230 %
2231 \family default
2231 \family default
2232 ' explicitly.
2232 ' explicitly.
2233 See sec.
2233 See sec.
2234
2234
2235 \begin_inset LatexCommand \ref{sec:dyn-object-info}
2235 \begin_inset LatexCommand \ref{sec:dyn-object-info}
2236
2236
2237 \end_inset
2237 \end_inset
2238
2238
2239 for more.
2239 for more.
2240 \end_layout
2240 \end_layout
2241
2241
2242 \begin_layout Itemize
2242 \begin_layout Itemize
2243 The
2243 The
2244 \family typewriter
2244 \family typewriter
2245 %run
2245 %run
2246 \family default
2246 \family default
2247 magic command allows you to run any python script and load all of its data
2247 magic command allows you to run any python script and load all of its data
2248 directly into the interactive namespace.
2248 directly into the interactive namespace.
2249 Since the file is re-read from disk each time, changes you make to it are
2249 Since the file is re-read from disk each time, changes you make to it are
2250 reflected immediately (in contrast to the behavior of
2250 reflected immediately (in contrast to the behavior of
2251 \family typewriter
2251 \family typewriter
2252 import
2252 import
2253 \family default
2253 \family default
2254 ).
2254 ).
2255 I rarely use
2255 I rarely use
2256 \family typewriter
2256 \family typewriter
2257 import
2257 import
2258 \family default
2258 \family default
2259 for code I am testing, relying on
2259 for code I am testing, relying on
2260 \family typewriter
2260 \family typewriter
2261 %run
2261 %run
2262 \family default
2262 \family default
2263 instead.
2263 instead.
2264 See sec.
2264 See sec.
2265
2265
2266 \begin_inset LatexCommand \ref{sec:magic}
2266 \begin_inset LatexCommand \ref{sec:magic}
2267
2267
2268 \end_inset
2268 \end_inset
2269
2269
2270 for more on this and other magic commands, or type the name of any magic
2270 for more on this and other magic commands, or type the name of any magic
2271 command and ? to get details on it.
2271 command and ? to get details on it.
2272 See also sec.
2272 See also sec.
2273
2273
2274 \begin_inset LatexCommand \ref{sec:dreload}
2274 \begin_inset LatexCommand \ref{sec:dreload}
2275
2275
2276 \end_inset
2276 \end_inset
2277
2277
2278 for a recursive reload command.
2278 for a recursive reload command.
2279 \newline
2279 \newline
2280
2280
2281 \family typewriter
2281 \family typewriter
2282 %run
2282 %run
2283 \family default
2283 \family default
2284 also has special flags for timing the execution of your scripts (
2284 also has special flags for timing the execution of your scripts (
2285 \family typewriter
2285 \family typewriter
2286 -t
2286 -t
2287 \family default
2287 \family default
2288 ) and for executing them under the control of either Python's
2288 ) and for executing them under the control of either Python's
2289 \family typewriter
2289 \family typewriter
2290 pdb
2290 pdb
2291 \family default
2291 \family default
2292 debugger (
2292 debugger (
2293 \family typewriter
2293 \family typewriter
2294 -d
2294 -d
2295 \family default
2295 \family default
2296 ) or profiler (
2296 ) or profiler (
2297 \family typewriter
2297 \family typewriter
2298 -p
2298 -p
2299 \family default
2299 \family default
2300 ).
2300 ).
2301 With all of these,
2301 With all of these,
2302 \family typewriter
2302 \family typewriter
2303 %run
2303 %run
2304 \family default
2304 \family default
2305 can be used as the main tool for efficient interactive development of code
2305 can be used as the main tool for efficient interactive development of code
2306 which you write in your editor of choice.
2306 which you write in your editor of choice.
2307 \end_layout
2307 \end_layout
2308
2308
2309 \begin_layout Itemize
2309 \begin_layout Itemize
2310 Use the Python debugger,
2310 Use the Python debugger,
2311 \family typewriter
2311 \family typewriter
2312 pdb
2312 pdb
2313 \family default
2313 \family default
2314
2314
2315 \begin_inset Foot
2315 \begin_inset Foot
2316 status collapsed
2316 status collapsed
2317
2317
2318 \begin_layout Standard
2318 \begin_layout Standard
2319 Thanks to Christian Hart and Matthew Arnison for the suggestions leading
2319 Thanks to Christian Hart and Matthew Arnison for the suggestions leading
2320 to IPython's improved debugger and profiler support.
2320 to IPython's improved debugger and profiler support.
2321 \end_layout
2321 \end_layout
2322
2322
2323 \end_inset
2323 \end_inset
2324
2324
2325 .
2325 .
2326 The
2326 The
2327 \family typewriter
2327 \family typewriter
2328 %pdb
2328 %pdb
2329 \family default
2329 \family default
2330 command allows you to toggle on and off the automatic invocation of an
2330 command allows you to toggle on and off the automatic invocation of an
2331 IPython-enhanced
2331 IPython-enhanced
2332 \family typewriter
2332 \family typewriter
2333 pdb
2333 pdb
2334 \family default
2334 \family default
2335 debugger (with coloring, tab completion and more) at any uncaught exception.
2335 debugger (with coloring, tab completion and more) at any uncaught exception.
2336 The advantage of this is that
2336 The advantage of this is that
2337 \family typewriter
2337 \family typewriter
2338 pdb
2338 pdb
2339 \family default
2339 \family default
2340 starts
2340 starts
2341 \emph on
2341 \emph on
2342 inside
2342 inside
2343 \emph default
2343 \emph default
2344 the function where the exception occurred, with all data still available.
2344 the function where the exception occurred, with all data still available.
2345 You can print variables, see code, execute statements and even walk up
2345 You can print variables, see code, execute statements and even walk up
2346 and down the call stack to track down the true source of the problem (which
2346 and down the call stack to track down the true source of the problem (which
2347 often is many layers in the stack above where the exception gets triggered).
2347 often is many layers in the stack above where the exception gets triggered).
2348 \newline
2348 \newline
2349 Runn
2349 Runn
2350 ing programs with
2350 ing programs with
2351 \family typewriter
2351 \family typewriter
2352 %run
2352 %run
2353 \family default
2353 \family default
2354 and pdb active can be an efficient to develop and debug code, in many cases
2354 and pdb active can be an efficient to develop and debug code, in many cases
2355 eliminating the need for
2355 eliminating the need for
2356 \family typewriter
2356 \family typewriter
2357 print
2357 print
2358 \family default
2358 \family default
2359 statements or external debugging tools.
2359 statements or external debugging tools.
2360 I often simply put a
2360 I often simply put a
2361 \family typewriter
2361 \family typewriter
2362 1/0
2362 1/0
2363 \family default
2363 \family default
2364 in a place where I want to take a look so that pdb gets called, quickly
2364 in a place where I want to take a look so that pdb gets called, quickly
2365 view whatever variables I need to or test various pieces of code and then
2365 view whatever variables I need to or test various pieces of code and then
2366 remove the
2366 remove the
2367 \family typewriter
2367 \family typewriter
2368 1/0
2368 1/0
2369 \family default
2369 \family default
2370 .
2370 .
2371 \newline
2371 \newline
2372 Note also that `
2372 Note also that `
2373 \family typewriter
2373 \family typewriter
2374 %run -d
2374 %run -d
2375 \family default
2375 \family default
2376 ' activates
2376 ' activates
2377 \family typewriter
2377 \family typewriter
2378 pdb
2378 pdb
2379 \family default
2379 \family default
2380 and automatically sets initial breakpoints for you to step through your
2380 and automatically sets initial breakpoints for you to step through your
2381 code, watch variables, etc.
2381 code, watch variables, etc.
2382 See Sec.\InsetSpace ~
2382 See Sec.\InsetSpace ~
2383
2383
2384 \begin_inset LatexCommand \ref{sec:cache_output}
2384 \begin_inset LatexCommand \ref{sec:cache_output}
2385
2385
2386 \end_inset
2386 \end_inset
2387
2387
2388 for details.
2388 for details.
2389 \end_layout
2389 \end_layout
2390
2390
2391 \begin_layout Itemize
2391 \begin_layout Itemize
2392 Use the output cache.
2392 Use the output cache.
2393 All output results are automatically stored in a global dictionary named
2393 All output results are automatically stored in a global dictionary named
2394
2394
2395 \family typewriter
2395 \family typewriter
2396 Out
2396 Out
2397 \family default
2397 \family default
2398 and variables named
2398 and variables named
2399 \family typewriter
2399 \family typewriter
2400 _1
2400 _1
2401 \family default
2401 \family default
2402 ,
2402 ,
2403 \family typewriter
2403 \family typewriter
2404 _2
2404 _2
2405 \family default
2405 \family default
2406 , etc.
2406 , etc.
2407 alias them.
2407 alias them.
2408 For example, the result of input line 4 is available either as
2408 For example, the result of input line 4 is available either as
2409 \family typewriter
2409 \family typewriter
2410 Out[4]
2410 Out[4]
2411 \family default
2411 \family default
2412 or as
2412 or as
2413 \family typewriter
2413 \family typewriter
2414 _4
2414 _4
2415 \family default
2415 \family default
2416 .
2416 .
2417 Additionally, three variables named
2417 Additionally, three variables named
2418 \family typewriter
2418 \family typewriter
2419 _
2419 _
2420 \family default
2420 \family default
2421 ,
2421 ,
2422 \family typewriter
2422 \family typewriter
2423 __
2423 __
2424 \family default
2424 \family default
2425 and
2425 and
2426 \family typewriter
2426 \family typewriter
2427 ___
2427 ___
2428 \family default
2428 \family default
2429 are always kept updated with the for the last three results.
2429 are always kept updated with the for the last three results.
2430 This allows you to recall any previous result and further use it for new
2430 This allows you to recall any previous result and further use it for new
2431 calculations.
2431 calculations.
2432 See Sec.\InsetSpace ~
2432 See Sec.\InsetSpace ~
2433
2433
2434 \begin_inset LatexCommand \ref{sec:cache_output}
2434 \begin_inset LatexCommand \ref{sec:cache_output}
2435
2435
2436 \end_inset
2436 \end_inset
2437
2437
2438 for more.
2438 for more.
2439 \end_layout
2439 \end_layout
2440
2440
2441 \begin_layout Itemize
2441 \begin_layout Itemize
2442 Put a '
2442 Put a '
2443 \family typewriter
2443 \family typewriter
2444 ;
2444 ;
2445 \family default
2445 \family default
2446 ' at the end of a line to supress the printing of output.
2446 ' at the end of a line to supress the printing of output.
2447 This is useful when doing calculations which generate long output you are
2447 This is useful when doing calculations which generate long output you are
2448 not interested in seeing.
2448 not interested in seeing.
2449 The
2449 The
2450 \family typewriter
2450 \family typewriter
2451 _*
2451 _*
2452 \family default
2452 \family default
2453 variables and the
2453 variables and the
2454 \family typewriter
2454 \family typewriter
2455 Out[]
2455 Out[]
2456 \family default
2456 \family default
2457 list do get updated with the contents of the output, even if it is not
2457 list do get updated with the contents of the output, even if it is not
2458 printed.
2458 printed.
2459 You can thus still access the generated results this way for further processing.
2459 You can thus still access the generated results this way for further processing.
2460 \end_layout
2460 \end_layout
2461
2461
2462 \begin_layout Itemize
2462 \begin_layout Itemize
2463 A similar system exists for caching input.
2463 A similar system exists for caching input.
2464 All input is stored in a global list called
2464 All input is stored in a global list called
2465 \family typewriter
2465 \family typewriter
2466 In
2466 In
2467 \family default
2467 \family default
2468 , so you can re-execute lines 22 through 28 plus line 34 by typing
2468 , so you can re-execute lines 22 through 28 plus line 34 by typing
2469 \family typewriter
2469 \family typewriter
2470 'exec In[22:29]+In[34]'
2470 'exec In[22:29]+In[34]'
2471 \family default
2471 \family default
2472 (using Python slicing notation).
2472 (using Python slicing notation).
2473 If you need to execute the same set of lines often, you can assign them
2473 If you need to execute the same set of lines often, you can assign them
2474 to a macro with the
2474 to a macro with the
2475 \family typewriter
2475 \family typewriter
2476 %macro
2476 %macro
2477 \family default
2477 \family default
2478
2478
2479 \family typewriter
2479 \family typewriter
2480 function.
2480 function.
2481
2481
2482 \family default
2482 \family default
2483 See sec.
2483 See sec.
2484
2484
2485 \begin_inset LatexCommand \ref{sec:cache_input}
2485 \begin_inset LatexCommand \ref{sec:cache_input}
2486
2486
2487 \end_inset
2487 \end_inset
2488
2488
2489 for more.
2489 for more.
2490 \end_layout
2490 \end_layout
2491
2491
2492 \begin_layout Itemize
2492 \begin_layout Itemize
2493 Use your input history.
2493 Use your input history.
2494 The
2494 The
2495 \family typewriter
2495 \family typewriter
2496 %hist
2496 %hist
2497 \family default
2497 \family default
2498 command can show you all previous input, without line numbers if desired
2498 command can show you all previous input, without line numbers if desired
2499 (option
2499 (option
2500 \family typewriter
2500 \family typewriter
2501 -n
2501 -n
2502 \family default
2502 \family default
2503 ) so you can directly copy and paste code either back in IPython or in a
2503 ) so you can directly copy and paste code either back in IPython or in a
2504 text editor.
2504 text editor.
2505 You can also save all your history by turning on logging via
2505 You can also save all your history by turning on logging via
2506 \family typewriter
2506 \family typewriter
2507 %logstart
2507 %logstart
2508 \family default
2508 \family default
2509 ; these logs can later be either reloaded as IPython sessions or used as
2509 ; these logs can later be either reloaded as IPython sessions or used as
2510 code for your programs.
2510 code for your programs.
2511 \end_layout
2511 \end_layout
2512
2512
2513 \begin_layout Itemize
2513 \begin_layout Itemize
2514 Define your own system aliases.
2514 Define your own system aliases.
2515 Even though IPython gives you access to your system shell via the
2515 Even though IPython gives you access to your system shell via the
2516 \family typewriter
2516 \family typewriter
2517 !
2517 !
2518 \family default
2518 \family default
2519 prefix, it is convenient to have aliases to the system commands you use
2519 prefix, it is convenient to have aliases to the system commands you use
2520 most often.
2520 most often.
2521 This allows you to work seamlessly from inside IPython with the same commands
2521 This allows you to work seamlessly from inside IPython with the same commands
2522 you are used to in your system shell.
2522 you are used to in your system shell.
2523 \newline
2523 \newline
2524 IPython comes with some pre-defined
2524 IPython comes with some pre-defined
2525 aliases and a complete system for changing directories, both via a stack
2525 aliases and a complete system for changing directories, both via a stack
2526 (see
2526 (see
2527 \family typewriter
2527 \family typewriter
2528 %pushd
2528 %pushd
2529 \family default
2529 \family default
2530 ,
2530 ,
2531 \family typewriter
2531 \family typewriter
2532 %popd
2532 %popd
2533 \family default
2533 \family default
2534 and
2534 and
2535 \family typewriter
2535 \family typewriter
2536 %dhist
2536 %dhist
2537 \family default
2537 \family default
2538 ) and via direct
2538 ) and via direct
2539 \family typewriter
2539 \family typewriter
2540 %cd
2540 %cd
2541 \family default
2541 \family default
2542 .
2542 .
2543 The latter keeps a history of visited directories and allows you to go
2543 The latter keeps a history of visited directories and allows you to go
2544 to any previously visited one.
2544 to any previously visited one.
2545 \end_layout
2545 \end_layout
2546
2546
2547 \begin_layout Itemize
2547 \begin_layout Itemize
2548 Use Python to manipulate the results of system commands.
2548 Use Python to manipulate the results of system commands.
2549 The `
2549 The `
2550 \family typewriter
2550 \family typewriter
2551 !!
2551 !!
2552 \family default
2552 \family default
2553 ' special syntax, and the
2553 ' special syntax, and the
2554 \family typewriter
2554 \family typewriter
2555 %sc
2555 %sc
2556 \family default
2556 \family default
2557 and
2557 and
2558 \family typewriter
2558 \family typewriter
2559 %sx
2559 %sx
2560 \family default
2560 \family default
2561 magic commands allow you to capture system output into Python variables.
2561 magic commands allow you to capture system output into Python variables.
2562 \end_layout
2562 \end_layout
2563
2563
2564 \begin_layout Itemize
2564 \begin_layout Itemize
2565 Expand python variables when calling the shell (either via
2565 Expand python variables when calling the shell (either via
2566 \family typewriter
2566 \family typewriter
2567 `!'
2567 `!'
2568 \family default
2568 \family default
2569 and
2569 and
2570 \family typewriter
2570 \family typewriter
2571 `!!'
2571 `!!'
2572 \family default
2572 \family default
2573 or via aliases) by prepending a
2573 or via aliases) by prepending a
2574 \family typewriter
2574 \family typewriter
2575 $
2575 $
2576 \family default
2576 \family default
2577 in front of them.
2577 in front of them.
2578 You can also expand complete python expressions.
2578 You can also expand complete python expressions.
2579 See sec.\InsetSpace ~
2579 See sec.\InsetSpace ~
2580
2580
2581 \begin_inset LatexCommand \ref{sub:System-shell-access}
2581 \begin_inset LatexCommand \ref{sub:System-shell-access}
2582
2582
2583 \end_inset
2583 \end_inset
2584
2584
2585 for more.
2585 for more.
2586 \end_layout
2586 \end_layout
2587
2587
2588 \begin_layout Itemize
2588 \begin_layout Itemize
2589 Use profiles to maintain different configurations (modules to load, function
2589 Use profiles to maintain different configurations (modules to load, function
2590 definitions, option settings) for particular tasks.
2590 definitions, option settings) for particular tasks.
2591 You can then have customized versions of IPython for specific purposes.
2591 You can then have customized versions of IPython for specific purposes.
2592 See sec.\InsetSpace ~
2592 See sec.\InsetSpace ~
2593
2593
2594 \begin_inset LatexCommand \ref{sec:profiles}
2594 \begin_inset LatexCommand \ref{sec:profiles}
2595
2595
2596 \end_inset
2596 \end_inset
2597
2597
2598 for more.
2598 for more.
2599 \end_layout
2599 \end_layout
2600
2600
2601 \begin_layout Itemize
2601 \begin_layout Itemize
2602 Embed IPython in your programs.
2602 Embed IPython in your programs.
2603 A few lines of code are enough to load a complete IPython inside your own
2603 A few lines of code are enough to load a complete IPython inside your own
2604 programs, giving you the ability to work with your data interactively after
2604 programs, giving you the ability to work with your data interactively after
2605 automatic processing has been completed.
2605 automatic processing has been completed.
2606 See sec.\InsetSpace ~
2606 See sec.\InsetSpace ~
2607
2607
2608 \begin_inset LatexCommand \ref{sec:embed}
2608 \begin_inset LatexCommand \ref{sec:embed}
2609
2609
2610 \end_inset
2610 \end_inset
2611
2611
2612 for more.
2612 for more.
2613 \end_layout
2613 \end_layout
2614
2614
2615 \begin_layout Itemize
2615 \begin_layout Itemize
2616 Use the Python profiler.
2616 Use the Python profiler.
2617 When dealing with performance issues, the
2617 When dealing with performance issues, the
2618 \family typewriter
2618 \family typewriter
2619 %run
2619 %run
2620 \family default
2620 \family default
2621 command with a
2621 command with a
2622 \family typewriter
2622 \family typewriter
2623 -p
2623 -p
2624 \family default
2624 \family default
2625 option allows you to run complete programs under the control of the Python
2625 option allows you to run complete programs under the control of the Python
2626 profiler.
2626 profiler.
2627 The
2627 The
2628 \family typewriter
2628 \family typewriter
2629 %prun
2629 %prun
2630 \family default
2630 \family default
2631 command does a similar job for single Python expressions (like function
2631 command does a similar job for single Python expressions (like function
2632 calls).
2632 calls).
2633 \end_layout
2633 \end_layout
2634
2634
2635 \begin_layout Itemize
2635 \begin_layout Itemize
2636 Use the IPython.demo.Demo class to load any Python script as an interactive
2636 Use the IPython.demo.Demo class to load any Python script as an interactive
2637 demo.
2637 demo.
2638 With a minimal amount of simple markup, you can control the execution of
2638 With a minimal amount of simple markup, you can control the execution of
2639 the script, stopping as needed.
2639 the script, stopping as needed.
2640 See sec.\InsetSpace ~
2640 See sec.\InsetSpace ~
2641
2641
2642 \begin_inset LatexCommand \ref{sec:interactive-demos}
2642 \begin_inset LatexCommand \ref{sec:interactive-demos}
2643
2643
2644 \end_inset
2644 \end_inset
2645
2645
2646 for more.
2646 for more.
2647 \end_layout
2647 \end_layout
2648
2648
2649 \begin_layout Subsection
2649 \begin_layout Subsection
2650 Source code handling tips
2650 Source code handling tips
2651 \end_layout
2651 \end_layout
2652
2652
2653 \begin_layout Standard
2653 \begin_layout Standard
2654 IPython is a line-oriented program, without full control of the terminal.
2654 IPython is a line-oriented program, without full control of the terminal.
2655 Therefore, it doesn't support true multiline editing.
2655 Therefore, it doesn't support true multiline editing.
2656 However, it has a number of useful tools to help you in dealing effectively
2656 However, it has a number of useful tools to help you in dealing effectively
2657 with more complex editing.
2657 with more complex editing.
2658 \end_layout
2658 \end_layout
2659
2659
2660 \begin_layout Standard
2660 \begin_layout Standard
2661 The
2661 The
2662 \family typewriter
2662 \family typewriter
2663 %edit
2663 %edit
2664 \family default
2664 \family default
2665 command gives a reasonable approximation of multiline editing, by invoking
2665 command gives a reasonable approximation of multiline editing, by invoking
2666 your favorite editor on the spot.
2666 your favorite editor on the spot.
2667 IPython will execute the code you type in there as if it were typed interactive
2667 IPython will execute the code you type in there as if it were typed interactive
2668 ly.
2668 ly.
2669 Type
2669 Type
2670 \family typewriter
2670 \family typewriter
2671 %edit?
2671 %edit?
2672 \family default
2672 \family default
2673 for the full details on the edit command.
2673 for the full details on the edit command.
2674 \end_layout
2674 \end_layout
2675
2675
2676 \begin_layout Standard
2676 \begin_layout Standard
2677 If you have typed various commands during a session, which you'd like to
2677 If you have typed various commands during a session, which you'd like to
2678 reuse, IPython provides you with a number of tools.
2678 reuse, IPython provides you with a number of tools.
2679 Start by using
2679 Start by using
2680 \family typewriter
2680 \family typewriter
2681 %hist
2681 %hist
2682 \family default
2682 \family default
2683 to see your input history, so you can see the line numbers of all input.
2683 to see your input history, so you can see the line numbers of all input.
2684 Let us say that you'd like to reuse lines 10 through 20, plus lines 24
2684 Let us say that you'd like to reuse lines 10 through 20, plus lines 24
2685 and 28.
2685 and 28.
2686 All the commands below can operate on these with the syntax
2686 All the commands below can operate on these with the syntax
2687 \end_layout
2687 \end_layout
2688
2688
2689 \begin_layout LyX-Code
2689 \begin_layout LyX-Code
2690 %command 10-20 24 28
2690 %command 10-20 24 28
2691 \end_layout
2691 \end_layout
2692
2692
2693 \begin_layout Standard
2693 \begin_layout Standard
2694 where the command given can be:
2694 where the command given can be:
2695 \end_layout
2695 \end_layout
2696
2696
2697 \begin_layout Itemize
2697 \begin_layout Itemize
2698
2698
2699 \family typewriter
2699 \family typewriter
2700 %macro <macroname>
2700 %macro <macroname>
2701 \family default
2701 \family default
2702 : this stores the lines into a variable which, when called at the prompt,
2702 : this stores the lines into a variable which, when called at the prompt,
2703 re-executes the input.
2703 re-executes the input.
2704 Macros can be edited later using
2704 Macros can be edited later using
2705 \family typewriter
2705 \family typewriter
2706 `%edit macroname
2706 `%edit macroname
2707 \family default
2707 \family default
2708 ', and they can be stored persistently across sessions with `
2708 ', and they can be stored persistently across sessions with `
2709 \family typewriter
2709 \family typewriter
2710 %store macroname
2710 %store macroname
2711 \family default
2711 \family default
2712 ' (the storage system is per-profile).
2712 ' (the storage system is per-profile).
2713 The combination of quick macros, persistent storage and editing, allows
2713 The combination of quick macros, persistent storage and editing, allows
2714 you to easily refine quick-and-dirty interactive input into permanent utilities
2714 you to easily refine quick-and-dirty interactive input into permanent utilities
2715 , always available both in IPython and as files for general reuse.
2715 , always available both in IPython and as files for general reuse.
2716 \end_layout
2716 \end_layout
2717
2717
2718 \begin_layout Itemize
2718 \begin_layout Itemize
2719
2719
2720 \family typewriter
2720 \family typewriter
2721 %edit
2721 %edit
2722 \family default
2722 \family default
2723 : this will open a text editor with those lines pre-loaded for further modificat
2723 : this will open a text editor with those lines pre-loaded for further modificat
2724 ion.
2724 ion.
2725 It will then execute the resulting file's contents as if you had typed
2725 It will then execute the resulting file's contents as if you had typed
2726 it at the prompt.
2726 it at the prompt.
2727 \end_layout
2727 \end_layout
2728
2728
2729 \begin_layout Itemize
2729 \begin_layout Itemize
2730
2730
2731 \family typewriter
2731 \family typewriter
2732 %save <filename>
2732 %save <filename>
2733 \family default
2733 \family default
2734 : this saves the lines directly to a named file on disk.
2734 : this saves the lines directly to a named file on disk.
2735 \end_layout
2735 \end_layout
2736
2736
2737 \begin_layout Standard
2737 \begin_layout Standard
2738 While
2738 While
2739 \family typewriter
2739 \family typewriter
2740 %macro
2740 %macro
2741 \family default
2741 \family default
2742 saves input lines into memory for interactive re-execution, sometimes you'd
2742 saves input lines into memory for interactive re-execution, sometimes you'd
2743 like to save your input directly to a file.
2743 like to save your input directly to a file.
2744 The
2744 The
2745 \family typewriter
2745 \family typewriter
2746 %save
2746 %save
2747 \family default
2747 \family default
2748 magic does this: its input sytnax is the same as
2748 magic does this: its input sytnax is the same as
2749 \family typewriter
2749 \family typewriter
2750 %macro
2750 %macro
2751 \family default
2751 \family default
2752 , but it saves your input directly to a Python file.
2752 , but it saves your input directly to a Python file.
2753 Note that the
2753 Note that the
2754 \family typewriter
2754 \family typewriter
2755 %logstart
2755 %logstart
2756 \family default
2756 \family default
2757 command also saves input, but it logs
2757 command also saves input, but it logs
2758 \emph on
2758 \emph on
2759 all
2759 all
2760 \emph default
2760 \emph default
2761 input to disk (though you can temporarily suspend it and reactivate it
2761 input to disk (though you can temporarily suspend it and reactivate it
2762 with
2762 with
2763 \family typewriter
2763 \family typewriter
2764 %logoff/%logon
2764 %logoff/%logon
2765 \family default
2765 \family default
2766 );
2766 );
2767 \family typewriter
2767 \family typewriter
2768 %save
2768 %save
2769 \family default
2769 \family default
2770 allows you to select which lines of input you need to save.
2770 allows you to select which lines of input you need to save.
2771 \end_layout
2771 \end_layout
2772
2772
2773 \begin_layout Subsubsection*
2773 \begin_layout Subsubsection*
2774 Lightweight 'version control'
2774 Lightweight 'version control'
2775 \end_layout
2775 \end_layout
2776
2776
2777 \begin_layout Standard
2777 \begin_layout Standard
2778 When you call
2778 When you call
2779 \family typewriter
2779 \family typewriter
2780 %edit
2780 %edit
2781 \family default
2781 \family default
2782 with no arguments, IPython opens an empty editor with a temporary file,
2782 with no arguments, IPython opens an empty editor with a temporary file,
2783 and it returns the contents of your editing session as a string variable.
2783 and it returns the contents of your editing session as a string variable.
2784 Thanks to IPython's output caching mechanism, this is automatically stored:
2784 Thanks to IPython's output caching mechanism, this is automatically stored:
2785 \end_layout
2785 \end_layout
2786
2786
2787 \begin_layout LyX-Code
2787 \begin_layout LyX-Code
2788 In [1]: %edit
2788 In [1]: %edit
2789 \end_layout
2789 \end_layout
2790
2790
2791 \begin_layout LyX-Code
2791 \begin_layout LyX-Code
2792 IPython will make a temporary file named: /tmp/ipython_edit_yR-HCN.py
2792 IPython will make a temporary file named: /tmp/ipython_edit_yR-HCN.py
2793 \end_layout
2793 \end_layout
2794
2794
2795 \begin_layout LyX-Code
2795 \begin_layout LyX-Code
2796 Editing...
2796 Editing...
2797 done.
2797 done.
2798 Executing edited code...
2798 Executing edited code...
2799 \end_layout
2799 \end_layout
2800
2800
2801 \begin_layout LyX-Code
2801 \begin_layout LyX-Code
2802 hello - this is a temporary file
2802 hello - this is a temporary file
2803 \end_layout
2803 \end_layout
2804
2804
2805 \begin_layout LyX-Code
2805 \begin_layout LyX-Code
2806 Out[1]: "print 'hello - this is a temporary file'
2806 Out[1]: "print 'hello - this is a temporary file'
2807 \backslash
2807 \backslash
2808 n"
2808 n"
2809 \end_layout
2809 \end_layout
2810
2810
2811 \begin_layout Standard
2811 \begin_layout Standard
2812 Now, if you call
2812 Now, if you call
2813 \family typewriter
2813 \family typewriter
2814 `%edit -p'
2814 `%edit -p'
2815 \family default
2815 \family default
2816 , IPython tries to open an editor with the same data as the last time you
2816 , IPython tries to open an editor with the same data as the last time you
2817 used
2817 used
2818 \family typewriter
2818 \family typewriter
2819 %edit
2819 %edit
2820 \family default
2820 \family default
2821 .
2821 .
2822 So if you haven't used
2822 So if you haven't used
2823 \family typewriter
2823 \family typewriter
2824 %edit
2824 %edit
2825 \family default
2825 \family default
2826 in the meantime, this same contents will reopen; however, it will be done
2826 in the meantime, this same contents will reopen; however, it will be done
2827 in a
2827 in a
2828 \emph on
2828 \emph on
2829 new file
2829 new file
2830 \emph default
2830 \emph default
2831 .
2831 .
2832 This means that if you make changes and you later want to find an old version,
2832 This means that if you make changes and you later want to find an old version,
2833 you can always retrieve it by using its output number, via
2833 you can always retrieve it by using its output number, via
2834 \family typewriter
2834 \family typewriter
2835 `%edit _NN'
2835 `%edit _NN'
2836 \family default
2836 \family default
2837 , where
2837 , where
2838 \family typewriter
2838 \family typewriter
2839 NN
2839 NN
2840 \family default
2840 \family default
2841 is the number of the output prompt.
2841 is the number of the output prompt.
2842 \end_layout
2842 \end_layout
2843
2843
2844 \begin_layout Standard
2844 \begin_layout Standard
2845 Continuing with the example above, this should illustrate this idea:
2845 Continuing with the example above, this should illustrate this idea:
2846 \end_layout
2846 \end_layout
2847
2847
2848 \begin_layout LyX-Code
2848 \begin_layout LyX-Code
2849 In [2]: edit -p
2849 In [2]: edit -p
2850 \end_layout
2850 \end_layout
2851
2851
2852 \begin_layout LyX-Code
2852 \begin_layout LyX-Code
2853 IPython will make a temporary file named: /tmp/ipython_edit_nA09Qk.py
2853 IPython will make a temporary file named: /tmp/ipython_edit_nA09Qk.py
2854 \end_layout
2854 \end_layout
2855
2855
2856 \begin_layout LyX-Code
2856 \begin_layout LyX-Code
2857 Editing...
2857 Editing...
2858 done.
2858 done.
2859 Executing edited code...
2859 Executing edited code...
2860 \end_layout
2860 \end_layout
2861
2861
2862 \begin_layout LyX-Code
2862 \begin_layout LyX-Code
2863 hello - now I made some changes
2863 hello - now I made some changes
2864 \end_layout
2864 \end_layout
2865
2865
2866 \begin_layout LyX-Code
2866 \begin_layout LyX-Code
2867 Out[2]: "print 'hello - now I made some changes'
2867 Out[2]: "print 'hello - now I made some changes'
2868 \backslash
2868 \backslash
2869 n"
2869 n"
2870 \end_layout
2870 \end_layout
2871
2871
2872 \begin_layout LyX-Code
2872 \begin_layout LyX-Code
2873 In [3]: edit _1
2873 In [3]: edit _1
2874 \end_layout
2874 \end_layout
2875
2875
2876 \begin_layout LyX-Code
2876 \begin_layout LyX-Code
2877 IPython will make a temporary file named: /tmp/ipython_edit_gy6-zD.py
2877 IPython will make a temporary file named: /tmp/ipython_edit_gy6-zD.py
2878 \end_layout
2878 \end_layout
2879
2879
2880 \begin_layout LyX-Code
2880 \begin_layout LyX-Code
2881 Editing...
2881 Editing...
2882 done.
2882 done.
2883 Executing edited code...
2883 Executing edited code...
2884 \end_layout
2884 \end_layout
2885
2885
2886 \begin_layout LyX-Code
2886 \begin_layout LyX-Code
2887 hello - this is a temporary file
2887 hello - this is a temporary file
2888 \end_layout
2888 \end_layout
2889
2889
2890 \begin_layout LyX-Code
2890 \begin_layout LyX-Code
2891 IPython version control at work :)
2891 IPython version control at work :)
2892 \end_layout
2892 \end_layout
2893
2893
2894 \begin_layout LyX-Code
2894 \begin_layout LyX-Code
2895 Out[3]: "print 'hello - this is a temporary file'
2895 Out[3]: "print 'hello - this is a temporary file'
2896 \backslash
2896 \backslash
2897 nprint 'IPython version control at work :)'
2897 nprint 'IPython version control at work :)'
2898 \backslash
2898 \backslash
2899 n"
2899 n"
2900 \end_layout
2900 \end_layout
2901
2901
2902 \begin_layout Standard
2902 \begin_layout Standard
2903 This section was written after a contribution by Alexander Belchenko on
2903 This section was written after a contribution by Alexander Belchenko on
2904 the IPython user list.
2904 the IPython user list.
2905 \end_layout
2905 \end_layout
2906
2906
2907 \begin_layout LyX-Code
2907 \begin_layout LyX-Code
2908
2908
2909 \end_layout
2909 \end_layout
2910
2910
2911 \begin_layout Subsection
2911 \begin_layout Subsection
2912 Effective logging
2912 Effective logging
2913 \end_layout
2913 \end_layout
2914
2914
2915 \begin_layout Standard
2915 \begin_layout Standard
2916 A very useful suggestion sent in by Robert Kern follows:
2916 A very useful suggestion sent in by Robert Kern follows:
2917 \end_layout
2917 \end_layout
2918
2918
2919 \begin_layout Standard
2919 \begin_layout Standard
2920 I recently happened on a nifty way to keep tidy per-project log files.
2920 I recently happened on a nifty way to keep tidy per-project log files.
2921 I made a profile for my project (which is called "parkfield").
2921 I made a profile for my project (which is called "parkfield").
2922 \end_layout
2922 \end_layout
2923
2923
2924 \begin_layout LyX-Code
2924 \begin_layout LyX-Code
2925 include ipythonrc
2925 include ipythonrc
2926 \end_layout
2926 \end_layout
2927
2927
2928 \begin_layout LyX-Code
2928 \begin_layout LyX-Code
2929 # cancel earlier logfile invocation:
2929 # cancel earlier logfile invocation:
2930 \end_layout
2930 \end_layout
2931
2931
2932 \begin_layout LyX-Code
2932 \begin_layout LyX-Code
2933 logfile ''
2933 logfile ''
2934 \end_layout
2934 \end_layout
2935
2935
2936 \begin_layout LyX-Code
2936 \begin_layout LyX-Code
2937 execute import time
2937 execute import time
2938 \end_layout
2938 \end_layout
2939
2939
2940 \begin_layout LyX-Code
2940 \begin_layout LyX-Code
2941 execute __cmd = '/Users/kern/research/logfiles/parkfield-%s.log rotate'
2941 execute __cmd = '/Users/kern/research/logfiles/parkfield-%s.log rotate'
2942 \end_layout
2942 \end_layout
2943
2943
2944 \begin_layout LyX-Code
2944 \begin_layout LyX-Code
2945 execute __IP.magic_logstart(__cmd % time.strftime('%Y-%m-%d'))
2945 execute __IP.magic_logstart(__cmd % time.strftime('%Y-%m-%d'))
2946 \end_layout
2946 \end_layout
2947
2947
2948 \begin_layout Standard
2948 \begin_layout Standard
2949 I also added a shell alias for convenience:
2949 I also added a shell alias for convenience:
2950 \end_layout
2950 \end_layout
2951
2951
2952 \begin_layout LyX-Code
2952 \begin_layout LyX-Code
2953 alias parkfield="ipython -pylab -profile parkfield"
2953 alias parkfield="ipython -pylab -profile parkfield"
2954 \end_layout
2954 \end_layout
2955
2955
2956 \begin_layout Standard
2956 \begin_layout Standard
2957 Now I have a nice little directory with everything I ever type in, organized
2957 Now I have a nice little directory with everything I ever type in, organized
2958 by project and date.
2958 by project and date.
2959 \end_layout
2959 \end_layout
2960
2960
2961 \begin_layout Standard
2961 \begin_layout Standard
2962
2962
2963 \series bold
2963 \series bold
2964 Contribute your own:
2964 Contribute your own:
2965 \series default
2965 \series default
2966 If you have your own favorite tip on using IPython efficiently for a certain
2966 If you have your own favorite tip on using IPython efficiently for a certain
2967 task (especially things which can't be done in the normal Python interpreter),
2967 task (especially things which can't be done in the normal Python interpreter),
2968 don't hesitate to send it!
2968 don't hesitate to send it!
2969 \end_layout
2969 \end_layout
2970
2970
2971 \begin_layout Section
2971 \begin_layout Section
2972 Command-line use
2972 Command-line use
2973 \end_layout
2973 \end_layout
2974
2974
2975 \begin_layout Standard
2975 \begin_layout Standard
2976 You start IPython with the command:
2976 You start IPython with the command:
2977 \end_layout
2977 \end_layout
2978
2978
2979 \begin_layout Standard
2979 \begin_layout Standard
2980
2980
2981 \family typewriter
2981 \family typewriter
2982 $ ipython [options] files
2982 $ ipython [options] files
2983 \end_layout
2983 \end_layout
2984
2984
2985 \begin_layout Standard
2985 \begin_layout Standard
2986 If invoked with no options, it executes all the files listed in sequence
2986 If invoked with no options, it executes all the files listed in sequence
2987 and drops you into the interpreter while still acknowledging any options
2987 and drops you into the interpreter while still acknowledging any options
2988 you may have set in your ipythonrc file.
2988 you may have set in your ipythonrc file.
2989 This behavior is different from standard Python, which when called as
2989 This behavior is different from standard Python, which when called as
2990 \family typewriter
2990 \family typewriter
2991 python -i
2991 python -i
2992 \family default
2992 \family default
2993 will only execute one file and ignore your configuration setup.
2993 will only execute one file and ignore your configuration setup.
2994 \end_layout
2994 \end_layout
2995
2995
2996 \begin_layout Standard
2996 \begin_layout Standard
2997 Please note that some of the configuration options are not available at
2997 Please note that some of the configuration options are not available at
2998 the command line, simply because they are not practical here.
2998 the command line, simply because they are not practical here.
2999 Look into your ipythonrc configuration file for details on those.
2999 Look into your ipythonrc configuration file for details on those.
3000 This file typically installed in the
3000 This file typically installed in the
3001 \family typewriter
3001 \family typewriter
3002 $HOME/.ipython
3002 $HOME/.ipython
3003 \family default
3003 \family default
3004 directory.
3004 directory.
3005 For Windows users,
3005 For Windows users,
3006 \family typewriter
3006 \family typewriter
3007 $HOME
3007 $HOME
3008 \family default
3008 \family default
3009 resolves to
3009 resolves to
3010 \family typewriter
3010 \family typewriter
3011 C:
3011 C:
3012 \backslash
3012 \backslash
3013
3013
3014 \backslash
3014 \backslash
3015 Documents and Settings
3015 Documents and Settings
3016 \backslash
3016 \backslash
3017
3017
3018 \backslash
3018 \backslash
3019 YourUserName
3019 YourUserName
3020 \family default
3020 \family default
3021 in most instances.
3021 in most instances.
3022 In the rest of this text, we will refer to this directory as
3022 In the rest of this text, we will refer to this directory as
3023 \family typewriter
3023 \family typewriter
3024 IPYTHONDIR
3024 IPYTHONDIR
3025 \family default
3025 \family default
3026 .
3026 .
3027 \end_layout
3027 \end_layout
3028
3028
3029 \begin_layout Subsection
3029 \begin_layout Subsection
3030 \begin_inset LatexCommand \label{sec:threading-opts}
3030 \begin_inset LatexCommand \label{sec:threading-opts}
3031
3031
3032 \end_inset
3032 \end_inset
3033
3033
3034 Special Threading Options
3034 Special Threading Options
3035 \end_layout
3035 \end_layout
3036
3036
3037 \begin_layout Standard
3037 \begin_layout Standard
3038 The following special options are ONLY valid at the beginning of the command
3038 The following special options are ONLY valid at the beginning of the command
3039 line, and not later.
3039 line, and not later.
3040 This is because they control the initial- ization of ipython itself, before
3040 This is because they control the initial- ization of ipython itself, before
3041 the normal option-handling mechanism is active.
3041 the normal option-handling mechanism is active.
3042 \end_layout
3042 \end_layout
3043
3043
3044 \begin_layout List
3044 \begin_layout List
3045 \labelwidthstring 00.00.0000
3045 \labelwidthstring 00.00.0000
3046
3046
3047 \family typewriter
3047 \family typewriter
3048 \series bold
3048 \series bold
3049 -gthread,\InsetSpace ~
3049 -gthread,\InsetSpace ~
3050 -qthread,\InsetSpace ~
3050 -qthread,\InsetSpace ~
3051 -q4thread,\InsetSpace ~
3051 -q4thread,\InsetSpace ~
3052 -wthread,\InsetSpace ~
3052 -wthread,\InsetSpace ~
3053 -pylab:
3053 -pylab:
3054 \family default
3054 \family default
3055 \series default
3055 \series default
3056 Only
3056 Only
3057 \emph on
3057 \emph on
3058 one
3058 one
3059 \emph default
3059 \emph default
3060 of these can be given, and it can only be given as the first option passed
3060 of these can be given, and it can only be given as the first option passed
3061 to IPython (it will have no effect in any other position).
3061 to IPython (it will have no effect in any other position).
3062 They provide threading support for the GTK, Qt (versions 3 and 4) and WXPython
3062 They provide threading support for the GTK, Qt (versions 3 and 4) and WXPython
3063 toolkits, and for the matplotlib library.
3063 toolkits, and for the matplotlib library.
3064 \end_layout
3064 \end_layout
3065
3065
3066 \begin_layout List
3066 \begin_layout List
3067 \labelwidthstring 00.00.0000
3067 \labelwidthstring 00.00.0000
3068 \InsetSpace ~
3068 \InsetSpace ~
3069 With any of the first four options, IPython starts running a separate thread
3069 With any of the first four options, IPython starts running a separate thread
3070 for the graphical toolkit's operation, so that you can open and control
3070 for the graphical toolkit's operation, so that you can open and control
3071 graphical elements from within an IPython command line, without blocking.
3071 graphical elements from within an IPython command line, without blocking.
3072 All four provide essentially the same functionality, respectively for GTK,
3072 All four provide essentially the same functionality, respectively for GTK,
3073 Qt3, Qt4 and WXWidgets (via their Python interfaces).
3073 Qt3, Qt4 and WXWidgets (via their Python interfaces).
3074 \end_layout
3074 \end_layout
3075
3075
3076 \begin_layout List
3076 \begin_layout List
3077 \labelwidthstring 00.00.0000
3077 \labelwidthstring 00.00.0000
3078 \InsetSpace ~
3078 \InsetSpace ~
3079 Note that with
3079 Note that with
3080 \family typewriter
3080 \family typewriter
3081 -wthread
3081 -wthread
3082 \family default
3082 \family default
3083 , you can additionally use the -wxversion option to request a specific version
3083 , you can additionally use the -wxversion option to request a specific version
3084 of wx to be used.
3084 of wx to be used.
3085 This requires that you have the
3085 This requires that you have the
3086 \family typewriter
3086 \family typewriter
3087 wxversion
3087 wxversion
3088 \family default
3088 \family default
3089 Python module installed, which is part of recent wxPython distributions.
3089 Python module installed, which is part of recent wxPython distributions.
3090 \end_layout
3090 \end_layout
3091
3091
3092 \begin_layout List
3092 \begin_layout List
3093 \labelwidthstring 00.00.0000
3093 \labelwidthstring 00.00.0000
3094 \InsetSpace ~
3094 \InsetSpace ~
3095 If
3095 If
3096 \family typewriter
3096 \family typewriter
3097 -pylab
3097 -pylab
3098 \family default
3098 \family default
3099 is given, IPython loads special support for the mat plotlib library (
3099 is given, IPython loads special support for the mat plotlib library (
3100 \begin_inset LatexCommand \htmlurl{http://matplotlib.sourceforge.net}
3100 \begin_inset LatexCommand \htmlurl{http://matplotlib.sourceforge.net}
3101
3101
3102 \end_inset
3102 \end_inset
3103
3103
3104 ), allowing interactive usage of any of its backends as defined in the user's
3104 ), allowing interactive usage of any of its backends as defined in the user's
3105
3105
3106 \family typewriter
3106 \family typewriter
3107 ~/.matplotlib/matplotlibrc
3107 ~/.matplotlib/matplotlibrc
3108 \family default
3108 \family default
3109 file.
3109 file.
3110 It automatically activates GTK, Qt or WX threading for IPyhton if the choice
3110 It automatically activates GTK, Qt or WX threading for IPyhton if the choice
3111 of matplotlib backend requires it.
3111 of matplotlib backend requires it.
3112 It also modifies the
3112 It also modifies the
3113 \family typewriter
3113 \family typewriter
3114 %run
3114 %run
3115 \family default
3115 \family default
3116 command to correctly execute (without blocking) any matplotlib-based script
3116 command to correctly execute (without blocking) any matplotlib-based script
3117 which calls
3117 which calls
3118 \family typewriter
3118 \family typewriter
3119 show()
3119 show()
3120 \family default
3120 \family default
3121 at the end.
3121 at the end.
3122
3122
3123 \end_layout
3123 \end_layout
3124
3124
3125 \begin_layout List
3125 \begin_layout List
3126 \labelwidthstring 00.00.0000
3126 \labelwidthstring 00.00.0000
3127
3127
3128 \family typewriter
3128 \family typewriter
3129 \series bold
3129 \series bold
3130 -tk
3130 -tk
3131 \family default
3131 \family default
3132 \series default
3132 \series default
3133 The
3133 The
3134 \family typewriter
3134 \family typewriter
3135 -g/q/q4/wthread
3135 -g/q/q4/wthread
3136 \family default
3136 \family default
3137 options, and
3137 options, and
3138 \family typewriter
3138 \family typewriter
3139 -pylab
3139 -pylab
3140 \family default
3140 \family default
3141 (if matplotlib is configured to use GTK, Qt3, Qt4 or WX), will normally
3141 (if matplotlib is configured to use GTK, Qt3, Qt4 or WX), will normally
3142 block Tk graphical interfaces.
3142 block Tk graphical interfaces.
3143 This means that when either GTK, Qt or WX threading is active, any attempt
3143 This means that when either GTK, Qt or WX threading is active, any attempt
3144 to open a Tk GUI will result in a dead window, and possibly cause the Python
3144 to open a Tk GUI will result in a dead window, and possibly cause the Python
3145 interpreter to crash.
3145 interpreter to crash.
3146 An extra option,
3146 An extra option,
3147 \family typewriter
3147 \family typewriter
3148 -tk
3148 -tk
3149 \family default
3149 \family default
3150 , is available to address this issue.
3150 , is available to address this issue.
3151 It can
3151 It can
3152 \emph on
3152 \emph on
3153 only
3153 only
3154 \emph default
3154 \emph default
3155 be given as a
3155 be given as a
3156 \emph on
3156 \emph on
3157 second
3157 second
3158 \emph default
3158 \emph default
3159 option after any of the above (
3159 option after any of the above (
3160 \family typewriter
3160 \family typewriter
3161 -gthread
3161 -gthread
3162 \family default
3162 \family default
3163 ,
3163 ,
3164 \family typewriter
3164 \family typewriter
3165 -wthread
3165 -wthread
3166 \family default
3166 \family default
3167 or
3167 or
3168 \family typewriter
3168 \family typewriter
3169 -pylab
3169 -pylab
3170 \family default
3170 \family default
3171 ).
3171 ).
3172 \end_layout
3172 \end_layout
3173
3173
3174 \begin_layout List
3174 \begin_layout List
3175 \labelwidthstring 00.00.0000
3175 \labelwidthstring 00.00.0000
3176 \InsetSpace ~
3176 \InsetSpace ~
3177 If
3177 If
3178 \family typewriter
3178 \family typewriter
3179 -tk
3179 -tk
3180 \family default
3180 \family default
3181 is given, IPython will try to coordinate Tk threading with GTK, Qt or WX.
3181 is given, IPython will try to coordinate Tk threading with GTK, Qt or WX.
3182 This is however potentially unreliable, and you will have to test on your
3182 This is however potentially unreliable, and you will have to test on your
3183 platform and Python configuration to determine whether it works for you.
3183 platform and Python configuration to determine whether it works for you.
3184 Debian users have reported success, apparently due to the fact that Debian
3184 Debian users have reported success, apparently due to the fact that Debian
3185 builds all of Tcl, Tk, Tkinter and Python with pthreads support.
3185 builds all of Tcl, Tk, Tkinter and Python with pthreads support.
3186 Under other Linux environments (such as Fedora Core 2/3), this option has
3186 Under other Linux environments (such as Fedora Core 2/3), this option has
3187 caused random crashes and lockups of the Python interpreter.
3187 caused random crashes and lockups of the Python interpreter.
3188 Under other operating systems (Mac OSX and Windows), you'll need to try
3188 Under other operating systems (Mac OSX and Windows), you'll need to try
3189 it to find out, since currently no user reports are available.
3189 it to find out, since currently no user reports are available.
3190 \end_layout
3190 \end_layout
3191
3191
3192 \begin_layout List
3192 \begin_layout List
3193 \labelwidthstring 00.00.0000
3193 \labelwidthstring 00.00.0000
3194 \InsetSpace ~
3194 \InsetSpace ~
3195 There is unfortunately no way for IPython to determine at run time whether
3195 There is unfortunately no way for IPython to determine at run time whether
3196
3196
3197 \family typewriter
3197 \family typewriter
3198 -tk
3198 -tk
3199 \family default
3199 \family default
3200 will work reliably or not, so you will need to do some experiments before
3200 will work reliably or not, so you will need to do some experiments before
3201 relying on it for regular work.
3201 relying on it for regular work.
3202
3202
3203 \end_layout
3203 \end_layout
3204
3204
3205 \begin_layout Subsection
3205 \begin_layout Subsection
3206 \begin_inset LatexCommand \label{sec:cmd-line-opts}
3206 \begin_inset LatexCommand \label{sec:cmd-line-opts}
3207
3207
3208 \end_inset
3208 \end_inset
3209
3209
3210 Regular Options
3210 Regular Options
3211 \end_layout
3211 \end_layout
3212
3212
3213 \begin_layout Standard
3213 \begin_layout Standard
3214 After the above threading options have been given, regular options can follow
3214 After the above threading options have been given, regular options can follow
3215 in any order.
3215 in any order.
3216 All options can be abbreviated to their shortest non-ambiguous form and
3216 All options can be abbreviated to their shortest non-ambiguous form and
3217 are case-sensitive.
3217 are case-sensitive.
3218 One or two dashes can be used.
3218 One or two dashes can be used.
3219 Some options have an alternate short form, indicated after a
3219 Some options have an alternate short form, indicated after a
3220 \family typewriter
3220 \family typewriter
3221 |
3221 |
3222 \family default
3222 \family default
3223 .
3223 .
3224 \end_layout
3224 \end_layout
3225
3225
3226 \begin_layout Standard
3226 \begin_layout Standard
3227 Most options can also be set from your ipythonrc configuration file.
3227 Most options can also be set from your ipythonrc configuration file.
3228 See the provided example for more details on what the options do.
3228 See the provided example for more details on what the options do.
3229 Options given at the command line override the values set in the ipythonrc
3229 Options given at the command line override the values set in the ipythonrc
3230 file.
3230 file.
3231 \end_layout
3231 \end_layout
3232
3232
3233 \begin_layout Standard
3233 \begin_layout Standard
3234 All options with a
3234 All options with a
3235 \family typewriter
3235 \family typewriter
3236 [no]
3236 [no]
3237 \family default
3237 \family default
3238 prepended can be specified in negated form (
3238 prepended can be specified in negated form (
3239 \family typewriter
3239 \family typewriter
3240 -nooption
3240 -nooption
3241 \family default
3241 \family default
3242 instead of
3242 instead of
3243 \family typewriter
3243 \family typewriter
3244 -option
3244 -option
3245 \family default
3245 \family default
3246 ) to turn the feature off.
3246 ) to turn the feature off.
3247 \end_layout
3247 \end_layout
3248
3248
3249 \begin_layout List
3249 \begin_layout List
3250 \labelwidthstring 00.00.0000
3250 \labelwidthstring 00.00.0000
3251
3251
3252 \family typewriter
3252 \family typewriter
3253 \series bold
3253 \series bold
3254 -help
3254 -help
3255 \family default
3255 \family default
3256 \series default
3256 \series default
3257 : print a help message and exit.
3257 : print a help message and exit.
3258 \end_layout
3258 \end_layout
3259
3259
3260 \begin_layout List
3260 \begin_layout List
3261 \labelwidthstring 00.00.0000
3261 \labelwidthstring 00.00.0000
3262
3262
3263 \family typewriter
3263 \family typewriter
3264 \series bold
3264 \series bold
3265 -pylab:
3265 -pylab:
3266 \family default
3266 \family default
3267 \series default
3267 \series default
3268 this can
3268 this can
3269 \emph on
3269 \emph on
3270 only
3270 only
3271 \emph default
3271 \emph default
3272 be given as the
3272 be given as the
3273 \emph on
3273 \emph on
3274 first
3274 first
3275 \emph default
3275 \emph default
3276 option passed to IPython (it will have no effect in any other position).
3276 option passed to IPython (it will have no effect in any other position).
3277 It adds special support for the matplotlib library (
3277 It adds special support for the matplotlib library (
3278 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
3278 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
3279
3279
3280 \end_inset
3280 \end_inset
3281
3281
3282 ), allowing interactive usage of any of its backends as defined in the user's
3282 ), allowing interactive usage of any of its backends as defined in the user's
3283
3283
3284 \family typewriter
3284 \family typewriter
3285 .matplotlibrc
3285 .matplotlibrc
3286 \family default
3286 \family default
3287 file.
3287 file.
3288 It automatically activates GTK or WX threading for IPyhton if the choice
3288 It automatically activates GTK or WX threading for IPyhton if the choice
3289 of matplotlib backend requires it.
3289 of matplotlib backend requires it.
3290 It also modifies the
3290 It also modifies the
3291 \family typewriter
3291 \family typewriter
3292 %run
3292 %run
3293 \family default
3293 \family default
3294 command to correctly execute (without blocking) any matplotlib-based script
3294 command to correctly execute (without blocking) any matplotlib-based script
3295 which calls
3295 which calls
3296 \family typewriter
3296 \family typewriter
3297 show()
3297 show()
3298 \family default
3298 \family default
3299 at the end.
3299 at the end.
3300 See Sec.\InsetSpace ~
3300 See Sec.\InsetSpace ~
3301
3301
3302 \begin_inset LatexCommand \ref{sec:matplotlib-support}
3302 \begin_inset LatexCommand \ref{sec:matplotlib-support}
3303
3303
3304 \end_inset
3304 \end_inset
3305
3305
3306 for more details.
3306 for more details.
3307 \end_layout
3307 \end_layout
3308
3308
3309 \begin_layout List
3309 \begin_layout List
3310 \labelwidthstring 00.00.0000
3310 \labelwidthstring 00.00.0000
3311
3311
3312 \family typewriter
3312 \family typewriter
3313 \series bold
3313 \series bold
3314 -autocall <val>:
3314 -autocall <val>:
3315 \family default
3315 \family default
3316 \series default
3316 \series default
3317 Make IPython automatically call any callable object even if you didn't
3317 Make IPython automatically call any callable object even if you didn't
3318 type explicit parentheses.
3318 type explicit parentheses.
3319 For example, `str 43' becomes `str(43)' automatically.
3319 For example, `str 43' becomes `str(43)' automatically.
3320 The value can be `0' to disable the feature, `1' for
3320 The value can be `0' to disable the feature, `1' for
3321 \emph on
3321 \emph on
3322 smart
3322 smart
3323 \emph default
3323 \emph default
3324 autocall, where it is not applied if there are no more arguments on the
3324 autocall, where it is not applied if there are no more arguments on the
3325 line, and `2' for
3325 line, and `2' for
3326 \emph on
3326 \emph on
3327 full
3327 full
3328 \emph default
3328 \emph default
3329 autocall, where all callable objects are automatically called (even if
3329 autocall, where all callable objects are automatically called (even if
3330 no arguments are present).
3330 no arguments are present).
3331 The default is `1'.
3331 The default is `1'.
3332 \end_layout
3332 \end_layout
3333
3333
3334 \begin_layout List
3334 \begin_layout List
3335 \labelwidthstring 00.00.0000
3335 \labelwidthstring 00.00.0000
3336
3336
3337 \family typewriter
3337 \family typewriter
3338 \series bold
3338 \series bold
3339 -[no]autoindent:
3339 -[no]autoindent:
3340 \family default
3340 \family default
3341 \series default
3341 \series default
3342 Turn automatic indentation on/off.
3342 Turn automatic indentation on/off.
3343 \end_layout
3343 \end_layout
3344
3344
3345 \begin_layout List
3345 \begin_layout List
3346 \labelwidthstring 00.00.0000
3346 \labelwidthstring 00.00.0000
3347
3347
3348 \family typewriter
3348 \family typewriter
3349 \series bold
3349 \series bold
3350 -[no]automagic
3350 -[no]automagic
3351 \series default
3351 \series default
3352 :
3352 :
3353 \family default
3353 \family default
3354 make magic commands automatic (without needing their first character to
3354 make magic commands automatic (without needing their first character to
3355 be
3355 be
3356 \family typewriter
3356 \family typewriter
3357 %
3357 %
3358 \family default
3358 \family default
3359 ).
3359 ).
3360 Type
3360 Type
3361 \family typewriter
3361 \family typewriter
3362 %magic
3362 %magic
3363 \family default
3363 \family default
3364 at the IPython prompt for more information.
3364 at the IPython prompt for more information.
3365 \end_layout
3365 \end_layout
3366
3366
3367 \begin_layout List
3367 \begin_layout List
3368 \labelwidthstring 00.00.0000
3368 \labelwidthstring 00.00.0000
3369
3369
3370 \family typewriter
3370 \family typewriter
3371 \series bold
3371 \series bold
3372 -[no]autoedit_syntax:
3372 -[no]autoedit_syntax:
3373 \family default
3373 \family default
3374 \series default
3374 \series default
3375 When a syntax error occurs after editing a file, automatically open the
3375 When a syntax error occurs after editing a file, automatically open the
3376 file to the trouble causing line for convenient fixing.
3376 file to the trouble causing line for convenient fixing.
3377
3377
3378 \end_layout
3378 \end_layout
3379
3379
3380 \begin_layout List
3380 \begin_layout List
3381 \labelwidthstring 00.00.0000
3381 \labelwidthstring 00.00.0000
3382
3382
3383 \family typewriter
3383 \family typewriter
3384 \series bold
3384 \series bold
3385 -[no]banner
3385 -[no]banner
3386 \series default
3386 \series default
3387 :
3387 :
3388 \family default
3388 \family default
3389 Print the initial information banner (default on).
3389 Print the initial information banner (default on).
3390 \end_layout
3390 \end_layout
3391
3391
3392 \begin_layout List
3392 \begin_layout List
3393 \labelwidthstring 00.00.0000
3393 \labelwidthstring 00.00.0000
3394
3394
3395 \family typewriter
3395 \family typewriter
3396 \series bold
3396 \series bold
3397 -c\InsetSpace ~
3397 -c\InsetSpace ~
3398 <command>:
3398 <command>:
3399 \family default
3399 \family default
3400 \series default
3400 \series default
3401 execute the given command string, and set sys.argv to
3401 execute the given command string, and set sys.argv to
3402 \family typewriter
3402 \family typewriter
3403 ['c']
3403 ['c']
3404 \family default
3404 \family default
3405 .
3405 .
3406 This is similar to the
3406 This is similar to the
3407 \family typewriter
3407 \family typewriter
3408 -c
3408 -c
3409 \family default
3409 \family default
3410 option in the normal Python interpreter.
3410 option in the normal Python interpreter.
3411
3411
3412 \end_layout
3412 \end_layout
3413
3413
3414 \begin_layout List
3414 \begin_layout List
3415 \labelwidthstring 00.00.0000
3415 \labelwidthstring 00.00.0000
3416
3416
3417 \family typewriter
3417 \family typewriter
3418 \series bold
3418 \series bold
3419 -cache_size|cs\InsetSpace ~
3419 -cache_size|cs\InsetSpace ~
3420 <n>
3420 <n>
3421 \series default
3421 \series default
3422 :
3422 :
3423 \family default
3423 \family default
3424 size of the output cache (maximum number of entries to hold in memory).
3424 size of the output cache (maximum number of entries to hold in memory).
3425 The default is 1000, you can change it permanently in your config file.
3425 The default is 1000, you can change it permanently in your config file.
3426 Setting it to 0 completely disables the caching system, and the minimum
3426 Setting it to 0 completely disables the caching system, and the minimum
3427 value accepted is 20 (if you provide a value less than 20, it is reset
3427 value accepted is 20 (if you provide a value less than 20, it is reset
3428 to 0 and a warning is issued) This limit is defined because otherwise you'll
3428 to 0 and a warning is issued) This limit is defined because otherwise you'll
3429 spend more time re-flushing a too small cache than working.
3429 spend more time re-flushing a too small cache than working.
3430 \end_layout
3430 \end_layout
3431
3431
3432 \begin_layout List
3432 \begin_layout List
3433 \labelwidthstring 00.00.0000
3433 \labelwidthstring 00.00.0000
3434
3434
3435 \family typewriter
3435 \family typewriter
3436 \series bold
3436 \series bold
3437 -classic|cl
3437 -classic|cl
3438 \series default
3438 \series default
3439 :
3439 :
3440 \family default
3440 \family default
3441 Gives IPython a similar feel to the classic Python prompt.
3441 Gives IPython a similar feel to the classic Python prompt.
3442 \end_layout
3442 \end_layout
3443
3443
3444 \begin_layout List
3444 \begin_layout List
3445 \labelwidthstring 00.00.0000
3445 \labelwidthstring 00.00.0000
3446
3446
3447 \family typewriter
3447 \family typewriter
3448 \series bold
3448 \series bold
3449 -colors\InsetSpace ~
3449 -colors\InsetSpace ~
3450 <scheme>:
3450 <scheme>:
3451 \family default
3451 \family default
3452 \series default
3452 \series default
3453 Color scheme for prompts and exception reporting.
3453 Color scheme for prompts and exception reporting.
3454 Currently implemented: NoColor, Linux and LightBG.
3454 Currently implemented: NoColor, Linux and LightBG.
3455 \end_layout
3455 \end_layout
3456
3456
3457 \begin_layout List
3457 \begin_layout List
3458 \labelwidthstring 00.00.0000
3458 \labelwidthstring 00.00.0000
3459
3459
3460 \family typewriter
3460 \family typewriter
3461 \series bold
3461 \series bold
3462 -[no]color_info:
3462 -[no]color_info:
3463 \family default
3463 \family default
3464 \series default
3464 \series default
3465 IPython can display information about objects via a set of functions, and
3465 IPython can display information about objects via a set of functions, and
3466 optionally can use colors for this, syntax highlighting source code and
3466 optionally can use colors for this, syntax highlighting source code and
3467 various other elements.
3467 various other elements.
3468 However, because this information is passed through a pager (like 'less')
3468 However, because this information is passed through a pager (like 'less')
3469 and many pagers get confused with color codes, this option is off by default.
3469 and many pagers get confused with color codes, this option is off by default.
3470 You can test it and turn it on permanently in your ipythonrc file if it
3470 You can test it and turn it on permanently in your ipythonrc file if it
3471 works for you.
3471 works for you.
3472 As a reference, the 'less' pager supplied with Mandrake 8.2 works ok, but
3472 As a reference, the 'less' pager supplied with Mandrake 8.2 works ok, but
3473 that in RedHat 7.2 doesn't.
3473 that in RedHat 7.2 doesn't.
3474 \end_layout
3474 \end_layout
3475
3475
3476 \begin_layout List
3476 \begin_layout List
3477 \labelwidthstring 00.00.0000
3477 \labelwidthstring 00.00.0000
3478 \InsetSpace ~
3478 \InsetSpace ~
3479 Test it and turn it on permanently if it works with your system.
3479 Test it and turn it on permanently if it works with your system.
3480 The magic function
3480 The magic function
3481 \family typewriter
3481 \family typewriter
3482 %color_info
3482 %color_info
3483 \family default
3483 \family default
3484 allows you to toggle this interactively for testing.
3484 allows you to toggle this interactively for testing.
3485 \end_layout
3485 \end_layout
3486
3486
3487 \begin_layout List
3487 \begin_layout List
3488 \labelwidthstring 00.00.0000
3488 \labelwidthstring 00.00.0000
3489
3489
3490 \family typewriter
3490 \family typewriter
3491 \series bold
3491 \series bold
3492 -[no]debug
3492 -[no]debug
3493 \family default
3493 \family default
3494 \series default
3494 \series default
3495 : Show information about the loading process.
3495 : Show information about the loading process.
3496 Very useful to pin down problems with your configuration files or to get
3496 Very useful to pin down problems with your configuration files or to get
3497 details about session restores.
3497 details about session restores.
3498 \end_layout
3498 \end_layout
3499
3499
3500 \begin_layout List
3500 \begin_layout List
3501 \labelwidthstring 00.00.0000
3501 \labelwidthstring 00.00.0000
3502
3502
3503 \family typewriter
3503 \family typewriter
3504 \series bold
3504 \series bold
3505 -[no]deep_reload
3505 -[no]deep_reload
3506 \series default
3506 \series default
3507 :
3507 :
3508 \family default
3508 \family default
3509 IPython can use the
3509 IPython can use the
3510 \family typewriter
3510 \family typewriter
3511 deep_reload
3511 deep_reload
3512 \family default
3512 \family default
3513 module which reloads changes in modules recursively (it replaces the
3513 module which reloads changes in modules recursively (it replaces the
3514 \family typewriter
3514 \family typewriter
3515 reload()
3515 reload()
3516 \family default
3516 \family default
3517 function, so you don't need to change anything to use it).
3517 function, so you don't need to change anything to use it).
3518
3518
3519 \family typewriter
3519 \family typewriter
3520 deep_reload()
3520 deep_reload()
3521 \family default
3521 \family default
3522 forces a full reload of modules whose code may have changed, which the
3522 forces a full reload of modules whose code may have changed, which the
3523 default
3523 default
3524 \family typewriter
3524 \family typewriter
3525 reload()
3525 reload()
3526 \family default
3526 \family default
3527 function does not.
3527 function does not.
3528 \end_layout
3528 \end_layout
3529
3529
3530 \begin_layout List
3530 \begin_layout List
3531 \labelwidthstring 00.00.0000
3531 \labelwidthstring 00.00.0000
3532 \InsetSpace ~
3532 \InsetSpace ~
3533 When deep_reload is off, IPython will use the normal
3533 When deep_reload is off, IPython will use the normal
3534 \family typewriter
3534 \family typewriter
3535 reload()
3535 reload()
3536 \family default
3536 \family default
3537 , but deep_reload will still be available as
3537 , but deep_reload will still be available as
3538 \family typewriter
3538 \family typewriter
3539 dreload()
3539 dreload()
3540 \family default
3540 \family default
3541 .
3541 .
3542 This feature is off by default [which means that you have both normal
3542 This feature is off by default [which means that you have both normal
3543 \family typewriter
3543 \family typewriter
3544 reload()
3544 reload()
3545 \family default
3545 \family default
3546 and
3546 and
3547 \family typewriter
3547 \family typewriter
3548 dreload()
3548 dreload()
3549 \family default
3549 \family default
3550 ].
3550 ].
3551 \end_layout
3551 \end_layout
3552
3552
3553 \begin_layout List
3553 \begin_layout List
3554 \labelwidthstring 00.00.0000
3554 \labelwidthstring 00.00.0000
3555
3555
3556 \family typewriter
3556 \family typewriter
3557 \series bold
3557 \series bold
3558 -editor\InsetSpace ~
3558 -editor\InsetSpace ~
3559 <name>
3559 <name>
3560 \family default
3560 \family default
3561 \series default
3561 \series default
3562 : Which editor to use with the
3562 : Which editor to use with the
3563 \family typewriter
3563 \family typewriter
3564 %edit
3564 %edit
3565 \family default
3565 \family default
3566 command.
3566 command.
3567 By default, IPython will honor your
3567 By default, IPython will honor your
3568 \family typewriter
3568 \family typewriter
3569 EDITOR
3569 EDITOR
3570 \family default
3570 \family default
3571 environment variable (if not set, vi is the Unix default and notepad the
3571 environment variable (if not set, vi is the Unix default and notepad the
3572 Windows one).
3572 Windows one).
3573 Since this editor is invoked on the fly by IPython and is meant for editing
3573 Since this editor is invoked on the fly by IPython and is meant for editing
3574 small code snippets, you may want to use a small, lightweight editor here
3574 small code snippets, you may want to use a small, lightweight editor here
3575 (in case your default
3575 (in case your default
3576 \family typewriter
3576 \family typewriter
3577 EDITOR
3577 EDITOR
3578 \family default
3578 \family default
3579 is something like Emacs).
3579 is something like Emacs).
3580 \end_layout
3580 \end_layout
3581
3581
3582 \begin_layout List
3582 \begin_layout List
3583 \labelwidthstring 00.00.0000
3583 \labelwidthstring 00.00.0000
3584
3584
3585 \family typewriter
3585 \family typewriter
3586 \series bold
3586 \series bold
3587 -ipythondir\InsetSpace ~
3587 -ipythondir\InsetSpace ~
3588 <name>
3588 <name>
3589 \series default
3589 \series default
3590 :
3590 :
3591 \family default
3591 \family default
3592 name of your IPython configuration directory
3592 name of your IPython configuration directory
3593 \family typewriter
3593 \family typewriter
3594 IPYTHONDIR
3594 IPYTHONDIR
3595 \family default
3595 \family default
3596 .
3596 .
3597 This can also be specified through the environment variable
3597 This can also be specified through the environment variable
3598 \family typewriter
3598 \family typewriter
3599 IPYTHONDIR
3599 IPYTHONDIR
3600 \family default
3600 \family default
3601 .
3601 .
3602 \end_layout
3602 \end_layout
3603
3603
3604 \begin_layout List
3604 \begin_layout List
3605 \labelwidthstring 00.00.0000
3605 \labelwidthstring 00.00.0000
3606
3606
3607 \family typewriter
3607 \family typewriter
3608 \series bold
3608 \series bold
3609 -log|l
3609 -log|l
3610 \family default
3610 \family default
3611 \series default
3611 \series default
3612 : generate a log file of all input.
3612 : generate a log file of all input.
3613 The file is named
3613 The file is named
3614 \family typewriter
3614 \family typewriter
3615 ipython_log.py
3615 ipython_log.py
3616 \family default
3616 \family default
3617 in your current directory (which prevents logs from multiple IPython sessions
3617 in your current directory (which prevents logs from multiple IPython sessions
3618 from trampling each other).
3618 from trampling each other).
3619 You can use this to later restore a session by loading your logfile as
3619 You can use this to later restore a session by loading your logfile as
3620 a file to be executed with option
3620 a file to be executed with option
3621 \family typewriter
3621 \family typewriter
3622 -logplay
3622 -logplay
3623 \family default
3623 \family default
3624 (see below).
3624 (see below).
3625 \end_layout
3625 \end_layout
3626
3626
3627 \begin_layout List
3627 \begin_layout List
3628 \labelwidthstring 00.00.0000
3628 \labelwidthstring 00.00.0000
3629
3629
3630 \family typewriter
3630 \family typewriter
3631 \series bold
3631 \series bold
3632 -logfile|lf\InsetSpace ~
3632 -logfile|lf\InsetSpace ~
3633 <name>
3633 <name>
3634 \series default
3634 \series default
3635 :
3635 :
3636 \family default
3636 \family default
3637 specify the name of your logfile.
3637 specify the name of your logfile.
3638 \end_layout
3638 \end_layout
3639
3639
3640 \begin_layout List
3640 \begin_layout List
3641 \labelwidthstring 00.00.0000
3641 \labelwidthstring 00.00.0000
3642
3642
3643 \family typewriter
3643 \family typewriter
3644 \series bold
3644 \series bold
3645 -logplay|lp\InsetSpace ~
3645 -logplay|lp\InsetSpace ~
3646 <name>
3646 <name>
3647 \series default
3647 \series default
3648 :
3648 :
3649 \family default
3649 \family default
3650 you can replay a previous log.
3650 you can replay a previous log.
3651 For restoring a session as close as possible to the state you left it in,
3651 For restoring a session as close as possible to the state you left it in,
3652 use this option (don't just run the logfile).
3652 use this option (don't just run the logfile).
3653 With
3653 With
3654 \family typewriter
3654 \family typewriter
3655 -logplay
3655 -logplay
3656 \family default
3656 \family default
3657 , IPython will try to reconstruct the previous working environment in full,
3657 , IPython will try to reconstruct the previous working environment in full,
3658 not just execute the commands in the logfile.
3658 not just execute the commands in the logfile.
3659 \end_layout
3659 \end_layout
3660
3660
3661 \begin_layout List
3661 \begin_layout List
3662 \labelwidthstring 00.00.0000
3662 \labelwidthstring 00.00.0000
3663 \InsetSpace ~
3663 \InsetSpace ~
3664 When a session is restored, logging is automatically turned on again with
3664 When a session is restored, logging is automatically turned on again with
3665 the name of the logfile it was invoked with (it is read from the log header).
3665 the name of the logfile it was invoked with (it is read from the log header).
3666 So once you've turned logging on for a session, you can quit IPython and
3666 So once you've turned logging on for a session, you can quit IPython and
3667 reload it as many times as you want and it will continue to log its history
3667 reload it as many times as you want and it will continue to log its history
3668 and restore from the beginning every time.
3668 and restore from the beginning every time.
3669 \end_layout
3669 \end_layout
3670
3670
3671 \begin_layout List
3671 \begin_layout List
3672 \labelwidthstring 00.00.0000
3672 \labelwidthstring 00.00.0000
3673 \InsetSpace ~
3673 \InsetSpace ~
3674 Caveats: there are limitations in this option.
3674 Caveats: there are limitations in this option.
3675 The history variables
3675 The history variables
3676 \family typewriter
3676 \family typewriter
3677 _i*
3677 _i*
3678 \family default
3678 \family default
3679 ,
3679 ,
3680 \family typewriter
3680 \family typewriter
3681 _*
3681 _*
3682 \family default
3682 \family default
3683 and
3683 and
3684 \family typewriter
3684 \family typewriter
3685 _dh
3685 _dh
3686 \family default
3686 \family default
3687 don't get restored properly.
3687 don't get restored properly.
3688 In the future we will try to implement full session saving by writing and
3688 In the future we will try to implement full session saving by writing and
3689 retrieving a 'snapshot' of the memory state of IPython.
3689 retrieving a 'snapshot' of the memory state of IPython.
3690 But our first attempts failed because of inherent limitations of Python's
3690 But our first attempts failed because of inherent limitations of Python's
3691 Pickle module, so this may have to wait.
3691 Pickle module, so this may have to wait.
3692 \end_layout
3692 \end_layout
3693
3693
3694 \begin_layout List
3694 \begin_layout List
3695 \labelwidthstring 00.00.0000
3695 \labelwidthstring 00.00.0000
3696
3696
3697 \family typewriter
3697 \family typewriter
3698 \series bold
3698 \series bold
3699 -[no]messages
3699 -[no]messages
3700 \series default
3700 \series default
3701 :
3701 :
3702 \family default
3702 \family default
3703 Print messages which IPython collects about its startup process (default
3703 Print messages which IPython collects about its startup process (default
3704 on).
3704 on).
3705 \end_layout
3705 \end_layout
3706
3706
3707 \begin_layout List
3707 \begin_layout List
3708 \labelwidthstring 00.00.0000
3708 \labelwidthstring 00.00.0000
3709
3709
3710 \family typewriter
3710 \family typewriter
3711 \series bold
3711 \series bold
3712 -[no]pdb
3712 -[no]pdb
3713 \family default
3713 \family default
3714 \series default
3714 \series default
3715 : Automatically call the pdb debugger after every uncaught exception.
3715 : Automatically call the pdb debugger after every uncaught exception.
3716 If you are used to debugging using pdb, this puts you automatically inside
3716 If you are used to debugging using pdb, this puts you automatically inside
3717 of it after any call (either in IPython or in code called by it) which
3717 of it after any call (either in IPython or in code called by it) which
3718 triggers an exception which goes uncaught.
3718 triggers an exception which goes uncaught.
3719 \end_layout
3719 \end_layout
3720
3720
3721 \begin_layout List
3721 \begin_layout List
3722 \labelwidthstring 00.00.0000
3722 \labelwidthstring 00.00.0000
3723
3723
3724 \family typewriter
3724 \family typewriter
3725 \series bold
3725 \series bold
3726 -[no]pprint
3726 -[no]pprint
3727 \series default
3727 \series default
3728 :
3728 :
3729 \family default
3729 \family default
3730 ipython can optionally use the pprint (pretty printer) module for displaying
3730 ipython can optionally use the pprint (pretty printer) module for displaying
3731 results.
3731 results.
3732 pprint tends to give a nicer display of nested data structures.
3732 pprint tends to give a nicer display of nested data structures.
3733 If you like it, you can turn it on permanently in your config file (default
3733 If you like it, you can turn it on permanently in your config file (default
3734 off).
3734 off).
3735 \end_layout
3735 \end_layout
3736
3736
3737 \begin_layout List
3737 \begin_layout List
3738 \labelwidthstring 00.00.0000
3738 \labelwidthstring 00.00.0000
3739
3739
3740 \family typewriter
3740 \family typewriter
3741 \series bold
3741 \series bold
3742 -profile|p <name>
3742 -profile|p <name>
3743 \series default
3743 \series default
3744 :
3744 :
3745 \family default
3745 \family default
3746 assume that your config file is
3746 assume that your config file is
3747 \family typewriter
3747 \family typewriter
3748 ipythonrc-<name>
3748 ipythonrc-<name>
3749 \family default
3749 \family default
3750 (looks in current dir first, then in
3750 (looks in current dir first, then in
3751 \family typewriter
3751 \family typewriter
3752 IPYTHONDIR
3752 IPYTHONDIR
3753 \family default
3753 \family default
3754 ).
3754 ).
3755 This is a quick way to keep and load multiple config files for different
3755 This is a quick way to keep and load multiple config files for different
3756 tasks, especially if you use the include option of config files.
3756 tasks, especially if you use the include option of config files.
3757 You can keep a basic
3757 You can keep a basic
3758 \family typewriter
3758 \family typewriter
3759 IPYTHONDIR/ipythonrc
3759 IPYTHONDIR/ipythonrc
3760 \family default
3760 \family default
3761 file and then have other 'profiles' which include this one and load extra
3761 file and then have other 'profiles' which include this one and load extra
3762 things for particular tasks.
3762 things for particular tasks.
3763 For example:
3763 For example:
3764 \end_layout
3764 \end_layout
3765
3765
3766 \begin_layout List
3766 \begin_layout List
3767 \labelwidthstring 00.00.0000
3767 \labelwidthstring 00.00.0000
3768
3768
3769 \family typewriter
3769 \family typewriter
3770 \InsetSpace ~
3770 \InsetSpace ~
3771
3771
3772 \family default
3772 \family default
3773 1.
3773 1.
3774
3774
3775 \family typewriter
3775 \family typewriter
3776 $HOME/.ipython/ipythonrc
3776 $HOME/.ipython/ipythonrc
3777 \family default
3777 \family default
3778 : load basic things you always want.
3778 : load basic things you always want.
3779 \end_layout
3779 \end_layout
3780
3780
3781 \begin_layout List
3781 \begin_layout List
3782 \labelwidthstring 00.00.0000
3782 \labelwidthstring 00.00.0000
3783
3783
3784 \family typewriter
3784 \family typewriter
3785 \InsetSpace ~
3785 \InsetSpace ~
3786
3786
3787 \family default
3787 \family default
3788 2.
3788 2.
3789
3789
3790 \family typewriter
3790 \family typewriter
3791 $HOME/.ipython/ipythonrc-math
3791 $HOME/.ipython/ipythonrc-math
3792 \family default
3792 \family default
3793 : load (1) and basic math-related modules.
3793 : load (1) and basic math-related modules.
3794
3794
3795 \end_layout
3795 \end_layout
3796
3796
3797 \begin_layout List
3797 \begin_layout List
3798 \labelwidthstring 00.00.0000
3798 \labelwidthstring 00.00.0000
3799
3799
3800 \family typewriter
3800 \family typewriter
3801 \InsetSpace ~
3801 \InsetSpace ~
3802
3802
3803 \family default
3803 \family default
3804 3.
3804 3.
3805
3805
3806 \family typewriter
3806 \family typewriter
3807 $HOME/.ipython/ipythonrc-numeric
3807 $HOME/.ipython/ipythonrc-numeric
3808 \family default
3808 \family default
3809 : load (1) and Numeric and plotting modules.
3809 : load (1) and Numeric and plotting modules.
3810 \end_layout
3810 \end_layout
3811
3811
3812 \begin_layout List
3812 \begin_layout List
3813 \labelwidthstring 00.00.0000
3813 \labelwidthstring 00.00.0000
3814 \InsetSpace ~
3814 \InsetSpace ~
3815 Since it is possible to create an endless loop by having circular file
3815 Since it is possible to create an endless loop by having circular file
3816 inclusions, IPython will stop if it reaches 15 recursive inclusions.
3816 inclusions, IPython will stop if it reaches 15 recursive inclusions.
3817 \end_layout
3817 \end_layout
3818
3818
3819 \begin_layout List
3819 \begin_layout List
3820 \labelwidthstring 00.00.0000
3820 \labelwidthstring 00.00.0000
3821
3821
3822 \family typewriter
3822 \family typewriter
3823 \series bold
3823 \series bold
3824 -prompt_in1|pi1\InsetSpace ~
3824 -prompt_in1|pi1\InsetSpace ~
3825 <string>:
3825 <string>:
3826 \family default
3826 \family default
3827 \series default
3827 \series default
3828 Specify the string used for input prompts.
3828 Specify the string used for input prompts.
3829 Note that if you are using numbered prompts, the number is represented
3829 Note that if you are using numbered prompts, the number is represented
3830 with a '
3830 with a '
3831 \backslash
3831 \backslash
3832 #' in the string.
3832 #' in the string.
3833 Don't forget to quote strings with spaces embedded in them.
3833 Don't forget to quote strings with spaces embedded in them.
3834 Default: '
3834 Default: '
3835 \family typewriter
3835 \family typewriter
3836 In\InsetSpace ~
3836 In\InsetSpace ~
3837 [
3837 [
3838 \backslash
3838 \backslash
3839 #]:
3839 #]:
3840 \family default
3840 \family default
3841 '.
3841 '.
3842 Sec.\InsetSpace ~
3842 Sec.\InsetSpace ~
3843
3843
3844 \begin_inset LatexCommand \ref{sec:prompts}
3844 \begin_inset LatexCommand \ref{sec:prompts}
3845
3845
3846 \end_inset
3846 \end_inset
3847
3847
3848 discusses in detail all the available escapes to customize your prompts.
3848 discusses in detail all the available escapes to customize your prompts.
3849 \end_layout
3849 \end_layout
3850
3850
3851 \begin_layout List
3851 \begin_layout List
3852 \labelwidthstring 00.00.0000
3852 \labelwidthstring 00.00.0000
3853
3853
3854 \family typewriter
3854 \family typewriter
3855 \series bold
3855 \series bold
3856 -prompt_in2|pi2\InsetSpace ~
3856 -prompt_in2|pi2\InsetSpace ~
3857 <string>:
3857 <string>:
3858 \family default
3858 \family default
3859 \series default
3859 \series default
3860 Similar to the previous option, but used for the continuation prompts.
3860 Similar to the previous option, but used for the continuation prompts.
3861 The special sequence '
3861 The special sequence '
3862 \family typewriter
3862 \family typewriter
3863
3863
3864 \backslash
3864 \backslash
3865 D
3865 D
3866 \family default
3866 \family default
3867 ' is similar to '
3867 ' is similar to '
3868 \family typewriter
3868 \family typewriter
3869
3869
3870 \backslash
3870 \backslash
3871 #
3871 #
3872 \family default
3872 \family default
3873 ', but with all digits replaced dots (so you can have your continuation
3873 ', but with all digits replaced dots (so you can have your continuation
3874 prompt aligned with your input prompt).
3874 prompt aligned with your input prompt).
3875 Default: '
3875 Default: '
3876 \family typewriter
3876 \family typewriter
3877 \InsetSpace ~
3877 \InsetSpace ~
3878 \InsetSpace ~
3878 \InsetSpace ~
3879 \InsetSpace ~
3879 \InsetSpace ~
3880 .
3880 .
3881 \backslash
3881 \backslash
3882 D.:
3882 D.:
3883 \family default
3883 \family default
3884 ' (note three spaces at the start for alignment with '
3884 ' (note three spaces at the start for alignment with '
3885 \family typewriter
3885 \family typewriter
3886 In\InsetSpace ~
3886 In\InsetSpace ~
3887 [
3887 [
3888 \backslash
3888 \backslash
3889 #]
3889 #]
3890 \family default
3890 \family default
3891 ').
3891 ').
3892 \end_layout
3892 \end_layout
3893
3893
3894 \begin_layout List
3894 \begin_layout List
3895 \labelwidthstring 00.00.0000
3895 \labelwidthstring 00.00.0000
3896
3896
3897 \family typewriter
3897 \family typewriter
3898 \series bold
3898 \series bold
3899 -prompt_out|po\InsetSpace ~
3899 -prompt_out|po\InsetSpace ~
3900 <string>:
3900 <string>:
3901 \family default
3901 \family default
3902 \series default
3902 \series default
3903 String used for output prompts, also uses numbers like
3903 String used for output prompts, also uses numbers like
3904 \family typewriter
3904 \family typewriter
3905 prompt_in1
3905 prompt_in1
3906 \family default
3906 \family default
3907 .
3907 .
3908 Default: '
3908 Default: '
3909 \family typewriter
3909 \family typewriter
3910 Out[
3910 Out[
3911 \backslash
3911 \backslash
3912 #]:
3912 #]:
3913 \family default
3913 \family default
3914 '
3914 '
3915 \end_layout
3915 \end_layout
3916
3916
3917 \begin_layout List
3917 \begin_layout List
3918 \labelwidthstring 00.00.0000
3918 \labelwidthstring 00.00.0000
3919
3919
3920 \family typewriter
3920 \family typewriter
3921 \series bold
3921 \series bold
3922 -quick
3922 -quick
3923 \family default
3923 \family default
3924 \series default
3924 \series default
3925 : start in bare bones mode (no config file loaded).
3925 : start in bare bones mode (no config file loaded).
3926 \end_layout
3926 \end_layout
3927
3927
3928 \begin_layout List
3928 \begin_layout List
3929 \labelwidthstring 00.00.0000
3929 \labelwidthstring 00.00.0000
3930
3930
3931 \family typewriter
3931 \family typewriter
3932 \series bold
3932 \series bold
3933 -rcfile\InsetSpace ~
3933 -rcfile\InsetSpace ~
3934 <name>
3934 <name>
3935 \series default
3935 \series default
3936 :
3936 :
3937 \family default
3937 \family default
3938 name of your IPython resource configuration file.
3938 name of your IPython resource configuration file.
3939 Normally IPython loads ipythonrc (from current directory) or
3939 Normally IPython loads ipythonrc (from current directory) or
3940 \family typewriter
3940 \family typewriter
3941 IPYTHONDIR/ipythonrc
3941 IPYTHONDIR/ipythonrc
3942 \family default
3942 \family default
3943 .
3943 .
3944 \end_layout
3944 \end_layout
3945
3945
3946 \begin_layout List
3946 \begin_layout List
3947 \labelwidthstring 00.00.0000
3947 \labelwidthstring 00.00.0000
3948 \InsetSpace ~
3948 \InsetSpace ~
3949 If the loading of your config file fails, IPython starts with a bare bones
3949 If the loading of your config file fails, IPython starts with a bare bones
3950 configuration (no modules loaded at all).
3950 configuration (no modules loaded at all).
3951 \end_layout
3951 \end_layout
3952
3952
3953 \begin_layout List
3953 \begin_layout List
3954 \labelwidthstring 00.00.0000
3954 \labelwidthstring 00.00.0000
3955
3955
3956 \family typewriter
3956 \family typewriter
3957 \series bold
3957 \series bold
3958 -[no]readline
3958 -[no]readline
3959 \family default
3959 \family default
3960 \series default
3960 \series default
3961 : use the readline library, which is needed to support name completion and
3961 : use the readline library, which is needed to support name completion and
3962 command history, among other things.
3962 command history, among other things.
3963 It is enabled by default, but may cause problems for users of X/Emacs in
3963 It is enabled by default, but may cause problems for users of X/Emacs in
3964 Python comint or shell buffers.
3964 Python comint or shell buffers.
3965 \end_layout
3965 \end_layout
3966
3966
3967 \begin_layout List
3967 \begin_layout List
3968 \labelwidthstring 00.00.0000
3968 \labelwidthstring 00.00.0000
3969 \InsetSpace ~
3969 \InsetSpace ~
3970 Note that X/Emacs 'eterm' buffers (opened with
3970 Note that X/Emacs 'eterm' buffers (opened with
3971 \family typewriter
3971 \family typewriter
3972 M-x\InsetSpace ~
3972 M-x\InsetSpace ~
3973 term
3973 term
3974 \family default
3974 \family default
3975 ) support IPython's readline and syntax coloring fine, only 'emacs' (
3975 ) support IPython's readline and syntax coloring fine, only 'emacs' (
3976 \family typewriter
3976 \family typewriter
3977 M-x\InsetSpace ~
3977 M-x\InsetSpace ~
3978 shell
3978 shell
3979 \family default
3979 \family default
3980 and
3980 and
3981 \family typewriter
3981 \family typewriter
3982 C-c\InsetSpace ~
3982 C-c\InsetSpace ~
3983 !
3983 !
3984 \family default
3984 \family default
3985 ) buffers do not.
3985 ) buffers do not.
3986 \end_layout
3986 \end_layout
3987
3987
3988 \begin_layout List
3988 \begin_layout List
3989 \labelwidthstring 00.00.0000
3989 \labelwidthstring 00.00.0000
3990
3990
3991 \family typewriter
3991 \family typewriter
3992 \series bold
3992 \series bold
3993 -screen_length|sl\InsetSpace ~
3993 -screen_length|sl\InsetSpace ~
3994 <n>
3994 <n>
3995 \series default
3995 \series default
3996 :
3996 :
3997 \family default
3997 \family default
3998 number of lines of your screen.
3998 number of lines of your screen.
3999 This is used to control printing of very long strings.
3999 This is used to control printing of very long strings.
4000 Strings longer than this number of lines will be sent through a pager instead
4000 Strings longer than this number of lines will be sent through a pager instead
4001 of directly printed.
4001 of directly printed.
4002 \end_layout
4002 \end_layout
4003
4003
4004 \begin_layout List
4004 \begin_layout List
4005 \labelwidthstring 00.00.0000
4005 \labelwidthstring 00.00.0000
4006 \InsetSpace ~
4006 \InsetSpace ~
4007 The default value for this is 0, which means IPython will auto-detect your
4007 The default value for this is 0, which means IPython will auto-detect your
4008 screen size every time it needs to print certain potentially long strings
4008 screen size every time it needs to print certain potentially long strings
4009 (this doesn't change the behavior of the 'print' keyword, it's only triggered
4009 (this doesn't change the behavior of the 'print' keyword, it's only triggered
4010 internally).
4010 internally).
4011 If for some reason this isn't working well (it needs curses support), specify
4011 If for some reason this isn't working well (it needs curses support), specify
4012 it yourself.
4012 it yourself.
4013 Otherwise don't change the default.
4013 Otherwise don't change the default.
4014 \end_layout
4014 \end_layout
4015
4015
4016 \begin_layout List
4016 \begin_layout List
4017 \labelwidthstring 00.00.0000
4017 \labelwidthstring 00.00.0000
4018
4018
4019 \family typewriter
4019 \family typewriter
4020 \series bold
4020 \series bold
4021 -separate_in|si\InsetSpace ~
4021 -separate_in|si\InsetSpace ~
4022 <string>
4022 <string>
4023 \series default
4023 \series default
4024 :
4024 :
4025 \family default
4025 \family default
4026 separator before input prompts.
4026 separator before input prompts.
4027 Default: '
4027 Default: '
4028 \family typewriter
4028 \family typewriter
4029
4029
4030 \backslash
4030 \backslash
4031 n
4031 n
4032 \family default
4032 \family default
4033 '
4033 '
4034 \end_layout
4034 \end_layout
4035
4035
4036 \begin_layout List
4036 \begin_layout List
4037 \labelwidthstring 00.00.0000
4037 \labelwidthstring 00.00.0000
4038
4038
4039 \family typewriter
4039 \family typewriter
4040 \series bold
4040 \series bold
4041 -separate_out|so\InsetSpace ~
4041 -separate_out|so\InsetSpace ~
4042 <string>
4042 <string>
4043 \family default
4043 \family default
4044 \series default
4044 \series default
4045 : separator before output prompts.
4045 : separator before output prompts.
4046 Default: nothing.
4046 Default: nothing.
4047 \end_layout
4047 \end_layout
4048
4048
4049 \begin_layout List
4049 \begin_layout List
4050 \labelwidthstring 00.00.0000
4050 \labelwidthstring 00.00.0000
4051
4051
4052 \family typewriter
4052 \family typewriter
4053 \series bold
4053 \series bold
4054 -separate_out2|so2\InsetSpace ~
4054 -separate_out2|so2\InsetSpace ~
4055 <string>
4055 <string>
4056 \series default
4056 \series default
4057 :
4057 :
4058 \family default
4058 \family default
4059 separator after output prompts.
4059 separator after output prompts.
4060 Default: nothing.
4060 Default: nothing.
4061 \end_layout
4061 \end_layout
4062
4062
4063 \begin_layout List
4063 \begin_layout List
4064 \labelwidthstring 00.00.0000
4064 \labelwidthstring 00.00.0000
4065 \InsetSpace ~
4065 \InsetSpace ~
4066 For these three options, use the value 0 to specify no separator.
4066 For these three options, use the value 0 to specify no separator.
4067 \end_layout
4067 \end_layout
4068
4068
4069 \begin_layout List
4069 \begin_layout List
4070 \labelwidthstring 00.00.0000
4070 \labelwidthstring 00.00.0000
4071
4071
4072 \family typewriter
4072 \family typewriter
4073 \series bold
4073 \series bold
4074 -nosep
4074 -nosep
4075 \series default
4075 \series default
4076 :
4076 :
4077 \family default
4077 \family default
4078 shorthand for
4078 shorthand for
4079 \family typewriter
4079 \family typewriter
4080 '-SeparateIn 0 -SeparateOut 0 -SeparateOut2 0'
4080 '-SeparateIn 0 -SeparateOut 0 -SeparateOut2 0'
4081 \family default
4081 \family default
4082 .
4082 .
4083 Simply removes all input/output separators.
4083 Simply removes all input/output separators.
4084 \end_layout
4084 \end_layout
4085
4085
4086 \begin_layout List
4086 \begin_layout List
4087 \labelwidthstring 00.00.0000
4087 \labelwidthstring 00.00.0000
4088
4088
4089 \family typewriter
4089 \family typewriter
4090 \series bold
4090 \series bold
4091 -upgrade
4091 -upgrade
4092 \family default
4092 \family default
4093 \series default
4093 \series default
4094 : allows you to upgrade your
4094 : allows you to upgrade your
4095 \family typewriter
4095 \family typewriter
4096 IPYTHONDIR
4096 IPYTHONDIR
4097 \family default
4097 \family default
4098 configuration when you install a new version of IPython.
4098 configuration when you install a new version of IPython.
4099 Since new versions may include new command line options or example files,
4099 Since new versions may include new command line options or example files,
4100 this copies updated ipythonrc-type files.
4100 this copies updated ipythonrc-type files.
4101 However, it backs up (with a
4101 However, it backs up (with a
4102 \family typewriter
4102 \family typewriter
4103 .old
4103 .old
4104 \family default
4104 \family default
4105 extension) all files which it overwrites so that you can merge back any
4105 extension) all files which it overwrites so that you can merge back any
4106 customizations you might have in your personal files.
4106 customizations you might have in your personal files.
4107 \end_layout
4107 \end_layout
4108
4108
4109 \begin_layout List
4109 \begin_layout List
4110 \labelwidthstring 00.00.0000
4110 \labelwidthstring 00.00.0000
4111
4111
4112 \family typewriter
4112 \family typewriter
4113 \series bold
4113 \series bold
4114 -Version
4114 -Version
4115 \series default
4115 \series default
4116 :
4116 :
4117 \family default
4117 \family default
4118 print version information and exit.
4118 print version information and exit.
4119 \end_layout
4119 \end_layout
4120
4120
4121 \begin_layout List
4121 \begin_layout List
4122 \labelwidthstring 00.00.0000
4122 \labelwidthstring 00.00.0000
4123
4123
4124 \family typewriter
4124 \family typewriter
4125 \series bold
4125 \series bold
4126 -wxversion\InsetSpace ~
4126 -wxversion\InsetSpace ~
4127 <string>:
4127 <string>:
4128 \family default
4128 \family default
4129 \series default
4129 \series default
4130 Select a specific version of wxPython (used in conjunction with
4130 Select a specific version of wxPython (used in conjunction with
4131 \family typewriter
4131 \family typewriter
4132 -wthread
4132 -wthread
4133 \family default
4133 \family default
4134 ).
4134 ).
4135 Requires the wxversion module, part of recent wxPython distributions
4135 Requires the wxversion module, part of recent wxPython distributions
4136 \end_layout
4136 \end_layout
4137
4137
4138 \begin_layout List
4138 \begin_layout List
4139 \labelwidthstring 00.00.0000
4139 \labelwidthstring 00.00.0000
4140
4140
4141 \family typewriter
4141 \family typewriter
4142 \series bold
4142 \series bold
4143 -xmode\InsetSpace ~
4143 -xmode\InsetSpace ~
4144 <modename>
4144 <modename>
4145 \series default
4145 \series default
4146 :
4146 :
4147 \family default
4147 \family default
4148 Mode for exception reporting.
4148 Mode for exception reporting.
4149 \end_layout
4149 \end_layout
4150
4150
4151 \begin_layout List
4151 \begin_layout List
4152 \labelwidthstring 00.00.0000
4152 \labelwidthstring 00.00.0000
4153 \InsetSpace ~
4153 \InsetSpace ~
4154 Valid modes: Plain, Context and Verbose.
4154 Valid modes: Plain, Context and Verbose.
4155 \end_layout
4155 \end_layout
4156
4156
4157 \begin_layout List
4157 \begin_layout List
4158 \labelwidthstring 00.00.0000
4158 \labelwidthstring 00.00.0000
4159 \InsetSpace ~
4159 \InsetSpace ~
4160 Plain: similar to python's normal traceback printing.
4160 Plain: similar to python's normal traceback printing.
4161 \end_layout
4161 \end_layout
4162
4162
4163 \begin_layout List
4163 \begin_layout List
4164 \labelwidthstring 00.00.0000
4164 \labelwidthstring 00.00.0000
4165 \InsetSpace ~
4165 \InsetSpace ~
4166 Context: prints 5 lines of context source code around each line in the
4166 Context: prints 5 lines of context source code around each line in the
4167 traceback.
4167 traceback.
4168 \end_layout
4168 \end_layout
4169
4169
4170 \begin_layout List
4170 \begin_layout List
4171 \labelwidthstring 00.00.0000
4171 \labelwidthstring 00.00.0000
4172 \InsetSpace ~
4172 \InsetSpace ~
4173 Verbose: similar to Context, but additionally prints the variables currently
4173 Verbose: similar to Context, but additionally prints the variables currently
4174 visible where the exception happened (shortening their strings if too long).
4174 visible where the exception happened (shortening their strings if too long).
4175 This can potentially be very slow, if you happen to have a huge data structure
4175 This can potentially be very slow, if you happen to have a huge data structure
4176 whose string representation is complex to compute.
4176 whose string representation is complex to compute.
4177 Your computer may appear to freeze for a while with cpu usage at 100%.
4177 Your computer may appear to freeze for a while with cpu usage at 100%.
4178 If this occurs, you can cancel the traceback with Ctrl-C (maybe hitting
4178 If this occurs, you can cancel the traceback with Ctrl-C (maybe hitting
4179 it more than once).
4179 it more than once).
4180 \end_layout
4180 \end_layout
4181
4181
4182 \begin_layout Section
4182 \begin_layout Section
4183 Interactive use
4183 Interactive use
4184 \end_layout
4184 \end_layout
4185
4185
4186 \begin_layout Standard
4186 \begin_layout Standard
4187
4187
4188 \series bold
4188 \series bold
4189 Warning
4189 Warning
4190 \series default
4190 \series default
4191 : IPython relies on the existence of a global variable called
4191 : IPython relies on the existence of a global variable called
4192 \family typewriter
4192 \family typewriter
4193 __IP
4193 __IP
4194 \family default
4194 \family default
4195 which controls the shell itself.
4195 which controls the shell itself.
4196 If you redefine
4196 If you redefine
4197 \family typewriter
4197 \family typewriter
4198 __IP
4198 __IP
4199 \family default
4199 \family default
4200 to anything, bizarre behavior will quickly occur.
4200 to anything, bizarre behavior will quickly occur.
4201 \end_layout
4201 \end_layout
4202
4202
4203 \begin_layout Standard
4203 \begin_layout Standard
4204 Other than the above warning, IPython is meant to work as a drop-in replacement
4204 Other than the above warning, IPython is meant to work as a drop-in replacement
4205 for the standard interactive interpreter.
4205 for the standard interactive interpreter.
4206 As such, any code which is valid python should execute normally under IPython
4206 As such, any code which is valid python should execute normally under IPython
4207 (cases where this is not true should be reported as bugs).
4207 (cases where this is not true should be reported as bugs).
4208 It does, however, offer many features which are not available at a standard
4208 It does, however, offer many features which are not available at a standard
4209 python prompt.
4209 python prompt.
4210 What follows is a list of these.
4210 What follows is a list of these.
4211 \end_layout
4211 \end_layout
4212
4212
4213 \begin_layout Subsection
4213 \begin_layout Subsection
4214 Caution for Windows users
4214 Caution for Windows users
4215 \end_layout
4215 \end_layout
4216
4216
4217 \begin_layout Standard
4217 \begin_layout Standard
4218 Windows, unfortunately, uses the `
4218 Windows, unfortunately, uses the `
4219 \family typewriter
4219 \family typewriter
4220
4220
4221 \backslash
4221 \backslash
4222
4222
4223 \family default
4223 \family default
4224 ' character as a path separator.
4224 ' character as a path separator.
4225 This is a terrible choice, because `
4225 This is a terrible choice, because `
4226 \family typewriter
4226 \family typewriter
4227
4227
4228 \backslash
4228 \backslash
4229
4229
4230 \family default
4230 \family default
4231 ' also represents the escape character in most modern programming languages,
4231 ' also represents the escape character in most modern programming languages,
4232 including Python.
4232 including Python.
4233 For this reason, issuing many of the commands discussed below (especially
4233 For this reason, issuing many of the commands discussed below (especially
4234 magics which affect the filesystem) with `
4234 magics which affect the filesystem) with `
4235 \family typewriter
4235 \family typewriter
4236
4236
4237 \backslash
4237 \backslash
4238
4238
4239 \family default
4239 \family default
4240 ' in them will cause strange errors.
4240 ' in them will cause strange errors.
4241 \end_layout
4241 \end_layout
4242
4242
4243 \begin_layout Standard
4243 \begin_layout Standard
4244 A partial solution is to use instead the `
4244 A partial solution is to use instead the `
4245 \family typewriter
4245 \family typewriter
4246 /
4246 /
4247 \family default
4247 \family default
4248 ' character as a path separator, which Windows recognizes in
4248 ' character as a path separator, which Windows recognizes in
4249 \emph on
4249 \emph on
4250 most
4250 most
4251 \emph default
4251 \emph default
4252 situations.
4252 situations.
4253 However, in Windows commands `
4253 However, in Windows commands `
4254 \family typewriter
4254 \family typewriter
4255 /
4255 /
4256 \family default
4256 \family default
4257 ' flags options, so you can not use it for the root directory.
4257 ' flags options, so you can not use it for the root directory.
4258 This means that paths beginning at the root must be typed in a contrived
4258 This means that paths beginning at the root must be typed in a contrived
4259 manner like:
4259 manner like:
4260 \newline
4260 \newline
4261
4261
4262 \family typewriter
4262 \family typewriter
4263 %copy
4263 %copy
4264 \backslash
4264 \backslash
4265 opt/foo/bar.txt
4265 opt/foo/bar.txt
4266 \backslash
4266 \backslash
4267 tmp
4267 tmp
4268 \end_layout
4268 \end_layout
4269
4269
4270 \begin_layout Standard
4270 \begin_layout Standard
4271 There is no sensible thing IPython can do to truly work around this flaw
4271 There is no sensible thing IPython can do to truly work around this flaw
4272 in Windows
4272 in Windows
4273 \begin_inset Foot
4273 \begin_inset Foot
4274 status collapsed
4274 status collapsed
4275
4275
4276 \begin_layout Standard
4276 \begin_layout Standard
4277 If anyone comes up with a
4277 If anyone comes up with a
4278 \emph on
4278 \emph on
4279 clean
4279 clean
4280 \emph default
4280 \emph default
4281 solution which works consistently and does not negatively impact other
4281 solution which works consistently and does not negatively impact other
4282 platforms at all, I'll gladly accept a patch.
4282 platforms at all, I'll gladly accept a patch.
4283 \end_layout
4283 \end_layout
4284
4284
4285 \end_inset
4285 \end_inset
4286
4286
4287 .
4287 .
4288 \end_layout
4288 \end_layout
4289
4289
4290 \begin_layout Subsection
4290 \begin_layout Subsection
4291 \begin_inset LatexCommand \label{sec:magic}
4291 \begin_inset LatexCommand \label{sec:magic}
4292
4292
4293 \end_inset
4293 \end_inset
4294
4294
4295 Magic command system
4295 Magic command system
4296 \end_layout
4296 \end_layout
4297
4297
4298 \begin_layout Standard
4298 \begin_layout Standard
4299 IPython will treat any line whose first character is a
4299 IPython will treat any line whose first character is a
4300 \family typewriter
4300 \family typewriter
4301 %
4301 %
4302 \family default
4302 \family default
4303 as a special call to a 'magic' function.
4303 as a special call to a 'magic' function.
4304 These allow you to control the behavior of IPython itself, plus a lot of
4304 These allow you to control the behavior of IPython itself, plus a lot of
4305 system-type features.
4305 system-type features.
4306 They are all prefixed with a
4306 They are all prefixed with a
4307 \family typewriter
4307 \family typewriter
4308 %
4308 %
4309 \family default
4309 \family default
4310 character, but parameters are given without parentheses or quotes.
4310 character, but parameters are given without parentheses or quotes.
4311 \end_layout
4311 \end_layout
4312
4312
4313 \begin_layout Standard
4313 \begin_layout Standard
4314 Example: typing
4314 Example: typing
4315 \family typewriter
4315 \family typewriter
4316 '%cd mydir'
4316 '%cd mydir'
4317 \family default
4317 \family default
4318 (without the quotes) changes you working directory to
4318 (without the quotes) changes you working directory to
4319 \family typewriter
4319 \family typewriter
4320 'mydir'
4320 'mydir'
4321 \family default
4321 \family default
4322 , if it exists.
4322 , if it exists.
4323 \end_layout
4323 \end_layout
4324
4324
4325 \begin_layout Standard
4325 \begin_layout Standard
4326 If you have 'automagic' enabled (in your
4326 If you have 'automagic' enabled (in your
4327 \family typewriter
4327 \family typewriter
4328 ipythonrc
4328 ipythonrc
4329 \family default
4329 \family default
4330 file, via the command line option
4330 file, via the command line option
4331 \family typewriter
4331 \family typewriter
4332 -automagic
4332 -automagic
4333 \family default
4333 \family default
4334 or with the
4334 or with the
4335 \family typewriter
4335 \family typewriter
4336 %automagic
4336 %automagic
4337 \family default
4337 \family default
4338 function), you don't need to type in the
4338 function), you don't need to type in the
4339 \family typewriter
4339 \family typewriter
4340 %
4340 %
4341 \family default
4341 \family default
4342 explicitly.
4342 explicitly.
4343 IPython will scan its internal list of magic functions and call one if
4343 IPython will scan its internal list of magic functions and call one if
4344 it exists.
4344 it exists.
4345 With automagic on you can then just type '
4345 With automagic on you can then just type '
4346 \family typewriter
4346 \family typewriter
4347 cd mydir
4347 cd mydir
4348 \family default
4348 \family default
4349 ' to go to directory '
4349 ' to go to directory '
4350 \family typewriter
4350 \family typewriter
4351 mydir
4351 mydir
4352 \family default
4352 \family default
4353 '.
4353 '.
4354 The automagic system has the lowest possible precedence in name searches,
4354 The automagic system has the lowest possible precedence in name searches,
4355 so defining an identifier with the same name as an existing magic function
4355 so defining an identifier with the same name as an existing magic function
4356 will shadow it for automagic use.
4356 will shadow it for automagic use.
4357 You can still access the shadowed magic function by explicitly using the
4357 You can still access the shadowed magic function by explicitly using the
4358
4358
4359 \family typewriter
4359 \family typewriter
4360 %
4360 %
4361 \family default
4361 \family default
4362 character at the beginning of the line.
4362 character at the beginning of the line.
4363 \end_layout
4363 \end_layout
4364
4364
4365 \begin_layout Standard
4365 \begin_layout Standard
4366 An example (with automagic on) should clarify all this:
4366 An example (with automagic on) should clarify all this:
4367 \end_layout
4367 \end_layout
4368
4368
4369 \begin_layout LyX-Code
4369 \begin_layout LyX-Code
4370 In [1]: cd ipython # %cd is called by automagic
4370 In [1]: cd ipython # %cd is called by automagic
4371 \end_layout
4371 \end_layout
4372
4372
4373 \begin_layout LyX-Code
4373 \begin_layout LyX-Code
4374 /home/fperez/ipython
4374 /home/fperez/ipython
4375 \end_layout
4375 \end_layout
4376
4376
4377 \begin_layout LyX-Code
4377 \begin_layout LyX-Code
4378 In [2]: cd=1 # now cd is just a variable
4378 In [2]: cd=1 # now cd is just a variable
4379 \end_layout
4379 \end_layout
4380
4380
4381 \begin_layout LyX-Code
4381 \begin_layout LyX-Code
4382 In [3]: cd ..
4382 In [3]: cd ..
4383 # and doesn't work as a function anymore
4383 # and doesn't work as a function anymore
4384 \end_layout
4384 \end_layout
4385
4385
4386 \begin_layout LyX-Code
4386 \begin_layout LyX-Code
4387 ------------------------------------------------------------
4387 ------------------------------------------------------------
4388 \end_layout
4388 \end_layout
4389
4389
4390 \begin_layout LyX-Code
4390 \begin_layout LyX-Code
4391 File "<console>", line 1
4391 File "<console>", line 1
4392 \end_layout
4392 \end_layout
4393
4393
4394 \begin_layout LyX-Code
4394 \begin_layout LyX-Code
4395 cd ..
4395 cd ..
4396 \end_layout
4396 \end_layout
4397
4397
4398 \begin_layout LyX-Code
4398 \begin_layout LyX-Code
4399 ^
4399 ^
4400 \end_layout
4400 \end_layout
4401
4401
4402 \begin_layout LyX-Code
4402 \begin_layout LyX-Code
4403 SyntaxError: invalid syntax
4403 SyntaxError: invalid syntax
4404 \end_layout
4404 \end_layout
4405
4405
4406 \begin_layout LyX-Code
4406 \begin_layout LyX-Code
4407
4407
4408 \end_layout
4408 \end_layout
4409
4409
4410 \begin_layout LyX-Code
4410 \begin_layout LyX-Code
4411 In [4]: %cd ..
4411 In [4]: %cd ..
4412 # but %cd always works
4412 # but %cd always works
4413 \end_layout
4413 \end_layout
4414
4414
4415 \begin_layout LyX-Code
4415 \begin_layout LyX-Code
4416 /home/fperez
4416 /home/fperez
4417 \end_layout
4417 \end_layout
4418
4418
4419 \begin_layout LyX-Code
4419 \begin_layout LyX-Code
4420 In [5]: del cd # if you remove the cd variable
4420 In [5]: del cd # if you remove the cd variable
4421 \end_layout
4421 \end_layout
4422
4422
4423 \begin_layout LyX-Code
4423 \begin_layout LyX-Code
4424 In [6]: cd ipython # automagic can work again
4424 In [6]: cd ipython # automagic can work again
4425 \end_layout
4425 \end_layout
4426
4426
4427 \begin_layout LyX-Code
4427 \begin_layout LyX-Code
4428 /home/fperez/ipython
4428 /home/fperez/ipython
4429 \end_layout
4429 \end_layout
4430
4430
4431 \begin_layout Standard
4431 \begin_layout Standard
4432 You can define your own magic functions to extend the system.
4432 You can define your own magic functions to extend the system.
4433 The following is a snippet of code which shows how to do it.
4433 The following example defines a new magic command,
4434 It is provided as file
4435 \family typewriter
4434 \family typewriter
4436 example-magic.py
4435 %impall
4437 \family default
4436 \family default
4438 in the examples directory:
4437 :
4439 \end_layout
4438 \end_layout
4440
4439
4441 \begin_layout Standard
4440 \begin_layout LyX-Code
4442 \begin_inset ERT
4441 import IPython.ipapi
4443 status open
4442 \end_layout
4444
4443
4445 \begin_layout Standard
4444 \begin_layout LyX-Code
4445 ip = IPython.ipapi.get()
4446 \end_layout
4446
4447
4448 \begin_layout LyX-Code
4447
4449
4448 \backslash
4449 codelist{examples/example-magic.py}
4450 \end_layout
4450 \end_layout
4451
4451
4452 \end_inset
4452 \begin_layout LyX-Code
4453 def doimp(self, arg):
4454 \end_layout
4453
4455
4456 \begin_layout LyX-Code
4457 ip = self.api
4458 \end_layout
4454
4459
4460 \begin_layout LyX-Code
4461 ip.ex("import %s; reload(%s); from %s import *" % (
4462 \end_layout
4463
4464 \begin_layout LyX-Code
4465 arg,arg,arg)
4466 \end_layout
4467
4468 \begin_layout LyX-Code
4469 )
4470 \end_layout
4471
4472 \begin_layout LyX-Code
4473 ip.expose_magic('impall', doimp)
4455 \end_layout
4474 \end_layout
4456
4475
4457 \begin_layout Standard
4476 \begin_layout Standard
4458 You can also define your own aliased names for magic functions.
4477 You can also define your own aliased names for magic functions.
4459 In your
4478 In your
4460 \family typewriter
4479 \family typewriter
4461 ipythonrc
4480 ipythonrc
4462 \family default
4481 \family default
4463 file, placing a line like:
4482 file, placing a line like:
4464 \end_layout
4483 \end_layout
4465
4484
4466 \begin_layout Standard
4485 \begin_layout Standard
4467
4486
4468 \family typewriter
4487 \family typewriter
4469 execute __IP.magic_cl = __IP.magic_clear
4488 execute __IP.magic_cl = __IP.magic_clear
4470 \end_layout
4489 \end_layout
4471
4490
4472 \begin_layout Standard
4491 \begin_layout Standard
4473 will define
4492 will define
4474 \family typewriter
4493 \family typewriter
4475 %cl
4494 %cl
4476 \family default
4495 \family default
4477 as a new name for
4496 as a new name for
4478 \family typewriter
4497 \family typewriter
4479 %clear
4498 %clear
4480 \family default
4499 \family default
4481 .
4500 .
4482 \end_layout
4501 \end_layout
4483
4502
4484 \begin_layout Standard
4503 \begin_layout Standard
4485 Type
4504 Type
4486 \family typewriter
4505 \family typewriter
4487 %magic
4506 %magic
4488 \family default
4507 \family default
4489 for more information, including a list of all available magic functions
4508 for more information, including a list of all available magic functions
4490 at any time and their docstrings.
4509 at any time and their docstrings.
4491 You can also type
4510 You can also type
4492 \family typewriter
4511 \family typewriter
4493 %magic_function_name?
4512 %magic_function_name?
4494 \family default
4513 \family default
4495 (see sec.
4514 (see sec.
4496
4515
4497 \begin_inset LatexCommand \ref{sec:dyn-object-info}
4516 \begin_inset LatexCommand \ref{sec:dyn-object-info}
4498
4517
4499 \end_inset
4518 \end_inset
4500
4519
4501 for information on the
4520 for information on the
4502 \family typewriter
4521 \family typewriter
4503 '?'
4522 '?'
4504 \family default
4523 \family default
4505 system) to get information about any particular magic function you are
4524 system) to get information about any particular magic function you are
4506 interested in.
4525 interested in.
4507 \end_layout
4526 \end_layout
4508
4527
4509 \begin_layout Subsubsection
4528 \begin_layout Subsubsection
4510 Magic commands
4529 Magic commands
4511 \end_layout
4530 \end_layout
4512
4531
4513 \begin_layout Standard
4532 \begin_layout Standard
4514 The rest of this section is automatically generated for each release from
4533 The rest of this section is automatically generated for each release from
4515 the docstrings in the IPython code.
4534 the docstrings in the IPython code.
4516 Therefore the formatting is somewhat minimal, but this method has the advantage
4535 Therefore the formatting is somewhat minimal, but this method has the advantage
4517 of having information always in sync with the code.
4536 of having information always in sync with the code.
4518 \end_layout
4537 \end_layout
4519
4538
4520 \begin_layout Standard
4539 \begin_layout Standard
4521 A list of all the magic commands available in IPython's
4540 A list of all the magic commands available in IPython's
4522 \emph on
4541 \emph on
4523 default
4542 default
4524 \emph default
4543 \emph default
4525 installation follows.
4544 installation follows.
4526 This is similar to what you'll see by simply typing
4545 This is similar to what you'll see by simply typing
4527 \family typewriter
4546 \family typewriter
4528 %magic
4547 %magic
4529 \family default
4548 \family default
4530 at the prompt, but that will also give you information about magic commands
4549 at the prompt, but that will also give you information about magic commands
4531 you may have added as part of your personal customizations.
4550 you may have added as part of your personal customizations.
4532 \end_layout
4551 \end_layout
4533
4552
4534 \begin_layout Standard
4553 \begin_layout Standard
4535 \begin_inset Include \input{magic.tex}
4554 \begin_inset Include \input{magic.tex}
4536 preview false
4555 preview false
4537
4556
4538 \end_inset
4557 \end_inset
4539
4558
4540
4559
4541 \end_layout
4560 \end_layout
4542
4561
4543 \begin_layout Subsection
4562 \begin_layout Subsection
4544 Access to the standard Python help
4563 Access to the standard Python help
4545 \end_layout
4564 \end_layout
4546
4565
4547 \begin_layout Standard
4566 \begin_layout Standard
4548 As of Python 2.1, a help system is available with access to object docstrings
4567 As of Python 2.1, a help system is available with access to object docstrings
4549 and the Python manuals.
4568 and the Python manuals.
4550 Simply type
4569 Simply type
4551 \family typewriter
4570 \family typewriter
4552 'help'
4571 'help'
4553 \family default
4572 \family default
4554 (no quotes) to access it.
4573 (no quotes) to access it.
4555 You can also type
4574 You can also type
4556 \family typewriter
4575 \family typewriter
4557 help(object)
4576 help(object)
4558 \family default
4577 \family default
4559 to obtain information about a given object, and
4578 to obtain information about a given object, and
4560 \family typewriter
4579 \family typewriter
4561 help('keyword')
4580 help('keyword')
4562 \family default
4581 \family default
4563 for information on a keyword.
4582 for information on a keyword.
4564 As noted in sec.
4583 As noted in sec.
4565
4584
4566 \begin_inset LatexCommand \ref{sec:help-access}
4585 \begin_inset LatexCommand \ref{sec:help-access}
4567
4586
4568 \end_inset
4587 \end_inset
4569
4588
4570 , you need to properly configure your environment variable
4589 , you need to properly configure your environment variable
4571 \family typewriter
4590 \family typewriter
4572 PYTHONDOCS
4591 PYTHONDOCS
4573 \family default
4592 \family default
4574 for this feature to work correctly.
4593 for this feature to work correctly.
4575 \end_layout
4594 \end_layout
4576
4595
4577 \begin_layout Subsection
4596 \begin_layout Subsection
4578 \begin_inset LatexCommand \label{sec:dyn-object-info}
4597 \begin_inset LatexCommand \label{sec:dyn-object-info}
4579
4598
4580 \end_inset
4599 \end_inset
4581
4600
4582 Dynamic object information
4601 Dynamic object information
4583 \end_layout
4602 \end_layout
4584
4603
4585 \begin_layout Standard
4604 \begin_layout Standard
4586 Typing
4605 Typing
4587 \family typewriter
4606 \family typewriter
4588 ?word
4607 ?word
4589 \family default
4608 \family default
4590 or
4609 or
4591 \family typewriter
4610 \family typewriter
4592 word?
4611 word?
4593 \family default
4612 \family default
4594 prints detailed information about an object.
4613 prints detailed information about an object.
4595 If certain strings in the object are too long (docstrings, code, etc.) they
4614 If certain strings in the object are too long (docstrings, code, etc.) they
4596 get snipped in the center for brevity.
4615 get snipped in the center for brevity.
4597 This system gives access variable types and values, full source code for
4616 This system gives access variable types and values, full source code for
4598 any object (if available), function prototypes and other useful information.
4617 any object (if available), function prototypes and other useful information.
4599 \end_layout
4618 \end_layout
4600
4619
4601 \begin_layout Standard
4620 \begin_layout Standard
4602 Typing
4621 Typing
4603 \family typewriter
4622 \family typewriter
4604 ??word
4623 ??word
4605 \family default
4624 \family default
4606 or
4625 or
4607 \family typewriter
4626 \family typewriter
4608 word??
4627 word??
4609 \family default
4628 \family default
4610 gives access to the full information without snipping long strings.
4629 gives access to the full information without snipping long strings.
4611 Long strings are sent to the screen through the
4630 Long strings are sent to the screen through the
4612 \family typewriter
4631 \family typewriter
4613 less
4632 less
4614 \family default
4633 \family default
4615 pager if longer than the screen and printed otherwise.
4634 pager if longer than the screen and printed otherwise.
4616 On systems lacking the
4635 On systems lacking the
4617 \family typewriter
4636 \family typewriter
4618 less
4637 less
4619 \family default
4638 \family default
4620 command, IPython uses a very basic internal pager.
4639 command, IPython uses a very basic internal pager.
4621 \end_layout
4640 \end_layout
4622
4641
4623 \begin_layout Standard
4642 \begin_layout Standard
4624 The following magic functions are particularly useful for gathering information
4643 The following magic functions are particularly useful for gathering information
4625 about your working environment.
4644 about your working environment.
4626 You can get more details by typing
4645 You can get more details by typing
4627 \family typewriter
4646 \family typewriter
4628 %magic
4647 %magic
4629 \family default
4648 \family default
4630 or querying them individually (use
4649 or querying them individually (use
4631 \family typewriter
4650 \family typewriter
4632 %function_name?
4651 %function_name?
4633 \family default
4652 \family default
4634 with or without the
4653 with or without the
4635 \family typewriter
4654 \family typewriter
4636 %
4655 %
4637 \family default
4656 \family default
4638 ), this is just a summary:
4657 ), this is just a summary:
4639 \end_layout
4658 \end_layout
4640
4659
4641 \begin_layout List
4660 \begin_layout List
4642 \labelwidthstring 00.00.0000
4661 \labelwidthstring 00.00.0000
4643
4662
4644 \family typewriter
4663 \family typewriter
4645 \series bold
4664 \series bold
4646 %pdoc\InsetSpace ~
4665 %pdoc\InsetSpace ~
4647 <object>
4666 <object>
4648 \family default
4667 \family default
4649 \series default
4668 \series default
4650 : Print (or run through a pager if too long) the docstring for an object.
4669 : Print (or run through a pager if too long) the docstring for an object.
4651 If the given object is a class, it will print both the class and the constructo
4670 If the given object is a class, it will print both the class and the constructo
4652 r docstrings.
4671 r docstrings.
4653 \end_layout
4672 \end_layout
4654
4673
4655 \begin_layout List
4674 \begin_layout List
4656 \labelwidthstring 00.00.0000
4675 \labelwidthstring 00.00.0000
4657
4676
4658 \family typewriter
4677 \family typewriter
4659 \series bold
4678 \series bold
4660 %pdef\InsetSpace ~
4679 %pdef\InsetSpace ~
4661 <object>
4680 <object>
4662 \family default
4681 \family default
4663 \series default
4682 \series default
4664 : Print the definition header for any callable object.
4683 : Print the definition header for any callable object.
4665 If the object is a class, print the constructor information.
4684 If the object is a class, print the constructor information.
4666 \end_layout
4685 \end_layout
4667
4686
4668 \begin_layout List
4687 \begin_layout List
4669 \labelwidthstring 00.00.0000
4688 \labelwidthstring 00.00.0000
4670
4689
4671 \family typewriter
4690 \family typewriter
4672 \series bold
4691 \series bold
4673 %psource\InsetSpace ~
4692 %psource\InsetSpace ~
4674 <object>
4693 <object>
4675 \family default
4694 \family default
4676 \series default
4695 \series default
4677 : Print (or run through a pager if too long) the source code for an object.
4696 : Print (or run through a pager if too long) the source code for an object.
4678 \end_layout
4697 \end_layout
4679
4698
4680 \begin_layout List
4699 \begin_layout List
4681 \labelwidthstring 00.00.0000
4700 \labelwidthstring 00.00.0000
4682
4701
4683 \family typewriter
4702 \family typewriter
4684 \series bold
4703 \series bold
4685 %pfile\InsetSpace ~
4704 %pfile\InsetSpace ~
4686 <object>
4705 <object>
4687 \family default
4706 \family default
4688 \series default
4707 \series default
4689 : Show the entire source file where an object was defined via a pager, opening
4708 : Show the entire source file where an object was defined via a pager, opening
4690 it at the line where the object definition begins.
4709 it at the line where the object definition begins.
4691 \end_layout
4710 \end_layout
4692
4711
4693 \begin_layout List
4712 \begin_layout List
4694 \labelwidthstring 00.00.0000
4713 \labelwidthstring 00.00.0000
4695
4714
4696 \family typewriter
4715 \family typewriter
4697 \series bold
4716 \series bold
4698 %who/%whos
4717 %who/%whos
4699 \family default
4718 \family default
4700 \series default
4719 \series default
4701 : These functions give information about identifiers you have defined interactiv
4720 : These functions give information about identifiers you have defined interactiv
4702 ely (not things you loaded or defined in your configuration files).
4721 ely (not things you loaded or defined in your configuration files).
4703
4722
4704 \family typewriter
4723 \family typewriter
4705 %who
4724 %who
4706 \family default
4725 \family default
4707 just prints a list of identifiers and
4726 just prints a list of identifiers and
4708 \family typewriter
4727 \family typewriter
4709 %whos
4728 %whos
4710 \family default
4729 \family default
4711 prints a table with some basic details about each identifier.
4730 prints a table with some basic details about each identifier.
4712 \end_layout
4731 \end_layout
4713
4732
4714 \begin_layout Standard
4733 \begin_layout Standard
4715 Note that the dynamic object information functions (
4734 Note that the dynamic object information functions (
4716 \family typewriter
4735 \family typewriter
4717 ?/??, %pdoc, %pfile, %pdef, %psource
4736 ?/??, %pdoc, %pfile, %pdef, %psource
4718 \family default
4737 \family default
4719 ) give you access to documentation even on things which are not really defined
4738 ) give you access to documentation even on things which are not really defined
4720 as separate identifiers.
4739 as separate identifiers.
4721 Try for example typing
4740 Try for example typing
4722 \family typewriter
4741 \family typewriter
4723 {}.get?
4742 {}.get?
4724 \family default
4743 \family default
4725 or after doing
4744 or after doing
4726 \family typewriter
4745 \family typewriter
4727 import os
4746 import os
4728 \family default
4747 \family default
4729 , type
4748 , type
4730 \family typewriter
4749 \family typewriter
4731 os.path.abspath??
4750 os.path.abspath??
4732 \family default
4751 \family default
4733 .
4752 .
4734 \end_layout
4753 \end_layout
4735
4754
4736 \begin_layout Subsection
4755 \begin_layout Subsection
4737 \begin_inset LatexCommand \label{sec:readline}
4756 \begin_inset LatexCommand \label{sec:readline}
4738
4757
4739 \end_inset
4758 \end_inset
4740
4759
4741 Readline-based features
4760 Readline-based features
4742 \end_layout
4761 \end_layout
4743
4762
4744 \begin_layout Standard
4763 \begin_layout Standard
4745 These features require the GNU readline library, so they won't work if your
4764 These features require the GNU readline library, so they won't work if your
4746 Python installation lacks readline support.
4765 Python installation lacks readline support.
4747 We will first describe the default behavior IPython uses, and then how
4766 We will first describe the default behavior IPython uses, and then how
4748 to change it to suit your preferences.
4767 to change it to suit your preferences.
4749 \end_layout
4768 \end_layout
4750
4769
4751 \begin_layout Subsubsection
4770 \begin_layout Subsubsection
4752 Command line completion
4771 Command line completion
4753 \end_layout
4772 \end_layout
4754
4773
4755 \begin_layout Standard
4774 \begin_layout Standard
4756 At any time, hitting TAB will complete any available python commands or
4775 At any time, hitting TAB will complete any available python commands or
4757 variable names, and show you a list of the possible completions if there's
4776 variable names, and show you a list of the possible completions if there's
4758 no unambiguous one.
4777 no unambiguous one.
4759 It will also complete filenames in the current directory if no python names
4778 It will also complete filenames in the current directory if no python names
4760 match what you've typed so far.
4779 match what you've typed so far.
4761 \end_layout
4780 \end_layout
4762
4781
4763 \begin_layout Subsubsection
4782 \begin_layout Subsubsection
4764 Search command history
4783 Search command history
4765 \end_layout
4784 \end_layout
4766
4785
4767 \begin_layout Standard
4786 \begin_layout Standard
4768 IPython provides two ways for searching through previous input and thus
4787 IPython provides two ways for searching through previous input and thus
4769 reduce the need for repetitive typing:
4788 reduce the need for repetitive typing:
4770 \end_layout
4789 \end_layout
4771
4790
4772 \begin_layout Enumerate
4791 \begin_layout Enumerate
4773 Start typing, and then use
4792 Start typing, and then use
4774 \family typewriter
4793 \family typewriter
4775 Ctrl-p
4794 Ctrl-p
4776 \family default
4795 \family default
4777 (previous,up) and
4796 (previous,up) and
4778 \family typewriter
4797 \family typewriter
4779 Ctrl-n
4798 Ctrl-n
4780 \family default
4799 \family default
4781 (next,down) to search through only the history items that match what you've
4800 (next,down) to search through only the history items that match what you've
4782 typed so far.
4801 typed so far.
4783 If you use
4802 If you use
4784 \family typewriter
4803 \family typewriter
4785 Ctrl-p/Ctrl-n
4804 Ctrl-p/Ctrl-n
4786 \family default
4805 \family default
4787 at a blank prompt, they just behave like normal arrow keys.
4806 at a blank prompt, they just behave like normal arrow keys.
4788 \end_layout
4807 \end_layout
4789
4808
4790 \begin_layout Enumerate
4809 \begin_layout Enumerate
4791 Hit
4810 Hit
4792 \family typewriter
4811 \family typewriter
4793 Ctrl-r
4812 Ctrl-r
4794 \family default
4813 \family default
4795 : opens a search prompt.
4814 : opens a search prompt.
4796 Begin typing and the system searches your history for lines that contain
4815 Begin typing and the system searches your history for lines that contain
4797 what you've typed so far, completing as much as it can.
4816 what you've typed so far, completing as much as it can.
4798 \end_layout
4817 \end_layout
4799
4818
4800 \begin_layout Subsubsection
4819 \begin_layout Subsubsection
4801 Persistent command history across sessions
4820 Persistent command history across sessions
4802 \end_layout
4821 \end_layout
4803
4822
4804 \begin_layout Standard
4823 \begin_layout Standard
4805 IPython will save your input history when it leaves and reload it next time
4824 IPython will save your input history when it leaves and reload it next time
4806 you restart it.
4825 you restart it.
4807 By default, the history file is named
4826 By default, the history file is named
4808 \family typewriter
4827 \family typewriter
4809 $IPYTHONDIR/history
4828 $IPYTHONDIR/history
4810 \family default
4829 \family default
4811 , but if you've loaded a named profile, '
4830 , but if you've loaded a named profile, '
4812 \family typewriter
4831 \family typewriter
4813 -PROFILE_NAME
4832 -PROFILE_NAME
4814 \family default
4833 \family default
4815 ' is appended to the name.
4834 ' is appended to the name.
4816 This allows you to keep separate histories related to various tasks: commands
4835 This allows you to keep separate histories related to various tasks: commands
4817 related to numerical work will not be clobbered by a system shell history,
4836 related to numerical work will not be clobbered by a system shell history,
4818 for example.
4837 for example.
4819 \end_layout
4838 \end_layout
4820
4839
4821 \begin_layout Subsubsection
4840 \begin_layout Subsubsection
4822 Autoindent
4841 Autoindent
4823 \end_layout
4842 \end_layout
4824
4843
4825 \begin_layout Standard
4844 \begin_layout Standard
4826 IPython can recognize lines ending in ':' and indent the next line, while
4845 IPython can recognize lines ending in ':' and indent the next line, while
4827 also un-indenting automatically after 'raise' or 'return'.
4846 also un-indenting automatically after 'raise' or 'return'.
4828
4847
4829 \end_layout
4848 \end_layout
4830
4849
4831 \begin_layout Standard
4850 \begin_layout Standard
4832 This feature uses the readline library, so it will honor your
4851 This feature uses the readline library, so it will honor your
4833 \family typewriter
4852 \family typewriter
4834 ~/.inputrc
4853 ~/.inputrc
4835 \family default
4854 \family default
4836 configuration (or whatever file your
4855 configuration (or whatever file your
4837 \family typewriter
4856 \family typewriter
4838 INPUTRC
4857 INPUTRC
4839 \family default
4858 \family default
4840 variable points to).
4859 variable points to).
4841 Adding the following lines to your
4860 Adding the following lines to your
4842 \family typewriter
4861 \family typewriter
4843 .inputrc
4862 .inputrc
4844 \family default
4863 \family default
4845 file can make indenting/unindenting more convenient (
4864 file can make indenting/unindenting more convenient (
4846 \family typewriter
4865 \family typewriter
4847 M-i
4866 M-i
4848 \family default
4867 \family default
4849 indents,
4868 indents,
4850 \family typewriter
4869 \family typewriter
4851 M-u
4870 M-u
4852 \family default
4871 \family default
4853 unindents):
4872 unindents):
4854 \end_layout
4873 \end_layout
4855
4874
4856 \begin_layout Standard
4875 \begin_layout Standard
4857
4876
4858 \family typewriter
4877 \family typewriter
4859 $if Python
4878 $if Python
4860 \newline
4879 \newline
4861 "
4880 "
4862 \backslash
4881 \backslash
4863 M-i": "\InsetSpace ~
4882 M-i": "\InsetSpace ~
4864 \InsetSpace ~
4883 \InsetSpace ~
4865 \InsetSpace ~
4884 \InsetSpace ~
4866 \InsetSpace ~
4885 \InsetSpace ~
4867 "
4886 "
4868 \newline
4887 \newline
4869 "
4888 "
4870 \backslash
4889 \backslash
4871 M-u": "
4890 M-u": "
4872 \backslash
4891 \backslash
4873 d
4892 d
4874 \backslash
4893 \backslash
4875 d
4894 d
4876 \backslash
4895 \backslash
4877 d
4896 d
4878 \backslash
4897 \backslash
4879 d"
4898 d"
4880 \newline
4899 \newline
4881 $endif
4900 $endif
4882 \end_layout
4901 \end_layout
4883
4902
4884 \begin_layout Standard
4903 \begin_layout Standard
4885 Note that there are 4 spaces between the quote marks after
4904 Note that there are 4 spaces between the quote marks after
4886 \family typewriter
4905 \family typewriter
4887 "M-i"
4906 "M-i"
4888 \family default
4907 \family default
4889 above.
4908 above.
4890 \end_layout
4909 \end_layout
4891
4910
4892 \begin_layout Standard
4911 \begin_layout Standard
4893
4912
4894 \series bold
4913 \series bold
4895 Warning:
4914 Warning:
4896 \series default
4915 \series default
4897 this feature is ON by default, but it can cause problems with the pasting
4916 this feature is ON by default, but it can cause problems with the pasting
4898 of multi-line indented code (the pasted code gets re-indented on each line).
4917 of multi-line indented code (the pasted code gets re-indented on each line).
4899 A magic function
4918 A magic function
4900 \family typewriter
4919 \family typewriter
4901 %autoindent
4920 %autoindent
4902 \family default
4921 \family default
4903 allows you to toggle it on/off at runtime.
4922 allows you to toggle it on/off at runtime.
4904 You can also disable it permanently on in your
4923 You can also disable it permanently on in your
4905 \family typewriter
4924 \family typewriter
4906 ipythonrc
4925 ipythonrc
4907 \family default
4926 \family default
4908 file (set
4927 file (set
4909 \family typewriter
4928 \family typewriter
4910 autoindent 0
4929 autoindent 0
4911 \family default
4930 \family default
4912 ).
4931 ).
4913 \end_layout
4932 \end_layout
4914
4933
4915 \begin_layout Subsubsection
4934 \begin_layout Subsubsection
4916 Customizing readline behavior
4935 Customizing readline behavior
4917 \end_layout
4936 \end_layout
4918
4937
4919 \begin_layout Standard
4938 \begin_layout Standard
4920 All these features are based on the GNU readline library, which has an extremely
4939 All these features are based on the GNU readline library, which has an extremely
4921 customizable interface.
4940 customizable interface.
4922 Normally, readline is configured via a file which defines the behavior
4941 Normally, readline is configured via a file which defines the behavior
4923 of the library; the details of the syntax for this can be found in the
4942 of the library; the details of the syntax for this can be found in the
4924 readline documentation available with your system or on the Internet.
4943 readline documentation available with your system or on the Internet.
4925 IPython doesn't read this file (if it exists) directly, but it does support
4944 IPython doesn't read this file (if it exists) directly, but it does support
4926 passing to readline valid options via a simple interface.
4945 passing to readline valid options via a simple interface.
4927 In brief, you can customize readline by setting the following options in
4946 In brief, you can customize readline by setting the following options in
4928 your
4947 your
4929 \family typewriter
4948 \family typewriter
4930 ipythonrc
4949 ipythonrc
4931 \family default
4950 \family default
4932 configuration file (note that these options can
4951 configuration file (note that these options can
4933 \emph on
4952 \emph on
4934 not
4953 not
4935 \emph default
4954 \emph default
4936 be specified at the command line):
4955 be specified at the command line):
4937 \end_layout
4956 \end_layout
4938
4957
4939 \begin_layout List
4958 \begin_layout List
4940 \labelwidthstring 00.00.0000
4959 \labelwidthstring 00.00.0000
4941
4960
4942 \family typewriter
4961 \family typewriter
4943 \series bold
4962 \series bold
4944 readline_parse_and_bind:
4963 readline_parse_and_bind:
4945 \family default
4964 \family default
4946 \series default
4965 \series default
4947 this option can appear as many times as you want, each time defining a
4966 this option can appear as many times as you want, each time defining a
4948 string to be executed via a
4967 string to be executed via a
4949 \family typewriter
4968 \family typewriter
4950 readline.parse_and_bind()
4969 readline.parse_and_bind()
4951 \family default
4970 \family default
4952 command.
4971 command.
4953 The syntax for valid commands of this kind can be found by reading the
4972 The syntax for valid commands of this kind can be found by reading the
4954 documentation for the GNU readline library, as these commands are of the
4973 documentation for the GNU readline library, as these commands are of the
4955 kind which readline accepts in its configuration file.
4974 kind which readline accepts in its configuration file.
4956 \end_layout
4975 \end_layout
4957
4976
4958 \begin_layout List
4977 \begin_layout List
4959 \labelwidthstring 00.00.0000
4978 \labelwidthstring 00.00.0000
4960
4979
4961 \family typewriter
4980 \family typewriter
4962 \series bold
4981 \series bold
4963 readline_remove_delims:
4982 readline_remove_delims:
4964 \family default
4983 \family default
4965 \series default
4984 \series default
4966 a string of characters to be removed from the default word-delimiters list
4985 a string of characters to be removed from the default word-delimiters list
4967 used by readline, so that completions may be performed on strings which
4986 used by readline, so that completions may be performed on strings which
4968 contain them.
4987 contain them.
4969 Do not change the default value unless you know what you're doing.
4988 Do not change the default value unless you know what you're doing.
4970 \end_layout
4989 \end_layout
4971
4990
4972 \begin_layout List
4991 \begin_layout List
4973 \labelwidthstring 00.00.0000
4992 \labelwidthstring 00.00.0000
4974
4993
4975 \family typewriter
4994 \family typewriter
4976 \series bold
4995 \series bold
4977 readline_omit__names
4996 readline_omit__names
4978 \family default
4997 \family default
4979 \series default
4998 \series default
4980 : when tab-completion is enabled, hitting
4999 : when tab-completion is enabled, hitting
4981 \family typewriter
5000 \family typewriter
4982 <tab>
5001 <tab>
4983 \family default
5002 \family default
4984 after a '
5003 after a '
4985 \family typewriter
5004 \family typewriter
4986 .
5005 .
4987 \family default
5006 \family default
4988 ' in a name will complete all attributes of an object, including all the
5007 ' in a name will complete all attributes of an object, including all the
4989 special methods whose names include double underscores (like
5008 special methods whose names include double underscores (like
4990 \family typewriter
5009 \family typewriter
4991 __getitem__
5010 __getitem__
4992 \family default
5011 \family default
4993 or
5012 or
4994 \family typewriter
5013 \family typewriter
4995 __class__
5014 __class__
4996 \family default
5015 \family default
4997 ).
5016 ).
4998 If you'd rather not see these names by default, you can set this option
5017 If you'd rather not see these names by default, you can set this option
4999 to 1.
5018 to 1.
5000 Note that even when this option is set, you can still see those names by
5019 Note that even when this option is set, you can still see those names by
5001 explicitly typing a
5020 explicitly typing a
5002 \family typewriter
5021 \family typewriter
5003 _
5022 _
5004 \family default
5023 \family default
5005 after the period and hitting
5024 after the period and hitting
5006 \family typewriter
5025 \family typewriter
5007 <tab>
5026 <tab>
5008 \family default
5027 \family default
5009 : '
5028 : '
5010 \family typewriter
5029 \family typewriter
5011 name._<tab>
5030 name._<tab>
5012 \family default
5031 \family default
5013 ' will always complete attribute names starting with '
5032 ' will always complete attribute names starting with '
5014 \family typewriter
5033 \family typewriter
5015 _
5034 _
5016 \family default
5035 \family default
5017 '.
5036 '.
5018 \end_layout
5037 \end_layout
5019
5038
5020 \begin_layout List
5039 \begin_layout List
5021 \labelwidthstring 00.00.0000
5040 \labelwidthstring 00.00.0000
5022 \InsetSpace ~
5041 \InsetSpace ~
5023 This option is off by default so that new users see all attributes of any
5042 This option is off by default so that new users see all attributes of any
5024 objects they are dealing with.
5043 objects they are dealing with.
5025 \end_layout
5044 \end_layout
5026
5045
5027 \begin_layout Standard
5046 \begin_layout Standard
5028 You will find the default values along with a corresponding detailed explanation
5047 You will find the default values along with a corresponding detailed explanation
5029 in your
5048 in your
5030 \family typewriter
5049 \family typewriter
5031 ipythonrc
5050 ipythonrc
5032 \family default
5051 \family default
5033 file.
5052 file.
5034 \end_layout
5053 \end_layout
5035
5054
5036 \begin_layout Subsection
5055 \begin_layout Subsection
5037 Session logging and restoring
5056 Session logging and restoring
5038 \end_layout
5057 \end_layout
5039
5058
5040 \begin_layout Standard
5059 \begin_layout Standard
5041 You can log all input from a session either by starting IPython with the
5060 You can log all input from a session either by starting IPython with the
5042 command line switches
5061 command line switches
5043 \family typewriter
5062 \family typewriter
5044 -log
5063 -log
5045 \family default
5064 \family default
5046 or
5065 or
5047 \family typewriter
5066 \family typewriter
5048 -logfile
5067 -logfile
5049 \family default
5068 \family default
5050 (see sec.
5069 (see sec.
5051
5070
5052 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
5071 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
5053
5072
5054 \end_inset
5073 \end_inset
5055
5074
5056 )or by activating the logging at any moment with the magic function
5075 )or by activating the logging at any moment with the magic function
5057 \family typewriter
5076 \family typewriter
5058 %logstart
5077 %logstart
5059 \family default
5078 \family default
5060 .
5079 .
5061
5080
5062 \end_layout
5081 \end_layout
5063
5082
5064 \begin_layout Standard
5083 \begin_layout Standard
5065 Log files can later be reloaded with the
5084 Log files can later be reloaded with the
5066 \family typewriter
5085 \family typewriter
5067 -logplay
5086 -logplay
5068 \family default
5087 \family default
5069 option and IPython will attempt to 'replay' the log by executing all the
5088 option and IPython will attempt to 'replay' the log by executing all the
5070 lines in it, thus restoring the state of a previous session.
5089 lines in it, thus restoring the state of a previous session.
5071 This feature is not quite perfect, but can still be useful in many cases.
5090 This feature is not quite perfect, but can still be useful in many cases.
5072 \end_layout
5091 \end_layout
5073
5092
5074 \begin_layout Standard
5093 \begin_layout Standard
5075 The log files can also be used as a way to have a permanent record of any
5094 The log files can also be used as a way to have a permanent record of any
5076 code you wrote while experimenting.
5095 code you wrote while experimenting.
5077 Log files are regular text files which you can later open in your favorite
5096 Log files are regular text files which you can later open in your favorite
5078 text editor to extract code or to 'clean them up' before using them to
5097 text editor to extract code or to 'clean them up' before using them to
5079 replay a session.
5098 replay a session.
5080 \end_layout
5099 \end_layout
5081
5100
5082 \begin_layout Standard
5101 \begin_layout Standard
5083 The
5102 The
5084 \family typewriter
5103 \family typewriter
5085 %logstart
5104 %logstart
5086 \family default
5105 \family default
5087 function for activating logging in mid-session is used as follows:
5106 function for activating logging in mid-session is used as follows:
5088 \end_layout
5107 \end_layout
5089
5108
5090 \begin_layout Standard
5109 \begin_layout Standard
5091
5110
5092 \family typewriter
5111 \family typewriter
5093 %logstart [log_name [log_mode]]
5112 %logstart [log_name [log_mode]]
5094 \end_layout
5113 \end_layout
5095
5114
5096 \begin_layout Standard
5115 \begin_layout Standard
5097 If no name is given, it defaults to a file named
5116 If no name is given, it defaults to a file named
5098 \family typewriter
5117 \family typewriter
5099 'log'
5118 'log'
5100 \family default
5119 \family default
5101 in your IPYTHONDIR directory, in
5120 in your IPYTHONDIR directory, in
5102 \family typewriter
5121 \family typewriter
5103 'rotate'
5122 'rotate'
5104 \family default
5123 \family default
5105 mode (see below).
5124 mode (see below).
5106 \end_layout
5125 \end_layout
5107
5126
5108 \begin_layout Standard
5127 \begin_layout Standard
5109 '
5128 '
5110 \family typewriter
5129 \family typewriter
5111 %logstart name
5130 %logstart name
5112 \family default
5131 \family default
5113 ' saves to file
5132 ' saves to file
5114 \family typewriter
5133 \family typewriter
5115 'name'
5134 'name'
5116 \family default
5135 \family default
5117 in
5136 in
5118 \family typewriter
5137 \family typewriter
5119 'backup'
5138 'backup'
5120 \family default
5139 \family default
5121 mode.
5140 mode.
5122 It saves your history up to that point and then continues logging.
5141 It saves your history up to that point and then continues logging.
5123 \end_layout
5142 \end_layout
5124
5143
5125 \begin_layout Standard
5144 \begin_layout Standard
5126
5145
5127 \family typewriter
5146 \family typewriter
5128 %logstart
5147 %logstart
5129 \family default
5148 \family default
5130 takes a second optional parameter: logging mode.
5149 takes a second optional parameter: logging mode.
5131 This can be one of (note that the modes are given unquoted):
5150 This can be one of (note that the modes are given unquoted):
5132 \end_layout
5151 \end_layout
5133
5152
5134 \begin_layout List
5153 \begin_layout List
5135 \labelwidthstring 00.00.0000
5154 \labelwidthstring 00.00.0000
5136
5155
5137 \family typewriter
5156 \family typewriter
5138 over
5157 over
5139 \family default
5158 \family default
5140 : overwrite existing
5159 : overwrite existing
5141 \family typewriter
5160 \family typewriter
5142 log_name
5161 log_name
5143 \family default
5162 \family default
5144 .
5163 .
5145 \end_layout
5164 \end_layout
5146
5165
5147 \begin_layout List
5166 \begin_layout List
5148 \labelwidthstring 00.00.0000
5167 \labelwidthstring 00.00.0000
5149
5168
5150 \family typewriter
5169 \family typewriter
5151 backup
5170 backup
5152 \family default
5171 \family default
5153 : rename (if exists) to
5172 : rename (if exists) to
5154 \family typewriter
5173 \family typewriter
5155 log_name~
5174 log_name~
5156 \family default
5175 \family default
5157 and start
5176 and start
5158 \family typewriter
5177 \family typewriter
5159 log_name
5178 log_name
5160 \family default
5179 \family default
5161 .
5180 .
5162 \end_layout
5181 \end_layout
5163
5182
5164 \begin_layout List
5183 \begin_layout List
5165 \labelwidthstring 00.00.0000
5184 \labelwidthstring 00.00.0000
5166
5185
5167 \family typewriter
5186 \family typewriter
5168 append
5187 append
5169 \family default
5188 \family default
5170 : well, that says it.
5189 : well, that says it.
5171 \end_layout
5190 \end_layout
5172
5191
5173 \begin_layout List
5192 \begin_layout List
5174 \labelwidthstring 00.00.0000
5193 \labelwidthstring 00.00.0000
5175
5194
5176 \family typewriter
5195 \family typewriter
5177 rotate
5196 rotate
5178 \family default
5197 \family default
5179 : create rotating logs
5198 : create rotating logs
5180 \family typewriter
5199 \family typewriter
5181 log_name
5200 log_name
5182 \family default
5201 \family default
5183 .
5202 .
5184 \family typewriter
5203 \family typewriter
5185 1~
5204 1~
5186 \family default
5205 \family default
5187 ,
5206 ,
5188 \family typewriter
5207 \family typewriter
5189 log_name.2~
5208 log_name.2~
5190 \family default
5209 \family default
5191 , etc.
5210 , etc.
5192 \end_layout
5211 \end_layout
5193
5212
5194 \begin_layout Standard
5213 \begin_layout Standard
5195 The
5214 The
5196 \family typewriter
5215 \family typewriter
5197 %logoff
5216 %logoff
5198 \family default
5217 \family default
5199 and
5218 and
5200 \family typewriter
5219 \family typewriter
5201 %logon
5220 %logon
5202 \family default
5221 \family default
5203 functions allow you to temporarily stop and resume logging to a file which
5222 functions allow you to temporarily stop and resume logging to a file which
5204 had previously been started with
5223 had previously been started with
5205 \family typewriter
5224 \family typewriter
5206 %logstart
5225 %logstart
5207 \family default
5226 \family default
5208 .
5227 .
5209 They will fail (with an explanation) if you try to use them before logging
5228 They will fail (with an explanation) if you try to use them before logging
5210 has been started.
5229 has been started.
5211 \end_layout
5230 \end_layout
5212
5231
5213 \begin_layout Subsection
5232 \begin_layout Subsection
5214 \begin_inset LatexCommand \label{sub:System-shell-access}
5233 \begin_inset LatexCommand \label{sub:System-shell-access}
5215
5234
5216 \end_inset
5235 \end_inset
5217
5236
5218 System shell access
5237 System shell access
5219 \end_layout
5238 \end_layout
5220
5239
5221 \begin_layout Standard
5240 \begin_layout Standard
5222 Any input line beginning with a
5241 Any input line beginning with a
5223 \family typewriter
5242 \family typewriter
5224 !
5243 !
5225 \family default
5244 \family default
5226 character is passed verbatim (minus the
5245 character is passed verbatim (minus the
5227 \family typewriter
5246 \family typewriter
5228 !
5247 !
5229 \family default
5248 \family default
5230 , of course) to the underlying operating system.
5249 , of course) to the underlying operating system.
5231 For example, typing
5250 For example, typing
5232 \family typewriter
5251 \family typewriter
5233 !ls
5252 !ls
5234 \family default
5253 \family default
5235 will run
5254 will run
5236 \family typewriter
5255 \family typewriter
5237 'ls'
5256 'ls'
5238 \family default
5257 \family default
5239 in the current directory.
5258 in the current directory.
5240 \end_layout
5259 \end_layout
5241
5260
5242 \begin_layout Subsubsection
5261 \begin_layout Subsubsection
5243 Manual capture of command output
5262 Manual capture of command output
5244 \end_layout
5263 \end_layout
5245
5264
5246 \begin_layout Standard
5265 \begin_layout Standard
5247 If the input line begins with
5266 If the input line begins with
5248 \emph on
5267 \emph on
5249 two
5268 two
5250 \emph default
5269 \emph default
5251 exclamation marks,
5270 exclamation marks,
5252 \family typewriter
5271 \family typewriter
5253 !!
5272 !!
5254 \family default
5273 \family default
5255 , the command is executed but its output is captured and returned as a python
5274 , the command is executed but its output is captured and returned as a python
5256 list, split on newlines.
5275 list, split on newlines.
5257 Any output sent by the subprocess to standard error is printed separately,
5276 Any output sent by the subprocess to standard error is printed separately,
5258 so that the resulting list only captures standard output.
5277 so that the resulting list only captures standard output.
5259 The
5278 The
5260 \family typewriter
5279 \family typewriter
5261 !!
5280 !!
5262 \family default
5281 \family default
5263 syntax is a shorthand for the
5282 syntax is a shorthand for the
5264 \family typewriter
5283 \family typewriter
5265 %sx
5284 %sx
5266 \family default
5285 \family default
5267 magic command.
5286 magic command.
5268 \end_layout
5287 \end_layout
5269
5288
5270 \begin_layout Standard
5289 \begin_layout Standard
5271 Finally, the
5290 Finally, the
5272 \family typewriter
5291 \family typewriter
5273 %sc
5292 %sc
5274 \family default
5293 \family default
5275 magic (short for `shell capture') is similar to
5294 magic (short for `shell capture') is similar to
5276 \family typewriter
5295 \family typewriter
5277 %sx
5296 %sx
5278 \family default
5297 \family default
5279 , but allowing more fine-grained control of the capture details, and storing
5298 , but allowing more fine-grained control of the capture details, and storing
5280 the result directly into a named variable.
5299 the result directly into a named variable.
5281 \end_layout
5300 \end_layout
5282
5301
5283 \begin_layout Standard
5302 \begin_layout Standard
5284 See Sec.\InsetSpace ~
5303 See Sec.\InsetSpace ~
5285
5304
5286 \begin_inset LatexCommand \ref{sec:magic}
5305 \begin_inset LatexCommand \ref{sec:magic}
5287
5306
5288 \end_inset
5307 \end_inset
5289
5308
5290 for details on the magics
5309 for details on the magics
5291 \family typewriter
5310 \family typewriter
5292 %sc
5311 %sc
5293 \family default
5312 \family default
5294 and
5313 and
5295 \family typewriter
5314 \family typewriter
5296 %sx
5315 %sx
5297 \family default
5316 \family default
5298 , or use IPython's own help (
5317 , or use IPython's own help (
5299 \family typewriter
5318 \family typewriter
5300 sc?
5319 sc?
5301 \family default
5320 \family default
5302 and
5321 and
5303 \family typewriter
5322 \family typewriter
5304 sx?
5323 sx?
5305 \family default
5324 \family default
5306 ) for further details.
5325 ) for further details.
5307 \end_layout
5326 \end_layout
5308
5327
5309 \begin_layout Standard
5328 \begin_layout Standard
5310 IPython also allows you to expand the value of python variables when making
5329 IPython also allows you to expand the value of python variables when making
5311 system calls.
5330 system calls.
5312 Any python variable or expression which you prepend with
5331 Any python variable or expression which you prepend with
5313 \family typewriter
5332 \family typewriter
5314 $
5333 $
5315 \family default
5334 \family default
5316 will get expanded before the system call is made.
5335 will get expanded before the system call is made.
5317
5336
5318 \end_layout
5337 \end_layout
5319
5338
5320 \begin_layout Standard
5339 \begin_layout Standard
5321
5340
5322 \family typewriter
5341 \family typewriter
5323 In [1]: pyvar='Hello world'
5342 In [1]: pyvar='Hello world'
5324 \newline
5343 \newline
5325 In [2]: !echo "A python variable: $pyvar"
5344 In [2]: !echo "A python variable: $pyvar"
5326 \newline
5345 \newline
5327 A python
5346 A python
5328 variable: Hello world
5347 variable: Hello world
5329 \end_layout
5348 \end_layout
5330
5349
5331 \begin_layout Standard
5350 \begin_layout Standard
5332 If you want the shell to actually see a literal
5351 If you want the shell to actually see a literal
5333 \family typewriter
5352 \family typewriter
5334 $
5353 $
5335 \family default
5354 \family default
5336 , you need to type it twice:
5355 , you need to type it twice:
5337 \end_layout
5356 \end_layout
5338
5357
5339 \begin_layout Standard
5358 \begin_layout Standard
5340
5359
5341 \family typewriter
5360 \family typewriter
5342 In [3]: !echo "A system variable: $$HOME"
5361 In [3]: !echo "A system variable: $$HOME"
5343 \newline
5362 \newline
5344 A system variable: /home/fperez
5363 A system variable: /home/fperez
5345 \end_layout
5364 \end_layout
5346
5365
5347 \begin_layout Standard
5366 \begin_layout Standard
5348 You can pass arbitrary expressions, though you'll need to delimit them with
5367 You can pass arbitrary expressions, though you'll need to delimit them with
5349
5368
5350 \family typewriter
5369 \family typewriter
5351 {}
5370 {}
5352 \family default
5371 \family default
5353 if there is ambiguity as to the extent of the expression:
5372 if there is ambiguity as to the extent of the expression:
5354 \end_layout
5373 \end_layout
5355
5374
5356 \begin_layout Standard
5375 \begin_layout Standard
5357
5376
5358 \family typewriter
5377 \family typewriter
5359 In [5]: x=10
5378 In [5]: x=10
5360 \newline
5379 \newline
5361 In [6]: y=20
5380 In [6]: y=20
5362 \newline
5381 \newline
5363 In [13]: !echo $x+y
5382 In [13]: !echo $x+y
5364 \newline
5383 \newline
5365 10+y
5384 10+y
5366 \newline
5385 \newline
5367 In [7]: !echo ${x+y}
5386 In [7]: !echo ${x+y}
5368 \newline
5387 \newline
5369 30
5388 30
5370
5389
5371 \end_layout
5390 \end_layout
5372
5391
5373 \begin_layout Standard
5392 \begin_layout Standard
5374 Even object attributes can be expanded:
5393 Even object attributes can be expanded:
5375 \end_layout
5394 \end_layout
5376
5395
5377 \begin_layout Standard
5396 \begin_layout Standard
5378
5397
5379 \family typewriter
5398 \family typewriter
5380 In [12]: !echo $sys.argv
5399 In [12]: !echo $sys.argv
5381 \newline
5400 \newline
5382 [/home/fperez/usr/bin/ipython]
5401 [/home/fperez/usr/bin/ipython]
5383 \end_layout
5402 \end_layout
5384
5403
5385 \begin_layout Subsection
5404 \begin_layout Subsection
5386 System command aliases
5405 System command aliases
5387 \end_layout
5406 \end_layout
5388
5407
5389 \begin_layout Standard
5408 \begin_layout Standard
5390 The
5409 The
5391 \family typewriter
5410 \family typewriter
5392 %alias
5411 %alias
5393 \family default
5412 \family default
5394 magic function and the
5413 magic function and the
5395 \family typewriter
5414 \family typewriter
5396 alias
5415 alias
5397 \family default
5416 \family default
5398 option in the
5417 option in the
5399 \family typewriter
5418 \family typewriter
5400 ipythonrc
5419 ipythonrc
5401 \family default
5420 \family default
5402 configuration file allow you to define magic functions which are in fact
5421 configuration file allow you to define magic functions which are in fact
5403 system shell commands.
5422 system shell commands.
5404 These aliases can have parameters.
5423 These aliases can have parameters.
5405
5424
5406 \end_layout
5425 \end_layout
5407
5426
5408 \begin_layout Standard
5427 \begin_layout Standard
5409 '
5428 '
5410 \family typewriter
5429 \family typewriter
5411 %alias alias_name cmd
5430 %alias alias_name cmd
5412 \family default
5431 \family default
5413 ' defines '
5432 ' defines '
5414 \family typewriter
5433 \family typewriter
5415 alias_name
5434 alias_name
5416 \family default
5435 \family default
5417 ' as an alias for '
5436 ' as an alias for '
5418 \family typewriter
5437 \family typewriter
5419 cmd
5438 cmd
5420 \family default
5439 \family default
5421 '
5440 '
5422 \end_layout
5441 \end_layout
5423
5442
5424 \begin_layout Standard
5443 \begin_layout Standard
5425 Then, typing '
5444 Then, typing '
5426 \family typewriter
5445 \family typewriter
5427 %alias_name params
5446 %alias_name params
5428 \family default
5447 \family default
5429 ' will execute the system command '
5448 ' will execute the system command '
5430 \family typewriter
5449 \family typewriter
5431 cmd params
5450 cmd params
5432 \family default
5451 \family default
5433 ' (from your underlying operating system).
5452 ' (from your underlying operating system).
5434
5453
5435 \end_layout
5454 \end_layout
5436
5455
5437 \begin_layout Standard
5456 \begin_layout Standard
5438 You can also define aliases with parameters using
5457 You can also define aliases with parameters using
5439 \family typewriter
5458 \family typewriter
5440 %s
5459 %s
5441 \family default
5460 \family default
5442 specifiers (one per parameter).
5461 specifiers (one per parameter).
5443 The following example defines the
5462 The following example defines the
5444 \family typewriter
5463 \family typewriter
5445 %parts
5464 %parts
5446 \family default
5465 \family default
5447 function as an alias to the command '
5466 function as an alias to the command '
5448 \family typewriter
5467 \family typewriter
5449 echo first %s second %s
5468 echo first %s second %s
5450 \family default
5469 \family default
5451 ' where each
5470 ' where each
5452 \family typewriter
5471 \family typewriter
5453 %s
5472 %s
5454 \family default
5473 \family default
5455 will be replaced by a positional parameter to the call to
5474 will be replaced by a positional parameter to the call to
5456 \family typewriter
5475 \family typewriter
5457 %parts:
5476 %parts:
5458 \end_layout
5477 \end_layout
5459
5478
5460 \begin_layout Standard
5479 \begin_layout Standard
5461
5480
5462 \family typewriter
5481 \family typewriter
5463 In [1]: alias parts echo first %s second %s
5482 In [1]: alias parts echo first %s second %s
5464 \newline
5483 \newline
5465 In [2]: %parts A B
5484 In [2]: %parts A B
5466 \newline
5485 \newline
5467 first A second
5486 first A second
5468 B
5487 B
5469 \newline
5488 \newline
5470 In [3]: %parts A
5489 In [3]: %parts A
5471 \newline
5490 \newline
5472 Incorrect number of arguments: 2 expected.
5491 Incorrect number of arguments: 2 expected.
5473
5492
5474 \newline
5493 \newline
5475 parts is an alias to: 'echo first %s second %s'
5494 parts is an alias to: 'echo first %s second %s'
5476 \end_layout
5495 \end_layout
5477
5496
5478 \begin_layout Standard
5497 \begin_layout Standard
5479 If called with no parameters,
5498 If called with no parameters,
5480 \family typewriter
5499 \family typewriter
5481 %alias
5500 %alias
5482 \family default
5501 \family default
5483 prints the table of currently defined aliases.
5502 prints the table of currently defined aliases.
5484 \end_layout
5503 \end_layout
5485
5504
5486 \begin_layout Standard
5505 \begin_layout Standard
5487 The
5506 The
5488 \family typewriter
5507 \family typewriter
5489 %rehash/rehashx
5508 %rehash/rehashx
5490 \family default
5509 \family default
5491 magics allow you to load your entire
5510 magics allow you to load your entire
5492 \family typewriter
5511 \family typewriter
5493 $PATH
5512 $PATH
5494 \family default
5513 \family default
5495 as ipython aliases.
5514 as ipython aliases.
5496 See their respective docstrings (or sec.\InsetSpace ~
5515 See their respective docstrings (or sec.\InsetSpace ~
5497
5516
5498 \begin_inset LatexCommand \ref{sec:magic}
5517 \begin_inset LatexCommand \ref{sec:magic}
5499
5518
5500 \end_inset
5519 \end_inset
5501
5520
5502 for further details).
5521 for further details).
5503 \end_layout
5522 \end_layout
5504
5523
5505 \begin_layout Subsection
5524 \begin_layout Subsection
5506 \begin_inset LatexCommand \label{sec:dreload}
5525 \begin_inset LatexCommand \label{sec:dreload}
5507
5526
5508 \end_inset
5527 \end_inset
5509
5528
5510 Recursive reload
5529 Recursive reload
5511 \end_layout
5530 \end_layout
5512
5531
5513 \begin_layout Standard
5532 \begin_layout Standard
5514 The
5533 The
5515 \family typewriter
5534 \family typewriter
5516 dreload
5535 dreload
5517 \family default
5536 \family default
5518 function does a recursive reload of a module: changes made to the module
5537 function does a recursive reload of a module: changes made to the module
5519 since you imported will actually be available without having to exit.
5538 since you imported will actually be available without having to exit.
5520 \end_layout
5539 \end_layout
5521
5540
5522 \begin_layout Subsection
5541 \begin_layout Subsection
5523 Verbose and colored exception traceback printouts
5542 Verbose and colored exception traceback printouts
5524 \end_layout
5543 \end_layout
5525
5544
5526 \begin_layout Standard
5545 \begin_layout Standard
5527 IPython provides the option to see very detailed exception tracebacks, which
5546 IPython provides the option to see very detailed exception tracebacks, which
5528 can be especially useful when debugging large programs.
5547 can be especially useful when debugging large programs.
5529 You can run any Python file with the
5548 You can run any Python file with the
5530 \family typewriter
5549 \family typewriter
5531 %run
5550 %run
5532 \family default
5551 \family default
5533 function to benefit from these detailed tracebacks.
5552 function to benefit from these detailed tracebacks.
5534 Furthermore, both normal and verbose tracebacks can be colored (if your
5553 Furthermore, both normal and verbose tracebacks can be colored (if your
5535 terminal supports it) which makes them much easier to parse visually.
5554 terminal supports it) which makes them much easier to parse visually.
5536 \end_layout
5555 \end_layout
5537
5556
5538 \begin_layout Standard
5557 \begin_layout Standard
5539 See the magic
5558 See the magic
5540 \family typewriter
5559 \family typewriter
5541 xmode
5560 xmode
5542 \family default
5561 \family default
5543 and
5562 and
5544 \family typewriter
5563 \family typewriter
5545 colors
5564 colors
5546 \family default
5565 \family default
5547 functions for details (just type
5566 functions for details (just type
5548 \family typewriter
5567 \family typewriter
5549 %magic
5568 %magic
5550 \family default
5569 \family default
5551 ).
5570 ).
5552 \end_layout
5571 \end_layout
5553
5572
5554 \begin_layout Standard
5573 \begin_layout Standard
5555 These features are basically a terminal version of Ka-Ping Yee's
5574 These features are basically a terminal version of Ka-Ping Yee's
5556 \family typewriter
5575 \family typewriter
5557 cgitb
5576 cgitb
5558 \family default
5577 \family default
5559 module, now part of the standard Python library.
5578 module, now part of the standard Python library.
5560 \end_layout
5579 \end_layout
5561
5580
5562 \begin_layout Subsection
5581 \begin_layout Subsection
5563 \begin_inset LatexCommand \label{sec:cache_input}
5582 \begin_inset LatexCommand \label{sec:cache_input}
5564
5583
5565 \end_inset
5584 \end_inset
5566
5585
5567 Input caching system
5586 Input caching system
5568 \end_layout
5587 \end_layout
5569
5588
5570 \begin_layout Standard
5589 \begin_layout Standard
5571 IPython offers numbered prompts (In/Out) with input and output caching.
5590 IPython offers numbered prompts (In/Out) with input and output caching.
5572 All input is saved and can be retrieved as variables (besides the usual
5591 All input is saved and can be retrieved as variables (besides the usual
5573 arrow key recall).
5592 arrow key recall).
5574 \end_layout
5593 \end_layout
5575
5594
5576 \begin_layout Standard
5595 \begin_layout Standard
5577 The following GLOBAL variables always exist (so don't overwrite them!):
5596 The following GLOBAL variables always exist (so don't overwrite them!):
5578
5597
5579 \family typewriter
5598 \family typewriter
5580 _i
5599 _i
5581 \family default
5600 \family default
5582 : stores previous input.
5601 : stores previous input.
5583
5602
5584 \family typewriter
5603 \family typewriter
5585 _ii
5604 _ii
5586 \family default
5605 \family default
5587 : next previous.
5606 : next previous.
5588
5607
5589 \family typewriter
5608 \family typewriter
5590 _iii
5609 _iii
5591 \family default
5610 \family default
5592 : next-next previous.
5611 : next-next previous.
5593
5612
5594 \family typewriter
5613 \family typewriter
5595 _ih
5614 _ih
5596 \family default
5615 \family default
5597 : a list of all input
5616 : a list of all input
5598 \family typewriter
5617 \family typewriter
5599 _ih[n]
5618 _ih[n]
5600 \family default
5619 \family default
5601 is the input from line
5620 is the input from line
5602 \family typewriter
5621 \family typewriter
5603 n
5622 n
5604 \family default
5623 \family default
5605 and this list is aliased to the global variable
5624 and this list is aliased to the global variable
5606 \family typewriter
5625 \family typewriter
5607 In
5626 In
5608 \family default
5627 \family default
5609 .
5628 .
5610 If you overwrite
5629 If you overwrite
5611 \family typewriter
5630 \family typewriter
5612 In
5631 In
5613 \family default
5632 \family default
5614 with a variable of your own, you can remake the assignment to the internal
5633 with a variable of your own, you can remake the assignment to the internal
5615 list with a simple
5634 list with a simple
5616 \family typewriter
5635 \family typewriter
5617 'In=_ih'
5636 'In=_ih'
5618 \family default
5637 \family default
5619 .
5638 .
5620 \end_layout
5639 \end_layout
5621
5640
5622 \begin_layout Standard
5641 \begin_layout Standard
5623 Additionally, global variables named
5642 Additionally, global variables named
5624 \family typewriter
5643 \family typewriter
5625 _i<n>
5644 _i<n>
5626 \family default
5645 \family default
5627 are dynamically created (
5646 are dynamically created (
5628 \family typewriter
5647 \family typewriter
5629 <n>
5648 <n>
5630 \family default
5649 \family default
5631 being the prompt counter), such that
5650 being the prompt counter), such that
5632 \newline
5651 \newline
5633
5652
5634 \family typewriter
5653 \family typewriter
5635 _i<n> == _ih[<n>] == In[<n>].
5654 _i<n> == _ih[<n>] == In[<n>].
5636 \end_layout
5655 \end_layout
5637
5656
5638 \begin_layout Standard
5657 \begin_layout Standard
5639 For example, what you typed at prompt 14 is available as
5658 For example, what you typed at prompt 14 is available as
5640 \family typewriter
5659 \family typewriter
5641 _i14,
5660 _i14,
5642 \family default
5661 \family default
5643
5662
5644 \family typewriter
5663 \family typewriter
5645 _ih[14]
5664 _ih[14]
5646 \family default
5665 \family default
5647 and
5666 and
5648 \family typewriter
5667 \family typewriter
5649 In[14]
5668 In[14]
5650 \family default
5669 \family default
5651 .
5670 .
5652 \end_layout
5671 \end_layout
5653
5672
5654 \begin_layout Standard
5673 \begin_layout Standard
5655 This allows you to easily cut and paste multi line interactive prompts by
5674 This allows you to easily cut and paste multi line interactive prompts by
5656 printing them out: they print like a clean string, without prompt characters.
5675 printing them out: they print like a clean string, without prompt characters.
5657 You can also manipulate them like regular variables (they are strings),
5676 You can also manipulate them like regular variables (they are strings),
5658 modify or exec them (typing
5677 modify or exec them (typing
5659 \family typewriter
5678 \family typewriter
5660 'exec _i9'
5679 'exec _i9'
5661 \family default
5680 \family default
5662 will re-execute the contents of input prompt 9, '
5681 will re-execute the contents of input prompt 9, '
5663 \family typewriter
5682 \family typewriter
5664 exec In[9:14]+In[18]
5683 exec In[9:14]+In[18]
5665 \family default
5684 \family default
5666 ' will re-execute lines 9 through 13 and line 18).
5685 ' will re-execute lines 9 through 13 and line 18).
5667 \end_layout
5686 \end_layout
5668
5687
5669 \begin_layout Standard
5688 \begin_layout Standard
5670 You can also re-execute multiple lines of input easily by using the magic
5689 You can also re-execute multiple lines of input easily by using the magic
5671
5690
5672 \family typewriter
5691 \family typewriter
5673 %macro
5692 %macro
5674 \family default
5693 \family default
5675 function (which automates the process and allows re-execution without having
5694 function (which automates the process and allows re-execution without having
5676 to type '
5695 to type '
5677 \family typewriter
5696 \family typewriter
5678 exec
5697 exec
5679 \family default
5698 \family default
5680 ' every time).
5699 ' every time).
5681 The macro system also allows you to re-execute previous lines which include
5700 The macro system also allows you to re-execute previous lines which include
5682 magic function calls (which require special processing).
5701 magic function calls (which require special processing).
5683 Type
5702 Type
5684 \family typewriter
5703 \family typewriter
5685 %macro?
5704 %macro?
5686 \family default
5705 \family default
5687 or see sec.
5706 or see sec.
5688
5707
5689 \begin_inset LatexCommand \ref{sec:magic}
5708 \begin_inset LatexCommand \ref{sec:magic}
5690
5709
5691 \end_inset
5710 \end_inset
5692
5711
5693 for more details on the macro system.
5712 for more details on the macro system.
5694 \end_layout
5713 \end_layout
5695
5714
5696 \begin_layout Standard
5715 \begin_layout Standard
5697 A history function
5716 A history function
5698 \family typewriter
5717 \family typewriter
5699 %hist
5718 %hist
5700 \family default
5719 \family default
5701 allows you to see any part of your input history by printing a range of
5720 allows you to see any part of your input history by printing a range of
5702 the
5721 the
5703 \family typewriter
5722 \family typewriter
5704 _i
5723 _i
5705 \family default
5724 \family default
5706 variables.
5725 variables.
5707 \end_layout
5726 \end_layout
5708
5727
5709 \begin_layout Subsection
5728 \begin_layout Subsection
5710 \begin_inset LatexCommand \label{sec:cache_output}
5729 \begin_inset LatexCommand \label{sec:cache_output}
5711
5730
5712 \end_inset
5731 \end_inset
5713
5732
5714 Output caching system
5733 Output caching system
5715 \end_layout
5734 \end_layout
5716
5735
5717 \begin_layout Standard
5736 \begin_layout Standard
5718 For output that is returned from actions, a system similar to the input
5737 For output that is returned from actions, a system similar to the input
5719 cache exists but using
5738 cache exists but using
5720 \family typewriter
5739 \family typewriter
5721 _
5740 _
5722 \family default
5741 \family default
5723 instead of
5742 instead of
5724 \family typewriter
5743 \family typewriter
5725 _i
5744 _i
5726 \family default
5745 \family default
5727 .
5746 .
5728 Only actions that produce a result (NOT assignments, for example) are cached.
5747 Only actions that produce a result (NOT assignments, for example) are cached.
5729 If you are familiar with Mathematica, IPython's
5748 If you are familiar with Mathematica, IPython's
5730 \family typewriter
5749 \family typewriter
5731 _
5750 _
5732 \family default
5751 \family default
5733 variables behave exactly like Mathematica's
5752 variables behave exactly like Mathematica's
5734 \family typewriter
5753 \family typewriter
5735 %
5754 %
5736 \family default
5755 \family default
5737 variables.
5756 variables.
5738 \end_layout
5757 \end_layout
5739
5758
5740 \begin_layout Standard
5759 \begin_layout Standard
5741 The following GLOBAL variables always exist (so don't overwrite them!):
5760 The following GLOBAL variables always exist (so don't overwrite them!):
5742
5761
5743 \end_layout
5762 \end_layout
5744
5763
5745 \begin_layout List
5764 \begin_layout List
5746 \labelwidthstring 00.00.0000
5765 \labelwidthstring 00.00.0000
5747
5766
5748 \family typewriter
5767 \family typewriter
5749 \series bold
5768 \series bold
5750 _
5769 _
5751 \family default
5770 \family default
5752 \series default
5771 \series default
5753 (a
5772 (a
5754 \emph on
5773 \emph on
5755 single
5774 single
5756 \emph default
5775 \emph default
5757 underscore) : stores previous output, like Python's default interpreter.
5776 underscore) : stores previous output, like Python's default interpreter.
5758 \end_layout
5777 \end_layout
5759
5778
5760 \begin_layout List
5779 \begin_layout List
5761 \labelwidthstring 00.00.0000
5780 \labelwidthstring 00.00.0000
5762
5781
5763 \family typewriter
5782 \family typewriter
5764 \series bold
5783 \series bold
5765 __
5784 __
5766 \family default
5785 \family default
5767 \series default
5786 \series default
5768 (two underscores): next previous.
5787 (two underscores): next previous.
5769 \end_layout
5788 \end_layout
5770
5789
5771 \begin_layout List
5790 \begin_layout List
5772 \labelwidthstring 00.00.0000
5791 \labelwidthstring 00.00.0000
5773
5792
5774 \family typewriter
5793 \family typewriter
5775 \series bold
5794 \series bold
5776 ___
5795 ___
5777 \family default
5796 \family default
5778 \series default
5797 \series default
5779 (three underscores): next-next previous.
5798 (three underscores): next-next previous.
5780 \end_layout
5799 \end_layout
5781
5800
5782 \begin_layout Standard
5801 \begin_layout Standard
5783 Additionally, global variables named
5802 Additionally, global variables named
5784 \family typewriter
5803 \family typewriter
5785 _<n>
5804 _<n>
5786 \family default
5805 \family default
5787 are dynamically created (
5806 are dynamically created (
5788 \family typewriter
5807 \family typewriter
5789 <n>
5808 <n>
5790 \family default
5809 \family default
5791 being the prompt counter), such that the result of output
5810 being the prompt counter), such that the result of output
5792 \family typewriter
5811 \family typewriter
5793 <n>
5812 <n>
5794 \family default
5813 \family default
5795 is always available as
5814 is always available as
5796 \family typewriter
5815 \family typewriter
5797 _<n>
5816 _<n>
5798 \family default
5817 \family default
5799 (don't use the angle brackets, just the number, e.g.
5818 (don't use the angle brackets, just the number, e.g.
5800
5819
5801 \family typewriter
5820 \family typewriter
5802 _21
5821 _21
5803 \family default
5822 \family default
5804 ).
5823 ).
5805 \end_layout
5824 \end_layout
5806
5825
5807 \begin_layout Standard
5826 \begin_layout Standard
5808 These global variables are all stored in a global dictionary (not a list,
5827 These global variables are all stored in a global dictionary (not a list,
5809 since it only has entries for lines which returned a result) available
5828 since it only has entries for lines which returned a result) available
5810 under the names
5829 under the names
5811 \family typewriter
5830 \family typewriter
5812 _oh
5831 _oh
5813 \family default
5832 \family default
5814 and
5833 and
5815 \family typewriter
5834 \family typewriter
5816 Out
5835 Out
5817 \family default
5836 \family default
5818 (similar to
5837 (similar to
5819 \family typewriter
5838 \family typewriter
5820 _ih
5839 _ih
5821 \family default
5840 \family default
5822 and
5841 and
5823 \family typewriter
5842 \family typewriter
5824 In
5843 In
5825 \family default
5844 \family default
5826 ).
5845 ).
5827 So the output from line 12 can be obtained as
5846 So the output from line 12 can be obtained as
5828 \family typewriter
5847 \family typewriter
5829 _12
5848 _12
5830 \family default
5849 \family default
5831 ,
5850 ,
5832 \family typewriter
5851 \family typewriter
5833 Out[12]
5852 Out[12]
5834 \family default
5853 \family default
5835 or
5854 or
5836 \family typewriter
5855 \family typewriter
5837 _oh[12]
5856 _oh[12]
5838 \family default
5857 \family default
5839 .
5858 .
5840 If you accidentally overwrite the
5859 If you accidentally overwrite the
5841 \family typewriter
5860 \family typewriter
5842 Out
5861 Out
5843 \family default
5862 \family default
5844 variable you can recover it by typing
5863 variable you can recover it by typing
5845 \family typewriter
5864 \family typewriter
5846 'Out=_oh
5865 'Out=_oh
5847 \family default
5866 \family default
5848 ' at the prompt.
5867 ' at the prompt.
5849 \end_layout
5868 \end_layout
5850
5869
5851 \begin_layout Standard
5870 \begin_layout Standard
5852 This system obviously can potentially put heavy memory demands on your system,
5871 This system obviously can potentially put heavy memory demands on your system,
5853 since it prevents Python's garbage collector from removing any previously
5872 since it prevents Python's garbage collector from removing any previously
5854 computed results.
5873 computed results.
5855 You can control how many results are kept in memory with the option (at
5874 You can control how many results are kept in memory with the option (at
5856 the command line or in your
5875 the command line or in your
5857 \family typewriter
5876 \family typewriter
5858 ipythonrc
5877 ipythonrc
5859 \family default
5878 \family default
5860 file)
5879 file)
5861 \family typewriter
5880 \family typewriter
5862 cache_size
5881 cache_size
5863 \family default
5882 \family default
5864 .
5883 .
5865 If you set it to 0, the whole system is completely disabled and the prompts
5884 If you set it to 0, the whole system is completely disabled and the prompts
5866 revert to the classic
5885 revert to the classic
5867 \family typewriter
5886 \family typewriter
5868 '>>>'
5887 '>>>'
5869 \family default
5888 \family default
5870 of normal Python.
5889 of normal Python.
5871 \end_layout
5890 \end_layout
5872
5891
5873 \begin_layout Subsection
5892 \begin_layout Subsection
5874 Directory history
5893 Directory history
5875 \end_layout
5894 \end_layout
5876
5895
5877 \begin_layout Standard
5896 \begin_layout Standard
5878 Your history of visited directories is kept in the global list
5897 Your history of visited directories is kept in the global list
5879 \family typewriter
5898 \family typewriter
5880 _dh
5899 _dh
5881 \family default
5900 \family default
5882 , and the magic
5901 , and the magic
5883 \family typewriter
5902 \family typewriter
5884 %cd
5903 %cd
5885 \family default
5904 \family default
5886 command can be used to go to any entry in that list.
5905 command can be used to go to any entry in that list.
5887 The
5906 The
5888 \family typewriter
5907 \family typewriter
5889 %dhist
5908 %dhist
5890 \family default
5909 \family default
5891 command allows you to view this history.
5910 command allows you to view this history.
5892 \end_layout
5911 \end_layout
5893
5912
5894 \begin_layout Subsection
5913 \begin_layout Subsection
5895 Automatic parentheses and quotes
5914 Automatic parentheses and quotes
5896 \end_layout
5915 \end_layout
5897
5916
5898 \begin_layout Standard
5917 \begin_layout Standard
5899 These features were adapted from Nathan Gray's LazyPython.
5918 These features were adapted from Nathan Gray's LazyPython.
5900 They are meant to allow less typing for common situations.
5919 They are meant to allow less typing for common situations.
5901 \end_layout
5920 \end_layout
5902
5921
5903 \begin_layout Subsubsection
5922 \begin_layout Subsubsection
5904 Automatic parentheses
5923 Automatic parentheses
5905 \end_layout
5924 \end_layout
5906
5925
5907 \begin_layout Standard
5926 \begin_layout Standard
5908 Callable objects (i.e.
5927 Callable objects (i.e.
5909 functions, methods, etc) can be invoked like this (notice the commas between
5928 functions, methods, etc) can be invoked like this (notice the commas between
5910 the arguments):
5929 the arguments):
5911 \end_layout
5930 \end_layout
5912
5931
5913 \begin_layout Standard
5932 \begin_layout Standard
5914
5933
5915 \family typewriter
5934 \family typewriter
5916 >>> callable_ob arg1, arg2, arg3
5935 >>> callable_ob arg1, arg2, arg3
5917 \end_layout
5936 \end_layout
5918
5937
5919 \begin_layout Standard
5938 \begin_layout Standard
5920 and the input will be translated to this:
5939 and the input will be translated to this:
5921 \end_layout
5940 \end_layout
5922
5941
5923 \begin_layout Standard
5942 \begin_layout Standard
5924
5943
5925 \family typewriter
5944 \family typewriter
5926 --> callable_ob(arg1, arg2, arg3)
5945 --> callable_ob(arg1, arg2, arg3)
5927 \end_layout
5946 \end_layout
5928
5947
5929 \begin_layout Standard
5948 \begin_layout Standard
5930 You can force automatic parentheses by using '/' as the first character
5949 You can force automatic parentheses by using '/' as the first character
5931 of a line.
5950 of a line.
5932 For example:
5951 For example:
5933 \end_layout
5952 \end_layout
5934
5953
5935 \begin_layout Standard
5954 \begin_layout Standard
5936
5955
5937 \family typewriter
5956 \family typewriter
5938 >>> /globals # becomes 'globals()'
5957 >>> /globals # becomes 'globals()'
5939 \end_layout
5958 \end_layout
5940
5959
5941 \begin_layout Standard
5960 \begin_layout Standard
5942 Note that the '/' MUST be the first character on the line! This won't work:
5961 Note that the '/' MUST be the first character on the line! This won't work:
5943
5962
5944 \end_layout
5963 \end_layout
5945
5964
5946 \begin_layout Standard
5965 \begin_layout Standard
5947
5966
5948 \family typewriter
5967 \family typewriter
5949 >>> print /globals # syntax error
5968 >>> print /globals # syntax error
5950 \end_layout
5969 \end_layout
5951
5970
5952 \begin_layout Standard
5971 \begin_layout Standard
5953 In most cases the automatic algorithm should work, so you should rarely
5972 In most cases the automatic algorithm should work, so you should rarely
5954 need to explicitly invoke /.
5973 need to explicitly invoke /.
5955 One notable exception is if you are trying to call a function with a list
5974 One notable exception is if you are trying to call a function with a list
5956 of tuples as arguments (the parenthesis will confuse IPython):
5975 of tuples as arguments (the parenthesis will confuse IPython):
5957 \end_layout
5976 \end_layout
5958
5977
5959 \begin_layout Standard
5978 \begin_layout Standard
5960
5979
5961 \family typewriter
5980 \family typewriter
5962 In [1]: zip (1,2,3),(4,5,6) # won't work
5981 In [1]: zip (1,2,3),(4,5,6) # won't work
5963 \end_layout
5982 \end_layout
5964
5983
5965 \begin_layout Standard
5984 \begin_layout Standard
5966 but this will work:
5985 but this will work:
5967 \end_layout
5986 \end_layout
5968
5987
5969 \begin_layout Standard
5988 \begin_layout Standard
5970
5989
5971 \family typewriter
5990 \family typewriter
5972 In [2]: /zip (1,2,3),(4,5,6)
5991 In [2]: /zip (1,2,3),(4,5,6)
5973 \newline
5992 \newline
5974 ------> zip ((1,2,3),(4,5,6))
5993 ------> zip ((1,2,3),(4,5,6))
5975 \newline
5994 \newline
5976 Out[2]= [(1, 4),
5995 Out[2]= [(1, 4),
5977 (2, 5), (3, 6)]
5996 (2, 5), (3, 6)]
5978 \end_layout
5997 \end_layout
5979
5998
5980 \begin_layout Standard
5999 \begin_layout Standard
5981 IPython tells you that it has altered your command line by displaying the
6000 IPython tells you that it has altered your command line by displaying the
5982 new command line preceded by
6001 new command line preceded by
5983 \family typewriter
6002 \family typewriter
5984 -->
6003 -->
5985 \family default
6004 \family default
5986 .
6005 .
5987 e.g.:
6006 e.g.:
5988 \end_layout
6007 \end_layout
5989
6008
5990 \begin_layout Standard
6009 \begin_layout Standard
5991
6010
5992 \family typewriter
6011 \family typewriter
5993 In [18]: callable list
6012 In [18]: callable list
5994 \newline
6013 \newline
5995 -------> callable (list)
6014 -------> callable (list)
5996 \end_layout
6015 \end_layout
5997
6016
5998 \begin_layout Subsubsection
6017 \begin_layout Subsubsection
5999 Automatic quoting
6018 Automatic quoting
6000 \end_layout
6019 \end_layout
6001
6020
6002 \begin_layout Standard
6021 \begin_layout Standard
6003 You can force automatic quoting of a function's arguments by using
6022 You can force automatic quoting of a function's arguments by using
6004 \family typewriter
6023 \family typewriter
6005 `,'
6024 `,'
6006 \family default
6025 \family default
6007 or
6026 or
6008 \family typewriter
6027 \family typewriter
6009 `;'
6028 `;'
6010 \family default
6029 \family default
6011 as the first character of a line.
6030 as the first character of a line.
6012 For example:
6031 For example:
6013 \end_layout
6032 \end_layout
6014
6033
6015 \begin_layout Standard
6034 \begin_layout Standard
6016
6035
6017 \family typewriter
6036 \family typewriter
6018 >>> ,my_function /home/me # becomes my_function("/home/me")
6037 >>> ,my_function /home/me # becomes my_function("/home/me")
6019 \end_layout
6038 \end_layout
6020
6039
6021 \begin_layout Standard
6040 \begin_layout Standard
6022 If you use
6041 If you use
6023 \family typewriter
6042 \family typewriter
6024 `;'
6043 `;'
6025 \family default
6044 \family default
6026 instead, the whole argument is quoted as a single string (while
6045 instead, the whole argument is quoted as a single string (while
6027 \family typewriter
6046 \family typewriter
6028 `,'
6047 `,'
6029 \family default
6048 \family default
6030 splits on whitespace):
6049 splits on whitespace):
6031 \end_layout
6050 \end_layout
6032
6051
6033 \begin_layout Standard
6052 \begin_layout Standard
6034
6053
6035 \family typewriter
6054 \family typewriter
6036 >>> ,my_function a b c # becomes my_function("a","b","c")
6055 >>> ,my_function a b c # becomes my_function("a","b","c")
6037 \end_layout
6056 \end_layout
6038
6057
6039 \begin_layout Standard
6058 \begin_layout Standard
6040
6059
6041 \family typewriter
6060 \family typewriter
6042 >>> ;my_function a b c # becomes my_function("a b c")
6061 >>> ;my_function a b c # becomes my_function("a b c")
6043 \end_layout
6062 \end_layout
6044
6063
6045 \begin_layout Standard
6064 \begin_layout Standard
6046 Note that the `
6065 Note that the `
6047 \family typewriter
6066 \family typewriter
6048 ,
6067 ,
6049 \family default
6068 \family default
6050 ' or `
6069 ' or `
6051 \family typewriter
6070 \family typewriter
6052 ;
6071 ;
6053 \family default
6072 \family default
6054 ' MUST be the first character on the line! This won't work:
6073 ' MUST be the first character on the line! This won't work:
6055 \end_layout
6074 \end_layout
6056
6075
6057 \begin_layout Standard
6076 \begin_layout Standard
6058
6077
6059 \family typewriter
6078 \family typewriter
6060 >>> x = ,my_function /home/me # syntax error
6079 >>> x = ,my_function /home/me # syntax error
6061 \end_layout
6080 \end_layout
6062
6081
6063 \begin_layout Section
6082 \begin_layout Section
6064 \begin_inset LatexCommand \label{sec:customization}
6083 \begin_inset LatexCommand \label{sec:customization}
6065
6084
6066 \end_inset
6085 \end_inset
6067
6086
6068 Customization
6087 Customization
6069 \end_layout
6088 \end_layout
6070
6089
6071 \begin_layout Standard
6090 \begin_layout Standard
6072 As we've already mentioned, IPython reads a configuration file which can
6091 As we've already mentioned, IPython reads a configuration file which can
6073 be specified at the command line (
6092 be specified at the command line (
6074 \family typewriter
6093 \family typewriter
6075 -rcfile
6094 -rcfile
6076 \family default
6095 \family default
6077 ) or which by default is assumed to be called
6096 ) or which by default is assumed to be called
6078 \family typewriter
6097 \family typewriter
6079 ipythonrc
6098 ipythonrc
6080 \family default
6099 \family default
6081 .
6100 .
6082 Such a file is looked for in the current directory where IPython is started
6101 Such a file is looked for in the current directory where IPython is started
6083 and then in your
6102 and then in your
6084 \family typewriter
6103 \family typewriter
6085 IPYTHONDIR
6104 IPYTHONDIR
6086 \family default
6105 \family default
6087 , which allows you to have local configuration files for specific projects.
6106 , which allows you to have local configuration files for specific projects.
6088 In this section we will call these types of configuration files simply
6107 In this section we will call these types of configuration files simply
6089 rcfiles (short for resource configuration file).
6108 rcfiles (short for resource configuration file).
6090 \end_layout
6109 \end_layout
6091
6110
6092 \begin_layout Standard
6111 \begin_layout Standard
6093 The syntax of an rcfile is one of key-value pairs separated by whitespace,
6112 The syntax of an rcfile is one of key-value pairs separated by whitespace,
6094 one per line.
6113 one per line.
6095 Lines beginning with a
6114 Lines beginning with a
6096 \family typewriter
6115 \family typewriter
6097 #
6116 #
6098 \family default
6117 \family default
6099 are ignored as comments, but comments can
6118 are ignored as comments, but comments can
6100 \series bold
6119 \series bold
6101 not
6120 not
6102 \series default
6121 \series default
6103 be put on lines with data (the parser is fairly primitive).
6122 be put on lines with data (the parser is fairly primitive).
6104 Note that these are not python files, and this is deliberate, because it
6123 Note that these are not python files, and this is deliberate, because it
6105 allows us to do some things which would be quite tricky to implement if
6124 allows us to do some things which would be quite tricky to implement if
6106 they were normal python files.
6125 they were normal python files.
6107 \end_layout
6126 \end_layout
6108
6127
6109 \begin_layout Standard
6128 \begin_layout Standard
6110 First, an rcfile can contain permanent default values for almost all command
6129 First, an rcfile can contain permanent default values for almost all command
6111 line options (except things like
6130 line options (except things like
6112 \family typewriter
6131 \family typewriter
6113 -help
6132 -help
6114 \family default
6133 \family default
6115 or
6134 or
6116 \family typewriter
6135 \family typewriter
6117 -Version
6136 -Version
6118 \family default
6137 \family default
6119 ).
6138 ).
6120 Sec\InsetSpace ~
6139 Sec\InsetSpace ~
6121
6140
6122 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
6141 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
6123
6142
6124 \end_inset
6143 \end_inset
6125
6144
6126 contains a description of all command-line options.
6145 contains a description of all command-line options.
6127 However, values you explicitly specify at the command line override the
6146 However, values you explicitly specify at the command line override the
6128 values defined in the rcfile.
6147 values defined in the rcfile.
6129 \end_layout
6148 \end_layout
6130
6149
6131 \begin_layout Standard
6150 \begin_layout Standard
6132 Besides command line option values, the rcfile can specify values for certain
6151 Besides command line option values, the rcfile can specify values for certain
6133 extra special options which are not available at the command line.
6152 extra special options which are not available at the command line.
6134 These options are briefly described below.
6153 These options are briefly described below.
6135
6154
6136 \end_layout
6155 \end_layout
6137
6156
6138 \begin_layout Standard
6157 \begin_layout Standard
6139 Each of these options may appear as many times as you need it in the file.
6158 Each of these options may appear as many times as you need it in the file.
6140 \end_layout
6159 \end_layout
6141
6160
6142 \begin_layout List
6161 \begin_layout List
6143 \labelwidthstring 00.00.0000
6162 \labelwidthstring 00.00.0000
6144
6163
6145 \family typewriter
6164 \family typewriter
6146 \series bold
6165 \series bold
6147 include\InsetSpace ~
6166 include\InsetSpace ~
6148 <file1>\InsetSpace ~
6167 <file1>\InsetSpace ~
6149 <file2>\InsetSpace ~
6168 <file2>\InsetSpace ~
6150 ...
6169 ...
6151 \family default
6170 \family default
6152 \series default
6171 \series default
6153 : you can name
6172 : you can name
6154 \emph on
6173 \emph on
6155 other
6174 other
6156 \emph default
6175 \emph default
6157 rcfiles you want to recursively load up to 15 levels (don't use the
6176 rcfiles you want to recursively load up to 15 levels (don't use the
6158 \family typewriter
6177 \family typewriter
6159 <>
6178 <>
6160 \family default
6179 \family default
6161 brackets in your names!).
6180 brackets in your names!).
6162 This feature allows you to define a 'base' rcfile with general options
6181 This feature allows you to define a 'base' rcfile with general options
6163 and special-purpose files which can be loaded only when needed with particular
6182 and special-purpose files which can be loaded only when needed with particular
6164 configuration options.
6183 configuration options.
6165 To make this more convenient, IPython accepts the
6184 To make this more convenient, IPython accepts the
6166 \family typewriter
6185 \family typewriter
6167 -profile <name>
6186 -profile <name>
6168 \family default
6187 \family default
6169 option (abbreviates to
6188 option (abbreviates to
6170 \family typewriter
6189 \family typewriter
6171 -p <name
6190 -p <name
6172 \family default
6191 \family default
6173 >)
6192 >)
6174 \family typewriter
6193 \family typewriter
6175 which
6194 which
6176 \family default
6195 \family default
6177 tells it to look for an rcfile named
6196 tells it to look for an rcfile named
6178 \family typewriter
6197 \family typewriter
6179 ipythonrc-<name>
6198 ipythonrc-<name>
6180 \family default
6199 \family default
6181 .
6200 .
6182
6201
6183 \end_layout
6202 \end_layout
6184
6203
6185 \begin_layout List
6204 \begin_layout List
6186 \labelwidthstring 00.00.0000
6205 \labelwidthstring 00.00.0000
6187
6206
6188 \family typewriter
6207 \family typewriter
6189 \series bold
6208 \series bold
6190 import_mod\InsetSpace ~
6209 import_mod\InsetSpace ~
6191 <mod1>\InsetSpace ~
6210 <mod1>\InsetSpace ~
6192 <mod2>\InsetSpace ~
6211 <mod2>\InsetSpace ~
6193 ...
6212 ...
6194 \family default
6213 \family default
6195 \series default
6214 \series default
6196 : import modules with '
6215 : import modules with '
6197 \family typewriter
6216 \family typewriter
6198 import
6217 import
6199 \family default
6218 \family default
6200
6219
6201 \family typewriter
6220 \family typewriter
6202 <mod1>,<mod2>,...
6221 <mod1>,<mod2>,...
6203 \family default
6222 \family default
6204 '
6223 '
6205 \end_layout
6224 \end_layout
6206
6225
6207 \begin_layout List
6226 \begin_layout List
6208 \labelwidthstring 00.00.0000
6227 \labelwidthstring 00.00.0000
6209
6228
6210 \family typewriter
6229 \family typewriter
6211 \series bold
6230 \series bold
6212 import_some\InsetSpace ~
6231 import_some\InsetSpace ~
6213 <mod>\InsetSpace ~
6232 <mod>\InsetSpace ~
6214 <f1>\InsetSpace ~
6233 <f1>\InsetSpace ~
6215 <f2>\InsetSpace ~
6234 <f2>\InsetSpace ~
6216 ...
6235 ...
6217 \family default
6236 \family default
6218 \series default
6237 \series default
6219 : import functions with '
6238 : import functions with '
6220 \family typewriter
6239 \family typewriter
6221 from <mod> import
6240 from <mod> import
6222 \family default
6241 \family default
6223
6242
6224 \family typewriter
6243 \family typewriter
6225 <f1>,<f2>,...
6244 <f1>,<f2>,...
6226 \family default
6245 \family default
6227 '
6246 '
6228 \end_layout
6247 \end_layout
6229
6248
6230 \begin_layout List
6249 \begin_layout List
6231 \labelwidthstring 00.00.0000
6250 \labelwidthstring 00.00.0000
6232
6251
6233 \family typewriter
6252 \family typewriter
6234 \series bold
6253 \series bold
6235 import_all\InsetSpace ~
6254 import_all\InsetSpace ~
6236 <mod1>\InsetSpace ~
6255 <mod1>\InsetSpace ~
6237 <mod2>\InsetSpace ~
6256 <mod2>\InsetSpace ~
6238 ...
6257 ...
6239 \family default
6258 \family default
6240 \series default
6259 \series default
6241 : for each module listed import functions with '
6260 : for each module listed import functions with '
6242 \family typewriter
6261 \family typewriter
6243 from <mod> import *
6262 from <mod> import *
6244 \family default
6263 \family default
6245 '
6264 '
6246 \end_layout
6265 \end_layout
6247
6266
6248 \begin_layout List
6267 \begin_layout List
6249 \labelwidthstring 00.00.0000
6268 \labelwidthstring 00.00.0000
6250
6269
6251 \family typewriter
6270 \family typewriter
6252 \series bold
6271 \series bold
6253 execute\InsetSpace ~
6272 execute\InsetSpace ~
6254 <python\InsetSpace ~
6273 <python\InsetSpace ~
6255 code>
6274 code>
6256 \family default
6275 \family default
6257 \series default
6276 \series default
6258 : give any single-line python code to be executed.
6277 : give any single-line python code to be executed.
6259 \end_layout
6278 \end_layout
6260
6279
6261 \begin_layout List
6280 \begin_layout List
6262 \labelwidthstring 00.00.0000
6281 \labelwidthstring 00.00.0000
6263
6282
6264 \family typewriter
6283 \family typewriter
6265 \series bold
6284 \series bold
6266 execfile\InsetSpace ~
6285 execfile\InsetSpace ~
6267 <filename>
6286 <filename>
6268 \family default
6287 \family default
6269 \series default
6288 \series default
6270 : execute the python file given with an '
6289 : execute the python file given with an '
6271 \family typewriter
6290 \family typewriter
6272 execfile(filename)
6291 execfile(filename)
6273 \family default
6292 \family default
6274 ' command.
6293 ' command.
6275 Username expansion is performed on the given names.
6294 Username expansion is performed on the given names.
6276 So if you need any amount of extra fancy customization that won't fit in
6295 So if you need any amount of extra fancy customization that won't fit in
6277 any of the above 'canned' options, you can just put it in a separate python
6296 any of the above 'canned' options, you can just put it in a separate python
6278 file and execute it.
6297 file and execute it.
6279 \end_layout
6298 \end_layout
6280
6299
6281 \begin_layout List
6300 \begin_layout List
6282 \labelwidthstring 00.00.0000
6301 \labelwidthstring 00.00.0000
6283
6302
6284 \family typewriter
6303 \family typewriter
6285 \series bold
6304 \series bold
6286 alias\InsetSpace ~
6305 alias\InsetSpace ~
6287 <alias_def>
6306 <alias_def>
6288 \family default
6307 \family default
6289 \series default
6308 \series default
6290 : this is equivalent to calling '
6309 : this is equivalent to calling '
6291 \family typewriter
6310 \family typewriter
6292 %alias\InsetSpace ~
6311 %alias\InsetSpace ~
6293 <alias_def>
6312 <alias_def>
6294 \family default
6313 \family default
6295 ' at the IPython command line.
6314 ' at the IPython command line.
6296 This way, from within IPython you can do common system tasks without having
6315 This way, from within IPython you can do common system tasks without having
6297 to exit it or use the
6316 to exit it or use the
6298 \family typewriter
6317 \family typewriter
6299 !
6318 !
6300 \family default
6319 \family default
6301 escape.
6320 escape.
6302 IPython isn't meant to be a shell replacement, but it is often very useful
6321 IPython isn't meant to be a shell replacement, but it is often very useful
6303 to be able to do things with files while testing code.
6322 to be able to do things with files while testing code.
6304 This gives you the flexibility to have within IPython any aliases you may
6323 This gives you the flexibility to have within IPython any aliases you may
6305 be used to under your normal system shell.
6324 be used to under your normal system shell.
6306 \end_layout
6325 \end_layout
6307
6326
6308 \begin_layout Subsection
6327 \begin_layout Subsection
6309 \begin_inset LatexCommand \label{sec:ipytonrc-sample}
6328 \begin_inset LatexCommand \label{sec:ipytonrc-sample}
6310
6329
6311 \end_inset
6330 \end_inset
6312
6331
6313 Sample
6332 Sample
6314 \family typewriter
6333 \family typewriter
6315 ipythonrc
6334 ipythonrc
6316 \family default
6335 \family default
6317 file
6336 file
6318 \end_layout
6337 \end_layout
6319
6338
6320 \begin_layout Standard
6339 \begin_layout Standard
6321 The default rcfile, called
6340 The default rcfile, called
6322 \family typewriter
6341 \family typewriter
6323 ipythonrc
6342 ipythonrc
6324 \family default
6343 \family default
6325 and supplied in your
6344 and supplied in your
6326 \family typewriter
6345 \family typewriter
6327 IPYTHONDIR
6346 IPYTHONDIR
6328 \family default
6347 \family default
6329 directory contains lots of comments on all of these options.
6348 directory contains lots of comments on all of these options.
6330 We reproduce it here for reference:
6349 We reproduce it here for reference:
6331 \end_layout
6350 \end_layout
6332
6351
6333 \begin_layout Standard
6352 \begin_layout Standard
6334 \begin_inset ERT
6353 \begin_inset ERT
6335 status open
6354 status open
6336
6355
6337 \begin_layout Standard
6356 \begin_layout Standard
6338
6357
6339
6358
6340 \backslash
6359 \backslash
6341 codelist{../IPython/UserConfig/ipythonrc}
6360 codelist{../IPython/UserConfig/ipythonrc}
6342 \end_layout
6361 \end_layout
6343
6362
6344 \end_inset
6363 \end_inset
6345
6364
6346
6365
6347 \end_layout
6366 \end_layout
6348
6367
6349 \begin_layout Subsection
6368 \begin_layout Subsection
6350 \begin_inset LatexCommand \label{sec:prompts}
6369 \begin_inset LatexCommand \label{sec:prompts}
6351
6370
6352 \end_inset
6371 \end_inset
6353
6372
6354 Fine-tuning your prompt
6373 Fine-tuning your prompt
6355 \end_layout
6374 \end_layout
6356
6375
6357 \begin_layout Standard
6376 \begin_layout Standard
6358 IPython's prompts can be customized using a syntax similar to that of the
6377 IPython's prompts can be customized using a syntax similar to that of the
6359
6378
6360 \family typewriter
6379 \family typewriter
6361 bash
6380 bash
6362 \family default
6381 \family default
6363 shell.
6382 shell.
6364 Many of
6383 Many of
6365 \family typewriter
6384 \family typewriter
6366 bash
6385 bash
6367 \family default
6386 \family default
6368 's escapes are supported, as well as a few additional ones.
6387 's escapes are supported, as well as a few additional ones.
6369 We list them below:
6388 We list them below:
6370 \end_layout
6389 \end_layout
6371
6390
6372 \begin_layout Description
6391 \begin_layout Description
6373
6392
6374 \backslash
6393 \backslash
6375 # the prompt/history count number.
6394 # the prompt/history count number.
6376 This escape is automatically wrapped in the coloring codes for the currently
6395 This escape is automatically wrapped in the coloring codes for the currently
6377 active color scheme.
6396 active color scheme.
6378 \end_layout
6397 \end_layout
6379
6398
6380 \begin_layout Description
6399 \begin_layout Description
6381
6400
6382 \backslash
6401 \backslash
6383 N the 'naked' prompt/history count number: this is just the number itself,
6402 N the 'naked' prompt/history count number: this is just the number itself,
6384 without any coloring applied to it.
6403 without any coloring applied to it.
6385 This lets you produce numbered prompts with your own colors.
6404 This lets you produce numbered prompts with your own colors.
6386 \end_layout
6405 \end_layout
6387
6406
6388 \begin_layout Description
6407 \begin_layout Description
6389
6408
6390 \backslash
6409 \backslash
6391 D the prompt/history count, with the actual digits replaced by dots.
6410 D the prompt/history count, with the actual digits replaced by dots.
6392 Used mainly in continuation prompts (prompt_in2)
6411 Used mainly in continuation prompts (prompt_in2)
6393 \end_layout
6412 \end_layout
6394
6413
6395 \begin_layout Description
6414 \begin_layout Description
6396
6415
6397 \backslash
6416 \backslash
6398 w the current working directory
6417 w the current working directory
6399 \end_layout
6418 \end_layout
6400
6419
6401 \begin_layout Description
6420 \begin_layout Description
6402
6421
6403 \backslash
6422 \backslash
6404 W the basename of current working directory
6423 W the basename of current working directory
6405 \end_layout
6424 \end_layout
6406
6425
6407 \begin_layout Description
6426 \begin_layout Description
6408
6427
6409 \backslash
6428 \backslash
6410 X
6429 X
6411 \emph on
6430 \emph on
6412 n
6431 n
6413 \emph default
6432 \emph default
6414 where
6433 where
6415 \begin_inset Formula $n=0\ldots5.$
6434 \begin_inset Formula $n=0\ldots5.$
6416 \end_inset
6435 \end_inset
6417
6436
6418 The current working directory, with
6437 The current working directory, with
6419 \family typewriter
6438 \family typewriter
6420 $HOME
6439 $HOME
6421 \family default
6440 \family default
6422 replaced by
6441 replaced by
6423 \family typewriter
6442 \family typewriter
6424 ~
6443 ~
6425 \family default
6444 \family default
6426 , and filtered out to contain only
6445 , and filtered out to contain only
6427 \begin_inset Formula $n$
6446 \begin_inset Formula $n$
6428 \end_inset
6447 \end_inset
6429
6448
6430 path elements
6449 path elements
6431 \end_layout
6450 \end_layout
6432
6451
6433 \begin_layout Description
6452 \begin_layout Description
6434
6453
6435 \backslash
6454 \backslash
6436 Y
6455 Y
6437 \emph on
6456 \emph on
6438 n
6457 n
6439 \emph default
6458 \emph default
6440 Similar to
6459 Similar to
6441 \backslash
6460 \backslash
6442 X
6461 X
6443 \emph on
6462 \emph on
6444 n
6463 n
6445 \emph default
6464 \emph default
6446 , but with the
6465 , but with the
6447 \begin_inset Formula $n+1$
6466 \begin_inset Formula $n+1$
6448 \end_inset
6467 \end_inset
6449
6468
6450 element included if it is
6469 element included if it is
6451 \family typewriter
6470 \family typewriter
6452 ~
6471 ~
6453 \family default
6472 \family default
6454 (this is similar to the behavior of the %c
6473 (this is similar to the behavior of the %c
6455 \emph on
6474 \emph on
6456 n
6475 n
6457 \emph default
6476 \emph default
6458 escapes in
6477 escapes in
6459 \family typewriter
6478 \family typewriter
6460 tcsh
6479 tcsh
6461 \family default
6480 \family default
6462 )
6481 )
6463 \end_layout
6482 \end_layout
6464
6483
6465 \begin_layout Description
6484 \begin_layout Description
6466
6485
6467 \backslash
6486 \backslash
6468 u the username of the current user
6487 u the username of the current user
6469 \end_layout
6488 \end_layout
6470
6489
6471 \begin_layout Description
6490 \begin_layout Description
6472
6491
6473 \backslash
6492 \backslash
6474 $ if the effective UID is 0, a #, otherwise a $
6493 $ if the effective UID is 0, a #, otherwise a $
6475 \end_layout
6494 \end_layout
6476
6495
6477 \begin_layout Description
6496 \begin_layout Description
6478
6497
6479 \backslash
6498 \backslash
6480 h the hostname up to the first `.'
6499 h the hostname up to the first `.'
6481 \end_layout
6500 \end_layout
6482
6501
6483 \begin_layout Description
6502 \begin_layout Description
6484
6503
6485 \backslash
6504 \backslash
6486 H the hostname
6505 H the hostname
6487 \end_layout
6506 \end_layout
6488
6507
6489 \begin_layout Description
6508 \begin_layout Description
6490
6509
6491 \backslash
6510 \backslash
6492 n a newline
6511 n a newline
6493 \end_layout
6512 \end_layout
6494
6513
6495 \begin_layout Description
6514 \begin_layout Description
6496
6515
6497 \backslash
6516 \backslash
6498 r a carriage return
6517 r a carriage return
6499 \end_layout
6518 \end_layout
6500
6519
6501 \begin_layout Description
6520 \begin_layout Description
6502
6521
6503 \backslash
6522 \backslash
6504 v IPython version string
6523 v IPython version string
6505 \end_layout
6524 \end_layout
6506
6525
6507 \begin_layout Standard
6526 \begin_layout Standard
6508 In addition to these, ANSI color escapes can be insterted into the prompts,
6527 In addition to these, ANSI color escapes can be insterted into the prompts,
6509 as
6528 as
6510 \family typewriter
6529 \family typewriter
6511
6530
6512 \backslash
6531 \backslash
6513 C_
6532 C_
6514 \emph on
6533 \emph on
6515 ColorName
6534 ColorName
6516 \family default
6535 \family default
6517 \emph default
6536 \emph default
6518 .
6537 .
6519 The list of valid color names is: Black, Blue, Brown, Cyan, DarkGray, Green,
6538 The list of valid color names is: Black, Blue, Brown, Cyan, DarkGray, Green,
6520 LightBlue, LightCyan, LightGray, LightGreen, LightPurple, LightRed, NoColor,
6539 LightBlue, LightCyan, LightGray, LightGreen, LightPurple, LightRed, NoColor,
6521 Normal, Purple, Red, White, Yellow.
6540 Normal, Purple, Red, White, Yellow.
6522 \end_layout
6541 \end_layout
6523
6542
6524 \begin_layout Standard
6543 \begin_layout Standard
6525 Finally, IPython supports the evaluation of arbitrary expressions in your
6544 Finally, IPython supports the evaluation of arbitrary expressions in your
6526 prompt string.
6545 prompt string.
6527 The prompt strings are evaluated through the syntax of PEP 215, but basically
6546 The prompt strings are evaluated through the syntax of PEP 215, but basically
6528 you can use
6547 you can use
6529 \family typewriter
6548 \family typewriter
6530 $x.y
6549 $x.y
6531 \family default
6550 \family default
6532 to expand the value of
6551 to expand the value of
6533 \family typewriter
6552 \family typewriter
6534 x.y
6553 x.y
6535 \family default
6554 \family default
6536 , and for more complicated expressions you can use braces:
6555 , and for more complicated expressions you can use braces:
6537 \family typewriter
6556 \family typewriter
6538 ${foo()+x}
6557 ${foo()+x}
6539 \family default
6558 \family default
6540 will call function
6559 will call function
6541 \family typewriter
6560 \family typewriter
6542 foo
6561 foo
6543 \family default
6562 \family default
6544 and add to it the value of
6563 and add to it the value of
6545 \family typewriter
6564 \family typewriter
6546 x
6565 x
6547 \family default
6566 \family default
6548 , before putting the result into your prompt.
6567 , before putting the result into your prompt.
6549 For example, using
6568 For example, using
6550 \newline
6569 \newline
6551
6570
6552 \family typewriter
6571 \family typewriter
6553 prompt_in1 '${commands.getoutput("uptime")}
6572 prompt_in1 '${commands.getoutput("uptime")}
6554 \backslash
6573 \backslash
6555 nIn [
6574 nIn [
6556 \backslash
6575 \backslash
6557 #]: '
6576 #]: '
6558 \newline
6577 \newline
6559
6578
6560 \family default
6579 \family default
6561 will print the result of the uptime command on each prompt (assuming the
6580 will print the result of the uptime command on each prompt (assuming the
6562
6581
6563 \family typewriter
6582 \family typewriter
6564 commands
6583 commands
6565 \family default
6584 \family default
6566 module has been imported in your
6585 module has been imported in your
6567 \family typewriter
6586 \family typewriter
6568 ipythonrc
6587 ipythonrc
6569 \family default
6588 \family default
6570 file).
6589 file).
6571 \end_layout
6590 \end_layout
6572
6591
6573 \begin_layout Subsubsection
6592 \begin_layout Subsubsection
6574 Prompt examples
6593 Prompt examples
6575 \end_layout
6594 \end_layout
6576
6595
6577 \begin_layout Standard
6596 \begin_layout Standard
6578 The following options in an ipythonrc file will give you IPython's default
6597 The following options in an ipythonrc file will give you IPython's default
6579 prompts:
6598 prompts:
6580 \end_layout
6599 \end_layout
6581
6600
6582 \begin_layout Standard
6601 \begin_layout Standard
6583
6602
6584 \family typewriter
6603 \family typewriter
6585 prompt_in1 'In [
6604 prompt_in1 'In [
6586 \backslash
6605 \backslash
6587 #]:'
6606 #]:'
6588 \newline
6607 \newline
6589 prompt_in2 '\InsetSpace ~
6608 prompt_in2 '\InsetSpace ~
6590 \InsetSpace ~
6609 \InsetSpace ~
6591 \InsetSpace ~
6610 \InsetSpace ~
6592 .
6611 .
6593 \backslash
6612 \backslash
6594 D.:'
6613 D.:'
6595 \newline
6614 \newline
6596 prompt_out 'Out[
6615 prompt_out 'Out[
6597 \backslash
6616 \backslash
6598 #]:'
6617 #]:'
6599 \end_layout
6618 \end_layout
6600
6619
6601 \begin_layout Standard
6620 \begin_layout Standard
6602 which look like this:
6621 which look like this:
6603 \end_layout
6622 \end_layout
6604
6623
6605 \begin_layout Standard
6624 \begin_layout Standard
6606
6625
6607 \family typewriter
6626 \family typewriter
6608 In [1]: 1+2
6627 In [1]: 1+2
6609 \newline
6628 \newline
6610 Out[1]: 3
6629 Out[1]: 3
6611 \end_layout
6630 \end_layout
6612
6631
6613 \begin_layout Standard
6632 \begin_layout Standard
6614
6633
6615 \family typewriter
6634 \family typewriter
6616 In [2]: for i in (1,2,3):
6635 In [2]: for i in (1,2,3):
6617 \newline
6636 \newline
6618
6637
6619 \begin_inset ERT
6638 \begin_inset ERT
6620 status collapsed
6639 status collapsed
6621
6640
6622 \begin_layout Standard
6641 \begin_layout Standard
6623
6642
6624
6643
6625 \backslash
6644 \backslash
6626 hspace*{0mm}
6645 hspace*{0mm}
6627 \end_layout
6646 \end_layout
6628
6647
6629 \end_inset
6648 \end_inset
6630
6649
6631 \InsetSpace ~
6650 \InsetSpace ~
6632 \InsetSpace ~
6651 \InsetSpace ~
6633 \InsetSpace ~
6652 \InsetSpace ~
6634 ...: \InsetSpace ~
6653 ...: \InsetSpace ~
6635 \InsetSpace ~
6654 \InsetSpace ~
6636 \InsetSpace ~
6655 \InsetSpace ~
6637 \InsetSpace ~
6656 \InsetSpace ~
6638 print i,
6657 print i,
6639 \newline
6658 \newline
6640
6659
6641 \begin_inset ERT
6660 \begin_inset ERT
6642 status collapsed
6661 status collapsed
6643
6662
6644 \begin_layout Standard
6663 \begin_layout Standard
6645
6664
6646
6665
6647 \backslash
6666 \backslash
6648 hspace*{0mm}
6667 hspace*{0mm}
6649 \end_layout
6668 \end_layout
6650
6669
6651 \end_inset
6670 \end_inset
6652
6671
6653 \InsetSpace ~
6672 \InsetSpace ~
6654 \InsetSpace ~
6673 \InsetSpace ~
6655 \InsetSpace ~
6674 \InsetSpace ~
6656 ...:
6675 ...:
6657 \newline
6676 \newline
6658 1 2 3
6677 1 2 3
6659 \end_layout
6678 \end_layout
6660
6679
6661 \begin_layout Standard
6680 \begin_layout Standard
6662 These will give you a very colorful prompt with path information:
6681 These will give you a very colorful prompt with path information:
6663 \end_layout
6682 \end_layout
6664
6683
6665 \begin_layout Standard
6684 \begin_layout Standard
6666
6685
6667 \family typewriter
6686 \family typewriter
6668 #prompt_in1 '
6687 #prompt_in1 '
6669 \backslash
6688 \backslash
6670 C_Red
6689 C_Red
6671 \backslash
6690 \backslash
6672 u
6691 u
6673 \backslash
6692 \backslash
6674 C_Blue[
6693 C_Blue[
6675 \backslash
6694 \backslash
6676 C_Cyan
6695 C_Cyan
6677 \backslash
6696 \backslash
6678 Y1
6697 Y1
6679 \backslash
6698 \backslash
6680 C_Blue]
6699 C_Blue]
6681 \backslash
6700 \backslash
6682 C_LightGreen
6701 C_LightGreen
6683 \backslash
6702 \backslash
6684 #>'
6703 #>'
6685 \newline
6704 \newline
6686 prompt_in2 ' ..
6705 prompt_in2 ' ..
6687 \backslash
6706 \backslash
6688 D>'
6707 D>'
6689 \newline
6708 \newline
6690 prompt_out '<
6709 prompt_out '<
6691 \backslash
6710 \backslash
6692 #>'
6711 #>'
6693 \end_layout
6712 \end_layout
6694
6713
6695 \begin_layout Standard
6714 \begin_layout Standard
6696 which look like this:
6715 which look like this:
6697 \end_layout
6716 \end_layout
6698
6717
6699 \begin_layout Standard
6718 \begin_layout Standard
6700
6719
6701 \family typewriter
6720 \family typewriter
6702 \color red
6721 \color red
6703 fperez
6722 fperez
6704 \color blue
6723 \color blue
6705 [
6724 [
6706 \color cyan
6725 \color cyan
6707 ~/ipython
6726 ~/ipython
6708 \color blue
6727 \color blue
6709 ]
6728 ]
6710 \color green
6729 \color green
6711 1>
6730 1>
6712 \color none
6731 \color none
6713 1+2
6732 1+2
6714 \newline
6733 \newline
6715
6734
6716 \begin_inset ERT
6735 \begin_inset ERT
6717 status collapsed
6736 status collapsed
6718
6737
6719 \begin_layout Standard
6738 \begin_layout Standard
6720
6739
6721
6740
6722 \backslash
6741 \backslash
6723 hspace*{0mm}
6742 hspace*{0mm}
6724 \end_layout
6743 \end_layout
6725
6744
6726 \end_inset
6745 \end_inset
6727
6746
6728 \InsetSpace ~
6747 \InsetSpace ~
6729 \InsetSpace ~
6748 \InsetSpace ~
6730 \InsetSpace ~
6749 \InsetSpace ~
6731 \InsetSpace ~
6750 \InsetSpace ~
6732 \InsetSpace ~
6751 \InsetSpace ~
6733 \InsetSpace ~
6752 \InsetSpace ~
6734 \InsetSpace ~
6753 \InsetSpace ~
6735 \InsetSpace ~
6754 \InsetSpace ~
6736 \InsetSpace ~
6755 \InsetSpace ~
6737 \InsetSpace ~
6756 \InsetSpace ~
6738 \InsetSpace ~
6757 \InsetSpace ~
6739 \InsetSpace ~
6758 \InsetSpace ~
6740 \InsetSpace ~
6759 \InsetSpace ~
6741 \InsetSpace ~
6760 \InsetSpace ~
6742 \InsetSpace ~
6761 \InsetSpace ~
6743 \InsetSpace ~
6762 \InsetSpace ~
6744
6763
6745 \color red
6764 \color red
6746 <1>
6765 <1>
6747 \color none
6766 \color none
6748 3
6767 3
6749 \newline
6768 \newline
6750
6769
6751 \color red
6770 \color red
6752 fperez
6771 fperez
6753 \color blue
6772 \color blue
6754 [
6773 [
6755 \color cyan
6774 \color cyan
6756 ~/ipython
6775 ~/ipython
6757 \color blue
6776 \color blue
6758 ]
6777 ]
6759 \color green
6778 \color green
6760 2>
6779 2>
6761 \color none
6780 \color none
6762 for i in (1,2,3):
6781 for i in (1,2,3):
6763 \newline
6782 \newline
6764
6783
6765 \begin_inset ERT
6784 \begin_inset ERT
6766 status collapsed
6785 status collapsed
6767
6786
6768 \begin_layout Standard
6787 \begin_layout Standard
6769
6788
6770
6789
6771 \backslash
6790 \backslash
6772 hspace*{0mm}
6791 hspace*{0mm}
6773 \end_layout
6792 \end_layout
6774
6793
6775 \end_inset
6794 \end_inset
6776
6795
6777 \InsetSpace ~
6796 \InsetSpace ~
6778 \InsetSpace ~
6797 \InsetSpace ~
6779 \InsetSpace ~
6798 \InsetSpace ~
6780 \InsetSpace ~
6799 \InsetSpace ~
6781 \InsetSpace ~
6800 \InsetSpace ~
6782 \InsetSpace ~
6801 \InsetSpace ~
6783 \InsetSpace ~
6802 \InsetSpace ~
6784 \InsetSpace ~
6803 \InsetSpace ~
6785 \InsetSpace ~
6804 \InsetSpace ~
6786 \InsetSpace ~
6805 \InsetSpace ~
6787 \InsetSpace ~
6806 \InsetSpace ~
6788 \InsetSpace ~
6807 \InsetSpace ~
6789 \InsetSpace ~
6808 \InsetSpace ~
6790 \InsetSpace ~
6809 \InsetSpace ~
6791 \InsetSpace ~
6810 \InsetSpace ~
6792
6811
6793 \color green
6812 \color green
6794 ...>
6813 ...>
6795 \color none
6814 \color none
6796 \InsetSpace ~
6815 \InsetSpace ~
6797 \InsetSpace ~
6816 \InsetSpace ~
6798 \InsetSpace ~
6817 \InsetSpace ~
6799 \InsetSpace ~
6818 \InsetSpace ~
6800 print i,
6819 print i,
6801 \newline
6820 \newline
6802
6821
6803 \begin_inset ERT
6822 \begin_inset ERT
6804 status collapsed
6823 status collapsed
6805
6824
6806 \begin_layout Standard
6825 \begin_layout Standard
6807
6826
6808
6827
6809 \backslash
6828 \backslash
6810 hspace*{0mm}
6829 hspace*{0mm}
6811 \end_layout
6830 \end_layout
6812
6831
6813 \end_inset
6832 \end_inset
6814
6833
6815 \InsetSpace ~
6834 \InsetSpace ~
6816 \InsetSpace ~
6835 \InsetSpace ~
6817 \InsetSpace ~
6836 \InsetSpace ~
6818 \InsetSpace ~
6837 \InsetSpace ~
6819 \InsetSpace ~
6838 \InsetSpace ~
6820 \InsetSpace ~
6839 \InsetSpace ~
6821 \InsetSpace ~
6840 \InsetSpace ~
6822 \InsetSpace ~
6841 \InsetSpace ~
6823 \InsetSpace ~
6842 \InsetSpace ~
6824 \InsetSpace ~
6843 \InsetSpace ~
6825 \InsetSpace ~
6844 \InsetSpace ~
6826 \InsetSpace ~
6845 \InsetSpace ~
6827 \InsetSpace ~
6846 \InsetSpace ~
6828 \InsetSpace ~
6847 \InsetSpace ~
6829 \InsetSpace ~
6848 \InsetSpace ~
6830
6849
6831 \color green
6850 \color green
6832 ...>
6851 ...>
6833 \color none
6852 \color none
6834
6853
6835 \newline
6854 \newline
6836 1 2 3
6855 1 2 3
6837 \end_layout
6856 \end_layout
6838
6857
6839 \begin_layout Standard
6858 \begin_layout Standard
6840 The following shows the usage of dynamic expression evaluation:
6859 The following shows the usage of dynamic expression evaluation:
6841 \end_layout
6860 \end_layout
6842
6861
6843 \begin_layout Subsection
6862 \begin_layout Subsection
6844 \begin_inset LatexCommand \label{sec:profiles}
6863 \begin_inset LatexCommand \label{sec:profiles}
6845
6864
6846 \end_inset
6865 \end_inset
6847
6866
6848 IPython profiles
6867 IPython profiles
6849 \end_layout
6868 \end_layout
6850
6869
6851 \begin_layout Standard
6870 \begin_layout Standard
6852 As we already mentioned, IPython supports the
6871 As we already mentioned, IPython supports the
6853 \family typewriter
6872 \family typewriter
6854 -profile
6873 -profile
6855 \family default
6874 \family default
6856 command-line option (see sec.
6875 command-line option (see sec.
6857
6876
6858 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
6877 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
6859
6878
6860 \end_inset
6879 \end_inset
6861
6880
6862 ).
6881 ).
6863 A profile is nothing more than a particular configuration file like your
6882 A profile is nothing more than a particular configuration file like your
6864 basic
6883 basic
6865 \family typewriter
6884 \family typewriter
6866 ipythonrc
6885 ipythonrc
6867 \family default
6886 \family default
6868 one, but with particular customizations for a specific purpose.
6887 one, but with particular customizations for a specific purpose.
6869 When you start IPython with '
6888 When you start IPython with '
6870 \family typewriter
6889 \family typewriter
6871 ipython -profile <name>
6890 ipython -profile <name>
6872 \family default
6891 \family default
6873 ', it assumes that in your
6892 ', it assumes that in your
6874 \family typewriter
6893 \family typewriter
6875 IPYTHONDIR
6894 IPYTHONDIR
6876 \family default
6895 \family default
6877 there is a file called
6896 there is a file called
6878 \family typewriter
6897 \family typewriter
6879 ipythonrc-<name>
6898 ipythonrc-<name>
6880 \family default
6899 \family default
6881 , and loads it instead of the normal
6900 , and loads it instead of the normal
6882 \family typewriter
6901 \family typewriter
6883 ipythonrc
6902 ipythonrc
6884 \family default
6903 \family default
6885 .
6904 .
6886 \end_layout
6905 \end_layout
6887
6906
6888 \begin_layout Standard
6907 \begin_layout Standard
6889 This system allows you to maintain multiple configurations which load modules,
6908 This system allows you to maintain multiple configurations which load modules,
6890 set options, define functions, etc.
6909 set options, define functions, etc.
6891 suitable for different tasks and activate them in a very simple manner.
6910 suitable for different tasks and activate them in a very simple manner.
6892 In order to avoid having to repeat all of your basic options (common things
6911 In order to avoid having to repeat all of your basic options (common things
6893 that don't change such as your color preferences, for example), any profile
6912 that don't change such as your color preferences, for example), any profile
6894 can include another configuration file.
6913 can include another configuration file.
6895 The most common way to use profiles is then to have each one include your
6914 The most common way to use profiles is then to have each one include your
6896 basic
6915 basic
6897 \family typewriter
6916 \family typewriter
6898 ipythonrc
6917 ipythonrc
6899 \family default
6918 \family default
6900 file as a starting point, and then add further customizations.
6919 file as a starting point, and then add further customizations.
6901 \end_layout
6920 \end_layout
6902
6921
6903 \begin_layout Standard
6922 \begin_layout Standard
6904 In sections
6923 In sections
6905 \begin_inset LatexCommand \ref{sec:syntax-extensions}
6924 \begin_inset LatexCommand \ref{sec:syntax-extensions}
6906
6925
6907 \end_inset
6926 \end_inset
6908
6927
6909 and
6928 and
6910 \begin_inset LatexCommand \ref{sec:Gnuplot}
6929 \begin_inset LatexCommand \ref{sec:Gnuplot}
6911
6930
6912 \end_inset
6931 \end_inset
6913
6932
6914 we discuss some particular profiles which come as part of the standard
6933 we discuss some particular profiles which come as part of the standard
6915 IPython distribution.
6934 IPython distribution.
6916 You may also look in your
6935 You may also look in your
6917 \family typewriter
6936 \family typewriter
6918 IPYTHONDIR
6937 IPYTHONDIR
6919 \family default
6938 \family default
6920 directory, any file whose name begins with
6939 directory, any file whose name begins with
6921 \family typewriter
6940 \family typewriter
6922 ipythonrc-
6941 ipythonrc-
6923 \family default
6942 \family default
6924 is a profile.
6943 is a profile.
6925 You can use those as examples for further customizations to suit your own
6944 You can use those as examples for further customizations to suit your own
6926 needs.
6945 needs.
6927 \end_layout
6946 \end_layout
6928
6947
6929 \begin_layout Section
6948 \begin_layout Section
6930 \begin_inset OptArg
6949 \begin_inset OptArg
6931 status open
6950 status open
6932
6951
6933 \begin_layout Standard
6952 \begin_layout Standard
6934 IPython as default...
6953 IPython as default...
6935 \end_layout
6954 \end_layout
6936
6955
6937 \end_inset
6956 \end_inset
6938
6957
6939 IPython as your default Python environment
6958 IPython as your default Python environment
6940 \end_layout
6959 \end_layout
6941
6960
6942 \begin_layout Standard
6961 \begin_layout Standard
6943 Python honors the environment variable
6962 Python honors the environment variable
6944 \family typewriter
6963 \family typewriter
6945 PYTHONSTARTUP
6964 PYTHONSTARTUP
6946 \family default
6965 \family default
6947 and will execute at startup the file referenced by this variable.
6966 and will execute at startup the file referenced by this variable.
6948 If you put at the end of this file the following two lines of code:
6967 If you put at the end of this file the following two lines of code:
6949 \end_layout
6968 \end_layout
6950
6969
6951 \begin_layout Standard
6970 \begin_layout Standard
6952
6971
6953 \family typewriter
6972 \family typewriter
6954 import IPython
6973 import IPython
6955 \newline
6974 \newline
6956 IPython.Shell.IPShell().mainloop(sys_exit=1)
6975 IPython.Shell.IPShell().mainloop(sys_exit=1)
6957 \end_layout
6976 \end_layout
6958
6977
6959 \begin_layout Standard
6978 \begin_layout Standard
6960 then IPython will be your working environment anytime you start Python.
6979 then IPython will be your working environment anytime you start Python.
6961 The
6980 The
6962 \family typewriter
6981 \family typewriter
6963 sys_exit=1
6982 sys_exit=1
6964 \family default
6983 \family default
6965 is needed to have IPython issue a call to
6984 is needed to have IPython issue a call to
6966 \family typewriter
6985 \family typewriter
6967 sys.exit()
6986 sys.exit()
6968 \family default
6987 \family default
6969 when it finishes, otherwise you'll be back at the normal Python '
6988 when it finishes, otherwise you'll be back at the normal Python '
6970 \family typewriter
6989 \family typewriter
6971 >>>
6990 >>>
6972 \family default
6991 \family default
6973 ' prompt
6992 ' prompt
6974 \begin_inset Foot
6993 \begin_inset Foot
6975 status collapsed
6994 status collapsed
6976
6995
6977 \begin_layout Standard
6996 \begin_layout Standard
6978 Based on an idea by Holger Krekel.
6997 Based on an idea by Holger Krekel.
6979 \end_layout
6998 \end_layout
6980
6999
6981 \end_inset
7000 \end_inset
6982
7001
6983 .
7002 .
6984 \end_layout
7003 \end_layout
6985
7004
6986 \begin_layout Standard
7005 \begin_layout Standard
6987 This is probably useful to developers who manage multiple Python versions
7006 This is probably useful to developers who manage multiple Python versions
6988 and don't want to have correspondingly multiple IPython versions.
7007 and don't want to have correspondingly multiple IPython versions.
6989 Note that in this mode, there is no way to pass IPython any command-line
7008 Note that in this mode, there is no way to pass IPython any command-line
6990 options, as those are trapped first by Python itself.
7009 options, as those are trapped first by Python itself.
6991 \end_layout
7010 \end_layout
6992
7011
6993 \begin_layout Section
7012 \begin_layout Section
6994 \begin_inset LatexCommand \label{sec:embed}
7013 \begin_inset LatexCommand \label{sec:embed}
6995
7014
6996 \end_inset
7015 \end_inset
6997
7016
6998 Embedding IPython
7017 Embedding IPython
6999 \end_layout
7018 \end_layout
7000
7019
7001 \begin_layout Standard
7020 \begin_layout Standard
7002 It is possible to start an IPython instance
7021 It is possible to start an IPython instance
7003 \emph on
7022 \emph on
7004 inside
7023 inside
7005 \emph default
7024 \emph default
7006 your own Python programs.
7025 your own Python programs.
7007 This allows you to evaluate dynamically the state of your code, operate
7026 This allows you to evaluate dynamically the state of your code, operate
7008 with your variables, analyze them, etc.
7027 with your variables, analyze them, etc.
7009 Note however that any changes you make to values while in the shell do
7028 Note however that any changes you make to values while in the shell do
7010
7029
7011 \emph on
7030 \emph on
7012 not
7031 not
7013 \emph default
7032 \emph default
7014 propagate back to the running code, so it is safe to modify your values
7033 propagate back to the running code, so it is safe to modify your values
7015 because you won't break your code in bizarre ways by doing so.
7034 because you won't break your code in bizarre ways by doing so.
7016 \end_layout
7035 \end_layout
7017
7036
7018 \begin_layout Standard
7037 \begin_layout Standard
7019 This feature allows you to easily have a fully functional python environment
7038 This feature allows you to easily have a fully functional python environment
7020 for doing object introspection anywhere in your code with a simple function
7039 for doing object introspection anywhere in your code with a simple function
7021 call.
7040 call.
7022 In some cases a simple print statement is enough, but if you need to do
7041 In some cases a simple print statement is enough, but if you need to do
7023 more detailed analysis of a code fragment this feature can be very valuable.
7042 more detailed analysis of a code fragment this feature can be very valuable.
7024 \end_layout
7043 \end_layout
7025
7044
7026 \begin_layout Standard
7045 \begin_layout Standard
7027 It can also be useful in scientific computing situations where it is common
7046 It can also be useful in scientific computing situations where it is common
7028 to need to do some automatic, computationally intensive part and then stop
7047 to need to do some automatic, computationally intensive part and then stop
7029 to look at data, plots, etc
7048 to look at data, plots, etc
7030 \begin_inset Foot
7049 \begin_inset Foot
7031 status collapsed
7050 status collapsed
7032
7051
7033 \begin_layout Standard
7052 \begin_layout Standard
7034 This functionality was inspired by IDL's combination of the
7053 This functionality was inspired by IDL's combination of the
7035 \family typewriter
7054 \family typewriter
7036 stop
7055 stop
7037 \family default
7056 \family default
7038 keyword and the
7057 keyword and the
7039 \family typewriter
7058 \family typewriter
7040 .continue
7059 .continue
7041 \family default
7060 \family default
7042 executive command, which I have found very useful in the past, and by a
7061 executive command, which I have found very useful in the past, and by a
7043 posting on comp.lang.python by cmkl <cmkleffner-AT-gmx.de> on Dec.
7062 posting on comp.lang.python by cmkl <cmkleffner-AT-gmx.de> on Dec.
7044 06/01 concerning similar uses of pyrepl.
7063 06/01 concerning similar uses of pyrepl.
7045 \end_layout
7064 \end_layout
7046
7065
7047 \end_inset
7066 \end_inset
7048
7067
7049 .
7068 .
7050 Opening an IPython instance will give you full access to your data and
7069 Opening an IPython instance will give you full access to your data and
7051 functions, and you can resume program execution once you are done with
7070 functions, and you can resume program execution once you are done with
7052 the interactive part (perhaps to stop again later, as many times as needed).
7071 the interactive part (perhaps to stop again later, as many times as needed).
7053 \end_layout
7072 \end_layout
7054
7073
7055 \begin_layout Standard
7074 \begin_layout Standard
7056 The following code snippet is the bare minimum you need to include in your
7075 The following code snippet is the bare minimum you need to include in your
7057 Python programs for this to work (detailed examples follow later):
7076 Python programs for this to work (detailed examples follow later):
7058 \end_layout
7077 \end_layout
7059
7078
7060 \begin_layout LyX-Code
7079 \begin_layout LyX-Code
7061 from IPython.Shell import IPShellEmbed
7080 from IPython.Shell import IPShellEmbed
7062 \end_layout
7081 \end_layout
7063
7082
7064 \begin_layout LyX-Code
7083 \begin_layout LyX-Code
7065 ipshell = IPShellEmbed()
7084 ipshell = IPShellEmbed()
7066 \end_layout
7085 \end_layout
7067
7086
7068 \begin_layout LyX-Code
7087 \begin_layout LyX-Code
7069 ipshell() # this call anywhere in your program will start IPython
7088 ipshell() # this call anywhere in your program will start IPython
7070 \end_layout
7089 \end_layout
7071
7090
7072 \begin_layout Standard
7091 \begin_layout Standard
7073 You can run embedded instances even in code which is itself being run at
7092 You can run embedded instances even in code which is itself being run at
7074 the IPython interactive prompt with '
7093 the IPython interactive prompt with '
7075 \family typewriter
7094 \family typewriter
7076 %run\InsetSpace ~
7095 %run\InsetSpace ~
7077 <filename>
7096 <filename>
7078 \family default
7097 \family default
7079 '.
7098 '.
7080 Since it's easy to get lost as to where you are (in your top-level IPython
7099 Since it's easy to get lost as to where you are (in your top-level IPython
7081 or in your embedded one), it's a good idea in such cases to set the in/out
7100 or in your embedded one), it's a good idea in such cases to set the in/out
7082 prompts to something different for the embedded instances.
7101 prompts to something different for the embedded instances.
7083 The code examples below illustrate this.
7102 The code examples below illustrate this.
7084 \end_layout
7103 \end_layout
7085
7104
7086 \begin_layout Standard
7105 \begin_layout Standard
7087 You can also have multiple IPython instances in your program and open them
7106 You can also have multiple IPython instances in your program and open them
7088 separately, for example with different options for data presentation.
7107 separately, for example with different options for data presentation.
7089 If you close and open the same instance multiple times, its prompt counters
7108 If you close and open the same instance multiple times, its prompt counters
7090 simply continue from each execution to the next.
7109 simply continue from each execution to the next.
7091 \end_layout
7110 \end_layout
7092
7111
7093 \begin_layout Standard
7112 \begin_layout Standard
7094 Please look at the docstrings in the
7113 Please look at the docstrings in the
7095 \family typewriter
7114 \family typewriter
7096 Shell.py
7115 Shell.py
7097 \family default
7116 \family default
7098 module for more details on the use of this system.
7117 module for more details on the use of this system.
7099 \end_layout
7118 \end_layout
7100
7119
7101 \begin_layout Standard
7120 \begin_layout Standard
7102 The following sample file illustrating how to use the embedding functionality
7121 The following sample file illustrating how to use the embedding functionality
7103 is provided in the examples directory as
7122 is provided in the examples directory as
7104 \family typewriter
7123 \family typewriter
7105 example-embed.py
7124 example-embed.py
7106 \family default
7125 \family default
7107 .
7126 .
7108 It should be fairly self-explanatory:
7127 It should be fairly self-explanatory:
7109 \end_layout
7128 \end_layout
7110
7129
7111 \begin_layout Standard
7130 \begin_layout Standard
7112 \begin_inset ERT
7131 \begin_inset ERT
7113 status open
7132 status open
7114
7133
7115 \begin_layout Standard
7134 \begin_layout Standard
7116
7135
7117
7136
7118 \backslash
7137 \backslash
7119 codelist{examples/example-embed.py}
7138 codelist{examples/example-embed.py}
7120 \end_layout
7139 \end_layout
7121
7140
7122 \end_inset
7141 \end_inset
7123
7142
7124
7143
7125 \end_layout
7144 \end_layout
7126
7145
7127 \begin_layout Standard
7146 \begin_layout Standard
7128 Once you understand how the system functions, you can use the following
7147 Once you understand how the system functions, you can use the following
7129 code fragments in your programs which are ready for cut and paste:
7148 code fragments in your programs which are ready for cut and paste:
7130 \end_layout
7149 \end_layout
7131
7150
7132 \begin_layout Standard
7151 \begin_layout Standard
7133 \begin_inset ERT
7152 \begin_inset ERT
7134 status open
7153 status open
7135
7154
7136 \begin_layout Standard
7155 \begin_layout Standard
7137
7156
7138
7157
7139 \backslash
7158 \backslash
7140 codelist{examples/example-embed-short.py}
7159 codelist{examples/example-embed-short.py}
7141 \end_layout
7160 \end_layout
7142
7161
7143 \end_inset
7162 \end_inset
7144
7163
7145
7164
7146 \end_layout
7165 \end_layout
7147
7166
7148 \begin_layout Section
7167 \begin_layout Section
7149 \begin_inset LatexCommand \label{sec:using-pdb}
7168 \begin_inset LatexCommand \label{sec:using-pdb}
7150
7169
7151 \end_inset
7170 \end_inset
7152
7171
7153 Using the Python debugger (
7172 Using the Python debugger (
7154 \family typewriter
7173 \family typewriter
7155 pdb
7174 pdb
7156 \family default
7175 \family default
7157 )
7176 )
7158 \end_layout
7177 \end_layout
7159
7178
7160 \begin_layout Subsection
7179 \begin_layout Subsection
7161 Running entire programs via
7180 Running entire programs via
7162 \family typewriter
7181 \family typewriter
7163 pdb
7182 pdb
7164 \end_layout
7183 \end_layout
7165
7184
7166 \begin_layout Standard
7185 \begin_layout Standard
7167
7186
7168 \family typewriter
7187 \family typewriter
7169 pdb
7188 pdb
7170 \family default
7189 \family default
7171 , the Python debugger, is a powerful interactive debugger which allows you
7190 , the Python debugger, is a powerful interactive debugger which allows you
7172 to step through code, set breakpoints, watch variables, etc.
7191 to step through code, set breakpoints, watch variables, etc.
7173 IPython makes it very easy to start any script under the control of
7192 IPython makes it very easy to start any script under the control of
7174 \family typewriter
7193 \family typewriter
7175 pdb
7194 pdb
7176 \family default
7195 \family default
7177 , regardless of whether you have wrapped it into a
7196 , regardless of whether you have wrapped it into a
7178 \family typewriter
7197 \family typewriter
7179 `main()'
7198 `main()'
7180 \family default
7199 \family default
7181 function or not.
7200 function or not.
7182 For this, simply type
7201 For this, simply type
7183 \family typewriter
7202 \family typewriter
7184 `%run -d myscript'
7203 `%run -d myscript'
7185 \family default
7204 \family default
7186 at an IPython prompt.
7205 at an IPython prompt.
7187 See the
7206 See the
7188 \family typewriter
7207 \family typewriter
7189 %run
7208 %run
7190 \family default
7209 \family default
7191 command's documentation (via
7210 command's documentation (via
7192 \family typewriter
7211 \family typewriter
7193 `%run?'
7212 `%run?'
7194 \family default
7213 \family default
7195 or in Sec.\InsetSpace ~
7214 or in Sec.\InsetSpace ~
7196
7215
7197 \begin_inset LatexCommand \ref{sec:magic}
7216 \begin_inset LatexCommand \ref{sec:magic}
7198
7217
7199 \end_inset
7218 \end_inset
7200
7219
7201 ) for more details, including how to control where
7220 ) for more details, including how to control where
7202 \family typewriter
7221 \family typewriter
7203 pdb
7222 pdb
7204 \family default
7223 \family default
7205 will stop execution first.
7224 will stop execution first.
7206 \end_layout
7225 \end_layout
7207
7226
7208 \begin_layout Standard
7227 \begin_layout Standard
7209 For more information on the use of the
7228 For more information on the use of the
7210 \family typewriter
7229 \family typewriter
7211 pdb
7230 pdb
7212 \family default
7231 \family default
7213 debugger, read the included
7232 debugger, read the included
7214 \family typewriter
7233 \family typewriter
7215 pdb.doc
7234 pdb.doc
7216 \family default
7235 \family default
7217 file (part of the standard Python distribution).
7236 file (part of the standard Python distribution).
7218 On a stock Linux system it is located at
7237 On a stock Linux system it is located at
7219 \family typewriter
7238 \family typewriter
7220 /usr/lib/python2.3/pdb.doc
7239 /usr/lib/python2.3/pdb.doc
7221 \family default
7240 \family default
7222 , but the easiest way to read it is by using the
7241 , but the easiest way to read it is by using the
7223 \family typewriter
7242 \family typewriter
7224 help()
7243 help()
7225 \family default
7244 \family default
7226 function of the
7245 function of the
7227 \family typewriter
7246 \family typewriter
7228 pdb
7247 pdb
7229 \family default
7248 \family default
7230 module as follows (in an IPython prompt):
7249 module as follows (in an IPython prompt):
7231 \end_layout
7250 \end_layout
7232
7251
7233 \begin_layout Standard
7252 \begin_layout Standard
7234
7253
7235 \family typewriter
7254 \family typewriter
7236 In [1]: import pdb
7255 In [1]: import pdb
7237 \newline
7256 \newline
7238 In [2]: pdb.help()
7257 In [2]: pdb.help()
7239 \end_layout
7258 \end_layout
7240
7259
7241 \begin_layout Standard
7260 \begin_layout Standard
7242 This will load the
7261 This will load the
7243 \family typewriter
7262 \family typewriter
7244 pdb.doc
7263 pdb.doc
7245 \family default
7264 \family default
7246 document in a file viewer for you automatically.
7265 document in a file viewer for you automatically.
7247 \end_layout
7266 \end_layout
7248
7267
7249 \begin_layout Subsection
7268 \begin_layout Subsection
7250 Automatic invocation of
7269 Automatic invocation of
7251 \family typewriter
7270 \family typewriter
7252 pdb
7271 pdb
7253 \family default
7272 \family default
7254 on exceptions
7273 on exceptions
7255 \end_layout
7274 \end_layout
7256
7275
7257 \begin_layout Standard
7276 \begin_layout Standard
7258 IPython, if started with the
7277 IPython, if started with the
7259 \family typewriter
7278 \family typewriter
7260 -pdb
7279 -pdb
7261 \family default
7280 \family default
7262 option (or if the option is set in your rc file) can call the Python
7281 option (or if the option is set in your rc file) can call the Python
7263 \family typewriter
7282 \family typewriter
7264 pdb
7283 pdb
7265 \family default
7284 \family default
7266 debugger every time your code triggers an uncaught exception
7285 debugger every time your code triggers an uncaught exception
7267 \begin_inset Foot
7286 \begin_inset Foot
7268 status collapsed
7287 status collapsed
7269
7288
7270 \begin_layout Standard
7289 \begin_layout Standard
7271 Many thanks to Christopher Hart for the request which prompted adding this
7290 Many thanks to Christopher Hart for the request which prompted adding this
7272 feature to IPython.
7291 feature to IPython.
7273 \end_layout
7292 \end_layout
7274
7293
7275 \end_inset
7294 \end_inset
7276
7295
7277 .
7296 .
7278 This feature can also be toggled at any time with the
7297 This feature can also be toggled at any time with the
7279 \family typewriter
7298 \family typewriter
7280 %pdb
7299 %pdb
7281 \family default
7300 \family default
7282 magic command.
7301 magic command.
7283 This can be extremely useful in order to find the origin of subtle bugs,
7302 This can be extremely useful in order to find the origin of subtle bugs,
7284 because
7303 because
7285 \family typewriter
7304 \family typewriter
7286 pdb
7305 pdb
7287 \family default
7306 \family default
7288 opens up at the point in your code which triggered the exception, and while
7307 opens up at the point in your code which triggered the exception, and while
7289 your program is at this point `dead', all the data is still available and
7308 your program is at this point `dead', all the data is still available and
7290 you can walk up and down the stack frame and understand the origin of the
7309 you can walk up and down the stack frame and understand the origin of the
7291 problem.
7310 problem.
7292 \end_layout
7311 \end_layout
7293
7312
7294 \begin_layout Standard
7313 \begin_layout Standard
7295 Furthermore, you can use these debugging facilities both with the embedded
7314 Furthermore, you can use these debugging facilities both with the embedded
7296 IPython mode and without IPython at all.
7315 IPython mode and without IPython at all.
7297 For an embedded shell (see sec.
7316 For an embedded shell (see sec.
7298
7317
7299 \begin_inset LatexCommand \ref{sec:embed}
7318 \begin_inset LatexCommand \ref{sec:embed}
7300
7319
7301 \end_inset
7320 \end_inset
7302
7321
7303 ), simply call the constructor with
7322 ), simply call the constructor with
7304 \family typewriter
7323 \family typewriter
7305 `-pdb'
7324 `-pdb'
7306 \family default
7325 \family default
7307 in the argument string and automatically
7326 in the argument string and automatically
7308 \family typewriter
7327 \family typewriter
7309 pdb
7328 pdb
7310 \family default
7329 \family default
7311 will be called if an uncaught exception is triggered by your code.
7330 will be called if an uncaught exception is triggered by your code.
7312
7331
7313 \end_layout
7332 \end_layout
7314
7333
7315 \begin_layout Standard
7334 \begin_layout Standard
7316 For stand-alone use of the feature in your programs which do not use IPython
7335 For stand-alone use of the feature in your programs which do not use IPython
7317 at all, put the following lines toward the top of your `main' routine:
7336 at all, put the following lines toward the top of your `main' routine:
7318 \end_layout
7337 \end_layout
7319
7338
7320 \begin_layout Standard
7339 \begin_layout Standard
7321 \align left
7340 \align left
7322
7341
7323 \family typewriter
7342 \family typewriter
7324 import sys,IPython.ultraTB
7343 import sys,IPython.ultraTB
7325 \newline
7344 \newline
7326 sys.excepthook = IPython.ultraTB.FormattedTB(mode=`Verbos
7345 sys.excepthook = IPython.ultraTB.FormattedTB(mode=`Verbos
7327 e', color_scheme=`Linux', call_pdb=1)
7346 e', color_scheme=`Linux', call_pdb=1)
7328 \end_layout
7347 \end_layout
7329
7348
7330 \begin_layout Standard
7349 \begin_layout Standard
7331 The
7350 The
7332 \family typewriter
7351 \family typewriter
7333 mode
7352 mode
7334 \family default
7353 \family default
7335 keyword can be either
7354 keyword can be either
7336 \family typewriter
7355 \family typewriter
7337 `Verbose'
7356 `Verbose'
7338 \family default
7357 \family default
7339 or
7358 or
7340 \family typewriter
7359 \family typewriter
7341 `Plain'
7360 `Plain'
7342 \family default
7361 \family default
7343 , giving either very detailed or normal tracebacks respectively.
7362 , giving either very detailed or normal tracebacks respectively.
7344 The
7363 The
7345 \family typewriter
7364 \family typewriter
7346 color_scheme
7365 color_scheme
7347 \family default
7366 \family default
7348 keyword can be one of
7367 keyword can be one of
7349 \family typewriter
7368 \family typewriter
7350 `NoColor'
7369 `NoColor'
7351 \family default
7370 \family default
7352 ,
7371 ,
7353 \family typewriter
7372 \family typewriter
7354 `Linux'
7373 `Linux'
7355 \family default
7374 \family default
7356 (default) or
7375 (default) or
7357 \family typewriter
7376 \family typewriter
7358 `LightBG'
7377 `LightBG'
7359 \family default
7378 \family default
7360 .
7379 .
7361 These are the same options which can be set in IPython with
7380 These are the same options which can be set in IPython with
7362 \family typewriter
7381 \family typewriter
7363 -colors
7382 -colors
7364 \family default
7383 \family default
7365 and
7384 and
7366 \family typewriter
7385 \family typewriter
7367 -xmode
7386 -xmode
7368 \family default
7387 \family default
7369 .
7388 .
7370 \end_layout
7389 \end_layout
7371
7390
7372 \begin_layout Standard
7391 \begin_layout Standard
7373 This will give any of your programs detailed, colored tracebacks with automatic
7392 This will give any of your programs detailed, colored tracebacks with automatic
7374 invocation of
7393 invocation of
7375 \family typewriter
7394 \family typewriter
7376 pdb
7395 pdb
7377 \family default
7396 \family default
7378 .
7397 .
7379 \end_layout
7398 \end_layout
7380
7399
7381 \begin_layout Section
7400 \begin_layout Section
7382 \begin_inset LatexCommand \label{sec:syntax-extensions}
7401 \begin_inset LatexCommand \label{sec:syntax-extensions}
7383
7402
7384 \end_inset
7403 \end_inset
7385
7404
7386 Extensions for syntax processing
7405 Extensions for syntax processing
7387 \end_layout
7406 \end_layout
7388
7407
7389 \begin_layout Standard
7408 \begin_layout Standard
7390 This isn't for the faint of heart, because the potential for breaking things
7409 This isn't for the faint of heart, because the potential for breaking things
7391 is quite high.
7410 is quite high.
7392 But it can be a very powerful and useful feature.
7411 But it can be a very powerful and useful feature.
7393 In a nutshell, you can redefine the way IPython processes the user input
7412 In a nutshell, you can redefine the way IPython processes the user input
7394 line to accept new, special extensions to the syntax without needing to
7413 line to accept new, special extensions to the syntax without needing to
7395 change any of IPython's own code.
7414 change any of IPython's own code.
7396 \end_layout
7415 \end_layout
7397
7416
7398 \begin_layout Standard
7417 \begin_layout Standard
7399 In the
7418 In the
7400 \family typewriter
7419 \family typewriter
7401 IPython/Extensions
7420 IPython/Extensions
7402 \family default
7421 \family default
7403 directory you will find some examples supplied, which we will briefly describe
7422 directory you will find some examples supplied, which we will briefly describe
7404 now.
7423 now.
7405 These can be used `as is' (and both provide very useful functionality),
7424 These can be used `as is' (and both provide very useful functionality),
7406 or you can use them as a starting point for writing your own extensions.
7425 or you can use them as a starting point for writing your own extensions.
7407 \end_layout
7426 \end_layout
7408
7427
7409 \begin_layout Subsection
7428 \begin_layout Subsection
7410 Pasting of code starting with
7429 Pasting of code starting with
7411 \family typewriter
7430 \family typewriter
7412 `>>>
7431 `>>>
7413 \family default
7432 \family default
7414 ' or
7433 ' or
7415 \family typewriter
7434 \family typewriter
7416 `...
7435 `...
7417
7436
7418 \family default
7437 \family default
7419 '
7438 '
7420 \end_layout
7439 \end_layout
7421
7440
7422 \begin_layout Standard
7441 \begin_layout Standard
7423 In the python tutorial it is common to find code examples which have been
7442 In the python tutorial it is common to find code examples which have been
7424 taken from real python sessions.
7443 taken from real python sessions.
7425 The problem with those is that all the lines begin with either
7444 The problem with those is that all the lines begin with either
7426 \family typewriter
7445 \family typewriter
7427 `>>>
7446 `>>>
7428 \family default
7447 \family default
7429 ' or
7448 ' or
7430 \family typewriter
7449 \family typewriter
7431 `...
7450 `...
7432
7451
7433 \family default
7452 \family default
7434 ', which makes it impossible to paste them all at once.
7453 ', which makes it impossible to paste them all at once.
7435 One must instead do a line by line manual copying, carefully removing the
7454 One must instead do a line by line manual copying, carefully removing the
7436 leading extraneous characters.
7455 leading extraneous characters.
7437 \end_layout
7456 \end_layout
7438
7457
7439 \begin_layout Standard
7458 \begin_layout Standard
7440 This extension identifies those starting characters and removes them from
7459 This extension identifies those starting characters and removes them from
7441 the input automatically, so that one can paste multi-line examples directly
7460 the input automatically, so that one can paste multi-line examples directly
7442 into IPython, saving a lot of time.
7461 into IPython, saving a lot of time.
7443 Please look at the file
7462 Please look at the file
7444 \family typewriter
7463 \family typewriter
7445 InterpreterPasteInput.py
7464 InterpreterPasteInput.py
7446 \family default
7465 \family default
7447 in the
7466 in the
7448 \family typewriter
7467 \family typewriter
7449 IPython/Extensions
7468 IPython/Extensions
7450 \family default
7469 \family default
7451 directory for details on how this is done.
7470 directory for details on how this is done.
7452 \end_layout
7471 \end_layout
7453
7472
7454 \begin_layout Standard
7473 \begin_layout Standard
7455 IPython comes with a special profile enabling this feature, called
7474 IPython comes with a special profile enabling this feature, called
7456 \family typewriter
7475 \family typewriter
7457 tutorial
7476 tutorial
7458 \family default
7477 \family default
7459 \emph on
7478 \emph on
7460 .
7479 .
7461
7480
7462 \emph default
7481 \emph default
7463 Simply start IPython via
7482 Simply start IPython via
7464 \family typewriter
7483 \family typewriter
7465 `ipython\InsetSpace ~
7484 `ipython\InsetSpace ~
7466 -p\InsetSpace ~
7485 -p\InsetSpace ~
7467 tutorial'
7486 tutorial'
7468 \family default
7487 \family default
7469 and the feature will be available.
7488 and the feature will be available.
7470 In a normal IPython session you can activate the feature by importing the
7489 In a normal IPython session you can activate the feature by importing the
7471 corresponding module with:
7490 corresponding module with:
7472 \newline
7491 \newline
7473
7492
7474 \family typewriter
7493 \family typewriter
7475 In [1]: import IPython.Extensions.InterpreterPasteInput
7494 In [1]: import IPython.Extensions.InterpreterPasteInput
7476 \end_layout
7495 \end_layout
7477
7496
7478 \begin_layout Standard
7497 \begin_layout Standard
7479 The following is a 'screenshot' of how things work when this extension is
7498 The following is a 'screenshot' of how things work when this extension is
7480 on, copying an example from the standard tutorial:
7499 on, copying an example from the standard tutorial:
7481 \end_layout
7500 \end_layout
7482
7501
7483 \begin_layout Standard
7502 \begin_layout Standard
7484
7503
7485 \family typewriter
7504 \family typewriter
7486 IPython profile: tutorial
7505 IPython profile: tutorial
7487 \newline
7506 \newline
7488 \InsetSpace ~
7507 \InsetSpace ~
7489
7508
7490 \newline
7509 \newline
7491 *** Pasting of code with ">>>" or "..." has been enabled.
7510 *** Pasting of code with ">>>" or "..." has been enabled.
7492 \newline
7511 \newline
7493 \InsetSpace ~
7512 \InsetSpace ~
7494
7513
7495 \newline
7514 \newline
7496 In
7515 In
7497 [1]: >>> def fib2(n): # return Fibonacci series up to n
7516 [1]: >>> def fib2(n): # return Fibonacci series up to n
7498 \newline
7517 \newline
7499
7518
7500 \begin_inset ERT
7519 \begin_inset ERT
7501 status collapsed
7520 status collapsed
7502
7521
7503 \begin_layout Standard
7522 \begin_layout Standard
7504
7523
7505
7524
7506 \backslash
7525 \backslash
7507 hspace*{0mm}
7526 hspace*{0mm}
7508 \end_layout
7527 \end_layout
7509
7528
7510 \end_inset
7529 \end_inset
7511
7530
7512 \InsetSpace ~
7531 \InsetSpace ~
7513 \InsetSpace ~
7532 \InsetSpace ~
7514 ...: ...\InsetSpace ~
7533 ...: ...\InsetSpace ~
7515 \InsetSpace ~
7534 \InsetSpace ~
7516 \InsetSpace ~
7535 \InsetSpace ~
7517 \InsetSpace ~
7536 \InsetSpace ~
7518 """Return a list containing the Fibonacci series up to n."""
7537 """Return a list containing the Fibonacci series up to n."""
7519 \newline
7538 \newline
7520
7539
7521 \begin_inset ERT
7540 \begin_inset ERT
7522 status collapsed
7541 status collapsed
7523
7542
7524 \begin_layout Standard
7543 \begin_layout Standard
7525
7544
7526
7545
7527 \backslash
7546 \backslash
7528 hspace*{0mm}
7547 hspace*{0mm}
7529 \end_layout
7548 \end_layout
7530
7549
7531 \end_inset
7550 \end_inset
7532
7551
7533 \InsetSpace ~
7552 \InsetSpace ~
7534 \InsetSpace ~
7553 \InsetSpace ~
7535 ...: ...\InsetSpace ~
7554 ...: ...\InsetSpace ~
7536 \InsetSpace ~
7555 \InsetSpace ~
7537 \InsetSpace ~
7556 \InsetSpace ~
7538 \InsetSpace ~
7557 \InsetSpace ~
7539 result = []
7558 result = []
7540 \newline
7559 \newline
7541
7560
7542 \begin_inset ERT
7561 \begin_inset ERT
7543 status collapsed
7562 status collapsed
7544
7563
7545 \begin_layout Standard
7564 \begin_layout Standard
7546
7565
7547
7566
7548 \backslash
7567 \backslash
7549 hspace*{0mm}
7568 hspace*{0mm}
7550 \end_layout
7569 \end_layout
7551
7570
7552 \end_inset
7571 \end_inset
7553
7572
7554 \InsetSpace ~
7573 \InsetSpace ~
7555 \InsetSpace ~
7574 \InsetSpace ~
7556 ...: ...\InsetSpace ~
7575 ...: ...\InsetSpace ~
7557 \InsetSpace ~
7576 \InsetSpace ~
7558 \InsetSpace ~
7577 \InsetSpace ~
7559 \InsetSpace ~
7578 \InsetSpace ~
7560 a, b = 0, 1
7579 a, b = 0, 1
7561 \newline
7580 \newline
7562
7581
7563 \begin_inset ERT
7582 \begin_inset ERT
7564 status collapsed
7583 status collapsed
7565
7584
7566 \begin_layout Standard
7585 \begin_layout Standard
7567
7586
7568
7587
7569 \backslash
7588 \backslash
7570 hspace*{0mm}
7589 hspace*{0mm}
7571 \end_layout
7590 \end_layout
7572
7591
7573 \end_inset
7592 \end_inset
7574
7593
7575 \InsetSpace ~
7594 \InsetSpace ~
7576 \InsetSpace ~
7595 \InsetSpace ~
7577 ...: ...\InsetSpace ~
7596 ...: ...\InsetSpace ~
7578 \InsetSpace ~
7597 \InsetSpace ~
7579 \InsetSpace ~
7598 \InsetSpace ~
7580 \InsetSpace ~
7599 \InsetSpace ~
7581 while b < n:
7600 while b < n:
7582 \newline
7601 \newline
7583
7602
7584 \begin_inset ERT
7603 \begin_inset ERT
7585 status collapsed
7604 status collapsed
7586
7605
7587 \begin_layout Standard
7606 \begin_layout Standard
7588
7607
7589
7608
7590 \backslash
7609 \backslash
7591 hspace*{0mm}
7610 hspace*{0mm}
7592 \end_layout
7611 \end_layout
7593
7612
7594 \end_inset
7613 \end_inset
7595
7614
7596 \InsetSpace ~
7615 \InsetSpace ~
7597 \InsetSpace ~
7616 \InsetSpace ~
7598 ...: ...\InsetSpace ~
7617 ...: ...\InsetSpace ~
7599 \InsetSpace ~
7618 \InsetSpace ~
7600 \InsetSpace ~
7619 \InsetSpace ~
7601 \InsetSpace ~
7620 \InsetSpace ~
7602 \InsetSpace ~
7621 \InsetSpace ~
7603 \InsetSpace ~
7622 \InsetSpace ~
7604 \InsetSpace ~
7623 \InsetSpace ~
7605 \InsetSpace ~
7624 \InsetSpace ~
7606 result.append(b)\InsetSpace ~
7625 result.append(b)\InsetSpace ~
7607 \InsetSpace ~
7626 \InsetSpace ~
7608 \InsetSpace ~
7627 \InsetSpace ~
7609 # see below
7628 # see below
7610 \newline
7629 \newline
7611
7630
7612 \begin_inset ERT
7631 \begin_inset ERT
7613 status collapsed
7632 status collapsed
7614
7633
7615 \begin_layout Standard
7634 \begin_layout Standard
7616
7635
7617
7636
7618 \backslash
7637 \backslash
7619 hspace*{0mm}
7638 hspace*{0mm}
7620 \end_layout
7639 \end_layout
7621
7640
7622 \end_inset
7641 \end_inset
7623
7642
7624 \InsetSpace ~
7643 \InsetSpace ~
7625 \InsetSpace ~
7644 \InsetSpace ~
7626 ...: ...\InsetSpace ~
7645 ...: ...\InsetSpace ~
7627 \InsetSpace ~
7646 \InsetSpace ~
7628 \InsetSpace ~
7647 \InsetSpace ~
7629 \InsetSpace ~
7648 \InsetSpace ~
7630 \InsetSpace ~
7649 \InsetSpace ~
7631 \InsetSpace ~
7650 \InsetSpace ~
7632 \InsetSpace ~
7651 \InsetSpace ~
7633 \InsetSpace ~
7652 \InsetSpace ~
7634 a, b = b, a+b
7653 a, b = b, a+b
7635 \newline
7654 \newline
7636
7655
7637 \begin_inset ERT
7656 \begin_inset ERT
7638 status collapsed
7657 status collapsed
7639
7658
7640 \begin_layout Standard
7659 \begin_layout Standard
7641
7660
7642
7661
7643 \backslash
7662 \backslash
7644 hspace*{0mm}
7663 hspace*{0mm}
7645 \end_layout
7664 \end_layout
7646
7665
7647 \end_inset
7666 \end_inset
7648
7667
7649 \InsetSpace ~
7668 \InsetSpace ~
7650 \InsetSpace ~
7669 \InsetSpace ~
7651 ...: ...\InsetSpace ~
7670 ...: ...\InsetSpace ~
7652 \InsetSpace ~
7671 \InsetSpace ~
7653 \InsetSpace ~
7672 \InsetSpace ~
7654 \InsetSpace ~
7673 \InsetSpace ~
7655 return result
7674 return result
7656 \newline
7675 \newline
7657
7676
7658 \begin_inset ERT
7677 \begin_inset ERT
7659 status collapsed
7678 status collapsed
7660
7679
7661 \begin_layout Standard
7680 \begin_layout Standard
7662
7681
7663
7682
7664 \backslash
7683 \backslash
7665 hspace*{0mm}
7684 hspace*{0mm}
7666 \end_layout
7685 \end_layout
7667
7686
7668 \end_inset
7687 \end_inset
7669
7688
7670 \InsetSpace ~
7689 \InsetSpace ~
7671 \InsetSpace ~
7690 \InsetSpace ~
7672 ...:
7691 ...:
7673 \newline
7692 \newline
7674 \InsetSpace ~
7693 \InsetSpace ~
7675
7694
7676 \newline
7695 \newline
7677 In [2]: fib2(10)
7696 In [2]: fib2(10)
7678 \newline
7697 \newline
7679 Out[2]: [1, 1, 2, 3, 5, 8]
7698 Out[2]: [1, 1, 2, 3, 5, 8]
7680 \end_layout
7699 \end_layout
7681
7700
7682 \begin_layout Standard
7701 \begin_layout Standard
7683 Note that as currently written, this extension does
7702 Note that as currently written, this extension does
7684 \emph on
7703 \emph on
7685 not
7704 not
7686 \emph default
7705 \emph default
7687 recognize IPython's prompts for pasting.
7706 recognize IPython's prompts for pasting.
7688 Those are more complicated, since the user can change them very easily,
7707 Those are more complicated, since the user can change them very easily,
7689 they involve numbers and can vary in length.
7708 they involve numbers and can vary in length.
7690 One could however extract all the relevant information from the IPython
7709 One could however extract all the relevant information from the IPython
7691 instance and build an appropriate regular expression.
7710 instance and build an appropriate regular expression.
7692 This is left as an exercise for the reader.
7711 This is left as an exercise for the reader.
7693 \end_layout
7712 \end_layout
7694
7713
7695 \begin_layout Subsection
7714 \begin_layout Subsection
7696 Input of physical quantities with units
7715 Input of physical quantities with units
7697 \end_layout
7716 \end_layout
7698
7717
7699 \begin_layout Standard
7718 \begin_layout Standard
7700 The module
7719 The module
7701 \family typewriter
7720 \family typewriter
7702 PhysicalQInput
7721 PhysicalQInput
7703 \family default
7722 \family default
7704 allows a simplified form of input for physical quantities with units.
7723 allows a simplified form of input for physical quantities with units.
7705 This file is meant to be used in conjunction with the
7724 This file is meant to be used in conjunction with the
7706 \family typewriter
7725 \family typewriter
7707 PhysicalQInteractive
7726 PhysicalQInteractive
7708 \family default
7727 \family default
7709 module (in the same directory) and
7728 module (in the same directory) and
7710 \family typewriter
7729 \family typewriter
7711 Physics.PhysicalQuantities
7730 Physics.PhysicalQuantities
7712 \family default
7731 \family default
7713 from Konrad Hinsen's ScientificPython (
7732 from Konrad Hinsen's ScientificPython (
7714 \begin_inset LatexCommand \htmlurl{http://dirac.cnrs-orleans.fr/ScientificPython/}
7733 \begin_inset LatexCommand \htmlurl{http://dirac.cnrs-orleans.fr/ScientificPython/}
7715
7734
7716 \end_inset
7735 \end_inset
7717
7736
7718 ).
7737 ).
7719 \end_layout
7738 \end_layout
7720
7739
7721 \begin_layout Standard
7740 \begin_layout Standard
7722 The
7741 The
7723 \family typewriter
7742 \family typewriter
7724 Physics.PhysicalQuantities
7743 Physics.PhysicalQuantities
7725 \family default
7744 \family default
7726 module defines
7745 module defines
7727 \family typewriter
7746 \family typewriter
7728 PhysicalQuantity
7747 PhysicalQuantity
7729 \family default
7748 \family default
7730 objects, but these must be declared as instances of a class.
7749 objects, but these must be declared as instances of a class.
7731 For example, to define
7750 For example, to define
7732 \family typewriter
7751 \family typewriter
7733 v
7752 v
7734 \family default
7753 \family default
7735 as a velocity of 3\InsetSpace ~
7754 as a velocity of 3\InsetSpace ~
7736 m/s, normally you would write:
7755 m/s, normally you would write:
7737 \family typewriter
7756 \family typewriter
7738
7757
7739 \newline
7758 \newline
7740 In [1]: v = PhysicalQuantity(3,'m/s')
7759 In [1]: v = PhysicalQuantity(3,'m/s')
7741 \end_layout
7760 \end_layout
7742
7761
7743 \begin_layout Standard
7762 \begin_layout Standard
7744 Using the
7763 Using the
7745 \family typewriter
7764 \family typewriter
7746 PhysicalQ_Input
7765 PhysicalQ_Input
7747 \family default
7766 \family default
7748 extension this can be input instead as:
7767 extension this can be input instead as:
7749 \family typewriter
7768 \family typewriter
7750
7769
7751 \newline
7770 \newline
7752 In [1]: v = 3 m/s
7771 In [1]: v = 3 m/s
7753 \family default
7772 \family default
7754
7773
7755 \newline
7774 \newline
7756 which is much more convenient for interactive use (even though it is blatantly
7775 which is much more convenient for interactive use (even though it is blatantly
7757 invalid Python syntax).
7776 invalid Python syntax).
7758 \end_layout
7777 \end_layout
7759
7778
7760 \begin_layout Standard
7779 \begin_layout Standard
7761 The
7780 The
7762 \family typewriter
7781 \family typewriter
7763 physics
7782 physics
7764 \family default
7783 \family default
7765 profile supplied with IPython (enabled via
7784 profile supplied with IPython (enabled via
7766 \family typewriter
7785 \family typewriter
7767 'ipython -p physics'
7786 'ipython -p physics'
7768 \family default
7787 \family default
7769 ) uses these extensions, which you can also activate with:
7788 ) uses these extensions, which you can also activate with:
7770 \end_layout
7789 \end_layout
7771
7790
7772 \begin_layout Standard
7791 \begin_layout Standard
7773
7792
7774 \family typewriter
7793 \family typewriter
7775 from math import * # math MUST be imported BEFORE PhysicalQInteractive
7794 from math import * # math MUST be imported BEFORE PhysicalQInteractive
7776 \newline
7795 \newline
7777 from
7796 from
7778 IPython.Extensions.PhysicalQInteractive import *
7797 IPython.Extensions.PhysicalQInteractive import *
7779 \newline
7798 \newline
7780 import IPython.Extensions.PhysicalQ
7799 import IPython.Extensions.PhysicalQ
7781 Input
7800 Input
7782 \end_layout
7801 \end_layout
7783
7802
7784 \begin_layout Section
7803 \begin_layout Section
7785 \begin_inset LatexCommand \label{sec:IPython-as-shell}
7804 \begin_inset LatexCommand \label{sec:IPython-as-shell}
7786
7805
7787 \end_inset
7806 \end_inset
7788
7807
7789 IPython as a system shell
7808 IPython as a system shell
7790 \end_layout
7809 \end_layout
7791
7810
7792 \begin_layout Standard
7811 \begin_layout Standard
7793 IPython ships with a special profile called
7812 IPython ships with a special profile called
7794 \family typewriter
7813 \family typewriter
7795 pysh
7814 pysh
7796 \family default
7815 \family default
7797 , which you can activate at the command line as
7816 , which you can activate at the command line as
7798 \family typewriter
7817 \family typewriter
7799 `ipython -p pysh'
7818 `ipython -p pysh'
7800 \family default
7819 \family default
7801 .
7820 .
7802 This loads
7821 This loads
7803 \family typewriter
7822 \family typewriter
7804 InterpreterExec
7823 InterpreterExec
7805 \family default
7824 \family default
7806 , along with some additional facilities and a prompt customized for filesystem
7825 , along with some additional facilities and a prompt customized for filesystem
7807 navigation.
7826 navigation.
7808 \end_layout
7827 \end_layout
7809
7828
7810 \begin_layout Standard
7829 \begin_layout Standard
7811 Note that this does
7830 Note that this does
7812 \emph on
7831 \emph on
7813 not
7832 not
7814 \emph default
7833 \emph default
7815 make IPython a full-fledged system shell.
7834 make IPython a full-fledged system shell.
7816 In particular, it has no job control, so if you type Ctrl-Z (under Unix),
7835 In particular, it has no job control, so if you type Ctrl-Z (under Unix),
7817 you'll suspend pysh itself, not the process you just started.
7836 you'll suspend pysh itself, not the process you just started.
7818
7837
7819 \end_layout
7838 \end_layout
7820
7839
7821 \begin_layout Standard
7840 \begin_layout Standard
7822 What the shell profile allows you to do is to use the convenient and powerful
7841 What the shell profile allows you to do is to use the convenient and powerful
7823 syntax of Python to do quick scripting at the command line.
7842 syntax of Python to do quick scripting at the command line.
7824 Below we describe some of its features.
7843 Below we describe some of its features.
7825 \end_layout
7844 \end_layout
7826
7845
7827 \begin_layout Subsection
7846 \begin_layout Subsection
7828 Aliases
7847 Aliases
7829 \end_layout
7848 \end_layout
7830
7849
7831 \begin_layout Standard
7850 \begin_layout Standard
7832 All of your
7851 All of your
7833 \family typewriter
7852 \family typewriter
7834 $PATH
7853 $PATH
7835 \family default
7854 \family default
7836 has been loaded as IPython aliases, so you should be able to type any normal
7855 has been loaded as IPython aliases, so you should be able to type any normal
7837 system command and have it executed.
7856 system command and have it executed.
7838 See
7857 See
7839 \family typewriter
7858 \family typewriter
7840 %alias?
7859 %alias?
7841 \family default
7860 \family default
7842 and
7861 and
7843 \family typewriter
7862 \family typewriter
7844 %unalias?
7863 %unalias?
7845 \family default
7864 \family default
7846 for details on the alias facilities.
7865 for details on the alias facilities.
7847 See also
7866 See also
7848 \family typewriter
7867 \family typewriter
7849 %rehash?
7868 %rehash?
7850 \family default
7869 \family default
7851 and
7870 and
7852 \family typewriter
7871 \family typewriter
7853 %rehashx?
7872 %rehashx?
7854 \family default
7873 \family default
7855 for details on the mechanism used to load
7874 for details on the mechanism used to load
7856 \family typewriter
7875 \family typewriter
7857 $PATH
7876 $PATH
7858 \family default
7877 \family default
7859 .
7878 .
7860 \end_layout
7879 \end_layout
7861
7880
7862 \begin_layout Subsection
7881 \begin_layout Subsection
7863 Special syntax
7882 Special syntax
7864 \end_layout
7883 \end_layout
7865
7884
7866 \begin_layout Standard
7885 \begin_layout Standard
7867 Any lines which begin with
7886 Any lines which begin with
7868 \family typewriter
7887 \family typewriter
7869 `~'
7888 `~'
7870 \family default
7889 \family default
7871 ,
7890 ,
7872 \family typewriter
7891 \family typewriter
7873 `/'
7892 `/'
7874 \family default
7893 \family default
7875 and
7894 and
7876 \family typewriter
7895 \family typewriter
7877 `.'
7896 `.'
7878 \family default
7897 \family default
7879 will be executed as shell commands instead of as Python code.
7898 will be executed as shell commands instead of as Python code.
7880 The special escapes below are also recognized.
7899 The special escapes below are also recognized.
7881
7900
7882 \family typewriter
7901 \family typewriter
7883 !cmd
7902 !cmd
7884 \family default
7903 \family default
7885 is valid in single or multi-line input, all others are only valid in single-lin
7904 is valid in single or multi-line input, all others are only valid in single-lin
7886 e input:
7905 e input:
7887 \end_layout
7906 \end_layout
7888
7907
7889 \begin_layout Description
7908 \begin_layout Description
7890
7909
7891 \family typewriter
7910 \family typewriter
7892 !cmd
7911 !cmd
7893 \family default
7912 \family default
7894 pass `cmd' directly to the shell
7913 pass `cmd' directly to the shell
7895 \end_layout
7914 \end_layout
7896
7915
7897 \begin_layout Description
7916 \begin_layout Description
7898
7917
7899 \family typewriter
7918 \family typewriter
7900 !!cmd
7919 !!cmd
7901 \family default
7920 \family default
7902 execute `cmd' and return output as a list (split on `
7921 execute `cmd' and return output as a list (split on `
7903 \backslash
7922 \backslash
7904 n')
7923 n')
7905 \end_layout
7924 \end_layout
7906
7925
7907 \begin_layout Description
7926 \begin_layout Description
7908
7927
7909 \family typewriter
7928 \family typewriter
7910 $var=cmd
7929 $var=cmd
7911 \family default
7930 \family default
7912 capture output of cmd into var, as a string
7931 capture output of cmd into var, as a string
7913 \end_layout
7932 \end_layout
7914
7933
7915 \begin_layout Description
7934 \begin_layout Description
7916
7935
7917 \family typewriter
7936 \family typewriter
7918 $$var=cmd
7937 $$var=cmd
7919 \family default
7938 \family default
7920 capture output of cmd into var, as a list (split on `
7939 capture output of cmd into var, as a list (split on `
7921 \backslash
7940 \backslash
7922 n')
7941 n')
7923 \end_layout
7942 \end_layout
7924
7943
7925 \begin_layout Standard
7944 \begin_layout Standard
7926 The
7945 The
7927 \family typewriter
7946 \family typewriter
7928 $
7947 $
7929 \family default
7948 \family default
7930 /
7949 /
7931 \family typewriter
7950 \family typewriter
7932 $$
7951 $$
7933 \family default
7952 \family default
7934 syntaxes make Python variables from system output, which you can later
7953 syntaxes make Python variables from system output, which you can later
7935 use for further scripting.
7954 use for further scripting.
7936 The converse is also possible: when executing an alias or calling to the
7955 The converse is also possible: when executing an alias or calling to the
7937 system via
7956 system via
7938 \family typewriter
7957 \family typewriter
7939 !
7958 !
7940 \family default
7959 \family default
7941 /
7960 /
7942 \family typewriter
7961 \family typewriter
7943 !!
7962 !!
7944 \family default
7963 \family default
7945 , you can expand any python variable or expression by prepending it with
7964 , you can expand any python variable or expression by prepending it with
7946
7965
7947 \family typewriter
7966 \family typewriter
7948 $
7967 $
7949 \family default
7968 \family default
7950 .
7969 .
7951 Full details of the allowed syntax can be found in Python's PEP 215.
7970 Full details of the allowed syntax can be found in Python's PEP 215.
7952 \end_layout
7971 \end_layout
7953
7972
7954 \begin_layout Standard
7973 \begin_layout Standard
7955 A few brief examples will illustrate these (note that the indentation below
7974 A few brief examples will illustrate these (note that the indentation below
7956 may be incorrectly displayed):
7975 may be incorrectly displayed):
7957 \end_layout
7976 \end_layout
7958
7977
7959 \begin_layout Standard
7978 \begin_layout Standard
7960
7979
7961 \family typewriter
7980 \family typewriter
7962 fperez[~/test]|3> !ls *s.py
7981 fperez[~/test]|3> !ls *s.py
7963 \newline
7982 \newline
7964 scopes.py strings.py
7983 scopes.py strings.py
7965 \end_layout
7984 \end_layout
7966
7985
7967 \begin_layout Standard
7986 \begin_layout Standard
7968 ls is an internal alias, so there's no need to use
7987 ls is an internal alias, so there's no need to use
7969 \family typewriter
7988 \family typewriter
7970 !
7989 !
7971 \family default
7990 \family default
7972 :
7991 :
7973 \end_layout
7992 \end_layout
7974
7993
7975 \begin_layout Standard
7994 \begin_layout Standard
7976
7995
7977 \family typewriter
7996 \family typewriter
7978 fperez[~/test]|4> ls *s.py
7997 fperez[~/test]|4> ls *s.py
7979 \newline
7998 \newline
7980 scopes.py* strings.py
7999 scopes.py* strings.py
7981 \end_layout
8000 \end_layout
7982
8001
7983 \begin_layout Standard
8002 \begin_layout Standard
7984 !!ls will return the output into a Python variable:
8003 !!ls will return the output into a Python variable:
7985 \end_layout
8004 \end_layout
7986
8005
7987 \begin_layout Standard
8006 \begin_layout Standard
7988
8007
7989 \family typewriter
8008 \family typewriter
7990 fperez[~/test]|5> !!ls *s.py
8009 fperez[~/test]|5> !!ls *s.py
7991 \newline
8010 \newline
7992
8011
7993 \begin_inset ERT
8012 \begin_inset ERT
7994 status collapsed
8013 status collapsed
7995
8014
7996 \begin_layout Standard
8015 \begin_layout Standard
7997
8016
7998
8017
7999 \backslash
8018 \backslash
8000 hspace*{0mm}
8019 hspace*{0mm}
8001 \end_layout
8020 \end_layout
8002
8021
8003 \end_inset
8022 \end_inset
8004
8023
8005 \InsetSpace ~
8024 \InsetSpace ~
8006 \InsetSpace ~
8025 \InsetSpace ~
8007 \InsetSpace ~
8026 \InsetSpace ~
8008 \InsetSpace ~
8027 \InsetSpace ~
8009 \InsetSpace ~
8028 \InsetSpace ~
8010 \InsetSpace ~
8029 \InsetSpace ~
8011 \InsetSpace ~
8030 \InsetSpace ~
8012 \InsetSpace ~
8031 \InsetSpace ~
8013 \InsetSpace ~
8032 \InsetSpace ~
8014 \InsetSpace ~
8033 \InsetSpace ~
8015 \InsetSpace ~
8034 \InsetSpace ~
8016 \InsetSpace ~
8035 \InsetSpace ~
8017 \InsetSpace ~
8036 \InsetSpace ~
8018 \InsetSpace ~
8037 \InsetSpace ~
8019 <5> ['scopes.py', 'strings.py']
8038 <5> ['scopes.py', 'strings.py']
8020 \newline
8039 \newline
8021 fperez[~/test]|6> print _5
8040 fperez[~/test]|6> print _5
8022 \newline
8041 \newline
8023 ['scopes.py', 'strings.py
8042 ['scopes.py', 'strings.py
8024 ']
8043 ']
8025 \end_layout
8044 \end_layout
8026
8045
8027 \begin_layout Standard
8046 \begin_layout Standard
8028
8047
8029 \family typewriter
8048 \family typewriter
8030 $
8049 $
8031 \family default
8050 \family default
8032 and
8051 and
8033 \family typewriter
8052 \family typewriter
8034 $$
8053 $$
8035 \family default
8054 \family default
8036 allow direct capture to named variables:
8055 allow direct capture to named variables:
8037 \end_layout
8056 \end_layout
8038
8057
8039 \begin_layout Standard
8058 \begin_layout Standard
8040
8059
8041 \family typewriter
8060 \family typewriter
8042 fperez[~/test]|7> $astr = ls *s.py
8061 fperez[~/test]|7> $astr = ls *s.py
8043 \newline
8062 \newline
8044 fperez[~/test]|8> astr
8063 fperez[~/test]|8> astr
8045 \newline
8064 \newline
8046
8065
8047 \begin_inset ERT
8066 \begin_inset ERT
8048 status collapsed
8067 status collapsed
8049
8068
8050 \begin_layout Standard
8069 \begin_layout Standard
8051
8070
8052
8071
8053 \backslash
8072 \backslash
8054 hspace*{0mm}
8073 hspace*{0mm}
8055 \end_layout
8074 \end_layout
8056
8075
8057 \end_inset
8076 \end_inset
8058
8077
8059 \InsetSpace ~
8078 \InsetSpace ~
8060 \InsetSpace ~
8079 \InsetSpace ~
8061 \InsetSpace ~
8080 \InsetSpace ~
8062 \InsetSpace ~
8081 \InsetSpace ~
8063 \InsetSpace ~
8082 \InsetSpace ~
8064 \InsetSpace ~
8083 \InsetSpace ~
8065 \InsetSpace ~
8084 \InsetSpace ~
8066 \InsetSpace ~
8085 \InsetSpace ~
8067 \InsetSpace ~
8086 \InsetSpace ~
8068 \InsetSpace ~
8087 \InsetSpace ~
8069 \InsetSpace ~
8088 \InsetSpace ~
8070 \InsetSpace ~
8089 \InsetSpace ~
8071 \InsetSpace ~
8090 \InsetSpace ~
8072 \InsetSpace ~
8091 \InsetSpace ~
8073 <8> 'scopes.py
8092 <8> 'scopes.py
8074 \backslash
8093 \backslash
8075 nstrings.py'
8094 nstrings.py'
8076 \end_layout
8095 \end_layout
8077
8096
8078 \begin_layout Standard
8097 \begin_layout Standard
8079
8098
8080 \family typewriter
8099 \family typewriter
8081 fperez[~/test]|9> $$alist = ls *s.py
8100 fperez[~/test]|9> $$alist = ls *s.py
8082 \newline
8101 \newline
8083 fperez[~/test]|10> alist
8102 fperez[~/test]|10> alist
8084 \newline
8103 \newline
8085
8104
8086 \begin_inset ERT
8105 \begin_inset ERT
8087 status collapsed
8106 status collapsed
8088
8107
8089 \begin_layout Standard
8108 \begin_layout Standard
8090
8109
8091
8110
8092 \backslash
8111 \backslash
8093 hspace*{0mm}
8112 hspace*{0mm}
8094 \end_layout
8113 \end_layout
8095
8114
8096 \end_inset
8115 \end_inset
8097
8116
8098 \InsetSpace ~
8117 \InsetSpace ~
8099 \InsetSpace ~
8118 \InsetSpace ~
8100 \InsetSpace ~
8119 \InsetSpace ~
8101 \InsetSpace ~
8120 \InsetSpace ~
8102 \InsetSpace ~
8121 \InsetSpace ~
8103 \InsetSpace ~
8122 \InsetSpace ~
8104 \InsetSpace ~
8123 \InsetSpace ~
8105 \InsetSpace ~
8124 \InsetSpace ~
8106 \InsetSpace ~
8125 \InsetSpace ~
8107 \InsetSpace ~
8126 \InsetSpace ~
8108 \InsetSpace ~
8127 \InsetSpace ~
8109 \InsetSpace ~
8128 \InsetSpace ~
8110 \InsetSpace ~
8129 \InsetSpace ~
8111 \InsetSpace ~
8130 \InsetSpace ~
8112 <10> ['scopes.py', 'strings.py']
8131 <10> ['scopes.py', 'strings.py']
8113 \end_layout
8132 \end_layout
8114
8133
8115 \begin_layout Standard
8134 \begin_layout Standard
8116 alist is now a normal python list you can loop over.
8135 alist is now a normal python list you can loop over.
8117 Using
8136 Using
8118 \family typewriter
8137 \family typewriter
8119 $
8138 $
8120 \family default
8139 \family default
8121 will expand back the python values when alias calls are made:
8140 will expand back the python values when alias calls are made:
8122 \end_layout
8141 \end_layout
8123
8142
8124 \begin_layout Standard
8143 \begin_layout Standard
8125
8144
8126 \family typewriter
8145 \family typewriter
8127 fperez[~/test]|11> for f in alist:
8146 fperez[~/test]|11> for f in alist:
8128 \newline
8147 \newline
8129
8148
8130 \begin_inset ERT
8149 \begin_inset ERT
8131 status collapsed
8150 status collapsed
8132
8151
8133 \begin_layout Standard
8152 \begin_layout Standard
8134
8153
8135
8154
8136 \backslash
8155 \backslash
8137 hspace*{0mm}
8156 hspace*{0mm}
8138 \end_layout
8157 \end_layout
8139
8158
8140 \end_inset
8159 \end_inset
8141
8160
8142 \InsetSpace ~
8161 \InsetSpace ~
8143 \InsetSpace ~
8162 \InsetSpace ~
8144 \InsetSpace ~
8163 \InsetSpace ~
8145 \InsetSpace ~
8164 \InsetSpace ~
8146 \InsetSpace ~
8165 \InsetSpace ~
8147 \InsetSpace ~
8166 \InsetSpace ~
8148 \InsetSpace ~
8167 \InsetSpace ~
8149 \InsetSpace ~
8168 \InsetSpace ~
8150 \InsetSpace ~
8169 \InsetSpace ~
8151 \InsetSpace ~
8170 \InsetSpace ~
8152 \InsetSpace ~
8171 \InsetSpace ~
8153 \InsetSpace ~
8172 \InsetSpace ~
8154 \InsetSpace ~
8173 \InsetSpace ~
8155 \InsetSpace ~
8174 \InsetSpace ~
8156 |..> \InsetSpace ~
8175 |..> \InsetSpace ~
8157 \InsetSpace ~
8176 \InsetSpace ~
8158 \InsetSpace ~
8177 \InsetSpace ~
8159 \InsetSpace ~
8178 \InsetSpace ~
8160 print 'file',f,
8179 print 'file',f,
8161 \newline
8180 \newline
8162
8181
8163 \begin_inset ERT
8182 \begin_inset ERT
8164 status collapsed
8183 status collapsed
8165
8184
8166 \begin_layout Standard
8185 \begin_layout Standard
8167
8186
8168
8187
8169 \backslash
8188 \backslash
8170 hspace*{0mm}
8189 hspace*{0mm}
8171 \end_layout
8190 \end_layout
8172
8191
8173 \end_inset
8192 \end_inset
8174
8193
8175 \InsetSpace ~
8194 \InsetSpace ~
8176 \InsetSpace ~
8195 \InsetSpace ~
8177 \InsetSpace ~
8196 \InsetSpace ~
8178 \InsetSpace ~
8197 \InsetSpace ~
8179 \InsetSpace ~
8198 \InsetSpace ~
8180 \InsetSpace ~
8199 \InsetSpace ~
8181 \InsetSpace ~
8200 \InsetSpace ~
8182 \InsetSpace ~
8201 \InsetSpace ~
8183 \InsetSpace ~
8202 \InsetSpace ~
8184 \InsetSpace ~
8203 \InsetSpace ~
8185 \InsetSpace ~
8204 \InsetSpace ~
8186 \InsetSpace ~
8205 \InsetSpace ~
8187 \InsetSpace ~
8206 \InsetSpace ~
8188 \InsetSpace ~
8207 \InsetSpace ~
8189 |..> \InsetSpace ~
8208 |..> \InsetSpace ~
8190 \InsetSpace ~
8209 \InsetSpace ~
8191 \InsetSpace ~
8210 \InsetSpace ~
8192 \InsetSpace ~
8211 \InsetSpace ~
8193 wc -l $f
8212 wc -l $f
8194 \newline
8213 \newline
8195
8214
8196 \begin_inset ERT
8215 \begin_inset ERT
8197 status collapsed
8216 status collapsed
8198
8217
8199 \begin_layout Standard
8218 \begin_layout Standard
8200
8219
8201
8220
8202 \backslash
8221 \backslash
8203 hspace*{0mm}
8222 hspace*{0mm}
8204 \end_layout
8223 \end_layout
8205
8224
8206 \end_inset
8225 \end_inset
8207
8226
8208 \InsetSpace ~
8227 \InsetSpace ~
8209 \InsetSpace ~
8228 \InsetSpace ~
8210 \InsetSpace ~
8229 \InsetSpace ~
8211 \InsetSpace ~
8230 \InsetSpace ~
8212 \InsetSpace ~
8231 \InsetSpace ~
8213 \InsetSpace ~
8232 \InsetSpace ~
8214 \InsetSpace ~
8233 \InsetSpace ~
8215 \InsetSpace ~
8234 \InsetSpace ~
8216 \InsetSpace ~
8235 \InsetSpace ~
8217 \InsetSpace ~
8236 \InsetSpace ~
8218 \InsetSpace ~
8237 \InsetSpace ~
8219 \InsetSpace ~
8238 \InsetSpace ~
8220 \InsetSpace ~
8239 \InsetSpace ~
8221 \InsetSpace ~
8240 \InsetSpace ~
8222 |..>
8241 |..>
8223 \newline
8242 \newline
8224 file scopes.py 13 scopes.py
8243 file scopes.py 13 scopes.py
8225 \newline
8244 \newline
8226 file strings.py 4 strings.py
8245 file strings.py 4 strings.py
8227 \end_layout
8246 \end_layout
8228
8247
8229 \begin_layout Standard
8248 \begin_layout Standard
8230 Note that you may need to protect your variables with braces if you want
8249 Note that you may need to protect your variables with braces if you want
8231 to append strings to their names.
8250 to append strings to their names.
8232 To copy all files in alist to
8251 To copy all files in alist to
8233 \family typewriter
8252 \family typewriter
8234 .bak
8253 .bak
8235 \family default
8254 \family default
8236 extensions, you must use:
8255 extensions, you must use:
8237 \end_layout
8256 \end_layout
8238
8257
8239 \begin_layout Standard
8258 \begin_layout Standard
8240
8259
8241 \family typewriter
8260 \family typewriter
8242 fperez[~/test]|12> for f in alist:
8261 fperez[~/test]|12> for f in alist:
8243 \newline
8262 \newline
8244
8263
8245 \begin_inset ERT
8264 \begin_inset ERT
8246 status collapsed
8265 status collapsed
8247
8266
8248 \begin_layout Standard
8267 \begin_layout Standard
8249
8268
8250
8269
8251 \backslash
8270 \backslash
8252 hspace*{0mm}
8271 hspace*{0mm}
8253 \end_layout
8272 \end_layout
8254
8273
8255 \end_inset
8274 \end_inset
8256
8275
8257 \InsetSpace ~
8276 \InsetSpace ~
8258 \InsetSpace ~
8277 \InsetSpace ~
8259 \InsetSpace ~
8278 \InsetSpace ~
8260 \InsetSpace ~
8279 \InsetSpace ~
8261 \InsetSpace ~
8280 \InsetSpace ~
8262 \InsetSpace ~
8281 \InsetSpace ~
8263 \InsetSpace ~
8282 \InsetSpace ~
8264 \InsetSpace ~
8283 \InsetSpace ~
8265 \InsetSpace ~
8284 \InsetSpace ~
8266 \InsetSpace ~
8285 \InsetSpace ~
8267 \InsetSpace ~
8286 \InsetSpace ~
8268 \InsetSpace ~
8287 \InsetSpace ~
8269 \InsetSpace ~
8288 \InsetSpace ~
8270 \InsetSpace ~
8289 \InsetSpace ~
8271 |..> \InsetSpace ~
8290 |..> \InsetSpace ~
8272 \InsetSpace ~
8291 \InsetSpace ~
8273 \InsetSpace ~
8292 \InsetSpace ~
8274 \InsetSpace ~
8293 \InsetSpace ~
8275 cp $f ${f}.bak
8294 cp $f ${f}.bak
8276 \end_layout
8295 \end_layout
8277
8296
8278 \begin_layout Standard
8297 \begin_layout Standard
8279 If you try using
8298 If you try using
8280 \family typewriter
8299 \family typewriter
8281 $f.bak
8300 $f.bak
8282 \family default
8301 \family default
8283 , you'll get an AttributeError exception saying that your string object
8302 , you'll get an AttributeError exception saying that your string object
8284 doesn't have a
8303 doesn't have a
8285 \family typewriter
8304 \family typewriter
8286 .bak
8305 .bak
8287 \family default
8306 \family default
8288 attribute.
8307 attribute.
8289 This is because the
8308 This is because the
8290 \family typewriter
8309 \family typewriter
8291 $
8310 $
8292 \family default
8311 \family default
8293 expansion mechanism allows you to expand full Python expressions:
8312 expansion mechanism allows you to expand full Python expressions:
8294 \end_layout
8313 \end_layout
8295
8314
8296 \begin_layout Standard
8315 \begin_layout Standard
8297
8316
8298 \family typewriter
8317 \family typewriter
8299 fperez[~/test]|13> echo "sys.platform is: $sys.platform"
8318 fperez[~/test]|13> echo "sys.platform is: $sys.platform"
8300 \newline
8319 \newline
8301 sys.platform is: linux2
8320 sys.platform is: linux2
8302 \end_layout
8321 \end_layout
8303
8322
8304 \begin_layout Standard
8323 \begin_layout Standard
8305 IPython's input history handling is still active, which allows you to rerun
8324 IPython's input history handling is still active, which allows you to rerun
8306 a single block of multi-line input by simply using exec:
8325 a single block of multi-line input by simply using exec:
8307 \newline
8326 \newline
8308
8327
8309 \family typewriter
8328 \family typewriter
8310 fperez[~/test]|14> $$alist = ls *.eps
8329 fperez[~/test]|14> $$alist = ls *.eps
8311 \newline
8330 \newline
8312 fperez[~/test]|15> exec _i11
8331 fperez[~/test]|15> exec _i11
8313 \newline
8332 \newline
8314 file image2.eps
8333 file image2.eps
8315 921 image2.eps
8334 921 image2.eps
8316 \newline
8335 \newline
8317 file image.eps 921 image.eps
8336 file image.eps 921 image.eps
8318 \end_layout
8337 \end_layout
8319
8338
8320 \begin_layout Standard
8339 \begin_layout Standard
8321 While these are new special-case syntaxes, they are designed to allow very
8340 While these are new special-case syntaxes, they are designed to allow very
8322 efficient use of the shell with minimal typing.
8341 efficient use of the shell with minimal typing.
8323 At an interactive shell prompt, conciseness of expression wins over readability.
8342 At an interactive shell prompt, conciseness of expression wins over readability.
8324 \end_layout
8343 \end_layout
8325
8344
8326 \begin_layout Subsection
8345 \begin_layout Subsection
8327 Useful functions and modules
8346 Useful functions and modules
8328 \end_layout
8347 \end_layout
8329
8348
8330 \begin_layout Standard
8349 \begin_layout Standard
8331 The os, sys and shutil modules from the Python standard library are automaticall
8350 The os, sys and shutil modules from the Python standard library are automaticall
8332 y loaded.
8351 y loaded.
8333 Some additional functions, useful for shell usage, are listed below.
8352 Some additional functions, useful for shell usage, are listed below.
8334 You can request more help about them with `
8353 You can request more help about them with `
8335 \family typewriter
8354 \family typewriter
8336 ?
8355 ?
8337 \family default
8356 \family default
8338 '.
8357 '.
8339 \end_layout
8358 \end_layout
8340
8359
8341 \begin_layout Description
8360 \begin_layout Description
8342
8361
8343 \family typewriter
8362 \family typewriter
8344 shell
8363 shell
8345 \family default
8364 \family default
8346 - execute a command in the underlying system shell
8365 - execute a command in the underlying system shell
8347 \end_layout
8366 \end_layout
8348
8367
8349 \begin_layout Description
8368 \begin_layout Description
8350
8369
8351 \family typewriter
8370 \family typewriter
8352 system
8371 system
8353 \family default
8372 \family default
8354 - like
8373 - like
8355 \family typewriter
8374 \family typewriter
8356 shell()
8375 shell()
8357 \family default
8376 \family default
8358 , but return the exit status of the command
8377 , but return the exit status of the command
8359 \end_layout
8378 \end_layout
8360
8379
8361 \begin_layout Description
8380 \begin_layout Description
8362
8381
8363 \family typewriter
8382 \family typewriter
8364 sout
8383 sout
8365 \family default
8384 \family default
8366 - capture the output of a command as a string
8385 - capture the output of a command as a string
8367 \end_layout
8386 \end_layout
8368
8387
8369 \begin_layout Description
8388 \begin_layout Description
8370
8389
8371 \family typewriter
8390 \family typewriter
8372 lout
8391 lout
8373 \family default
8392 \family default
8374 - capture the output of a command as a list (split on `
8393 - capture the output of a command as a list (split on `
8375 \backslash
8394 \backslash
8376 n')
8395 n')
8377 \end_layout
8396 \end_layout
8378
8397
8379 \begin_layout Description
8398 \begin_layout Description
8380
8399
8381 \family typewriter
8400 \family typewriter
8382 getoutputerror
8401 getoutputerror
8383 \family default
8402 \family default
8384 - capture (output,error) of a shell commandss
8403 - capture (output,error) of a shell commandss
8385 \end_layout
8404 \end_layout
8386
8405
8387 \begin_layout Standard
8406 \begin_layout Standard
8388
8407
8389 \family typewriter
8408 \family typewriter
8390 sout
8409 sout
8391 \family default
8410 \family default
8392 /
8411 /
8393 \family typewriter
8412 \family typewriter
8394 lout
8413 lout
8395 \family default
8414 \family default
8396 are the functional equivalents of
8415 are the functional equivalents of
8397 \family typewriter
8416 \family typewriter
8398 $
8417 $
8399 \family default
8418 \family default
8400 /
8419 /
8401 \family typewriter
8420 \family typewriter
8402 $$
8421 $$
8403 \family default
8422 \family default
8404 .
8423 .
8405 They are provided to allow you to capture system output in the middle of
8424 They are provided to allow you to capture system output in the middle of
8406 true python code, function definitions, etc (where
8425 true python code, function definitions, etc (where
8407 \family typewriter
8426 \family typewriter
8408 $
8427 $
8409 \family default
8428 \family default
8410 and
8429 and
8411 \family typewriter
8430 \family typewriter
8412 $$
8431 $$
8413 \family default
8432 \family default
8414 are invalid).
8433 are invalid).
8415 \end_layout
8434 \end_layout
8416
8435
8417 \begin_layout Subsection
8436 \begin_layout Subsection
8418 Directory management
8437 Directory management
8419 \end_layout
8438 \end_layout
8420
8439
8421 \begin_layout Standard
8440 \begin_layout Standard
8422 Since each command passed by pysh to the underlying system is executed in
8441 Since each command passed by pysh to the underlying system is executed in
8423 a subshell which exits immediately, you can NOT use !cd to navigate the
8442 a subshell which exits immediately, you can NOT use !cd to navigate the
8424 filesystem.
8443 filesystem.
8425 \end_layout
8444 \end_layout
8426
8445
8427 \begin_layout Standard
8446 \begin_layout Standard
8428 Pysh provides its own builtin
8447 Pysh provides its own builtin
8429 \family typewriter
8448 \family typewriter
8430 `%cd
8449 `%cd
8431 \family default
8450 \family default
8432 ' magic command to move in the filesystem (the
8451 ' magic command to move in the filesystem (the
8433 \family typewriter
8452 \family typewriter
8434 %
8453 %
8435 \family default
8454 \family default
8436 is not required with automagic on).
8455 is not required with automagic on).
8437 It also maintains a list of visited directories (use
8456 It also maintains a list of visited directories (use
8438 \family typewriter
8457 \family typewriter
8439 %dhist
8458 %dhist
8440 \family default
8459 \family default
8441 to see it) and allows direct switching to any of them.
8460 to see it) and allows direct switching to any of them.
8442 Type
8461 Type
8443 \family typewriter
8462 \family typewriter
8444 `cd?
8463 `cd?
8445 \family default
8464 \family default
8446 ' for more details.
8465 ' for more details.
8447 \end_layout
8466 \end_layout
8448
8467
8449 \begin_layout Standard
8468 \begin_layout Standard
8450
8469
8451 \family typewriter
8470 \family typewriter
8452 %pushd
8471 %pushd
8453 \family default
8472 \family default
8454 ,
8473 ,
8455 \family typewriter
8474 \family typewriter
8456 %popd
8475 %popd
8457 \family default
8476 \family default
8458 and
8477 and
8459 \family typewriter
8478 \family typewriter
8460 %dirs
8479 %dirs
8461 \family default
8480 \family default
8462 are provided for directory stack handling.
8481 are provided for directory stack handling.
8463 \end_layout
8482 \end_layout
8464
8483
8465 \begin_layout Subsection
8484 \begin_layout Subsection
8466 Prompt customization
8485 Prompt customization
8467 \end_layout
8486 \end_layout
8468
8487
8469 \begin_layout Standard
8488 \begin_layout Standard
8470 The supplied
8489 The supplied
8471 \family typewriter
8490 \family typewriter
8472 ipythonrc-pysh
8491 ipythonrc-pysh
8473 \family default
8492 \family default
8474 profile comes with an example of a very colored and detailed prompt, mainly
8493 profile comes with an example of a very colored and detailed prompt, mainly
8475 to serve as an illustration.
8494 to serve as an illustration.
8476 The valid escape sequences, besides color names, are:
8495 The valid escape sequences, besides color names, are:
8477 \end_layout
8496 \end_layout
8478
8497
8479 \begin_layout Description
8498 \begin_layout Description
8480
8499
8481 \backslash
8500 \backslash
8482 # - Prompt number.
8501 # - Prompt number.
8483 \end_layout
8502 \end_layout
8484
8503
8485 \begin_layout Description
8504 \begin_layout Description
8486
8505
8487 \backslash
8506 \backslash
8488 D - Dots, as many as there are digits in
8507 D - Dots, as many as there are digits in
8489 \backslash
8508 \backslash
8490 # (so they align).
8509 # (so they align).
8491 \end_layout
8510 \end_layout
8492
8511
8493 \begin_layout Description
8512 \begin_layout Description
8494
8513
8495 \backslash
8514 \backslash
8496 w - Current working directory (cwd).
8515 w - Current working directory (cwd).
8497 \end_layout
8516 \end_layout
8498
8517
8499 \begin_layout Description
8518 \begin_layout Description
8500
8519
8501 \backslash
8520 \backslash
8502 W - Basename of current working directory.
8521 W - Basename of current working directory.
8503 \end_layout
8522 \end_layout
8504
8523
8505 \begin_layout Description
8524 \begin_layout Description
8506
8525
8507 \backslash
8526 \backslash
8508 X
8527 X
8509 \emph on
8528 \emph on
8510 N
8529 N
8511 \emph default
8530 \emph default
8512 - Where
8531 - Where
8513 \emph on
8532 \emph on
8514 N
8533 N
8515 \emph default
8534 \emph default
8516 =0..5.
8535 =0..5.
8517 N terms of the cwd, with $HOME written as ~.
8536 N terms of the cwd, with $HOME written as ~.
8518 \end_layout
8537 \end_layout
8519
8538
8520 \begin_layout Description
8539 \begin_layout Description
8521
8540
8522 \backslash
8541 \backslash
8523 Y
8542 Y
8524 \emph on
8543 \emph on
8525 N
8544 N
8526 \emph default
8545 \emph default
8527 - Where
8546 - Where
8528 \emph on
8547 \emph on
8529 N
8548 N
8530 \emph default
8549 \emph default
8531 =0..5.
8550 =0..5.
8532 Like X
8551 Like X
8533 \emph on
8552 \emph on
8534 N
8553 N
8535 \emph default
8554 \emph default
8536 , but if ~ is term
8555 , but if ~ is term
8537 \emph on
8556 \emph on
8538 N
8557 N
8539 \emph default
8558 \emph default
8540 +1 it's also shown.
8559 +1 it's also shown.
8541 \end_layout
8560 \end_layout
8542
8561
8543 \begin_layout Description
8562 \begin_layout Description
8544
8563
8545 \backslash
8564 \backslash
8546 u - Username.
8565 u - Username.
8547 \end_layout
8566 \end_layout
8548
8567
8549 \begin_layout Description
8568 \begin_layout Description
8550
8569
8551 \backslash
8570 \backslash
8552 H - Full hostname.
8571 H - Full hostname.
8553 \end_layout
8572 \end_layout
8554
8573
8555 \begin_layout Description
8574 \begin_layout Description
8556
8575
8557 \backslash
8576 \backslash
8558 h - Hostname up to first '.'
8577 h - Hostname up to first '.'
8559 \end_layout
8578 \end_layout
8560
8579
8561 \begin_layout Description
8580 \begin_layout Description
8562
8581
8563 \backslash
8582 \backslash
8564 $ - Root symbol ($ or #).
8583 $ - Root symbol ($ or #).
8565
8584
8566 \end_layout
8585 \end_layout
8567
8586
8568 \begin_layout Description
8587 \begin_layout Description
8569
8588
8570 \backslash
8589 \backslash
8571 t - Current time, in H:M:S format.
8590 t - Current time, in H:M:S format.
8572 \end_layout
8591 \end_layout
8573
8592
8574 \begin_layout Description
8593 \begin_layout Description
8575
8594
8576 \backslash
8595 \backslash
8577 v - IPython release version.
8596 v - IPython release version.
8578
8597
8579 \end_layout
8598 \end_layout
8580
8599
8581 \begin_layout Description
8600 \begin_layout Description
8582
8601
8583 \backslash
8602 \backslash
8584 n - Newline.
8603 n - Newline.
8585
8604
8586 \end_layout
8605 \end_layout
8587
8606
8588 \begin_layout Description
8607 \begin_layout Description
8589
8608
8590 \backslash
8609 \backslash
8591 r - Carriage return.
8610 r - Carriage return.
8592
8611
8593 \end_layout
8612 \end_layout
8594
8613
8595 \begin_layout Description
8614 \begin_layout Description
8596
8615
8597 \backslash
8616 \backslash
8598
8617
8599 \backslash
8618 \backslash
8600 - An explicitly escaped '
8619 - An explicitly escaped '
8601 \backslash
8620 \backslash
8602 '.
8621 '.
8603 \end_layout
8622 \end_layout
8604
8623
8605 \begin_layout Standard
8624 \begin_layout Standard
8606 You can configure your prompt colors using any ANSI color escape.
8625 You can configure your prompt colors using any ANSI color escape.
8607 Each color escape sets the color for any subsequent text, until another
8626 Each color escape sets the color for any subsequent text, until another
8608 escape comes in and changes things.
8627 escape comes in and changes things.
8609 The valid color escapes are:
8628 The valid color escapes are:
8610 \end_layout
8629 \end_layout
8611
8630
8612 \begin_layout Description
8631 \begin_layout Description
8613
8632
8614 \backslash
8633 \backslash
8615 C_Black
8634 C_Black
8616 \end_layout
8635 \end_layout
8617
8636
8618 \begin_layout Description
8637 \begin_layout Description
8619
8638
8620 \backslash
8639 \backslash
8621 C_Blue
8640 C_Blue
8622 \end_layout
8641 \end_layout
8623
8642
8624 \begin_layout Description
8643 \begin_layout Description
8625
8644
8626 \backslash
8645 \backslash
8627 C_Brown
8646 C_Brown
8628 \end_layout
8647 \end_layout
8629
8648
8630 \begin_layout Description
8649 \begin_layout Description
8631
8650
8632 \backslash
8651 \backslash
8633 C_Cyan
8652 C_Cyan
8634 \end_layout
8653 \end_layout
8635
8654
8636 \begin_layout Description
8655 \begin_layout Description
8637
8656
8638 \backslash
8657 \backslash
8639 C_DarkGray
8658 C_DarkGray
8640 \end_layout
8659 \end_layout
8641
8660
8642 \begin_layout Description
8661 \begin_layout Description
8643
8662
8644 \backslash
8663 \backslash
8645 C_Green
8664 C_Green
8646 \end_layout
8665 \end_layout
8647
8666
8648 \begin_layout Description
8667 \begin_layout Description
8649
8668
8650 \backslash
8669 \backslash
8651 C_LightBlue
8670 C_LightBlue
8652 \end_layout
8671 \end_layout
8653
8672
8654 \begin_layout Description
8673 \begin_layout Description
8655
8674
8656 \backslash
8675 \backslash
8657 C_LightCyan
8676 C_LightCyan
8658 \end_layout
8677 \end_layout
8659
8678
8660 \begin_layout Description
8679 \begin_layout Description
8661
8680
8662 \backslash
8681 \backslash
8663 C_LightGray
8682 C_LightGray
8664 \end_layout
8683 \end_layout
8665
8684
8666 \begin_layout Description
8685 \begin_layout Description
8667
8686
8668 \backslash
8687 \backslash
8669 C_LightGreen
8688 C_LightGreen
8670 \end_layout
8689 \end_layout
8671
8690
8672 \begin_layout Description
8691 \begin_layout Description
8673
8692
8674 \backslash
8693 \backslash
8675 C_LightPurple
8694 C_LightPurple
8676 \end_layout
8695 \end_layout
8677
8696
8678 \begin_layout Description
8697 \begin_layout Description
8679
8698
8680 \backslash
8699 \backslash
8681 C_LightRed
8700 C_LightRed
8682 \end_layout
8701 \end_layout
8683
8702
8684 \begin_layout Description
8703 \begin_layout Description
8685
8704
8686 \backslash
8705 \backslash
8687 C_Purple
8706 C_Purple
8688 \end_layout
8707 \end_layout
8689
8708
8690 \begin_layout Description
8709 \begin_layout Description
8691
8710
8692 \backslash
8711 \backslash
8693 C_Red
8712 C_Red
8694 \end_layout
8713 \end_layout
8695
8714
8696 \begin_layout Description
8715 \begin_layout Description
8697
8716
8698 \backslash
8717 \backslash
8699 C_White
8718 C_White
8700 \end_layout
8719 \end_layout
8701
8720
8702 \begin_layout Description
8721 \begin_layout Description
8703
8722
8704 \backslash
8723 \backslash
8705 C_Yellow
8724 C_Yellow
8706 \end_layout
8725 \end_layout
8707
8726
8708 \begin_layout Description
8727 \begin_layout Description
8709
8728
8710 \backslash
8729 \backslash
8711 C_Normal Stop coloring, defaults to your terminal settings.
8730 C_Normal Stop coloring, defaults to your terminal settings.
8712 \end_layout
8731 \end_layout
8713
8732
8714 \begin_layout Section
8733 \begin_layout Section
8715 \begin_inset LatexCommand \label{sec:Threading-support}
8734 \begin_inset LatexCommand \label{sec:Threading-support}
8716
8735
8717 \end_inset
8736 \end_inset
8718
8737
8719 Threading support
8738 Threading support
8720 \end_layout
8739 \end_layout
8721
8740
8722 \begin_layout Standard
8741 \begin_layout Standard
8723
8742
8724 \series bold
8743 \series bold
8725 WARNING:
8744 WARNING:
8726 \series default
8745 \series default
8727 The threading support is still somewhat experimental, and it has only seen
8746 The threading support is still somewhat experimental, and it has only seen
8728 reasonable testing under Linux.
8747 reasonable testing under Linux.
8729 Threaded code is particularly tricky to debug, and it tends to show extremely
8748 Threaded code is particularly tricky to debug, and it tends to show extremely
8730 platform-dependent behavior.
8749 platform-dependent behavior.
8731 Since I only have access to Linux machines, I will have to rely on user's
8750 Since I only have access to Linux machines, I will have to rely on user's
8732 experiences and assistance for this area of IPython to improve under other
8751 experiences and assistance for this area of IPython to improve under other
8733 platforms.
8752 platforms.
8734 \end_layout
8753 \end_layout
8735
8754
8736 \begin_layout Standard
8755 \begin_layout Standard
8737 IPython, via the
8756 IPython, via the
8738 \family typewriter
8757 \family typewriter
8739 -gthread
8758 -gthread
8740 \family default
8759 \family default
8741 ,
8760 ,
8742 \family typewriter
8761 \family typewriter
8743 -qthread
8762 -qthread
8744 \family default
8763 \family default
8745 and
8764 and
8746 \family typewriter
8765 \family typewriter
8747 -wthread
8766 -wthread
8748 \family default
8767 \family default
8749 options (described in Sec.\InsetSpace ~
8768 options (described in Sec.\InsetSpace ~
8750
8769
8751 \begin_inset LatexCommand \ref{sec:threading-opts}
8770 \begin_inset LatexCommand \ref{sec:threading-opts}
8752
8771
8753 \end_inset
8772 \end_inset
8754
8773
8755 ), can run in multithreaded mode to support pyGTK, Qt and WXPython applications
8774 ), can run in multithreaded mode to support pyGTK, Qt and WXPython applications
8756 respectively.
8775 respectively.
8757 These GUI toolkits need to control the python main loop of execution, so
8776 These GUI toolkits need to control the python main loop of execution, so
8758 under a normal Python interpreter, starting a pyGTK, Qt or WXPython application
8777 under a normal Python interpreter, starting a pyGTK, Qt or WXPython application
8759 will immediately freeze the shell.
8778 will immediately freeze the shell.
8760
8779
8761 \end_layout
8780 \end_layout
8762
8781
8763 \begin_layout Standard
8782 \begin_layout Standard
8764 IPython, with one of these options (you can only use one at a time), separates
8783 IPython, with one of these options (you can only use one at a time), separates
8765 the graphical loop and IPython's code execution run into different threads.
8784 the graphical loop and IPython's code execution run into different threads.
8766 This allows you to test interactively (with
8785 This allows you to test interactively (with
8767 \family typewriter
8786 \family typewriter
8768 %run
8787 %run
8769 \family default
8788 \family default
8770 , for example) your GUI code without blocking.
8789 , for example) your GUI code without blocking.
8771 \end_layout
8790 \end_layout
8772
8791
8773 \begin_layout Standard
8792 \begin_layout Standard
8774 A nice mini-tutorial on using IPython along with the Qt Designer application
8793 A nice mini-tutorial on using IPython along with the Qt Designer application
8775 is available at the SciPy wiki:
8794 is available at the SciPy wiki:
8776 \begin_inset LatexCommand \htmlurl{http://www.scipy.org/Cookbook/Matplotlib/Qt_with_IPython_and_Designer}
8795 \begin_inset LatexCommand \htmlurl{http://www.scipy.org/Cookbook/Matplotlib/Qt_with_IPython_and_Designer}
8777
8796
8778 \end_inset
8797 \end_inset
8779
8798
8780 .
8799 .
8781 \end_layout
8800 \end_layout
8782
8801
8783 \begin_layout Subsection
8802 \begin_layout Subsection
8784 Tk issues
8803 Tk issues
8785 \end_layout
8804 \end_layout
8786
8805
8787 \begin_layout Standard
8806 \begin_layout Standard
8788 As indicated in Sec.\InsetSpace ~
8807 As indicated in Sec.\InsetSpace ~
8789
8808
8790 \begin_inset LatexCommand \ref{sec:threading-opts}
8809 \begin_inset LatexCommand \ref{sec:threading-opts}
8791
8810
8792 \end_inset
8811 \end_inset
8793
8812
8794 , a special
8813 , a special
8795 \family typewriter
8814 \family typewriter
8796 -tk
8815 -tk
8797 \family default
8816 \family default
8798 option is provided to try and allow Tk graphical applications to coexist
8817 option is provided to try and allow Tk graphical applications to coexist
8799 interactively with WX, Qt or GTK ones.
8818 interactively with WX, Qt or GTK ones.
8800 Whether this works at all, however, is very platform and configuration
8819 Whether this works at all, however, is very platform and configuration
8801 dependent.
8820 dependent.
8802 Please experiment with simple test cases before committing to using this
8821 Please experiment with simple test cases before committing to using this
8803 combination of Tk and GTK/Qt/WX threading in a production environment.
8822 combination of Tk and GTK/Qt/WX threading in a production environment.
8804 \end_layout
8823 \end_layout
8805
8824
8806 \begin_layout Subsection
8825 \begin_layout Subsection
8807 Signals and Threads
8826 Signals and Threads
8808 \end_layout
8827 \end_layout
8809
8828
8810 \begin_layout Standard
8829 \begin_layout Standard
8811 When any of the thread systems (GTK, Qt or WX) are active, either directly
8830 When any of the thread systems (GTK, Qt or WX) are active, either directly
8812 or via
8831 or via
8813 \family typewriter
8832 \family typewriter
8814 -pylab
8833 -pylab
8815 \family default
8834 \family default
8816 with a threaded backend, it is impossible to interrupt long-running Python
8835 with a threaded backend, it is impossible to interrupt long-running Python
8817 code via
8836 code via
8818 \family typewriter
8837 \family typewriter
8819 Ctrl-C
8838 Ctrl-C
8820 \family default
8839 \family default
8821 .
8840 .
8822 IPython can not pass the KeyboardInterrupt exception (or the underlying
8841 IPython can not pass the KeyboardInterrupt exception (or the underlying
8823
8842
8824 \family typewriter
8843 \family typewriter
8825 SIGINT
8844 SIGINT
8826 \family default
8845 \family default
8827 ) across threads, so any long-running process started from IPython will
8846 ) across threads, so any long-running process started from IPython will
8828 run to completion, or will have to be killed via an external (OS-based)
8847 run to completion, or will have to be killed via an external (OS-based)
8829 mechanism.
8848 mechanism.
8830 \end_layout
8849 \end_layout
8831
8850
8832 \begin_layout Standard
8851 \begin_layout Standard
8833 To the best of my knowledge, this limitation is imposed by the Python interprete
8852 To the best of my knowledge, this limitation is imposed by the Python interprete
8834 r itself, and it comes from the difficulty of writing portable signal/threaded
8853 r itself, and it comes from the difficulty of writing portable signal/threaded
8835 code.
8854 code.
8836 If any user is an expert on this topic and can suggest a better solution,
8855 If any user is an expert on this topic and can suggest a better solution,
8837 I would love to hear about it.
8856 I would love to hear about it.
8838 In the IPython sources, look at the
8857 In the IPython sources, look at the
8839 \family typewriter
8858 \family typewriter
8840 Shell.py
8859 Shell.py
8841 \family default
8860 \family default
8842 module, and in particular at the
8861 module, and in particular at the
8843 \family typewriter
8862 \family typewriter
8844 runcode()
8863 runcode()
8845 \family default
8864 \family default
8846 method.
8865 method.
8847
8866
8848 \end_layout
8867 \end_layout
8849
8868
8850 \begin_layout Subsection
8869 \begin_layout Subsection
8851 I/O pitfalls
8870 I/O pitfalls
8852 \end_layout
8871 \end_layout
8853
8872
8854 \begin_layout Standard
8873 \begin_layout Standard
8855 Be mindful that the Python interpreter switches between threads every
8874 Be mindful that the Python interpreter switches between threads every
8856 \begin_inset Formula $N$
8875 \begin_inset Formula $N$
8857 \end_inset
8876 \end_inset
8858
8877
8859 bytecodes, where the default value as of Python\InsetSpace ~
8878 bytecodes, where the default value as of Python\InsetSpace ~
8860 2.3 is
8879 2.3 is
8861 \begin_inset Formula $N=100.$
8880 \begin_inset Formula $N=100.$
8862 \end_inset
8881 \end_inset
8863
8882
8864 This value can be read by using the
8883 This value can be read by using the
8865 \family typewriter
8884 \family typewriter
8866 sys.getcheckinterval()
8885 sys.getcheckinterval()
8867 \family default
8886 \family default
8868 function, and it can be reset via
8887 function, and it can be reset via
8869 \family typewriter
8888 \family typewriter
8870 sys.setcheckinterval(
8889 sys.setcheckinterval(
8871 \emph on
8890 \emph on
8872 N
8891 N
8873 \emph default
8892 \emph default
8874 )
8893 )
8875 \family default
8894 \family default
8876 .
8895 .
8877 This switching of threads can cause subtly confusing effects if one of
8896 This switching of threads can cause subtly confusing effects if one of
8878 your threads is doing file I/O.
8897 your threads is doing file I/O.
8879 In text mode, most systems only flush file buffers when they encounter
8898 In text mode, most systems only flush file buffers when they encounter
8880 a
8899 a
8881 \family typewriter
8900 \family typewriter
8882 `
8901 `
8883 \backslash
8902 \backslash
8884 n'
8903 n'
8885 \family default
8904 \family default
8886 .
8905 .
8887 An instruction as simple as
8906 An instruction as simple as
8888 \family typewriter
8907 \family typewriter
8889
8908
8890 \newline
8909 \newline
8891 \InsetSpace ~
8910 \InsetSpace ~
8892 \InsetSpace ~
8911 \InsetSpace ~
8893 print >> filehandle,
8912 print >> filehandle,
8894 \begin_inset Quotes eld
8913 \begin_inset Quotes eld
8895 \end_inset
8914 \end_inset
8896
8915
8897 hello world
8916 hello world
8898 \begin_inset Quotes erd
8917 \begin_inset Quotes erd
8899 \end_inset
8918 \end_inset
8900
8919
8901
8920
8902 \family default
8921 \family default
8903
8922
8904 \newline
8923 \newline
8905 actually consists of several bytecodes, so it is possible that the newline
8924 actually consists of several bytecodes, so it is possible that the newline
8906 does not reach your file before the next thread switch.
8925 does not reach your file before the next thread switch.
8907 Similarly, if you are writing to a file in binary mode, the file won't
8926 Similarly, if you are writing to a file in binary mode, the file won't
8908 be flushed until the buffer fills, and your other thread may see apparently
8927 be flushed until the buffer fills, and your other thread may see apparently
8909 truncated files.
8928 truncated files.
8910
8929
8911 \end_layout
8930 \end_layout
8912
8931
8913 \begin_layout Standard
8932 \begin_layout Standard
8914 For this reason, if you are using IPython's thread support and have (for
8933 For this reason, if you are using IPython's thread support and have (for
8915 example) a GUI application which will read data generated by files written
8934 example) a GUI application which will read data generated by files written
8916 to from the IPython thread, the safest approach is to open all of your
8935 to from the IPython thread, the safest approach is to open all of your
8917 files in unbuffered mode (the third argument to the
8936 files in unbuffered mode (the third argument to the
8918 \family typewriter
8937 \family typewriter
8919 file/open
8938 file/open
8920 \family default
8939 \family default
8921 function is the buffering value):
8940 function is the buffering value):
8922 \newline
8941 \newline
8923
8942
8924 \family typewriter
8943 \family typewriter
8925 \InsetSpace ~
8944 \InsetSpace ~
8926 \InsetSpace ~
8945 \InsetSpace ~
8927 filehandle = open(filename,mode,0)
8946 filehandle = open(filename,mode,0)
8928 \end_layout
8947 \end_layout
8929
8948
8930 \begin_layout Standard
8949 \begin_layout Standard
8931 This is obviously a brute force way of avoiding race conditions with the
8950 This is obviously a brute force way of avoiding race conditions with the
8932 file buffering.
8951 file buffering.
8933 If you want to do it cleanly, and you have a resource which is being shared
8952 If you want to do it cleanly, and you have a resource which is being shared
8934 by the interactive IPython loop and your GUI thread, you should really
8953 by the interactive IPython loop and your GUI thread, you should really
8935 handle it with thread locking and syncrhonization properties.
8954 handle it with thread locking and syncrhonization properties.
8936 The Python documentation discusses these.
8955 The Python documentation discusses these.
8937 \end_layout
8956 \end_layout
8938
8957
8939 \begin_layout Section
8958 \begin_layout Section
8940 \begin_inset LatexCommand \label{sec:interactive-demos}
8959 \begin_inset LatexCommand \label{sec:interactive-demos}
8941
8960
8942 \end_inset
8961 \end_inset
8943
8962
8944 Interactive demos with IPython
8963 Interactive demos with IPython
8945 \end_layout
8964 \end_layout
8946
8965
8947 \begin_layout Standard
8966 \begin_layout Standard
8948 IPython ships with a basic system for running scripts interactively in sections,
8967 IPython ships with a basic system for running scripts interactively in sections,
8949 useful when presenting code to audiences.
8968 useful when presenting code to audiences.
8950 A few tags embedded in comments (so that the script remains valid Python
8969 A few tags embedded in comments (so that the script remains valid Python
8951 code) divide a file into separate blocks, and the demo can be run one block
8970 code) divide a file into separate blocks, and the demo can be run one block
8952 at a time, with IPython printing (with syntax highlighting) the block before
8971 at a time, with IPython printing (with syntax highlighting) the block before
8953 executing it, and returning to the interactive prompt after each block.
8972 executing it, and returning to the interactive prompt after each block.
8954 The interactive namespace is updated after each block is run with the contents
8973 The interactive namespace is updated after each block is run with the contents
8955 of the demo's namespace.
8974 of the demo's namespace.
8956 \end_layout
8975 \end_layout
8957
8976
8958 \begin_layout Standard
8977 \begin_layout Standard
8959 This allows you to show a piece of code, run it and then execute interactively
8978 This allows you to show a piece of code, run it and then execute interactively
8960 commands based on the variables just created.
8979 commands based on the variables just created.
8961 Once you want to continue, you simply execute the next block of the demo.
8980 Once you want to continue, you simply execute the next block of the demo.
8962 The following listing shows the markup necessary for dividing a script
8981 The following listing shows the markup necessary for dividing a script
8963 into sections for execution as a demo.
8982 into sections for execution as a demo.
8964 \end_layout
8983 \end_layout
8965
8984
8966 \begin_layout Standard
8985 \begin_layout Standard
8967 \begin_inset ERT
8986 \begin_inset ERT
8968 status open
8987 status open
8969
8988
8970 \begin_layout Standard
8989 \begin_layout Standard
8971
8990
8972
8991
8973 \backslash
8992 \backslash
8974 codelist{examples/example-demo.py}
8993 codelist{examples/example-demo.py}
8975 \end_layout
8994 \end_layout
8976
8995
8977 \end_inset
8996 \end_inset
8978
8997
8979
8998
8980 \end_layout
8999 \end_layout
8981
9000
8982 \begin_layout Standard
9001 \begin_layout Standard
8983 In order to run a file as a demo, you must first make a
9002 In order to run a file as a demo, you must first make a
8984 \family typewriter
9003 \family typewriter
8985 Demo
9004 Demo
8986 \family default
9005 \family default
8987 object out of it.
9006 object out of it.
8988 If the file is named
9007 If the file is named
8989 \family typewriter
9008 \family typewriter
8990 myscript.py
9009 myscript.py
8991 \family default
9010 \family default
8992 , the following code will make a demo:
9011 , the following code will make a demo:
8993 \end_layout
9012 \end_layout
8994
9013
8995 \begin_layout LyX-Code
9014 \begin_layout LyX-Code
8996 from IPython.demo import Demo
9015 from IPython.demo import Demo
8997 \end_layout
9016 \end_layout
8998
9017
8999 \begin_layout LyX-Code
9018 \begin_layout LyX-Code
9000 mydemo = Demo('myscript.py')
9019 mydemo = Demo('myscript.py')
9001 \end_layout
9020 \end_layout
9002
9021
9003 \begin_layout Standard
9022 \begin_layout Standard
9004 This creates the
9023 This creates the
9005 \family typewriter
9024 \family typewriter
9006 mydemo
9025 mydemo
9007 \family default
9026 \family default
9008 object, whose blocks you run one at a time by simply calling the object
9027 object, whose blocks you run one at a time by simply calling the object
9009 with no arguments.
9028 with no arguments.
9010 If you have autocall active in IPython (the default), all you need to do
9029 If you have autocall active in IPython (the default), all you need to do
9011 is type
9030 is type
9012 \end_layout
9031 \end_layout
9013
9032
9014 \begin_layout LyX-Code
9033 \begin_layout LyX-Code
9015 mydemo
9034 mydemo
9016 \end_layout
9035 \end_layout
9017
9036
9018 \begin_layout Standard
9037 \begin_layout Standard
9019 and IPython will call it, executing each block.
9038 and IPython will call it, executing each block.
9020 Demo objects can be restarted, you can move forward or back skipping blocks,
9039 Demo objects can be restarted, you can move forward or back skipping blocks,
9021 re-execute the last block, etc.
9040 re-execute the last block, etc.
9022 Simply use the Tab key on a demo object to see its methods, and call
9041 Simply use the Tab key on a demo object to see its methods, and call
9023 \family typewriter
9042 \family typewriter
9024 `?'
9043 `?'
9025 \family default
9044 \family default
9026 on them to see their docstrings for more usage details.
9045 on them to see their docstrings for more usage details.
9027 In addition, the
9046 In addition, the
9028 \family typewriter
9047 \family typewriter
9029 demo
9048 demo
9030 \family default
9049 \family default
9031 module itself contains a comprehensive docstring, which you can access
9050 module itself contains a comprehensive docstring, which you can access
9032 via
9051 via
9033 \end_layout
9052 \end_layout
9034
9053
9035 \begin_layout LyX-Code
9054 \begin_layout LyX-Code
9036 from IPython import demo
9055 from IPython import demo
9037 \end_layout
9056 \end_layout
9038
9057
9039 \begin_layout LyX-Code
9058 \begin_layout LyX-Code
9040 demo?
9059 demo?
9041 \end_layout
9060 \end_layout
9042
9061
9043 \begin_layout Standard
9062 \begin_layout Standard
9044
9063
9045 \series bold
9064 \series bold
9046 Limitations:
9065 Limitations:
9047 \series default
9066 \series default
9048 It is important to note that these demos are limited to fairly simple uses.
9067 It is important to note that these demos are limited to fairly simple uses.
9049 In particular, you can
9068 In particular, you can
9050 \emph on
9069 \emph on
9051 not
9070 not
9052 \emph default
9071 \emph default
9053 put division marks in indented code (loops, if statements, function definitions
9072 put division marks in indented code (loops, if statements, function definitions
9054 , etc.) Supporting something like this would basically require tracking the
9073 , etc.) Supporting something like this would basically require tracking the
9055 internal execution state of the Python interpreter, so only top-level divisions
9074 internal execution state of the Python interpreter, so only top-level divisions
9056 are allowed.
9075 are allowed.
9057 If you want to be able to open an IPython instance at an arbitrary point
9076 If you want to be able to open an IPython instance at an arbitrary point
9058 in a program, you can use IPython's embedding facilities, described in
9077 in a program, you can use IPython's embedding facilities, described in
9059 detail in Sec\SpecialChar \@.
9078 detail in Sec\SpecialChar \@.
9060 \InsetSpace ~
9079 \InsetSpace ~
9061
9080
9062 \begin_inset LatexCommand \ref{sec:embed}
9081 \begin_inset LatexCommand \ref{sec:embed}
9063
9082
9064 \end_inset
9083 \end_inset
9065
9084
9066 .
9085 .
9067 \end_layout
9086 \end_layout
9068
9087
9069 \begin_layout Section
9088 \begin_layout Section
9070 \begin_inset LatexCommand \label{sec:matplotlib-support}
9089 \begin_inset LatexCommand \label{sec:matplotlib-support}
9071
9090
9072 \end_inset
9091 \end_inset
9073
9092
9074 Plotting with
9093 Plotting with
9075 \family typewriter
9094 \family typewriter
9076 matplotlib
9095 matplotlib
9077 \family default
9096 \family default
9078
9097
9079 \end_layout
9098 \end_layout
9080
9099
9081 \begin_layout Standard
9100 \begin_layout Standard
9082 The matplotlib library (
9101 The matplotlib library (
9083 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
9102 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
9084
9103
9085 \end_inset
9104 \end_inset
9086
9105
9087 ) provides high quality 2D plotting for Python.
9106 ) provides high quality 2D plotting for Python.
9088 Matplotlib can produce plots on screen using a variety of GUI toolkits,
9107 Matplotlib can produce plots on screen using a variety of GUI toolkits,
9089 including Tk, GTK and WXPython.
9108 including Tk, GTK and WXPython.
9090 It also provides a number of commands useful for scientific computing,
9109 It also provides a number of commands useful for scientific computing,
9091 all with a syntax compatible with that of the popular Matlab program.
9110 all with a syntax compatible with that of the popular Matlab program.
9092 \end_layout
9111 \end_layout
9093
9112
9094 \begin_layout Standard
9113 \begin_layout Standard
9095 IPython accepts the special option
9114 IPython accepts the special option
9096 \family typewriter
9115 \family typewriter
9097 -pylab
9116 -pylab
9098 \family default
9117 \family default
9099 (Sec.\InsetSpace ~
9118 (Sec.\InsetSpace ~
9100
9119
9101 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
9120 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
9102
9121
9103 \end_inset
9122 \end_inset
9104
9123
9105 ).
9124 ).
9106 This configures it to support matplotlib, honoring the settings in the
9125 This configures it to support matplotlib, honoring the settings in the
9107
9126
9108 \family typewriter
9127 \family typewriter
9109 .matplotlibrc
9128 .matplotlibrc
9110 \family default
9129 \family default
9111 file.
9130 file.
9112 IPython will detect the user's choice of matplotlib GUI backend, and automatica
9131 IPython will detect the user's choice of matplotlib GUI backend, and automatica
9113 lly select the proper threading model to prevent blocking.
9132 lly select the proper threading model to prevent blocking.
9114 It also sets matplotlib in interactive mode and modifies
9133 It also sets matplotlib in interactive mode and modifies
9115 \family typewriter
9134 \family typewriter
9116 %run
9135 %run
9117 \family default
9136 \family default
9118 slightly, so that any matplotlib-based script can be executed using
9137 slightly, so that any matplotlib-based script can be executed using
9119 \family typewriter
9138 \family typewriter
9120 %run
9139 %run
9121 \family default
9140 \family default
9122 and the final
9141 and the final
9123 \family typewriter
9142 \family typewriter
9124 show()
9143 show()
9125 \family default
9144 \family default
9126 command does not block the interactive shell.
9145 command does not block the interactive shell.
9127 \end_layout
9146 \end_layout
9128
9147
9129 \begin_layout Standard
9148 \begin_layout Standard
9130 The
9149 The
9131 \family typewriter
9150 \family typewriter
9132 -pylab
9151 -pylab
9133 \family default
9152 \family default
9134 option must be given first in order for IPython to configure its threading
9153 option must be given first in order for IPython to configure its threading
9135 mode.
9154 mode.
9136 However, you can still issue other options afterwards.
9155 However, you can still issue other options afterwards.
9137 This allows you to have a matplotlib-based environment customized with
9156 This allows you to have a matplotlib-based environment customized with
9138 additional modules using the standard IPython profile mechanism (Sec.\InsetSpace ~
9157 additional modules using the standard IPython profile mechanism (Sec.\InsetSpace ~
9139
9158
9140 \begin_inset LatexCommand \ref{sec:profiles}
9159 \begin_inset LatexCommand \ref{sec:profiles}
9141
9160
9142 \end_inset
9161 \end_inset
9143
9162
9144 ): ``
9163 ): ``
9145 \family typewriter
9164 \family typewriter
9146 ipython -pylab -p myprofile
9165 ipython -pylab -p myprofile
9147 \family default
9166 \family default
9148 '' will load the profile defined in
9167 '' will load the profile defined in
9149 \family typewriter
9168 \family typewriter
9150 ipythonrc-myprofile
9169 ipythonrc-myprofile
9151 \family default
9170 \family default
9152 after configuring matplotlib.
9171 after configuring matplotlib.
9153 \end_layout
9172 \end_layout
9154
9173
9155 \begin_layout Section
9174 \begin_layout Section
9156 \begin_inset LatexCommand \label{sec:Gnuplot}
9175 \begin_inset LatexCommand \label{sec:Gnuplot}
9157
9176
9158 \end_inset
9177 \end_inset
9159
9178
9160 Plotting with
9179 Plotting with
9161 \family typewriter
9180 \family typewriter
9162 Gnuplot
9181 Gnuplot
9163 \end_layout
9182 \end_layout
9164
9183
9165 \begin_layout Standard
9184 \begin_layout Standard
9166 Through the magic extension system described in sec.
9185 Through the magic extension system described in sec.
9167
9186
9168 \begin_inset LatexCommand \ref{sec:magic}
9187 \begin_inset LatexCommand \ref{sec:magic}
9169
9188
9170 \end_inset
9189 \end_inset
9171
9190
9172 , IPython incorporates a mechanism for conveniently interfacing with the
9191 , IPython incorporates a mechanism for conveniently interfacing with the
9173 Gnuplot system (
9192 Gnuplot system (
9174 \begin_inset LatexCommand \htmlurl{http://www.gnuplot.info}
9193 \begin_inset LatexCommand \htmlurl{http://www.gnuplot.info}
9175
9194
9176 \end_inset
9195 \end_inset
9177
9196
9178 ).
9197 ).
9179 Gnuplot is a very complete 2D and 3D plotting package available for many
9198 Gnuplot is a very complete 2D and 3D plotting package available for many
9180 operating systems and commonly included in modern Linux distributions.
9199 operating systems and commonly included in modern Linux distributions.
9181
9200
9182 \end_layout
9201 \end_layout
9183
9202
9184 \begin_layout Standard
9203 \begin_layout Standard
9185 Besides having Gnuplot installed, this functionality requires the
9204 Besides having Gnuplot installed, this functionality requires the
9186 \family typewriter
9205 \family typewriter
9187 Gnuplot.py
9206 Gnuplot.py
9188 \family default
9207 \family default
9189 module for interfacing python with Gnuplot.
9208 module for interfacing python with Gnuplot.
9190 It can be downloaded from:
9209 It can be downloaded from:
9191 \begin_inset LatexCommand \htmlurl{http://gnuplot-py.sourceforge.net}
9210 \begin_inset LatexCommand \htmlurl{http://gnuplot-py.sourceforge.net}
9192
9211
9193 \end_inset
9212 \end_inset
9194
9213
9195 .
9214 .
9196 \end_layout
9215 \end_layout
9197
9216
9198 \begin_layout Subsection
9217 \begin_layout Subsection
9199 Proper Gnuplot configuration
9218 Proper Gnuplot configuration
9200 \end_layout
9219 \end_layout
9201
9220
9202 \begin_layout Standard
9221 \begin_layout Standard
9203 As of version 4.0, Gnuplot has excellent mouse and interactive keyboard support.
9222 As of version 4.0, Gnuplot has excellent mouse and interactive keyboard support.
9204 However, as of
9223 However, as of
9205 \family typewriter
9224 \family typewriter
9206 Gnuplot.py
9225 Gnuplot.py
9207 \family default
9226 \family default
9208 version 1.7, a new option was added to communicate between Python and Gnuplot
9227 version 1.7, a new option was added to communicate between Python and Gnuplot
9209 via FIFOs (pipes).
9228 via FIFOs (pipes).
9210 This mechanism, while fast, also breaks the mouse system.
9229 This mechanism, while fast, also breaks the mouse system.
9211 You must therefore set the variable
9230 You must therefore set the variable
9212 \family typewriter
9231 \family typewriter
9213 prefer_fifo_data
9232 prefer_fifo_data
9214 \family default
9233 \family default
9215 to
9234 to
9216 \family typewriter
9235 \family typewriter
9217 0
9236 0
9218 \family default
9237 \family default
9219 in file
9238 in file
9220 \family typewriter
9239 \family typewriter
9221 gp_unix.py
9240 gp_unix.py
9222 \family default
9241 \family default
9223 if you wish to keep the interactive mouse and keyboard features working
9242 if you wish to keep the interactive mouse and keyboard features working
9224 properly (
9243 properly (
9225 \family typewriter
9244 \family typewriter
9226 prefer_inline_data
9245 prefer_inline_data
9227 \family default
9246 \family default
9228 also must be
9247 also must be
9229 \family typewriter
9248 \family typewriter
9230 0
9249 0
9231 \family default
9250 \family default
9232 , but this is the default so unless you've changed it manually you should
9251 , but this is the default so unless you've changed it manually you should
9233 be fine).
9252 be fine).
9234 \end_layout
9253 \end_layout
9235
9254
9236 \begin_layout Standard
9255 \begin_layout Standard
9237 'Out of the box', Gnuplot is configured with a rather poor set of size,
9256 'Out of the box', Gnuplot is configured with a rather poor set of size,
9238 color and linewidth choices which make the graphs fairly hard to read on
9257 color and linewidth choices which make the graphs fairly hard to read on
9239 modern high-resolution displays (although they work fine on old 640x480
9258 modern high-resolution displays (although they work fine on old 640x480
9240 ones).
9259 ones).
9241 Below is a section of my
9260 Below is a section of my
9242 \family typewriter
9261 \family typewriter
9243 .Xdefaults
9262 .Xdefaults
9244 \family default
9263 \family default
9245 file which I use for having a more convenient Gnuplot setup.
9264 file which I use for having a more convenient Gnuplot setup.
9246 Remember to load it by running
9265 Remember to load it by running
9247 \family typewriter
9266 \family typewriter
9248 `xrdb .Xdefaults`
9267 `xrdb .Xdefaults`
9249 \family default
9268 \family default
9250 :
9269 :
9251 \end_layout
9270 \end_layout
9252
9271
9253 \begin_layout Standard
9272 \begin_layout Standard
9254
9273
9255 \family typewriter
9274 \family typewriter
9256 !******************************************************************
9275 !******************************************************************
9257 \newline
9276 \newline
9258 ! gnuplot
9277 ! gnuplot
9259 options
9278 options
9260 \newline
9279 \newline
9261 ! modify this for a convenient window size
9280 ! modify this for a convenient window size
9262 \newline
9281 \newline
9263 gnuplot*geometry: 780x580
9282 gnuplot*geometry: 780x580
9264 \end_layout
9283 \end_layout
9265
9284
9266 \begin_layout Standard
9285 \begin_layout Standard
9267
9286
9268 \family typewriter
9287 \family typewriter
9269 ! on-screen font (not for PostScript)
9288 ! on-screen font (not for PostScript)
9270 \newline
9289 \newline
9271 gnuplot*font: -misc-fixed-bold-r-normal--15
9290 gnuplot*font: -misc-fixed-bold-r-normal--15
9272 -120-100-100-c-90-iso8859-1
9291 -120-100-100-c-90-iso8859-1
9273 \end_layout
9292 \end_layout
9274
9293
9275 \begin_layout Standard
9294 \begin_layout Standard
9276
9295
9277 \family typewriter
9296 \family typewriter
9278 ! color options
9297 ! color options
9279 \newline
9298 \newline
9280 gnuplot*background: black
9299 gnuplot*background: black
9281 \newline
9300 \newline
9282 gnuplot*textColor: white
9301 gnuplot*textColor: white
9283 \newline
9302 \newline
9284 gnuplot*borderCo
9303 gnuplot*borderCo
9285 lor: white
9304 lor: white
9286 \newline
9305 \newline
9287 gnuplot*axisColor: white
9306 gnuplot*axisColor: white
9288 \newline
9307 \newline
9289 gnuplot*line1Color: red
9308 gnuplot*line1Color: red
9290 \newline
9309 \newline
9291 gnuplot*line2Color:
9310 gnuplot*line2Color:
9292 green
9311 green
9293 \newline
9312 \newline
9294 gnuplot*line3Color: blue
9313 gnuplot*line3Color: blue
9295 \newline
9314 \newline
9296 gnuplot*line4Color: magenta
9315 gnuplot*line4Color: magenta
9297 \newline
9316 \newline
9298 gnuplot*line5Color:
9317 gnuplot*line5Color:
9299 cyan
9318 cyan
9300 \newline
9319 \newline
9301 gnuplot*line6Color: sienna
9320 gnuplot*line6Color: sienna
9302 \newline
9321 \newline
9303 gnuplot*line7Color: orange
9322 gnuplot*line7Color: orange
9304 \newline
9323 \newline
9305 gnuplot*line8Color:
9324 gnuplot*line8Color:
9306 coral
9325 coral
9307 \end_layout
9326 \end_layout
9308
9327
9309 \begin_layout Standard
9328 \begin_layout Standard
9310
9329
9311 \family typewriter
9330 \family typewriter
9312 ! multiplicative factor for point styles
9331 ! multiplicative factor for point styles
9313 \newline
9332 \newline
9314 gnuplot*pointsize: 2
9333 gnuplot*pointsize: 2
9315 \end_layout
9334 \end_layout
9316
9335
9317 \begin_layout Standard
9336 \begin_layout Standard
9318
9337
9319 \family typewriter
9338 \family typewriter
9320 ! line width options (in pixels)
9339 ! line width options (in pixels)
9321 \newline
9340 \newline
9322 gnuplot*borderWidth: 2
9341 gnuplot*borderWidth: 2
9323 \newline
9342 \newline
9324 gnuplot*axisWidth:
9343 gnuplot*axisWidth:
9325 2
9344 2
9326 \newline
9345 \newline
9327 gnuplot*line1Width: 2
9346 gnuplot*line1Width: 2
9328 \newline
9347 \newline
9329 gnuplot*line2Width: 2
9348 gnuplot*line2Width: 2
9330 \newline
9349 \newline
9331 gnuplot*line3Width: 2
9350 gnuplot*line3Width: 2
9332 \newline
9351 \newline
9333 gnuplot*line4Wi
9352 gnuplot*line4Wi
9334 dth: 2
9353 dth: 2
9335 \newline
9354 \newline
9336 gnuplot*line5Width: 2
9355 gnuplot*line5Width: 2
9337 \newline
9356 \newline
9338 gnuplot*line6Width: 2
9357 gnuplot*line6Width: 2
9339 \newline
9358 \newline
9340 gnuplot*line7Width: 2
9359 gnuplot*line7Width: 2
9341 \newline
9360 \newline
9342 gnuplot*lin
9361 gnuplot*lin
9343 e8Width: 2
9362 e8Width: 2
9344 \end_layout
9363 \end_layout
9345
9364
9346 \begin_layout Subsection
9365 \begin_layout Subsection
9347 The
9366 The
9348 \family typewriter
9367 \family typewriter
9349 IPython.GnuplotRuntime
9368 IPython.GnuplotRuntime
9350 \family default
9369 \family default
9351 module
9370 module
9352 \end_layout
9371 \end_layout
9353
9372
9354 \begin_layout Standard
9373 \begin_layout Standard
9355 IPython includes a module called
9374 IPython includes a module called
9356 \family typewriter
9375 \family typewriter
9357 Gnuplot2.py
9376 Gnuplot2.py
9358 \family default
9377 \family default
9359 which extends and improves the default
9378 which extends and improves the default
9360 \family typewriter
9379 \family typewriter
9361 Gnuplot
9380 Gnuplot
9362 \family default
9381 \family default
9363 .
9382 .
9364 \family typewriter
9383 \family typewriter
9365 py
9384 py
9366 \family default
9385 \family default
9367 (which it still relies upon).
9386 (which it still relies upon).
9368 For example, the new
9387 For example, the new
9369 \family typewriter
9388 \family typewriter
9370 plot
9389 plot
9371 \family default
9390 \family default
9372 function adds several improvements to the original making it more convenient
9391 function adds several improvements to the original making it more convenient
9373 for interactive use, and
9392 for interactive use, and
9374 \family typewriter
9393 \family typewriter
9375 hardcopy
9394 hardcopy
9376 \family default
9395 \family default
9377 fixes a bug in the original which under some circumstances blocks the creation
9396 fixes a bug in the original which under some circumstances blocks the creation
9378 of PostScript output.
9397 of PostScript output.
9379 \end_layout
9398 \end_layout
9380
9399
9381 \begin_layout Standard
9400 \begin_layout Standard
9382 For scripting use,
9401 For scripting use,
9383 \family typewriter
9402 \family typewriter
9384 GnuplotRuntime.py
9403 GnuplotRuntime.py
9385 \family default
9404 \family default
9386 is provided, which wraps
9405 is provided, which wraps
9387 \family typewriter
9406 \family typewriter
9388 Gnuplot2.py
9407 Gnuplot2.py
9389 \family default
9408 \family default
9390 and creates a series of global aliases.
9409 and creates a series of global aliases.
9391 These make it easy to control Gnuplot plotting jobs through the Python
9410 These make it easy to control Gnuplot plotting jobs through the Python
9392 language.
9411 language.
9393 \end_layout
9412 \end_layout
9394
9413
9395 \begin_layout Standard
9414 \begin_layout Standard
9396 Below is some example code which illustrates how to configure Gnuplot inside
9415 Below is some example code which illustrates how to configure Gnuplot inside
9397 your own programs but have it available for further interactive use through
9416 your own programs but have it available for further interactive use through
9398 an embedded IPython instance.
9417 an embedded IPython instance.
9399 Simply run this file at a system prompt.
9418 Simply run this file at a system prompt.
9400 This file is provided as
9419 This file is provided as
9401 \family typewriter
9420 \family typewriter
9402 example-gnuplot.py
9421 example-gnuplot.py
9403 \family default
9422 \family default
9404 in the examples directory:
9423 in the examples directory:
9405 \end_layout
9424 \end_layout
9406
9425
9407 \begin_layout Standard
9426 \begin_layout Standard
9408 \begin_inset ERT
9427 \begin_inset ERT
9409 status open
9428 status open
9410
9429
9411 \begin_layout Standard
9430 \begin_layout Standard
9412
9431
9413
9432
9414 \backslash
9433 \backslash
9415 codelist{examples/example-gnuplot.py}
9434 codelist{examples/example-gnuplot.py}
9416 \end_layout
9435 \end_layout
9417
9436
9418 \end_inset
9437 \end_inset
9419
9438
9420
9439
9421 \end_layout
9440 \end_layout
9422
9441
9423 \begin_layout Subsection
9442 \begin_layout Subsection
9424 The
9443 The
9425 \family typewriter
9444 \family typewriter
9426 numeric
9445 numeric
9427 \family default
9446 \family default
9428 profile: a scientific computing environment
9447 profile: a scientific computing environment
9429 \end_layout
9448 \end_layout
9430
9449
9431 \begin_layout Standard
9450 \begin_layout Standard
9432 The
9451 The
9433 \family typewriter
9452 \family typewriter
9434 numeric
9453 numeric
9435 \family default
9454 \family default
9436 IPython profile, which you can activate with
9455 IPython profile, which you can activate with
9437 \family typewriter
9456 \family typewriter
9438 `ipython -p numeric
9457 `ipython -p numeric
9439 \family default
9458 \family default
9440 ' will automatically load the IPython Gnuplot extensions (plus Numeric and
9459 ' will automatically load the IPython Gnuplot extensions (plus Numeric and
9441 other useful things for numerical computing), contained in the
9460 other useful things for numerical computing), contained in the
9442 \family typewriter
9461 \family typewriter
9443 IPython.GnuplotInteractive
9462 IPython.GnuplotInteractive
9444 \family default
9463 \family default
9445 module.
9464 module.
9446 This will create the globals
9465 This will create the globals
9447 \family typewriter
9466 \family typewriter
9448 Gnuplot
9467 Gnuplot
9449 \family default
9468 \family default
9450 (an alias to the improved Gnuplot2 module),
9469 (an alias to the improved Gnuplot2 module),
9451 \family typewriter
9470 \family typewriter
9452 gp
9471 gp
9453 \family default
9472 \family default
9454 (a Gnuplot active instance), the new magic commands
9473 (a Gnuplot active instance), the new magic commands
9455 \family typewriter
9474 \family typewriter
9456 %gpc
9475 %gpc
9457 \family default
9476 \family default
9458 and
9477 and
9459 \family typewriter
9478 \family typewriter
9460 %gp_set_instance
9479 %gp_set_instance
9461 \family default
9480 \family default
9462 and several other convenient globals.
9481 and several other convenient globals.
9463 Type
9482 Type
9464 \family typewriter
9483 \family typewriter
9465 gphelp()
9484 gphelp()
9466 \family default
9485 \family default
9467 for further details.
9486 for further details.
9468 \end_layout
9487 \end_layout
9469
9488
9470 \begin_layout Standard
9489 \begin_layout Standard
9471 This should turn IPython into a convenient environment for numerical computing,
9490 This should turn IPython into a convenient environment for numerical computing,
9472 with all the functions in the NumPy library and the Gnuplot facilities
9491 with all the functions in the NumPy library and the Gnuplot facilities
9473 for plotting.
9492 for plotting.
9474 Further improvements can be obtained by loading the SciPy libraries for
9493 Further improvements can be obtained by loading the SciPy libraries for
9475 scientific computing, available at
9494 scientific computing, available at
9476 \begin_inset LatexCommand \htmlurl{http://scipy.org}
9495 \begin_inset LatexCommand \htmlurl{http://scipy.org}
9477
9496
9478 \end_inset
9497 \end_inset
9479
9498
9480 .
9499 .
9481 \end_layout
9500 \end_layout
9482
9501
9483 \begin_layout Standard
9502 \begin_layout Standard
9484 If you are in the middle of a working session with numerical objects and
9503 If you are in the middle of a working session with numerical objects and
9485 need to plot them but you didn't start the
9504 need to plot them but you didn't start the
9486 \family typewriter
9505 \family typewriter
9487 numeric
9506 numeric
9488 \family default
9507 \family default
9489 profile, you can load these extensions at any time by typing
9508 profile, you can load these extensions at any time by typing
9490 \newline
9509 \newline
9491
9510
9492 \family typewriter
9511 \family typewriter
9493 from IPython.GnuplotInteractive import *
9512 from IPython.GnuplotInteractive import *
9494 \newline
9513 \newline
9495
9514
9496 \family default
9515 \family default
9497 at the IPython prompt.
9516 at the IPython prompt.
9498 This will allow you to keep your objects intact and start using Gnuplot
9517 This will allow you to keep your objects intact and start using Gnuplot
9499 to view them.
9518 to view them.
9500 \end_layout
9519 \end_layout
9501
9520
9502 \begin_layout Section
9521 \begin_layout Section
9503 Reporting bugs
9522 Reporting bugs
9504 \end_layout
9523 \end_layout
9505
9524
9506 \begin_layout Subsection*
9525 \begin_layout Subsection*
9507 Automatic crash reports
9526 Automatic crash reports
9508 \end_layout
9527 \end_layout
9509
9528
9510 \begin_layout Standard
9529 \begin_layout Standard
9511 Ideally, IPython itself shouldn't crash.
9530 Ideally, IPython itself shouldn't crash.
9512 It will catch exceptions produced by you, but bugs in its internals will
9531 It will catch exceptions produced by you, but bugs in its internals will
9513 still crash it.
9532 still crash it.
9514 \end_layout
9533 \end_layout
9515
9534
9516 \begin_layout Standard
9535 \begin_layout Standard
9517 In such a situation, IPython will leave a file named
9536 In such a situation, IPython will leave a file named
9518 \family typewriter
9537 \family typewriter
9519 IPython_crash_report.txt
9538 IPython_crash_report.txt
9520 \family default
9539 \family default
9521 in your IPYTHONDIR directory (that way if crashes happen several times
9540 in your IPYTHONDIR directory (that way if crashes happen several times
9522 it won't litter many directories, the post-mortem file is always located
9541 it won't litter many directories, the post-mortem file is always located
9523 in the same place and new occurrences just overwrite the previous one).
9542 in the same place and new occurrences just overwrite the previous one).
9524 If you can mail this file to the developers (see sec.
9543 If you can mail this file to the developers (see sec.
9525
9544
9526 \begin_inset LatexCommand \ref{sec:credits}
9545 \begin_inset LatexCommand \ref{sec:credits}
9527
9546
9528 \end_inset
9547 \end_inset
9529
9548
9530 for names and addresses), it will help us
9549 for names and addresses), it will help us
9531 \emph on
9550 \emph on
9532 a lot
9551 a lot
9533 \emph default
9552 \emph default
9534 in understanding the cause of the problem and fixing it sooner.
9553 in understanding the cause of the problem and fixing it sooner.
9535 \end_layout
9554 \end_layout
9536
9555
9537 \begin_layout Subsection*
9556 \begin_layout Subsection*
9538 The bug tracker
9557 The bug tracker
9539 \end_layout
9558 \end_layout
9540
9559
9541 \begin_layout Standard
9560 \begin_layout Standard
9542 IPython also has an online bug-tracker, located at
9561 IPython also has an online bug-tracker, located at
9543 \begin_inset LatexCommand \htmlurl{http://projects.scipy.org/ipython/ipython/report/1}
9562 \begin_inset LatexCommand \htmlurl{http://projects.scipy.org/ipython/ipython/report/1}
9544
9563
9545 \end_inset
9564 \end_inset
9546
9565
9547 .
9566 .
9548 In addition to mailing the developers, it would be a good idea to file
9567 In addition to mailing the developers, it would be a good idea to file
9549 a bug report here.
9568 a bug report here.
9550 This will ensure that the issue is properly followed to conclusion.
9569 This will ensure that the issue is properly followed to conclusion.
9551 To report new bugs you will have to register first.
9570 To report new bugs you will have to register first.
9552 \end_layout
9571 \end_layout
9553
9572
9554 \begin_layout Standard
9573 \begin_layout Standard
9555 You can also use this bug tracker to file feature requests.
9574 You can also use this bug tracker to file feature requests.
9556 \end_layout
9575 \end_layout
9557
9576
9558 \begin_layout Section
9577 \begin_layout Section
9559 Brief history
9578 Brief history
9560 \end_layout
9579 \end_layout
9561
9580
9562 \begin_layout Subsection
9581 \begin_layout Subsection
9563 Origins
9582 Origins
9564 \end_layout
9583 \end_layout
9565
9584
9566 \begin_layout Standard
9585 \begin_layout Standard
9567 The current IPython system grew out of the following three projects:
9586 The current IPython system grew out of the following three projects:
9568 \end_layout
9587 \end_layout
9569
9588
9570 \begin_layout List
9589 \begin_layout List
9571 \labelwidthstring 00.00.0000
9590 \labelwidthstring 00.00.0000
9572 ipython by Fernando P
9591 ipython by Fernando P
9573 \begin_inset ERT
9592 \begin_inset ERT
9574 status collapsed
9593 status collapsed
9575
9594
9576 \begin_layout Standard
9595 \begin_layout Standard
9577
9596
9578
9597
9579 \backslash
9598 \backslash
9580 '{e}
9599 '{e}
9581 \end_layout
9600 \end_layout
9582
9601
9583 \end_inset
9602 \end_inset
9584
9603
9585 rez.
9604 rez.
9586 I was working on adding Mathematica-type prompts and a flexible configuration
9605 I was working on adding Mathematica-type prompts and a flexible configuration
9587 system (something better than
9606 system (something better than
9588 \family typewriter
9607 \family typewriter
9589 $PYTHONSTARTUP
9608 $PYTHONSTARTUP
9590 \family default
9609 \family default
9591 ) to the standard Python interactive interpreter.
9610 ) to the standard Python interactive interpreter.
9592 \end_layout
9611 \end_layout
9593
9612
9594 \begin_layout List
9613 \begin_layout List
9595 \labelwidthstring 00.00.0000
9614 \labelwidthstring 00.00.0000
9596 IPP by Janko Hauser.
9615 IPP by Janko Hauser.
9597 Very well organized, great usability.
9616 Very well organized, great usability.
9598 Had an old help system.
9617 Had an old help system.
9599 IPP was used as the `container' code into which I added the functionality
9618 IPP was used as the `container' code into which I added the functionality
9600 from ipython and LazyPython.
9619 from ipython and LazyPython.
9601 \end_layout
9620 \end_layout
9602
9621
9603 \begin_layout List
9622 \begin_layout List
9604 \labelwidthstring 00.00.0000
9623 \labelwidthstring 00.00.0000
9605 LazyPython by Nathan Gray.
9624 LazyPython by Nathan Gray.
9606 Simple but
9625 Simple but
9607 \emph on
9626 \emph on
9608 very
9627 very
9609 \emph default
9628 \emph default
9610 powerful.
9629 powerful.
9611 The quick syntax (auto parens, auto quotes) and verbose/colored tracebacks
9630 The quick syntax (auto parens, auto quotes) and verbose/colored tracebacks
9612 were all taken from here.
9631 were all taken from here.
9613 \end_layout
9632 \end_layout
9614
9633
9615 \begin_layout Standard
9634 \begin_layout Standard
9616 When I found out (see sec.
9635 When I found out (see sec.
9617
9636
9618 \begin_inset LatexCommand \ref{figgins}
9637 \begin_inset LatexCommand \ref{figgins}
9619
9638
9620 \end_inset
9639 \end_inset
9621
9640
9622 ) about IPP and LazyPython I tried to join all three into a unified system.
9641 ) about IPP and LazyPython I tried to join all three into a unified system.
9623 I thought this could provide a very nice working environment, both for
9642 I thought this could provide a very nice working environment, both for
9624 regular programming and scientific computing: shell-like features, IDL/Matlab
9643 regular programming and scientific computing: shell-like features, IDL/Matlab
9625 numerics, Mathematica-type prompt history and great object introspection
9644 numerics, Mathematica-type prompt history and great object introspection
9626 and help facilities.
9645 and help facilities.
9627 I think it worked reasonably well, though it was a lot more work than I
9646 I think it worked reasonably well, though it was a lot more work than I
9628 had initially planned.
9647 had initially planned.
9629 \end_layout
9648 \end_layout
9630
9649
9631 \begin_layout Subsection
9650 \begin_layout Subsection
9632 Current status
9651 Current status
9633 \end_layout
9652 \end_layout
9634
9653
9635 \begin_layout Standard
9654 \begin_layout Standard
9636 The above listed features work, and quite well for the most part.
9655 The above listed features work, and quite well for the most part.
9637 But until a major internal restructuring is done (see below), only bug
9656 But until a major internal restructuring is done (see below), only bug
9638 fixing will be done, no other features will be added (unless very minor
9657 fixing will be done, no other features will be added (unless very minor
9639 and well localized in the cleaner parts of the code).
9658 and well localized in the cleaner parts of the code).
9640 \end_layout
9659 \end_layout
9641
9660
9642 \begin_layout Standard
9661 \begin_layout Standard
9643 IPython consists of some 18000 lines of pure python code, of which roughly
9662 IPython consists of some 18000 lines of pure python code, of which roughly
9644 two thirds is reasonably clean.
9663 two thirds is reasonably clean.
9645 The rest is, messy code which needs a massive restructuring before any
9664 The rest is, messy code which needs a massive restructuring before any
9646 further major work is done.
9665 further major work is done.
9647 Even the messy code is fairly well documented though, and most of the problems
9666 Even the messy code is fairly well documented though, and most of the problems
9648 in the (non-existent) class design are well pointed to by a PyChecker run.
9667 in the (non-existent) class design are well pointed to by a PyChecker run.
9649 So the rewriting work isn't that bad, it will just be time-consuming.
9668 So the rewriting work isn't that bad, it will just be time-consuming.
9650 \end_layout
9669 \end_layout
9651
9670
9652 \begin_layout Subsection
9671 \begin_layout Subsection
9653 Future
9672 Future
9654 \end_layout
9673 \end_layout
9655
9674
9656 \begin_layout Standard
9675 \begin_layout Standard
9657 See the separate
9676 See the separate
9658 \family typewriter
9677 \family typewriter
9659 new_design
9678 new_design
9660 \family default
9679 \family default
9661 document for details.
9680 document for details.
9662 Ultimately, I would like to see IPython become part of the standard Python
9681 Ultimately, I would like to see IPython become part of the standard Python
9663 distribution as a `big brother with batteries' to the standard Python interacti
9682 distribution as a `big brother with batteries' to the standard Python interacti
9664 ve interpreter.
9683 ve interpreter.
9665 But that will never happen with the current state of the code, so all contribut
9684 But that will never happen with the current state of the code, so all contribut
9666 ions are welcome.
9685 ions are welcome.
9667 \end_layout
9686 \end_layout
9668
9687
9669 \begin_layout Section
9688 \begin_layout Section
9670 License
9689 License
9671 \end_layout
9690 \end_layout
9672
9691
9673 \begin_layout Standard
9692 \begin_layout Standard
9674 IPython is released under the terms of the BSD license, whose general form
9693 IPython is released under the terms of the BSD license, whose general form
9675 can be found at:
9694 can be found at:
9676 \begin_inset LatexCommand \htmlurl{http://www.opensource.org/licenses/bsd-license.php}
9695 \begin_inset LatexCommand \htmlurl{http://www.opensource.org/licenses/bsd-license.php}
9677
9696
9678 \end_inset
9697 \end_inset
9679
9698
9680 .
9699 .
9681 The full text of the IPython license is reproduced below:
9700 The full text of the IPython license is reproduced below:
9682 \end_layout
9701 \end_layout
9683
9702
9684 \begin_layout Quote
9703 \begin_layout Quote
9685
9704
9686 \family typewriter
9705 \family typewriter
9687 \size small
9706 \size small
9688 IPython is released under a BSD-type license.
9707 IPython is released under a BSD-type license.
9689 \end_layout
9708 \end_layout
9690
9709
9691 \begin_layout Quote
9710 \begin_layout Quote
9692
9711
9693 \family typewriter
9712 \family typewriter
9694 \size small
9713 \size small
9695 Copyright (c) 2001, 2002, 2003, 2004 Fernando Perez <fperez@colorado.edu>.
9714 Copyright (c) 2001, 2002, 2003, 2004 Fernando Perez <fperez@colorado.edu>.
9696 \end_layout
9715 \end_layout
9697
9716
9698 \begin_layout Quote
9717 \begin_layout Quote
9699
9718
9700 \family typewriter
9719 \family typewriter
9701 \size small
9720 \size small
9702 Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and
9721 Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and
9703 \newline
9722 \newline
9704 Nathaniel Gray <n8gray@ca
9723 Nathaniel Gray <n8gray@ca
9705 ltech.edu>.
9724 ltech.edu>.
9706 \end_layout
9725 \end_layout
9707
9726
9708 \begin_layout Quote
9727 \begin_layout Quote
9709
9728
9710 \family typewriter
9729 \family typewriter
9711 \size small
9730 \size small
9712 All rights reserved.
9731 All rights reserved.
9713 \end_layout
9732 \end_layout
9714
9733
9715 \begin_layout Quote
9734 \begin_layout Quote
9716
9735
9717 \family typewriter
9736 \family typewriter
9718 \size small
9737 \size small
9719 Redistribution and use in source and binary forms, with or without modification,
9738 Redistribution and use in source and binary forms, with or without modification,
9720 are permitted provided that the following conditions are met:
9739 are permitted provided that the following conditions are met:
9721 \end_layout
9740 \end_layout
9722
9741
9723 \begin_layout Quote
9742 \begin_layout Quote
9724
9743
9725 \family typewriter
9744 \family typewriter
9726 \size small
9745 \size small
9727 a.
9746 a.
9728 Redistributions of source code must retain the above copyright notice,
9747 Redistributions of source code must retain the above copyright notice,
9729 this list of conditions and the following disclaimer.
9748 this list of conditions and the following disclaimer.
9730 \end_layout
9749 \end_layout
9731
9750
9732 \begin_layout Quote
9751 \begin_layout Quote
9733
9752
9734 \family typewriter
9753 \family typewriter
9735 \size small
9754 \size small
9736 b.
9755 b.
9737 Redistributions in binary form must reproduce the above copyright notice,
9756 Redistributions in binary form must reproduce the above copyright notice,
9738 this list of conditions and the following disclaimer in the documentation
9757 this list of conditions and the following disclaimer in the documentation
9739 and/or other materials provided with the distribution.
9758 and/or other materials provided with the distribution.
9740 \end_layout
9759 \end_layout
9741
9760
9742 \begin_layout Quote
9761 \begin_layout Quote
9743
9762
9744 \family typewriter
9763 \family typewriter
9745 \size small
9764 \size small
9746 c.
9765 c.
9747 Neither the name of the copyright holders nor the names of any contributors
9766 Neither the name of the copyright holders nor the names of any contributors
9748 to this software may be used to endorse or promote products derived from
9767 to this software may be used to endorse or promote products derived from
9749 this software without specific prior written permission.
9768 this software without specific prior written permission.
9750 \end_layout
9769 \end_layout
9751
9770
9752 \begin_layout Quote
9771 \begin_layout Quote
9753
9772
9754 \family typewriter
9773 \family typewriter
9755 \size small
9774 \size small
9756 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
9775 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
9757 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
9776 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
9758 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
9777 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
9759 PURPOSE ARE DISCLAIMED.
9778 PURPOSE ARE DISCLAIMED.
9760 IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
9779 IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
9761 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
9780 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
9762 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
9781 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
9763 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
9782 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
9764 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
9783 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
9765 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
9784 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
9766 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9785 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9767
9786
9768 \end_layout
9787 \end_layout
9769
9788
9770 \begin_layout Standard
9789 \begin_layout Standard
9771 Individual authors are the holders of the copyright for their code and are
9790 Individual authors are the holders of the copyright for their code and are
9772 listed in each file.
9791 listed in each file.
9773 \end_layout
9792 \end_layout
9774
9793
9775 \begin_layout Standard
9794 \begin_layout Standard
9776 Some files (
9795 Some files (
9777 \family typewriter
9796 \family typewriter
9778 DPyGetOpt.py
9797 DPyGetOpt.py
9779 \family default
9798 \family default
9780 , for example) may be licensed under different conditions.
9799 , for example) may be licensed under different conditions.
9781 Ultimately each file indicates clearly the conditions under which its author/au
9800 Ultimately each file indicates clearly the conditions under which its author/au
9782 thors have decided to publish the code.
9801 thors have decided to publish the code.
9783 \end_layout
9802 \end_layout
9784
9803
9785 \begin_layout Standard
9804 \begin_layout Standard
9786 Versions of IPython up to and including 0.6.3 were released under the GNU
9805 Versions of IPython up to and including 0.6.3 were released under the GNU
9787 Lesser General Public License (LGPL), available at
9806 Lesser General Public License (LGPL), available at
9788 \begin_inset LatexCommand \htmlurl{http://www.gnu.org/copyleft/lesser.html}
9807 \begin_inset LatexCommand \htmlurl{http://www.gnu.org/copyleft/lesser.html}
9789
9808
9790 \end_inset
9809 \end_inset
9791
9810
9792 .
9811 .
9793 \end_layout
9812 \end_layout
9794
9813
9795 \begin_layout Section
9814 \begin_layout Section
9796 \begin_inset LatexCommand \label{sec:credits}
9815 \begin_inset LatexCommand \label{sec:credits}
9797
9816
9798 \end_inset
9817 \end_inset
9799
9818
9800 Credits
9819 Credits
9801 \end_layout
9820 \end_layout
9802
9821
9803 \begin_layout Standard
9822 \begin_layout Standard
9804 IPython is mainly developed by Fernando P
9823 IPython is mainly developed by Fernando P
9805 \begin_inset ERT
9824 \begin_inset ERT
9806 status collapsed
9825 status collapsed
9807
9826
9808 \begin_layout Standard
9827 \begin_layout Standard
9809
9828
9810
9829
9811 \backslash
9830 \backslash
9812 '{e}
9831 '{e}
9813 \end_layout
9832 \end_layout
9814
9833
9815 \end_inset
9834 \end_inset
9816
9835
9817 rez
9836 rez
9818 \family typewriter
9837 \family typewriter
9819 <Fernando.Perez@colorado.edu>
9838 <Fernando.Perez@colorado.edu>
9820 \family default
9839 \family default
9821 , but the project was born from mixing in Fernando's code with the IPP project
9840 , but the project was born from mixing in Fernando's code with the IPP project
9822 by Janko Hauser
9841 by Janko Hauser
9823 \family typewriter
9842 \family typewriter
9824 <jhauser-AT-zscout.de>
9843 <jhauser-AT-zscout.de>
9825 \family default
9844 \family default
9826 and LazyPython by Nathan Gray
9845 and LazyPython by Nathan Gray
9827 \family typewriter
9846 \family typewriter
9828 <n8gray-AT-caltech.edu>
9847 <n8gray-AT-caltech.edu>
9829 \family default
9848 \family default
9830 .
9849 .
9831 For all IPython-related requests, please contact Fernando.
9850 For all IPython-related requests, please contact Fernando.
9832
9851
9833 \end_layout
9852 \end_layout
9834
9853
9835 \begin_layout Standard
9854 \begin_layout Standard
9836 As of early 2006, the following developers have joined the core team:
9855 As of early 2006, the following developers have joined the core team:
9837 \end_layout
9856 \end_layout
9838
9857
9839 \begin_layout List
9858 \begin_layout List
9840 \labelwidthstring 00.00.0000
9859 \labelwidthstring 00.00.0000
9841 Robert\InsetSpace ~
9860 Robert\InsetSpace ~
9842 Kern
9861 Kern
9843 \family typewriter
9862 \family typewriter
9844 <rkern-AT-enthought.com>
9863 <rkern-AT-enthought.com>
9845 \family default
9864 \family default
9846 : co-mentored the 2005 Google Summer of Code project to develop python interacti
9865 : co-mentored the 2005 Google Summer of Code project to develop python interacti
9847 ve notebooks (XML documents) and graphical interface.
9866 ve notebooks (XML documents) and graphical interface.
9848 This project was awarded to the students Tzanko Matev
9867 This project was awarded to the students Tzanko Matev
9849 \family typewriter
9868 \family typewriter
9850 <tsanko-AT-gmail.com>
9869 <tsanko-AT-gmail.com>
9851 \family default
9870 \family default
9852 and Toni Alatalo
9871 and Toni Alatalo
9853 \family typewriter
9872 \family typewriter
9854 <antont-AT-an.org>
9873 <antont-AT-an.org>
9855 \end_layout
9874 \end_layout
9856
9875
9857 \begin_layout List
9876 \begin_layout List
9858 \labelwidthstring 00.00.0000
9877 \labelwidthstring 00.00.0000
9859 Brian\InsetSpace ~
9878 Brian\InsetSpace ~
9860 Granger
9879 Granger
9861 \family typewriter
9880 \family typewriter
9862 <bgranger-AT-scu.edu>
9881 <bgranger-AT-scu.edu>
9863 \family default
9882 \family default
9864 : extending IPython to allow support for interactive parallel computing.
9883 : extending IPython to allow support for interactive parallel computing.
9865 \end_layout
9884 \end_layout
9866
9885
9867 \begin_layout List
9886 \begin_layout List
9868 \labelwidthstring 00.00.0000
9887 \labelwidthstring 00.00.0000
9869 Ville\InsetSpace ~
9888 Ville\InsetSpace ~
9870 Vainio
9889 Vainio
9871 \family typewriter
9890 \family typewriter
9872 <vivainio-AT-gmail.com>
9891 <vivainio-AT-gmail.com>
9873 \family default
9892 \family default
9874 : Ville is the new maintainer for the main trunk of IPython after version
9893 : Ville is the new maintainer for the main trunk of IPython after version
9875 0.7.1.
9894 0.7.1.
9876 \end_layout
9895 \end_layout
9877
9896
9878 \begin_layout Standard
9897 \begin_layout Standard
9879 User or development help should be requested via the IPython mailing lists:
9898 User or development help should be requested via the IPython mailing lists:
9880 \end_layout
9899 \end_layout
9881
9900
9882 \begin_layout Description
9901 \begin_layout Description
9883 User\InsetSpace ~
9902 User\InsetSpace ~
9884 list:
9903 list:
9885 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-user}
9904 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-user}
9886
9905
9887 \end_inset
9906 \end_inset
9888
9907
9889
9908
9890 \end_layout
9909 \end_layout
9891
9910
9892 \begin_layout Description
9911 \begin_layout Description
9893 Developer's\InsetSpace ~
9912 Developer's\InsetSpace ~
9894 list:
9913 list:
9895 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-dev}
9914 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-dev}
9896
9915
9897 \end_inset
9916 \end_inset
9898
9917
9899
9918
9900 \end_layout
9919 \end_layout
9901
9920
9902 \begin_layout Standard
9921 \begin_layout Standard
9903 The IPython project is also very grateful to
9922 The IPython project is also very grateful to
9904 \begin_inset Foot
9923 \begin_inset Foot
9905 status collapsed
9924 status collapsed
9906
9925
9907 \begin_layout Standard
9926 \begin_layout Standard
9908 I've mangled email addresses to reduce spam, since the IPython manuals can
9927 I've mangled email addresses to reduce spam, since the IPython manuals can
9909 be accessed online.
9928 be accessed online.
9910 \end_layout
9929 \end_layout
9911
9930
9912 \end_inset
9931 \end_inset
9913
9932
9914 :
9933 :
9915 \end_layout
9934 \end_layout
9916
9935
9917 \begin_layout Standard
9936 \begin_layout Standard
9918 Bill Bumgarner
9937 Bill Bumgarner
9919 \family typewriter
9938 \family typewriter
9920 <bbum-AT-friday.com>
9939 <bbum-AT-friday.com>
9921 \family default
9940 \family default
9922 : for providing the DPyGetOpt module which gives very powerful and convenient
9941 : for providing the DPyGetOpt module which gives very powerful and convenient
9923 handling of command-line options (light years ahead of what Python 2.1.1's
9942 handling of command-line options (light years ahead of what Python 2.1.1's
9924 getopt module does).
9943 getopt module does).
9925 \end_layout
9944 \end_layout
9926
9945
9927 \begin_layout Standard
9946 \begin_layout Standard
9928 Ka-Ping Yee
9947 Ka-Ping Yee
9929 \family typewriter
9948 \family typewriter
9930 <ping-AT-lfw.org>
9949 <ping-AT-lfw.org>
9931 \family default
9950 \family default
9932 : for providing the Itpl module for convenient and powerful string interpolation
9951 : for providing the Itpl module for convenient and powerful string interpolation
9933 with a much nicer syntax than formatting through the '%' operator.
9952 with a much nicer syntax than formatting through the '%' operator.
9934 \end_layout
9953 \end_layout
9935
9954
9936 \begin_layout Standard
9955 \begin_layout Standard
9937 Arnd Baecker
9956 Arnd Baecker
9938 \family typewriter
9957 \family typewriter
9939 <baecker-AT-physik.tu-dresden.de>
9958 <baecker-AT-physik.tu-dresden.de>
9940 \family default
9959 \family default
9941 : for his many very useful suggestions and comments, and lots of help with
9960 : for his many very useful suggestions and comments, and lots of help with
9942 testing and documentation checking.
9961 testing and documentation checking.
9943 Many of IPython's newer features are a result of discussions with him (bugs
9962 Many of IPython's newer features are a result of discussions with him (bugs
9944 are still my fault, not his).
9963 are still my fault, not his).
9945 \end_layout
9964 \end_layout
9946
9965
9947 \begin_layout Standard
9966 \begin_layout Standard
9948 Obviously Guido van\InsetSpace ~
9967 Obviously Guido van\InsetSpace ~
9949 Rossum and the whole Python development team, that goes
9968 Rossum and the whole Python development team, that goes
9950 without saying.
9969 without saying.
9951 \end_layout
9970 \end_layout
9952
9971
9953 \begin_layout Standard
9972 \begin_layout Standard
9954 IPython's website is generously hosted at
9973 IPython's website is generously hosted at
9955 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
9974 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
9956
9975
9957 \end_inset
9976 \end_inset
9958
9977
9959 by Enthought (
9978 by Enthought (
9960 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
9979 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
9961
9980
9962 \end_inset
9981 \end_inset
9963
9982
9964 ).
9983 ).
9965 I am very grateful to them and all of the SciPy team for their contribution.
9984 I am very grateful to them and all of the SciPy team for their contribution.
9966 \end_layout
9985 \end_layout
9967
9986
9968 \begin_layout Standard
9987 \begin_layout Standard
9969 \begin_inset LatexCommand \label{figgins}
9988 \begin_inset LatexCommand \label{figgins}
9970
9989
9971 \end_inset
9990 \end_inset
9972
9991
9973 Fernando would also like to thank Stephen Figgins
9992 Fernando would also like to thank Stephen Figgins
9974 \family typewriter
9993 \family typewriter
9975 <fig-AT-monitor.net>
9994 <fig-AT-monitor.net>
9976 \family default
9995 \family default
9977 , an O'Reilly Python editor.
9996 , an O'Reilly Python editor.
9978 His Oct/11/2001 article about IPP and LazyPython, was what got this project
9997 His Oct/11/2001 article about IPP and LazyPython, was what got this project
9979 started.
9998 started.
9980 You can read it at:
9999 You can read it at:
9981 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2001/10/11/pythonnews.html}
10000 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2001/10/11/pythonnews.html}
9982
10001
9983 \end_inset
10002 \end_inset
9984
10003
9985 .
10004 .
9986 \end_layout
10005 \end_layout
9987
10006
9988 \begin_layout Standard
10007 \begin_layout Standard
9989 And last but not least, all the kind IPython users who have emailed new
10008 And last but not least, all the kind IPython users who have emailed new
9990 code, bug reports, fixes, comments and ideas.
10009 code, bug reports, fixes, comments and ideas.
9991 A brief list follows, please let me know if I have ommitted your name by
10010 A brief list follows, please let me know if I have ommitted your name by
9992 accident:
10011 accident:
9993 \end_layout
10012 \end_layout
9994
10013
9995 \begin_layout List
10014 \begin_layout List
9996 \labelwidthstring 00.00.0000
10015 \labelwidthstring 00.00.0000
9997 Jack\InsetSpace ~
10016 Jack\InsetSpace ~
9998 Moffit
10017 Moffit
9999 \family typewriter
10018 \family typewriter
10000 <jack-AT-xiph.org>
10019 <jack-AT-xiph.org>
10001 \family default
10020 \family default
10002 Bug fixes, including the infamous color problem.
10021 Bug fixes, including the infamous color problem.
10003 This bug alone caused many lost hours and frustration, many thanks to him
10022 This bug alone caused many lost hours and frustration, many thanks to him
10004 for the fix.
10023 for the fix.
10005 I've always been a fan of Ogg & friends, now I have one more reason to
10024 I've always been a fan of Ogg & friends, now I have one more reason to
10006 like these folks.
10025 like these folks.
10007 \newline
10026 \newline
10008 Jack is also contributing with Debian packaging and many
10027 Jack is also contributing with Debian packaging and many
10009 other things.
10028 other things.
10010 \end_layout
10029 \end_layout
10011
10030
10012 \begin_layout List
10031 \begin_layout List
10013 \labelwidthstring 00.00.0000
10032 \labelwidthstring 00.00.0000
10014 Alexander\InsetSpace ~
10033 Alexander\InsetSpace ~
10015 Schmolck
10034 Schmolck
10016 \family typewriter
10035 \family typewriter
10017 <a.schmolck-AT-gmx.net>
10036 <a.schmolck-AT-gmx.net>
10018 \family default
10037 \family default
10019 Emacs work, bug reports, bug fixes, ideas, lots more.
10038 Emacs work, bug reports, bug fixes, ideas, lots more.
10020 The ipython.el mode for (X)Emacs is Alex's code, providing full support
10039 The ipython.el mode for (X)Emacs is Alex's code, providing full support
10021 for IPython under (X)Emacs.
10040 for IPython under (X)Emacs.
10022 \end_layout
10041 \end_layout
10023
10042
10024 \begin_layout List
10043 \begin_layout List
10025 \labelwidthstring 00.00.0000
10044 \labelwidthstring 00.00.0000
10026 Andrea\InsetSpace ~
10045 Andrea\InsetSpace ~
10027 Riciputi
10046 Riciputi
10028 \family typewriter
10047 \family typewriter
10029 <andrea.riciputi-AT-libero.it>
10048 <andrea.riciputi-AT-libero.it>
10030 \family default
10049 \family default
10031 Mac OSX information, Fink package management.
10050 Mac OSX information, Fink package management.
10032 \end_layout
10051 \end_layout
10033
10052
10034 \begin_layout List
10053 \begin_layout List
10035 \labelwidthstring 00.00.0000
10054 \labelwidthstring 00.00.0000
10036 Gary\InsetSpace ~
10055 Gary\InsetSpace ~
10037 Bishop
10056 Bishop
10038 \family typewriter
10057 \family typewriter
10039 <gb-AT-cs.unc.edu>
10058 <gb-AT-cs.unc.edu>
10040 \family default
10059 \family default
10041 Bug reports, and patches to work around the exception handling idiosyncracies
10060 Bug reports, and patches to work around the exception handling idiosyncracies
10042 of WxPython.
10061 of WxPython.
10043 Readline and color support for Windows.
10062 Readline and color support for Windows.
10044 \end_layout
10063 \end_layout
10045
10064
10046 \begin_layout List
10065 \begin_layout List
10047 \labelwidthstring 00.00.0000
10066 \labelwidthstring 00.00.0000
10048 Jeffrey\InsetSpace ~
10067 Jeffrey\InsetSpace ~
10049 Collins
10068 Collins
10050 \family typewriter
10069 \family typewriter
10051 <Jeff.Collins-AT-vexcel.com>
10070 <Jeff.Collins-AT-vexcel.com>
10052 \family default
10071 \family default
10053 Bug reports.
10072 Bug reports.
10054 Much improved readline support, including fixes for Python 2.3.
10073 Much improved readline support, including fixes for Python 2.3.
10055 \end_layout
10074 \end_layout
10056
10075
10057 \begin_layout List
10076 \begin_layout List
10058 \labelwidthstring 00.00.0000
10077 \labelwidthstring 00.00.0000
10059 Dryice\InsetSpace ~
10078 Dryice\InsetSpace ~
10060 Liu
10079 Liu
10061 \family typewriter
10080 \family typewriter
10062 <dryice-AT-liu.com.cn>
10081 <dryice-AT-liu.com.cn>
10063 \family default
10082 \family default
10064 FreeBSD port.
10083 FreeBSD port.
10065 \end_layout
10084 \end_layout
10066
10085
10067 \begin_layout List
10086 \begin_layout List
10068 \labelwidthstring 00.00.0000
10087 \labelwidthstring 00.00.0000
10069 Mike\InsetSpace ~
10088 Mike\InsetSpace ~
10070 Heeter
10089 Heeter
10071 \family typewriter
10090 \family typewriter
10072 <korora-AT-SDF.LONESTAR.ORG>
10091 <korora-AT-SDF.LONESTAR.ORG>
10073 \end_layout
10092 \end_layout
10074
10093
10075 \begin_layout List
10094 \begin_layout List
10076 \labelwidthstring 00.00.0000
10095 \labelwidthstring 00.00.0000
10077 Christopher\InsetSpace ~
10096 Christopher\InsetSpace ~
10078 Hart
10097 Hart
10079 \family typewriter
10098 \family typewriter
10080 <hart-AT-caltech.edu>
10099 <hart-AT-caltech.edu>
10081 \family default
10100 \family default
10082 PDB integration.
10101 PDB integration.
10083 \end_layout
10102 \end_layout
10084
10103
10085 \begin_layout List
10104 \begin_layout List
10086 \labelwidthstring 00.00.0000
10105 \labelwidthstring 00.00.0000
10087 Milan\InsetSpace ~
10106 Milan\InsetSpace ~
10088 Zamazal
10107 Zamazal
10089 \family typewriter
10108 \family typewriter
10090 <pdm-AT-zamazal.org>
10109 <pdm-AT-zamazal.org>
10091 \family default
10110 \family default
10092 Emacs info.
10111 Emacs info.
10093 \end_layout
10112 \end_layout
10094
10113
10095 \begin_layout List
10114 \begin_layout List
10096 \labelwidthstring 00.00.0000
10115 \labelwidthstring 00.00.0000
10097 Philip\InsetSpace ~
10116 Philip\InsetSpace ~
10098 Hisley
10117 Hisley
10099 \family typewriter
10118 \family typewriter
10100 <compsys-AT-starpower.net>
10119 <compsys-AT-starpower.net>
10101 \end_layout
10120 \end_layout
10102
10121
10103 \begin_layout List
10122 \begin_layout List
10104 \labelwidthstring 00.00.0000
10123 \labelwidthstring 00.00.0000
10105 Holger\InsetSpace ~
10124 Holger\InsetSpace ~
10106 Krekel
10125 Krekel
10107 \family typewriter
10126 \family typewriter
10108 <pyth-AT-devel.trillke.net>
10127 <pyth-AT-devel.trillke.net>
10109 \family default
10128 \family default
10110 Tab completion, lots more.
10129 Tab completion, lots more.
10111 \end_layout
10130 \end_layout
10112
10131
10113 \begin_layout List
10132 \begin_layout List
10114 \labelwidthstring 00.00.0000
10133 \labelwidthstring 00.00.0000
10115 Robin\InsetSpace ~
10134 Robin\InsetSpace ~
10116 Siebler
10135 Siebler
10117 \family typewriter
10136 \family typewriter
10118 <robinsiebler-AT-starband.net>
10137 <robinsiebler-AT-starband.net>
10119 \end_layout
10138 \end_layout
10120
10139
10121 \begin_layout List
10140 \begin_layout List
10122 \labelwidthstring 00.00.0000
10141 \labelwidthstring 00.00.0000
10123 Ralf\InsetSpace ~
10142 Ralf\InsetSpace ~
10124 Ahlbrink
10143 Ahlbrink
10125 \family typewriter
10144 \family typewriter
10126 <ralf_ahlbrink-AT-web.de>
10145 <ralf_ahlbrink-AT-web.de>
10127 \end_layout
10146 \end_layout
10128
10147
10129 \begin_layout List
10148 \begin_layout List
10130 \labelwidthstring 00.00.0000
10149 \labelwidthstring 00.00.0000
10131 Thorsten\InsetSpace ~
10150 Thorsten\InsetSpace ~
10132 Kampe
10151 Kampe
10133 \family typewriter
10152 \family typewriter
10134 <thorsten-AT-thorstenkampe.de>
10153 <thorsten-AT-thorstenkampe.de>
10135 \end_layout
10154 \end_layout
10136
10155
10137 \begin_layout List
10156 \begin_layout List
10138 \labelwidthstring 00.00.0000
10157 \labelwidthstring 00.00.0000
10139 Fredrik\InsetSpace ~
10158 Fredrik\InsetSpace ~
10140 Kant
10159 Kant
10141 \family typewriter
10160 \family typewriter
10142 <fredrik.kant-AT-front.com>
10161 <fredrik.kant-AT-front.com>
10143 \family default
10162 \family default
10144 Windows setup.
10163 Windows setup.
10145 \end_layout
10164 \end_layout
10146
10165
10147 \begin_layout List
10166 \begin_layout List
10148 \labelwidthstring 00.00.0000
10167 \labelwidthstring 00.00.0000
10149 Syver\InsetSpace ~
10168 Syver\InsetSpace ~
10150 Enstad
10169 Enstad
10151 \family typewriter
10170 \family typewriter
10152 <syver-en-AT-online.no>
10171 <syver-en-AT-online.no>
10153 \family default
10172 \family default
10154 Windows setup.
10173 Windows setup.
10155 \end_layout
10174 \end_layout
10156
10175
10157 \begin_layout List
10176 \begin_layout List
10158 \labelwidthstring 00.00.0000
10177 \labelwidthstring 00.00.0000
10159 Richard
10178 Richard
10160 \family typewriter
10179 \family typewriter
10161 <rxe-AT-renre-europe.com>
10180 <rxe-AT-renre-europe.com>
10162 \family default
10181 \family default
10163 Global embedding.
10182 Global embedding.
10164 \end_layout
10183 \end_layout
10165
10184
10166 \begin_layout List
10185 \begin_layout List
10167 \labelwidthstring 00.00.0000
10186 \labelwidthstring 00.00.0000
10168 Hayden\InsetSpace ~
10187 Hayden\InsetSpace ~
10169 Callow
10188 Callow
10170 \family typewriter
10189 \family typewriter
10171 <h.callow-AT-elec.canterbury.ac.nz>
10190 <h.callow-AT-elec.canterbury.ac.nz>
10172 \family default
10191 \family default
10173 Gnuplot.py 1.6 compatibility.
10192 Gnuplot.py 1.6 compatibility.
10174 \end_layout
10193 \end_layout
10175
10194
10176 \begin_layout List
10195 \begin_layout List
10177 \labelwidthstring 00.00.0000
10196 \labelwidthstring 00.00.0000
10178 Leonardo\InsetSpace ~
10197 Leonardo\InsetSpace ~
10179 Santagada
10198 Santagada
10180 \family typewriter
10199 \family typewriter
10181 <retype-AT-terra.com.br>
10200 <retype-AT-terra.com.br>
10182 \family default
10201 \family default
10183 Fixes for Windows installation.
10202 Fixes for Windows installation.
10184 \end_layout
10203 \end_layout
10185
10204
10186 \begin_layout List
10205 \begin_layout List
10187 \labelwidthstring 00.00.0000
10206 \labelwidthstring 00.00.0000
10188 Christopher\InsetSpace ~
10207 Christopher\InsetSpace ~
10189 Armstrong
10208 Armstrong
10190 \family typewriter
10209 \family typewriter
10191 <radix-AT-twistedmatrix.com>
10210 <radix-AT-twistedmatrix.com>
10192 \family default
10211 \family default
10193 Bugfixes.
10212 Bugfixes.
10194 \end_layout
10213 \end_layout
10195
10214
10196 \begin_layout List
10215 \begin_layout List
10197 \labelwidthstring 00.00.0000
10216 \labelwidthstring 00.00.0000
10198 Francois\InsetSpace ~
10217 Francois\InsetSpace ~
10199 Pinard
10218 Pinard
10200 \family typewriter
10219 \family typewriter
10201 <pinard-AT-iro.umontreal.ca>
10220 <pinard-AT-iro.umontreal.ca>
10202 \family default
10221 \family default
10203 Code and documentation fixes.
10222 Code and documentation fixes.
10204 \end_layout
10223 \end_layout
10205
10224
10206 \begin_layout List
10225 \begin_layout List
10207 \labelwidthstring 00.00.0000
10226 \labelwidthstring 00.00.0000
10208 Cory\InsetSpace ~
10227 Cory\InsetSpace ~
10209 Dodt
10228 Dodt
10210 \family typewriter
10229 \family typewriter
10211 <cdodt-AT-fcoe.k12.ca.us>
10230 <cdodt-AT-fcoe.k12.ca.us>
10212 \family default
10231 \family default
10213 Bug reports and Windows ideas.
10232 Bug reports and Windows ideas.
10214 Patches for Windows installer.
10233 Patches for Windows installer.
10215 \end_layout
10234 \end_layout
10216
10235
10217 \begin_layout List
10236 \begin_layout List
10218 \labelwidthstring 00.00.0000
10237 \labelwidthstring 00.00.0000
10219 Olivier\InsetSpace ~
10238 Olivier\InsetSpace ~
10220 Aubert
10239 Aubert
10221 \family typewriter
10240 \family typewriter
10222 <oaubert-AT-bat710.univ-lyon1.fr>
10241 <oaubert-AT-bat710.univ-lyon1.fr>
10223 \family default
10242 \family default
10224 New magics.
10243 New magics.
10225 \end_layout
10244 \end_layout
10226
10245
10227 \begin_layout List
10246 \begin_layout List
10228 \labelwidthstring 00.00.0000
10247 \labelwidthstring 00.00.0000
10229 King\InsetSpace ~
10248 King\InsetSpace ~
10230 C.\InsetSpace ~
10249 C.\InsetSpace ~
10231 Shu
10250 Shu
10232 \family typewriter
10251 \family typewriter
10233 <kingshu-AT-myrealbox.com>
10252 <kingshu-AT-myrealbox.com>
10234 \family default
10253 \family default
10235 Autoindent patch.
10254 Autoindent patch.
10236 \end_layout
10255 \end_layout
10237
10256
10238 \begin_layout List
10257 \begin_layout List
10239 \labelwidthstring 00.00.0000
10258 \labelwidthstring 00.00.0000
10240 Chris\InsetSpace ~
10259 Chris\InsetSpace ~
10241 Drexler
10260 Drexler
10242 \family typewriter
10261 \family typewriter
10243 <chris-AT-ac-drexler.de>
10262 <chris-AT-ac-drexler.de>
10244 \family default
10263 \family default
10245 Readline packages for Win32/CygWin.
10264 Readline packages for Win32/CygWin.
10246 \end_layout
10265 \end_layout
10247
10266
10248 \begin_layout List
10267 \begin_layout List
10249 \labelwidthstring 00.00.0000
10268 \labelwidthstring 00.00.0000
10250 Gustavo\InsetSpace ~
10269 Gustavo\InsetSpace ~
10251 Cordova\InsetSpace ~
10270 Cordova\InsetSpace ~
10252 Avila
10271 Avila
10253 \family typewriter
10272 \family typewriter
10254 <gcordova-AT-sismex.com>
10273 <gcordova-AT-sismex.com>
10255 \family default
10274 \family default
10256 EvalDict code for nice, lightweight string interpolation.
10275 EvalDict code for nice, lightweight string interpolation.
10257 \end_layout
10276 \end_layout
10258
10277
10259 \begin_layout List
10278 \begin_layout List
10260 \labelwidthstring 00.00.0000
10279 \labelwidthstring 00.00.0000
10261 Kasper\InsetSpace ~
10280 Kasper\InsetSpace ~
10262 Souren
10281 Souren
10263 \family typewriter
10282 \family typewriter
10264 <Kasper.Souren-AT-ircam.fr>
10283 <Kasper.Souren-AT-ircam.fr>
10265 \family default
10284 \family default
10266 Bug reports, ideas.
10285 Bug reports, ideas.
10267 \end_layout
10286 \end_layout
10268
10287
10269 \begin_layout List
10288 \begin_layout List
10270 \labelwidthstring 00.00.0000
10289 \labelwidthstring 00.00.0000
10271 Gever\InsetSpace ~
10290 Gever\InsetSpace ~
10272 Tulley
10291 Tulley
10273 \family typewriter
10292 \family typewriter
10274 <gever-AT-helium.com>
10293 <gever-AT-helium.com>
10275 \family default
10294 \family default
10276 Code contributions.
10295 Code contributions.
10277 \end_layout
10296 \end_layout
10278
10297
10279 \begin_layout List
10298 \begin_layout List
10280 \labelwidthstring 00.00.0000
10299 \labelwidthstring 00.00.0000
10281 Ralf\InsetSpace ~
10300 Ralf\InsetSpace ~
10282 Schmitt
10301 Schmitt
10283 \family typewriter
10302 \family typewriter
10284 <ralf-AT-brainbot.com>
10303 <ralf-AT-brainbot.com>
10285 \family default
10304 \family default
10286 Bug reports & fixes.
10305 Bug reports & fixes.
10287 \end_layout
10306 \end_layout
10288
10307
10289 \begin_layout List
10308 \begin_layout List
10290 \labelwidthstring 00.00.0000
10309 \labelwidthstring 00.00.0000
10291 Oliver\InsetSpace ~
10310 Oliver\InsetSpace ~
10292 Sander
10311 Sander
10293 \family typewriter
10312 \family typewriter
10294 <osander-AT-gmx.de>
10313 <osander-AT-gmx.de>
10295 \family default
10314 \family default
10296 Bug reports.
10315 Bug reports.
10297 \end_layout
10316 \end_layout
10298
10317
10299 \begin_layout List
10318 \begin_layout List
10300 \labelwidthstring 00.00.0000
10319 \labelwidthstring 00.00.0000
10301 Rod\InsetSpace ~
10320 Rod\InsetSpace ~
10302 Holland
10321 Holland
10303 \family typewriter
10322 \family typewriter
10304 <rhh-AT-structurelabs.com>
10323 <rhh-AT-structurelabs.com>
10305 \family default
10324 \family default
10306 Bug reports and fixes to logging module.
10325 Bug reports and fixes to logging module.
10307 \end_layout
10326 \end_layout
10308
10327
10309 \begin_layout List
10328 \begin_layout List
10310 \labelwidthstring 00.00.0000
10329 \labelwidthstring 00.00.0000
10311 Daniel\InsetSpace ~
10330 Daniel\InsetSpace ~
10312 'Dang'\InsetSpace ~
10331 'Dang'\InsetSpace ~
10313 Griffith
10332 Griffith
10314 \family typewriter
10333 \family typewriter
10315 <pythondev-dang-AT-lazytwinacres.net>
10334 <pythondev-dang-AT-lazytwinacres.net>
10316 \family default
10335 \family default
10317 Fixes, enhancement suggestions for system shell use.
10336 Fixes, enhancement suggestions for system shell use.
10318 \end_layout
10337 \end_layout
10319
10338
10320 \begin_layout List
10339 \begin_layout List
10321 \labelwidthstring 00.00.0000
10340 \labelwidthstring 00.00.0000
10322 Viktor\InsetSpace ~
10341 Viktor\InsetSpace ~
10323 Ransmayr
10342 Ransmayr
10324 \family typewriter
10343 \family typewriter
10325 <viktor.ransmayr-AT-t-online.de>
10344 <viktor.ransmayr-AT-t-online.de>
10326 \family default
10345 \family default
10327 Tests and reports on Windows installation issues.
10346 Tests and reports on Windows installation issues.
10328 Contributed a true Windows binary installer.
10347 Contributed a true Windows binary installer.
10329 \end_layout
10348 \end_layout
10330
10349
10331 \begin_layout List
10350 \begin_layout List
10332 \labelwidthstring 00.00.0000
10351 \labelwidthstring 00.00.0000
10333 Mike\InsetSpace ~
10352 Mike\InsetSpace ~
10334 Salib
10353 Salib
10335 \family typewriter
10354 \family typewriter
10336 <msalib-AT-mit.edu>
10355 <msalib-AT-mit.edu>
10337 \family default
10356 \family default
10338 Help fixing a subtle bug related to traceback printing.
10357 Help fixing a subtle bug related to traceback printing.
10339 \end_layout
10358 \end_layout
10340
10359
10341 \begin_layout List
10360 \begin_layout List
10342 \labelwidthstring 00.00.0000
10361 \labelwidthstring 00.00.0000
10343 W.J.\InsetSpace ~
10362 W.J.\InsetSpace ~
10344 van\InsetSpace ~
10363 van\InsetSpace ~
10345 der\InsetSpace ~
10364 der\InsetSpace ~
10346 Laan
10365 Laan
10347 \family typewriter
10366 \family typewriter
10348 <gnufnork-AT-hetdigitalegat.nl>
10367 <gnufnork-AT-hetdigitalegat.nl>
10349 \family default
10368 \family default
10350 Bash-like prompt specials.
10369 Bash-like prompt specials.
10351 \end_layout
10370 \end_layout
10352
10371
10353 \begin_layout List
10372 \begin_layout List
10354 \labelwidthstring 00.00.0000
10373 \labelwidthstring 00.00.0000
10355 Antoon\InsetSpace ~
10374 Antoon\InsetSpace ~
10356 Pardon
10375 Pardon
10357 \family typewriter
10376 \family typewriter
10358 <Antoon.Pardon-AT-rece.vub.ac.be>
10377 <Antoon.Pardon-AT-rece.vub.ac.be>
10359 \family default
10378 \family default
10360 Critical fix for the multithreaded IPython.
10379 Critical fix for the multithreaded IPython.
10361 \end_layout
10380 \end_layout
10362
10381
10363 \begin_layout List
10382 \begin_layout List
10364 \labelwidthstring 00.00.0000
10383 \labelwidthstring 00.00.0000
10365 John\InsetSpace ~
10384 John\InsetSpace ~
10366 Hunter
10385 Hunter
10367 \family typewriter
10386 \family typewriter
10368 <jdhunter-AT-nitace.bsd.uchicago.edu>
10387 <jdhunter-AT-nitace.bsd.uchicago.edu>
10369 \family default
10388 \family default
10370 Matplotlib author, helped with all the development of support for matplotlib
10389 Matplotlib author, helped with all the development of support for matplotlib
10371 in IPyhton, including making necessary changes to matplotlib itself.
10390 in IPyhton, including making necessary changes to matplotlib itself.
10372 \end_layout
10391 \end_layout
10373
10392
10374 \begin_layout List
10393 \begin_layout List
10375 \labelwidthstring 00.00.0000
10394 \labelwidthstring 00.00.0000
10376 Matthew\InsetSpace ~
10395 Matthew\InsetSpace ~
10377 Arnison
10396 Arnison
10378 \family typewriter
10397 \family typewriter
10379 <maffew-AT-cat.org.au>
10398 <maffew-AT-cat.org.au>
10380 \family default
10399 \family default
10381 Bug reports, `
10400 Bug reports, `
10382 \family typewriter
10401 \family typewriter
10383 %run -d
10402 %run -d
10384 \family default
10403 \family default
10385 ' idea.
10404 ' idea.
10386 \end_layout
10405 \end_layout
10387
10406
10388 \begin_layout List
10407 \begin_layout List
10389 \labelwidthstring 00.00.0000
10408 \labelwidthstring 00.00.0000
10390 Prabhu\InsetSpace ~
10409 Prabhu\InsetSpace ~
10391 Ramachandran
10410 Ramachandran
10392 \family typewriter
10411 \family typewriter
10393 <prabhu_r-AT-users.sourceforge.net>
10412 <prabhu_r-AT-users.sourceforge.net>
10394 \family default
10413 \family default
10395 Help with (X)Emacs support, threading patches, ideas...
10414 Help with (X)Emacs support, threading patches, ideas...
10396 \end_layout
10415 \end_layout
10397
10416
10398 \begin_layout List
10417 \begin_layout List
10399 \labelwidthstring 00.00.0000
10418 \labelwidthstring 00.00.0000
10400 Norbert\InsetSpace ~
10419 Norbert\InsetSpace ~
10401 Tretkowski
10420 Tretkowski
10402 \family typewriter
10421 \family typewriter
10403 <tretkowski-AT-inittab.de>
10422 <tretkowski-AT-inittab.de>
10404 \family default
10423 \family default
10405 help with Debian packaging and distribution.
10424 help with Debian packaging and distribution.
10406 \end_layout
10425 \end_layout
10407
10426
10408 \begin_layout List
10427 \begin_layout List
10409 \labelwidthstring 00.00.0000
10428 \labelwidthstring 00.00.0000
10410 George\InsetSpace ~
10429 George\InsetSpace ~
10411 Sakkis <
10430 Sakkis <
10412 \family typewriter
10431 \family typewriter
10413 gsakkis-AT-eden.rutgers.edu>
10432 gsakkis-AT-eden.rutgers.edu>
10414 \family default
10433 \family default
10415 New matcher for tab-completing named arguments of user-defined functions.
10434 New matcher for tab-completing named arguments of user-defined functions.
10416 \end_layout
10435 \end_layout
10417
10436
10418 \begin_layout List
10437 \begin_layout List
10419 \labelwidthstring 00.00.0000
10438 \labelwidthstring 00.00.0000
10420 JοΏ½rgen\InsetSpace ~
10439 JοΏ½rgen\InsetSpace ~
10421 Stenarson
10440 Stenarson
10422 \family typewriter
10441 \family typewriter
10423 <jorgen.stenarson-AT-bostream.nu>
10442 <jorgen.stenarson-AT-bostream.nu>
10424 \family default
10443 \family default
10425 Wildcard support implementation for searching namespaces.
10444 Wildcard support implementation for searching namespaces.
10426 \end_layout
10445 \end_layout
10427
10446
10428 \begin_layout List
10447 \begin_layout List
10429 \labelwidthstring 00.00.0000
10448 \labelwidthstring 00.00.0000
10430 Vivian\InsetSpace ~
10449 Vivian\InsetSpace ~
10431 De\InsetSpace ~
10450 De\InsetSpace ~
10432 Smedt
10451 Smedt
10433 \family typewriter
10452 \family typewriter
10434 <vivian-AT-vdesmedt.com>
10453 <vivian-AT-vdesmedt.com>
10435 \family default
10454 \family default
10436 Debugger enhancements, so that when pdb is activated from within IPython,
10455 Debugger enhancements, so that when pdb is activated from within IPython,
10437 coloring, tab completion and other features continue to work seamlessly.
10456 coloring, tab completion and other features continue to work seamlessly.
10438 \end_layout
10457 \end_layout
10439
10458
10440 \begin_layout List
10459 \begin_layout List
10441 \labelwidthstring 00.00.0000
10460 \labelwidthstring 00.00.0000
10442 Scott\InsetSpace ~
10461 Scott\InsetSpace ~
10443 Tsai
10462 Tsai
10444 \family typewriter
10463 \family typewriter
10445 <scottt958-AT-yahoo.com.tw>
10464 <scottt958-AT-yahoo.com.tw>
10446 \family default
10465 \family default
10447 Support for automatic editor invocation on syntax errors (see
10466 Support for automatic editor invocation on syntax errors (see
10448 \begin_inset LatexCommand \htmlurl{http://www.scipy.net/roundup/ipython/issue36}
10467 \begin_inset LatexCommand \htmlurl{http://www.scipy.net/roundup/ipython/issue36}
10449
10468
10450 \end_inset
10469 \end_inset
10451
10470
10452 ).
10471 ).
10453 \end_layout
10472 \end_layout
10454
10473
10455 \begin_layout List
10474 \begin_layout List
10456 \labelwidthstring 00.00.0000
10475 \labelwidthstring 00.00.0000
10457 Alexander\InsetSpace ~
10476 Alexander\InsetSpace ~
10458 Belchenko
10477 Belchenko
10459 \family typewriter
10478 \family typewriter
10460 <bialix-AT-ukr.net>
10479 <bialix-AT-ukr.net>
10461 \family default
10480 \family default
10462 Improvements for win32 paging system.
10481 Improvements for win32 paging system.
10463 \end_layout
10482 \end_layout
10464
10483
10465 \begin_layout List
10484 \begin_layout List
10466 \labelwidthstring 00.00.0000
10485 \labelwidthstring 00.00.0000
10467 Will\InsetSpace ~
10486 Will\InsetSpace ~
10468 Maier
10487 Maier
10469 \family typewriter
10488 \family typewriter
10470 <willmaier-AT-ml1.net>
10489 <willmaier-AT-ml1.net>
10471 \family default
10490 \family default
10472 Official OpenBSD port.
10491 Official OpenBSD port.
10473 \end_layout
10492 \end_layout
10474
10493
10475 \end_body
10494 \end_body
10476 \end_document
10495 \end_document
@@ -1,173 +1,172 b''
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
2 # -*- coding: utf-8 -*-
3 """Setup script for IPython.
3 """Setup script for IPython.
4
4
5 Under Posix environments it works like a typical setup.py script.
5 Under Posix environments it works like a typical setup.py script.
6 Under Windows, the command sdist is not supported, since IPython
6 Under Windows, the command sdist is not supported, since IPython
7 requires utilities, which are not available under Windows."""
7 requires utilities, which are not available under Windows."""
8
8
9 #*****************************************************************************
9 #*****************************************************************************
10 # Copyright (C) 2001-2005 Fernando Perez <fperez@colorado.edu>
10 # Copyright (C) 2001-2005 Fernando Perez <fperez@colorado.edu>
11 #
11 #
12 # Distributed under the terms of the BSD License. The full license is in
12 # Distributed under the terms of the BSD License. The full license is in
13 # the file COPYING, distributed as part of this software.
13 # the file COPYING, distributed as part of this software.
14 #*****************************************************************************
14 #*****************************************************************************
15
15
16 import sys, os
16 import sys, os
17 from glob import glob
17 from glob import glob
18 from setupext import install_data_ext
18 from setupext import install_data_ext
19 isfile = os.path.isfile
19 isfile = os.path.isfile
20
20
21 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
21 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
22 # update it when the contents of directories change.
22 # update it when the contents of directories change.
23 if os.path.exists('MANIFEST'): os.remove('MANIFEST')
23 if os.path.exists('MANIFEST'): os.remove('MANIFEST')
24
24
25 if os.name == 'posix':
25 if os.name == 'posix':
26 os_name = 'posix'
26 os_name = 'posix'
27 elif os.name in ['nt','dos']:
27 elif os.name in ['nt','dos']:
28 os_name = 'windows'
28 os_name = 'windows'
29 else:
29 else:
30 print 'Unsupported operating system:',os.name
30 print 'Unsupported operating system:',os.name
31 sys.exit(1)
31 sys.exit(1)
32
32
33 # Under Windows, 'sdist' is not supported, since it requires lyxport (and
33 # Under Windows, 'sdist' is not supported, since it requires lyxport (and
34 # hence lyx,perl,latex,pdflatex,latex2html,sh,...)
34 # hence lyx,perl,latex,pdflatex,latex2html,sh,...)
35 if os_name == 'windows' and 'sdist' in sys.argv:
35 if os_name == 'windows' and 'sdist' in sys.argv:
36 print 'The sdist command is not available under Windows. Exiting.'
36 print 'The sdist command is not available under Windows. Exiting.'
37 sys.exit(1)
37 sys.exit(1)
38
38
39 from distutils.core import setup
39 from distutils.core import setup
40
40
41 # update the manuals when building a source dist
41 # update the manuals when building a source dist
42 if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'):
42 if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'):
43 from IPython.genutils import target_update
43 from IPython.genutils import target_update
44 # list of things to be updated. Each entry is a triplet of args for
44 # list of things to be updated. Each entry is a triplet of args for
45 # target_update()
45 # target_update()
46 to_update = [('doc/magic.tex',
46 to_update = [('doc/magic.tex',
47 ['IPython/Magic.py'],
47 ['IPython/Magic.py'],
48 "cd doc && ./update_magic.sh" ),
48 "cd doc && ./update_magic.sh" ),
49
49
50 ('doc/manual.lyx',
50 ('doc/manual.lyx',
51 ['IPython/Release.py','doc/manual_base.lyx'],
51 ['IPython/Release.py','doc/manual_base.lyx'],
52 "cd doc && ./update_version.sh" ),
52 "cd doc && ./update_version.sh" ),
53
53
54 ('doc/manual/manual.html',
54 ('doc/manual/manual.html',
55 ['doc/manual.lyx',
55 ['doc/manual.lyx',
56 'doc/magic.tex',
56 'doc/magic.tex',
57 'doc/examples/example-gnuplot.py',
57 'doc/examples/example-gnuplot.py',
58 'doc/examples/example-magic.py',
59 'doc/examples/example-embed.py',
58 'doc/examples/example-embed.py',
60 'doc/examples/example-embed-short.py',
59 'doc/examples/example-embed-short.py',
61 'IPython/UserConfig/ipythonrc',
60 'IPython/UserConfig/ipythonrc',
62 ],
61 ],
63 "cd doc && "
62 "cd doc && "
64 "lyxport -tt --leave --pdf "
63 "lyxport -tt --leave --pdf "
65 "--html -o '-noinfo -split +1 -local_icons' manual.lyx"),
64 "--html -o '-noinfo -split +1 -local_icons' manual.lyx"),
66
65
67 ('doc/new_design.pdf',
66 ('doc/new_design.pdf',
68 ['doc/new_design.lyx'],
67 ['doc/new_design.lyx'],
69 "cd doc && lyxport -tt --pdf new_design.lyx"),
68 "cd doc && lyxport -tt --pdf new_design.lyx"),
70
69
71 ('doc/ipython.1.gz',
70 ('doc/ipython.1.gz',
72 ['doc/ipython.1'],
71 ['doc/ipython.1'],
73 "cd doc && gzip -9c ipython.1 > ipython.1.gz"),
72 "cd doc && gzip -9c ipython.1 > ipython.1.gz"),
74
73
75 ('doc/pycolor.1.gz',
74 ('doc/pycolor.1.gz',
76 ['doc/pycolor.1'],
75 ['doc/pycolor.1'],
77 "cd doc && gzip -9c pycolor.1 > pycolor.1.gz"),
76 "cd doc && gzip -9c pycolor.1 > pycolor.1.gz"),
78 ]
77 ]
79 for target in to_update:
78 for target in to_update:
80 target_update(*target)
79 target_update(*target)
81
80
82 # Release.py contains version, authors, license, url, keywords, etc.
81 # Release.py contains version, authors, license, url, keywords, etc.
83 execfile(os.path.join('IPython','Release.py'))
82 execfile(os.path.join('IPython','Release.py'))
84
83
85 # A little utility we'll need below, since glob() does NOT allow you to do
84 # A little utility we'll need below, since glob() does NOT allow you to do
86 # exclusion on multiple endings!
85 # exclusion on multiple endings!
87 def file_doesnt_endwith(test,endings):
86 def file_doesnt_endwith(test,endings):
88 """Return true if test is a file and its name does NOT end with any
87 """Return true if test is a file and its name does NOT end with any
89 of the strings listed in endings."""
88 of the strings listed in endings."""
90 if not isfile(test):
89 if not isfile(test):
91 return False
90 return False
92 for e in endings:
91 for e in endings:
93 if test.endswith(e):
92 if test.endswith(e):
94 return False
93 return False
95 return True
94 return True
96
95
97 # I can't find how to make distutils create a nested dir. structure, so
96 # I can't find how to make distutils create a nested dir. structure, so
98 # in the meantime do it manually. Butt ugly.
97 # in the meantime do it manually. Butt ugly.
99 # Note that http://www.redbrick.dcu.ie/~noel/distutils.html, ex. 2/3, contain
98 # Note that http://www.redbrick.dcu.ie/~noel/distutils.html, ex. 2/3, contain
100 # information on how to do this more cleanly once python 2.4 can be assumed.
99 # information on how to do this more cleanly once python 2.4 can be assumed.
101 # Thanks to Noel for the tip.
100 # Thanks to Noel for the tip.
102 docdirbase = 'share/doc/ipython-%s' % version
101 docdirbase = 'share/doc/ipython-%s' % version
103 manpagebase = 'share/man/man1'
102 manpagebase = 'share/man/man1'
104
103
105 # We only need to exclude from this things NOT already excluded in the
104 # We only need to exclude from this things NOT already excluded in the
106 # MANIFEST.in file.
105 # MANIFEST.in file.
107 exclude = ('.sh','.1.gz')
106 exclude = ('.sh','.1.gz')
108 docfiles = filter(lambda f:file_doesnt_endwith(f,exclude),glob('doc/*'))
107 docfiles = filter(lambda f:file_doesnt_endwith(f,exclude),glob('doc/*'))
109
108
110 examfiles = filter(isfile, glob('doc/examples/*.py'))
109 examfiles = filter(isfile, glob('doc/examples/*.py'))
111 manfiles = filter(isfile, glob('doc/manual/*.html')) + \
110 manfiles = filter(isfile, glob('doc/manual/*.html')) + \
112 filter(isfile, glob('doc/manual/*.css')) + \
111 filter(isfile, glob('doc/manual/*.css')) + \
113 filter(isfile, glob('doc/manual/*.png'))
112 filter(isfile, glob('doc/manual/*.png'))
114 manpages = filter(isfile, glob('doc/*.1.gz'))
113 manpages = filter(isfile, glob('doc/*.1.gz'))
115 cfgfiles = filter(isfile, glob('IPython/UserConfig/*'))
114 cfgfiles = filter(isfile, glob('IPython/UserConfig/*'))
116 scriptfiles = filter(isfile, ['scripts/ipython','scripts/pycolor',
115 scriptfiles = filter(isfile, ['scripts/ipython','scripts/pycolor',
117 'scripts/irunner'])
116 'scripts/irunner'])
118 igridhelpfiles = filter(isfile, glob('IPython/Extensions/igrid_help.*'))
117 igridhelpfiles = filter(isfile, glob('IPython/Extensions/igrid_help.*'))
119
118
120 # Script to be run by the windows binary installer after the default setup
119 # Script to be run by the windows binary installer after the default setup
121 # routine, to add shortcuts and similar windows-only things. Windows
120 # routine, to add shortcuts and similar windows-only things. Windows
122 # post-install scripts MUST reside in the scripts/ dir, otherwise distutils
121 # post-install scripts MUST reside in the scripts/ dir, otherwise distutils
123 # doesn't find them.
122 # doesn't find them.
124 if 'bdist_wininst' in sys.argv:
123 if 'bdist_wininst' in sys.argv:
125 if len(sys.argv) > 2 and ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
124 if len(sys.argv) > 2 and ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
126 print >> sys.stderr,"ERROR: bdist_wininst must be run alone. Exiting."
125 print >> sys.stderr,"ERROR: bdist_wininst must be run alone. Exiting."
127 sys.exit(1)
126 sys.exit(1)
128 scriptfiles.append('scripts/ipython_win_post_install.py')
127 scriptfiles.append('scripts/ipython_win_post_install.py')
129
128
130 datafiles = [('data', docdirbase, docfiles),
129 datafiles = [('data', docdirbase, docfiles),
131 ('data', os.path.join(docdirbase, 'examples'),
130 ('data', os.path.join(docdirbase, 'examples'),
132 examfiles),
131 examfiles),
133 ('data', os.path.join(docdirbase, 'manual'),
132 ('data', os.path.join(docdirbase, 'manual'),
134 manfiles),
133 manfiles),
135 ('data', manpagebase, manpages),
134 ('data', manpagebase, manpages),
136 ('lib', 'IPython/UserConfig', cfgfiles),
135 ('lib', 'IPython/UserConfig', cfgfiles),
137 ('data','IPython/Extensions', igridhelpfiles)]
136 ('data','IPython/Extensions', igridhelpfiles)]
138 if 'setuptools' in sys.modules:
137 if 'setuptools' in sys.modules:
139 # setuptools config for egg building
138 # setuptools config for egg building
140 egg_extra_kwds = {
139 egg_extra_kwds = {
141 'entry_points': {
140 'entry_points': {
142 'console_scripts': [
141 'console_scripts': [
143 'ipython = IPython.ipapi:launch_new_instance',
142 'ipython = IPython.ipapi:launch_new_instance',
144 'pycolor = IPython.PyColorize:main'
143 'pycolor = IPython.PyColorize:main'
145 ]}
144 ]}
146 }
145 }
147 scriptfiles = []
146 scriptfiles = []
148 # eggs will lack docs, examples XXX not anymore
147 # eggs will lack docs, examples XXX not anymore
149 #datafiles = [('lib', 'IPython/UserConfig', cfgfiles)]
148 #datafiles = [('lib', 'IPython/UserConfig', cfgfiles)]
150 else:
149 else:
151 egg_extra_kwds = {}
150 egg_extra_kwds = {}
152
151
153
152
154 # Call the setup() routine which does most of the work
153 # Call the setup() routine which does most of the work
155 setup(name = name,
154 setup(name = name,
156 version = version,
155 version = version,
157 description = description,
156 description = description,
158 long_description = long_description,
157 long_description = long_description,
159 author = authors['Fernando'][0],
158 author = authors['Fernando'][0],
160 author_email = authors['Fernando'][1],
159 author_email = authors['Fernando'][1],
161 url = url,
160 url = url,
162 download_url = download_url,
161 download_url = download_url,
163 license = license,
162 license = license,
164 platforms = platforms,
163 platforms = platforms,
165 keywords = keywords,
164 keywords = keywords,
166 packages = ['IPython', 'IPython.Extensions', 'IPython.external'],
165 packages = ['IPython', 'IPython.Extensions', 'IPython.external'],
167 scripts = scriptfiles,
166 scripts = scriptfiles,
168
167
169 cmdclass = {'install_data': install_data_ext},
168 cmdclass = {'install_data': install_data_ext},
170 data_files = datafiles,
169 data_files = datafiles,
171 # extra params needed for eggs
170 # extra params needed for eggs
172 **egg_extra_kwds
171 **egg_extra_kwds
173 )
172 )
@@ -1,136 +1,141 b''
1 #!python
1 #!python
2 """Windows-specific part of the installation"""
2 """Windows-specific part of the installation"""
3
3
4 import os, sys
4 import os, sys
5
5
6 try:
6 try:
7 import shutil,pythoncom
7 import shutil,pythoncom
8 from win32com.shell import shell
8 from win32com.shell import shell
9 import _winreg as wreg
9 import _winreg as wreg
10 except ImportError:
10 except ImportError:
11 print """
11 print """
12 You seem to be missing the PythonWin extensions necessary for automatic
12 You seem to be missing the PythonWin extensions necessary for automatic
13 installation. You can get them (free) from
13 installation. You can get them (free) from
14 http://starship.python.net/crew/mhammond/
14 http://starship.python.net/crew/mhammond/
15
15
16 Please see the manual for details if you want to finish the installation by
16 Please see the manual for details if you want to finish the installation by
17 hand, or get PythonWin and repeat the procedure.
17 hand, or get PythonWin and repeat the procedure.
18
18
19 Press <Enter> to exit this installer."""
19 Press <Enter> to exit this installer."""
20 raw_input()
20 raw_input()
21 sys.exit()
21 sys.exit()
22
22
23
23
24 def make_shortcut(fname,target,args='',start_in='',comment='',icon=None):
24 def make_shortcut(fname,target,args='',start_in='',comment='',icon=None):
25 """Make a Windows shortcut (.lnk) file.
25 """Make a Windows shortcut (.lnk) file.
26
26
27 make_shortcut(fname,target,args='',start_in='',comment='',icon=None)
27 make_shortcut(fname,target,args='',start_in='',comment='',icon=None)
28
28
29 Arguments:
29 Arguments:
30 fname - name of the final shortcut file (include the .lnk)
30 fname - name of the final shortcut file (include the .lnk)
31 target - what the shortcut will point to
31 target - what the shortcut will point to
32 args - additional arguments to pass to the target program
32 args - additional arguments to pass to the target program
33 start_in - directory where the target command will be called
33 start_in - directory where the target command will be called
34 comment - for the popup tooltips
34 comment - for the popup tooltips
35 icon - optional icon file. This must be a tuple of the type
35 icon - optional icon file. This must be a tuple of the type
36 (icon_file,index), where index is the index of the icon you want
36 (icon_file,index), where index is the index of the icon you want
37 in the file. For single .ico files, index=0, but for icon libraries
37 in the file. For single .ico files, index=0, but for icon libraries
38 contained in a single file it can be >0.
38 contained in a single file it can be >0.
39 """
39 """
40
40
41 shortcut = pythoncom.CoCreateInstance(
41 shortcut = pythoncom.CoCreateInstance(
42 shell.CLSID_ShellLink, None,
42 shell.CLSID_ShellLink, None,
43 pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink
43 pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink
44 )
44 )
45 shortcut.SetPath(target)
45 shortcut.SetPath(target)
46 shortcut.SetArguments(args)
46 shortcut.SetArguments(args)
47 shortcut.SetWorkingDirectory(start_in)
47 shortcut.SetWorkingDirectory(start_in)
48 shortcut.SetDescription(comment)
48 shortcut.SetDescription(comment)
49 if icon:
49 if icon:
50 shortcut.SetIconLocation(*icon)
50 shortcut.SetIconLocation(*icon)
51 shortcut.QueryInterface(pythoncom.IID_IPersistFile).Save(fname,0)
51 shortcut.QueryInterface(pythoncom.IID_IPersistFile).Save(fname,0)
52
52
53
53
54 def run(wait=0):
54 def run(wait=0):
55 # Find where the Start Menu and My Documents are on the filesystem
55 # Find where the Start Menu and My Documents are on the filesystem
56 key = wreg.OpenKey(wreg.HKEY_CURRENT_USER,
56 key = wreg.OpenKey(wreg.HKEY_CURRENT_USER,
57 r'Software\Microsoft\Windows\CurrentVersion'
57 r'Software\Microsoft\Windows\CurrentVersion'
58 r'\Explorer\Shell Folders')
58 r'\Explorer\Shell Folders')
59
59
60 programs_dir = wreg.QueryValueEx(key,'Programs')[0]
60 programs_dir = wreg.QueryValueEx(key,'Programs')[0]
61 my_documents_dir = wreg.QueryValueEx(key,'Personal')[0]
61 my_documents_dir = wreg.QueryValueEx(key,'Personal')[0]
62 key.Close()
62 key.Close()
63
63
64 # Find where the 'program files' directory is
64 # Find where the 'program files' directory is
65 key = wreg.OpenKey(wreg.HKEY_LOCAL_MACHINE,
65 key = wreg.OpenKey(wreg.HKEY_LOCAL_MACHINE,
66 r'SOFTWARE\Microsoft\Windows\CurrentVersion')
66 r'SOFTWARE\Microsoft\Windows\CurrentVersion')
67
67
68 program_files_dir = wreg.QueryValueEx(key,'ProgramFilesDir')[0]
68 program_files_dir = wreg.QueryValueEx(key,'ProgramFilesDir')[0]
69 key.Close()
69 key.Close()
70
70
71
71
72 # File and directory names
72 # File and directory names
73 ip_dir = program_files_dir + r'\IPython'
73 ip_dir = program_files_dir + r'\IPython'
74 ip_prog_dir = programs_dir + r'\IPython'
74 ip_prog_dir = programs_dir + r'\IPython'
75 doc_dir = ip_dir+r'\doc'
75 doc_dir = ip_dir+r'\doc'
76 ip_filename = ip_dir+r'\IPython_shell.py'
76 ip_filename = ip_dir+r'\IPython_shell.py'
77 pycon_icon = doc_dir+r'\pycon.ico'
77 pycon_icon = doc_dir+r'\pycon.ico'
78
78
79 if not os.path.isdir(ip_dir):
79 if not os.path.isdir(ip_dir):
80 os.mkdir(ip_dir)
80 os.mkdir(ip_dir)
81
81
82 # Copy startup script and documentation
82 # Copy startup script and documentation
83 shutil.copy(sys.prefix+r'\Scripts\ipython',ip_filename)
83 shutil.copy(sys.prefix+r'\Scripts\ipython',ip_filename)
84 if os.path.isdir(doc_dir):
84 if os.path.isdir(doc_dir):
85 shutil.rmtree(doc_dir)
85 shutil.rmtree(doc_dir)
86 shutil.copytree('doc',doc_dir)
86 shutil.copytree('doc',doc_dir)
87
87
88 # make shortcuts for IPython, html and pdf docs.
88 # make shortcuts for IPython, html and pdf docs.
89 print 'Making entries for IPython in Start Menu...',
89 print 'Making entries for IPython in Start Menu...',
90
90
91 # Create .bat file in \Scripts
91 # Create .bat file in \Scripts
92 fic = open(sys.prefix + r'\Scripts\ipython.bat','w')
92 fic = open(sys.prefix + r'\Scripts\ipython.bat','w')
93 fic.write('"' + sys.prefix + r'\python.exe' + '" -i ' + '"' +
93 fic.write('"' + sys.prefix + r'\python.exe' + '" -i ' + '"' +
94 sys.prefix + r'\Scripts\ipython" %*')
94 sys.prefix + r'\Scripts\ipython" %*')
95 fic.close()
95 fic.close()
96
96
97 # Create .bat file in \\Scripts
98 fic = open(sys.prefix + '\\Scripts\\ipython.bat','w')
99 fic.write('"' + sys.prefix + '\\python.exe' + '" -i ' + '"' + sys.prefix + '\\Scripts\ipython" %*')
100 fic.close()
101
97 # Create shortcuts in Programs\IPython:
102 # Create shortcuts in Programs\IPython:
98 if not os.path.isdir(ip_prog_dir):
103 if not os.path.isdir(ip_prog_dir):
99 os.mkdir(ip_prog_dir)
104 os.mkdir(ip_prog_dir)
100 os.chdir(ip_prog_dir)
105 os.chdir(ip_prog_dir)
101
106
102 man_pdf = doc_dir + r'\manual.pdf'
107 man_pdf = doc_dir + r'\manual.pdf'
103 man_htm = doc_dir + r'\manual\manual.html'
108 man_htm = doc_dir + r'\manual\manual.html'
104
109
105 make_shortcut('IPython.lnk',sys.executable, '"%s"' % ip_filename,
110 make_shortcut('IPython.lnk',sys.executable, '"%s"' % ip_filename,
106 my_documents_dir,
111 my_documents_dir,
107 'IPython - Enhanced python command line interpreter',
112 'IPython - Enhanced python command line interpreter',
108 (pycon_icon,0))
113 (pycon_icon,0))
109 make_shortcut('pysh.lnk',sys.executable, '"%s" -p pysh' % ip_filename,
114 make_shortcut('pysh.lnk',sys.executable, '"%s" -p pysh' % ip_filename,
110 my_documents_dir,
115 my_documents_dir,
111 'pysh - a system shell with Python syntax (IPython based)',
116 'pysh - a system shell with Python syntax (IPython based)',
112 (pycon_icon,0))
117 (pycon_icon,0))
113 make_shortcut('Manual in HTML format.lnk',man_htm,'','',
118 make_shortcut('Manual in HTML format.lnk',man_htm,'','',
114 'IPython Manual - HTML format')
119 'IPython Manual - HTML format')
115 make_shortcut('Manual in PDF format.lnk',man_pdf,'','',
120 make_shortcut('Manual in PDF format.lnk',man_pdf,'','',
116 'IPython Manual - PDF format')
121 'IPython Manual - PDF format')
117
122
118 print """Done.
123 print """Done.
119
124
120 I created the directory %s. There you will find the
125 I created the directory %s. There you will find the
121 IPython startup script and manuals.
126 IPython startup script and manuals.
122
127
123 An IPython menu was also created in your Start Menu, with entries for
128 An IPython menu was also created in your Start Menu, with entries for
124 IPython itself and the manual in HTML and PDF formats.
129 IPython itself and the manual in HTML and PDF formats.
125
130
126 For reading PDF documents you need the freely available Adobe Acrobat
131 For reading PDF documents you need the freely available Adobe Acrobat
127 Reader. If you don't have it, you can download it from:
132 Reader. If you don't have it, you can download it from:
128 http://www.adobe.com/products/acrobat/readstep2.html
133 http://www.adobe.com/products/acrobat/readstep2.html
129 """ % ip_dir
134 """ % ip_dir
130
135
131 if wait:
136 if wait:
132 print "Finished with IPython installation. Press Enter to exit this installer.",
137 print "Finished with IPython installation. Press Enter to exit this installer.",
133 raw_input()
138 raw_input()
134
139
135 if __name__ == '__main__':
140 if __name__ == '__main__':
136 run()
141 run()
General Comments 0
You need to be logged in to leave comments. Login now